comparison dstep/foundation/NSScanner.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
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.NSScanner; 7 module dstep.foundation.NSScanner;
8 8
9 import dstep.foundation.NSCharacterSet; 9 import dstep.foundation.NSCharacterSet;
10 import dstep.foundation.NSDecimal;
11 import dstep.foundation.NSDecimalNumber;
10 import dstep.foundation.NSDictionary; 12 import dstep.foundation.NSDictionary;
13 import dstep.foundation.NSObjCRuntime;
11 import dstep.foundation.NSObject; 14 import dstep.foundation.NSObject;
12 import dstep.foundation.NSString; 15 import dstep.foundation.NSString;
16 import dstep.foundation.NSZone;
17 import dstep.internal.Version;
13 import dstep.objc.bridge.Bridge; 18 import dstep.objc.bridge.Bridge;
14 import dstep.objc.objc : id; 19 import dstep.objc.objc;
20
21 const TNSExtendedScanner = `
22
23 NSCharacterSet charactersToBeSkipped ()
24 {
25 return invokeObjcSelf!(NSCharacterSet, "charactersToBeSkipped");
26 }
27
28 bool caseSensitive ()
29 {
30 return invokeObjcSelf!(bool, "caseSensitive");
31 }
32
33 Object locale ()
34 {
35 return invokeObjcSelf!(Object, "locale");
36 }
37
38 bool scanInt (int* value)
39 {
40 return invokeObjcSelf!(bool, "scanInt:", int*)(value);
41 }
42
43 bool scanInteger (NSInteger* value)
44 {
45 return invokeObjcSelf!(bool, "scanInteger:", NSInteger*)(value);
46 }
47
48 bool scanHexLongLong (ulong* result)
49 {
50 return invokeObjcSelf!(bool, "scanHexLongLong:", ulong*)(result);
51 }
52
53 bool scanHexFloat (float* result)
54 {
55 return invokeObjcSelf!(bool, "scanHexFloat:", float*)(result);
56 }
57
58 bool scanHexDouble (double* result)
59 {
60 return invokeObjcSelf!(bool, "scanHexDouble:", double*)(result);
61 }
62
63 bool scanHexInt (uint* value)
64 {
65 return invokeObjcSelf!(bool, "scanHexInt:", uint*)(value);
66 }
67
68 bool scanLongLong (long* value)
69 {
70 return invokeObjcSelf!(bool, "scanLongLong:", long*)(value);
71 }
72
73 bool scanFloat (float* value)
74 {
75 return invokeObjcSelf!(bool, "scanFloat:", float*)(value);
76 }
77
78 bool scanDouble (double* value)
79 {
80 return invokeObjcSelf!(bool, "scanDouble:", double*)(value);
81 }
82
83 bool scanString (NSString string, ref NSString value)
84 {
85 id val;
86
87 if (value)
88 val = new objc_object;
89
90 bool result = invokeObjcSelf!(bool, "scanString:intoString:", NSString, id*)(string, &val);
91
92 if (val)
93 value = new NSString(val);
94
95 return result;
96 }
97
98 bool scanCharactersFromSet (NSCharacterSet set, ref NSString value)
99 {
100 id val;
101
102 if (value)
103 val = new objc_object;
104
105 bool result = invokeObjcSelf!(bool, "scanCharactersFromSet:intoString:", NSCharacterSet, id*)(set, &val);
106
107 if (val)
108 value = new NSString(val);
109
110 return result;
111 }
112
113 bool scanUpToString (NSString string, ref NSString value)
114 {
115 id val;
116
117 if (value)
118 val = new objc_object;
119
120 bool result = invokeObjcSelf!(bool, "scanUpToString:intoString:", NSString, id*)(string, &val);
121
122 if (val)
123 value = new NSString(val);
124
125 return result;
126 }
127
128 bool scanUpToCharactersFromSet (NSCharacterSet set, ref NSString value)
129 {
130 id val;
131
132 if (value)
133 val = new objc_object;
134
135 bool result = invokeObjcSelf!(bool, "scanUpToCharactersFromSet:intoString:", NSCharacterSet, id*)(set, &val);
136
137 if (val)
138 value = new NSString(val);
139
140 return result;
141 }
142
143 bool isAtEnd ()
144 {
145 return invokeObjcSelf!(bool, "isAtEnd");
146 }
147
148 Object initWithString (NSString string)
149 {
150 return invokeObjcSelf!(Object, "initWithString:", NSString)(string);
151 }
152
153 this (NSString string)
154 {
155 typeof(this).alloc.initWithString(string);
156 }
157
158 static Object scannerWithString (NSString string)
159 {
160 return invokeObjcSuperClass!(Object, "scannerWithString:", NSString)(string);
161 }
162
163 static Object localizedScannerWithString (NSString string)
164 {
165 return invokeObjcSuperClass!(Object, "localizedScannerWithString:", NSString)(string);
166 }
167 `;
15 168
16 class NSScanner : NSObject, INSCopying 169 class NSScanner : NSObject, INSCopying
17 { 170 {
18 mixin ObjcWrap; 171 mixin (ObjcWrap);
19 mixin TNSDecimalNumberScanning; 172
20 mixin TNSExtendedScanner; 173 this ()
174 {
175 super(typeof(this).alloc.init.objcObject);
176 }
177
178 typeof(this) init ()
179 {
180 return invokeObjcSelf!(typeof(this), "init");
181 }
21 182
22 NSString string () 183 NSString string ()
23 { 184 {
24 return invokeObjcSelf!(NSString, "string"); 185 return invokeObjcSelf!(NSString, "string");
25 } 186 }
51 212
52 Object copyWithZone (NSZone* zone) 213 Object copyWithZone (NSZone* zone)
53 { 214 {
54 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); 215 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
55 } 216 }
217
218 // TNSDecimalNumberScanning
219 bool scanDecimal (NSDecimal* dcm)
220 {
221 return invokeObjcSelf!(bool, "scanDecimal:", NSDecimal*)(dcm);
222 }
223
224 // TNSExtendedScanner
225 NSCharacterSet charactersToBeSkipped ()
226 {
227 return invokeObjcSelf!(NSCharacterSet, "charactersToBeSkipped");
228 }
229
230 bool caseSensitive ()
231 {
232 return invokeObjcSelf!(bool, "caseSensitive");
233 }
234
235 Object locale ()
236 {
237 return invokeObjcSelf!(Object, "locale");
238 }
239
240 bool scanInt (int* value)
241 {
242 return invokeObjcSelf!(bool, "scanInt:", int*)(value);
243 }
244
245 bool scanInteger (NSInteger* value)
246 {
247 return invokeObjcSelf!(bool, "scanInteger:", NSInteger*)(value);
248 }
249
250 bool scanHexLongLong (ulong* result)
251 {
252 return invokeObjcSelf!(bool, "scanHexLongLong:", ulong*)(result);
253 }
254
255 bool scanHexFloat (float* result)
256 {
257 return invokeObjcSelf!(bool, "scanHexFloat:", float*)(result);
258 }
259
260 bool scanHexDouble (double* result)
261 {
262 return invokeObjcSelf!(bool, "scanHexDouble:", double*)(result);
263 }
264
265 bool scanHexInt (uint* value)
266 {
267 return invokeObjcSelf!(bool, "scanHexInt:", uint*)(value);
268 }
269
270 bool scanLongLong (long* value)
271 {
272 return invokeObjcSelf!(bool, "scanLongLong:", long*)(value);
273 }
274
275 bool scanFloat (float* value)
276 {
277 return invokeObjcSelf!(bool, "scanFloat:", float*)(value);
278 }
279
280 bool scanDouble (double* value)
281 {
282 return invokeObjcSelf!(bool, "scanDouble:", double*)(value);
283 }
284
285 bool scanString (NSString string, ref NSString value)
286 {
287 id val;
288
289 if (value)
290 val = new objc_object;
291
292 bool result = invokeObjcSelf!(bool, "scanString:intoString:", NSString, id*)(string, &val);
293
294 if (val)
295 value = new NSString(val);
296
297 return result;
298 }
299
300 bool scanCharactersFromSet (NSCharacterSet set, ref NSString value)
301 {
302 id val;
303
304 if (value)
305 val = new objc_object;
306
307 bool result = invokeObjcSelf!(bool, "scanCharactersFromSet:intoString:", NSCharacterSet, id*)(set, &val);
308
309 if (val)
310 value = new NSString(val);
311
312 return result;
313 }
314
315 bool scanUpToString (NSString string, ref NSString value)
316 {
317 id val;
318
319 if (value)
320 val = new objc_object;
321
322 bool result = invokeObjcSelf!(bool, "scanUpToString:intoString:", NSString, id*)(string, &val);
323
324 if (val)
325 value = new NSString(val);
326
327 return result;
328 }
329
330 bool scanUpToCharactersFromSet (NSCharacterSet set, ref NSString value)
331 {
332 id val;
333
334 if (value)
335 val = new objc_object;
336
337 bool result = invokeObjcSelf!(bool, "scanUpToCharactersFromSet:intoString:", NSCharacterSet, id*)(set, &val);
338
339 if (val)
340 value = new NSString(val);
341
342 return result;
343 }
344
345 bool isAtEnd ()
346 {
347 return invokeObjcSelf!(bool, "isAtEnd");
348 }
349
350 Object initWithString (NSString string)
351 {
352 return invokeObjcSelf!(Object, "initWithString:", NSString)(string);
353 }
354
355 this (NSString string)
356 {
357 typeof(this).alloc.initWithString(string);
358 }
359
360 static Object scannerWithString (NSString string)
361 {
362 return invokeObjcSuperClass!(Object, "scannerWithString:", NSString)(string);
363 }
364
365 static Object localizedScannerWithString (NSString string)
366 {
367 return invokeObjcSuperClass!(Object, "localizedScannerWithString:", NSString)(string);
368 }
56 } 369 }
57
58 template TNSExtendedScanner ()
59 {
60 NSCharacterSet charactersToBeSkipped ()
61 {
62 return invokeObjcSelf!(NSCharacterSet, "charactersToBeSkipped");
63 }
64
65 bool caseSensitive ()
66 {
67 return invokeObjcSelf!(bool, "caseSensitive");
68 }
69
70 Object locale ()
71 {
72 return invokeObjcSelf!(Object, "locale");
73 }
74
75 bool scanInt (int* value)
76 {
77 return invokeObjcSelf!(bool, "scanInt:", int*)(value);
78 }
79
80 bool scanInteger (NSInteger* value)
81 {
82 return invokeObjcSelf!(bool, "scanInteger:", NSInteger*)(value);
83 }
84
85 bool scanHexLongLong (unsigned long long* result)
86 {
87 return invokeObjcSelf!(bool, "scanHexLongLong:", unsigned long long*)(result);
88 }
89
90 bool scanHexFloat (float* result)
91 {
92 return invokeObjcSelf!(bool, "scanHexFloat:", float*)(result);
93 }
94
95 bool scanHexDouble (double* result)
96 {
97 return invokeObjcSelf!(bool, "scanHexDouble:", double*)(result);
98 }
99
100 bool scanHexInt (unsigned* value)
101 {
102 return invokeObjcSelf!(bool, "scanHexInt:", unsigned*)(value);
103 }
104
105 bool scanLongLong (long long* value)
106 {
107 return invokeObjcSelf!(bool, "scanLongLong:", long long*)(value);
108 }
109
110 bool scanFloat (float* value)
111 {
112 return invokeObjcSelf!(bool, "scanFloat:", float*)(value);
113 }
114
115 bool scanDouble (double* value)
116 {
117 return invokeObjcSelf!(bool, "scanDouble:", double*)(value);
118 }
119
120 bool scanString (NSString string, NSString** value)
121 {
122 return invokeObjcSelf!(bool, "scanString:intoString:", NSString, NSString**)(string, value);
123 }
124
125 bool scanCharactersFromSet (NSCharacterSet set, NSString** value)
126 {
127 return invokeObjcSelf!(bool, "scanCharactersFromSet:intoString:", NSCharacterSet, NSString**)(set, value);
128 }
129
130 bool scanUpToString (NSString string, NSString** value)
131 {
132 return invokeObjcSelf!(bool, "scanUpToString:intoString:", NSString, NSString**)(string, value);
133 }
134
135 bool scanUpToCharactersFromSet (NSCharacterSet set, NSString** value)
136 {
137 return invokeObjcSelf!(bool, "scanUpToCharactersFromSet:intoString:", NSCharacterSet, NSString**)(set, value);
138 }
139
140 bool isAtEnd ()
141 {
142 return invokeObjcSelf!(bool, "isAtEnd");
143 }
144
145 Object initWithString (NSString string)
146 {
147 return invokeObjcSelf!(Object, "initWithString:", NSString)(string);
148 }
149
150 this (NSString string)
151 {
152 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
153 id result = Bridge.invokeObjcMethod!(id, "initWithString:", NSString)(objcObject, string);
154
155 if (result)
156 objcObject = ret;
157
158 dObject = this;
159 }
160
161 static Object scannerWithString (NSString string)
162 {
163 return invokeObjcSelfClass!(Object, "scannerWithString:", NSString)(string);
164 }
165
166 static Object localizedScannerWithString (NSString string)
167 {
168 return invokeObjcSelfClass!(Object, "localizedScannerWithString:", NSString)(string);
169 }
170 }
171