Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
refs #6248: handle all NSNumber types
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Sep 8, 2016
1 parent 8edf995 commit 22b6618
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions platform/darwin/src/NSExpression+MGLAdditions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,37 @@ @implementation NSExpression (MGLAdditions)
return { std::string([(NSString *)value UTF8String]) };
} else if ([value isKindOfClass:NSNumber.class]) {
NSNumber *number = (NSNumber *)value;
if((strcmp([number objCType], @encode(int))) == 0) {
// handle all types defined in NSNumber designated initializers
if (strcmp([number objCType], @encode(char)) == 0) {
return { number.charValue };
} else if (strcmp([number objCType], @encode(unsigned char)) == 0) {
return { number.unsignedCharValue };
} else if (strcmp([number objCType], @encode(short)) == 0) {
return { number.shortValue };
} else if (strcmp([number objCType], @encode(unsigned short)) == 0) {
return { number.unsignedShortValue };
} else if (strcmp([number objCType], @encode(int)) == 0) {
return { number.intValue };
} else if ((strcmp([number objCType], @encode(double))) == 0) {
} else if (strcmp([number objCType], @encode(unsigned int)) == 0) {
return { number.unsignedIntValue };
} else if (strcmp([number objCType], @encode(long)) == 0) {
return { number.longValue };
} else if (strcmp([number objCType], @encode(unsigned long)) == 0) {
return { number.unsignedLongValue };
} else if (strcmp([number objCType], @encode(long long)) == 0) {
return { number.longLongValue };
} else if (strcmp([number objCType], @encode(unsigned long long)) == 0) {
return { number.unsignedLongLongValue };
} else if (strcmp([number objCType], @encode(float)) == 0) {
return { number.floatValue };
} else if (strcmp([number objCType], @encode(double)) == 0) {
return { number.doubleValue };
} else if ((strcmp([number objCType], @encode(char))) == 0) {
} else if (strcmp([number objCType], @encode(bool)) == 0) {
return { number.boolValue };
} else if (strcmp([number objCType], @encode(NSInteger)) == 0) {
return { number.integerValue };
} else if (strcmp([number objCType], @encode(NSUInteger)) == 0) {
return { number.unsignedIntegerValue };
}
}
[NSException raise:@"Value not handled"
Expand Down

0 comments on commit 22b6618

Please sign in to comment.