Mercurial > projects > dstep
annotate 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 |
rev | line source |
---|---|
14 | 1 /** |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSURLCache; | |
8 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
9 import dstep.foundation.NSCoder; |
14 | 10 import dstep.foundation.NSData; |
11 import dstep.foundation.NSDictionary; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
12 import dstep.foundation.NSObjCRuntime; |
14 | 13 import dstep.foundation.NSObject; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
14 import dstep.foundation.NSString; |
14 | 15 import dstep.foundation.NSURLRequest; |
16 import dstep.foundation.NSURLResponse; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
17 import dstep.foundation.NSZone; |
14 | 18 import dstep.objc.bridge.Bridge; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
19 import dstep.objc.objc; |
14 | 20 |
21 alias NSUInteger NSURLCacheStoragePolicy; | |
22 | |
23 enum | |
24 { | |
25 NSURLCacheStorageAllowed, | |
26 NSURLCacheStorageAllowedInMemoryOnly, | |
27 NSURLCacheStorageNotAllowed | |
28 } | |
29 | |
30 class NSCachedURLResponse : NSObject, INSCoding, INSCopying | |
31 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
32 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
33 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
34 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
35 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
36 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
37 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
38 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
39 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
40 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
41 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
42 } |
14 | 43 |
44 Object initWithResponse (NSURLResponse response, NSData data) | |
45 { | |
46 return invokeObjcSelf!(Object, "initWithResponse:data:", NSURLResponse, NSData)(response, data); | |
47 } | |
48 | |
49 this (NSURLResponse response, NSData data) | |
50 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
51 typeof(this).alloc.initWithResponse(response, data); |
14 | 52 } |
53 | |
54 Object initWithResponse (NSURLResponse response, NSData data, NSDictionary userInfo, uint storagePolicy) | |
55 { | |
56 return invokeObjcSelf!(Object, "initWithResponse:data:userInfo:storagePolicy:", NSURLResponse, NSData, NSDictionary, uint)(response, data, userInfo, storagePolicy); | |
57 } | |
58 | |
59 this (NSURLResponse response, NSData data, NSDictionary userInfo, uint storagePolicy) | |
60 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
61 typeof(this).alloc.initWithResponse(response, data, userInfo, storagePolicy); |
14 | 62 } |
63 | |
64 NSURLResponse response () | |
65 { | |
66 return invokeObjcSelf!(NSURLResponse, "response"); | |
67 } | |
68 | |
69 NSData data () | |
70 { | |
71 return invokeObjcSelf!(NSData, "data"); | |
72 } | |
73 | |
74 NSDictionary userInfo () | |
75 { | |
76 return invokeObjcSelf!(NSDictionary, "userInfo"); | |
77 } | |
78 | |
79 uint storagePolicy () | |
80 { | |
81 return invokeObjcSelf!(uint, "storagePolicy"); | |
82 } | |
83 | |
84 void encodeWithCoder (NSCoder aCoder) | |
85 { | |
86 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
87 } | |
88 | |
89 Object initWithCoder (NSCoder aDecoder) | |
90 { | |
91 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
92 } | |
93 | |
94 this (NSCoder aDecoder) | |
95 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
96 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 97 } |
98 | |
99 Object copyWithZone (NSZone* zone) | |
100 { | |
101 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
102 } | |
103 } | |
104 | |
105 class NSURLCache : NSObject | |
106 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
107 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
108 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
109 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
110 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
111 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
112 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
113 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
114 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
115 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
116 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
117 } |
14 | 118 |
119 static NSURLCache sharedURLCache () | |
120 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
121 return invokeObjcSuperClass!(NSURLCache, "sharedURLCache"); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
122 } |
14 | 123 |
124 static void setSharedURLCache (NSURLCache cache) | |
125 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
126 return invokeObjcSuperClass!(void, "setSharedURLCache:", NSURLCache)(cache); |
14 | 127 } |
128 | |
129 Object initWithMemoryCapacity (NSUInteger memoryCapacity, NSUInteger diskCapacity, NSString path) | |
130 { | |
131 return invokeObjcSelf!(Object, "initWithMemoryCapacity:diskCapacity:diskPath:", NSUInteger, NSUInteger, NSString)(memoryCapacity, diskCapacity, path); | |
132 } | |
133 | |
134 this (NSUInteger memoryCapacity, NSUInteger diskCapacity, NSString path) | |
135 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
136 typeof(this).alloc.initWithMemoryCapacity(memoryCapacity, diskCapacity, path); |
14 | 137 } |
138 | |
139 NSCachedURLResponse cachedResponseForRequest (NSURLRequest request) | |
140 { | |
141 return invokeObjcSelf!(NSCachedURLResponse, "cachedResponseForRequest:", NSURLRequest)(request); | |
142 } | |
143 | |
144 void storeCachedResponse (NSCachedURLResponse cachedResponse, NSURLRequest request) | |
145 { | |
146 return invokeObjcSelf!(void, "storeCachedResponse:forRequest:", NSCachedURLResponse, NSURLRequest)(cachedResponse, request); | |
147 } | |
148 | |
149 void removeCachedResponseForRequest (NSURLRequest request) | |
150 { | |
151 return invokeObjcSelf!(void, "removeCachedResponseForRequest:", NSURLRequest)(request); | |
152 } | |
153 | |
154 void removeAllCachedResponses () | |
155 { | |
156 return invokeObjcSelf!(void, "removeAllCachedResponses"); | |
157 } | |
158 | |
159 NSUInteger memoryCapacity () | |
160 { | |
161 return invokeObjcSelf!(NSUInteger, "memoryCapacity"); | |
162 } | |
163 | |
164 NSUInteger diskCapacity () | |
165 { | |
166 return invokeObjcSelf!(NSUInteger, "diskCapacity"); | |
167 } | |
168 | |
169 void setMemoryCapacity (NSUInteger memoryCapacity) | |
170 { | |
171 return invokeObjcSelf!(void, "setMemoryCapacity:", NSUInteger)(memoryCapacity); | |
172 } | |
173 | |
174 void setDiskCapacity (NSUInteger diskCapacity) | |
175 { | |
176 return invokeObjcSelf!(void, "setDiskCapacity:", NSUInteger)(diskCapacity); | |
177 } | |
178 | |
179 NSUInteger currentMemoryUsage () | |
180 { | |
181 return invokeObjcSelf!(NSUInteger, "currentMemoryUsage"); | |
182 } | |
183 | |
184 NSUInteger currentDiskUsage () | |
185 { | |
186 return invokeObjcSelf!(NSUInteger, "currentDiskUsage"); | |
187 } | |
188 } | |
189 |