Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSNumber.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.NSNumber; | |
15 | |
16 import dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSComparisonResult; | |
18 import dwt.internal.cocoa.NSDecimal; | |
19 import dwt.internal.cocoa.NSString; | |
20 import dwt.internal.cocoa.NSValue; | |
21 import dwt.internal.cocoa.OS; | |
22 import objc = dwt.internal.objc.runtime; | |
23 | |
24 public class NSNumber : NSValue | |
25 { | |
26 | |
27 public this () | |
28 { | |
29 super(); | |
30 } | |
31 | |
32 public this (objc.id id) | |
33 { | |
34 super(id); | |
35 } | |
36 | |
37 public bool boolValue () | |
38 { | |
39 return OS.objc_msgSend(this.id, OS.sel_boolValue) !is null; | |
40 } | |
41 | |
42 public byte charValue () | |
43 { | |
44 return cast(byte) OS.objc_msgSend(this.id, OS.sel_charValue); | |
45 } | |
46 | |
47 public NSComparisonResult compare (NSNumber otherNumber) | |
48 { | |
49 return OS.objc_msgSend(this.id, OS.sel_compare_1, otherNumber !is null ? otherNumber.id : null); | |
50 } | |
51 | |
52 public NSDecimal decimalValue () | |
53 { | |
54 NSDecimal result = new NSDecimal(); | |
55 OS.objc_msgSend_stret(result, this.id, OS.sel_decimalValue); | |
56 return result; | |
57 } | |
58 | |
59 public NSString descriptionWithLocale (id locale) | |
60 { | |
61 objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null); | |
62 return result !is null ? new NSString(result) : null; | |
63 } | |
64 | |
65 public double doubleValue () | |
66 { | |
67 return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue); | |
68 } | |
69 | |
70 public float floatValue () | |
71 { | |
72 return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_floatValue); | |
73 } | |
74 | |
75 public id initWithBool (bool value) | |
76 { | |
77 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBool_1, value); | |
78 return result !is null ? new id(result) : null; | |
79 } | |
80 | |
81 public id initWithChar (byte value) | |
82 { | |
83 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithChar_1, value); | |
84 return result !is null ? new id(result) : null; | |
85 } | |
86 | |
87 public id initWithDouble (double value) | |
88 { | |
89 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDouble_1, value); | |
90 return result !is null ? new id(result) : null; | |
91 } | |
92 | |
93 public id initWithFloat (float value) | |
94 { | |
95 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFloat_1, value); | |
96 return result !is null ? new id(result) : null; | |
97 } | |
98 | |
99 public id initWithInt (int value) | |
100 { | |
101 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithInt_1, value); | |
102 return result !is null ? new id(result) : null; | |
103 } | |
104 | |
105 public id initWithInteger (int value) | |
106 { | |
107 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithInteger_1, value); | |
108 return result !is null ? new id(result) : null; | |
109 } | |
110 | |
111 public id initWithLong (int value) | |
112 { | |
113 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLong_1, value); | |
114 return result !is null ? new id(result) : null; | |
115 } | |
116 | |
117 public id initWithLongLong (long value) | |
118 { | |
119 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLongLong_1, value); | |
120 return result !is null ? new id(result) : null; | |
121 } | |
122 | |
123 public id initWithShort (short value) | |
124 { | |
125 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithShort_1, value); | |
126 return result !is null ? new id(result) : null; | |
127 } | |
128 | |
129 public id initWithUnsignedChar (ubyte value) | |
130 { | |
131 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedChar_1, value); | |
132 return result !is null ? new id(result) : null; | |
133 } | |
134 | |
135 public id initWithUnsignedInt (uint value) | |
136 { | |
137 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedInt_1, value); | |
138 return result !is null ? new id(result) : null; | |
139 } | |
140 | |
141 public id initWithUnsignedInteger (uint value) | |
142 { | |
143 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedInteger_1, value); | |
144 return result !is null ? new id(result) : null; | |
145 } | |
146 | |
147 public id initWithUnsignedLong (uint value) | |
148 { | |
149 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedLong_1, value); | |
150 return result !is null ? new id(result) : null; | |
151 } | |
152 | |
153 public id initWithUnsignedLongLong (ulong value) | |
154 { | |
155 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedLongLong_1, value); | |
156 return result !is null ? new id(result) : null; | |
157 } | |
158 | |
159 public id initWithUnsignedShort (ushort value) | |
160 { | |
161 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedShort_1, value); | |
162 return result !is null ? new id(result) : null; | |
163 } | |
164 | |
165 public int intValue () | |
166 { | |
167 return cast(int)OS.objc_msgSend(this.id, OS.sel_intValue); | |
168 } | |
169 | |
170 public int integerValue () | |
171 { | |
172 return cast(int)OS.objc_msgSend(this.id, OS.sel_integerValue); | |
173 } | |
174 | |
175 public bool isEqualToNumber (NSNumber number) | |
176 { | |
177 return OS.objc_msgSend(this.id, OS.sel_isEqualToNumber_1, number !is null ? number.id : null) !is null; | |
178 } | |
179 | |
180 public long longLongValue () | |
181 { | |
182 return cast(long) OS.objc_msgSend(this.id, OS.sel_longLongValue); | |
183 } | |
184 | |
185 public int longValue () | |
186 { | |
187 return cast(int)OS.objc_msgSend(this.id, OS.sel_longValue); | |
188 } | |
189 | |
190 public static NSNumber numberWithBool (bool value) | |
191 { | |
192 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithBool_1, value); | |
193 return result !is null ? new NSNumber(result) : null; | |
194 } | |
195 | |
196 public static NSNumber numberWithChar (byte value) | |
197 { | |
198 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithChar_1, value); | |
199 return result !is null ? new NSNumber(result) : null; | |
200 } | |
201 | |
202 public static NSNumber numberWithDouble (double value) | |
203 { | |
204 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithDouble_1, value); | |
205 return result !is null ? new NSNumber(result) : null; | |
206 } | |
207 | |
208 public static NSNumber numberWithFloat (float value) | |
209 { | |
210 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithFloat_1, value); | |
211 return result !is null ? new NSNumber(result) : null; | |
212 } | |
213 | |
214 public static NSNumber numberWithInt (int value) | |
215 { | |
216 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithInt_1, value); | |
217 return result !is null ? new NSNumber(result) : null; | |
218 } | |
219 | |
220 public static NSNumber numberWithInteger (int value) | |
221 { | |
222 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithInteger_1, value); | |
223 return result !is null ? new NSNumber(result) : null; | |
224 } | |
225 | |
226 public static NSNumber numberWithLong (int value) | |
227 { | |
228 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithLong_1, value); | |
229 return result !is null ? new NSNumber(result) : null; | |
230 } | |
231 | |
232 public static NSNumber numberWithLongLong (long value) | |
233 { | |
234 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithLongLong_1, value); | |
235 return result !is null ? new NSNumber(result) : null; | |
236 } | |
237 | |
238 public static NSNumber numberWithShort (short value) | |
239 { | |
240 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithShort_1, value); | |
241 return result !is null ? new NSNumber(result) : null; | |
242 } | |
243 | |
244 public static NSNumber numberWithUnsignedChar (ubyte value) | |
245 { | |
246 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedChar_1, value); | |
247 return result !is null ? new NSNumber(result) : null; | |
248 } | |
249 | |
250 public static NSNumber numberWithUnsignedInt (uint value) | |
251 { | |
252 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedInt_1, value); | |
253 return result !is null ? new NSNumber(result) : null; | |
254 } | |
255 | |
256 public static NSNumber numberWithUnsignedInteger (uint value) | |
257 { | |
258 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedInteger_1, value); | |
259 return result !is null ? new NSNumber(result) : null; | |
260 } | |
261 | |
262 public static NSNumber numberWithUnsignedLong (uint value) | |
263 { | |
264 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedLong_1, value); | |
265 return result !is null ? new NSNumber(result) : null; | |
266 } | |
267 | |
268 public static NSNumber numberWithUnsignedLongLong (ulong value) | |
269 { | |
270 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedLongLong_1, value); | |
271 return result !is null ? new NSNumber(result) : null; | |
272 } | |
273 | |
274 public static NSNumber numberWithUnsignedShort (ushort value) | |
275 { | |
276 objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedShort_1, value); | |
277 return result !is null ? new NSNumber(result) : null; | |
278 } | |
279 | |
280 public short shortValue () | |
281 { | |
282 return cast(short) OS.objc_msgSend(this.id, OS.sel_shortValue); | |
283 } | |
284 | |
285 public NSString stringValue () | |
286 { | |
287 objc.id result = OS.objc_msgSend(this.id, OS.sel_stringValue); | |
288 return result !is null ? new NSString(result) : null; | |
289 } | |
290 | |
291 public ubyte unsignedCharValue () | |
292 { | |
293 return cast(ubyte) OS.objc_msgSend(this.id, OS.sel_unsignedCharValue); | |
294 } | |
295 | |
296 public uint unsignedIntValue () | |
297 { | |
298 return cast(uint)OS.objc_msgSend(this.id, OS.sel_unsignedIntValue); | |
299 } | |
300 | |
301 public uint unsignedIntegerValue () | |
302 { | |
303 return cast(uint)OS.objc_msgSend(this.id, OS.sel_unsignedIntegerValue); | |
304 } | |
305 | |
306 public ulong unsignedLongLongValue () | |
307 { | |
308 return cast(ulong) OS.objc_msgSend(this.id, OS.sel_unsignedLongLongValue); | |
309 } | |
310 | |
311 public uint unsignedLongValue () | |
312 { | |
313 return cast(uint)OS.objc_msgSend(this.id, OS.sel_unsignedLongValue); | |
314 } | |
315 | |
316 public ushort unsignedShortValue () | |
317 { | |
318 return cast(ushort) OS.objc_msgSend(this.id, OS.sel_unsignedShortValue); | |
319 } | |
320 | |
321 } |