Mercurial > projects > dstep
comparison dstep/foundation/NSPredicate.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 |
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.NSPredicate; | 7 module dstep.foundation.NSPredicate; |
8 | 8 |
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSCoder; | |
11 import dstep.foundation.NSDictionary; | |
10 import dstep.foundation.NSObject; | 12 import dstep.foundation.NSObject; |
11 import dstep.foundation.NSSet; | 13 import dstep.foundation.NSSet; |
14 import dstep.foundation.NSString; | |
15 import dstep.foundation.NSZone; | |
12 import dstep.objc.bridge.Bridge; | 16 import dstep.objc.bridge.Bridge; |
13 import dstep.objc.objc : id; | 17 import dstep.objc.objc; |
18 | |
19 | |
20 const TNSPredicateSupport = ` | |
21 | |
22 void filterUsingPredicate (NSPredicate predicate) | |
23 { | |
24 return invokeObjcSelf!(void, "filterUsingPredicate:", NSPredicate)(predicate); | |
25 } | |
26 `; | |
14 | 27 |
15 class NSPredicate : NSObject, INSCoding, INSCopying | 28 class NSPredicate : NSObject, INSCoding, INSCopying |
16 { | 29 { |
17 mixin ObjcWrap; | 30 mixin (ObjcWrap); |
31 | |
32 this () | |
33 { | |
34 super(typeof(this).alloc.init.objcObject); | |
35 } | |
36 | |
37 typeof(this) init () | |
38 { | |
39 return invokeObjcSelf!(typeof(this), "init"); | |
40 } | |
18 | 41 |
19 static NSPredicate predicateWithFormat (NSString predicateFormat, NSArray arguments) | 42 static NSPredicate predicateWithFormat (NSString predicateFormat, NSArray arguments) |
20 { | 43 { |
21 return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:argumentArray:", NSString, NSArray)(predicateFormat, arguments); | 44 return invokeObjcSuperClass!(NSPredicate, "predicateWithFormat:argumentArray:", NSString, NSArray)(predicateFormat, arguments); |
22 } | 45 } |
23 | 46 |
24 static NSPredicate predicateWithFormat (NSString predicateWithFormat, ...) | 47 static NSPredicate predicateWithFormat (NSString predicateWithFormat, ...) |
25 { | 48 { |
26 return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:", NSString)(predicateWithFormat); | 49 return invokeObjcSuperClass!(NSPredicate, "predicateWithFormat:", NSString)(predicateWithFormat); |
27 } | 50 } |
28 | 51 |
29 static NSPredicate predicateWithFormat (NSString predicateFormat, char* argList) | 52 static NSPredicate predicateWithFormat (NSString predicateFormat, char* argList) |
30 { | 53 { |
31 return invokeObjcSelfClass!(NSPredicate, "predicateWithFormat:arguments:", NSString, char*)(predicateFormat, argList); | 54 return invokeObjcSuperClass!(NSPredicate, "predicateWithFormat:arguments:", NSString, char*)(predicateFormat, argList); |
32 } | 55 } |
33 | 56 |
34 static NSPredicate predicateWithValue (bool value) | 57 static NSPredicate predicateWithValue (bool value) |
35 { | 58 { |
36 return invokeObjcSelfClass!(NSPredicate, "predicateWithValue:", bool)(value); | 59 return invokeObjcSuperClass!(NSPredicate, "predicateWithValue:", bool)(value); |
37 } | 60 } |
38 | 61 |
39 NSString predicateFormat () | 62 NSString predicateFormat () |
40 { | 63 { |
41 return invokeObjcSelf!(NSString, "predicateFormat"); | 64 return invokeObjcSelf!(NSString, "predicateFormat"); |
67 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | 90 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); |
68 } | 91 } |
69 | 92 |
70 this (NSCoder aDecoder) | 93 this (NSCoder aDecoder) |
71 { | 94 { |
72 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 95 typeof(this).alloc.initWithCoder(aDecoder); |
73 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
74 | |
75 if (result) | |
76 objcObject = ret; | |
77 | |
78 dObject = this; | |
79 } | 96 } |
80 | 97 |
81 Object copyWithZone (NSZone* zone) | 98 Object copyWithZone (NSZone* zone) |
82 { | 99 { |
83 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | 100 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); |
84 } | 101 } |
85 } | 102 } |
86 | |
87 template TNSPredicateSupport () | |
88 { | |
89 void filterUsingPredicate (NSPredicate predicate) | |
90 { | |
91 return invokeObjcSelf!(void, "filterUsingPredicate:", NSPredicate)(predicate); | |
92 } | |
93 } | |
94 |