Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSDictionary.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children | 62202ce0039f |
comparison
equal
deleted
inserted
replaced
44:ca5e494f2bbf | 45:d8635bb48c7c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | 10 * |
11 * Port to the D programming language: | 11 * Port to the D programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 12 * Jacob Carlborg <doob@me.com> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module dwt.internal.cocoa.NSDictionary; | 14 module dwt.internal.cocoa.NSDictionary; |
15 | 15 |
16 | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.c.carboncore.MacTypes : OSType; | 17 import cocoa = dwt.internal.cocoa.id; |
18 import dwt.internal.cocoa.id; | |
19 import dwt.internal.cocoa.NSArray; | 18 import dwt.internal.cocoa.NSArray; |
20 import dwt.internal.cocoa.NSDate; | |
21 import dwt.internal.cocoa.NSEnumerator; | 19 import dwt.internal.cocoa.NSEnumerator; |
22 import dwt.internal.cocoa.NSInteger; | |
23 import dwt.internal.cocoa.NSNumber; | |
24 import dwt.internal.cocoa.NSObject; | 20 import dwt.internal.cocoa.NSObject; |
25 import dwt.internal.cocoa.NSString; | 21 import dwt.internal.cocoa.NSString; |
26 import dwt.internal.cocoa.NSURL; | |
27 import dwt.internal.cocoa.OS; | 22 import dwt.internal.cocoa.OS; |
23 import dwt.internal.objc.cocoa.Cocoa; | |
28 import objc = dwt.internal.objc.runtime; | 24 import objc = dwt.internal.objc.runtime; |
29 | 25 |
26 public class NSDictionary : NSObject { | |
30 | 27 |
31 public class NSDictionary : NSObject | 28 public this() { |
32 { | 29 super(); |
30 } | |
33 | 31 |
34 public this () | 32 public this(objc.id id) { |
35 { | 33 super(id); |
36 super(); | 34 } |
37 } | |
38 | 35 |
39 public this (objc.id id) | 36 public this(cocoa.id id) { |
40 { | 37 super(id); |
41 super(id); | 38 } |
42 } | |
43 | 39 |
44 public NSArray allKeys () | 40 public NSArray allKeys() { |
45 { | 41 objc.id result = OS.objc_msgSend(this.id, OS.sel_allKeys); |
46 objc.id result = OS.objc_msgSend(this.id_, OS.sel_allKeys); | 42 return result !is null ? new NSArray(result) : null; |
47 return result !is null ? new NSArray(result) : null; | 43 } |
48 } | |
49 | 44 |
50 public NSArray allKeysForObject (id anObject) | 45 public NSUInteger count() { |
51 { | 46 return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_count); |
52 objc.id result = OS.objc_msgSend(this.id_, OS.sel_allKeysForObject_1, anObject !is null ? anObject.id_ : null); | 47 } |
53 return result !is null ? new NSArray(result) : null; | |
54 } | |
55 | 48 |
56 public NSArray allValues () | 49 public static NSDictionary dictionaryWithObject(cocoa.id object, cocoa.id key) { |
57 { | 50 objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObject_forKey_, object !is null ? object.id : null, key !is null ? key.id : null); |
58 objc.id result = OS.objc_msgSend(this.id_, OS.sel_allValues); | 51 return result !is null ? new NSDictionary(result) : null; |
59 return result !is null ? new NSArray(result) : null; | 52 } |
60 } | |
61 | 53 |
62 public NSUInteger count () | 54 public NSEnumerator objectEnumerator() { |
63 { | 55 objc.id result = OS.objc_msgSend(this.id, OS.sel_objectEnumerator); |
64 return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_count); | 56 return result !is null ? new NSEnumerator(result) : null; |
65 } | 57 } |
66 | 58 |
67 public NSString description () | 59 public cocoa.id objectForKey(cocoa.id aKey) { |
68 { | 60 objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForKey_, aKey !is null ? aKey.id : null); |
69 objc.id result = OS.objc_msgSend(this.id_, OS.sel_description); | 61 return result !is null ? new cocoa.id(result) : null; |
70 return result !is null ? new NSString(result) : null; | 62 } |
71 } | |
72 | 63 |
73 public NSString descriptionInStringsFileFormat () | 64 public cocoa.id valueForKey(NSString key) { |
74 { | 65 objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForKey_, key !is null ? key.id : null); |
75 objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionInStringsFileFormat); | 66 return result !is null ? new id(result) : null; |
76 return result !is null ? new NSString(result) : null; | 67 } |
77 } | |
78 | |
79 public NSString descriptionWithLocale_ (id locale) | |
80 { | |
81 objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id_ : null); | |
82 return result !is null ? new NSString(result) : null; | |
83 } | |
84 | |
85 public NSString descriptionWithLocale_indent_ (id locale, NSUInteger level) | |
86 { | |
87 objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1indent_1, locale !is null ? locale.id_ : null, level); | |
88 return result !is null ? new NSString(result) : null; | |
89 } | |
90 | |
91 public static id dictionary () | |
92 { | |
93 objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionary); | |
94 return result !is null ? new id(result) : null; | |
95 } | |
96 | |
97 public static id dictionaryWithContentsOfFile (NSString path) | |
98 { | |
99 objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithContentsOfFile_1, path !is null ? path.id_ : null); | |
100 return result !is null ? new id(result) : null; | |
101 } | |
102 | |
103 public static id dictionaryWithContentsOfURL (NSURL url) | |
104 { | |
105 objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithContentsOfURL_1, url !is null ? url.id_ : null); | |
106 return result !is null ? new id(result) : null; | |
107 } | |
108 | |
109 public static id dictionaryWithDictionary (NSDictionary dict) | |
110 { | |
111 objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithDictionary_1, dict !is null ? dict.id_ : null); | |
112 return result !is null ? new id(result) : null; | |
113 } | |
114 | |
115 public static id dictionaryWithObject (id object, id key) | |
116 { | |
117 objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObject_1forKey_1, object !is null ? object.id_ : null, | |
118 key !is null ? key.id_ : null); | |
119 return result !is null ? new id(result) : null; | |
120 } | |
121 | |
122 public static id static_dictionaryWithObjects_forKeys_ (NSArray objects, NSArray keys) | |
123 { | |
124 objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObjects_1forKeys_1, objects !is null ? objects.id_ : null, | |
125 keys !is null ? keys.id_ : null); | |
126 return result !is null ? new id(result) : null; | |
127 } | |
128 | |
129 public static id static_dictionaryWithObjects_forKeys_count_ (objc.id* objects, objc.id* keys, NSUInteger cnt) | |
130 { | |
131 objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObjects_1forKeys_1count_1, objects, keys, cnt); | |
132 return result !is null ? new id(result) : null; | |
133 } | |
134 | |
135 public static id dictionaryWithObjectsAndKeys (id dictionaryWithObjectsAndKeys) | |
136 { | |
137 objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObjectsAndKeys_1, | |
138 dictionaryWithObjectsAndKeys !is null ? dictionaryWithObjectsAndKeys.id_ : null); | |
139 return result !is null ? new id(result) : null; | |
140 } | |
141 | |
142 public NSDate fileCreationDate () | |
143 { | |
144 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileCreationDate); | |
145 return result !is null ? new NSDate(result) : null; | |
146 } | |
147 | |
148 public bool fileExtensionHidden () | |
149 { | |
150 return OS.objc_msgSend(this.id_, OS.sel_fileExtensionHidden) !is null; | |
151 } | |
152 | |
153 public NSNumber fileGroupOwnerAccountID () | |
154 { | |
155 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileGroupOwnerAccountID); | |
156 return result !is null ? new NSNumber(result) : null; | |
157 } | |
158 | |
159 public NSString fileGroupOwnerAccountName () | |
160 { | |
161 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileGroupOwnerAccountName); | |
162 return result !is null ? new NSString(result) : null; | |
163 } | |
164 | |
165 public OSType fileHFSCreatorCode () | |
166 { | |
167 return cast(OSType) OS.objc_msgSend(this.id_, OS.sel_fileHFSCreatorCode); | |
168 } | |
169 | |
170 public OSType fileHFSTypeCode () | |
171 { | |
172 return cast(OSType) OS.objc_msgSend(this.id_, OS.sel_fileHFSTypeCode); | |
173 } | |
174 | |
175 public bool fileIsAppendOnly () | |
176 { | |
177 return OS.objc_msgSend(this.id_, OS.sel_fileIsAppendOnly) !is null; | |
178 } | |
179 | |
180 public bool fileIsImmutable () | |
181 { | |
182 return OS.objc_msgSend(this.id_, OS.sel_fileIsImmutable) !is null; | |
183 } | |
184 | |
185 public NSDate fileModificationDate () | |
186 { | |
187 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileModificationDate); | |
188 return result !is null ? new NSDate(result) : null; | |
189 } | |
190 | |
191 public NSNumber fileOwnerAccountID () | |
192 { | |
193 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileOwnerAccountID); | |
194 return result !is null ? new NSNumber(result) : null; | |
195 } | |
196 | |
197 public NSString fileOwnerAccountName () | |
198 { | |
199 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileOwnerAccountName); | |
200 return result !is null ? new NSString(result) : null; | |
201 } | |
202 | |
203 public NSUInteger filePosixPermissions () | |
204 { | |
205 return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_filePosixPermissions); | |
206 } | |
207 | |
208 public ulong fileSize () | |
209 { | |
210 return cast(ulong) OS.objc_msgSend(this.id_, OS.sel_fileSize); | |
211 } | |
212 | |
213 public NSUInteger fileSystemFileNumber () | |
214 { | |
215 return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_fileSystemFileNumber); | |
216 } | |
217 | |
218 public NSInteger fileSystemNumber () | |
219 { | |
220 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_fileSystemNumber); | |
221 } | |
222 | |
223 public NSString fileType () | |
224 { | |
225 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileType); | |
226 return result !is null ? new NSString(result) : null; | |
227 } | |
228 | |
229 public void getObjects (objc.id* objects, objc.id* keys) | |
230 { | |
231 OS.objc_msgSend(this.id_, OS.sel_getObjects_1andKeys_1, objects, keys); | |
232 } | |
233 | |
234 public id initWithContentsOfFile (NSString path) | |
235 { | |
236 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfFile_1, path !is null ? path.id_ : null); | |
237 return result !is null ? new id(result) : null; | |
238 } | |
239 | |
240 public id initWithContentsOfURL (NSURL url) | |
241 { | |
242 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfURL_1, url !is null ? url.id_ : null); | |
243 return result !is null ? new id(result) : null; | |
244 } | |
245 | |
246 public id initWithDictionary_ (NSDictionary otherDictionary) | |
247 { | |
248 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithDictionary_1, otherDictionary !is null ? otherDictionary.id_ : null); | |
249 return result !is null ? new id(result) : null; | |
250 } | |
251 | |
252 public id initWithDictionary_copyItems_ (NSDictionary otherDictionary, bool flag) | |
253 { | |
254 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithDictionary_1copyItems_1, otherDictionary !is null ? otherDictionary.id_ : null, flag); | |
255 return result !is null ? new id(result) : null; | |
256 } | |
257 | |
258 public id initWithObjects_forKeys_ (NSArray objects, NSArray keys) | |
259 { | |
260 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithObjects_1forKeys_1, objects !is null ? objects.id_ : null, | |
261 keys !is null ? keys.id_ : null); | |
262 return result !is null ? new id(result) : null; | |
263 } | |
264 | |
265 public id initWithObjects_forKeys_count_ (objc.id* objects, objc.id* keys, NSUInteger cnt) | |
266 { | |
267 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithObjects_1forKeys_1count_1, objects, keys, cnt); | |
268 return result !is null ? new id(result) : null; | |
269 } | |
270 | |
271 public id initWithObjectsAndKeys (id initWithObjectsAndKeys) | |
272 { | |
273 objc.id | |
274 result = OS.objc_msgSend(this.id_, OS.sel_initWithObjectsAndKeys_1, initWithObjectsAndKeys !is null ? initWithObjectsAndKeys.id_ : null); | |
275 return result !is null ? new id(result) : null; | |
276 } | |
277 | |
278 public bool isEqualToDictionary (NSDictionary otherDictionary) | |
279 { | |
280 return OS.objc_msgSend(this.id_, OS.sel_isEqualToDictionary_1, otherDictionary !is null ? otherDictionary.id_ : null) !is null; | |
281 } | |
282 | |
283 public NSEnumerator keyEnumerator () | |
284 { | |
285 objc.id result = OS.objc_msgSend(this.id_, OS.sel_keyEnumerator); | |
286 return result !is null ? new NSEnumerator(result) : null; | |
287 } | |
288 | |
289 public NSArray keysSortedByValueUsingSelector (objc.SEL comparator) | |
290 { | |
291 objc.id result = OS.objc_msgSend(this.id_, OS.sel_keysSortedByValueUsingSelector_1, comparator); | |
292 return result !is null ? new NSArray(result) : null; | |
293 } | |
294 | |
295 public NSEnumerator objectEnumerator () | |
296 { | |
297 objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectEnumerator); | |
298 return result !is null ? new NSEnumerator(result) : null; | |
299 } | |
300 | |
301 public id objectForKey (id aKey) | |
302 { | |
303 objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectForKey_1, aKey !is null ? aKey.id_ : null); | |
304 return result !is null ? new id(result) : null; | |
305 } | |
306 | |
307 public NSArray objectsForKeys (NSArray keys, id marker) | |
308 { | |
309 objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectsForKeys_1notFoundMarker_1, keys !is null ? keys.id_ : null, | |
310 marker !is null ? marker.id_ : null); | |
311 return result !is null ? new NSArray(result) : null; | |
312 } | |
313 | |
314 public id valueForKey (NSString key) | |
315 { | |
316 objc.id result = OS.objc_msgSend(this.id_, OS.sel_valueForKey_1, key !is null ? key.id_ : null); | |
317 return result !is null ? new id(result) : null; | |
318 } | |
319 | |
320 public bool writeToFile (NSString path, bool useAuxiliaryFile) | |
321 { | |
322 return OS.objc_msgSend(this.id_, OS.sel_writeToFile_1atomically_1, path !is null ? path.id_ : null, useAuxiliaryFile) !is null; | |
323 } | |
324 | |
325 public bool writeToURL (NSURL url, bool atomically) | |
326 { | |
327 return OS.objc_msgSend(this.id_, OS.sel_writeToURL_1atomically_1, url !is null ? url.id_ : null, atomically) !is null; | |
328 } | |
329 | 68 |
330 } | 69 } |