diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-04-26 16:55:52 -0400 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-05-04 13:48:09 -0400 |
commit | 73fe7ac9d3380b8038294b5f7982033fb0cc4ea3 (patch) | |
tree | cc23121923b9eecfdd0aabc62f301720db4a5d8a | |
parent | a980f9c717151b30bf835d5a0c02edaf8b1ef94a (diff) | |
download | qtlocation-mapboxgl-73fe7ac9d3380b8038294b5f7982033fb0cc4ea3.tar.gz |
[ios, macos] Add multiple parameters support to to-color operand.
-rw-r--r-- | platform/darwin/src/NSExpression+MGLAdditions.mm | 9 | ||||
-rw-r--r-- | platform/darwin/test/MGLExpressionTests.mm | 5 |
2 files changed, 10 insertions, 4 deletions
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm index 4ef744e918..7a1d73f43a 100644 --- a/platform/darwin/src/NSExpression+MGLAdditions.mm +++ b/platform/darwin/src/NSExpression+MGLAdditions.mm @@ -804,11 +804,16 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { return [NSExpression expressionWithFormat:@"CAST(%@, 'NSString')", operand]; } else if ([op isEqualToString:@"to-color"]) { NSExpression *operand = [NSExpression expressionWithMGLJSONObject:argumentObjects.firstObject]; + + if (argumentObjects.count == 1) { #if TARGET_OS_IPHONE - return [NSExpression expressionWithFormat:@"CAST(%@, 'UIColor')", operand]; + return [NSExpression expressionWithFormat:@"CAST(%@, 'UIColor')", operand]; #else - return [NSExpression expressionWithFormat:@"CAST(%@, 'NSColor')", operand]; + return [NSExpression expressionWithFormat:@"CAST(%@, 'NSColor')", operand]; #endif + } + NSArray *subexpressions = MGLSubexpressionsWithJSONObjects(array); + return [NSExpression expressionForFunction:@"MGL_FUNCTION" arguments:subexpressions]; } else if ([op isEqualToString:@"to-rgba"]) { NSExpression *operand = [NSExpression expressionWithMGLJSONObject:argumentObjects.firstObject]; diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm index 531c326f31..4980599985 100644 --- a/platform/darwin/test/MGLExpressionTests.mm +++ b/platform/darwin/test/MGLExpressionTests.mm @@ -680,8 +680,8 @@ using namespace std::string_literals; XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression); } { - NSExpression *expression = [NSExpression expressionWithFormat:@"CAST(x, 'MGLColor')"]; - NSArray *jsonExpression = @[@"to-color", @[@"get", @"x"]]; + NSExpression *expression = [NSExpression expressionWithFormat:@"MGL_FUNCTION('to-color', x, y, z)"]; + NSArray *jsonExpression = @[@"to-color", @[@"get", @"x"], @[@"get", @"y"], @[@"get", @"z"]]; XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); } { @@ -690,6 +690,7 @@ using namespace std::string_literals; XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression); } + } - (void)testInterpolationExpressionObject { |