Mercurial > projects > dstep
annotate dstep/foundation/NSDecimalNumber.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 | 7ff919f595d5 |
children | b9de51448c6b |
rev | line source |
---|---|
14 | 1 /** |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSDecimalNumber; | |
8 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
9 import dstep.foundation.NSCoder; |
14 | 10 import dstep.foundation.NSDecimal; |
11 import dstep.foundation.NSDictionary; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
12 import dstep.foundation.NSObjCRuntime; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
13 import dstep.foundation.NSObject; |
14 | 14 import dstep.foundation.NSScanner; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
15 import dstep.foundation.NSString; |
14 | 16 import dstep.foundation.NSValue; |
17 import dstep.objc.bridge.Bridge; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
18 import dstep.objc.objc; |
14 | 19 |
20 import bindings = dstep.foundation.NSDecimalNumber_bindings; | |
21 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
22 private |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
23 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
24 NSString NSDecimalNumberExactnessException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
25 NSString NSDecimalNumberOverflowException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
26 NSString NSDecimalNumberUnderflowException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
27 NSString NSDecimalNumberDivideByZeroException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
28 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
29 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
30 NSString NSDecimalNumberExactnessException () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
31 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
32 if (NSDecimalNumberExactnessException_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
33 return NSDecimalNumberExactnessException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
34 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
35 return NSDecimalNumberExactnessException_ = new NSString(bindings.NSDecimalNumberExactnessException); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
36 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
37 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
38 NSString NSDecimalNumberOverflowException () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
39 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
40 if (NSDecimalNumberOverflowException_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
41 return NSDecimalNumberOverflowException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
42 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
43 return NSDecimalNumberOverflowException_ = new NSString(bindings.NSDecimalNumberOverflowException); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
44 } |
14 | 45 |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
46 NSString NSDecimalNumberUnderflowException () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
47 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
48 if (NSDecimalNumberUnderflowException_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
49 return NSDecimalNumberUnderflowException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
50 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
51 return NSDecimalNumberUnderflowException_ = new NSString(bindings.NSDecimalNumberUnderflowException); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
52 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
53 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
54 NSString NSDecimalNumberDivideByZeroException () |
14 | 55 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
56 if (NSDecimalNumberDivideByZeroException_) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
57 return NSDecimalNumberDivideByZeroException_; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
58 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
59 return NSDecimalNumberDivideByZeroException_ = new NSString(bindings.NSDecimalNumberDivideByZeroException); |
14 | 60 } |
61 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
62 const TNSDecimalNumberExtensions = ` |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
63 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
64 NSDecimal decimalValue () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
65 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
66 return invokeObjcSelf!(NSDecimal, "decimalValue"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
67 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
68 `; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
69 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
70 const TNSDecimalNumberScanning = ` |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
71 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
72 bool scanDecimal (NSDecimal* dcm) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
73 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
74 return invokeObjcSelf!(bool, "scanDecimal:", NSDecimal*)(dcm); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
75 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
76 `; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
77 |
14 | 78 class NSDecimalNumber : NSNumber |
79 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
80 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
81 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
82 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
83 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
84 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
85 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
86 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
87 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
88 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
89 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
90 } |
14 | 91 |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
92 NSDecimalNumber initWithMantissa (ulong mantissa, short exponent, bool flag) |
14 | 93 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
94 return invokeObjcSelf!(NSDecimalNumber, "initWithMantissa:exponent:isNegative:", ulong, short, bool)(mantissa, exponent, flag); |
14 | 95 } |
96 | |
97 this (ulong mantissa, short exponent, bool flag) | |
98 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
99 super(typeof(this).alloc.initWithMantissa(mantissa, exponent, flag).objcObject); |
14 | 100 } |
101 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
102 NSDecimalNumber initWithDecimal (NSDecimal dcm) |
14 | 103 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
104 return invokeObjcSelf!(NSDecimalNumber, "initWithDecimal:", NSDecimal)(dcm); |
14 | 105 } |
106 | |
107 this (NSDecimal dcm) | |
108 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
109 super(typeof(this).alloc.initWithDecimal(dcm).objcObject); |
14 | 110 } |
111 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
112 NSDecimalNumber initWithString (NSString numberValue) |
14 | 113 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
114 return invokeObjcSelf!(NSDecimalNumber, "initWithString:", NSString)(numberValue); |
14 | 115 } |
116 | |
117 this (NSString numberValue) | |
118 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
119 super(typeof(this).alloc.initWithString(numberValue).objcObject); |
14 | 120 } |
121 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
122 NSDecimalNumber initWithString (NSString numberValue, Object locale) |
14 | 123 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
124 return invokeObjcSelf!(NSDecimalNumber, "initWithString:locale:", NSString, Object)(numberValue, locale); |
14 | 125 } |
126 | |
127 this (NSString numberValue, Object locale) | |
128 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
129 super(typeof(this).alloc.initWithString(numberValue, locale).objcObject); |
14 | 130 } |
131 | |
132 NSString descriptionWithLocale (Object locale) | |
133 { | |
134 return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); | |
135 } | |
136 | |
137 NSDecimal decimalValue () | |
138 { | |
139 return invokeObjcSelf!(NSDecimal, "decimalValue"); | |
140 } | |
141 | |
142 static NSDecimalNumber decimalNumberWithMantissa (ulong mantissa, short exponent, bool flag) | |
143 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
144 return invokeObjcSuperClass!(NSDecimalNumber, "decimalNumberWithMantissa:exponent:isNegative:", ulong, short, bool)(mantissa, exponent, flag); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
145 } |
14 | 146 |
147 static NSDecimalNumber decimalNumberWithDecimal (NSDecimal dcm) | |
148 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
149 return invokeObjcSuperClass!(NSDecimalNumber, "decimalNumberWithDecimal:", NSDecimal)(dcm); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
150 } |
14 | 151 |
152 static NSDecimalNumber decimalNumberWithString (NSString numberValue) | |
153 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
154 return invokeObjcSuperClass!(NSDecimalNumber, "decimalNumberWithString:", NSString)(numberValue); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
155 } |
14 | 156 |
157 static NSDecimalNumber decimalNumberWithString (NSString numberValue, Object locale) | |
158 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
159 return invokeObjcSuperClass!(NSDecimalNumber, "decimalNumberWithString:locale:", NSString, Object)(numberValue, locale); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
160 } |
14 | 161 |
162 static NSDecimalNumber zero () | |
163 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
164 return invokeObjcSuperClass!(NSDecimalNumber, "zero"); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
165 } |
14 | 166 |
167 static NSDecimalNumber one () | |
168 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
169 return invokeObjcSuperClass!(NSDecimalNumber, "one"); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
170 } |
14 | 171 |
172 static NSDecimalNumber minimumDecimalNumber () | |
173 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
174 return invokeObjcSuperClass!(NSDecimalNumber, "minimumDecimalNumber"); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
175 } |
14 | 176 |
177 static NSDecimalNumber maximumDecimalNumber () | |
178 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
179 return invokeObjcSuperClass!(NSDecimalNumber, "maximumDecimalNumber"); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
180 } |
14 | 181 |
182 static NSDecimalNumber notANumber () | |
183 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
184 return invokeObjcSuperClass!(NSDecimalNumber, "notANumber"); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
185 } |
14 | 186 |
187 NSDecimalNumber decimalNumberByAdding (NSDecimalNumber decimalNumber) | |
188 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
189 id result = invokeObjcSelf!(id, "decimalNumberByAdding:", NSDecimalNumber)(decimalNumber); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
190 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
191 } |
14 | 192 |
193 NSDecimalNumber decimalNumberByAdding (NSDecimalNumber decimalNumber, INSDecimalNumberBehaviors behavior) | |
194 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
195 id result = invokeObjcSelf!(id, "decimalNumberByAdding:withBehavior:", NSDecimalNumber, INSDecimalNumberBehaviors)(decimalNumber, behavior); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
196 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
197 } |
14 | 198 |
199 NSDecimalNumber decimalNumberBySubtracting (NSDecimalNumber decimalNumber) | |
200 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
201 id result = invokeObjcSelf!(id, "decimalNumberBySubtracting:", NSDecimalNumber)(decimalNumber); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
202 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
203 } |
14 | 204 |
205 NSDecimalNumber decimalNumberBySubtracting (NSDecimalNumber decimalNumber, INSDecimalNumberBehaviors behavior) | |
206 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
207 id result = invokeObjcSelf!(id, "decimalNumberBySubtracting:withBehavior:", NSDecimalNumber, INSDecimalNumberBehaviors)(decimalNumber, behavior); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
208 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
209 } |
14 | 210 |
211 NSDecimalNumber decimalNumberByMultiplyingBy (NSDecimalNumber decimalNumber) | |
212 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
213 id result = invokeObjcSelf!(id, "decimalNumberByMultiplyingBy:", NSDecimalNumber)(decimalNumber); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
214 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
215 } |
14 | 216 |
217 NSDecimalNumber decimalNumberByMultiplyingBy (NSDecimalNumber decimalNumber, INSDecimalNumberBehaviors behavior) | |
218 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
219 id result = invokeObjcSelf!(id, "decimalNumberByMultiplyingBy:withBehavior:", NSDecimalNumber, INSDecimalNumberBehaviors)(decimalNumber, behavior); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
220 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
221 } |
14 | 222 |
223 NSDecimalNumber decimalNumberByDividingBy (NSDecimalNumber decimalNumber) | |
224 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
225 id result = invokeObjcSelf!(id, "decimalNumberByDividingBy:", NSDecimalNumber)(decimalNumber); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
226 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
227 } |
14 | 228 |
229 NSDecimalNumber decimalNumberByDividingBy (NSDecimalNumber decimalNumber, INSDecimalNumberBehaviors behavior) | |
230 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
231 id result = invokeObjcSelf!(id, "decimalNumberByDividingBy:withBehavior:", NSDecimalNumber, INSDecimalNumberBehaviors)(decimalNumber, behavior); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
232 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
233 } |
14 | 234 |
235 NSDecimalNumber decimalNumberByRaisingToPower (NSUInteger power) | |
236 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
237 id result = invokeObjcSelf!(id, "decimalNumberByRaisingToPower:", NSUInteger)(power); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
238 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
239 } |
14 | 240 |
241 NSDecimalNumber decimalNumberByRaisingToPower (NSUInteger power, INSDecimalNumberBehaviors behavior) | |
242 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
243 id result = invokeObjcSelf!(id, "decimalNumberByRaisingToPower:withBehavior:", NSUInteger, INSDecimalNumberBehaviors)(power, behavior); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
244 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
245 } |
14 | 246 |
247 NSDecimalNumber decimalNumberByMultiplyingByPowerOf10 (short power) | |
248 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
249 id result = invokeObjcSelf!(id, "decimalNumberByMultiplyingByPowerOf10:", short)(power); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
250 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
251 } |
14 | 252 |
253 NSDecimalNumber decimalNumberByMultiplyingByPowerOf10 (short power, INSDecimalNumberBehaviors behavior) | |
254 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
255 id result = invokeObjcSelf!(id, "decimalNumberByMultiplyingByPowerOf10:withBehavior:", short, INSDecimalNumberBehaviors)(power, behavior); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
256 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
257 } |
14 | 258 |
259 NSDecimalNumber decimalNumberByRoundingAccordingToBehavior (INSDecimalNumberBehaviors behavior) | |
260 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
261 id result = invokeObjcSelf!(id, "decimalNumberByRoundingAccordingToBehavior:", INSDecimalNumberBehaviors)(behavior); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
262 return result is this.objcObject ? this : (result !is null ? new NSDecimalNumber(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
263 } |
14 | 264 |
265 int compare (NSNumber decimalNumber) | |
266 { | |
267 return invokeObjcSelf!(int, "compare:", NSNumber)(decimalNumber); | |
268 } | |
269 | |
270 static void setDefaultBehavior (INSDecimalNumberBehaviors behavior) | |
271 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
272 return invokeObjcSuperClass!(void, "setDefaultBehavior:", INSDecimalNumberBehaviors)(behavior); |
14 | 273 } |
274 | |
275 static INSDecimalNumberBehaviors defaultBehavior () | |
276 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
277 return invokeObjcSuperClass!(INSDecimalNumberBehaviors, "defaultBehavior"); |
14 | 278 } |
279 | |
280 char* objCType () | |
281 { | |
282 return invokeObjcSelf!(char*, "objCType"); | |
283 } | |
284 | |
285 double doubleValue () | |
286 { | |
287 return invokeObjcSelf!(double, "doubleValue"); | |
288 } | |
289 } | |
290 | |
291 class NSDecimalNumberHandler : NSObject, INSDecimalNumberBehaviors, INSCoding | |
292 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
293 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
294 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
295 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
296 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
297 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
298 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
299 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
300 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
301 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
302 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
303 } |
14 | 304 |
305 static Object defaultDecimalNumberHandler () | |
306 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
307 return invokeObjcSuperClass!(Object, "defaultDecimalNumberHandler"); |
14 | 308 } |
309 | |
310 Object initWithRoundingMode (uint roundingMode, short scale, bool exact, bool overflow, bool underflow, bool divideByZero) | |
311 { | |
312 return invokeObjcSelf!(Object, "initWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:", uint, short, bool, bool, bool, bool)(roundingMode, scale, exact, overflow, underflow, divideByZero); | |
313 } | |
314 | |
315 this (uint roundingMode, short scale, bool exact, bool overflow, bool underflow, bool divideByZero) | |
316 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
317 typeof(this).alloc.initWithRoundingMode(roundingMode, scale, exact, overflow, underflow, divideByZero); |
14 | 318 } |
319 | |
320 static Object decimalNumberHandlerWithRoundingMode (uint roundingMode, short scale, bool exact, bool overflow, bool underflow, bool divideByZero) | |
321 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
322 return invokeObjcSuperClass!(Object, "decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:", uint, short, bool, bool, bool, bool)(roundingMode, scale, exact, overflow, underflow, divideByZero); |
14 | 323 } |
324 | |
325 uint roundingMode () | |
326 { | |
327 return invokeObjcSelf!(uint, "roundingMode"); | |
328 } | |
329 | |
330 short scale () | |
331 { | |
332 return invokeObjcSelf!(short, "scale"); | |
333 } | |
334 | |
335 NSDecimalNumber exceptionDuringOperation (SEL operation, uint error, NSDecimalNumber leftOperand, NSDecimalNumber rightOperand) | |
336 { | |
337 return invokeObjcSelf!(NSDecimalNumber, "exceptionDuringOperation:error:leftOperand:rightOperand:", SEL, uint, NSDecimalNumber, NSDecimalNumber)(operation, error, leftOperand, rightOperand); | |
338 } | |
339 | |
340 void encodeWithCoder (NSCoder aCoder) | |
341 { | |
342 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
343 } | |
344 | |
345 Object initWithCoder (NSCoder aDecoder) | |
346 { | |
347 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); | |
348 } | |
349 | |
350 this (NSCoder aDecoder) | |
351 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
352 typeof(this).alloc.initWithCoder(aDecoder); |
14 | 353 } |
354 } | |
355 | |
356 interface INSDecimalNumberBehaviors | |
357 { | |
358 uint roundingMode (); | |
359 short scale (); | |
360 NSDecimalNumber exceptionDuringOperation (SEL operation, uint error, NSDecimalNumber leftOperand, NSDecimalNumber rightOperand); | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
361 } |