Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSBundle.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * | |
11 * Port to the D Programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
13 *******************************************************************************/ | |
14 module dwt.internal.cocoa.NSBundle; | |
15 | |
16 import dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSArray; | |
18 import dwt.internal.cocoa.NSDictionary; | |
19 import dwt.internal.cocoa.NSObject; | |
20 import dwt.internal.cocoa.NSString; | |
21 import dwt.internal.cocoa.OS; | |
22 import objc = dwt.internal.objc.runtime; | |
23 | |
24 public class NSBundle : NSObject | |
25 { | |
26 | |
27 public this () | |
28 { | |
29 super(); | |
30 } | |
31 | |
32 public this (objc.id id) | |
33 { | |
34 super(id); | |
35 } | |
36 | |
37 public static NSArray allBundles () | |
38 { | |
39 objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_allBundles); | |
40 return result !is null ? new NSArray(result) : null; | |
41 } | |
42 | |
43 public static NSArray allFrameworks () | |
44 { | |
45 objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_allFrameworks); | |
46 return result !is null ? new NSArray(result) : null; | |
47 } | |
48 | |
49 public NSString builtInPlugInsPath () | |
50 { | |
51 objc.id result = OS.objc_msgSend(this.id, OS.sel_builtInPlugInsPath); | |
52 return result !is null ? new NSString(result) : null; | |
53 } | |
54 | |
55 public static NSBundle bundleForClass (objc.Class aClass) | |
56 { | |
57 objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleForClass_1, aClass); | |
58 return result !is null ? new NSBundle(result) : null; | |
59 } | |
60 | |
61 public NSString bundleIdentifier () | |
62 { | |
63 objc.id result = OS.objc_msgSend(this.id, OS.sel_bundleIdentifier); | |
64 return result !is null ? new NSString(result) : null; | |
65 } | |
66 | |
67 public NSString bundlePath () | |
68 { | |
69 objc.id result = OS.objc_msgSend(this.id, OS.sel_bundlePath); | |
70 return result !is null ? new NSString(result) : null; | |
71 } | |
72 | |
73 public static NSBundle bundleWithIdentifier (NSString identifier) | |
74 { | |
75 objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleWithIdentifier_1, identifier !is null ? identifier.id : null); | |
76 return result !is null ? new NSBundle(result) : null; | |
77 } | |
78 | |
79 public static NSBundle bundleWithPath (NSString path) | |
80 { | |
81 objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_bundleWithPath_1, path !is null ? path.id : null); | |
82 return result !is null ? new NSBundle(result) : null; | |
83 } | |
84 | |
85 public objc.Class classNamed (NSString className) | |
86 { | |
87 return OS.objc_msgSend(this.id, OS.sel_classNamed_1, className !is null ? className.id : null); | |
88 } | |
89 | |
90 public NSString developmentLocalization () | |
91 { | |
92 objc.id result = OS.objc_msgSend(this.id, OS.sel_developmentLocalization); | |
93 return result !is null ? new NSString(result) : null; | |
94 } | |
95 | |
96 public NSArray executableArchitectures () | |
97 { | |
98 objc.id result = OS.objc_msgSend(this.id, OS.sel_executableArchitectures); | |
99 return result !is null ? new NSArray(result) : null; | |
100 } | |
101 | |
102 public NSString executablePath () | |
103 { | |
104 objc.id result = OS.objc_msgSend(this.id, OS.sel_executablePath); | |
105 return result !is null ? new NSString(result) : null; | |
106 } | |
107 | |
108 public NSDictionary infoDictionary () | |
109 { | |
110 objc.id result = OS.objc_msgSend(this.id, OS.sel_infoDictionary); | |
111 return result !is null ? new NSDictionary(result) : null; | |
112 } | |
113 | |
114 public NSBundle initWithPath (NSString path) | |
115 { | |
116 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithPath_1, path !is null ? path.id : null); | |
117 return result !is null ? this : null; | |
118 } | |
119 | |
120 public bool isLoaded () | |
121 { | |
122 return OS.objc_msgSend(this.id, OS.sel_isLoaded) !is null; | |
123 } | |
124 | |
125 //public bool load() { | |
126 // return OS.objc_msgSend(this.id, OS.sel_load) !is null; | |
127 //} | |
128 | |
129 public bool loadAndReturnError (objc.id** error) | |
130 { | |
131 return OS.objc_msgSend(this.id, OS.sel_loadAndReturnError_1, error) !is null; | |
132 } | |
133 | |
134 public NSArray localizations () | |
135 { | |
136 objc.id result = OS.objc_msgSend(this.id, OS.sel_localizations); | |
137 return result !is null ? new NSArray(result) : null; | |
138 } | |
139 | |
140 public NSDictionary localizedInfoDictionary () | |
141 { | |
142 objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedInfoDictionary); | |
143 return result !is null ? new NSDictionary(result) : null; | |
144 } | |
145 | |
146 public NSString localizedStringForKey (NSString key, NSString value, NSString tableName) | |
147 { | |
148 objc.id result = OS.objc_msgSend(this.id, OS.sel_localizedStringForKey_1value_1table_1, key !is null ? key.id : null, | |
149 value !is null ? value.id : null, tableName !is null ? tableName.id : null); | |
150 return result !is null ? new NSString(result) : null; | |
151 } | |
152 | |
153 public static NSBundle mainBundle () | |
154 { | |
155 objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_mainBundle); | |
156 return result !is null ? new NSBundle(result) : null; | |
157 } | |
158 | |
159 public id objectForInfoDictionaryKey (NSString key) | |
160 { | |
161 objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForInfoDictionaryKey_1, key !is null ? key.id : null); | |
162 return result !is null ? new id(result) : null; | |
163 } | |
164 | |
165 public NSString pathForAuxiliaryExecutable (NSString executableName) | |
166 { | |
167 objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForAuxiliaryExecutable_1, executableName !is null ? executableName.id : null); | |
168 return result !is null ? new NSString(result) : null; | |
169 } | |
170 | |
171 public NSString pathForResource_ofType_ (NSString name, NSString ext) | |
172 { | |
173 objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForResource_1ofType_1, name !is null ? name.id : null, ext !is null ? ext.id : null); | |
174 return result !is null ? new NSString(result) : null; | |
175 } | |
176 | |
177 public NSString pathForResource_ofType_inDirectory_ (NSString name, NSString ext, NSString subpath) | |
178 { | |
179 objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForResource_1ofType_1inDirectory_1, name !is null ? name.id : null, | |
180 ext !is null ? ext.id : null, subpath !is null ? subpath.id : null); | |
181 return result !is null ? new NSString(result) : null; | |
182 } | |
183 | |
184 public static NSString static_pathForResource_ofType_inDirectory_ (NSString name, NSString ext, NSString bundlePath) | |
185 { | |
186 objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_pathForResource_1ofType_1inDirectory_1, name !is null ? name.id : null, | |
187 ext !is null ? ext.id : null, bundlePath !is null ? bundlePath.id : null); | |
188 return result !is null ? new NSString(result) : null; | |
189 } | |
190 | |
191 public NSString pathForResource_ofType_inDirectory_forLocalization_ (NSString name, NSString ext, NSString subpath, NSString localizationName) | |
192 { | |
193 objc.id result = OS.objc_msgSend(this.id, OS.sel_pathForResource_1ofType_1inDirectory_1forLocalization_1, name !is null ? name.id : null, | |
194 ext !is null ? ext.id : null, subpath !is null ? subpath.id : null, localizationName !is null ? localizationName.id : null); | |
195 return result !is null ? new NSString(result) : null; | |
196 } | |
197 | |
198 public static NSArray static_pathsForResourcesOfType_inDirectory_ (NSString ext, NSString bundlePath) | |
199 { | |
200 objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_pathsForResourcesOfType_1inDirectory_1, ext !is null ? ext.id : null, | |
201 bundlePath !is null ? bundlePath.id : null); | |
202 return result !is null ? new NSArray(result) : null; | |
203 } | |
204 | |
205 public NSArray pathsForResourcesOfType_inDirectory_ (NSString ext, NSString subpath) | |
206 { | |
207 objc.id result = OS.objc_msgSend(this.id, OS.sel_pathsForResourcesOfType_1inDirectory_1, ext !is null ? ext.id : null, | |
208 subpath !is null ? subpath.id : null); | |
209 return result !is null ? new NSArray(result) : null; | |
210 } | |
211 | |
212 public NSArray pathsForResourcesOfType_inDirectory_forLocalization_ (NSString ext, NSString subpath, NSString localizationName) | |
213 { | |
214 objc.id result = OS.objc_msgSend(this.id, OS.sel_pathsForResourcesOfType_1inDirectory_1forLocalization_1, ext !is null ? ext.id : null, | |
215 subpath !is null ? subpath.id : null, localizationName !is null ? localizationName.id : null); | |
216 return result !is null ? new NSArray(result) : null; | |
217 } | |
218 | |
219 public NSArray preferredLocalizations () | |
220 { | |
221 objc.id result = OS.objc_msgSend(this.id, OS.sel_preferredLocalizations); | |
222 return result !is null ? new NSArray(result) : null; | |
223 } | |
224 | |
225 public static NSArray static_preferredLocalizationsFromArray_ (NSArray localizationsArray) | |
226 { | |
227 objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_preferredLocalizationsFromArray_1, | |
228 localizationsArray !is null ? localizationsArray.id : null); | |
229 return result !is null ? new NSArray(result) : null; | |
230 } | |
231 | |
232 public static NSArray static_preferredLocalizationsFromArray_forPreferences_ (NSArray localizationsArray, NSArray preferencesArray) | |
233 { | |
234 objc.id result = OS.objc_msgSend(OS.class_NSBundle, OS.sel_preferredLocalizationsFromArray_1forPreferences_1, | |
235 localizationsArray !is null ? localizationsArray.id : null, preferencesArray !is null ? preferencesArray.id : null); | |
236 return result !is null ? new NSArray(result) : null; | |
237 } | |
238 | |
239 public bool preflightAndReturnError (objc.id** error) | |
240 { | |
241 return OS.objc_msgSend(this.id, OS.sel_preflightAndReturnError_1, error) !is null; | |
242 } | |
243 | |
244 public objc.Class principalClass () | |
245 { | |
246 return OS.objc_msgSend(this.id, OS.sel_principalClass); | |
247 } | |
248 | |
249 public NSString privateFrameworksPath () | |
250 { | |
251 objc.id result = OS.objc_msgSend(this.id, OS.sel_privateFrameworksPath); | |
252 return result !is null ? new NSString(result) : null; | |
253 } | |
254 | |
255 public NSString resourcePath () | |
256 { | |
257 objc.id result = OS.objc_msgSend(this.id, OS.sel_resourcePath); | |
258 return result !is null ? new NSString(result) : null; | |
259 } | |
260 | |
261 public NSString sharedFrameworksPath () | |
262 { | |
263 objc.id result = OS.objc_msgSend(this.id, OS.sel_sharedFrameworksPath); | |
264 return result !is null ? new NSString(result) : null; | |
265 } | |
266 | |
267 public NSString sharedSupportPath () | |
268 { | |
269 objc.id result = OS.objc_msgSend(this.id, OS.sel_sharedSupportPath); | |
270 return result !is null ? new NSString(result) : null; | |
271 } | |
272 | |
273 public bool unload () | |
274 { | |
275 return OS.objc_msgSend(this.id, OS.sel_unload) !is null; | |
276 } | |
277 | |
278 public static bool loadNibFile (id fileName, id dict, id zone) | |
279 { | |
280 return OS.objc_msgSend(OS.class_NSBundle, OS.sel_loadNibFile_1externalNameTable_1withZone_1, fileName.id, dict.id, 0) !is null; | |
281 } | |
282 | |
283 } |