Skip to content

Commit

Permalink
Support for short values
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhvh committed Dec 14, 2014
1 parent ec89707 commit 5fa1017
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/basetypes/MCValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/core/basetypes/MCValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/objc/utils/NSValue+MCO.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down

0 comments on commit 5fa1017

Please sign in to comment.