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

Commit

Permalink
[ios, macos] Special-case number conversion without fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Mar 8, 2018
1 parent 416732e commit 3e27fa5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions platform/darwin/src/NSExpression+MGLAdditions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,11 @@ + (instancetype)mgl_expressionWithJSONObject:(id)object {
NSExpression *operand = [NSExpression mgl_expressionWithJSONObject:argumentObjects.firstObject];
argumentObjects = [argumentObjects subarrayWithRange:NSMakeRange(1, argumentObjects.count - 1)];
NSArray *subexpressions = MGLSubexpressionsWithJSONObjects(argumentObjects);
return [NSExpression expressionForFunction:operand selectorName:@"mgl_numberWithFallbackValues:" arguments:subexpressions];
if (subexpressions.count == 0) {
return [NSExpression expressionForFunction:operand selectorName:@"mgl_number" arguments:@[]];
} else {
return [NSExpression expressionForFunction:operand selectorName:@"mgl_numberWithFallbackValues:" arguments:subexpressions];
}
} else if ([op isEqualToString:@"to-string"]) {
NSExpression *operand = [NSExpression mgl_expressionWithJSONObject:argumentObjects.firstObject];
return [NSExpression expressionForFunction:operand selectorName:@"stringValue" arguments:@[]];
Expand Down Expand Up @@ -616,7 +620,8 @@ - (id)mgl_jsonExpressionObject {
return [@[@"concat", self.operand.mgl_jsonExpressionObject] arrayByAddingObjectsFromArray:arguments];
} else if ([function isEqualToString:@"boolValue"]) {
return @[@"to-boolean", self.operand.mgl_jsonExpressionObject];
} else if ([function isEqualToString:@"mgl_numberWithFallbackValues:"] ||
} else if ([function isEqualToString:@"mgl_number"] ||
[function isEqualToString:@"mgl_numberWithFallbackValues:"] ||
[function isEqualToString:@"decimalValue"] ||
[function isEqualToString:@"floatValue"] ||
[function isEqualToString:@"doubleValue"]) {
Expand Down

0 comments on commit 3e27fa5

Please sign in to comment.