Mercurial > projects > dstep
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dstep/foundation/NSExpression.d Mon Aug 03 15:23:15 2009 +0200 @@ -0,0 +1,180 @@ +/** + * Copyright: Copyright (c) 2009 Jacob Carlborg. + * Authors: Jacob Carlborg + * Version: Initial created: Aug 3, 2009 + * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) + */ +module dstep.foundation.NSExpression; + +import dstep.foundation.NSArray; +import dstep.foundation.NSMutableDictionary; +import dstep.foundation.NSObject; +import dstep.foundation.NSPredicate; +import dstep.foundation.NSString; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc : id; + +alias NSUInteger NSExpressionType; + +enum +{ + NSConstantValueExpressionType = 0, + NSEvaluatedObjectExpressionType, + NSVariableExpressionType, + NSKeyPathExpressionType, + NSFunctionExpressionType, + NSUnionSetExpressionType, + NSIntersectSetExpressionType, + NSMinusSetExpressionType, + NSSubqueryExpressionType = 13, + NSAggregateExpressionType +} + +class NSExpression : NSObject, INSCoding, INSCopying +{ + mixin ObjcWrap; + + static NSExpression expressionForConstantValue (Object obj) + { + return invokeObjcSelfClass!(NSExpression, "expressionForConstantValue:", Object)(objreturn result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + static NSExpression expressionForEvaluatedObject () + { + return invokeObjcSelfClass!(NSExpression, "expressionForEvaluatedObject"return result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + static NSExpression expressionForVariable (NSString string) + { + return invokeObjcSelfClass!(NSExpression, "expressionForVariable:", NSString)(stringreturn result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + static NSExpression expressionForKeyPath (NSString keyPath) + { + return invokeObjcSelfClass!(NSExpression, "expressionForKeyPath:", NSString)(keyPathreturn result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + static NSExpression expressionForFunction (NSString name, NSArray parameters) + { + return invokeObjcSelfClass!(NSExpression, "expressionForFunction:arguments:", NSString, NSArray)(name, parametersreturn result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + static NSExpression expressionForAggregate (NSArray subexpressions) + { + return invokeObjcSelfClass!(NSExpression, "expressionForAggregate:", NSArray)(subexpressionsreturn result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + static NSExpression expressionForUnionSet (NSExpression left, NSExpression right) + { + return invokeObjcSelfClass!(NSExpression, "expressionForUnionSet:with:", NSExpression, NSExpression)(left, rightreturn result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + static NSExpression expressionForIntersectSet (NSExpression left, NSExpression right) + { + return invokeObjcSelfClass!(NSExpression, "expressionForIntersectSet:with:", NSExpression, NSExpression)(left, rightreturn result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + static NSExpression expressionForMinusSet (NSExpression left, NSExpression right) + { + return invokeObjcSelfClass!(NSExpression, "expressionForMinusSet:with:", NSExpression, NSExpression)(left, rightreturn result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + static NSExpression expressionForSubquery (NSExpression expression, NSString variable, Object predicate) + { + return invokeObjcSelfClass!(NSExpression, "expressionForSubquery:usingIteratorVariable:predicate:", NSExpression, NSString, Object)(expression, variable, predicatereturn result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + static NSExpression expressionForFunction (NSExpression target, NSString name, NSArray parameters) + { + return invokeObjcSelfClass!(NSExpression, "expressionForFunction:selectorName:arguments:", NSExpression, NSString, NSArray)(target, name, parametersreturn result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + Object initWithExpressionType (uint type) + { + return invokeObjcSelf!(Object, "initWithExpressionType:", uint)(type); + } + + this (uint type) + { + objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); + id result = Bridge.invokeObjcMethod!(id, "initWithExpressionType:", uint)(objcObject, type); + + if (result) + objcObject = ret; + + dObject = this; + } + + uint expressionType () + { + return invokeObjcSelf!(uint, "expressionType"); + } + + Object constantValue () + { + return invokeObjcSelf!(Object, "constantValue"); + } + + NSString keyPath () + { + return invokeObjcSelf!(NSString, "keyPath"); + } + + NSString function_ () + { + return invokeObjcSelf!(NSString, "function"); + } + + NSString variable () + { + return invokeObjcSelf!(NSString, "variable"); + } + + NSExpression operand () + { + id result = invokeObjcSelf!(id, "operand"return result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + NSArray arguments () + { + return invokeObjcSelf!(NSArray, "arguments"); + } + + Object collection () + { + return invokeObjcSelf!(Object, "collection"); + } + + NSPredicate predicate () + { + return invokeObjcSelf!(NSPredicate, "predicate"); + } + + NSExpression leftExpression () + { + id result = invokeObjcSelf!(id, "leftExpression"return result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + NSExpression rightExpression () + { + id result = invokeObjcSelf!(id, "rightExpression"return result is this.objcObject ? this : (result !is null ? new NSExpression(result) : null); } + + Object expressionValueWithObject (Object object, NSMutableDictionary context) + { + return invokeObjcSelf!(Object, "expressionValueWithObject:context:", Object, NSMutableDictionary)(object, context); + } + + void encodeWithCoder (NSCoder aCoder) + { + return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); + } + + Object initWithCoder (NSCoder aDecoder) + { + return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); + } + + this (NSCoder aDecoder) + { + objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); + id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); + + if (result) + objcObject = ret; + + dObject = this; + } + + Object copyWithZone (NSZone* zone) + { + return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); + } +} +