summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLStyleLayer.mm.ejs
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-07-17 12:21:50 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-07-20 12:35:00 -0700
commit2c5d0e74a1ef6743a23dbd346b79958e4b2f8614 (patch)
tree5dd56c0079294b6cebf2d26970bcb12852add27e /platform/darwin/src/MGLStyleLayer.mm.ejs
parentaf89318b1d3bef15e92e591887c9d65b10be54ce (diff)
downloadqtlocation-mapboxgl-2c5d0e74a1ef6743a23dbd346b79958e4b2f8614.tar.gz
[ios, macos] Convert token strings to expressions on input
Removes mgl_expressionByReplacingTokensWithKeyPaths and associated code. Converting on output is no longer necessary: from the prior commit, core converts token strings to expressions at parse time; all that's necessary is to ensure that the runtime styling API does so as well.
Diffstat (limited to 'platform/darwin/src/MGLStyleLayer.mm.ejs')
-rw-r--r--platform/darwin/src/MGLStyleLayer.mm.ejs20
1 files changed, 10 insertions, 10 deletions
diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs
index 1e760749e9..b37fbc04bf 100644
--- a/platform/darwin/src/MGLStyleLayer.mm.ejs
+++ b/platform/darwin/src/MGLStyleLayer.mm.ejs
@@ -121,6 +121,16 @@ namespace mbgl {
- (void)set<%- camelize(property.name) %>:(NSExpression *)<%- objCName(property) %> {
MGLAssertStyleLayerIsValid();
+<% if (property.tokens) { -%>
+ if (<%- objCName(property) %> && <%- objCName(property) %>.expressionType == NSConstantValueExpressionType) {
+ std::string string = ((NSString *)<%- objCName(property) %>.constantValue).UTF8String;
+ if (mbgl::style::conversion::hasTokens(string)) {
+ self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbgl::style::DataDrivenPropertyValue<std::string>(
+ mbgl::style::conversion::convertTokenStringToExpression(string)));
+ return;
+ }
+ }
+<% } -%>
<% if (isDataDriven(property)) { -%>
auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue<mbgl::style::DataDrivenPropertyValue<<%- valueTransformerArguments(property)[0] %>>>(<%- objCName(property) %>);
<% } else { -%>
@@ -136,12 +146,7 @@ namespace mbgl {
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>();
}
-<% if (property.type === 'string') { -%>
- NSExpression *expression = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toExpression(propertyValue);
- return expression.mgl_expressionByReplacingTokensWithKeyPaths;
-<% } else { -%>
return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toExpression(propertyValue);
-<% } -%>
}
<% if (property.original) { -%>
@@ -183,12 +188,7 @@ namespace mbgl {
if (propertyValue.isUndefined()) {
propertyValue = self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>();
}
-<% if (property.type === 'string') { -%>
- NSExpression *expression = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toExpression(propertyValue);
- return expression.mgl_expressionByReplacingTokensWithKeyPaths;
-<% } else { -%>
return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toExpression(propertyValue);
-<% } -%>
}
<% if (property["transition"]) { -%>