Mercurial > projects > dstep
annotate dstep/foundation/NSDecimal.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 |
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.NSDecimal; | |
8 | |
9 import dstep.foundation.NSDictionary; | |
10 import dstep.foundation.NSObjCRuntime; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
11 import dstep.foundation.NSString; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
12 import dstep.internal.Version; |
14 | 13 import dstep.objc.bridge.Bridge; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
14 import dstep.objc.bridge.Capsule; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
15 import dstep.objc.objc; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
16 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
17 import bindings = dstep.foundation.NSDecimal_bindings; |
14 | 18 |
19 alias NSUInteger NSRoundingMode; | |
20 alias NSUInteger NSCalculationError; | |
21 | |
22 enum | |
23 { | |
24 NSRoundPlain, | |
25 NSRoundDown, | |
26 NSRoundUp, | |
27 NSRoundBankers | |
28 } | |
29 | |
30 enum | |
31 { | |
32 NSCalculationNoError = 0, | |
33 NSCalculationLossOfPrecision, | |
34 NSCalculationUnderflow, | |
35 NSCalculationOverflow, | |
36 NSCalculationDivideByZero | |
37 } | |
38 | |
39 struct NSDecimal | |
40 { | |
41 int _exponent; | |
42 uint _length; | |
43 uint _isNegative; | |
44 uint _isCompact; | |
45 uint _reserved; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
46 ushort* _mantissa; |
14 | 47 } |
48 | |
49 NSString NSDecimalString (NSDecimal* dcm, Object locale) | |
50 { | |
51 return Bridge.invokeObjcFunction!(NSString, bindings.NSDecimalString, NSDecimal*, Object)(dcm, locale); | |
52 } | |
53 | |
54 extern (C) | |
55 { | |
56 void NSDecimalCopy (NSDecimal* destination, NSDecimal* source); | |
57 void NSDecimalCompact (NSDecimal* number); | |
58 int NSDecimalCompare (NSDecimal* leftOperand, NSDecimal* rightOperand); | |
59 void NSDecimalRound (NSDecimal* result, NSDecimal* number, NSInteger scale, uint roundingMode); | |
60 uint NSDecimalNormalize (NSDecimal* number1, NSDecimal* number2, uint roundingMode); | |
61 uint NSDecimalAdd (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode); | |
62 uint NSDecimalSubtract (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode); | |
63 uint NSDecimalMultiply (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode); | |
64 uint NSDecimalDivide (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode); | |
65 uint NSDecimalPower (NSDecimal* result, NSDecimal* number, NSUInteger power, uint roundingMode); | |
66 uint NSDecimalMultiplyByPowerOf10 (NSDecimal* result, NSDecimal* number, short power, uint roundingMode); | |
67 } |