Mercurial > projects > dstep
comparison dstep/foundation/NSSet.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 89f3c3ef1fd2 |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) |
6 */ | 6 */ |
7 module dstep.foundation.NSSet; | 7 module dstep.foundation.NSSet; |
8 | 8 |
9 import dstep.foundation.NSArray; | 9 import dstep.foundation.NSArray; |
10 import dstep.foundation.NSCoder; | |
10 import dstep.foundation.NSDictionary; | 11 import dstep.foundation.NSDictionary; |
11 import dstep.foundation.NSEnumerator; | 12 import dstep.foundation.NSEnumerator; |
13 import dstep.foundation.NSKeyValueObserving; | |
12 import dstep.foundation.NSObject; | 14 import dstep.foundation.NSObject; |
15 import dstep.foundation.NSObjCRuntime; | |
16 import dstep.foundation.NSPredicate; | |
13 import dstep.foundation.NSString; | 17 import dstep.foundation.NSString; |
18 import dstep.foundation.NSZone; | |
14 import dstep.objc.bridge.Bridge; | 19 import dstep.objc.bridge.Bridge; |
15 import dstep.objc.objc : id; | 20 import dstep.objc.objc; |
21 | |
22 const TNSSetCreation = ` | |
23 | |
24 static Object set () | |
25 { | |
26 return invokeObjcSuperClass!(Object, "set"); | |
27 } | |
28 | |
29 static Object setWithObject (Object object) | |
30 { | |
31 return invokeObjcSuperClass!(Object, "setWithObject:", Object)(object); | |
32 } | |
33 | |
34 static Object setWithObjects (id* objects, NSUInteger cnt) | |
35 { | |
36 return invokeObjcSuperClass!(Object, "setWithObjects:count:", id*, NSUInteger)(objects, cnt); | |
37 } | |
38 | |
39 static Object setWithObjects (Object setWithObjects, ...) | |
40 { | |
41 return invokeObjcSuperClass!(Object, "setWithObjects:", Object)(setWithObjects); | |
42 } | |
43 | |
44 static Object setWithSet (NSSet set) | |
45 { | |
46 return invokeObjcSuperClass!(Object, "setWithSet:", NSSet)(set); | |
47 } | |
48 | |
49 static Object setWithArray (NSArray array) | |
50 { | |
51 return invokeObjcSuperClass!(Object, "setWithArray:", NSArray)(array); | |
52 } | |
53 | |
54 Object initWithObjects (id* objects, NSUInteger cnt) | |
55 { | |
56 return invokeObjcSelf!(Object, "initWithObjects:count:", id*, NSUInteger)(objects, cnt); | |
57 } | |
58 | |
59 this (id* objects, NSUInteger cnt) | |
60 { | |
61 typeof(this).alloc.initWithObjects(objects, cnt); | |
62 } | |
63 | |
64 Object initWithObjects (Object initWithObjects, ...) | |
65 { | |
66 return invokeObjcSelf!(Object, "initWithObjects:", Object)(initWithObjects); | |
67 } | |
68 | |
69 this (Object initWithObjects, ...) | |
70 { | |
71 typeof(this).alloc.initWithObjects(initWithObjects); | |
72 } | |
73 | |
74 Object initWithSet (NSSet set) | |
75 { | |
76 return invokeObjcSelf!(Object, "initWithSet:", NSSet)(set); | |
77 } | |
78 | |
79 this (NSSet set) | |
80 { | |
81 typeof(this).alloc.initWithSet(set); | |
82 } | |
83 | |
84 Object initWithSet (NSSet set, bool flag) | |
85 { | |
86 return invokeObjcSelf!(Object, "initWithSet:copyItems:", NSSet, bool)(set, flag); | |
87 } | |
88 | |
89 this (NSSet set, bool flag) | |
90 { | |
91 typeof(this).alloc.initWithSet(set, flag); | |
92 } | |
93 | |
94 Object initWithArray (NSArray array) | |
95 { | |
96 return invokeObjcSelf!(Object, "initWithArray:", NSArray)(array); | |
97 } | |
98 | |
99 this (NSArray array) | |
100 { | |
101 typeof(this).alloc.initWithArray(array); | |
102 } | |
103 `; | |
104 | |
105 const TNSExtendedSet = ` | |
106 | |
107 NSArray allObjects () | |
108 { | |
109 return invokeObjcSelf!(NSArray, "allObjects"); | |
110 } | |
111 | |
112 Object anyObject () | |
113 { | |
114 return invokeObjcSelf!(Object, "anyObject"); | |
115 } | |
116 | |
117 bool containsObject (Object anObject) | |
118 { | |
119 return invokeObjcSelf!(bool, "containsObject:", Object)(anObject); | |
120 } | |
121 | |
122 NSString description () | |
123 { | |
124 return invokeObjcSelf!(NSString, "description"); | |
125 } | |
126 | |
127 NSString descriptionWithLocale (Object locale) | |
128 { | |
129 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); | |
130 } | |
131 | |
132 bool intersectsSet (NSSet otherSet) | |
133 { | |
134 return invokeObjcSelf!(bool, "intersectsSet:", NSSet)(otherSet); | |
135 } | |
136 | |
137 bool isEqualToSet (NSSet otherSet) | |
138 { | |
139 return invokeObjcSelf!(bool, "isEqualToSet:", NSSet)(otherSet); | |
140 } | |
141 | |
142 bool isSubsetOfSet (NSSet otherSet) | |
143 { | |
144 return invokeObjcSelf!(bool, "isSubsetOfSet:", NSSet)(otherSet); | |
145 } | |
146 | |
147 void makeObjectsPerformSelector (SEL aSelector) | |
148 { | |
149 return invokeObjcSelf!(void, "makeObjectsPerformSelector:", SEL)(aSelector); | |
150 } | |
151 | |
152 void makeObjectsPerformSelector (SEL aSelector, Object argument) | |
153 { | |
154 return invokeObjcSelf!(void, "makeObjectsPerformSelector:withObject:", SEL, Object)(aSelector, argument); | |
155 } | |
156 | |
157 NSSet setByAddingObject (Object anObject) | |
158 { | |
159 return invokeObjcSelf!(NSSet, "setByAddingObject:", Object)(anObject); | |
160 } | |
161 | |
162 NSSet setByAddingObjectsFromSet (NSSet other) | |
163 { | |
164 return invokeObjcSelf!(NSSet, "setByAddingObjectsFromSet:", NSSet)(other); | |
165 } | |
166 | |
167 NSSet setByAddingObjectsFromArray (NSArray other) | |
168 { | |
169 return invokeObjcSelf!(NSSet, "setByAddingObjectsFromArray:", NSArray)(other); | |
170 } | |
171 `; | |
172 | |
173 const TNSMutableSetCreation = ` | |
174 | |
175 static Object setWithCapacity (NSUInteger numItems) | |
176 { | |
177 return invokeObjcSuperClass!(Object, "setWithCapacity:", NSUInteger)(numItems); | |
178 } | |
179 | |
180 Object initWithCapacity (NSUInteger numItems) | |
181 { | |
182 return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(numItems); | |
183 } | |
184 | |
185 this (NSUInteger numItems) | |
186 { | |
187 typeof(this).alloc.initWithCapacity(numItems); | |
188 } | |
189 `; | |
190 | |
191 const TNSExtendedMutableSet = ` | |
192 | |
193 void addObjectsFromArray (NSArray array) | |
194 { | |
195 return invokeObjcSelf!(void, "addObjectsFromArray:", NSArray)(array); | |
196 } | |
197 | |
198 void intersectSet (NSSet otherSet) | |
199 { | |
200 return invokeObjcSelf!(void, "intersectSet:", NSSet)(otherSet); | |
201 } | |
202 | |
203 void minusSet (NSSet otherSet) | |
204 { | |
205 return invokeObjcSelf!(void, "minusSet:", NSSet)(otherSet); | |
206 } | |
207 | |
208 void removeAllObjects () | |
209 { | |
210 return invokeObjcSelf!(void, "removeAllObjects"); | |
211 } | |
212 | |
213 void unionSet (NSSet otherSet) | |
214 { | |
215 return invokeObjcSelf!(void, "unionSet:", NSSet)(otherSet); | |
216 } | |
217 | |
218 void setSet (NSSet otherSet) | |
219 { | |
220 return invokeObjcSelf!(void, "setSet:", NSSet)(otherSet); | |
221 } | |
222 `; | |
16 | 223 |
17 class NSSet : NSObject, INSCopying, INSMutableCopying, INSCoding, INSFastEnumeration | 224 class NSSet : NSObject, INSCopying, INSMutableCopying, INSCoding, INSFastEnumeration |
18 { | 225 { |
19 mixin ObjcWrap; | 226 mixin (ObjcWrap); |
20 mixin TNSSetCreation; | 227 |
21 mixin TNSExtendedSet; | 228 this () |
22 mixin TNSKeyValueObserverRegistration; | 229 { |
230 super(typeof(this).alloc.init.objcObject); | |
231 } | |
232 | |
233 typeof(this) init () | |
234 { | |
235 return invokeObjcSelf!(typeof(this), "init"); | |
236 } | |
23 | 237 |
24 NSUInteger count () | 238 NSUInteger count () |
25 { | 239 { |
26 return invokeObjcSelf!(NSUInteger, "count"); | 240 return invokeObjcSelf!(NSUInteger, "count"); |
27 } | 241 } |
56 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | 270 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); |
57 } | 271 } |
58 | 272 |
59 this (NSCoder aDecoder) | 273 this (NSCoder aDecoder) |
60 { | 274 { |
61 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 275 typeof(this).alloc.initWithCoder(aDecoder); |
62 id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); | |
63 | |
64 if (result) | |
65 objcObject = ret; | |
66 | |
67 dObject = this; | |
68 } | 276 } |
69 | 277 |
70 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) | 278 NSUInteger countByEnumeratingWithState (NSFastEnumerationState* state, id* stackbuf, NSUInteger len) |
71 { | 279 { |
72 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); | 280 return invokeObjcSelf!(NSUInteger, "countByEnumeratingWithState:objects:count:", NSFastEnumerationState*, id*, NSUInteger)(state, stackbuf, len); |
281 } | |
282 | |
283 // TNSSetCreation | |
284 static Object set () | |
285 { | |
286 return invokeObjcSuperClass!(Object, "set"); | |
287 } | |
288 | |
289 static Object setWithObject (Object object) | |
290 { | |
291 return invokeObjcSuperClass!(Object, "setWithObject:", Object)(object); | |
292 } | |
293 | |
294 static Object setWithObjects (id* objects, NSUInteger cnt) | |
295 { | |
296 return invokeObjcSuperClass!(Object, "setWithObjects:count:", id*, NSUInteger)(objects, cnt); | |
297 } | |
298 | |
299 static Object setWithObjects (Object setWithObjects, ...) | |
300 { | |
301 return invokeObjcSuperClass!(Object, "setWithObjects:", Object)(setWithObjects); | |
302 } | |
303 | |
304 static Object setWithSet (NSSet set) | |
305 { | |
306 return invokeObjcSuperClass!(Object, "setWithSet:", NSSet)(set); | |
307 } | |
308 | |
309 static Object setWithArray (NSArray array) | |
310 { | |
311 return invokeObjcSuperClass!(Object, "setWithArray:", NSArray)(array); | |
312 } | |
313 | |
314 Object initWithObjects (id* objects, NSUInteger cnt) | |
315 { | |
316 return invokeObjcSelf!(Object, "initWithObjects:count:", id*, NSUInteger)(objects, cnt); | |
317 } | |
318 | |
319 this (id* objects, NSUInteger cnt) | |
320 { | |
321 typeof(this).alloc.initWithObjects(objects, cnt); | |
322 } | |
323 | |
324 Object initWithObjects (Object initWithObjects, ...) | |
325 { | |
326 return invokeObjcSelf!(Object, "initWithObjects:", Object)(initWithObjects); | |
327 } | |
328 | |
329 this (Object initWithObjects, ...) | |
330 { | |
331 typeof(this).alloc.initWithObjects(initWithObjects); | |
332 } | |
333 | |
334 Object initWithSet (NSSet set) | |
335 { | |
336 return invokeObjcSelf!(Object, "initWithSet:", NSSet)(set); | |
337 } | |
338 | |
339 this (NSSet set) | |
340 { | |
341 typeof(this).alloc.initWithSet(set); | |
342 } | |
343 | |
344 Object initWithSet (NSSet set, bool flag) | |
345 { | |
346 return invokeObjcSelf!(Object, "initWithSet:copyItems:", NSSet, bool)(set, flag); | |
347 } | |
348 | |
349 this (NSSet set, bool flag) | |
350 { | |
351 typeof(this).alloc.initWithSet(set, flag); | |
352 } | |
353 | |
354 Object initWithArray (NSArray array) | |
355 { | |
356 return invokeObjcSelf!(Object, "initWithArray:", NSArray)(array); | |
357 } | |
358 | |
359 this (NSArray array) | |
360 { | |
361 typeof(this).alloc.initWithArray(array); | |
362 } | |
363 | |
364 // TNSExtendedSet | |
365 NSArray allObjects () | |
366 { | |
367 return invokeObjcSelf!(NSArray, "allObjects"); | |
368 } | |
369 | |
370 Object anyObject () | |
371 { | |
372 return invokeObjcSelf!(Object, "anyObject"); | |
373 } | |
374 | |
375 bool containsObject (Object anObject) | |
376 { | |
377 return invokeObjcSelf!(bool, "containsObject:", Object)(anObject); | |
378 } | |
379 | |
380 NSString description () | |
381 { | |
382 return invokeObjcSelf!(NSString, "description"); | |
383 } | |
384 | |
385 NSString descriptionWithLocale (Object locale) | |
386 { | |
387 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); | |
388 } | |
389 | |
390 bool intersectsSet (NSSet otherSet) | |
391 { | |
392 return invokeObjcSelf!(bool, "intersectsSet:", NSSet)(otherSet); | |
393 } | |
394 | |
395 bool isEqualToSet (NSSet otherSet) | |
396 { | |
397 return invokeObjcSelf!(bool, "isEqualToSet:", NSSet)(otherSet); | |
398 } | |
399 | |
400 bool isSubsetOfSet (NSSet otherSet) | |
401 { | |
402 return invokeObjcSelf!(bool, "isSubsetOfSet:", NSSet)(otherSet); | |
403 } | |
404 | |
405 void makeObjectsPerformSelector (SEL aSelector) | |
406 { | |
407 return invokeObjcSelf!(void, "makeObjectsPerformSelector:", SEL)(aSelector); | |
408 } | |
409 | |
410 void makeObjectsPerformSelector (SEL aSelector, Object argument) | |
411 { | |
412 return invokeObjcSelf!(void, "makeObjectsPerformSelector:withObject:", SEL, Object)(aSelector, argument); | |
413 } | |
414 | |
415 NSSet setByAddingObject (Object anObject) | |
416 { | |
417 return invokeObjcSelf!(NSSet, "setByAddingObject:", Object)(anObject); | |
418 } | |
419 | |
420 NSSet setByAddingObjectsFromSet (NSSet other) | |
421 { | |
422 return invokeObjcSelf!(NSSet, "setByAddingObjectsFromSet:", NSSet)(other); | |
423 } | |
424 | |
425 NSSet setByAddingObjectsFromArray (NSArray other) | |
426 { | |
427 return invokeObjcSelf!(NSSet, "setByAddingObjectsFromArray:", NSArray)(other); | |
428 } | |
429 | |
430 // TNSKeyValueObserverRegistration | |
431 void addObserver (NSObject observer, NSString keyPath, uint options, void* context) | |
432 { | |
433 return invokeObjcSelf!(void, "addObserver:forKeyPath:options:context:", NSObject, NSString, uint, void*)(observer, keyPath, options, context); | |
434 } | |
435 | |
436 void removeObserver (NSObject observer, NSString keyPath) | |
437 { | |
438 return invokeObjcSelf!(void, "removeObserver:forKeyPath:", NSObject, NSString)(observer, keyPath); | |
73 } | 439 } |
74 } | 440 } |
75 | 441 |
76 class NSMutableSet : NSSet | 442 class NSMutableSet : NSSet |
77 { | 443 { |
78 mixin ObjcWrap; | 444 mixin (ObjcWrap); |
79 mixin TNSPredicateSupport; | 445 |
80 mixin TNSMutableSetCreation; | 446 this () |
81 mixin TNSExtendedMutableSet; | 447 { |
448 super(typeof(this).alloc.init.objcObject); | |
449 } | |
450 | |
451 typeof(this) init () | |
452 { | |
453 return invokeObjcSelf!(typeof(this), "init"); | |
454 } | |
82 | 455 |
83 void addObject (Object object) | 456 void addObject (Object object) |
84 { | 457 { |
85 return invokeObjcSelf!(void, "addObject:", Object)(object); | 458 return invokeObjcSelf!(void, "addObject:", Object)(object); |
86 } | 459 } |
87 | 460 |
88 void removeObject (Object object) | 461 void removeObject (Object object) |
89 { | 462 { |
90 return invokeObjcSelf!(void, "removeObject:", Object)(object); | 463 return invokeObjcSelf!(void, "removeObject:", Object)(object); |
464 } | |
465 | |
466 // TNSPredicateSupport | |
467 void filterUsingPredicate (NSPredicate predicate) | |
468 { | |
469 return invokeObjcSelf!(void, "filterUsingPredicate:", NSPredicate)(predicate); | |
470 } | |
471 | |
472 // TNSMutableSetCreation | |
473 static Object setWithCapacity (NSUInteger numItems) | |
474 { | |
475 return invokeObjcSuperClass!(Object, "setWithCapacity:", NSUInteger)(numItems); | |
476 } | |
477 | |
478 Object initWithCapacity (NSUInteger numItems) | |
479 { | |
480 return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(numItems); | |
481 } | |
482 | |
483 this (NSUInteger numItems) | |
484 { | |
485 typeof(this).alloc.initWithCapacity(numItems); | |
486 } | |
487 | |
488 // TNSExtendedMutableSet | |
489 void addObjectsFromArray (NSArray array) | |
490 { | |
491 return invokeObjcSelf!(void, "addObjectsFromArray:", NSArray)(array); | |
492 } | |
493 | |
494 void intersectSet (NSSet otherSet) | |
495 { | |
496 return invokeObjcSelf!(void, "intersectSet:", NSSet)(otherSet); | |
497 } | |
498 | |
499 void minusSet (NSSet otherSet) | |
500 { | |
501 return invokeObjcSelf!(void, "minusSet:", NSSet)(otherSet); | |
502 } | |
503 | |
504 void removeAllObjects () | |
505 { | |
506 return invokeObjcSelf!(void, "removeAllObjects"); | |
507 } | |
508 | |
509 void unionSet (NSSet otherSet) | |
510 { | |
511 return invokeObjcSelf!(void, "unionSet:", NSSet)(otherSet); | |
512 } | |
513 | |
514 void setSet (NSSet otherSet) | |
515 { | |
516 return invokeObjcSelf!(void, "setSet:", NSSet)(otherSet); | |
91 } | 517 } |
92 } | 518 } |
93 | 519 |
94 class NSCountedSet : NSMutableSet | 520 class NSCountedSet : NSMutableSet |
95 { | 521 { |
96 mixin ObjcWrap; | 522 mixin (ObjcWrap); |
523 | |
524 this () | |
525 { | |
526 super(typeof(this).alloc.init.objcObject); | |
527 } | |
528 | |
529 typeof(this) init () | |
530 { | |
531 return invokeObjcSelf!(typeof(this), "init"); | |
532 } | |
97 | 533 |
98 Object initWithCapacity (NSUInteger numItems) | 534 Object initWithCapacity (NSUInteger numItems) |
99 { | 535 { |
100 return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(numItems); | 536 return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(numItems); |
101 } | 537 } |
102 | 538 |
103 this (NSUInteger numItems) | 539 this (NSUInteger numItems) |
104 { | 540 { |
105 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 541 typeof(this).alloc.initWithCapacity(numItems); |
106 id result = Bridge.invokeObjcMethod!(id, "initWithCapacity:", NSUInteger)(objcObject, numItems); | |
107 | |
108 if (result) | |
109 objcObject = ret; | |
110 | |
111 dObject = this; | |
112 } | 542 } |
113 | 543 |
114 Object initWithArray (NSArray array) | 544 Object initWithArray (NSArray array) |
115 { | 545 { |
116 return invokeObjcSelf!(Object, "initWithArray:", NSArray)(array); | 546 return invokeObjcSelf!(Object, "initWithArray:", NSArray)(array); |
117 } | 547 } |
118 | 548 |
119 this (NSArray array) | 549 this (NSArray array) |
120 { | 550 { |
121 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 551 typeof(this).alloc.initWithArray(array); |
122 id result = Bridge.invokeObjcMethod!(id, "initWithArray:", NSArray)(objcObject, array); | |
123 | |
124 if (result) | |
125 objcObject = ret; | |
126 | |
127 dObject = this; | |
128 } | 552 } |
129 | 553 |
130 Object initWithSet (NSSet set) | 554 Object initWithSet (NSSet set) |
131 { | 555 { |
132 return invokeObjcSelf!(Object, "initWithSet:", NSSet)(set); | 556 return invokeObjcSelf!(Object, "initWithSet:", NSSet)(set); |
133 } | 557 } |
134 | 558 |
135 this (NSSet set) | 559 this (NSSet set) |
136 { | 560 { |
137 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | 561 typeof(this).alloc.initWithSet(set); |
138 id result = Bridge.invokeObjcMethod!(id, "initWithSet:", NSSet)(objcObject, set); | |
139 | |
140 if (result) | |
141 objcObject = ret; | |
142 | |
143 dObject = this; | |
144 } | 562 } |
145 | 563 |
146 NSUInteger countForObject (Object object) | 564 NSUInteger countForObject (Object object) |
147 { | 565 { |
148 return invokeObjcSelf!(NSUInteger, "countForObject:", Object)(object); | 566 return invokeObjcSelf!(NSUInteger, "countForObject:", Object)(object); |
161 void removeObject (Object object) | 579 void removeObject (Object object) |
162 { | 580 { |
163 return invokeObjcSelf!(void, "removeObject:", Object)(object); | 581 return invokeObjcSelf!(void, "removeObject:", Object)(object); |
164 } | 582 } |
165 } | 583 } |
166 | |
167 template TNSSetCreation () | |
168 { | |
169 static Object set () | |
170 { | |
171 return invokeObjcSelfClass!(Object, "set"); | |
172 } | |
173 | |
174 static Object setWithObject (Object object) | |
175 { | |
176 return invokeObjcSelfClass!(Object, "setWithObject:", Object)(object); | |
177 } | |
178 | |
179 static Object setWithObjects (id* objects, NSUInteger cnt) | |
180 { | |
181 return invokeObjcSelfClass!(Object, "setWithObjects:count:", id*, NSUInteger)(objects, cnt); | |
182 } | |
183 | |
184 static Object setWithObjects (Object setWithObjects, ...) | |
185 { | |
186 return invokeObjcSelfClass!(Object, "setWithObjects:", Object)(setWithObjects); | |
187 } | |
188 | |
189 static Object setWithSet (NSSet set) | |
190 { | |
191 return invokeObjcSelfClass!(Object, "setWithSet:", NSSet)(set); | |
192 } | |
193 | |
194 static Object setWithArray (NSArray array) | |
195 { | |
196 return invokeObjcSelfClass!(Object, "setWithArray:", NSArray)(array); | |
197 } | |
198 | |
199 Object initWithObjects (id* objects, NSUInteger cnt) | |
200 { | |
201 return invokeObjcSelf!(Object, "initWithObjects:count:", id*, NSUInteger)(objects, cnt); | |
202 } | |
203 | |
204 this (id* objects, NSUInteger cnt) | |
205 { | |
206 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
207 id result = Bridge.invokeObjcMethod!(id, "initWithObjects:count:", id*, NSUInteger)(objcObject, objects, cnt); | |
208 | |
209 if (result) | |
210 objcObject = ret; | |
211 | |
212 dObject = this; | |
213 } | |
214 | |
215 Object initWithObjects (Object initWithObjects, ...) | |
216 { | |
217 return invokeObjcSelf!(Object, "initWithObjects:", Object)(initWithObjects); | |
218 } | |
219 | |
220 this (Object initWithObjects, ...) | |
221 { | |
222 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
223 id result = Bridge.invokeObjcMethod!(id, "initWithObjects:", Object)(objcObject, initWithObjects); | |
224 | |
225 if (result) | |
226 objcObject = ret; | |
227 | |
228 dObject = this; | |
229 } | |
230 | |
231 Object initWithSet (NSSet set) | |
232 { | |
233 return invokeObjcSelf!(Object, "initWithSet:", NSSet)(set); | |
234 } | |
235 | |
236 this (NSSet set) | |
237 { | |
238 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
239 id result = Bridge.invokeObjcMethod!(id, "initWithSet:", NSSet)(objcObject, set); | |
240 | |
241 if (result) | |
242 objcObject = ret; | |
243 | |
244 dObject = this; | |
245 } | |
246 | |
247 Object initWithSet (NSSet set, bool flag) | |
248 { | |
249 return invokeObjcSelf!(Object, "initWithSet:copyItems:", NSSet, bool)(set, flag); | |
250 } | |
251 | |
252 this (NSSet set, bool flag) | |
253 { | |
254 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
255 id result = Bridge.invokeObjcMethod!(id, "initWithSet:copyItems:", NSSet, bool)(objcObject, set, flag); | |
256 | |
257 if (result) | |
258 objcObject = ret; | |
259 | |
260 dObject = this; | |
261 } | |
262 | |
263 Object initWithArray (NSArray array) | |
264 { | |
265 return invokeObjcSelf!(Object, "initWithArray:", NSArray)(array); | |
266 } | |
267 | |
268 this (NSArray array) | |
269 { | |
270 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
271 id result = Bridge.invokeObjcMethod!(id, "initWithArray:", NSArray)(objcObject, array); | |
272 | |
273 if (result) | |
274 objcObject = ret; | |
275 | |
276 dObject = this; | |
277 } | |
278 } | |
279 | |
280 template TNSExtendedSet () | |
281 { | |
282 NSArray allObjects () | |
283 { | |
284 return invokeObjcSelf!(NSArray, "allObjects"); | |
285 } | |
286 | |
287 Object anyObject () | |
288 { | |
289 return invokeObjcSelf!(Object, "anyObject"); | |
290 } | |
291 | |
292 bool containsObject (Object anObject) | |
293 { | |
294 return invokeObjcSelf!(bool, "containsObject:", Object)(anObject); | |
295 } | |
296 | |
297 NSString description () | |
298 { | |
299 return invokeObjcSelf!(NSString, "description"); | |
300 } | |
301 | |
302 NSString descriptionWithLocale (Object locale) | |
303 { | |
304 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); | |
305 } | |
306 | |
307 bool intersectsSet (NSSet otherSet) | |
308 { | |
309 return invokeObjcSelf!(bool, "intersectsSet:", NSSet)(otherSet); | |
310 } | |
311 | |
312 bool isEqualToSet (NSSet otherSet) | |
313 { | |
314 return invokeObjcSelf!(bool, "isEqualToSet:", NSSet)(otherSet); | |
315 } | |
316 | |
317 bool isSubsetOfSet (NSSet otherSet) | |
318 { | |
319 return invokeObjcSelf!(bool, "isSubsetOfSet:", NSSet)(otherSet); | |
320 } | |
321 | |
322 void makeObjectsPerformSelector (SEL aSelector) | |
323 { | |
324 return invokeObjcSelf!(void, "makeObjectsPerformSelector:", SEL)(aSelector); | |
325 } | |
326 | |
327 void makeObjectsPerformSelector (SEL aSelector, Object argument) | |
328 { | |
329 return invokeObjcSelf!(void, "makeObjectsPerformSelector:withObject:", SEL, Object)(aSelector, argument); | |
330 } | |
331 | |
332 NSSet setByAddingObject (Object anObject) | |
333 { | |
334 return invokeObjcSelf!(NSSet, "setByAddingObject:", Object)(anObject); | |
335 } | |
336 | |
337 NSSet setByAddingObjectsFromSet (NSSet other) | |
338 { | |
339 return invokeObjcSelf!(NSSet, "setByAddingObjectsFromSet:", NSSet)(other); | |
340 } | |
341 | |
342 NSSet setByAddingObjectsFromArray (NSArray other) | |
343 { | |
344 return invokeObjcSelf!(NSSet, "setByAddingObjectsFromArray:", NSArray)(other); | |
345 } | |
346 } | |
347 | |
348 template TNSMutableSetCreation () | |
349 { | |
350 static Object setWithCapacity (NSUInteger numItems) | |
351 { | |
352 return invokeObjcSelfClass!(Object, "setWithCapacity:", NSUInteger)(numItems); | |
353 } | |
354 | |
355 Object initWithCapacity (NSUInteger numItems) | |
356 { | |
357 return invokeObjcSelf!(Object, "initWithCapacity:", NSUInteger)(numItems); | |
358 } | |
359 | |
360 this (NSUInteger numItems) | |
361 { | |
362 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
363 id result = Bridge.invokeObjcMethod!(id, "initWithCapacity:", NSUInteger)(objcObject, numItems); | |
364 | |
365 if (result) | |
366 objcObject = ret; | |
367 | |
368 dObject = this; | |
369 } | |
370 } | |
371 | |
372 template TNSExtendedMutableSet () | |
373 { | |
374 void addObjectsFromArray (NSArray array) | |
375 { | |
376 return invokeObjcSelf!(void, "addObjectsFromArray:", NSArray)(array); | |
377 } | |
378 | |
379 void intersectSet (NSSet otherSet) | |
380 { | |
381 return invokeObjcSelf!(void, "intersectSet:", NSSet)(otherSet); | |
382 } | |
383 | |
384 void minusSet (NSSet otherSet) | |
385 { | |
386 return invokeObjcSelf!(void, "minusSet:", NSSet)(otherSet); | |
387 } | |
388 | |
389 void removeAllObjects () | |
390 { | |
391 return invokeObjcSelf!(void, "removeAllObjects"); | |
392 } | |
393 | |
394 void unionSet (NSSet otherSet) | |
395 { | |
396 return invokeObjcSelf!(void, "unionSet:", NSSet)(otherSet); | |
397 } | |
398 | |
399 void setSet (NSSet otherSet) | |
400 { | |
401 return invokeObjcSelf!(void, "setSet:", NSSet)(otherSet); | |
402 } | |
403 } | |
404 |