comparison dstep/foundation/NSBundle.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.NSBundle;
8
9 import dstep.foundation.NSArray;
10 import dstep.foundation.NSDictionary;
11 import dstep.foundation.NSError;
12 import dstep.foundation.NSObject;
13 import dstep.foundation.NSString;
14 import dstep.objc.bridge.Bridge;
15 import dstep.objc.objc : id;
16
17 import bindings = dstep.foundation.NSBundle_bindings;
18
19 const NSString NSBundleDidLoadNotification;
20 const NSString NSLoadedClasses;
21
22 enum
23 {
24 NSBundleExecutableArchitectureI386 = 0x00000007,
25 NSBundleExecutableArchitecturePPC = 0x00000012,
26 NSBundleExecutableArchitectureX86_64 = 0x01000007,
27 NSBundleExecutableArchitecturePPC64 = 0x01000012
28 }
29
30 static this ()
31 {
32 NSBundleDidLoadNotification = new NSString(bindings.NSBundleDidLoadNotification);
33 NSLoadedClasses = new NSString(bindings.NSLoadedClasses);
34 }
35
36 class NSBundle : NSObject
37 {
38 mixin ObjcWrap;
39
40 static NSBundle mainBundle ()
41 {
42 return invokeObjcSelfClass!(NSBundle, "mainBundle"return result is this.objcObject ? this : (result !is null ? new NSBundle(result) : null); }
43
44 static NSBundle bundleWithPath (NSString path)
45 {
46 return invokeObjcSelfClass!(NSBundle, "bundleWithPath:", NSString)(pathreturn result is this.objcObject ? this : (result !is null ? new NSBundle(result) : null); }
47
48 Object initWithPath (NSString path)
49 {
50 return invokeObjcSelf!(Object, "initWithPath:", NSString)(path);
51 }
52
53 this (NSString path)
54 {
55 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
56 id result = Bridge.invokeObjcMethod!(id, "initWithPath:", NSString)(objcObject, path);
57
58 if (result)
59 objcObject = ret;
60
61 dObject = this;
62 }
63
64 static NSBundle bundleForClass (Class aClass)
65 {
66 return invokeObjcSelfClass!(NSBundle, "bundleForClass:", Class)(aClassreturn result is this.objcObject ? this : (result !is null ? new NSBundle(result) : null); }
67
68 static NSBundle bundleWithIdentifier (NSString identifier)
69 {
70 return invokeObjcSelfClass!(NSBundle, "bundleWithIdentifier:", NSString)(identifierreturn result is this.objcObject ? this : (result !is null ? new NSBundle(result) : null); }
71
72 static NSArray allBundles ()
73 {
74 return invokeObjcSelfClass!(NSArray, "allBundles");
75 }
76
77 static NSArray allFrameworks ()
78 {
79 return invokeObjcSelfClass!(NSArray, "allFrameworks");
80 }
81
82 bool load ()
83 {
84 return invokeObjcSelf!(bool, "load");
85 }
86
87 bool isLoaded ()
88 {
89 return invokeObjcSelf!(bool, "isLoaded");
90 }
91
92 bool unload ()
93 {
94 return invokeObjcSelf!(bool, "unload");
95 }
96
97 bool preflightAndReturnError (NSError** error)
98 {
99 return invokeObjcSelf!(bool, "preflightAndReturnError:", NSError**)(error);
100 }
101
102 bool loadAndReturnError (NSError** error)
103 {
104 return invokeObjcSelf!(bool, "loadAndReturnError:", NSError**)(error);
105 }
106
107 NSString bundlePath ()
108 {
109 return invokeObjcSelf!(NSString, "bundlePath");
110 }
111
112 NSString resourcePath ()
113 {
114 return invokeObjcSelf!(NSString, "resourcePath");
115 }
116
117 NSString executablePath ()
118 {
119 return invokeObjcSelf!(NSString, "executablePath");
120 }
121
122 NSString pathForAuxiliaryExecutable (NSString executableName)
123 {
124 return invokeObjcSelf!(NSString, "pathForAuxiliaryExecutable:", NSString)(executableName);
125 }
126
127 NSString privateFrameworksPath ()
128 {
129 return invokeObjcSelf!(NSString, "privateFrameworksPath");
130 }
131
132 NSString sharedFrameworksPath ()
133 {
134 return invokeObjcSelf!(NSString, "sharedFrameworksPath");
135 }
136
137 NSString sharedSupportPath ()
138 {
139 return invokeObjcSelf!(NSString, "sharedSupportPath");
140 }
141
142 NSString builtInPlugInsPath ()
143 {
144 return invokeObjcSelf!(NSString, "builtInPlugInsPath");
145 }
146
147 NSString bundleIdentifier ()
148 {
149 return invokeObjcSelf!(NSString, "bundleIdentifier");
150 }
151
152 Class classNamed (NSString className)
153 {
154 return invokeObjcSelf!(Class, "classNamed:", NSString)(className);
155 }
156
157 Class principalClass ()
158 {
159 return invokeObjcSelf!(Class, "principalClass");
160 }
161
162 static NSString pathForResource (NSString name, NSString ext, NSString bundlePath)
163 {
164 return invokeObjcSelfClass!(NSString, "pathForResource:ofType:inDirectory:", NSString, NSString, NSString)(name, ext, bundlePath);
165 }
166
167 NSString pathForResource (NSString name, NSString ext)
168 {
169 return invokeObjcSelf!(NSString, "pathForResource:ofType:", NSString, NSString)(name, ext);
170 }
171
172 NSString pathForResource (NSString name, NSString ext, NSString subpath)
173 {
174 return invokeObjcSelf!(NSString, "pathForResource:ofType:inDirectory:", NSString, NSString, NSString)(name, ext, subpath);
175 }
176
177 NSString pathForResource (NSString name, NSString ext, NSString subpath, NSString localizationName)
178 {
179 return invokeObjcSelf!(NSString, "pathForResource:ofType:inDirectory:forLocalization:", NSString, NSString, NSString, NSString)(name, ext, subpath, localizationName);
180 }
181
182 static NSArray pathsForResourcesOfType (NSString ext, NSString bundlePath)
183 {
184 return invokeObjcSelfClass!(NSArray, "pathsForResourcesOfType:inDirectory:", NSString, NSString)(ext, bundlePath);
185 }
186
187 NSArray pathsForResourcesOfType (NSString ext, NSString subpath)
188 {
189 return invokeObjcSelf!(NSArray, "pathsForResourcesOfType:inDirectory:", NSString, NSString)(ext, subpath);
190 }
191
192 NSArray pathsForResourcesOfType (NSString ext, NSString subpath, NSString localizationName)
193 {
194 return invokeObjcSelf!(NSArray, "pathsForResourcesOfType:inDirectory:forLocalization:", NSString, NSString, NSString)(ext, subpath, localizationName);
195 }
196
197 NSString localizedStringForKey (NSString key, NSString value, NSString tableName)
198 {
199 return invokeObjcSelf!(NSString, "localizedStringForKey:value:table:", NSString, NSString, NSString)(key, value, tableName);
200 }
201
202 NSDictionary infoDictionary ()
203 {
204 return invokeObjcSelf!(NSDictionary, "infoDictionary");
205 }
206
207 NSDictionary localizedInfoDictionary ()
208 {
209 return invokeObjcSelf!(NSDictionary, "localizedInfoDictionary");
210 }
211
212 Object objectForInfoDictionaryKey (NSString key)
213 {
214 return invokeObjcSelf!(Object, "objectForInfoDictionaryKey:", NSString)(key);
215 }
216
217 NSArray localizations ()
218 {
219 return invokeObjcSelf!(NSArray, "localizations");
220 }
221
222 NSArray preferredLocalizations ()
223 {
224 return invokeObjcSelf!(NSArray, "preferredLocalizations");
225 }
226
227 NSString developmentLocalization ()
228 {
229 return invokeObjcSelf!(NSString, "developmentLocalization");
230 }
231
232 static NSArray preferredLocalizationsFromArray (NSArray localizationsArray)
233 {
234 return invokeObjcSelfClass!(NSArray, "preferredLocalizationsFromArray:", NSArray)(localizationsArray);
235 }
236
237 static NSArray preferredLocalizationsFromArray (NSArray localizationsArray, NSArray preferencesArray)
238 {
239 return invokeObjcSelfClass!(NSArray, "preferredLocalizationsFromArray:forPreferences:", NSArray, NSArray)(localizationsArray, preferencesArray);
240 }
241
242 NSArray executableArchitectures ()
243 {
244 return invokeObjcSelf!(NSArray, "executableArchitectures");
245 }
246 }
247