Mercurial > projects > dstep
comparison dstep/foundation/NSURLCache.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.NSURLCache; | 7 module dstep.foundation.NSURLCache; |
8 | 8 |
9 import dstep.AvailabilityMacros; | 9 import dstep.foundation.NSCoder; |
10 import dstep.foundation.NSCachedURLResponseInternal; | |
11 import dstep.foundation.NSData; | 10 import dstep.foundation.NSData; |
12 import dstep.foundation.NSDictionary; | 11 import dstep.foundation.NSDictionary; |
12 import dstep.foundation.NSObjCRuntime; | |
13 import dstep.foundation.NSObject; | 13 import dstep.foundation.NSObject; |
14 import dstep.foundation.NSURLCacheInternal; | 14 import dstep.foundation.NSString; |
15 import dstep.foundation.NSURLRequest; | 15 import dstep.foundation.NSURLRequest; |
16 import dstep.foundation.NSURLResponse; | 16 import dstep.foundation.NSURLResponse; |
17 import dstep.foundation.NSZone; | |
17 import dstep.objc.bridge.Bridge; | 18 import dstep.objc.bridge.Bridge; |
18 import dstep.objc.objc : id; | 19 import dstep.objc.objc; |
19 | 20 |
20 alias NSUInteger NSURLCacheStoragePolicy; | 21 alias NSUInteger NSURLCacheStoragePolicy; |
21 | 22 |
22 enum | 23 enum |
23 { | 24 { |
26 NSURLCacheStorageNotAllowed | 27 NSURLCacheStorageNotAllowed |
27 } | 28 } |
28 | 29 |
29 class NSCachedURLResponse : NSObject, INSCoding, INSCopying | 30 class NSCachedURLResponse : NSObject, INSCoding, INSCopying |
30 { | 31 { |
31 mixin ObjcWrap; | 32 mixin (ObjcWrap); |
33 | |
34 this () | |
35 { | |
36 super(typeof(this).alloc.init.objcObject); | |
37 } | |
38 | |
39 typeof(this) init () | |
40 { | |
41 return invokeObjcSelf!(typeof(this), "init"); | |
42 } | |
32 | 43 |
33 Object initWithResponse (NSURLResponse response, NSData data) | 44 Object initWithResponse (NSURLResponse response, NSData data) |
34 { | 45 { |
35 return invokeObjcSelf!(Object, "initWithResponse:data:", NSURLResponse, NSData)(response, data); | 46 return invokeObjcSelf!(Object, "initWithResponse:data:", NSURLResponse, NSData)(response, data); |
36 } | 47 } |
37 | 48 |
38 this (NSURLResponse response, NSData data) | 49 this (NSURLResponse response, NSData data) |
39 { | 50 { |
40 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 51 typeof(this).alloc.initWithResponse(response, data); |
41 id result = Bridge.invokeObjcMethod!(id, "initWithResponse:data:", NSURLResponse, NSData)(objcObject, response, data); | |
42 | |
43 if (result) | |
44 objcObject = ret; | |
45 | |
46 dObject = this; | |
47 } | 52 } |
48 | 53 |
49 Object initWithResponse (NSURLResponse response, NSData data, NSDictionary userInfo, uint storagePolicy) | 54 Object initWithResponse (NSURLResponse response, NSData data, NSDictionary userInfo, uint storagePolicy) |
50 { | 55 { |
51 return invokeObjcSelf!(Object, "initWithResponse:data:userInfo:storagePolicy:", NSURLResponse, NSData, NSDictionary, uint)(response, data, userInfo, storagePolicy); | 56 return invokeObjcSelf!(Object, "initWithResponse:data:userInfo:storagePolicy:", NSURLResponse, NSData, NSDictionary, uint)(response, data, userInfo, storagePolicy); |
52 } | 57 } |
53 | 58 |
54 this (NSURLResponse response, NSData data, NSDictionary userInfo, uint storagePolicy) | 59 this (NSURLResponse response, NSData data, NSDictionary userInfo, uint storagePolicy) |
55 { | 60 { |
56 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 61 typeof(this).alloc.initWithResponse(response, data, userInfo, storagePolicy); |
57 id result = Bridge.invokeObjcMethod!(id, "initWithResponse:data:userInfo:storagePolicy:", NSURLResponse, NSData, NSDictionary, uint)(objcObject, response, data, userInfo, storagePolicy); | |
58 | |
59 if (result) | |
60 objcObject = ret; | |
61 | |
62 dObject = this; | |
63 } | 62 } |
64 | 63 |
65 NSURLResponse response () | 64 NSURLResponse response () |
66 { | 65 { |
67 return invokeObjcSelf!(NSURLResponse, "response"); | 66 return invokeObjcSelf!(NSURLResponse, "response"); |
92 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | 91 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); |
93 } | 92 } |
94 | 93 |
95 this (NSCoder aDecoder) | 94 this (NSCoder aDecoder) |
96 { | 95 { |
97 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 96 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 } | 97 } |
105 | 98 |
106 Object copyWithZone (NSZone* zone) | 99 Object copyWithZone (NSZone* zone) |
107 { | 100 { |
108 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | 101 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); |
109 } | 102 } |
110 } | 103 } |
111 | 104 |
112 class NSURLCache : NSObject | 105 class NSURLCache : NSObject |
113 { | 106 { |
114 mixin ObjcWrap; | 107 mixin (ObjcWrap); |
108 | |
109 this () | |
110 { | |
111 super(typeof(this).alloc.init.objcObject); | |
112 } | |
113 | |
114 typeof(this) init () | |
115 { | |
116 return invokeObjcSelf!(typeof(this), "init"); | |
117 } | |
115 | 118 |
116 static NSURLCache sharedURLCache () | 119 static NSURLCache sharedURLCache () |
117 { | 120 { |
118 return invokeObjcSelfClass!(NSURLCache, "sharedURLCache"); | 121 return invokeObjcSuperClass!(NSURLCache, "sharedURLCache"); |
119 } | 122 } |
120 | 123 |
121 static void setSharedURLCache (NSURLCache cache) | 124 static void setSharedURLCache (NSURLCache cache) |
122 { | 125 { |
123 return invokeObjcSelfClass!(void, "setSharedURLCache:", NSURLCache)(cache); | 126 return invokeObjcSuperClass!(void, "setSharedURLCache:", NSURLCache)(cache); |
124 } | 127 } |
125 | 128 |
126 Object initWithMemoryCapacity (NSUInteger memoryCapacity, NSUInteger diskCapacity, NSString path) | 129 Object initWithMemoryCapacity (NSUInteger memoryCapacity, NSUInteger diskCapacity, NSString path) |
127 { | 130 { |
128 return invokeObjcSelf!(Object, "initWithMemoryCapacity:diskCapacity:diskPath:", NSUInteger, NSUInteger, NSString)(memoryCapacity, diskCapacity, path); | 131 return invokeObjcSelf!(Object, "initWithMemoryCapacity:diskCapacity:diskPath:", NSUInteger, NSUInteger, NSString)(memoryCapacity, diskCapacity, path); |
129 } | 132 } |
130 | 133 |
131 this (NSUInteger memoryCapacity, NSUInteger diskCapacity, NSString path) | 134 this (NSUInteger memoryCapacity, NSUInteger diskCapacity, NSString path) |
132 { | 135 { |
133 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 136 typeof(this).alloc.initWithMemoryCapacity(memoryCapacity, diskCapacity, path); |
134 id result = Bridge.invokeObjcMethod!(id, "initWithMemoryCapacity:diskCapacity:diskPath:", NSUInteger, NSUInteger, NSString)(objcObject, memoryCapacity, diskCapacity, path); | |
135 | |
136 if (result) | |
137 objcObject = ret; | |
138 | |
139 dObject = this; | |
140 } | 137 } |
141 | 138 |
142 NSCachedURLResponse cachedResponseForRequest (NSURLRequest request) | 139 NSCachedURLResponse cachedResponseForRequest (NSURLRequest request) |
143 { | 140 { |
144 return invokeObjcSelf!(NSCachedURLResponse, "cachedResponseForRequest:", NSURLRequest)(request); | 141 return invokeObjcSelf!(NSCachedURLResponse, "cachedResponseForRequest:", NSURLRequest)(request); |