Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSSet.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 |
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.NSSet; | 14 module dwt.internal.cocoa.NSSet; |
15 | 15 |
16 import dwt.internal.cocoa.id; | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.cocoa.NSArray; | 17 import cocoa = dwt.internal.cocoa.id; |
18 import dwt.internal.cocoa.NSEnumerator; | 18 import dwt.internal.cocoa.NSEnumerator; |
19 import dwt.internal.cocoa.NSInteger; | |
20 import dwt.internal.cocoa.NSKeyValueObserving; | |
21 import dwt.internal.cocoa.NSObject; | 19 import dwt.internal.cocoa.NSObject; |
22 import dwt.internal.cocoa.NSPredicate; | |
23 import dwt.internal.cocoa.NSString; | |
24 import dwt.internal.cocoa.OS; | 20 import dwt.internal.cocoa.OS; |
21 import dwt.internal.objc.cocoa.Cocoa; | |
25 import objc = dwt.internal.objc.runtime; | 22 import objc = dwt.internal.objc.runtime; |
26 | 23 |
27 public class NSSet : NSObject | 24 public class NSSet : NSObject { |
28 { | |
29 | 25 |
30 public this () | 26 public this() { |
31 { | 27 super(); |
32 super(); | 28 } |
33 } | |
34 | 29 |
35 public this (objc.id id) | 30 public this(objc.id id) { |
36 { | 31 super(id); |
37 super(id); | 32 } |
38 } | |
39 | 33 |
40 public void addObserver (NSObject observer, NSString keyPath, NSKeyValueObservingOptions options, void* context) | 34 public this(cocoa.id id) { |
41 { | 35 super(id); |
42 OS.objc_msgSend(this.id_, OS.sel_addObserver_1forKeyPath_1options_1context_1, observer !is null ? observer.id_ : null, | 36 } |
43 keyPath !is null ? keyPath.id_ : null, options, context); | |
44 } | |
45 | 37 |
46 public NSArray allObjects () | 38 public NSUInteger count() { |
47 { | 39 return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_count); |
48 objc.id result = OS.objc_msgSend(this.id_, OS.sel_allObjects); | 40 } |
49 return result !is null ? new NSArray(result) : null; | |
50 } | |
51 | 41 |
52 public id anyObject () | 42 public NSEnumerator objectEnumerator() { |
53 { | 43 objc.id result = OS.objc_msgSend(this.id, OS.sel_objectEnumerator); |
54 objc.id result = OS.objc_msgSend(this.id_, OS.sel_anyObject); | 44 return result !is null ? new NSEnumerator(result) : null; |
55 return result !is null ? new id(result) : null; | 45 } |
56 } | |
57 | 46 |
58 public bool containsObject (id anObject) | 47 public static NSSet set() { |
59 { | 48 objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_set); |
60 return OS.objc_msgSend(this.id_, OS.sel_containsObject_1, anObject !is null ? anObject.id_ : null) !is null; | 49 return result !is null ? new NSSet(result) : null; |
61 } | 50 } |
62 | |
63 public NSUInteger count () | |
64 { | |
65 return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_count); | |
66 } | |
67 | |
68 public NSString description () | |
69 { | |
70 objc.id result = OS.objc_msgSend(this.id_, OS.sel_description); | |
71 return result !is null ? new NSString(result) : null; | |
72 } | |
73 | |
74 public NSString descriptionWithLocale (id locale) | |
75 { | |
76 objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id_ : null); | |
77 return result !is null ? new NSString(result) : null; | |
78 } | |
79 | |
80 public NSSet filteredSetUsingPredicate (NSPredicate predicate) | |
81 { | |
82 objc.id result = OS.objc_msgSend(this.id_, OS.sel_filteredSetUsingPredicate_1, predicate !is null ? predicate.id_ : null); | |
83 return result is this.id_ ? this : (result !is null ? new NSSet(result) : null); | |
84 } | |
85 | |
86 public NSSet initWithArray (NSArray array) | |
87 { | |
88 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithArray_1, array !is null ? array.id_ : null); | |
89 return result !is null ? this : null; | |
90 } | |
91 | |
92 public NSSet initWithObjects_ (id initWithObjects) | |
93 { | |
94 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithObjects_1, initWithObjects !is null ? initWithObjects.id_ : null); | |
95 return result !is null ? this : null; | |
96 } | |
97 | |
98 public NSSet initWithObjects_count_ (objc.id* objects, NSUInteger cnt) | |
99 { | |
100 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithObjects_1count_1, objects, cnt); | |
101 return result !is null ? this : null; | |
102 } | |
103 | |
104 public NSSet initWithSet_ (NSSet set) | |
105 { | |
106 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithSet_1, set !is null ? set.id_ : null); | |
107 return result !is null ? this : null; | |
108 } | |
109 | |
110 public NSSet initWithSet_copyItems_ (NSSet set, bool flag) | |
111 { | |
112 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithSet_1copyItems_1, set !is null ? set.id_ : null, flag); | |
113 return result !is null ? this : null; | |
114 } | |
115 | |
116 public bool intersectsSet (NSSet otherSet) | |
117 { | |
118 return OS.objc_msgSend(this.id_, OS.sel_intersectsSet_1, otherSet !is null ? otherSet.id_ : null) !is null; | |
119 } | |
120 | |
121 public bool isEqualToSet (NSSet otherSet) | |
122 { | |
123 return OS.objc_msgSend(this.id_, OS.sel_isEqualToSet_1, otherSet !is null ? otherSet.id_ : null) !is null; | |
124 } | |
125 | |
126 public bool isSubsetOfSet (NSSet otherSet) | |
127 { | |
128 return OS.objc_msgSend(this.id_, OS.sel_isSubsetOfSet_1, otherSet !is null ? otherSet.id_ : null) !is null; | |
129 } | |
130 | |
131 public void makeObjectsPerformSelector_ (objc.SEL aSelector) | |
132 { | |
133 OS.objc_msgSend(this.id_, OS.sel_makeObjectsPerformSelector_1, aSelector); | |
134 } | |
135 | |
136 public void makeObjectsPerformSelector_withObject_ (objc.SEL aSelector, id argument) | |
137 { | |
138 OS.objc_msgSend(this.id_, OS.sel_makeObjectsPerformSelector_1withObject_1, aSelector, argument !is null ? argument.id_ : null); | |
139 } | |
140 | |
141 public id member (id object) | |
142 { | |
143 objc.id result = OS.objc_msgSend(this.id_, OS.sel_member_1, object !is null ? object.id_ : null); | |
144 return result !is null ? new id(result) : null; | |
145 } | |
146 | |
147 public NSEnumerator objectEnumerator () | |
148 { | |
149 objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectEnumerator); | |
150 return result !is null ? new NSEnumerator(result) : null; | |
151 } | |
152 | |
153 public void removeObserver (NSObject observer, NSString keyPath) | |
154 { | |
155 OS.objc_msgSend(this.id_, OS.sel_removeObserver_1forKeyPath_1, observer !is null ? observer.id_ : null, keyPath !is null ? keyPath.id_ : null); | |
156 } | |
157 | |
158 public static id set () | |
159 { | |
160 objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_set); | |
161 return result !is null ? new id(result) : null; | |
162 } | |
163 | |
164 public NSSet setByAddingObject (id anObject) | |
165 { | |
166 objc.id result = OS.objc_msgSend(this.id_, OS.sel_setByAddingObject_1, anObject !is null ? anObject.id_ : null); | |
167 return result is this.id_ ? this : (result !is null ? new NSSet(result) : null); | |
168 } | |
169 | |
170 public NSSet setByAddingObjectsFromArray (NSArray other) | |
171 { | |
172 objc.id result = OS.objc_msgSend(this.id_, OS.sel_setByAddingObjectsFromArray_1, other !is null ? other.id_ : null); | |
173 return result is this.id_ ? this : (result !is null ? new NSSet(result) : null); | |
174 } | |
175 | |
176 public NSSet setByAddingObjectsFromSet (NSSet other) | |
177 { | |
178 objc.id result = OS.objc_msgSend(this.id_, OS.sel_setByAddingObjectsFromSet_1, other !is null ? other.id_ : null); | |
179 return result is this.id_ ? this : (result !is null ? new NSSet(result) : null); | |
180 } | |
181 | |
182 public void setValue (id value, NSString key) | |
183 { | |
184 OS.objc_msgSend(this.id_, OS.sel_setValue_1forKey_1, value !is null ? value.id_ : null, key !is null ? key.id_ : null); | |
185 } | |
186 | |
187 public static id setWithArray (NSArray array) | |
188 { | |
189 objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithArray_1, array !is null ? array.id_ : null); | |
190 return result !is null ? new id(result) : null; | |
191 } | |
192 | |
193 public static id setWithObject (id object) | |
194 { | |
195 objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithObject_1, object !is null ? object.id_ : null); | |
196 return result !is null ? new id(result) : null; | |
197 } | |
198 | |
199 public static id static_setWithObjects_ (id setWithObjects) | |
200 { | |
201 objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithObjects_1, setWithObjects !is null ? setWithObjects.id_ : null); | |
202 return result !is null ? new id(result) : null; | |
203 } | |
204 | |
205 public static id static_setWithObjects_count_ (objc.id* objects, NSUInteger cnt) | |
206 { | |
207 objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithObjects_1count_1, objects, cnt); | |
208 return result !is null ? new id(result) : null; | |
209 } | |
210 | |
211 public static id setWithSet (NSSet set) | |
212 { | |
213 objc.id result = OS.objc_msgSend(OS.class_NSSet, OS.sel_setWithSet_1, set !is null ? set.id_ : null); | |
214 return result !is null ? new id(result) : null; | |
215 } | |
216 | |
217 public id valueForKey (NSString key) | |
218 { | |
219 objc.id result = OS.objc_msgSend(this.id_, OS.sel_valueForKey_1, key !is null ? key.id_ : null); | |
220 return result !is null ? new id(result) : null; | |
221 } | |
222 | 51 |
223 } | 52 } |