Mercurial > projects > dstep
annotate dstep/foundation/NSExpression.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.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 { | |
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
|
38 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
|
39 |
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
|
40 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
|
41 { |
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
|
42 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
|
43 } |
16
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 this () |
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 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
48 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
49 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
50 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
51 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
52 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
53 } |
14 | 54 |
55 static NSExpression expressionForConstantValue (Object obj) | |
56 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
57 return invokeObjcSuperClass!(NSExpression, "expressionForConstantValue:", Object)(obj); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
58 } |
14 | 59 |
60 static NSExpression expressionForEvaluatedObject () | |
61 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
62 return invokeObjcSuperClass!(NSExpression, "expressionForEvaluatedObject"); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
63 } |
14 | 64 |
65 static NSExpression expressionForVariable (NSString string) | |
66 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
67 return invokeObjcSuperClass!(NSExpression, "expressionForVariable:", NSString)(string); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
68 } |
14 | 69 |
70 static NSExpression expressionForKeyPath (NSString keyPath) | |
71 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
72 return invokeObjcSuperClass!(NSExpression, "expressionForKeyPath:", NSString)(keyPath); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
73 } |
14 | 74 |
75 static NSExpression expressionForFunction (NSString name, NSArray parameters) | |
76 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
77 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
|
78 } |
14 | 79 |
80 static NSExpression expressionForAggregate (NSArray subexpressions) | |
81 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
82 return invokeObjcSuperClass!(NSExpression, "expressionForAggregate:", NSArray)(subexpressions); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
83 } |
14 | 84 |
85 static NSExpression expressionForUnionSet (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, "expressionForUnionSet: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 expressionForIntersectSet (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, "expressionForIntersectSet: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 expressionForMinusSet (NSExpression left, NSExpression right) | |
96 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
97 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
|
98 } |
14 | 99 |
100 static NSExpression expressionForSubquery (NSExpression expression, NSString variable, Object predicate) | |
101 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
102 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
|
103 } |
14 | 104 |
105 static NSExpression expressionForFunction (NSExpression target, NSString name, NSArray parameters) | |
106 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
107 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
|
108 } |
14 | 109 |
110 Object initWithExpressionType (uint type) | |
111 { | |
112 return invokeObjcSelf!(Object, "initWithExpressionType:", uint)(type); | |
113 } | |
114 | |
115 this (uint type) | |
116 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
117 typeof(this).alloc.initWithExpressionType(type); |
14 | 118 } |
119 | |
120 uint expressionType () | |
121 { | |
122 return invokeObjcSelf!(uint, "expressionType"); | |
123 } | |
124 | |
125 Object constantValue () | |
126 { | |
127 return invokeObjcSelf!(Object, "constantValue"); | |
128 } | |
129 | |
130 NSString keyPath () | |
131 { | |
132 return invokeObjcSelf!(NSString, "keyPath"); | |
133 } | |
134 | |
135 NSString function_ () | |
136 { | |
137 return invokeObjcSelf!(NSString, "function"); | |
138 } | |
139 | |
140 NSString variable () | |
141 { | |
142 return invokeObjcSelf!(NSString, "variable"); | |
143 } | |
144 | |
145 NSExpression operand () | |
146 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
147 id result = invokeObjcSelf!(id, "operand"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
148 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
|
149 } |
14 | 150 |
151 NSArray arguments () | |
152 { | |
153 return invokeObjcSelf!(NSArray, "arguments"); | |
154 } | |
155 | |
156 Object collection () | |
157 { | |
158 return invokeObjcSelf!(Object, "collection"); | |
159 } | |
160 | |
161 NSPredicate predicate () | |
162 { | |
163 return invokeObjcSelf!(NSPredicate, "predicate"); | |
164 } | |
165 | |
166 NSExpression leftExpression () | |
167 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
168 id result = invokeObjcSelf!(id, "leftExpression"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
169 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
|
170 } |
14 | 171 |
172 NSExpression rightExpression () | |
173 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
174 id result = invokeObjcSelf!(id, "rightExpression"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
175 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
|
176 } |
14 | 177 |
178 Object expressionValueWithObject (Object object, NSMutableDictionary context) | |
179 { | |
180 return invokeObjcSelf!(Object, "expressionValueWithObject:context:", Object, NSMutableDictionary)(object, context); | |
181 } | |
182 | |
183 void encodeWithCoder (NSCoder aCoder) | |
184 { | |
185 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
186 } | |
187 | |
188 Object initWithCoder (NSCoder aDecoder) | |
189 { | |
190 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
191 } | |
192 | |
193 this (NSCoder aDecoder) | |
194 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
195 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 196 } |
197 | |
198 Object copyWithZone (NSZone* zone) | |
199 { | |
200 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
201 } | |
202 } | |
203 |