Mercurial > projects > dstep
view dstep/foundation/NSValue.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 source
/** * 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.NSValue; import dstep.foundation.NSDictionary; import dstep.foundation.NSObject; import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; import dstep.objc.objc : id; class NSNumber : NSValue { mixin ObjcWrap; mixin TNSDecimalNumberExtensions; mixin TNSNumberCreation; byte charValue () { return invokeObjcSelf!(byte, "charValue"); } ubyte unsignedCharValue () { return invokeObjcSelf!(ubyte, "unsignedCharValue"); } short shortValue () { return invokeObjcSelf!(short, "shortValue"); } ushort unsignedShortValue () { return invokeObjcSelf!(ushort, "unsignedShortValue"); } int intValue () { return invokeObjcSelf!(int, "intValue"); } uint unsignedIntValue () { return invokeObjcSelf!(uint, "unsignedIntValue"); } int longValue () { return invokeObjcSelf!(int, "longValue"); } uint unsignedLongValue () { return invokeObjcSelf!(uint, "unsignedLongValue"); } long longLongValue () { return invokeObjcSelf!(long, "longLongValue"); } ulong unsignedLongLongValue () { return invokeObjcSelf!(ulong, "unsignedLongLongValue"); } float floatValue () { return invokeObjcSelf!(float, "floatValue"); } double doubleValue () { return invokeObjcSelf!(double, "doubleValue"); } bool boolValue () { return invokeObjcSelf!(bool, "boolValue"); } NSInteger integerValue () { return invokeObjcSelf!(NSInteger, "integerValue"); } NSUInteger unsignedIntegerValue () { return invokeObjcSelf!(NSUInteger, "unsignedIntegerValue"); } NSString stringValue () { return invokeObjcSelf!(NSString, "stringValue"); } int compare (NSNumber otherNumber) { return invokeObjcSelf!(int, "compare:", NSNumber)(otherNumber); } bool isEqualToNumber (NSNumber number) { return invokeObjcSelf!(bool, "isEqualToNumber:", NSNumber)(number); } NSString descriptionWithLocale (Object locale) { return invokeObjcSelf!(NSString, "descriptionWithLocale:", Object)(locale); } } class NSValue : NSObject, INSCopying, INSCoding { mixin ObjcWrap; mixin TNSValueGeometryExtensions; mixin TNSValueCreation; mixin TNSValueRangeExtensions; mixin TNSValueExtensionMethods; void getValue (void* value) { return invokeObjcSelf!(void, "getValue:", void*)(value); } char* objCType () { return invokeObjcSelf!(char*, "objCType"); } Object copyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); } void encodeWithCoder (NSCoder aCoder) { return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); } Object initWithCoder (NSCoder aDecoder) { return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); } this (NSCoder aDecoder) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); if (result) objcObject = ret; dObject = this; } } template TNSNumberCreation () { Object initWithChar (byte value) { return invokeObjcSelf!(Object, "initWithChar:", byte)(value); } this (byte value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithChar:", byte)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithUnsignedChar (ubyte value) { return invokeObjcSelf!(Object, "initWithUnsignedChar:", ubyte)(value); } this (ubyte value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedChar:", ubyte)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithShort (short value) { return invokeObjcSelf!(Object, "initWithShort:", short)(value); } this (short value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithShort:", short)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithUnsignedShort (ushort value) { return invokeObjcSelf!(Object, "initWithUnsignedShort:", ushort)(value); } this (ushort value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedShort:", ushort)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithInt (int value) { return invokeObjcSelf!(Object, "initWithInt:", int)(value); } this (int value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithInt:", int)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithUnsignedInt (uint value) { return invokeObjcSelf!(Object, "initWithUnsignedInt:", uint)(value); } this (uint value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedInt:", uint)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithLong (int value) { return invokeObjcSelf!(Object, "initWithLong:", int)(value); } this (int value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithLong:", int)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithUnsignedLong (uint value) { return invokeObjcSelf!(Object, "initWithUnsignedLong:", uint)(value); } this (uint value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedLong:", uint)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithLongLong (long value) { return invokeObjcSelf!(Object, "initWithLongLong:", long)(value); } this (long value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithLongLong:", long)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithUnsignedLongLong (ulong value) { return invokeObjcSelf!(Object, "initWithUnsignedLongLong:", ulong)(value); } this (ulong value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedLongLong:", ulong)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithFloat (float value) { return invokeObjcSelf!(Object, "initWithFloat:", float)(value); } this (float value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithFloat:", float)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithDouble (double value) { return invokeObjcSelf!(Object, "initWithDouble:", double)(value); } this (double value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithDouble:", double)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithBool (bool value) { return invokeObjcSelf!(Object, "initWithBool:", bool)(value); } this (bool value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithBool:", bool)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithInteger (NSInteger value) { return invokeObjcSelf!(Object, "initWithInteger:", NSInteger)(value); } this (NSInteger value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithInteger:", NSInteger)(objcObject, value); if (result) objcObject = ret; dObject = this; } Object initWithUnsignedInteger (NSUInteger value) { return invokeObjcSelf!(Object, "initWithUnsignedInteger:", NSUInteger)(value); } this (NSUInteger value) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithUnsignedInteger:", NSUInteger)(objcObject, value); if (result) objcObject = ret; dObject = this; } static NSNumber numberWithChar (byte value) { return invokeObjcSelfClass!(NSNumber, "numberWithChar:", byte)(value); } static NSNumber numberWithUnsignedChar (ubyte value) { return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedChar:", ubyte)(value); } static NSNumber numberWithShort (short value) { return invokeObjcSelfClass!(NSNumber, "numberWithShort:", short)(value); } static NSNumber numberWithUnsignedShort (ushort value) { return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedShort:", ushort)(value); } static NSNumber numberWithInt (int value) { return invokeObjcSelfClass!(NSNumber, "numberWithInt:", int)(value); } static NSNumber numberWithUnsignedInt (uint value) { return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedInt:", uint)(value); } static NSNumber numberWithLong (int value) { return invokeObjcSelfClass!(NSNumber, "numberWithLong:", int)(value); } static NSNumber numberWithUnsignedLong (uint value) { return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedLong:", uint)(value); } static NSNumber numberWithLongLong (long value) { return invokeObjcSelfClass!(NSNumber, "numberWithLongLong:", long)(value); } static NSNumber numberWithUnsignedLongLong (ulong value) { return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedLongLong:", ulong)(value); } static NSNumber numberWithFloat (float value) { return invokeObjcSelfClass!(NSNumber, "numberWithFloat:", float)(value); } static NSNumber numberWithDouble (double value) { return invokeObjcSelfClass!(NSNumber, "numberWithDouble:", double)(value); } static NSNumber numberWithBool (bool value) { return invokeObjcSelfClass!(NSNumber, "numberWithBool:", bool)(value); } static NSNumber numberWithInteger (NSInteger value) { return invokeObjcSelfClass!(NSNumber, "numberWithInteger:", NSInteger)(value); } static NSNumber numberWithUnsignedInteger (NSUInteger value) { return invokeObjcSelfClass!(NSNumber, "numberWithUnsignedInteger:", NSUInteger)(value); } } template TNSValueCreation () { Object initWithBytes (void* value, char* type) { return invokeObjcSelf!(Object, "initWithBytes:objCType:", void*, char*)(value, type); } this (void* value, char* type) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithBytes:objCType:", void*, char*)(objcObject, value, type); if (result) objcObject = ret; dObject = this; } static NSValue valueWithBytes (void* value, char* type) { return invokeObjcSelfClass!(NSValue, "valueWithBytes:objCType:", void*, char*)(value, type); } static NSValue value (void* value, char* type) { return invokeObjcSelfClass!(NSValue, "value:withObjCType:", void*, char*)(value, type); } } template TNSValueExtensionMethods () { static NSValue valueWithNonretainedObject (Object anObject) { return invokeObjcSelfClass!(NSValue, "valueWithNonretainedObject:", Object)(anObject); } Object nonretainedObjectValue () { return invokeObjcSelf!(Object, "nonretainedObjectValue"); } static NSValue valueWithPointer (void* pointer) { return invokeObjcSelfClass!(NSValue, "valueWithPointer:", void*)(pointer); } void* pointerValue () { return invokeObjcSelf!(void*, "pointerValue"); } bool isEqualToValue (NSValue value) { return invokeObjcSelf!(bool, "isEqualToValue:", NSValue)(value); } }