comparison dstep/foundation/NSURLHandle.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents 7ff919f595d5
children b9de51448c6b
comparison
equal deleted inserted replaced
15:7ff919f595d5 16:19885b43130e
4 * Version: Initial created: Aug 3, 2009 4 * Version: Initial created: Aug 3, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */ 6 */
7 module dstep.foundation.NSURLHandle; 7 module dstep.foundation.NSURLHandle;
8 8
9 import dstep.foundation.NSData;
10 import dstep.foundation.NSObjCRuntime;
9 import dstep.foundation.NSObject; 11 import dstep.foundation.NSObject;
12 import dstep.foundation.NSString;
13 import dstep.foundation.NSURL;
14 import dstep.internal.Version;
10 import dstep.objc.bridge.Bridge; 15 import dstep.objc.bridge.Bridge;
11 import dstep.objc.objc : id; 16 import dstep.objc.objc;
12 17
13 alias NSUInteger NSURLHandleStatus; 18 alias NSUInteger NSURLHandleStatus;
14 19
15 enum 20 enum
16 { 21 {
20 NSURLHandleLoadFailed 25 NSURLHandleLoadFailed
21 } 26 }
22 27
23 class NSURLHandle : NSObject 28 class NSURLHandle : NSObject
24 { 29 {
25 mixin ObjcWrap; 30 mixin (ObjcWrap);
31
32 this ()
33 {
34 super(typeof(this).alloc.init.objcObject);
35 }
36
37 typeof(this) init ()
38 {
39 return invokeObjcSelf!(typeof(this), "init");
40 }
26 41
27 static void registerURLHandleClass (Class anURLHandleSubclass) 42 static void registerURLHandleClass (Class anURLHandleSubclass)
28 { 43 {
29 return invokeObjcSelfClass!(void, "registerURLHandleClass:", Class)(anURLHandleSubclass); 44 return invokeObjcSuperClass!(void, "registerURLHandleClass:", Class)(anURLHandleSubclass);
30 } 45 }
31 46
32 static Class URLHandleClassForURL (NSURL anURL) 47 static Class URLHandleClassForURL (NSURL anURL)
33 { 48 {
34 return invokeObjcSelfClass!(Class, "URLHandleClassForURL:", NSURL)(anURL); 49 return invokeObjcSuperClass!(Class, "URLHandleClassForURL:", NSURL)(anURL);
35 } 50 }
36 51
37 uint status () 52 uint status ()
38 { 53 {
39 return invokeObjcSelf!(uint, "status"); 54 return invokeObjcSelf!(uint, "status");
94 return invokeObjcSelf!(void, "didLoadBytes:loadComplete:", NSData, bool)(newBytes, yorn); 109 return invokeObjcSelf!(void, "didLoadBytes:loadComplete:", NSData, bool)(newBytes, yorn);
95 } 110 }
96 111
97 static bool canInitWithURL (NSURL anURL) 112 static bool canInitWithURL (NSURL anURL)
98 { 113 {
99 return invokeObjcSelfClass!(bool, "canInitWithURL:", NSURL)(anURL); 114 return invokeObjcSuperClass!(bool, "canInitWithURL:", NSURL)(anURL);
100 } 115 }
101 116
102 static NSURLHandle cachedHandleForURL (NSURL anURL) 117 static NSURLHandle cachedHandleForURL (NSURL anURL)
103 { 118 {
104 return invokeObjcSelfClass!(NSURLHandle, "cachedHandleForURL:", NSURL)(anURL); 119 return invokeObjcSuperClass!(NSURLHandle, "cachedHandleForURL:", NSURL)(anURL);
105 } 120 }
106 121
107 Object initWithURL (NSURL anURL, bool willCache) 122 Object initWithURL (NSURL anURL, bool willCache)
108 { 123 {
109 return invokeObjcSelf!(Object, "initWithURL:cached:", NSURL, bool)(anURL, willCache); 124 return invokeObjcSelf!(Object, "initWithURL:cached:", NSURL, bool)(anURL, willCache);
110 } 125 }
111 126
112 this (NSURL anURL, bool willCache) 127 this (NSURL anURL, bool willCache)
113 { 128 {
114 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 129 typeof(this).alloc.initWithURL(anURL, willCache);
115 id result = Bridge.invokeObjcMethod!(id, "initWithURL:cached:", NSURL, bool)(objcObject, anURL, willCache);
116
117 if (result)
118 objcObject = ret;
119
120 dObject = this;
121 } 130 }
122 131
123 Object propertyForKey (NSString propertyKey) 132 Object propertyForKey (NSString propertyKey)
124 { 133 {
125 return invokeObjcSelf!(Object, "propertyForKey:", NSString)(propertyKey); 134 return invokeObjcSelf!(Object, "propertyForKey:", NSString)(propertyKey);