Mercurial > projects > dstep
comparison dstep/foundation/NSValue.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.NSValue; | 7 module dstep.foundation.NSValue; |
8 | 8 |
9 import dstep.foundation.NSCoder; | |
10 import dstep.foundation.NSDecimal; | |
11 import dstep.foundation.NSDecimalNumber; | |
9 import dstep.foundation.NSDictionary; | 12 import dstep.foundation.NSDictionary; |
13 import dstep.foundation.NSGeometry; | |
14 import dstep.foundation.NSObjCRuntime; | |
10 import dstep.foundation.NSObject; | 15 import dstep.foundation.NSObject; |
16 import dstep.foundation.NSRange; | |
11 import dstep.foundation.NSString; | 17 import dstep.foundation.NSString; |
18 import dstep.foundation.NSZone; | |
12 import dstep.objc.bridge.Bridge; | 19 import dstep.objc.bridge.Bridge; |
13 import dstep.objc.objc : id; | 20 import dstep.applicationservices.coregraphics.CGGeometry; |
21 import dstep.objc.objc; | |
22 | |
23 private | |
24 { | |
25 alias CGPoint NSPoint; | |
26 alias NSPoint* NSPointPointer; | |
27 alias NSPoint* NSPointArray; | |
28 alias CGSize NSSize; | |
29 alias NSSize* NSSizePointer; | |
30 alias NSSize* NSSizeArray; | |
31 alias CGRect NSRect; | |
32 alias NSRect* NSRectPointer; | |
33 alias NSRect* NSRectArray; | |
34 alias NSUInteger NSRectEdge; | |
35 } | |
36 | |
37 const TNSNumberCreation = ` | |
38 | |
39 Object initWithChar (byte value) | |
40 { | |
41 return invokeObjcSelf!(Object, "initWithChar:", byte)(value); | |
42 } | |
43 | |
44 this (byte value) | |
45 { | |
46 typeof(this).alloc.initWithChar(value); | |
47 } | |
48 | |
49 Object initWithUnsignedChar (ubyte value) | |
50 { | |
51 return invokeObjcSelf!(Object, "initWithUnsignedChar:", ubyte)(value); | |
52 } | |
53 | |
54 this (ubyte value) | |
55 { | |
56 typeof(this).alloc.initWithUnsignedChar(value); | |
57 } | |
58 | |
59 Object initWithShort (short value) | |
60 { | |
61 return invokeObjcSelf!(Object, "initWithShort:", short)(value); | |
62 } | |
63 | |
64 this (short value) | |
65 { | |
66 typeof(this).alloc.initWithShort(value); | |
67 } | |
68 | |
69 Object initWithUnsignedShort (ushort value) | |
70 { | |
71 return invokeObjcSelf!(Object, "initWithUnsignedShort:", ushort)(value); | |
72 } | |
73 | |
74 this (ushort value) | |
75 { | |
76 typeof(this).alloc.initWithUnsignedShort(value); | |
77 } | |
78 | |
79 Object initWithInt (int value) | |
80 { | |
81 return invokeObjcSelf!(Object, "initWithInt:", int)(value); | |
82 } | |
83 | |
84 this (int value) | |
85 { | |
86 typeof(this).alloc.initWithInt(value); | |
87 } | |
88 | |
89 Object initWithUnsignedInt (uint value) | |
90 { | |
91 return invokeObjcSelf!(Object, "initWithUnsignedInt:", uint)(value); | |
92 } | |
93 | |
94 this (uint value) | |
95 { | |
96 typeof(this).alloc.initWithUnsignedInt(value); | |
97 } | |
98 | |
99 Object initWithLong (int value) | |
100 { | |
101 return invokeObjcSelf!(Object, "initWithLong:", int)(value); | |
102 } | |
103 | |
104 this (int value) | |
105 { | |
106 typeof(this).alloc.initWithLong(value); | |
107 } | |
108 | |
109 Object initWithUnsignedLong (uint value) | |
110 { | |
111 return invokeObjcSelf!(Object, "initWithUnsignedLong:", uint)(value); | |
112 } | |
113 | |
114 this (uint value) | |
115 { | |
116 typeof(this).alloc.initWithUnsignedLong(value); | |
117 } | |
118 | |
119 Object initWithLongLong (long value) | |
120 { | |
121 return invokeObjcSelf!(Object, "initWithLongLong:", long)(value); | |
122 } | |
123 | |
124 this (long value) | |
125 { | |
126 typeof(this).alloc.initWithLongLong(value); | |
127 } | |
128 | |
129 Object initWithUnsignedLongLong (ulong value) | |
130 { | |
131 return invokeObjcSelf!(Object, "initWithUnsignedLongLong:", ulong)(value); | |
132 } | |
133 | |
134 this (ulong value) | |
135 { | |
136 typeof(this).alloc.initWithUnsignedLongLong(value); | |
137 } | |
138 | |
139 Object initWithFloat (float value) | |
140 { | |
141 return invokeObjcSelf!(Object, "initWithFloat:", float)(value); | |
142 } | |
143 | |
144 this (float value) | |
145 { | |
146 typeof(this).alloc.initWithFloat(value); | |
147 } | |
148 | |
149 Object initWithDouble (double value) | |
150 { | |
151 return invokeObjcSelf!(Object, "initWithDouble:", double)(value); | |
152 } | |
153 | |
154 this (double value) | |
155 { | |
156 typeof(this).alloc.initWithDouble(value); | |
157 } | |
158 | |
159 Object initWithBool (bool value) | |
160 { | |
161 return invokeObjcSelf!(Object, "initWithBool:", bool)(value); | |
162 } | |
163 | |
164 this (bool value) | |
165 { | |
166 typeof(this).alloc.initWithBool(value); | |
167 } | |
168 | |
169 Object initWithInteger (NSInteger value) | |
170 { | |
171 return invokeObjcSelf!(Object, "initWithInteger:", NSInteger)(value); | |
172 } | |
173 | |
174 this (NSInteger value) | |
175 { | |
176 typeof(this).alloc.initWithInteger(value); | |
177 } | |
178 | |
179 Object initWithUnsignedInteger (NSUInteger value) | |
180 { | |
181 return invokeObjcSelf!(Object, "initWithUnsignedInteger:", NSUInteger)(value); | |
182 } | |
183 | |
184 this (NSUInteger value) | |
185 { | |
186 typeof(this).alloc.initWithUnsignedInteger(value); | |
187 } | |
188 | |
189 static NSNumber numberWithChar (byte value) | |
190 { | |
191 return invokeObjcSuperClass!(NSNumber, "numberWithChar:", byte)(value); | |
192 } | |
193 | |
194 static NSNumber numberWithUnsignedChar (ubyte value) | |
195 { | |
196 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedChar:", ubyte)(value); | |
197 } | |
198 | |
199 static NSNumber numberWithShort (short value) | |
200 { | |
201 return invokeObjcSuperClass!(NSNumber, "numberWithShort:", short)(value); | |
202 } | |
203 | |
204 static NSNumber numberWithUnsignedShort (ushort value) | |
205 { | |
206 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedShort:", ushort)(value); | |
207 } | |
208 | |
209 static NSNumber numberWithInt (int value) | |
210 { | |
211 return invokeObjcSuperClass!(NSNumber, "numberWithInt:", int)(value); | |
212 } | |
213 | |
214 static NSNumber numberWithUnsignedInt (uint value) | |
215 { | |
216 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedInt:", uint)(value); | |
217 } | |
218 | |
219 static NSNumber numberWithLong (int value) | |
220 { | |
221 return invokeObjcSuperClass!(NSNumber, "numberWithLong:", int)(value); | |
222 } | |
223 | |
224 static NSNumber numberWithUnsignedLong (uint value) | |
225 { | |
226 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedLong:", uint)(value); | |
227 } | |
228 | |
229 static NSNumber numberWithLongLong (long value) | |
230 { | |
231 return invokeObjcSuperClass!(NSNumber, "numberWithLongLong:", long)(value); | |
232 } | |
233 | |
234 static NSNumber numberWithUnsignedLongLong (ulong value) | |
235 { | |
236 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedLongLong:", ulong)(value); | |
237 } | |
238 | |
239 static NSNumber numberWithFloat (float value) | |
240 { | |
241 return invokeObjcSuperClass!(NSNumber, "numberWithFloat:", float)(value); | |
242 } | |
243 | |
244 static NSNumber numberWithDouble (double value) | |
245 { | |
246 return invokeObjcSuperClass!(NSNumber, "numberWithDouble:", double)(value); | |
247 } | |
248 | |
249 static NSNumber numberWithBool (bool value) | |
250 { | |
251 return invokeObjcSuperClass!(NSNumber, "numberWithBool:", bool)(value); | |
252 } | |
253 | |
254 static NSNumber numberWithInteger (NSInteger value) | |
255 { | |
256 return invokeObjcSuperClass!(NSNumber, "numberWithInteger:", NSInteger)(value); | |
257 } | |
258 | |
259 static NSNumber numberWithUnsignedInteger (NSUInteger value) | |
260 { | |
261 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedInteger:", NSUInteger)(value); | |
262 } | |
263 `; | |
264 | |
265 const TNSValueCreation = ` | |
266 | |
267 Object initWithBytes (void* value, char* type) | |
268 { | |
269 return invokeObjcSelf!(Object, "initWithBytes:objCType:", void*, char*)(value, type); | |
270 } | |
271 | |
272 this (void* value, char* type) | |
273 { | |
274 typeof(this).alloc.initWithBytes(value, type); | |
275 } | |
276 | |
277 static NSValue valueWithBytes (void* value, char* type) | |
278 { | |
279 return invokeObjcSuperClass!(NSValue, "valueWithBytes:objCType:", void*, char*)(value, type); | |
280 } | |
281 | |
282 static NSValue value (void* value, char* type) | |
283 { | |
284 return invokeObjcSuperClass!(NSValue, "value:withObjCType:", void*, char*)(value, type); | |
285 } | |
286 `; | |
287 | |
288 const TNSValueExtensionMethods = ` | |
289 | |
290 static NSValue valueWithNonretainedObject (Object anObject) | |
291 { | |
292 return invokeObjcSuperClass!(NSValue, "valueWithNonretainedObject:", Object)(anObject); | |
293 } | |
294 | |
295 Object nonretainedObjectValue () | |
296 { | |
297 return invokeObjcSelf!(Object, "nonretainedObjectValue"); | |
298 } | |
299 | |
300 static NSValue valueWithPointer (void* pointer) | |
301 { | |
302 return invokeObjcSuperClass!(NSValue, "valueWithPointer:", void*)(pointer); | |
303 } | |
304 | |
305 void* pointerValue () | |
306 { | |
307 return invokeObjcSelf!(void*, "pointerValue"); | |
308 } | |
309 | |
310 bool isEqualToValue (NSValue value) | |
311 { | |
312 return invokeObjcSelf!(bool, "isEqualToValue:", NSValue)(value); | |
313 } | |
314 `; | |
315 | |
316 class NSValue : NSObject, INSCopying, INSCoding | |
317 { | |
318 mixin (ObjcWrap); | |
319 | |
320 this () | |
321 { | |
322 super(typeof(this).alloc.init.objcObject); | |
323 } | |
324 | |
325 typeof(this) init () | |
326 { | |
327 return invokeObjcSelf!(typeof(this), "init"); | |
328 } | |
329 | |
330 void getValue (void* value) | |
331 { | |
332 return invokeObjcSelf!(void, "getValue:", void*)(value); | |
333 } | |
334 | |
335 char* objCType () | |
336 { | |
337 return invokeObjcSelf!(char*, "objCType"); | |
338 } | |
339 | |
340 Object copyWithZone (NSZone* zone) | |
341 { | |
342 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
343 } | |
344 | |
345 void encodeWithCoder (NSCoder aCoder) | |
346 { | |
347 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
348 } | |
349 | |
350 Object initWithCoder (NSCoder aDecoder) | |
351 { | |
352 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
353 } | |
354 | |
355 this (NSCoder aDecoder) | |
356 { | |
357 typeof(this).alloc.initWithCoder(aDecoder); | |
358 } | |
359 | |
360 // TNSValueGeometryExtensions | |
361 static NSValue valueWithPoint (dstep.applicationservices.coregraphics.CGGeometry.CGPoint point) | |
362 { | |
363 return invokeObjcSuperClass!(NSValue, "valueWithPoint:", NSPoint)(point); | |
364 } | |
365 | |
366 static NSValue valueWithSize (NSSize size) | |
367 { | |
368 return invokeObjcSuperClass!(NSValue, "valueWithSize:", NSSize)(size); | |
369 } | |
370 | |
371 static NSValue valueWithRect (NSRect rect) | |
372 { | |
373 return invokeObjcSuperClass!(NSValue, "valueWithRect:", NSRect)(rect); | |
374 } | |
375 | |
376 NSPoint pointValue () | |
377 { | |
378 return invokeObjcSelf!(NSPoint, "pointValue"); | |
379 } | |
380 | |
381 NSSize sizeValue () | |
382 { | |
383 return invokeObjcSelf!(NSSize, "sizeValue"); | |
384 } | |
385 | |
386 NSRect rectValue () | |
387 { | |
388 return invokeObjcSelf!(NSRect, "rectValue"); | |
389 } | |
390 | |
391 // TNSValueCreation | |
392 Object initWithBytes (void* value, char* type) | |
393 { | |
394 return invokeObjcSelf!(Object, "initWithBytes:objCType:", void*, char*)(value, type); | |
395 } | |
396 | |
397 this (void* value, char* type) | |
398 { | |
399 typeof(this).alloc.initWithBytes(value, type); | |
400 } | |
401 | |
402 static NSValue valueWithBytes (void* value, char* type) | |
403 { | |
404 return invokeObjcSuperClass!(NSValue, "valueWithBytes:objCType:", void*, char*)(value, type); | |
405 } | |
406 | |
407 static NSValue value (void* value, char* type) | |
408 { | |
409 return invokeObjcSuperClass!(NSValue, "value:withObjCType:", void*, char*)(value, type); | |
410 } | |
411 | |
412 // TNSValueRangeExtensions | |
413 static NSValue valueWithRange (NSRange range) | |
414 { | |
415 return invokeObjcSuperClass!(NSValue, "valueWithRange:", NSRange)(range); | |
416 } | |
417 | |
418 NSRange rangeValue () | |
419 { | |
420 return invokeObjcSelf!(NSRange, "rangeValue"); | |
421 } | |
422 | |
423 // TNSValueExtensionMethods | |
424 static NSValue valueWithNonretainedObject (Object anObject) | |
425 { | |
426 return invokeObjcSuperClass!(NSValue, "valueWithNonretainedObject:", Object)(anObject); | |
427 } | |
428 | |
429 Object nonretainedObjectValue () | |
430 { | |
431 return invokeObjcSelf!(Object, "nonretainedObjectValue"); | |
432 } | |
433 | |
434 static NSValue valueWithPointer (void* pointer) | |
435 { | |
436 return invokeObjcSuperClass!(NSValue, "valueWithPointer:", void*)(pointer); | |
437 } | |
438 | |
439 void* pointerValue () | |
440 { | |
441 return invokeObjcSelf!(void*, "pointerValue"); | |
442 } | |
443 | |
444 bool isEqualToValue (NSValue value) | |
445 { | |
446 return invokeObjcSelf!(bool, "isEqualToValue:", NSValue)(value); | |
447 } | |
448 } | |
14 | 449 |
15 class NSNumber : NSValue | 450 class NSNumber : NSValue |
16 { | 451 { |
17 mixin ObjcWrap; | 452 mixin (ObjcWrap); |
18 mixin TNSDecimalNumberExtensions; | 453 |
19 mixin TNSNumberCreation; | 454 this () |
455 { | |
456 super(typeof(this).alloc.init.objcObject); | |
457 } | |
458 | |
459 typeof(this) init () | |
460 { | |
461 return invokeObjcSelf!(typeof(this), "init"); | |
462 } | |
20 | 463 |
21 byte charValue () | 464 byte charValue () |
22 { | 465 { |
23 return invokeObjcSelf!(byte, "charValue"); | 466 return invokeObjcSelf!(byte, "charValue"); |
24 } | 467 } |
110 | 553 |
111 NSString descriptionWithLocale (Object locale) | 554 NSString descriptionWithLocale (Object locale) |
112 { | 555 { |
113 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); | 556 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); |
114 } | 557 } |
558 | |
559 // TNSDecimalNumberExtensions | |
560 NSDecimal decimalValue () | |
561 { | |
562 return invokeObjcSelf!(NSDecimal, "decimalValue"); | |
563 } | |
564 | |
565 // TNSNumberCreation | |
566 Object initWithChar (byte value) | |
567 { | |
568 return invokeObjcSelf!(Object, "initWithChar:", byte)(value); | |
569 } | |
570 | |
571 this (byte value) | |
572 { | |
573 typeof(this).alloc.initWithChar(value); | |
574 } | |
575 | |
576 Object initWithUnsignedChar (ubyte value) | |
577 { | |
578 return invokeObjcSelf!(Object, "initWithUnsignedChar:", ubyte)(value); | |
579 } | |
580 | |
581 this (ubyte value) | |
582 { | |
583 typeof(this).alloc.initWithUnsignedChar(value); | |
584 } | |
585 | |
586 Object initWithShort (short value) | |
587 { | |
588 return invokeObjcSelf!(Object, "initWithShort:", short)(value); | |
589 } | |
590 | |
591 this (short value) | |
592 { | |
593 typeof(this).alloc.initWithShort(value); | |
594 } | |
595 | |
596 Object initWithUnsignedShort (ushort value) | |
597 { | |
598 return invokeObjcSelf!(Object, "initWithUnsignedShort:", ushort)(value); | |
599 } | |
600 | |
601 this (ushort value) | |
602 { | |
603 typeof(this).alloc.initWithUnsignedShort(value); | |
604 } | |
605 | |
606 Object initWithInt (int value) | |
607 { | |
608 return invokeObjcSelf!(Object, "initWithInt:", int)(value); | |
609 } | |
610 | |
611 this (int value) | |
612 { | |
613 typeof(this).alloc.initWithInt(value); | |
614 } | |
615 | |
616 Object initWithUnsignedInt (uint value) | |
617 { | |
618 return invokeObjcSelf!(Object, "initWithUnsignedInt:", uint)(value); | |
619 } | |
620 | |
621 this (uint value) | |
622 { | |
623 typeof(this).alloc.initWithUnsignedInt(value); | |
624 } | |
625 | |
626 Object initWithLong (int value) | |
627 { | |
628 return invokeObjcSelf!(Object, "initWithLong:", int)(value); | |
629 } | |
630 | |
631 Object initWithUnsignedLong (uint value) | |
632 { | |
633 return invokeObjcSelf!(Object, "initWithUnsignedLong:", uint)(value); | |
634 } | |
635 | |
636 Object initWithLongLong (long value) | |
637 { | |
638 return invokeObjcSelf!(Object, "initWithLongLong:", long)(value); | |
639 } | |
640 | |
641 this (long value) | |
642 { | |
643 typeof(this).alloc.initWithLongLong(value); | |
644 } | |
645 | |
646 Object initWithUnsignedLongLong (ulong value) | |
647 { | |
648 return invokeObjcSelf!(Object, "initWithUnsignedLongLong:", ulong)(value); | |
649 } | |
650 | |
651 this (ulong value) | |
652 { | |
653 typeof(this).alloc.initWithUnsignedLongLong(value); | |
654 } | |
655 | |
656 Object initWithFloat (float value) | |
657 { | |
658 return invokeObjcSelf!(Object, "initWithFloat:", float)(value); | |
659 } | |
660 | |
661 this (float value) | |
662 { | |
663 typeof(this).alloc.initWithFloat(value); | |
664 } | |
665 | |
666 Object initWithDouble (double value) | |
667 { | |
668 return invokeObjcSelf!(Object, "initWithDouble:", double)(value); | |
669 } | |
670 | |
671 this (double value) | |
672 { | |
673 typeof(this).alloc.initWithDouble(value); | |
674 } | |
675 | |
676 Object initWithBool (bool value) | |
677 { | |
678 return invokeObjcSelf!(Object, "initWithBool:", bool)(value); | |
679 } | |
680 | |
681 this (bool value) | |
682 { | |
683 typeof(this).alloc.initWithBool(value); | |
684 } | |
685 | |
686 Object initWithInteger (NSInteger value) | |
687 { | |
688 return invokeObjcSelf!(Object, "initWithInteger:", NSInteger)(value); | |
689 } | |
690 | |
691 Object initWithUnsignedInteger (NSUInteger value) | |
692 { | |
693 return invokeObjcSelf!(Object, "initWithUnsignedInteger:", NSUInteger)(value); | |
694 } | |
695 | |
696 static NSNumber numberWithChar (byte value) | |
697 { | |
698 return invokeObjcSuperClass!(NSNumber, "numberWithChar:", byte)(value); | |
699 } | |
700 | |
701 static NSNumber numberWithUnsignedChar (ubyte value) | |
702 { | |
703 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedChar:", ubyte)(value); | |
704 } | |
705 | |
706 static NSNumber numberWithShort (short value) | |
707 { | |
708 return invokeObjcSuperClass!(NSNumber, "numberWithShort:", short)(value); | |
709 } | |
710 | |
711 static NSNumber numberWithUnsignedShort (ushort value) | |
712 { | |
713 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedShort:", ushort)(value); | |
714 } | |
715 | |
716 static NSNumber numberWithInt (int value) | |
717 { | |
718 return invokeObjcSuperClass!(NSNumber, "numberWithInt:", int)(value); | |
719 } | |
720 | |
721 static NSNumber numberWithUnsignedInt (uint value) | |
722 { | |
723 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedInt:", uint)(value); | |
724 } | |
725 | |
726 static NSNumber numberWithLong (int value) | |
727 { | |
728 return invokeObjcSuperClass!(NSNumber, "numberWithLong:", int)(value); | |
729 } | |
730 | |
731 static NSNumber numberWithUnsignedLong (uint value) | |
732 { | |
733 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedLong:", uint)(value); | |
734 } | |
735 | |
736 static NSNumber numberWithLongLong (long value) | |
737 { | |
738 return invokeObjcSuperClass!(NSNumber, "numberWithLongLong:", long)(value); | |
739 } | |
740 | |
741 static NSNumber numberWithUnsignedLongLong (ulong value) | |
742 { | |
743 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedLongLong:", ulong)(value); | |
744 } | |
745 | |
746 static NSNumber numberWithFloat (float value) | |
747 { | |
748 return invokeObjcSuperClass!(NSNumber, "numberWithFloat:", float)(value); | |
749 } | |
750 | |
751 static NSNumber numberWithDouble (double value) | |
752 { | |
753 return invokeObjcSuperClass!(NSNumber, "numberWithDouble:", double)(value); | |
754 } | |
755 | |
756 static NSNumber numberWithBool (bool value) | |
757 { | |
758 return invokeObjcSuperClass!(NSNumber, "numberWithBool:", bool)(value); | |
759 } | |
760 | |
761 static NSNumber numberWithInteger (NSInteger value) | |
762 { | |
763 return invokeObjcSuperClass!(NSNumber, "numberWithInteger:", NSInteger)(value); | |
764 } | |
765 | |
766 static NSNumber numberWithUnsignedInteger (NSUInteger value) | |
767 { | |
768 return invokeObjcSuperClass!(NSNumber, "numberWithUnsignedInteger:", NSUInteger)(value); | |
769 } | |
115 } | 770 } |
116 | |
117 class NSValue : NSObject, INSCopying, INSCoding | |
118 { | |
119 mixin ObjcWrap; | |
120 mixin TNSValueGeometryExtensions; | |
121 mixin TNSValueCreation; | |
122 mixin TNSValueRangeExtensions; | |
123 mixin TNSValueExtensionMethods; | |
124 | |
125 void getValue (void* value) | |
126 { | |
127 return invokeObjcSelf!(void, "getValue:", void*)(value); | |
128 } | |
129 | |
130 char* objCType () | |
131 { | |
132 return invokeObjcSelf!(char*, "objCType"); | |
133 } | |
134 | |
135 Object copyWithZone (NSZone* zone) | |
136 { | |
137 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
138 } | |
139 | |
140 void encodeWithCoder (NSCoder aCoder) | |
141 { | |
142 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
143 } | |
144 | |
145 Object initWithCoder (NSCoder aDecoder) | |
146 { | |
147 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
148 } | |
149 | |
150 this (NSCoder aDecoder) | |
151 { | |
152 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
153 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
154 | |
155 if (result) | |
156 objcObject = ret; | |
157 | |
158 dObject = this; | |
159 } | |
160 } | |
161 | |
162 template TNSNumberCreation () | |
163 { | |
164 Object initWithChar (byte value) | |
165 { | |
166 return invokeObjcSelf!(Object, "initWithChar:", byte)(value); | |
167 } | |
168 | |
169 this (byte value) | |
170 { | |
171 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
172 id result = Bridge.invokeObjcMethod!(id, "initWithChar:", byte)(objcObject, value); | |
173 | |
174 if (result) | |
175 objcObject = ret; | |
176 | |
177 dObject = this; | |
178 } | |
179 | |
180 Object initWithUnsignedChar (ubyte value) | |
181 { | |
182 return invokeObjcSelf!(Object, "initWithUnsignedChar:", ubyte)(value); | |
183 } | |
184 | |
185 this (ubyte value) | |
186 { | |
187 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
188 id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedChar:", ubyte)(objcObject, value); | |
189 | |
190 if (result) | |
191 objcObject = ret; | |
192 | |
193 dObject = this; | |
194 } | |
195 | |
196 Object initWithShort (short value) | |
197 { | |
198 return invokeObjcSelf!(Object, "initWithShort:", short)(value); | |
199 } | |
200 | |
201 this (short value) | |
202 { | |
203 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
204 id result = Bridge.invokeObjcMethod!(id, "initWithShort:", short)(objcObject, value); | |
205 | |
206 if (result) | |
207 objcObject = ret; | |
208 | |
209 dObject = this; | |
210 } | |
211 | |
212 Object initWithUnsignedShort (ushort value) | |
213 { | |
214 return invokeObjcSelf!(Object, "initWithUnsignedShort:", ushort)(value); | |
215 } | |
216 | |
217 this (ushort value) | |
218 { | |
219 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
220 id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedShort:", ushort)(objcObject, value); | |
221 | |
222 if (result) | |
223 objcObject = ret; | |
224 | |
225 dObject = this; | |
226 } | |
227 | |
228 Object initWithInt (int value) | |
229 { | |
230 return invokeObjcSelf!(Object, "initWithInt:", int)(value); | |
231 } | |
232 | |
233 this (int value) | |
234 { | |
235 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
236 id result = Bridge.invokeObjcMethod!(id, "initWithInt:", int)(objcObject, value); | |
237 | |
238 if (result) | |
239 objcObject = ret; | |
240 | |
241 dObject = this; | |
242 } | |
243 | |
244 Object initWithUnsignedInt (uint value) | |
245 { | |
246 return invokeObjcSelf!(Object, "initWithUnsignedInt:", uint)(value); | |
247 } | |
248 | |
249 this (uint value) | |
250 { | |
251 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
252 id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedInt:", uint)(objcObject, value); | |
253 | |
254 if (result) | |
255 objcObject = ret; | |
256 | |
257 dObject = this; | |
258 } | |
259 | |
260 Object initWithLong (int value) | |
261 { | |
262 return invokeObjcSelf!(Object, "initWithLong:", int)(value); | |
263 } | |
264 | |
265 this (int value) | |
266 { | |
267 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
268 id result = Bridge.invokeObjcMethod!(id, "initWithLong:", int)(objcObject, value); | |
269 | |
270 if (result) | |
271 objcObject = ret; | |
272 | |
273 dObject = this; | |
274 } | |
275 | |
276 Object initWithUnsignedLong (uint value) | |
277 { | |
278 return invokeObjcSelf!(Object, "initWithUnsignedLong:", uint)(value); | |
279 } | |
280 | |
281 this (uint value) | |
282 { | |
283 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
284 id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedLong:", uint)(objcObject, value); | |
285 | |
286 if (result) | |
287 objcObject = ret; | |
288 | |
289 dObject = this; | |
290 } | |
291 | |
292 Object initWithLongLong (long value) | |
293 { | |
294 return invokeObjcSelf!(Object, "initWithLongLong:", long)(value); | |
295 } | |
296 | |
297 this (long value) | |
298 { | |
299 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
300 id result = Bridge.invokeObjcMethod!(id, "initWithLongLong:", long)(objcObject, value); | |
301 | |
302 if (result) | |
303 objcObject = ret; | |
304 | |
305 dObject = this; | |
306 } | |
307 | |
308 Object initWithUnsignedLongLong (ulong value) | |
309 { | |
310 return invokeObjcSelf!(Object, "initWithUnsignedLongLong:", ulong)(value); | |
311 } | |
312 | |
313 this (ulong value) | |
314 { | |
315 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
316 id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedLongLong:", ulong)(objcObject, value); | |
317 | |
318 if (result) | |
319 objcObject = ret; | |
320 | |
321 dObject = this; | |
322 } | |
323 | |
324 Object initWithFloat (float value) | |
325 { | |
326 return invokeObjcSelf!(Object, "initWithFloat:", float)(value); | |
327 } | |
328 | |
329 this (float value) | |
330 { | |
331 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
332 id result = Bridge.invokeObjcMethod!(id, "initWithFloat:", float)(objcObject, value); | |
333 | |
334 if (result) | |
335 objcObject = ret; | |
336 | |
337 dObject = this; | |
338 } | |
339 | |
340 Object initWithDouble (double value) | |
341 { | |
342 return invokeObjcSelf!(Object, "initWithDouble:", double)(value); | |
343 } | |
344 | |
345 this (double value) | |
346 { | |
347 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
348 id result = Bridge.invokeObjcMethod!(id, "initWithDouble:", double)(objcObject, value); | |
349 | |
350 if (result) | |
351 objcObject = ret; | |
352 | |
353 dObject = this; | |
354 } | |
355 | |
356 Object initWithBool (bool value) | |
357 { | |
358 return invokeObjcSelf!(Object, "initWithBool:", bool)(value); | |
359 } | |
360 | |
361 this (bool value) | |
362 { | |
363 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
364 id result = Bridge.invokeObjcMethod!(id, "initWithBool:", bool)(objcObject, value); | |
365 | |
366 if (result) | |
367 objcObject = ret; | |
368 | |
369 dObject = this; | |
370 } | |
371 | |
372 Object initWithInteger (NSInteger value) | |
373 { | |
374 return invokeObjcSelf!(Object, "initWithInteger:", NSInteger)(value); | |
375 } | |
376 | |
377 this (NSInteger value) | |
378 { | |
379 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
380 id result = Bridge.invokeObjcMethod!(id, "initWithInteger:", NSInteger)(objcObject, value); | |
381 | |
382 if (result) | |
383 objcObject = ret; | |
384 | |
385 dObject = this; | |
386 } | |
387 | |
388 Object initWithUnsignedInteger (NSUInteger value) | |
389 { | |
390 return invokeObjcSelf!(Object, "initWithUnsignedInteger:", NSUInteger)(value); | |
391 } | |
392 | |
393 this (NSUInteger value) | |
394 { | |
395 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
396 id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedInteger:", NSUInteger)(objcObject, value); | |
397 | |
398 if (result) | |
399 objcObject = ret; | |
400 | |
401 dObject = this; | |
402 } | |
403 | |
404 static NSNumber numberWithChar (byte value) | |
405 { | |
406 return invokeObjcSelfClass!(NSNumber, "numberWithChar:", byte)(value); | |
407 } | |
408 | |
409 static NSNumber numberWithUnsignedChar (ubyte value) | |
410 { | |
411 return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedChar:", ubyte)(value); | |
412 } | |
413 | |
414 static NSNumber numberWithShort (short value) | |
415 { | |
416 return invokeObjcSelfClass!(NSNumber, "numberWithShort:", short)(value); | |
417 } | |
418 | |
419 static NSNumber numberWithUnsignedShort (ushort value) | |
420 { | |
421 return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedShort:", ushort)(value); | |
422 } | |
423 | |
424 static NSNumber numberWithInt (int value) | |
425 { | |
426 return invokeObjcSelfClass!(NSNumber, "numberWithInt:", int)(value); | |
427 } | |
428 | |
429 static NSNumber numberWithUnsignedInt (uint value) | |
430 { | |
431 return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedInt:", uint)(value); | |
432 } | |
433 | |
434 static NSNumber numberWithLong (int value) | |
435 { | |
436 return invokeObjcSelfClass!(NSNumber, "numberWithLong:", int)(value); | |
437 } | |
438 | |
439 static NSNumber numberWithUnsignedLong (uint value) | |
440 { | |
441 return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedLong:", uint)(value); | |
442 } | |
443 | |
444 static NSNumber numberWithLongLong (long value) | |
445 { | |
446 return invokeObjcSelfClass!(NSNumber, "numberWithLongLong:", long)(value); | |
447 } | |
448 | |
449 static NSNumber numberWithUnsignedLongLong (ulong value) | |
450 { | |
451 return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedLongLong:", ulong)(value); | |
452 } | |
453 | |
454 static NSNumber numberWithFloat (float value) | |
455 { | |
456 return invokeObjcSelfClass!(NSNumber, "numberWithFloat:", float)(value); | |
457 } | |
458 | |
459 static NSNumber numberWithDouble (double value) | |
460 { | |
461 return invokeObjcSelfClass!(NSNumber, "numberWithDouble:", double)(value); | |
462 } | |
463 | |
464 static NSNumber numberWithBool (bool value) | |
465 { | |
466 return invokeObjcSelfClass!(NSNumber, "numberWithBool:", bool)(value); | |
467 } | |
468 | |
469 static NSNumber numberWithInteger (NSInteger value) | |
470 { | |
471 return invokeObjcSelfClass!(NSNumber, "numberWithInteger:", NSInteger)(value); | |
472 } | |
473 | |
474 static NSNumber numberWithUnsignedInteger (NSUInteger value) | |
475 { | |
476 return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedInteger:", NSUInteger)(value); | |
477 } | |
478 } | |
479 | |
480 template TNSValueCreation () | |
481 { | |
482 Object initWithBytes (void* value, char* type) | |
483 { | |
484 return invokeObjcSelf!(Object, "initWithBytes:objCType:", void*, char*)(value, type); | |
485 } | |
486 | |
487 this (void* value, char* type) | |
488 { | |
489 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
490 id result = Bridge.invokeObjcMethod!(id, "initWithBytes:objCType:", void*, char*)(objcObject, value, type); | |
491 | |
492 if (result) | |
493 objcObject = ret; | |
494 | |
495 dObject = this; | |
496 } | |
497 | |
498 static NSValue valueWithBytes (void* value, char* type) | |
499 { | |
500 return invokeObjcSelfClass!(NSValue, "valueWithBytes:objCType:", void*, char*)(value, type); | |
501 } | |
502 | |
503 static NSValue value (void* value, char* type) | |
504 { | |
505 return invokeObjcSelfClass!(NSValue, "value:withObjCType:", void*, char*)(value, type); | |
506 } | |
507 } | |
508 | |
509 template TNSValueExtensionMethods () | |
510 { | |
511 static NSValue valueWithNonretainedObject (Object anObject) | |
512 { | |
513 return invokeObjcSelfClass!(NSValue, "valueWithNonretainedObject:", Object)(anObject); | |
514 } | |
515 | |
516 Object nonretainedObjectValue () | |
517 { | |
518 return invokeObjcSelf!(Object, "nonretainedObjectValue"); | |
519 } | |
520 | |
521 static NSValue valueWithPointer (void* pointer) | |
522 { | |
523 return invokeObjcSelfClass!(NSValue, "valueWithPointer:", void*)(pointer); | |
524 } | |
525 | |
526 void* pointerValue () | |
527 { | |
528 return invokeObjcSelf!(void*, "pointerValue"); | |
529 } | |
530 | |
531 bool isEqualToValue (NSValue value) | |
532 { | |
533 return invokeObjcSelf!(bool, "isEqualToValue:", NSValue)(value); | |
534 } | |
535 } | |
536 |