Mercurial > projects > dstep
comparison dstep/foundation/NSSortDescriptor.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.NSSortDescriptor; | 7 module dstep.foundation.NSSortDescriptor; |
8 | 8 |
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSCoder; | |
11 import dstep.foundation.NSObject; | |
12 import dstep.foundation.NSString; | |
13 import dstep.foundation.NSZone; | |
10 import dstep.objc.bridge.Bridge; | 14 import dstep.objc.bridge.Bridge; |
11 import dstep.objc.objc : id; | 15 import dstep.objc.objc; |
12 | 16 |
13 class NSSortDescriptor : NSObject, INSCoding, INSCopying | 17 class NSSortDescriptor : NSObject, INSCoding, INSCopying |
14 { | 18 { |
15 mixin ObjcWrap; | 19 mixin (ObjcWrap); |
20 | |
21 this () | |
22 { | |
23 super(typeof(this).alloc.init.objcObject); | |
24 } | |
25 | |
26 typeof(this) init () | |
27 { | |
28 return invokeObjcSelf!(typeof(this), "init"); | |
29 } | |
16 | 30 |
17 Object initWithKey (NSString key, bool ascending) | 31 Object initWithKey (NSString key, bool ascending) |
18 { | 32 { |
19 return invokeObjcSelf!(Object, "initWithKey:ascending:", NSString, bool)(key, ascending); | 33 return invokeObjcSelf!(Object, "initWithKey:ascending:", NSString, bool)(key, ascending); |
20 } | 34 } |
21 | 35 |
22 this (NSString key, bool ascending) | 36 this (NSString key, bool ascending) |
23 { | 37 { |
24 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 38 typeof(this).alloc.initWithKey(key, ascending); |
25 id result = Bridge.invokeObjcMethod!(id, "initWithKey:ascending:", NSString, bool)(objcObject, key, ascending); | |
26 | |
27 if (result) | |
28 objcObject = ret; | |
29 | |
30 dObject = this; | |
31 } | 39 } |
32 | 40 |
33 Object initWithKey (NSString key, bool ascending, SEL selector) | 41 Object initWithKey (NSString key, bool ascending, SEL selector) |
34 { | 42 { |
35 return invokeObjcSelf!(Object, "initWithKey:ascending:selector:", NSString, bool, SEL)(key, ascending, selector); | 43 return invokeObjcSelf!(Object, "initWithKey:ascending:selector:", NSString, bool, SEL)(key, ascending, selector); |
36 } | 44 } |
37 | 45 |
38 this (NSString key, bool ascending, SEL selector) | 46 this (NSString key, bool ascending, SEL selector) |
39 { | 47 { |
40 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 48 typeof(this).alloc.initWithKey(key, ascending, selector); |
41 id result = Bridge.invokeObjcMethod!(id, "initWithKey:ascending:selector:", NSString, bool, SEL)(objcObject, key, ascending, selector); | |
42 | |
43 if (result) | |
44 objcObject = ret; | |
45 | |
46 dObject = this; | |
47 } | 49 } |
48 | 50 |
49 NSString key () | 51 NSString key () |
50 { | 52 { |
51 return invokeObjcSelf!(NSString, "key"); | 53 return invokeObjcSelf!(NSString, "key"); |
81 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | 83 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); |
82 } | 84 } |
83 | 85 |
84 this (NSCoder aDecoder) | 86 this (NSCoder aDecoder) |
85 { | 87 { |
86 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 88 typeof(this).alloc.initWithCoder(aDecoder); |
87 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
88 | |
89 if (result) | |
90 objcObject = ret; | |
91 | |
92 dObject = this; | |
93 } | 89 } |
94 | 90 |
95 Object copyWithZone (NSZone* zone) | 91 Object copyWithZone (NSZone* zone) |
96 { | 92 { |
97 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | 93 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); |
98 } | 94 } |
99 } | 95 } |
100 | 96 |
101 template TNSSortDescriptorSorting () | 97 const TNSSortDescriptorSorting = ` |
102 { | 98 |
103 NSArray sortedArrayUsingDescriptors (NSArray sortDescriptors) | 99 NSArray sortedArrayUsingDescriptors (NSArray sortDescriptors) |
104 { | 100 { |
105 return invokeObjcSelf!(NSArray, "sortedArrayUsingDescriptors:", NSArray)(sortDescriptors); | 101 return invokeObjcSelf!(NSArray, "sortedArrayUsingDescriptors:", NSArray)(sortDescriptors); |
106 } | 102 } |
107 } | 103 `; |
108 | 104 |