Mercurial > projects > dwt-mac
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/cocoa/NSNumber.d Sat Aug 09 17:00:02 2008 +0200 @@ -0,0 +1,321 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * + * Port to the D Programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> + *******************************************************************************/ +module dwt.internal.cocoa.NSNumber; + +import dwt.internal.cocoa.id; +import dwt.internal.cocoa.NSComparisonResult; +import dwt.internal.cocoa.NSDecimal; +import dwt.internal.cocoa.NSString; +import dwt.internal.cocoa.NSValue; +import dwt.internal.cocoa.OS; +import objc = dwt.internal.objc.runtime; + +public class NSNumber : NSValue +{ + + public this () + { + super(); + } + + public this (objc.id id) + { + super(id); + } + + public bool boolValue () + { + return OS.objc_msgSend(this.id, OS.sel_boolValue) !is null; + } + + public byte charValue () + { + return cast(byte) OS.objc_msgSend(this.id, OS.sel_charValue); + } + + public NSComparisonResult compare (NSNumber otherNumber) + { + return OS.objc_msgSend(this.id, OS.sel_compare_1, otherNumber !is null ? otherNumber.id : null); + } + + public NSDecimal decimalValue () + { + NSDecimal result = new NSDecimal(); + OS.objc_msgSend_stret(result, this.id, OS.sel_decimalValue); + return result; + } + + public NSString descriptionWithLocale (id locale) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null); + return result !is null ? new NSString(result) : null; + } + + public double doubleValue () + { + return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue); + } + + public float floatValue () + { + return cast(float) OS.objc_msgSend_fpret(this.id, OS.sel_floatValue); + } + + public id initWithBool (bool value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBool_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithChar (byte value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithChar_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithDouble (double value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDouble_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithFloat (float value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFloat_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithInt (int value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithInt_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithInteger (int value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithInteger_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithLong (int value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLong_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithLongLong (long value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithLongLong_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithShort (short value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithShort_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithUnsignedChar (ubyte value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedChar_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithUnsignedInt (uint value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedInt_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithUnsignedInteger (uint value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedInteger_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithUnsignedLong (uint value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedLong_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithUnsignedLongLong (ulong value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedLongLong_1, value); + return result !is null ? new id(result) : null; + } + + public id initWithUnsignedShort (ushort value) + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithUnsignedShort_1, value); + return result !is null ? new id(result) : null; + } + + public int intValue () + { + return cast(int)OS.objc_msgSend(this.id, OS.sel_intValue); + } + + public int integerValue () + { + return cast(int)OS.objc_msgSend(this.id, OS.sel_integerValue); + } + + public bool isEqualToNumber (NSNumber number) + { + return OS.objc_msgSend(this.id, OS.sel_isEqualToNumber_1, number !is null ? number.id : null) !is null; + } + + public long longLongValue () + { + return cast(long) OS.objc_msgSend(this.id, OS.sel_longLongValue); + } + + public int longValue () + { + return cast(int)OS.objc_msgSend(this.id, OS.sel_longValue); + } + + public static NSNumber numberWithBool (bool value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithBool_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithChar (byte value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithChar_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithDouble (double value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithDouble_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithFloat (float value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithFloat_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithInt (int value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithInt_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithInteger (int value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithInteger_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithLong (int value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithLong_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithLongLong (long value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithLongLong_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithShort (short value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithShort_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithUnsignedChar (ubyte value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedChar_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithUnsignedInt (uint value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedInt_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithUnsignedInteger (uint value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedInteger_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithUnsignedLong (uint value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedLong_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithUnsignedLongLong (ulong value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedLongLong_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public static NSNumber numberWithUnsignedShort (ushort value) + { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithUnsignedShort_1, value); + return result !is null ? new NSNumber(result) : null; + } + + public short shortValue () + { + return cast(short) OS.objc_msgSend(this.id, OS.sel_shortValue); + } + + public NSString stringValue () + { + objc.id result = OS.objc_msgSend(this.id, OS.sel_stringValue); + return result !is null ? new NSString(result) : null; + } + + public ubyte unsignedCharValue () + { + return cast(ubyte) OS.objc_msgSend(this.id, OS.sel_unsignedCharValue); + } + + public uint unsignedIntValue () + { + return cast(uint)OS.objc_msgSend(this.id, OS.sel_unsignedIntValue); + } + + public uint unsignedIntegerValue () + { + return cast(uint)OS.objc_msgSend(this.id, OS.sel_unsignedIntegerValue); + } + + public ulong unsignedLongLongValue () + { + return cast(ulong) OS.objc_msgSend(this.id, OS.sel_unsignedLongLongValue); + } + + public uint unsignedLongValue () + { + return cast(uint)OS.objc_msgSend(this.id, OS.sel_unsignedLongValue); + } + + public ushort unsignedShortValue () + { + return cast(ushort) OS.objc_msgSend(this.id, OS.sel_unsignedShortValue); + } + +}