Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSNumber.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children |
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSNumber.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/internal/cocoa/NSNumber.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,321 +1,80 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 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 + * IBM Corporation - initial API and implementation * * Port to the D programming language: - * Jacob Carlborg <jacob.carlborg@gmail.com> + * Jacob Carlborg <doob@me.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.dwthelper.utils; +import cocoa = dwt.internal.cocoa.id; +import dwt.internal.cocoa.NSPoint; +import dwt.internal.cocoa.NSRange; +import dwt.internal.cocoa.NSRect; +import dwt.internal.cocoa.NSSize; import dwt.internal.cocoa.NSValue; import dwt.internal.cocoa.OS; +import dwt.internal.objc.cocoa.Cocoa; 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 cast(NSComparisonResult) OS.objc_msgSend(this.id_, OS.sel_compare_1, otherNumber !is null ? otherNumber.id_ : null); - } +public class NSNumber : NSValue { - public NSDecimal decimalValue () - { - NSDecimal result; - 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 this() { + super(); +} - 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 this(objc.id id) { + super(id); +} - 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 this(cocoa.id id) { + super(id); +} - 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 int intValue() { + return cast(int)/*64*/OS.objc_msgSend(this.id, OS.sel_intValue); +} - 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 static NSNumber numberWithBool(bool value) { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithBool_, value); + return result !is null ? new NSNumber(result) : null; +} - 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 numberWithInt(int value) { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithInt_, 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(NSInteger value) { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_numberWithInteger_, 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 NSValue valueWithPoint(NSPoint point) { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_valueWithPoint_, point); + return result !is null ? new NSValue(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 static NSValue valueWithRange(NSRange range) { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_valueWithRange_, range); + return result !is null ? new NSValue(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 static NSValue valueWithRect(NSRect rect) { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_valueWithRect_, rect); + return result !is null ? new NSValue(result) : null; +} - 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); - } +public static NSValue valueWithSize(NSSize size) { + objc.id result = OS.objc_msgSend(OS.class_NSNumber, OS.sel_valueWithSize_, size); + return result !is null ? new NSValue(result) : null; +} }