diff dstep/foundation/NSDecimal.d @ 14:89f3c3ef1fd2

Added the Foundation framework
author Jacob Carlborg <doob@me.com>
date Mon, 03 Aug 2009 15:23:15 +0200
parents
children 19885b43130e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/foundation/NSDecimal.d	Mon Aug 03 15:23:15 2009 +0200
@@ -0,0 +1,63 @@
+/**
+ * Copyright: Copyright (c) 2009 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Aug 3, 2009 
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module dstep.foundation.NSDecimal;
+
+import dstep.foundation.NSDictionary;
+import dstep.foundation.NSObjCRuntime;
+import dstep.limits;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+
+alias NSUInteger NSRoundingMode;
+alias NSUInteger NSCalculationError;
+
+enum
+{
+	NSRoundPlain,
+	NSRoundDown,
+	NSRoundUp,
+	NSRoundBankers
+}
+
+enum
+{
+	NSCalculationNoError = 0,
+	NSCalculationLossOfPrecision,
+	NSCalculationUnderflow,
+	NSCalculationOverflow,
+	NSCalculationDivideByZero
+}
+
+struct NSDecimal
+{
+	int _exponent;
+	uint _length;
+	uint _isNegative;
+	uint _isCompact;
+	uint _reserved;
+	unsigned short* _mantissa;
+}
+
+NSString NSDecimalString (NSDecimal* dcm, Object locale)
+{
+	return Bridge.invokeObjcFunction!(NSString, bindings.NSDecimalString, NSDecimal*, Object)(dcm, locale);
+}
+
+extern (C)
+{
+	void NSDecimalCopy (NSDecimal* destination, NSDecimal* source);
+	void NSDecimalCompact (NSDecimal* number);
+	int NSDecimalCompare (NSDecimal* leftOperand, NSDecimal* rightOperand);
+	void NSDecimalRound (NSDecimal* result, NSDecimal* number, NSInteger scale, uint roundingMode);
+	uint NSDecimalNormalize (NSDecimal* number1, NSDecimal* number2, uint roundingMode);
+	uint NSDecimalAdd (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode);
+	uint NSDecimalSubtract (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode);
+	uint NSDecimalMultiply (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode);
+	uint NSDecimalDivide (NSDecimal* result, NSDecimal* leftOperand, NSDecimal* rightOperand, uint roundingMode);
+	uint NSDecimalPower (NSDecimal* result, NSDecimal* number, NSUInteger power, uint roundingMode);
+	uint NSDecimalMultiplyByPowerOf10 (NSDecimal* result, NSDecimal* number, short power, uint roundingMode);
+}
\ No newline at end of file