Mercurial > projects > dstep
comparison 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 |
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.NSScriptCommand; | |
8 | |
9 import dstep.foundation.NSAppleEventDescriptor; | |
10 import dstep.foundation.NSDictionary; | |
11 import dstep.foundation.NSMutableDictionary; | |
12 import dstep.foundation.NSObject; | |
13 import dstep.foundation.NSScriptCommandDescription; | |
14 import dstep.foundation.NSScriptObjectSpecifier; | |
15 import dstep.foundation.NSString; | |
16 import dstep.objc.bridge.Bridge; | |
17 import dstep.objc.objc : id; | |
18 | |
19 enum | |
20 { | |
21 NSNoScriptError = 0, | |
22 NSReceiverEvaluationScriptError, | |
23 NSKeySpecifierEvaluationScriptError, | |
24 NSArgumentEvaluationScriptError, | |
25 NSReceiversCantHandleCommandScriptError, | |
26 NSRequiredArgumentsMissingScriptError, | |
27 NSArgumentsWrongScriptError, | |
28 NSUnknownKeyScriptError, | |
29 NSInternalScriptError, | |
30 NSOperationNotSupportedForKeyScriptError, | |
31 NSCannotCreateScriptCommandError | |
32 } | |
33 | |
34 class NSScriptCommand : NSObject, INSCoding | |
35 { | |
36 mixin ObjcWrap; | |
37 | |
38 Object initWithCommandDescription (NSScriptCommandDescription commandDef) | |
39 { | |
40 return invokeObjcSelf!(Object, "initWithCommandDescription:", NSScriptCommandDescription)(commandDef); | |
41 } | |
42 | |
43 this (NSScriptCommandDescription commandDef) | |
44 { | |
45 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
46 id result = Bridge.invokeObjcMethod!(id, "initWithCommandDescription:", NSScriptCommandDescription)(objcObject, commandDef); | |
47 | |
48 if (result) | |
49 objcObject = ret; | |
50 | |
51 dObject = this; | |
52 } | |
53 | |
54 NSScriptCommandDescription commandDescription () | |
55 { | |
56 return invokeObjcSelf!(NSScriptCommandDescription, "commandDescription"); | |
57 } | |
58 | |
59 void setDirectParameter (Object directParameter) | |
60 { | |
61 return invokeObjcSelf!(void, "setDirectParameter:", Object)(directParameter); | |
62 } | |
63 | |
64 Object directParameter () | |
65 { | |
66 return invokeObjcSelf!(Object, "directParameter"); | |
67 } | |
68 | |
69 void setReceiversSpecifier (NSScriptObjectSpecifier receiversRef) | |
70 { | |
71 return invokeObjcSelf!(void, "setReceiversSpecifier:", NSScriptObjectSpecifier)(receiversRef); | |
72 } | |
73 | |
74 NSScriptObjectSpecifier receiversSpecifier () | |
75 { | |
76 return invokeObjcSelf!(NSScriptObjectSpecifier, "receiversSpecifier"); | |
77 } | |
78 | |
79 Object evaluatedReceivers () | |
80 { | |
81 return invokeObjcSelf!(Object, "evaluatedReceivers"); | |
82 } | |
83 | |
84 void setArguments (NSDictionary args) | |
85 { | |
86 return invokeObjcSelf!(void, "setArguments:", NSDictionary)(args); | |
87 } | |
88 | |
89 NSDictionary arguments () | |
90 { | |
91 return invokeObjcSelf!(NSDictionary, "arguments"); | |
92 } | |
93 | |
94 NSDictionary evaluatedArguments () | |
95 { | |
96 return invokeObjcSelf!(NSDictionary, "evaluatedArguments"); | |
97 } | |
98 | |
99 bool isWellFormed () | |
100 { | |
101 return invokeObjcSelf!(bool, "isWellFormed"); | |
102 } | |
103 | |
104 Object performDefaultImplementation () | |
105 { | |
106 return invokeObjcSelf!(Object, "performDefaultImplementation"); | |
107 } | |
108 | |
109 Object executeCommand () | |
110 { | |
111 return invokeObjcSelf!(Object, "executeCommand"); | |
112 } | |
113 | |
114 void setScriptErrorNumber (int errorNumber) | |
115 { | |
116 return invokeObjcSelf!(void, "setScriptErrorNumber:", int)(errorNumber); | |
117 } | |
118 | |
119 void setScriptErrorOffendingObjectDescriptor (NSAppleEventDescriptor errorOffendingObjectDescriptor) | |
120 { | |
121 return invokeObjcSelf!(void, "setScriptErrorOffendingObjectDescriptor:", NSAppleEventDescriptor)(errorOffendingObjectDescriptor); | |
122 } | |
123 | |
124 void setScriptErrorExpectedTypeDescriptor (NSAppleEventDescriptor errorExpectedTypeDescriptor) | |
125 { | |
126 return invokeObjcSelf!(void, "setScriptErrorExpectedTypeDescriptor:", NSAppleEventDescriptor)(errorExpectedTypeDescriptor); | |
127 } | |
128 | |
129 void setScriptErrorString (NSString errorString) | |
130 { | |
131 return invokeObjcSelf!(void, "setScriptErrorString:", NSString)(errorString); | |
132 } | |
133 | |
134 int scriptErrorNumber () | |
135 { | |
136 return invokeObjcSelf!(int, "scriptErrorNumber"); | |
137 } | |
138 | |
139 NSAppleEventDescriptor scriptErrorOffendingObjectDescriptor () | |
140 { | |
141 return invokeObjcSelf!(NSAppleEventDescriptor, "scriptErrorOffendingObjectDescriptor"); | |
142 } | |
143 | |
144 NSAppleEventDescriptor scriptErrorExpectedTypeDescriptor () | |
145 { | |
146 return invokeObjcSelf!(NSAppleEventDescriptor, "scriptErrorExpectedTypeDescriptor"); | |
147 } | |
148 | |
149 NSString scriptErrorString () | |
150 { | |
151 return invokeObjcSelf!(NSString, "scriptErrorString"); | |
152 } | |
153 | |
154 static NSScriptCommand currentCommand () | |
155 { | |
156 return invokeObjcSelfClass!(NSScriptCommand, "currentCommand"return result is this.objcObject ? this : (result !is null ? new NSScriptCommand(result) : null); } | |
157 | |
158 NSAppleEventDescriptor appleEvent () | |
159 { | |
160 return invokeObjcSelf!(NSAppleEventDescriptor, "appleEvent"); | |
161 } | |
162 | |
163 void suspendExecution () | |
164 { | |
165 return invokeObjcSelf!(void, "suspendExecution"); | |
166 } | |
167 | |
168 void resumeExecutionWithResult (Object result) | |
169 { | |
170 return invokeObjcSelf!(void, "resumeExecutionWithResult:", Object)(result); | |
171 } | |
172 | |
173 void encodeWithCoder (NSCoder aCoder) | |
174 { | |
175 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
176 } | |
177 | |
178 Object initWithCoder (NSCoder aDecoder) | |
179 { | |
180 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
181 } | |
182 | |
183 this (NSCoder aDecoder) | |
184 { | |
185 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
186 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
187 | |
188 if (result) | |
189 objcObject = ret; | |
190 | |
191 dObject = this; | |
192 } | |
193 } | |
194 |