Mercurial > projects > dstep
diff dstep/foundation/NSScriptCommand.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/NSScriptCommand.d Mon Aug 03 15:23:15 2009 +0200 @@ -0,0 +1,194 @@ +/** + * 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.NSScriptCommand; + +import dstep.foundation.NSAppleEventDescriptor; +import dstep.foundation.NSDictionary; +import dstep.foundation.NSMutableDictionary; +import dstep.foundation.NSObject; +import dstep.foundation.NSScriptCommandDescription; +import dstep.foundation.NSScriptObjectSpecifier; +import dstep.foundation.NSString; +import dstep.objc.bridge.Bridge; +import dstep.objc.objc : id; + +enum +{ + NSNoScriptError = 0, + NSReceiverEvaluationScriptError, + NSKeySpecifierEvaluationScriptError, + NSArgumentEvaluationScriptError, + NSReceiversCantHandleCommandScriptError, + NSRequiredArgumentsMissingScriptError, + NSArgumentsWrongScriptError, + NSUnknownKeyScriptError, + NSInternalScriptError, + NSOperationNotSupportedForKeyScriptError, + NSCannotCreateScriptCommandError +} + +class NSScriptCommand : NSObject, INSCoding +{ + mixin ObjcWrap; + + Object initWithCommandDescription (NSScriptCommandDescription commandDef) + { + return invokeObjcSelf!(Object, "initWithCommandDescription:", NSScriptCommandDescription)(commandDef); + } + + this (NSScriptCommandDescription commandDef) + { + objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); + id result = Bridge.invokeObjcMethod!(id, "initWithCommandDescription:", NSScriptCommandDescription)(objcObject, commandDef); + + if (result) + objcObject = ret; + + dObject = this; + } + + NSScriptCommandDescription commandDescription () + { + return invokeObjcSelf!(NSScriptCommandDescription, "commandDescription"); + } + + void setDirectParameter (Object directParameter) + { + return invokeObjcSelf!(void, "setDirectParameter:", Object)(directParameter); + } + + Object directParameter () + { + return invokeObjcSelf!(Object, "directParameter"); + } + + void setReceiversSpecifier (NSScriptObjectSpecifier receiversRef) + { + return invokeObjcSelf!(void, "setReceiversSpecifier:", NSScriptObjectSpecifier)(receiversRef); + } + + NSScriptObjectSpecifier receiversSpecifier () + { + return invokeObjcSelf!(NSScriptObjectSpecifier, "receiversSpecifier"); + } + + Object evaluatedReceivers () + { + return invokeObjcSelf!(Object, "evaluatedReceivers"); + } + + void setArguments (NSDictionary args) + { + return invokeObjcSelf!(void, "setArguments:", NSDictionary)(args); + } + + NSDictionary arguments () + { + return invokeObjcSelf!(NSDictionary, "arguments"); + } + + NSDictionary evaluatedArguments () + { + return invokeObjcSelf!(NSDictionary, "evaluatedArguments"); + } + + bool isWellFormed () + { + return invokeObjcSelf!(bool, "isWellFormed"); + } + + Object performDefaultImplementation () + { + return invokeObjcSelf!(Object, "performDefaultImplementation"); + } + + Object executeCommand () + { + return invokeObjcSelf!(Object, "executeCommand"); + } + + void setScriptErrorNumber (int errorNumber) + { + return invokeObjcSelf!(void, "setScriptErrorNumber:", int)(errorNumber); + } + + void setScriptErrorOffendingObjectDescriptor (NSAppleEventDescriptor errorOffendingObjectDescriptor) + { + return invokeObjcSelf!(void, "setScriptErrorOffendingObjectDescriptor:", NSAppleEventDescriptor)(errorOffendingObjectDescriptor); + } + + void setScriptErrorExpectedTypeDescriptor (NSAppleEventDescriptor errorExpectedTypeDescriptor) + { + return invokeObjcSelf!(void, "setScriptErrorExpectedTypeDescriptor:", NSAppleEventDescriptor)(errorExpectedTypeDescriptor); + } + + void setScriptErrorString (NSString errorString) + { + return invokeObjcSelf!(void, "setScriptErrorString:", NSString)(errorString); + } + + int scriptErrorNumber () + { + return invokeObjcSelf!(int, "scriptErrorNumber"); + } + + NSAppleEventDescriptor scriptErrorOffendingObjectDescriptor () + { + return invokeObjcSelf!(NSAppleEventDescriptor, "scriptErrorOffendingObjectDescriptor"); + } + + NSAppleEventDescriptor scriptErrorExpectedTypeDescriptor () + { + return invokeObjcSelf!(NSAppleEventDescriptor, "scriptErrorExpectedTypeDescriptor"); + } + + NSString scriptErrorString () + { + return invokeObjcSelf!(NSString, "scriptErrorString"); + } + + static NSScriptCommand currentCommand () + { + return invokeObjcSelfClass!(NSScriptCommand, "currentCommand"return result is this.objcObject ? this : (result !is null ? new NSScriptCommand(result) : null); } + + NSAppleEventDescriptor appleEvent () + { + return invokeObjcSelf!(NSAppleEventDescriptor, "appleEvent"); + } + + void suspendExecution () + { + return invokeObjcSelf!(void, "suspendExecution"); + } + + void resumeExecutionWithResult (Object result) + { + return invokeObjcSelf!(void, "resumeExecutionWithResult:", Object)(result); + } + + 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; + } +} +