Mercurial > projects > dstep
comparison 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 |
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.NSExpression; | 7 module dstep.foundation.NSExpression; |
8 | 8 |
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSMutableDictionary; | 10 import dstep.foundation.NSCoder; |
11 import dstep.foundation.NSDictionary; | |
12 import dstep.foundation.NSObjCRuntime; | |
11 import dstep.foundation.NSObject; | 13 import dstep.foundation.NSObject; |
12 import dstep.foundation.NSPredicate; | 14 import dstep.foundation.NSPredicate; |
13 import dstep.foundation.NSString; | 15 import dstep.foundation.NSString; |
16 import dstep.foundation.NSZone; | |
14 import dstep.objc.bridge.Bridge; | 17 import dstep.objc.bridge.Bridge; |
15 import dstep.objc.objc : id; | 18 import dstep.objc.objc; |
16 | 19 |
17 alias NSUInteger NSExpressionType; | 20 alias NSUInteger NSExpressionType; |
18 | 21 |
19 enum | 22 enum |
20 { | 23 { |
30 NSAggregateExpressionType | 33 NSAggregateExpressionType |
31 } | 34 } |
32 | 35 |
33 class NSExpression : NSObject, INSCoding, INSCopying | 36 class NSExpression : NSObject, INSCoding, INSCopying |
34 { | 37 { |
35 mixin ObjcWrap; | 38 mixin (ObjcWrap); |
39 | |
40 this () | |
41 { | |
42 super(typeof(this).alloc.init.objcObject); | |
43 } | |
44 | |
45 typeof(this) init () | |
46 { | |
47 return invokeObjcSelf!(typeof(this), "init"); | |
48 } | |
36 | 49 |
37 static NSExpression expressionForConstantValue (Object obj) | 50 static NSExpression expressionForConstantValue (Object obj) |
38 { | 51 { |
39 return invokeObjcSelfClass!(NSExpression, "expressionForConstantValue:", Object)(obj); | 52 return invokeObjcSuperClass!(NSExpression, "expressionForConstantValue:", Object)(obj); |
40 } | 53 } |
41 | 54 |
42 static NSExpression expressionForEvaluatedObject () | 55 static NSExpression expressionForEvaluatedObject () |
43 { | 56 { |
44 return invokeObjcSelfClass!(NSExpression, "expressionForEvaluatedObject"); | 57 return invokeObjcSuperClass!(NSExpression, "expressionForEvaluatedObject"); |
45 } | 58 } |
46 | 59 |
47 static NSExpression expressionForVariable (NSString string) | 60 static NSExpression expressionForVariable (NSString string) |
48 { | 61 { |
49 return invokeObjcSelfClass!(NSExpression, "expressionForVariable:", NSString)(string); | 62 return invokeObjcSuperClass!(NSExpression, "expressionForVariable:", NSString)(string); |
50 } | 63 } |
51 | 64 |
52 static NSExpression expressionForKeyPath (NSString keyPath) | 65 static NSExpression expressionForKeyPath (NSString keyPath) |
53 { | 66 { |
54 return invokeObjcSelfClass!(NSExpression, "expressionForKeyPath:", NSString)(keyPath); | 67 return invokeObjcSuperClass!(NSExpression, "expressionForKeyPath:", NSString)(keyPath); |
55 } | 68 } |
56 | 69 |
57 static NSExpression expressionForFunction (NSString name, NSArray parameters) | 70 static NSExpression expressionForFunction (NSString name, NSArray parameters) |
58 { | 71 { |
59 return invokeObjcSelfClass!(NSExpression, "expressionForFunction:arguments:", NSString, NSArray)(name, parameters); | 72 return invokeObjcSuperClass!(NSExpression, "expressionForFunction:arguments:", NSString, NSArray)(name, parameters); |
60 } | 73 } |
61 | 74 |
62 static NSExpression expressionForAggregate (NSArray subexpressions) | 75 static NSExpression expressionForAggregate (NSArray subexpressions) |
63 { | 76 { |
64 return invokeObjcSelfClass!(NSExpression, "expressionForAggregate:", NSArray)(subexpressions); | 77 return invokeObjcSuperClass!(NSExpression, "expressionForAggregate:", NSArray)(subexpressions); |
65 } | 78 } |
66 | 79 |
67 static NSExpression expressionForUnionSet (NSExpression left, NSExpression right) | 80 static NSExpression expressionForUnionSet (NSExpression left, NSExpression right) |
68 { | 81 { |
69 return invokeObjcSelfClass!(NSExpression, "expressionForUnionSet:with:", NSExpression, NSExpression)(left, right); | 82 return invokeObjcSuperClass!(NSExpression, "expressionForUnionSet:with:", NSExpression, NSExpression)(left, right); |
70 } | 83 } |
71 | 84 |
72 static NSExpression expressionForIntersectSet (NSExpression left, NSExpression right) | 85 static NSExpression expressionForIntersectSet (NSExpression left, NSExpression right) |
73 { | 86 { |
74 return invokeObjcSelfClass!(NSExpression, "expressionForIntersectSet:with:", NSExpression, NSExpression)(left, right); | 87 return invokeObjcSuperClass!(NSExpression, "expressionForIntersectSet:with:", NSExpression, NSExpression)(left, right); |
75 } | 88 } |
76 | 89 |
77 static NSExpression expressionForMinusSet (NSExpression left, NSExpression right) | 90 static NSExpression expressionForMinusSet (NSExpression left, NSExpression right) |
78 { | 91 { |
79 return invokeObjcSelfClass!(NSExpression, "expressionForMinusSet:with:", NSExpression, NSExpression)(left, right); | 92 return invokeObjcSuperClass!(NSExpression, "expressionForMinusSet:with:", NSExpression, NSExpression)(left, right); |
80 } | 93 } |
81 | 94 |
82 static NSExpression expressionForSubquery (NSExpression expression, NSString variable, Object predicate) | 95 static NSExpression expressionForSubquery (NSExpression expression, NSString variable, Object predicate) |
83 { | 96 { |
84 return invokeObjcSelfClass!(NSExpression, "expressionForSubquery:usingIteratorVariable:predicate:", NSExpression, NSString, Object)(expression, variable, predicate); | 97 return invokeObjcSuperClass!(NSExpression, "expressionForSubquery:usingIteratorVariable:predicate:", NSExpression, NSString, Object)(expression, variable, predicate); |
85 } | 98 } |
86 | 99 |
87 static NSExpression expressionForFunction (NSExpression target, NSString name, NSArray parameters) | 100 static NSExpression expressionForFunction (NSExpression target, NSString name, NSArray parameters) |
88 { | 101 { |
89 return invokeObjcSelfClass!(NSExpression, "expressionForFunction:selectorName:arguments:", NSExpression, NSString, NSArray)(target, name, parameters); | 102 return invokeObjcSuperClass!(NSExpression, "expressionForFunction:selectorName:arguments:", NSExpression, NSString, NSArray)(target, name, parameters); |
90 } | 103 } |
91 | 104 |
92 Object initWithExpressionType (uint type) | 105 Object initWithExpressionType (uint type) |
93 { | 106 { |
94 return invokeObjcSelf!(Object, "initWithExpressionType:", uint)(type); | 107 return invokeObjcSelf!(Object, "initWithExpressionType:", uint)(type); |
95 } | 108 } |
96 | 109 |
97 this (uint type) | 110 this (uint type) |
98 { | 111 { |
99 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 112 typeof(this).alloc.initWithExpressionType(type); |
100 id result = Bridge.invokeObjcMethod!(id, "initWithExpressionType:", uint)(objcObject, type); | |
101 | |
102 if (result) | |
103 objcObject = ret; | |
104 | |
105 dObject = this; | |
106 } | 113 } |
107 | 114 |
108 uint expressionType () | 115 uint expressionType () |
109 { | 116 { |
110 return invokeObjcSelf!(uint, "expressionType"); | 117 return invokeObjcSelf!(uint, "expressionType"); |
178 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | 185 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); |
179 } | 186 } |
180 | 187 |
181 this (NSCoder aDecoder) | 188 this (NSCoder aDecoder) |
182 { | 189 { |
183 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 190 typeof(this).alloc.initWithCoder(aDecoder); |
184 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
185 | |
186 if (result) | |
187 objcObject = ret; | |
188 | |
189 dObject = this; | |
190 } | 191 } |
191 | 192 |
192 Object copyWithZone (NSZone* zone) | 193 Object copyWithZone (NSZone* zone) |
193 { | 194 { |
194 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | 195 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); |