From 5fa101759996eaa1063488adc921a217a96ccc0d Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 14 Dec 2014 15:34:11 -0800 Subject: [PATCH] Support for short values --- src/core/basetypes/MCValue.cpp | 16 ++++++++++++++++ src/core/basetypes/MCValue.h | 2 ++ src/objc/utils/NSValue+MCO.mm | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/src/core/basetypes/MCValue.cpp b/src/core/basetypes/MCValue.cpp index 7f12db36f..a569fc133 100644 --- a/src/core/basetypes/MCValue.cpp +++ b/src/core/basetypes/MCValue.cpp @@ -135,6 +135,22 @@ Value * Value::valueWithUnsignedCharValue(unsigned char value) /////////////////////// +Value * Value::valueWithShortValue(short value) +{ + Value * result = new Value(); + result->mType = VALUE_TYPE_SHORT_VALUE; + result->mValue.shortValue = value; + return (Value *) result->autorelease(); +} + +Value * Value::valueWithUnsignedShortValue(unsigned short value) +{ + Value * result = new Value(); + result->mType = VALUE_TYPE_UNSIGNED_SHORT_VALUE; + result->mValue.unsignedShortValue = value; + return (Value *) result->autorelease(); +} + Value * Value::valueWithIntValue(int value) { Value * result = new Value(); diff --git a/src/core/basetypes/MCValue.h b/src/core/basetypes/MCValue.h index 41fb6918c..835cf6b6a 100644 --- a/src/core/basetypes/MCValue.h +++ b/src/core/basetypes/MCValue.h @@ -36,6 +36,8 @@ namespace mailcore { static Value * valueWithBoolValue(bool value); static Value * valueWithCharValue(char value); static Value * valueWithUnsignedCharValue(unsigned char value); + static Value * valueWithShortValue(short value); + static Value * valueWithUnsignedShortValue(unsigned short value); static Value * valueWithIntValue(int value); static Value * valueWithUnsignedIntValue(unsigned int value); static Value * valueWithLongValue(long value); diff --git a/src/objc/utils/NSValue+MCO.mm b/src/objc/utils/NSValue+MCO.mm index 9781534a4..d814dff19 100644 --- a/src/objc/utils/NSValue+MCO.mm +++ b/src/objc/utils/NSValue+MCO.mm @@ -72,6 +72,12 @@ + (NSNumber *) mco_valueWithMCValue:(mailcore::Value *)value else if (strcmp([self objCType], @encode(unsigned char)) == 0) { return mailcore::Value::valueWithUnsignedCharValue([nb unsignedCharValue]); } + else if (strcmp([self objCType], @encode(short)) == 0) { + return mailcore::Value::valueWithShortValue([nb shortValue]); + } + else if (strcmp([self objCType], @encode(unsigned short)) == 0) { + return mailcore::Value::valueWithUnsignedShortValue([nb unsignedShortValue]); + } else if (strcmp([self objCType], @encode(int)) == 0) { return mailcore::Value::valueWithIntValue([nb intValue]); }