comparison dstep/foundation/NSURLResponse.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 89f3c3ef1fd2
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.NSURLResponse; 7 module dstep.foundation.NSURLResponse;
8 8
9 import dstep.AvailabilityMacros; 9 import dstep.foundation.NSCoder;
10 import dstep.foundation.NSDictionary; 10 import dstep.foundation.NSDictionary;
11 import dstep.foundation.NSHTTPURLResponseInternal; 11 import dstep.foundation.NSObjCRuntime;
12 import dstep.foundation.NSObject; 12 import dstep.foundation.NSObject;
13 import dstep.foundation.NSString; 13 import dstep.foundation.NSString;
14 import dstep.foundation.NSURL; 14 import dstep.foundation.NSURL;
15 import dstep.foundation.NSURLRequest; 15 import dstep.foundation.NSURLRequest;
16 import dstep.foundation.NSURLResponseInternal; 16 import dstep.foundation.NSZone;
17 import dstep.objc.bridge.Bridge; 17 import dstep.objc.bridge.Bridge;
18 import dstep.objc.objc : id; 18 import dstep.objc.objc;
19 19
20 class NSHTTPURLResponse : NSURLResponse 20 class NSHTTPURLResponse : NSURLResponse
21 { 21 {
22 mixin ObjcWrap; 22 mixin (ObjcWrap);
23
24 this ()
25 {
26 super(typeof(this).alloc.init.objcObject);
27 }
28
29 typeof(this) init ()
30 {
31 return invokeObjcSelf!(typeof(this), "init");
32 }
23 33
24 NSInteger statusCode () 34 NSInteger statusCode ()
25 { 35 {
26 return invokeObjcSelf!(NSInteger, "statusCode"); 36 return invokeObjcSelf!(NSInteger, "statusCode");
27 } 37 }
31 return invokeObjcSelf!(NSDictionary, "allHeaderFields"); 41 return invokeObjcSelf!(NSDictionary, "allHeaderFields");
32 } 42 }
33 43
34 static NSString localizedStringForStatusCode (NSInteger statusCode) 44 static NSString localizedStringForStatusCode (NSInteger statusCode)
35 { 45 {
36 return invokeObjcSelfClass!(NSString, "localizedStringForStatusCode:", NSInteger)(statusCode); 46 return invokeObjcSuperClass!(NSString, "localizedStringForStatusCode:", NSInteger)(statusCode);
37 } 47 }
38 } 48 }
39 49
40 class NSURLResponse : NSObject, INSCoding, INSCopying 50 class NSURLResponse : NSObject, INSCoding, INSCopying
41 { 51 {
42 mixin ObjcWrap; 52 mixin (ObjcWrap);
53
54 this ()
55 {
56 super(typeof(this).alloc.init.objcObject);
57 }
58
59 typeof(this) init ()
60 {
61 return invokeObjcSelf!(typeof(this), "init");
62 }
43 63
44 Object initWithURL (NSURL URL, NSString MIMEType, NSInteger length, NSString name) 64 Object initWithURL (NSURL URL, NSString MIMEType, NSInteger length, NSString name)
45 { 65 {
46 return invokeObjcSelf!(Object, "initWithURL:MIMEType:expectedContentLength:textEncodingName:", NSURL, NSString, NSInteger, NSString)(URL, MIMEType, length, name); 66 return invokeObjcSelf!(Object, "initWithURL:MIMEType:expectedContentLength:textEncodingName:", NSURL, NSString, NSInteger, NSString)(URL, MIMEType, length, name);
47 } 67 }
48 68
49 this (NSURL URL, NSString MIMEType, NSInteger length, NSString name) 69 this (NSURL URL, NSString MIMEType, NSInteger length, NSString name)
50 { 70 {
51 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 71 typeof(this).alloc.initWithURL(URL, MIMEType, length, name);
52 id result = Bridge.invokeObjcMethod!(id, "initWithURL:MIMEType:expectedContentLength:textEncodingName:", NSURL, NSString, NSInteger, NSString)(objcObject, URL, MIMEType, length, name);
53
54 if (result)
55 objcObject = ret;
56
57 dObject = this;
58 } 72 }
59 73
60 NSURL URL () 74 NSURL URL ()
61 { 75 {
62 return invokeObjcSelf!(NSURL, "URL"); 76 return invokeObjcSelf!(NSURL, "URL");
92 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); 106 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
93 } 107 }
94 108
95 this (NSCoder aDecoder) 109 this (NSCoder aDecoder)
96 { 110 {
97 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); 111 typeof(this).alloc.initWithCoder(aDecoder);
98 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder);
99
100 if (result)
101 objcObject = ret;
102
103 dObject = this;
104 } 112 }
105 113
106 Object copyWithZone (NSZone* zone) 114 Object copyWithZone (NSZone* zone)
107 { 115 {
108 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); 116 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);