Mercurial > projects > dstep
diff dstep/foundation/NSScriptKeyValueCoding.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 | 89f3c3ef1fd2 |
children |
line wrap: on
line diff
--- a/dstep/foundation/NSScriptKeyValueCoding.d Mon Aug 03 15:31:48 2009 +0200 +++ b/dstep/foundation/NSScriptKeyValueCoding.d Sun Jan 03 22:06:11 2010 +0100 @@ -9,26 +9,70 @@ import dstep.foundation.NSObject; import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; -import dstep.objc.objc : id; +import dstep.objc.objc; + + import bindings = dstep.foundation.NSScriptKeyValueCoding_bindings; -NSString NSOperationNotSupportedForKeyException; +private NSString NSOperationNotSupportedForKeyException_; -static this () +NSString NSOperationNotSupportedForKeyException () { - NSOperationNotSupportedForKeyException = new NSString(bindings.NSOperationNotSupportedForKeyException); + if (NSOperationNotSupportedForKeyException_) + return NSOperationNotSupportedForKeyException_; + + return NSOperationNotSupportedForKeyException_ = new NSString(bindings.NSOperationNotSupportedForKeyException); } -template TNSScriptKeyValueCoding () -{ - Object valueAtIndex (NSUInteger index, NSString key); - Object valueWithName (NSString name, NSString key); - Object valueWithUniqueID (Object uniqueID, NSString key); - void insertValue (Object value, NSUInteger index, NSString key); - void removeValueAtIndex (NSUInteger index, NSString key); - void replaceValueAtIndex (NSUInteger index, NSString key, Object value); - void insertValue (Object value, NSString key); - Object coerceValue (Object value, NSString key); -} +const TNSScriptKeyValueCoding = ` + Object valueAtIndex (NSUInteger index, NSString key) + { + return invokeObjcSelf!(Object, "valueAtIndex:inPropertyWithKey:", NSUInteger, NSString)(index, key); + } + + Object valueWithName (NSString name, NSString key) + { + return invokeObjcSelf!(Object, "valueWithName:inPropertyWithKey:", NSString, NSString)(name, key); + } + + Object valueWithUniqueID (Object uniqueID, NSString key) + { + return invokeObjcSelf!(Object, "valueWithUniqueID:inPropertyWithKey:", Object, NSString)(uniqueID, key); + } + + void insertValue (Object value, NSUInteger index, NSString key) + { + return invokeObjcSelf!(void, "insertValue:atIndex:inPropertyWithKey:", Object, NSUInteger, NSString)(value, index, key); + } + + void removeValueAtIndex (NSUInteger index, NSString key) + { + return invokeObjcSelf!(void, "removeValueAtIndex:fromPropertyWithKey:", NSUInteger, NSString)(index, key); + } + + void replaceValueAtIndex (NSUInteger index, NSString key, Object value) + { + return invokeObjcSelf!(void, "replaceValueAtIndex:inPropertyWithKey:withValue:", NSUInteger, NSString, Object)(index, key, value); + } + + void insertValue (Object value, NSString key) + { + return invokeObjcSelf!(void, "insertValue:inPropertyWithKey:", Object, NSString)(value, key); + } + + Object coerceValue (Object value, NSString key) + { + return invokeObjcSelf!(Object, "coerceValue:forKey:", Object, NSString)(value, key); + } + + //mixin ObjcBindMethod!(valueAtIndex, "valueAtIndex:inPropertyWithKey:"); + //mixin ObjcBindMethod!(valueWithName, "valueWithName:inPropertyWithKey:"); + //mixin ObjcBindMethod!(valueWithUniqueID, "valueWithUniqueID:inPropertyWithKey:"); + //mixin ObjcBindMethod!(insertValue, "insertValue:atIndex:inPropertyWithKey:"); + //mixin ObjcBindMethod!(removeValueAtIndex, "removeValueAtIndex:fromPropertyWithKey:"); + //mixin ObjcBindMethod!(replaceValueAtIndex, "replaceValueAtIndex:inPropertyWithKey:withValue:"); + //mixin ObjcBindMethod!(insertValue, "insertValue:inPropertyWithKey:"); + //mixin ObjcBindMethod!(coerceValue, "coerceValue:forKey:"); +`; \ No newline at end of file