comparison dwt/internal/cocoa/NSArray.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.NSArray;
15
16 import dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSData;
18 import dwt.internal.cocoa.NSEnumerator;
19 import dwt.internal.cocoa.NSIndexSet;
20 import dwt.internal.cocoa.NSInteger;
21 import dwt.internal.cocoa.NSObject;
22 import dwt.internal.cocoa.NSPredicate;
23 import dwt.internal.cocoa.NSRange;
24 import dwt.internal.cocoa.NSString;
25 import dwt.internal.cocoa.NSURL;
26 import dwt.internal.cocoa.OS;
27 import objc = dwt.internal.objc.runtime;
28
29 public class NSArray : NSObject
30 {
31
32 public this ()
33 {
34 super();
35 }
36
37 public this (objc.id id)
38 {
39 super(id);
40 }
41
42 public void addObserver_forKeyPath_options_context_ (NSObject observer, NSString keyPath, objc.id options, objc.id context)
43 {
44 OS.objc_msgSend(this.id, OS.sel_addObserver_1forKeyPath_1options_1context_1, observer !is null ? observer.id : null,
45 keyPath !is null ? keyPath.id : null, options, context);
46 }
47
48 public void addObserver_toObjectsAtIndexes_forKeyPath_options_context_ (NSObject observer, NSIndexSet indexes, NSString keyPath, objc.id options,
49 objc.id context)
50 {
51 OS.objc_msgSend(this.id, OS.sel_addObserver_1toObjectsAtIndexes_1forKeyPath_1options_1context_1, observer !is null ? observer.id : null,
52 indexes !is null ? indexes.id : null, keyPath !is null ? keyPath.id : null, options, context);
53 }
54
55 public static id array ()
56 {
57 objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_array);
58 return result !is null ? new id(result) : null;
59 }
60
61 public NSArray arrayByAddingObject (id anObject)
62 {
63 objc.id result = OS.objc_msgSend(this.id, OS.sel_arrayByAddingObject_1, anObject !is null ? anObject.id : null);
64 return result is this.id ? this : (result !is null ? new NSArray(result) : null);
65 }
66
67 public NSArray arrayByAddingObjectsFromArray (NSArray otherArray)
68 {
69 objc.id result = OS.objc_msgSend(this.id, OS.sel_arrayByAddingObjectsFromArray_1, otherArray !is null ? otherArray.id : null);
70 return result is this.id ? this : (result !is null ? new NSArray(result) : null);
71 }
72
73 public static id arrayWithArray (NSArray array)
74 {
75 objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithArray_1, array !is null ? array.id : null);
76 return result !is null ? new id(result) : null;
77 }
78
79 public static id arrayWithContentsOfFile (NSString path)
80 {
81 objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithContentsOfFile_1, path !is null ? path.id : null);
82 return result !is null ? new id(result) : null;
83 }
84
85 public static id arrayWithContentsOfURL (NSURL url)
86 {
87 objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithContentsOfURL_1, url !is null ? url.id : null);
88 return result !is null ? new id(result) : null;
89 }
90
91 public static id arrayWithObject (id anObject)
92 {
93 objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObject_1, anObject !is null ? anObject.id : null);
94 return result !is null ? new id(result) : null;
95 }
96
97 public static id static_arrayWithObjects_ (id arrayWithObjects)
98 {
99 objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObjects_1, arrayWithObjects !is null ? arrayWithObjects.id : null);
100 return result !is null ? new id(result) : null;
101 }
102
103 public static id static_arrayWithObjects_count_ (/*const*/objc.id* objects, NSUInteger cnt)
104 {
105 objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObjects_1count_1, objects, cnt);
106 return result !is null ? new id(result) : null;
107 }
108
109 public NSString componentsJoinedByString (NSString separator)
110 {
111 objc.id result = OS.objc_msgSend(this.id, OS.sel_componentsJoinedByString_1, separator !is null ? separator.id : null);
112 return result !is null ? new NSString(result) : null;
113 }
114
115 public bool containsObject (id anObject)
116 {
117 return OS.objc_msgSend(this.id, OS.sel_containsObject_1, anObject !is null ? anObject.id : null) !is null;
118 }
119
120 public NSUInteger count ()
121 {
122 return OS.objc_msgSend(this.id, OS.sel_count);
123 }
124
125 public NSString description ()
126 {
127 objc.id result = OS.objc_msgSend(this.id, OS.sel_description);
128 return result !is null ? new NSString(result) : null;
129 }
130
131 public NSString descriptionWithLocale_ (id locale)
132 {
133 objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null);
134 return result !is null ? new NSString(result) : null;
135 }
136
137 public NSString descriptionWithLocale_indent_ (id locale, objc.id level)
138 {
139 objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1indent_1, locale !is null ? locale.id : null, level);
140 return result !is null ? new NSString(result) : null;
141 }
142
143 public NSArray filteredArrayUsingPredicate (NSPredicate predicate)
144 {
145 objc.id result = OS.objc_msgSend(this.id, OS.sel_filteredArrayUsingPredicate_1, predicate !is null ? predicate.id : null);
146 return result is this.id ? this : (result !is null ? new NSArray(result) : null);
147 }
148
149 public id firstObjectCommonWithArray (NSArray otherArray)
150 {
151 objc.id result = OS.objc_msgSend(this.id, OS.sel_firstObjectCommonWithArray_1, otherArray !is null ? otherArray.id : null);
152 return result !is null ? new id(result) : null;
153 }
154
155 public void getObjects_ (objc.id objects)
156 {
157 OS.objc_msgSend(this.id, OS.sel_getObjects_1, objects);
158 }
159
160 public void getObjects_range_ (objc.id objects, NSRange range)
161 {
162 OS.objc_msgSend(this.id, OS.sel_getObjects_1range_1, objects, range);
163 }
164
165 public NSUInteger indexOfObject_ (id anObject)
166 {
167 return OS.objc_msgSend(this.id, OS.sel_indexOfObject_1, anObject !is null ? anObject.id : null);
168 }
169
170 public NSUInteger indexOfObject_inRange_ (id anObject, NSRange range)
171 {
172 return OS.objc_msgSend(this.id, OS.sel_indexOfObject_1inRange_1, anObject !is null ? anObject.id : null, range);
173 }
174
175 public NSUInteger indexOfObjectIdenticalTo_ (id anObject)
176 {
177 return OS.objc_msgSend(this.id, OS.sel_indexOfObjectIdenticalTo_1, anObject !is null ? anObject.id : null);
178 }
179
180 public NSUInteger indexOfObjectIdenticalTo_inRange_ (id anObject, NSRange range)
181 {
182 return OS.objc_msgSend(this.id, OS.sel_indexOfObjectIdenticalTo_1inRange_1, anObject !is null ? anObject.id : null, range);
183 }
184
185 public NSArray initWithArray_ (NSArray array)
186 {
187 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithArray_1, array !is null ? array.id : null);
188 return result !is null ? this : null;
189 }
190
191 public NSArray initWithArray_copyItems_ (NSArray array, bool flag)
192 {
193 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithArray_1copyItems_1, array !is null ? array.id : null, flag);
194 return result !is null ? this : null;
195 }
196
197 public NSArray initWithContentsOfFile (NSString path)
198 {
199 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_1, path !is null ? path.id : null);
200 return result !is null ? this : null;
201 }
202
203 public NSArray initWithContentsOfURL (NSURL url)
204 {
205 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfURL_1, url !is null ? url.id : null);
206 return result !is null ? this : null;
207 }
208
209 public NSArray initWithObjects_ (id initWithObjects)
210 {
211 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjects_1, initWithObjects !is null ? initWithObjects.id : null);
212 return result !is null ? this : null;
213 }
214
215 public NSArray initWithObjects_count_ (/*const*/objc.id* objects, NSUInteger cnt)
216 {
217 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjects_1count_1, objects, cnt);
218 return result !is null ? this : null;
219 }
220
221 public bool isEqualToArray (NSArray otherArray)
222 {
223 return OS.objc_msgSend(this.id, OS.sel_isEqualToArray_1, otherArray !is null ? otherArray.id : null) !is null;
224 }
225
226 public id lastObject ()
227 {
228 objc.id result = OS.objc_msgSend(this.id, OS.sel_lastObject);
229 return result !is null ? new id(result) : null;
230 }
231
232 public void makeObjectsPerformSelector_ (objc.SEL aSelector)
233 {
234 OS.objc_msgSend(this.id, OS.sel_makeObjectsPerformSelector_1, aSelector);
235 }
236
237 public void makeObjectsPerformSelector_withObject_ (objc.SEL aSelector, id argument)
238 {
239 OS.objc_msgSend(this.id, OS.sel_makeObjectsPerformSelector_1withObject_1, aSelector, argument !is null ? argument.id : null);
240 }
241
242 public objc.id objectAtIndex (NSUInteger index)
243 {
244 objc.id result = OS.objc_msgSend(this.id, OS.sel_objectAtIndex_1, index);
245 return result;
246 // return result !is null ? new id(result) : null;
247 }
248
249 public NSEnumerator objectEnumerator ()
250 {
251 objc.id result = OS.objc_msgSend(this.id, OS.sel_objectEnumerator);
252 return result !is null ? new NSEnumerator(result) : null;
253 }
254
255 public NSArray objectsAtIndexes (NSIndexSet indexes)
256 {
257 objc.id result = OS.objc_msgSend(this.id, OS.sel_objectsAtIndexes_1, indexes !is null ? indexes.id : null);
258 return result is this.id ? this : (result !is null ? new NSArray(result) : null);
259 }
260
261 public NSArray pathsMatchingExtensions (NSArray filterTypes)
262 {
263 objc.id result = OS.objc_msgSend(this.id, OS.sel_pathsMatchingExtensions_1, filterTypes !is null ? filterTypes.id : null);
264 return result is this.id ? this : (result !is null ? new NSArray(result) : null);
265 }
266
267 public void removeObserver_forKeyPath_ (NSObject observer, NSString keyPath)
268 {
269 OS.objc_msgSend(this.id, OS.sel_removeObserver_1forKeyPath_1, observer !is null ? observer.id : null, keyPath !is null ? keyPath.id : null);
270 }
271
272 public void removeObserver_fromObjectsAtIndexes_forKeyPath_ (NSObject observer, NSIndexSet indexes, NSString keyPath)
273 {
274 OS.objc_msgSend(this.id, OS.sel_removeObserver_1fromObjectsAtIndexes_1forKeyPath_1, observer !is null ? observer.id : null,
275 indexes !is null ? indexes.id : null, keyPath !is null ? keyPath.id : null);
276 }
277
278 public NSEnumerator reverseObjectEnumerator ()
279 {
280 objc.id result = OS.objc_msgSend(this.id, OS.sel_reverseObjectEnumerator);
281 return result !is null ? new NSEnumerator(result) : null;
282 }
283
284 public void setValue (id value, NSString key)
285 {
286 OS.objc_msgSend(this.id, OS.sel_setValue_1forKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
287 }
288
289 public NSData sortedArrayHint ()
290 {
291 objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayHint);
292 return result !is null ? new NSData(result) : null;
293 }
294
295 public NSArray sortedArrayUsingDescriptors (NSArray sortDescriptors)
296 {
297 objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingDescriptors_1, sortDescriptors !is null ? sortDescriptors.id : null);
298 return result is this.id ? this : (result !is null ? new NSArray(result) : null);
299 }
300
301 public NSArray sortedArrayUsingFunction_context_ (objc.id comparator, objc.id context)
302 {
303 objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingFunction_1context_1, comparator, context);
304 return result is this.id ? this : (result !is null ? new NSArray(result) : null);
305 }
306
307 public NSArray sortedArrayUsingFunction_context_hint_ (objc.id comparator, objc.id context, NSData hint)
308 {
309 objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingFunction_1context_1hint_1, comparator, context,
310 hint !is null ? hint.id : null);
311 return result is this.id ? this : (result !is null ? new NSArray(result) : null);
312 }
313
314 public NSArray sortedArrayUsingSelector (objc.id comparator)
315 {
316 objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingSelector_1, comparator);
317 return result is this.id ? this : (result !is null ? new NSArray(result) : null);
318 }
319
320 public NSArray subarrayWithRange (NSRange range)
321 {
322 objc.id result = OS.objc_msgSend(this.id, OS.sel_subarrayWithRange_1, range);
323 return result is this.id ? this : (result !is null ? new NSArray(result) : null);
324 }
325
326 public id valueForKey (NSString key)
327 {
328 objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForKey_1, key !is null ? key.id : null);
329 return result !is null ? new id(result) : null;
330 }
331
332 public bool writeToFile (NSString path, bool useAuxiliaryFile)
333 {
334 return OS.objc_msgSend(this.id, OS.sel_writeToFile_1atomically_1, path !is null ? path.id : null, useAuxiliaryFile) !is null;
335 }
336
337 public bool writeToURL (NSURL url, bool atomically)
338 {
339 return OS.objc_msgSend(this.id, OS.sel_writeToURL_1atomically_1, url !is null ? url.id : null, atomically) !is null;
340 }
341
342 }