Mercurial > projects > dstep
annotate dstep/foundation/NSUserDefaults.d @ 25:b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Tue, 06 Apr 2010 11:37:27 +0200 |
parents | 19885b43130e |
children |
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.NSUserDefaults; | |
8 | |
9 import dstep.foundation.NSArray; | |
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; |
14 import dstep.foundation.NSString; | |
15 import dstep.objc.bridge.Bridge; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
16 import dstep.objc.objc; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
17 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
18 |
14 | 19 |
20 import bindings = dstep.foundation.NSUserDefaults_bindings; | |
21 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
22 private |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
23 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
24 NSString NSGlobalDomain_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
25 NSString NSArgumentDomain_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
26 NSString NSRegistrationDomain_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
27 NSString NSUserDefaultsDidChangeNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
28 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
29 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
30 NSString NSGlobalDomain () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
31 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
32 if (NSGlobalDomain_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
33 return NSGlobalDomain_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
34 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
35 return NSGlobalDomain_ = new NSString(bindings.NSGlobalDomain); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
36 } |
14 | 37 |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
38 NSString NSArgumentDomain () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
39 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
40 if (NSArgumentDomain_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
41 return NSArgumentDomain_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
42 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
43 return NSArgumentDomain_ = new NSString(bindings.NSArgumentDomain); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
44 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
45 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
46 NSString NSRegistrationDomain () |
14 | 47 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
48 if (NSRegistrationDomain_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
49 return NSRegistrationDomain_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
50 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
51 return NSRegistrationDomain_ = new NSString(bindings.NSRegistrationDomain); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
52 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
53 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
54 NSString NSUserDefaultsDidChangeNotification () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
55 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
56 if (NSUserDefaultsDidChangeNotification_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
57 return NSUserDefaultsDidChangeNotification_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
58 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
59 return NSUserDefaultsDidChangeNotification_ = new NSString(bindings.NSUserDefaultsDidChangeNotification); |
14 | 60 } |
61 | |
62 class NSUserDefaults : NSObject | |
63 { | |
25
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
64 mixin ObjcWrap; |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
65 |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
66 this (id object) |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
67 { |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
68 super(object); |
b9de51448c6b
Added an id constructor. Changed the string mixin to a template mixin. Added support for building as a dynamic library
Jacob Carlborg <doob@me.com>
parents:
16
diff
changeset
|
69 } |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
70 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
71 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
72 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
73 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
74 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
75 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
76 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
77 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
78 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
79 } |
14 | 80 |
81 static NSUserDefaults standardUserDefaults () | |
82 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
83 return invokeObjcSuperClass!(NSUserDefaults, "standardUserDefaults"); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
84 } |
14 | 85 |
86 static void resetStandardUserDefaults () | |
87 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
88 return invokeObjcSuperClass!(void, "resetStandardUserDefaults"); |
14 | 89 } |
90 | |
91 Object initWithUser (NSString username) | |
92 { | |
93 return invokeObjcSelf!(Object, "initWithUser:", NSString)(username); | |
94 } | |
95 | |
96 this (NSString username) | |
97 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
98 typeof(this).alloc.initWithUser(username); |
14 | 99 } |
100 | |
101 Object objectForKey (NSString defaultName) | |
102 { | |
103 return invokeObjcSelf!(Object, "objectForKey:", NSString)(defaultName); | |
104 } | |
105 | |
106 void setObject (Object value, NSString defaultName) | |
107 { | |
108 return invokeObjcSelf!(void, "setObject:forKey:", Object, NSString)(value, defaultName); | |
109 } | |
110 | |
111 void removeObjectForKey (NSString defaultName) | |
112 { | |
113 return invokeObjcSelf!(void, "removeObjectForKey:", NSString)(defaultName); | |
114 } | |
115 | |
116 NSString stringForKey (NSString defaultName) | |
117 { | |
118 return invokeObjcSelf!(NSString, "stringForKey:", NSString)(defaultName); | |
119 } | |
120 | |
121 NSArray arrayForKey (NSString defaultName) | |
122 { | |
123 return invokeObjcSelf!(NSArray, "arrayForKey:", NSString)(defaultName); | |
124 } | |
125 | |
126 NSDictionary dictionaryForKey (NSString defaultName) | |
127 { | |
128 return invokeObjcSelf!(NSDictionary, "dictionaryForKey:", NSString)(defaultName); | |
129 } | |
130 | |
131 NSData dataForKey (NSString defaultName) | |
132 { | |
133 return invokeObjcSelf!(NSData, "dataForKey:", NSString)(defaultName); | |
134 } | |
135 | |
136 NSArray stringArrayForKey (NSString defaultName) | |
137 { | |
138 return invokeObjcSelf!(NSArray, "stringArrayForKey:", NSString)(defaultName); | |
139 } | |
140 | |
141 NSInteger integerForKey (NSString defaultName) | |
142 { | |
143 return invokeObjcSelf!(NSInteger, "integerForKey:", NSString)(defaultName); | |
144 } | |
145 | |
146 float floatForKey (NSString defaultName) | |
147 { | |
148 return invokeObjcSelf!(float, "floatForKey:", NSString)(defaultName); | |
149 } | |
150 | |
151 double doubleForKey (NSString defaultName) | |
152 { | |
153 return invokeObjcSelf!(double, "doubleForKey:", NSString)(defaultName); | |
154 } | |
155 | |
156 bool boolForKey (NSString defaultName) | |
157 { | |
158 return invokeObjcSelf!(bool, "boolForKey:", NSString)(defaultName); | |
159 } | |
160 | |
161 void setInteger (NSInteger value, NSString defaultName) | |
162 { | |
163 return invokeObjcSelf!(void, "setInteger:forKey:", NSInteger, NSString)(value, defaultName); | |
164 } | |
165 | |
166 void setFloat (float value, NSString defaultName) | |
167 { | |
168 return invokeObjcSelf!(void, "setFloat:forKey:", float, NSString)(value, defaultName); | |
169 } | |
170 | |
171 void setDouble (double value, NSString defaultName) | |
172 { | |
173 return invokeObjcSelf!(void, "setDouble:forKey:", double, NSString)(value, defaultName); | |
174 } | |
175 | |
176 void setBool (bool value, NSString defaultName) | |
177 { | |
178 return invokeObjcSelf!(void, "setBool:forKey:", bool, NSString)(value, defaultName); | |
179 } | |
180 | |
181 void registerDefaults (NSDictionary registrationDictionary) | |
182 { | |
183 return invokeObjcSelf!(void, "registerDefaults:", NSDictionary)(registrationDictionary); | |
184 } | |
185 | |
186 void addSuiteNamed (NSString suiteName) | |
187 { | |
188 return invokeObjcSelf!(void, "addSuiteNamed:", NSString)(suiteName); | |
189 } | |
190 | |
191 void removeSuiteNamed (NSString suiteName) | |
192 { | |
193 return invokeObjcSelf!(void, "removeSuiteNamed:", NSString)(suiteName); | |
194 } | |
195 | |
196 NSDictionary dictionaryRepresentation () | |
197 { | |
198 return invokeObjcSelf!(NSDictionary, "dictionaryRepresentation"); | |
199 } | |
200 | |
201 NSArray volatileDomainNames () | |
202 { | |
203 return invokeObjcSelf!(NSArray, "volatileDomainNames"); | |
204 } | |
205 | |
206 NSDictionary volatileDomainForName (NSString domainName) | |
207 { | |
208 return invokeObjcSelf!(NSDictionary, "volatileDomainForName:", NSString)(domainName); | |
209 } | |
210 | |
211 void setVolatileDomain (NSDictionary domain, NSString domainName) | |
212 { | |
213 return invokeObjcSelf!(void, "setVolatileDomain:forName:", NSDictionary, NSString)(domain, domainName); | |
214 } | |
215 | |
216 void removeVolatileDomainForName (NSString domainName) | |
217 { | |
218 return invokeObjcSelf!(void, "removeVolatileDomainForName:", NSString)(domainName); | |
219 } | |
220 | |
221 NSArray persistentDomainNames () | |
222 { | |
223 return invokeObjcSelf!(NSArray, "persistentDomainNames"); | |
224 } | |
225 | |
226 NSDictionary persistentDomainForName (NSString domainName) | |
227 { | |
228 return invokeObjcSelf!(NSDictionary, "persistentDomainForName:", NSString)(domainName); | |
229 } | |
230 | |
231 void setPersistentDomain (NSDictionary domain, NSString domainName) | |
232 { | |
233 return invokeObjcSelf!(void, "setPersistentDomain:forName:", NSDictionary, NSString)(domain, domainName); | |
234 } | |
235 | |
236 void removePersistentDomainForName (NSString domainName) | |
237 { | |
238 return invokeObjcSelf!(void, "removePersistentDomainForName:", NSString)(domainName); | |
239 } | |
240 | |
241 bool synchronize () | |
242 { | |
243 return invokeObjcSelf!(bool, "synchronize"); | |
244 } | |
245 | |
246 bool objectIsForcedForKey (NSString key) | |
247 { | |
248 return invokeObjcSelf!(bool, "objectIsForcedForKey:", NSString)(key); | |
249 } | |
250 | |
251 bool objectIsForcedForKey (NSString key, NSString domain) | |
252 { | |
253 return invokeObjcSelf!(bool, "objectIsForcedForKey:inDomain:", NSString, NSString)(key, domain); | |
254 } | |
255 } | |
256 |