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