diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2017-01-16 11:38:35 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2017-01-16 11:38:35 -0800 |
commit | 7ef2843e6a62116667be6a2c12de085951fdd5ea (patch) | |
tree | 40eca249e044e2706efd1193d617e6eb8e59d708 /platform/darwin/src/MGLStyleLayer.mm.ejs | |
parent | 76301b252cbc4bc3ae1fc84322bcbcdbd26cae8a (diff) | |
parent | 13b97dd0cebffe36b187bdb74923910def6bd87b (diff) | |
download | qtlocation-mapboxgl-7ef2843e6a62116667be6a2c12de085951fdd5ea.tar.gz |
Merge branch 'release-ios-v3.4.0' into 1ec5-release-ios-v3.4.0-beta.7
Diffstat (limited to 'platform/darwin/src/MGLStyleLayer.mm.ejs')
-rw-r--r-- | platform/darwin/src/MGLStyleLayer.mm.ejs | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index baeed3b882..9445c3cf21 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -2,10 +2,10 @@ const type = locals.type; const layoutProperties = locals.layoutProperties; const paintProperties = locals.paintProperties; - const containsEnumerationProperties = locals.containsEnumerationProperties; + const enumProperties = locals.enumProperties; -%> // This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`. #import "MGLSource.h" #import "MGLMapView_Private.h" @@ -14,8 +14,10 @@ #import "MGLStyleValue_Private.h" #import "MGL<%- camelize(type) %>StyleLayer.h" +#include <mbgl/map/map.hpp> #include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp> -<% if (containsEnumerationProperties) { -%> +<% if (enumProperties) { -%> + namespace mbgl { <% if (layoutProperties.length) { -%> @@ -89,7 +91,15 @@ namespace mbgl { super.rawLayer = rawLayer; } -<% if (type !== 'background' && type !== 'raster') { -%> +<% if (type !== 'background') { -%> +- (NSString *)sourceIdentifier +{ + MGLAssertStyleLayerIsValid(); + + return @(self.rawLayer->getSourceID().c_str()); +} + +<% if (type !== 'raster') { -%> - (NSString *)sourceLayerIdentifier { MGLAssertStyleLayerIsValid(); @@ -109,7 +119,7 @@ namespace mbgl { { MGLAssertStyleLayerIsValid(); - self.rawLayer->setFilter(predicate.mgl_filter); + self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::NullFilter()); } - (NSPredicate *)predicate @@ -119,7 +129,7 @@ namespace mbgl { return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } -<% } -%> +<% }} -%> #pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer @@ -167,7 +177,7 @@ namespace mbgl { MGLAssertStyleLayerIsValid(); <% if (property.type == "enum") { -%> - auto mbglValue = MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer<<%- mbglType(property) %>, NSValue *, <%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); <% } else { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); @@ -180,15 +190,14 @@ namespace mbgl { auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>(); <% if (property.type == "enum") { -%> - return MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer<<%- mbglType(property) %>, NSValue *, <%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue); <% } else { -%> return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); <% } -%> } -<% if (property.original) { %> +<% if (property.original) { -%> - (void)set<%- camelize(originalPropertyName(property)) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> { - self.<%- camelizeWithLeadingLowercase(property.name) %> = <%- camelizeWithLeadingLowercase(originalPropertyName(property)) %>; } - (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> { @@ -206,7 +215,7 @@ namespace mbgl { MGLAssertStyleLayerIsValid(); <% if (property.type == "enum") { -%> - auto mbglValue = MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer<<%- mbglType(property) %>, NSValue *, <%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); <% } else { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); @@ -219,15 +228,18 @@ namespace mbgl { auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>(); <% if (property.type == "enum") { -%> - return MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer<<%- mbglType(property) %>, NSValue *, <%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue); <% } else { -%> return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); <% } -%> } -<% if (property.original) { %> +<% if (property.original) { -%> - (void)set<%- camelize(originalPropertyName(property)) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> { - NSAssert(NO, @"Use -set<%- camelize(property.name) %>: instead."); +} + +- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> { + return self.<%- objCGetter(property) %>; } <% } -%> @@ -235,3 +247,21 @@ namespace mbgl { <% } -%> @end +<% if (enumProperties) { -%> + +@implementation NSValue (MGL<%- camelize(type) %>StyleLayerAdditions) + +<% for (let property of enumProperties) { -%> ++ (NSValue *)valueWithMGL<%- camelize(property.name) %>:(MGL<%- camelize(property.name) %>)<%- objCName(property) %> { + return [NSValue value:&<%- objCName(property) %> withObjCType:@encode(MGL<%- camelize(property.name) %>)]; +} + +- (MGL<%- camelize(property.name) %>)MGL<%- camelize(property.name) %>Value { + MGL<%- camelize(property.name) %> <%- objCName(property) %>; + [self getValue:&<%- objCName(property) %>]; + return <%- objCName(property) %>; +} + +<% } -%> +@end +<% } -%> |