Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSMutableArray.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.NSMutableArray; | 14 module dwt.internal.cocoa.NSMutableArray; |
15 | 15 |
16 import dwt.internal.cocoa.id; | 16 import dwt.dwthelper.utils; |
17 import cocoa = dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSArray; | 18 import dwt.internal.cocoa.NSArray; |
18 import dwt.internal.cocoa.NSIndexSet; | |
19 import dwt.internal.cocoa.NSInteger; | |
20 import dwt.internal.cocoa.NSPredicate; | |
21 import dwt.internal.cocoa.NSRange; | |
22 import dwt.internal.cocoa.OS; | 19 import dwt.internal.cocoa.OS; |
20 import dwt.internal.objc.cocoa.Cocoa; | |
23 import objc = dwt.internal.objc.runtime; | 21 import objc = dwt.internal.objc.runtime; |
24 | 22 |
25 public class NSMutableArray : NSArray | 23 public class NSMutableArray : NSArray { |
26 { | |
27 | 24 |
28 public this () | 25 public this() { |
29 { | 26 super(); |
30 super(); | 27 } |
31 } | |
32 | 28 |
33 public this (objc.id id) | 29 public this(objc.id id) { |
34 { | 30 super(id); |
35 super(id); | 31 } |
36 } | |
37 | 32 |
38 public void addObject (id anObject) | 33 public this(cocoa.id id) { |
39 { | 34 super(id); |
40 OS.objc_msgSend(this.id_, OS.sel_addObject_1, anObject !is null ? anObject.id_ : null); | 35 } |
41 } | |
42 | 36 |
43 public void addObjectsFromArray (NSArray otherArray) | 37 public void addObject(cocoa.id anObject) { |
44 { | 38 OS.objc_msgSend(this.id, OS.sel_addObject_, anObject !is null ? anObject.id : null); |
45 OS.objc_msgSend(this.id_, OS.sel_addObjectsFromArray_1, otherArray !is null ? otherArray.id_ : null); | 39 } |
46 } | |
47 | 40 |
48 public static id arrayWithCapacity (NSUInteger numItems) | 41 public void addObjectsFromArray(NSArray otherArray) { |
49 { | 42 OS.objc_msgSend(this.id, OS.sel_addObjectsFromArray_, otherArray !is null ? otherArray.id : null); |
50 objc.id result = OS.objc_msgSend(OS.class_NSMutableArray, OS.sel_arrayWithCapacity_1, numItems); | 43 } |
51 return result !is null ? new id(result) : null; | |
52 } | |
53 | 44 |
54 public void exchangeObjectAtIndex (NSUInteger idx1, NSUInteger idx2) | 45 public static NSMutableArray arrayWithCapacity(NSUInteger numItems) { |
55 { | 46 objc.id result = OS.objc_msgSend(OS.class_NSMutableArray, OS.sel_arrayWithCapacity_, numItems); |
56 OS.objc_msgSend(this.id_, OS.sel_exchangeObjectAtIndex_1withObjectAtIndex_1, idx1, idx2); | 47 return result !is null ? new NSMutableArray(result) : null; |
57 } | 48 } |
58 | 49 |
59 public void filterUsingPredicate (NSPredicate predicate) | 50 public void removeObject(cocoa.id anObject) { |
60 { | 51 OS.objc_msgSend(this.id, OS.sel_removeObject_, anObject !is null ? anObject.id : null); |
61 OS.objc_msgSend(this.id_, OS.sel_filterUsingPredicate_1, predicate !is null ? predicate.id_ : null); | 52 } |
62 } | |
63 | 53 |
64 public NSMutableArray initWithCapacity (NSUInteger numItems) | 54 public void removeObjectAtIndex(NSUInteger index) { |
65 { | 55 OS.objc_msgSend(this.id, OS.sel_removeObjectAtIndex_, index); |
66 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCapacity_1, numItems); | 56 } |
67 return result !is null ? this : null; | |
68 } | |
69 | 57 |
70 public void insertObject (id anObject, NSUInteger index) | 58 public static NSArray array() { |
71 { | 59 objc.id result = OS.objc_msgSend(OS.class_NSMutableArray, OS.sel_array); |
72 OS.objc_msgSend(this.id_, OS.sel_insertObject_1atIndex_1, anObject !is null ? anObject.id_ : null, index); | 60 return result !is null ? new NSArray(result) : null; |
73 } | 61 } |
74 | 62 |
75 public void insertObjects (NSArray objects, NSIndexSet indexes) | 63 public static NSArray arrayWithObject(cocoa.id anObject) { |
76 { | 64 objc.id result = OS.objc_msgSend(OS.class_NSMutableArray, OS.sel_arrayWithObject_, anObject !is null ? anObject.id : null); |
77 OS.objc_msgSend(this.id_, OS.sel_insertObjects_1atIndexes_1, objects !is null ? objects.id_ : null, indexes !is null ? indexes.id_ : null); | 65 return result !is null ? new NSMutableArray(result) : null; |
78 } | 66 } |
79 | |
80 public void removeAllObjects () | |
81 { | |
82 OS.objc_msgSend(this.id_, OS.sel_removeAllObjects); | |
83 } | |
84 | |
85 public void removeLastObject () | |
86 { | |
87 OS.objc_msgSend(this.id_, OS.sel_removeLastObject); | |
88 } | |
89 | |
90 public void removeObject_ (id anObject) | |
91 { | |
92 OS.objc_msgSend(this.id_, OS.sel_removeObject_1, anObject !is null ? anObject.id_ : null); | |
93 } | |
94 | |
95 public void removeObject_inRange_ (id anObject, NSRange range) | |
96 { | |
97 OS.objc_msgSend(this.id_, OS.sel_removeObject_1inRange_1, anObject !is null ? anObject.id_ : null, range); | |
98 } | |
99 | |
100 public void removeObjectAtIndex (NSUInteger index) | |
101 { | |
102 OS.objc_msgSend(this.id_, OS.sel_removeObjectAtIndex_1, index); | |
103 } | |
104 | |
105 public void removeObjectIdenticalTo_ (id anObject) | |
106 { | |
107 OS.objc_msgSend(this.id_, OS.sel_removeObjectIdenticalTo_1, anObject !is null ? anObject.id_ : null); | |
108 } | |
109 | |
110 public void removeObjectIdenticalTo_inRange_ (id anObject, NSRange range) | |
111 { | |
112 OS.objc_msgSend(this.id_, OS.sel_removeObjectIdenticalTo_1inRange_1, anObject !is null ? anObject.id_ : null, range); | |
113 } | |
114 | |
115 public void removeObjectsAtIndexes (NSIndexSet indexes) | |
116 { | |
117 OS.objc_msgSend(this.id_, OS.sel_removeObjectsAtIndexes_1, indexes !is null ? indexes.id_ : null); | |
118 } | |
119 | |
120 public void removeObjectsFromIndices (NSUInteger* indices, NSUInteger cnt) | |
121 { | |
122 OS.objc_msgSend(this.id_, OS.sel_removeObjectsFromIndices_1numIndices_1, indices, cnt); | |
123 } | |
124 | |
125 public void removeObjectsInArray (NSArray otherArray) | |
126 { | |
127 OS.objc_msgSend(this.id_, OS.sel_removeObjectsInArray_1, otherArray !is null ? otherArray.id_ : null); | |
128 } | |
129 | |
130 public void removeObjectsInRange (NSRange range) | |
131 { | |
132 OS.objc_msgSend(this.id_, OS.sel_removeObjectsInRange_1, range); | |
133 } | |
134 | |
135 public void replaceObjectAtIndex (NSUInteger index, id anObject) | |
136 { | |
137 OS.objc_msgSend(this.id_, OS.sel_replaceObjectAtIndex_1withObject_1, index, anObject !is null ? anObject.id_ : null); | |
138 } | |
139 | |
140 public void replaceObjectsAtIndexes (NSIndexSet indexes, NSArray objects) | |
141 { | |
142 OS.objc_msgSend(this.id_, OS.sel_replaceObjectsAtIndexes_1withObjects_1, indexes !is null ? indexes.id_ : null, | |
143 objects !is null ? objects.id_ : null); | |
144 } | |
145 | |
146 public void replaceObjectsInRange_withObjectsFromArray_ (NSRange range, NSArray otherArray) | |
147 { | |
148 OS.objc_msgSend(this.id_, OS.sel_replaceObjectsInRange_1withObjectsFromArray_1, range, otherArray !is null ? otherArray.id_ : null); | |
149 } | |
150 | |
151 public void replaceObjectsInRange_withObjectsFromArray_range_ (NSRange range, NSArray otherArray, NSRange otherRange) | |
152 { | |
153 OS.objc_msgSend(this.id_, OS.sel_replaceObjectsInRange_1withObjectsFromArray_1range_1, range, otherArray !is null ? otherArray.id_ : null, | |
154 otherRange); | |
155 } | |
156 | |
157 public void setArray (NSArray otherArray) | |
158 { | |
159 OS.objc_msgSend(this.id_, OS.sel_setArray_1, otherArray !is null ? otherArray.id_ : null); | |
160 } | |
161 | |
162 public void sortUsingDescriptors (NSArray sortDescriptors) | |
163 { | |
164 OS.objc_msgSend(this.id_, OS.sel_sortUsingDescriptors_1, sortDescriptors !is null ? sortDescriptors.id_ : null); | |
165 } | |
166 | |
167 public void sortUsingFunction (int function (id, id, void*) compare, void* context) | |
168 { | |
169 OS.objc_msgSend(this.id_, OS.sel_sortUsingFunction_1context_1, compare, context); | |
170 } | |
171 | |
172 public void sortUsingSelector (objc.SEL comparator) | |
173 { | |
174 OS.objc_msgSend(this.id_, OS.sel_sortUsingSelector_1, comparator); | |
175 } | |
176 | 67 |
177 } | 68 } |