Mercurial > projects > dstep
annotate dstep/foundation/NSPredicate.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.NSPredicate; | |
8 | |
9 import dstep.foundation.NSArray; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
10 import dstep.foundation.NSCoder; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
11 import dstep.foundation.NSDictionary; |
14 | 12 import dstep.foundation.NSObject; |
13 import dstep.foundation.NSSet; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
14 import dstep.foundation.NSString; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
15 import dstep.foundation.NSZone; |
14 | 16 import dstep.objc.bridge.Bridge; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
17 import dstep.objc.objc; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
18 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
19 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
20 const TNSPredicateSupport = ` |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
21 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
22 void filterUsingPredicate (NSPredicate predicate) |
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 return invokeObjcSelf!(void, "filterUsingPredicate:", NSPredicate)(predicate); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
25 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
26 `; |
14 | 27 |
28 class NSPredicate : NSObject, INSCoding, INSCopying | |
29 { | |
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
|
30 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
|
31 |
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
|
32 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
|
33 { |
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
|
34 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
|
35 } |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
36 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
37 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
38 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
39 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
40 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
41 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
42 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
43 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
44 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
45 } |
14 | 46 |
47 static NSPredicate predicateWithFormat (NSString predicateFormat, NSArray arguments) | |
48 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
49 return invokeObjcSuperClass!(NSPredicate, "predicateWithFormat:argumentArray:", NSString, NSArray)(predicateFormat, arguments); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
50 } |
14 | 51 |
52 static NSPredicate predicateWithFormat (NSString predicateWithFormat, ...) | |
53 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
54 return invokeObjcSuperClass!(NSPredicate, "predicateWithFormat:", NSString)(predicateWithFormat); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
55 } |
14 | 56 |
57 static NSPredicate predicateWithFormat (NSString predicateFormat, char* argList) | |
58 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
59 return invokeObjcSuperClass!(NSPredicate, "predicateWithFormat:arguments:", NSString, char*)(predicateFormat, argList); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
60 } |
14 | 61 |
62 static NSPredicate predicateWithValue (bool value) | |
63 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
64 return invokeObjcSuperClass!(NSPredicate, "predicateWithValue:", bool)(value); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
65 } |
14 | 66 |
67 NSString predicateFormat () | |
68 { | |
69 return invokeObjcSelf!(NSString, "predicateFormat"); | |
70 } | |
71 | |
72 NSPredicate predicateWithSubstitutionVariables (NSDictionary variables) | |
73 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
74 id result = invokeObjcSelf!(id, "predicateWithSubstitutionVariables:", NSDictionary)(variables); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
75 return result is this.objcObject ? this : (result !is null ? new NSPredicate(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
76 } |
14 | 77 |
78 bool evaluateWithObject (Object object) | |
79 { | |
80 return invokeObjcSelf!(bool, "evaluateWithObject:", Object)(object); | |
81 } | |
82 | |
83 bool evaluateWithObject (Object object, NSDictionary bindings) | |
84 { | |
85 return invokeObjcSelf!(bool, "evaluateWithObject:substitutionVariables:", Object, NSDictionary)(object, bindings); | |
86 } | |
87 | |
88 void encodeWithCoder (NSCoder aCoder) | |
89 { | |
90 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
91 } | |
92 | |
93 Object initWithCoder (NSCoder aDecoder) | |
94 { | |
95 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
96 } | |
97 | |
98 this (NSCoder aDecoder) | |
99 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
100 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 101 } |
102 | |
103 Object copyWithZone (NSZone* zone) | |
104 { | |
105 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
106 } | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
107 } |