Mercurial > projects > dstep
annotate dstep/foundation/NSExpression.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 |
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.NSExpression; | |
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; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
12 import dstep.foundation.NSObjCRuntime; |
14 | 13 import dstep.foundation.NSObject; |
14 import dstep.foundation.NSPredicate; | |
15 import dstep.foundation.NSString; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
16 import dstep.foundation.NSZone; |
14 | 17 import dstep.objc.bridge.Bridge; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
18 import dstep.objc.objc; |
14 | 19 |
20 alias NSUInteger NSExpressionType; | |
21 | |
22 enum | |
23 { | |
24 NSConstantValueExpressionType = 0, | |
25 NSEvaluatedObjectExpressionType, | |
26 NSVariableExpressionType, | |
27 NSKeyPathExpressionType, | |
28 NSFunctionExpressionType, | |
29 NSUnionSetExpressionType, | |
30 NSIntersectSetExpressionType, | |
31 NSMinusSetExpressionType, | |
32 NSSubqueryExpressionType = 13, | |
33 NSAggregateExpressionType | |
34 } | |
35 | |
36 class NSExpression : NSObject, INSCoding, INSCopying | |
37 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
38 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
39 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
40 this () |
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 super(typeof(this).alloc.init.objcObject); |
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 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
45 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
46 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
47 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
48 } |
14 | 49 |
50 static NSExpression expressionForConstantValue (Object obj) | |
51 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
52 return invokeObjcSuperClass!(NSExpression, "expressionForConstantValue:", Object)(obj); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
53 } |
14 | 54 |
55 static NSExpression expressionForEvaluatedObject () | |
56 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
57 return invokeObjcSuperClass!(NSExpression, "expressionForEvaluatedObject"); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
58 } |
14 | 59 |
60 static NSExpression expressionForVariable (NSString string) | |
61 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
62 return invokeObjcSuperClass!(NSExpression, "expressionForVariable:", NSString)(string); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
63 } |
14 | 64 |
65 static NSExpression expressionForKeyPath (NSString keyPath) | |
66 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
67 return invokeObjcSuperClass!(NSExpression, "expressionForKeyPath:", NSString)(keyPath); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
68 } |
14 | 69 |
70 static NSExpression expressionForFunction (NSString name, NSArray parameters) | |
71 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
72 return invokeObjcSuperClass!(NSExpression, "expressionForFunction:arguments:", NSString, NSArray)(name, parameters); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
73 } |
14 | 74 |
75 static NSExpression expressionForAggregate (NSArray subexpressions) | |
76 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
77 return invokeObjcSuperClass!(NSExpression, "expressionForAggregate:", NSArray)(subexpressions); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
78 } |
14 | 79 |
80 static NSExpression expressionForUnionSet (NSExpression left, NSExpression right) | |
81 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
82 return invokeObjcSuperClass!(NSExpression, "expressionForUnionSet:with:", NSExpression, NSExpression)(left, right); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
83 } |
14 | 84 |
85 static NSExpression expressionForIntersectSet (NSExpression left, NSExpression right) | |
86 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
87 return invokeObjcSuperClass!(NSExpression, "expressionForIntersectSet:with:", NSExpression, NSExpression)(left, right); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
88 } |
14 | 89 |
90 static NSExpression expressionForMinusSet (NSExpression left, NSExpression right) | |
91 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
92 return invokeObjcSuperClass!(NSExpression, "expressionForMinusSet:with:", NSExpression, NSExpression)(left, right); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
93 } |
14 | 94 |
95 static NSExpression expressionForSubquery (NSExpression expression, NSString variable, Object predicate) | |
96 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
97 return invokeObjcSuperClass!(NSExpression, "expressionForSubquery:usingIteratorVariable:predicate:", NSExpression, NSString, Object)(expression, variable, predicate); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
98 } |
14 | 99 |
100 static NSExpression expressionForFunction (NSExpression target, NSString name, NSArray parameters) | |
101 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
102 return invokeObjcSuperClass!(NSExpression, "expressionForFunction:selectorName:arguments:", NSExpression, NSString, NSArray)(target, name, parameters); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
103 } |
14 | 104 |
105 Object initWithExpressionType (uint type) | |
106 { | |
107 return invokeObjcSelf!(Object, "initWithExpressionType:", uint)(type); | |
108 } | |
109 | |
110 this (uint type) | |
111 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
112 typeof(this).alloc.initWithExpressionType(type); |
14 | 113 } |
114 | |
115 uint expressionType () | |
116 { | |
117 return invokeObjcSelf!(uint, "expressionType"); | |
118 } | |
119 | |
120 Object constantValue () | |
121 { | |
122 return invokeObjcSelf!(Object, "constantValue"); | |
123 } | |
124 | |
125 NSString keyPath () | |
126 { | |
127 return invokeObjcSelf!(NSString, "keyPath"); | |
128 } | |
129 | |
130 NSString function_ () | |
131 { | |
132 return invokeObjcSelf!(NSString, "function"); | |
133 } | |
134 | |
135 NSString variable () | |
136 { | |
137 return invokeObjcSelf!(NSString, "variable"); | |
138 } | |
139 | |
140 NSExpression operand () | |
141 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
142 id result = invokeObjcSelf!(id, "operand"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
143 return result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
144 } |
14 | 145 |
146 NSArray arguments () | |
147 { | |
148 return invokeObjcSelf!(NSArray, "arguments"); | |
149 } | |
150 | |
151 Object collection () | |
152 { | |
153 return invokeObjcSelf!(Object, "collection"); | |
154 } | |
155 | |
156 NSPredicate predicate () | |
157 { | |
158 return invokeObjcSelf!(NSPredicate, "predicate"); | |
159 } | |
160 | |
161 NSExpression leftExpression () | |
162 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
163 id result = invokeObjcSelf!(id, "leftExpression"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
164 return result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
165 } |
14 | 166 |
167 NSExpression rightExpression () | |
168 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
169 id result = invokeObjcSelf!(id, "rightExpression"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
170 return result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
171 } |
14 | 172 |
173 Object expressionValueWithObject (Object object, NSMutableDictionary context) | |
174 { | |
175 return invokeObjcSelf!(Object, "expressionValueWithObject:context:", Object, NSMutableDictionary)(object, context); | |
176 } | |
177 | |
178 void encodeWithCoder (NSCoder aCoder) | |
179 { | |
180 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
181 } | |
182 | |
183 Object initWithCoder (NSCoder aDecoder) | |
184 { | |
185 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
186 } | |
187 | |
188 this (NSCoder aDecoder) | |
189 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
190 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 191 } |
192 | |
193 Object copyWithZone (NSZone* zone) | |
194 { | |
195 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
196 } | |
197 } | |
198 |