Mercurial > projects > dstep
comparison dstep/foundation/NSAppleScript.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
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.NSAppleScript; | |
8 | |
9 import dstep.foundation.NSAppleEventDescriptor; | |
10 import dstep.foundation.NSDictionary; | |
11 import dstep.foundation.NSObject; | |
12 import dstep.foundation.NSString; | |
13 import dstep.foundation.NSURL; | |
14 import dstep.objc.bridge.Bridge; | |
15 import dstep.objc.objc : id; | |
16 | |
17 import bindings = dstep.foundation.NSAppleScript_bindings; | |
18 | |
19 const NSString NSAppleScriptErrorMessage; | |
20 const NSString NSAppleScriptErrorNumber; | |
21 const NSString NSAppleScriptErrorAppName; | |
22 const NSString NSAppleScriptErrorBriefMessage; | |
23 const NSString NSAppleScriptErrorRange; | |
24 | |
25 static this () | |
26 { | |
27 NSAppleScriptErrorMessage = new NSString(bindings.NSAppleScriptErrorMessage); | |
28 NSAppleScriptErrorNumber = new NSString(bindings.NSAppleScriptErrorNumber); | |
29 NSAppleScriptErrorAppName = new NSString(bindings.NSAppleScriptErrorAppName); | |
30 NSAppleScriptErrorBriefMessage = new NSString(bindings.NSAppleScriptErrorBriefMessage); | |
31 NSAppleScriptErrorRange = new NSString(bindings.NSAppleScriptErrorRange); | |
32 } | |
33 | |
34 class NSAppleScript : NSObject, INSCopying | |
35 { | |
36 mixin ObjcWrap; | |
37 | |
38 Object initWithContentsOfURL (NSURL url, NSDictionary** errorInfo) | |
39 { | |
40 return invokeObjcSelf!(Object, "initWithContentsOfURL:error:", NSURL, NSDictionary**)(url, errorInfo); | |
41 } | |
42 | |
43 this (NSURL url, NSDictionary** errorInfo) | |
44 { | |
45 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
46 id result = Bridge.invokeObjcMethod!(id, "initWithContentsOfURL:error:", NSURL, NSDictionary**)(objcObject, url, errorInfo); | |
47 | |
48 if (result) | |
49 objcObject = ret; | |
50 | |
51 dObject = this; | |
52 } | |
53 | |
54 Object initWithSource (NSString source) | |
55 { | |
56 return invokeObjcSelf!(Object, "initWithSource:", NSString)(source); | |
57 } | |
58 | |
59 this (NSString source) | |
60 { | |
61 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
62 id result = Bridge.invokeObjcMethod!(id, "initWithSource:", NSString)(objcObject, source); | |
63 | |
64 if (result) | |
65 objcObject = ret; | |
66 | |
67 dObject = this; | |
68 } | |
69 | |
70 NSString source () | |
71 { | |
72 return invokeObjcSelf!(NSString, "source"); | |
73 } | |
74 | |
75 bool isCompiled () | |
76 { | |
77 return invokeObjcSelf!(bool, "isCompiled"); | |
78 } | |
79 | |
80 bool compileAndReturnError (NSDictionary** errorInfo) | |
81 { | |
82 return invokeObjcSelf!(bool, "compileAndReturnError:", NSDictionary**)(errorInfo); | |
83 } | |
84 | |
85 NSAppleEventDescriptor executeAndReturnError (NSDictionary** errorInfo) | |
86 { | |
87 return invokeObjcSelf!(NSAppleEventDescriptor, "executeAndReturnError:", NSDictionary**)(errorInfo); | |
88 } | |
89 | |
90 NSAppleEventDescriptor executeAppleEvent (NSAppleEventDescriptor event, NSDictionary** errorInfo) | |
91 { | |
92 return invokeObjcSelf!(NSAppleEventDescriptor, "executeAppleEvent:error:", NSAppleEventDescriptor, NSDictionary**)(event, errorInfo); | |
93 } | |
94 | |
95 Object copyWithZone (NSZone* zone) | |
96 { | |
97 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
98 } | |
99 } | |
100 |