From 9652028915af6602626939e0b0075333c34bfbfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 25 Sep 2016 12:37:45 -0700 Subject: [ios, macos] Expand changes to entire API --- platform/darwin/scripts/generate-style-code.js | 141 +++--- platform/darwin/src/MGLBackgroundStyleLayer.h | 16 +- platform/darwin/src/MGLBackgroundStyleLayer.mm | 32 +- platform/darwin/src/MGLCircleStyleLayer.h | 34 +- platform/darwin/src/MGLCircleStyleLayer.mm | 72 +-- platform/darwin/src/MGLFillStyleLayer.h | 32 +- platform/darwin/src/MGLFillStyleLayer.mm | 72 +-- platform/darwin/src/MGLLineStyleLayer.h | 63 ++- platform/darwin/src/MGLLineStyleLayer.mm | 134 +++--- platform/darwin/src/MGLRasterStyleLayer.h | 30 +- platform/darwin/src/MGLRasterStyleLayer.mm | 72 +-- platform/darwin/src/MGLStyleAttribute.h | 25 -- platform/darwin/src/MGLStyleAttribute.mm | 112 ----- platform/darwin/src/MGLStyleAttributeFunction.h | 47 -- platform/darwin/src/MGLStyleAttributeFunction.mm | 309 ------------- .../darwin/src/MGLStyleAttributeFunction_Private.h | 220 ---------- platform/darwin/src/MGLStyleAttributeValue.h | 5 - .../darwin/src/MGLStyleAttributeValue_Private.h | 24 - platform/darwin/src/MGLStyleLayer.h.ejs | 6 +- platform/darwin/src/MGLStyleLayer.mm.ejs | 22 +- platform/darwin/src/MGLStyleLayer_Private.h | 18 +- platform/darwin/src/MGLStyleValue.h | 32 ++ platform/darwin/src/MGLStyleValue.mm | 71 +++ platform/darwin/src/MGLStyleValue_Private.h | 150 +++++++ platform/darwin/src/MGLSymbolStyleLayer.h | 218 +++++----- platform/darwin/src/MGLSymbolStyleLayer.mm | 482 ++++++++++++--------- .../src/NSArray+MGLStyleAttributeAdditions.h | 7 - .../src/NSArray+MGLStyleAttributeAdditions.mm | 36 -- .../NSArray+MGLStyleAttributeAdditions_Private.h | 9 - .../src/NSColor+MGLStyleAttributeAdditions.h | 7 - .../src/NSColor+MGLStyleAttributeAdditions.m | 5 - .../NSColor+MGLStyleAttributeAdditions_Private.h | 9 - .../src/NSNumber+MGLStyleAttributeAdditions.h | 7 - .../src/NSNumber+MGLStyleAttributeAdditions.mm | 22 - .../NSNumber+MGLStyleAttributeAdditions_Private.h | 13 - .../src/NSString+MGLStyleAttributeAdditions.h | 7 - .../src/NSString+MGLStyleAttributeAdditions.mm | 17 - .../NSString+MGLStyleAttributeAdditions_Private.h | 11 - .../src/NSValue+MGLStyleAttributeAdditions.h | 10 +- .../src/NSValue+MGLStyleAttributeAdditions.mm | 19 - .../NSValue+MGLStyleAttributeAdditions_Private.h | 15 - .../UIColor+MGLStyleAttributeAdditions_Private.h | 9 - platform/darwin/test/MGLCircleStyleLayerTests.m | 6 +- platform/darwin/test/MGLFillStyleLayerTests.m | 3 +- platform/darwin/test/MGLLineStyleLayerTests.m | 9 +- platform/darwin/test/MGLRuntimeStylingHelper.h | 38 +- platform/darwin/test/MGLRuntimeStylingHelper.m | 120 ++--- platform/darwin/test/MGLSymbolStyleLayerTests.m | 30 +- 48 files changed, 1153 insertions(+), 1695 deletions(-) delete mode 100644 platform/darwin/src/MGLStyleAttribute.h delete mode 100644 platform/darwin/src/MGLStyleAttribute.mm delete mode 100644 platform/darwin/src/MGLStyleAttributeFunction.h delete mode 100644 platform/darwin/src/MGLStyleAttributeFunction.mm delete mode 100644 platform/darwin/src/MGLStyleAttributeFunction_Private.h delete mode 100644 platform/darwin/src/MGLStyleAttributeValue.h delete mode 100644 platform/darwin/src/MGLStyleAttributeValue_Private.h create mode 100644 platform/darwin/src/MGLStyleValue.h create mode 100644 platform/darwin/src/MGLStyleValue.mm create mode 100644 platform/darwin/src/MGLStyleValue_Private.h delete mode 100644 platform/darwin/src/NSArray+MGLStyleAttributeAdditions.h delete mode 100644 platform/darwin/src/NSArray+MGLStyleAttributeAdditions.mm delete mode 100644 platform/darwin/src/NSArray+MGLStyleAttributeAdditions_Private.h delete mode 100644 platform/darwin/src/NSColor+MGLStyleAttributeAdditions.h delete mode 100644 platform/darwin/src/NSColor+MGLStyleAttributeAdditions.m delete mode 100644 platform/darwin/src/NSColor+MGLStyleAttributeAdditions_Private.h delete mode 100644 platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.h delete mode 100644 platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.mm delete mode 100644 platform/darwin/src/NSNumber+MGLStyleAttributeAdditions_Private.h delete mode 100644 platform/darwin/src/NSString+MGLStyleAttributeAdditions.h delete mode 100644 platform/darwin/src/NSString+MGLStyleAttributeAdditions.mm delete mode 100644 platform/darwin/src/NSString+MGLStyleAttributeAdditions_Private.h delete mode 100644 platform/darwin/src/NSValue+MGLStyleAttributeAdditions_Private.h delete mode 100644 platform/darwin/src/UIColor+MGLStyleAttributeAdditions_Private.h (limited to 'platform/darwin') diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index 0c8b704e91..4bcfe54d32 100644 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -44,7 +44,8 @@ global.testGetterImplementation = function (property, layerType, isFunction) { if (isFunction) { return `XCTAssertEqualObjects(gLayer.${objCName(property)}, ${value});`; } - return `XCTAssert([(NSValue *)gLayer.${objCName(property)} isEqualToValue:${value}], @"%@ is not equal to %@", gLayer.${objCName(property)}, ${value});`; + return `XCTAssert([gLayer.${objCName(property)} isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.${objCName(property)}, ${value});`; } return `XCTAssertEqualObjects(gLayer.${objCName(property)}, ${value});`; } @@ -129,7 +130,7 @@ global.propertyReqs = function (property, layoutPropertiesByName, type) { return '`' + camelizeWithLeadingLowercase(req['!']) + '` is set to `nil`'; } else { let name = Object.keys(req)[0]; - return '`' + camelizeWithLeadingLowercase(name) + '` is set to ' + describeValue(req[name], layoutPropertiesByName[name], type); + return '`' + camelizeWithLeadingLowercase(name) + '` is set to an `MGLStyleValue` object containing ' + describeValue(req[name], layoutPropertiesByName[name], type); } }).join(', and ') + '. Otherwise, it is ignored.'; }; @@ -204,109 +205,93 @@ global.describeValue = function (value, property, layerType) { }; global.propertyDefault = function (property, layerType) { - return describeValue(property.default, property, layerType); + return 'an `MGLStyleValue` object containing ' + describeValue(property.default, property, layerType); }; -global.propertyType = function (property, _private) { - return _private ? `id ` : `id `; -}; - -global.initLayer = function (layerType) { - if (layerType == "background") { - return `_layer = new mbgl::style::${camelize(layerType)}Layer(identifier.UTF8String);` - } else { - return `_layer = new mbgl::style::${camelize(layerType)}Layer(identifier.UTF8String, source.identifier.UTF8String);` - } -} - -global.setSourceLayer = function() { - return `_layer->setSourceLayer(sourceLayer.UTF8String);` -} - -global.setterImplementation = function(property, layerType) { - let implementation = ''; +global.propertyType = function (property) { switch (property.type) { case 'boolean': - implementation = `self.layer->set${camelize(property.name)}(${objCName(property)}.mbgl_boolPropertyValue);`; - break; + return 'NSNumber *'; case 'number': - implementation = `self.layer->set${camelize(property.name)}(${objCName(property)}.mbgl_floatPropertyValue);`; - break; + return 'NSNumber *'; case 'string': - implementation = `self.layer->set${camelize(property.name)}(${objCName(property)}.mbgl_stringPropertyValue);`; - break; + return 'NSString *'; case 'enum': - let objCType = global.objCType(layerType, property.name); - implementation = `MGLSetEnumProperty(${objCName(property)}, ${camelize(property.name)}, ${mbglType(property)}, ${objCType});`; - break; + return 'NSValue *'; case 'color': - implementation = `self.layer->set${camelize(property.name)}(${objCName(property)}.mbgl_colorPropertyValue);`; - break; + return 'MGLColor *'; case 'array': - implementation = arraySetterImplementation(property); - break; - default: throw new Error(`unknown type for ${property.name}`) - } - return implementation; -} - -global.mbglType = function(property) { - let mbglType = camelize(property.name) + 'Type'; - if (/-translate-anchor$/.test(property.name)) { - mbglType = 'TranslateAnchorType'; - } - if (/-(rotation|pitch)-alignment$/.test(property.name)) { - mbglType = 'AlignmentType'; + switch (arrayType(property)) { + case 'dasharray': + return 'NSArray *'; + case 'font': + return 'NSArray *'; + case 'padding': + return 'NSValue *'; + case 'offset': + case 'translate': + return 'NSValue *'; + default: + throw new Error(`unknown array type for ${property.name}`); + } + default: + throw new Error(`unknown type for ${property.name}`); } - return mbglType; -} - -global.arraySetterImplementation = function(property) { - return `self.layer->set${camelize(property.name)}(${objCName(property)}.mbgl_${convertedType(property)}PropertyValue);`; -} +}; -global.styleAttributeFactory = function (property, layerType) { +global.valueTransformerArguments = function (property) { + let objCType = propertyType(property); switch (property.type) { case 'boolean': - return 'mbgl_boolWithPropertyValueBool'; + return ['bool', objCType]; case 'number': - return 'mbgl_numberWithPropertyValueNumber'; + return ['float', objCType]; case 'string': - return 'mbgl_stringWithPropertyValueString'; + return ['std::string', objCType]; case 'enum': - throw new Error('Use MGLGetEnumProperty() for enums.'); + return [`mbgl::style::${mbglType(property)}`, objCType]; case 'color': - return 'mbgl_colorWithPropertyValueColor'; + return ['mbgl::Color', objCType]; case 'array': - return `mbgl_${convertedType(property)}WithPropertyValue${camelize(convertedType(property))}`; + switch (arrayType(property)) { + case 'dasharray': + return ['std::vector', objCType, 'float']; + case 'font': + return ['std::vector', objCType, 'std::string']; + case 'padding': + return ['std::array', objCType]; + case 'offset': + case 'translate': + return ['std::array', objCType]; + default: + throw new Error(`unknown array type for ${property.name}`); + } default: throw new Error(`unknown type for ${property.name}`); } }; -global.getterImplementation = function(property, layerType) { - if (property.type === 'enum') { - let objCType = global.objCType(layerType, property.name); - return `MGLGetEnumProperty(${camelize(property.name)}, ${mbglType(property)}, ${objCType});`; +global.initLayer = function (layerType) { + if (layerType == "background") { + return `_layer = new mbgl::style::${camelize(layerType)}Layer(identifier.UTF8String);` + } else { + return `_layer = new mbgl::style::${camelize(layerType)}Layer(identifier.UTF8String, source.identifier.UTF8String);` } - let rawValue = `self.layer->get${camelize(property.name)}() ?: self.layer->getDefault${camelize(property.name)}()`; - return `return [MGLStyleAttribute ${styleAttributeFactory(property, layerType)}:${rawValue}];`; } -global.convertedType = function(property) { - switch (arrayType(property)) { - case 'dasharray': - return 'numberArray'; - case 'font': - return 'stringArray'; - case 'padding': - return 'padding'; - case 'offset': - case 'translate': - return 'offset'; - default: - throw new Error(`unknown array type for ${property.name}`); +global.setSourceLayer = function() { + return `_layer->setSourceLayer(sourceLayer.UTF8String);` +} + +global.mbglType = function(property) { + let mbglType = camelize(property.name) + 'Type'; + if (/-translate-anchor$/.test(property.name)) { + mbglType = 'TranslateAnchorType'; } + if (/-(rotation|pitch)-alignment$/.test(property.name)) { + mbglType = 'AlignmentType'; + } + return mbglType; } const layerH = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.h.ejs', 'utf8'), { strict: true }); diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.h b/platform/darwin/src/MGLBackgroundStyleLayer.h index 1a4c64dedf..1c167fc91c 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.h +++ b/platform/darwin/src/MGLBackgroundStyleLayer.h @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue.h" #import "MGLStyleLayer.h" NS_ASSUME_NONNULL_BEGIN @@ -22,33 +22,33 @@ NS_ASSUME_NONNULL_BEGIN /** The color with which the background will be drawn. - The default value of this property is `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `backgroundPattern` is set to `nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id backgroundColor; +@property (nonatomic, null_resettable) MGLStyleValue *backgroundColor; #else /** The color with which the background will be drawn. - The default value of this property is `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `backgroundPattern` is set to `nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id backgroundColor; +@property (nonatomic, null_resettable) MGLStyleValue *backgroundColor; #endif /** Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). */ -@property (nonatomic, null_resettable) id backgroundPattern; +@property (nonatomic, null_resettable) MGLStyleValue *backgroundPattern; /** The opacity at which the background will be drawn. - The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id backgroundOpacity; +@property (nonatomic, null_resettable) MGLStyleValue *backgroundOpacity; @end diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index 032aa196ee..33a105e5d5 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -4,7 +4,7 @@ #import "MGLSource.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue_Private.h" #import "MGLBackgroundStyleLayer.h" #include @@ -27,28 +27,34 @@ #pragma mark - Accessing the Paint Attributes -- (void)setBackgroundColor:(id )backgroundColor { - self.layer->setBackgroundColor(backgroundColor.mbgl_colorPropertyValue); +- (void)setBackgroundColor:(MGLStyleValue *)backgroundColor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(backgroundColor); + self.layer->setBackgroundColor(mbglValue); } -- (id )backgroundColor { - return [MGLStyleAttribute mbgl_colorWithPropertyValueColor:self.layer->getBackgroundColor() ?: self.layer->getDefaultBackgroundColor()]; +- (MGLStyleValue *)backgroundColor { + auto propertyValue = self.layer->getBackgroundColor() ?: self.layer->getDefaultBackgroundColor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setBackgroundPattern:(id )backgroundPattern { - self.layer->setBackgroundPattern(backgroundPattern.mbgl_stringPropertyValue); +- (void)setBackgroundPattern:(MGLStyleValue *)backgroundPattern { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(backgroundPattern); + self.layer->setBackgroundPattern(mbglValue); } -- (id )backgroundPattern { - return [MGLStyleAttribute mbgl_stringWithPropertyValueString:self.layer->getBackgroundPattern() ?: self.layer->getDefaultBackgroundPattern()]; +- (MGLStyleValue *)backgroundPattern { + auto propertyValue = self.layer->getBackgroundPattern() ?: self.layer->getDefaultBackgroundPattern(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setBackgroundOpacity:(id )backgroundOpacity { - self.layer->setBackgroundOpacity(backgroundOpacity.mbgl_floatPropertyValue); +- (void)setBackgroundOpacity:(MGLStyleValue *)backgroundOpacity { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(backgroundOpacity); + self.layer->setBackgroundOpacity(mbglValue); } -- (id )backgroundOpacity { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getBackgroundOpacity() ?: self.layer->getDefaultBackgroundOpacity()]; +- (MGLStyleValue *)backgroundOpacity { + auto propertyValue = self.layer->getBackgroundOpacity() ?: self.layer->getDefaultBackgroundOpacity(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } @end diff --git a/platform/darwin/src/MGLCircleStyleLayer.h b/platform/darwin/src/MGLCircleStyleLayer.h index 9a45f7280c..6006250cdf 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.h +++ b/platform/darwin/src/MGLCircleStyleLayer.h @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue.h" #import "MGLVectorStyleLayer.h" NS_ASSUME_NONNULL_BEGIN @@ -53,64 +53,64 @@ typedef NS_ENUM(NSUInteger, MGLCirclePitchScale) { This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `5`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `5`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id circleRadius; +@property (nonatomic, null_resettable) MGLStyleValue *circleRadius; #if TARGET_OS_IPHONE /** The fill color of the circle. - The default value of this property is `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id circleColor; +@property (nonatomic, null_resettable) MGLStyleValue *circleColor; #else /** The fill color of the circle. - The default value of this property is `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id circleColor; +@property (nonatomic, null_resettable) MGLStyleValue *circleColor; #endif /** Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id circleBlur; +@property (nonatomic, null_resettable) MGLStyleValue *circleBlur; /** The opacity at which the circle will be drawn. - The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id circleOpacity; +@property (nonatomic, null_resettable) MGLStyleValue *circleOpacity; /** The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. This property is measured in points. - The default value of this property is an `NSValue` object containing a `CGVector` struct set to 0 points from the left and 0 points from the top. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing a `CGVector` struct set to 0 points from the left and 0 points from the top. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id circleTranslate; +@property (nonatomic, null_resettable) MGLStyleValue *circleTranslate; /** Controls the translation reference point. - The default value of this property is an `NSValue` object containing `MGLCircleTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLCircleTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `circleTranslate` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id circleTranslateAnchor; +@property (nonatomic, null_resettable) MGLStyleValue *circleTranslateAnchor; /** Controls the scaling behavior of the circle when the map is pitched. - The default value of this property is an `NSValue` object containing `MGLCirclePitchScaleMap`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLCirclePitchScaleMap`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id circlePitchScale; +@property (nonatomic, null_resettable) MGLStyleValue *circlePitchScale; @end diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index 31fa795d54..8fe97a0537 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -4,7 +4,7 @@ #import "MGLSource.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue_Private.h" #import "MGLCircleStyleLayer.h" #include @@ -48,60 +48,74 @@ #pragma mark - Accessing the Paint Attributes -- (void)setCircleRadius:(id )circleRadius { - self.layer->setCircleRadius(circleRadius.mbgl_floatPropertyValue); +- (void)setCircleRadius:(MGLStyleValue *)circleRadius { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleRadius); + self.layer->setCircleRadius(mbglValue); } -- (id )circleRadius { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getCircleRadius() ?: self.layer->getDefaultCircleRadius()]; +- (MGLStyleValue *)circleRadius { + auto propertyValue = self.layer->getCircleRadius() ?: self.layer->getDefaultCircleRadius(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setCircleColor:(id )circleColor { - self.layer->setCircleColor(circleColor.mbgl_colorPropertyValue); +- (void)setCircleColor:(MGLStyleValue *)circleColor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleColor); + self.layer->setCircleColor(mbglValue); } -- (id )circleColor { - return [MGLStyleAttribute mbgl_colorWithPropertyValueColor:self.layer->getCircleColor() ?: self.layer->getDefaultCircleColor()]; +- (MGLStyleValue *)circleColor { + auto propertyValue = self.layer->getCircleColor() ?: self.layer->getDefaultCircleColor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setCircleBlur:(id )circleBlur { - self.layer->setCircleBlur(circleBlur.mbgl_floatPropertyValue); +- (void)setCircleBlur:(MGLStyleValue *)circleBlur { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleBlur); + self.layer->setCircleBlur(mbglValue); } -- (id )circleBlur { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getCircleBlur() ?: self.layer->getDefaultCircleBlur()]; +- (MGLStyleValue *)circleBlur { + auto propertyValue = self.layer->getCircleBlur() ?: self.layer->getDefaultCircleBlur(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setCircleOpacity:(id )circleOpacity { - self.layer->setCircleOpacity(circleOpacity.mbgl_floatPropertyValue); +- (void)setCircleOpacity:(MGLStyleValue *)circleOpacity { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleOpacity); + self.layer->setCircleOpacity(mbglValue); } -- (id )circleOpacity { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getCircleOpacity() ?: self.layer->getDefaultCircleOpacity()]; +- (MGLStyleValue *)circleOpacity { + auto propertyValue = self.layer->getCircleOpacity() ?: self.layer->getDefaultCircleOpacity(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setCircleTranslate:(id )circleTranslate { - self.layer->setCircleTranslate(circleTranslate.mbgl_offsetPropertyValue); +- (void)setCircleTranslate:(MGLStyleValue *)circleTranslate { + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(circleTranslate); + self.layer->setCircleTranslate(mbglValue); } -- (id )circleTranslate { - return [MGLStyleAttribute mbgl_offsetWithPropertyValueOffset:self.layer->getCircleTranslate() ?: self.layer->getDefaultCircleTranslate()]; +- (MGLStyleValue *)circleTranslate { + auto propertyValue = self.layer->getCircleTranslate() ?: self.layer->getDefaultCircleTranslate(); + return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } -- (void)setCircleTranslateAnchor:(id )circleTranslateAnchor { - MGLSetEnumProperty(circleTranslateAnchor, CircleTranslateAnchor, TranslateAnchorType, MGLCircleTranslateAnchor); +- (void)setCircleTranslateAnchor:(MGLStyleValue *)circleTranslateAnchor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleTranslateAnchor); + self.layer->setCircleTranslateAnchor(mbglValue); } -- (id )circleTranslateAnchor { - MGLGetEnumProperty(CircleTranslateAnchor, TranslateAnchorType, MGLCircleTranslateAnchor); +- (MGLStyleValue *)circleTranslateAnchor { + auto propertyValue = self.layer->getCircleTranslateAnchor() ?: self.layer->getDefaultCircleTranslateAnchor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setCirclePitchScale:(id )circlePitchScale { - MGLSetEnumProperty(circlePitchScale, CirclePitchScale, CirclePitchScaleType, MGLCirclePitchScale); +- (void)setCirclePitchScale:(MGLStyleValue *)circlePitchScale { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circlePitchScale); + self.layer->setCirclePitchScale(mbglValue); } -- (id )circlePitchScale { - MGLGetEnumProperty(CirclePitchScale, CirclePitchScaleType, MGLCirclePitchScale); +- (MGLStyleValue *)circlePitchScale { + auto propertyValue = self.layer->getCirclePitchScale() ?: self.layer->getDefaultCirclePitchScale(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } @end diff --git a/platform/darwin/src/MGLFillStyleLayer.h b/platform/darwin/src/MGLFillStyleLayer.h index d9ce1abace..712bfea998 100644 --- a/platform/darwin/src/MGLFillStyleLayer.h +++ b/platform/darwin/src/MGLFillStyleLayer.h @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue.h" #import "MGLVectorStyleLayer.h" NS_ASSUME_NONNULL_BEGIN @@ -35,66 +35,66 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslateAnchor) { /** Whether or not the fill should be antialiased. - The default value of this property is an `NSNumber` object containing `YES`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `YES`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id fillAntialias; +@property (nonatomic, null_resettable) MGLStyleValue *fillAntialias; /** The opacity of the entire fill layer. In contrast to the `fillColor`, this value will also affect the 1pt stroke around the fill, if the stroke is used. - The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id fillOpacity; +@property (nonatomic, null_resettable) MGLStyleValue *fillOpacity; #if TARGET_OS_IPHONE /** The color of the filled part of this layer. This color can be specified as `rgba` with an alpha component and the color's opacity will not affect the opacity of the 1pt stroke, if it is used. - The default value of this property is `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `fillPattern` is set to `nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id fillColor; +@property (nonatomic, null_resettable) MGLStyleValue *fillColor; #else /** The color of the filled part of this layer. This color can be specified as `rgba` with an alpha component and the color's opacity will not affect the opacity of the 1pt stroke, if it is used. - The default value of this property is `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `fillPattern` is set to `nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id fillColor; +@property (nonatomic, null_resettable) MGLStyleValue *fillColor; #endif /** The outline color of the fill. Matches the value of `fillColor` if unspecified. - This property is only applied to the style if `fillPattern` is set to `nil`, and `fillAntialias` is set to an `NSNumber` object containing `YES`. Otherwise, it is ignored. + This property is only applied to the style if `fillPattern` is set to `nil`, and `fillAntialias` is set to an `MGLStyleValue` object containing an `NSNumber` object containing `YES`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id fillOutlineColor; +@property (nonatomic, null_resettable) MGLStyleValue *fillOutlineColor; /** The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. This property is measured in points. - The default value of this property is an `NSValue` object containing a `CGVector` struct set to 0 points from the left and 0 points from the top. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing a `CGVector` struct set to 0 points from the left and 0 points from the top. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id fillTranslate; +@property (nonatomic, null_resettable) MGLStyleValue *fillTranslate; /** Controls the translation reference point. - The default value of this property is an `NSValue` object containing `MGLFillTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLFillTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `fillTranslate` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id fillTranslateAnchor; +@property (nonatomic, null_resettable) MGLStyleValue *fillTranslateAnchor; /** Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). */ -@property (nonatomic, null_resettable) id fillPattern; +@property (nonatomic, null_resettable) MGLStyleValue *fillPattern; @end diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index a2320f4fda..e16e3b2652 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -4,7 +4,7 @@ #import "MGLSource.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue_Private.h" #import "MGLFillStyleLayer.h" #include @@ -48,60 +48,74 @@ #pragma mark - Accessing the Paint Attributes -- (void)setFillAntialias:(id )fillAntialias { - self.layer->setFillAntialias(fillAntialias.mbgl_boolPropertyValue); +- (void)setFillAntialias:(MGLStyleValue *)fillAntialias { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillAntialias); + self.layer->setFillAntialias(mbglValue); } -- (id )fillAntialias { - return [MGLStyleAttribute mbgl_boolWithPropertyValueBool:self.layer->getFillAntialias() ?: self.layer->getDefaultFillAntialias()]; +- (MGLStyleValue *)fillAntialias { + auto propertyValue = self.layer->getFillAntialias() ?: self.layer->getDefaultFillAntialias(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setFillOpacity:(id )fillOpacity { - self.layer->setFillOpacity(fillOpacity.mbgl_floatPropertyValue); +- (void)setFillOpacity:(MGLStyleValue *)fillOpacity { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillOpacity); + self.layer->setFillOpacity(mbglValue); } -- (id )fillOpacity { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getFillOpacity() ?: self.layer->getDefaultFillOpacity()]; +- (MGLStyleValue *)fillOpacity { + auto propertyValue = self.layer->getFillOpacity() ?: self.layer->getDefaultFillOpacity(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setFillColor:(id )fillColor { - self.layer->setFillColor(fillColor.mbgl_colorPropertyValue); +- (void)setFillColor:(MGLStyleValue *)fillColor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillColor); + self.layer->setFillColor(mbglValue); } -- (id )fillColor { - return [MGLStyleAttribute mbgl_colorWithPropertyValueColor:self.layer->getFillColor() ?: self.layer->getDefaultFillColor()]; +- (MGLStyleValue *)fillColor { + auto propertyValue = self.layer->getFillColor() ?: self.layer->getDefaultFillColor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setFillOutlineColor:(id )fillOutlineColor { - self.layer->setFillOutlineColor(fillOutlineColor.mbgl_colorPropertyValue); +- (void)setFillOutlineColor:(MGLStyleValue *)fillOutlineColor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillOutlineColor); + self.layer->setFillOutlineColor(mbglValue); } -- (id )fillOutlineColor { - return [MGLStyleAttribute mbgl_colorWithPropertyValueColor:self.layer->getFillOutlineColor() ?: self.layer->getDefaultFillOutlineColor()]; +- (MGLStyleValue *)fillOutlineColor { + auto propertyValue = self.layer->getFillOutlineColor() ?: self.layer->getDefaultFillOutlineColor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setFillTranslate:(id )fillTranslate { - self.layer->setFillTranslate(fillTranslate.mbgl_offsetPropertyValue); +- (void)setFillTranslate:(MGLStyleValue *)fillTranslate { + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(fillTranslate); + self.layer->setFillTranslate(mbglValue); } -- (id )fillTranslate { - return [MGLStyleAttribute mbgl_offsetWithPropertyValueOffset:self.layer->getFillTranslate() ?: self.layer->getDefaultFillTranslate()]; +- (MGLStyleValue *)fillTranslate { + auto propertyValue = self.layer->getFillTranslate() ?: self.layer->getDefaultFillTranslate(); + return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } -- (void)setFillTranslateAnchor:(id )fillTranslateAnchor { - MGLSetEnumProperty(fillTranslateAnchor, FillTranslateAnchor, TranslateAnchorType, MGLFillTranslateAnchor); +- (void)setFillTranslateAnchor:(MGLStyleValue *)fillTranslateAnchor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillTranslateAnchor); + self.layer->setFillTranslateAnchor(mbglValue); } -- (id )fillTranslateAnchor { - MGLGetEnumProperty(FillTranslateAnchor, TranslateAnchorType, MGLFillTranslateAnchor); +- (MGLStyleValue *)fillTranslateAnchor { + auto propertyValue = self.layer->getFillTranslateAnchor() ?: self.layer->getDefaultFillTranslateAnchor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setFillPattern:(id )fillPattern { - self.layer->setFillPattern(fillPattern.mbgl_stringPropertyValue); +- (void)setFillPattern:(MGLStyleValue *)fillPattern { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillPattern); + self.layer->setFillPattern(mbglValue); } -- (id )fillPattern { - return [MGLStyleAttribute mbgl_stringWithPropertyValueString:self.layer->getFillPattern() ?: self.layer->getDefaultFillPattern()]; +- (MGLStyleValue *)fillPattern { + auto propertyValue = self.layer->getFillPattern() ?: self.layer->getDefaultFillPattern(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } @end diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h index cee33e1388..663e927718 100644 --- a/platform/darwin/src/MGLLineStyleLayer.h +++ b/platform/darwin/src/MGLLineStyleLayer.h @@ -1,9 +1,8 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue.h" #import "MGLVectorStyleLayer.h" -#import "MGLStyleAttributeFunction.h" NS_ASSUME_NONNULL_BEGIN @@ -76,62 +75,62 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslateAnchor) { /** The display of line endings. - The default value of this property is an `NSValue` object containing `MGLLineCapButt`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLLineCapButt`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id lineCap; +@property (nonatomic, null_resettable) MGLStyleValue *lineCap; /** The display of lines when joining. - The default value of this property is an `NSValue` object containing `MGLLineJoinMiter`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLLineJoinMiter`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) MGLStyleValue *lineJoin; +@property (nonatomic, null_resettable) MGLStyleValue *lineJoin; /** Used to automatically convert miter joins to bevel joins for sharp angles. - The default value of this property is an `NSNumber` object containing the float `2`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `2`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `lineJoin` is set to an `NSValue` object containing `MGLLineJoinMiter`. Otherwise, it is ignored. + This property is only applied to the style if `lineJoin` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLLineJoinMiter`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) MGLStyleValue *lineMiterLimit; +@property (nonatomic, null_resettable) MGLStyleValue *lineMiterLimit; /** Used to automatically convert round joins to miter joins for shallow angles. - The default value of this property is an `NSNumber` object containing the float `1.05`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1.05`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `lineJoin` is set to an `NSValue` object containing `MGLLineJoinRound`. Otherwise, it is ignored. + This property is only applied to the style if `lineJoin` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLLineJoinRound`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id lineRoundLimit; +@property (nonatomic, null_resettable) MGLStyleValue *lineRoundLimit; #pragma mark - Accessing the Paint Attributes /** The opacity at which the line will be drawn. - The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id lineOpacity; +@property (nonatomic, null_resettable) MGLStyleValue *lineOpacity; #if TARGET_OS_IPHONE /** The color with which the line will be drawn. - The default value of this property is `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `linePattern` is set to `nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id lineColor; +@property (nonatomic, null_resettable) MGLStyleValue *lineColor; #else /** The color with which the line will be drawn. - The default value of this property is `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `linePattern` is set to `nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id lineColor; +@property (nonatomic, null_resettable) MGLStyleValue *lineColor; #endif /** @@ -139,54 +138,54 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslateAnchor) { This property is measured in points. - The default value of this property is an `NSValue` object containing a `CGVector` struct set to 0 points from the left and 0 points from the top. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing a `CGVector` struct set to 0 points from the left and 0 points from the top. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id lineTranslate; +@property (nonatomic, null_resettable) MGLStyleValue *lineTranslate; /** Controls the translation reference point. - The default value of this property is an `NSValue` object containing `MGLLineTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLLineTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `lineTranslate` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id lineTranslateAnchor; +@property (nonatomic, null_resettable) MGLStyleValue *lineTranslateAnchor; /** Stroke thickness. This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id lineWidth; +@property (nonatomic, null_resettable) MGLStyleValue *lineWidth; /** Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap. This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id lineGapWidth; +@property (nonatomic, null_resettable) MGLStyleValue *lineGapWidth; /** The line's offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset. This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id lineOffset; +@property (nonatomic, null_resettable) MGLStyleValue *lineOffset; /** Blur applied to the line, in points. This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id lineBlur; +@property (nonatomic, null_resettable) MGLStyleValue *lineBlur; /** Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to points, multiply the length by the current line width. @@ -195,12 +194,12 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslateAnchor) { This property is only applied to the style if `linePattern` is set to `nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id lineDasharray; +@property (nonatomic, null_resettable) MGLStyleValue *> *lineDasharray; /** Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512). */ -@property (nonatomic, null_resettable) id linePattern; +@property (nonatomic, null_resettable) MGLStyleValue *linePattern; @end diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index 2d202290da..57724a0600 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -4,7 +4,7 @@ #import "MGLSource.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue_Private.h" #import "MGLLineStyleLayer.h" #include @@ -48,122 +48,146 @@ #pragma mark - Accessing the Layout Attributes -- (void)setLineCap:(id )lineCap { - MGLSetEnumProperty(lineCap, LineCap, LineCapType, MGLLineCap); +- (void)setLineCap:(MGLStyleValue *)lineCap { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineCap); + self.layer->setLineCap(mbglValue); } -- (id )lineCap { - MGLGetEnumProperty(LineCap, LineCapType, MGLLineCap); +- (MGLStyleValue *)lineCap { + auto propertyValue = self.layer->getLineCap() ?: self.layer->getDefaultLineCap(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineJoin:(MGLStyleValue *)lineJoin { - auto propertyValue = MGLStyleValueTransformer().toPropertyValue(lineJoin); - self.layer->setLineJoin(propertyValue); +- (void)setLineJoin:(MGLStyleValue *)lineJoin { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineJoin); + self.layer->setLineJoin(mbglValue); } -- (MGLStyleValue *)lineJoin { +- (MGLStyleValue *)lineJoin { auto propertyValue = self.layer->getLineJoin() ?: self.layer->getDefaultLineJoin(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineMiterLimit:(MGLStyleValue *)lineMiterLimit { +- (void)setLineMiterLimit:(MGLStyleValue *)lineMiterLimit { auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineMiterLimit); self.layer->setLineMiterLimit(mbglValue); } -- (MGLStyleValue *)lineMiterLimit { +- (MGLStyleValue *)lineMiterLimit { auto propertyValue = self.layer->getLineMiterLimit() ?: self.layer->getDefaultLineMiterLimit(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineRoundLimit:(id )lineRoundLimit { - self.layer->setLineRoundLimit(lineRoundLimit.mbgl_floatPropertyValue); +- (void)setLineRoundLimit:(MGLStyleValue *)lineRoundLimit { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineRoundLimit); + self.layer->setLineRoundLimit(mbglValue); } -- (id )lineRoundLimit { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getLineRoundLimit() ?: self.layer->getDefaultLineRoundLimit()]; +- (MGLStyleValue *)lineRoundLimit { + auto propertyValue = self.layer->getLineRoundLimit() ?: self.layer->getDefaultLineRoundLimit(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } #pragma mark - Accessing the Paint Attributes -- (void)setLineOpacity:(id )lineOpacity { - self.layer->setLineOpacity(lineOpacity.mbgl_floatPropertyValue); +- (void)setLineOpacity:(MGLStyleValue *)lineOpacity { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineOpacity); + self.layer->setLineOpacity(mbglValue); } -- (id )lineOpacity { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getLineOpacity() ?: self.layer->getDefaultLineOpacity()]; +- (MGLStyleValue *)lineOpacity { + auto propertyValue = self.layer->getLineOpacity() ?: self.layer->getDefaultLineOpacity(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineColor:(id )lineColor { - self.layer->setLineColor(lineColor.mbgl_colorPropertyValue); +- (void)setLineColor:(MGLStyleValue *)lineColor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineColor); + self.layer->setLineColor(mbglValue); } -- (id )lineColor { - return [MGLStyleAttribute mbgl_colorWithPropertyValueColor:self.layer->getLineColor() ?: self.layer->getDefaultLineColor()]; +- (MGLStyleValue *)lineColor { + auto propertyValue = self.layer->getLineColor() ?: self.layer->getDefaultLineColor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineTranslate:(id )lineTranslate { - self.layer->setLineTranslate(lineTranslate.mbgl_offsetPropertyValue); +- (void)setLineTranslate:(MGLStyleValue *)lineTranslate { + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(lineTranslate); + self.layer->setLineTranslate(mbglValue); } -- (id )lineTranslate { - return [MGLStyleAttribute mbgl_offsetWithPropertyValueOffset:self.layer->getLineTranslate() ?: self.layer->getDefaultLineTranslate()]; +- (MGLStyleValue *)lineTranslate { + auto propertyValue = self.layer->getLineTranslate() ?: self.layer->getDefaultLineTranslate(); + return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } -- (void)setLineTranslateAnchor:(id )lineTranslateAnchor { - MGLSetEnumProperty(lineTranslateAnchor, LineTranslateAnchor, TranslateAnchorType, MGLLineTranslateAnchor); +- (void)setLineTranslateAnchor:(MGLStyleValue *)lineTranslateAnchor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineTranslateAnchor); + self.layer->setLineTranslateAnchor(mbglValue); } -- (id )lineTranslateAnchor { - MGLGetEnumProperty(LineTranslateAnchor, TranslateAnchorType, MGLLineTranslateAnchor); +- (MGLStyleValue *)lineTranslateAnchor { + auto propertyValue = self.layer->getLineTranslateAnchor() ?: self.layer->getDefaultLineTranslateAnchor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineWidth:(id )lineWidth { - self.layer->setLineWidth(lineWidth.mbgl_floatPropertyValue); +- (void)setLineWidth:(MGLStyleValue *)lineWidth { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineWidth); + self.layer->setLineWidth(mbglValue); } -- (id )lineWidth { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getLineWidth() ?: self.layer->getDefaultLineWidth()]; +- (MGLStyleValue *)lineWidth { + auto propertyValue = self.layer->getLineWidth() ?: self.layer->getDefaultLineWidth(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineGapWidth:(id )lineGapWidth { - self.layer->setLineGapWidth(lineGapWidth.mbgl_floatPropertyValue); +- (void)setLineGapWidth:(MGLStyleValue *)lineGapWidth { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineGapWidth); + self.layer->setLineGapWidth(mbglValue); } -- (id )lineGapWidth { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getLineGapWidth() ?: self.layer->getDefaultLineGapWidth()]; +- (MGLStyleValue *)lineGapWidth { + auto propertyValue = self.layer->getLineGapWidth() ?: self.layer->getDefaultLineGapWidth(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineOffset:(id )lineOffset { - self.layer->setLineOffset(lineOffset.mbgl_floatPropertyValue); +- (void)setLineOffset:(MGLStyleValue *)lineOffset { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineOffset); + self.layer->setLineOffset(mbglValue); } -- (id )lineOffset { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getLineOffset() ?: self.layer->getDefaultLineOffset()]; +- (MGLStyleValue *)lineOffset { + auto propertyValue = self.layer->getLineOffset() ?: self.layer->getDefaultLineOffset(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineBlur:(id )lineBlur { - self.layer->setLineBlur(lineBlur.mbgl_floatPropertyValue); +- (void)setLineBlur:(MGLStyleValue *)lineBlur { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineBlur); + self.layer->setLineBlur(mbglValue); } -- (id )lineBlur { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getLineBlur() ?: self.layer->getDefaultLineBlur()]; +- (MGLStyleValue *)lineBlur { + auto propertyValue = self.layer->getLineBlur() ?: self.layer->getDefaultLineBlur(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setLineDasharray:(id )lineDasharray { - self.layer->setLineDasharray(lineDasharray.mbgl_numberArrayPropertyValue); +- (void)setLineDasharray:(MGLStyleValue *> *)lineDasharray { + auto mbglValue = MGLStyleValueTransformer, NSArray *, float>().toPropertyValue(lineDasharray); + self.layer->setLineDasharray(mbglValue); } -- (id )lineDasharray { - return [MGLStyleAttribute mbgl_numberArrayWithPropertyValueNumberArray:self.layer->getLineDasharray() ?: self.layer->getDefaultLineDasharray()]; +- (MGLStyleValue *> *)lineDasharray { + auto propertyValue = self.layer->getLineDasharray() ?: self.layer->getDefaultLineDasharray(); + return MGLStyleValueTransformer, NSArray *, float>().toStyleValue(propertyValue); } -- (void)setLinePattern:(id )linePattern { - self.layer->setLinePattern(linePattern.mbgl_stringPropertyValue); +- (void)setLinePattern:(MGLStyleValue *)linePattern { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(linePattern); + self.layer->setLinePattern(mbglValue); } -- (id )linePattern { - return [MGLStyleAttribute mbgl_stringWithPropertyValueString:self.layer->getLinePattern() ?: self.layer->getDefaultLinePattern()]; +- (MGLStyleValue *)linePattern { + auto propertyValue = self.layer->getLinePattern() ?: self.layer->getDefaultLinePattern(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } @end diff --git a/platform/darwin/src/MGLRasterStyleLayer.h b/platform/darwin/src/MGLRasterStyleLayer.h index 90af43c7a1..afae85001e 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.h +++ b/platform/darwin/src/MGLRasterStyleLayer.h @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue.h" #import "MGLForegroundStyleLayer.h" NS_ASSUME_NONNULL_BEGIN @@ -19,55 +19,55 @@ NS_ASSUME_NONNULL_BEGIN /** The opacity at which the image will be drawn. - The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id rasterOpacity; +@property (nonatomic, null_resettable) MGLStyleValue *rasterOpacity; /** Rotates hues around the color wheel. This property is measured in degrees. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id rasterHueRotate; +@property (nonatomic, null_resettable) MGLStyleValue *rasterHueRotate; /** Increase or reduce the brightness of the image. The value is the minimum brightness. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id rasterBrightnessMin; +@property (nonatomic, null_resettable) MGLStyleValue *rasterBrightnessMin; /** Increase or reduce the brightness of the image. The value is the maximum brightness. - The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id rasterBrightnessMax; +@property (nonatomic, null_resettable) MGLStyleValue *rasterBrightnessMax; /** Increase or reduce the saturation of the image. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id rasterSaturation; +@property (nonatomic, null_resettable) MGLStyleValue *rasterSaturation; /** Increase or reduce the contrast of the image. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id rasterContrast; +@property (nonatomic, null_resettable) MGLStyleValue *rasterContrast; /** Fade duration when a new tile is added. This property is measured in milliseconds. - The default value of this property is an `NSNumber` object containing the float `300`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `300`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id rasterFadeDuration; +@property (nonatomic, null_resettable) MGLStyleValue *rasterFadeDuration; @end diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index 01d3bf2bca..f616e89518 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -4,7 +4,7 @@ #import "MGLSource.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue_Private.h" #import "MGLRasterStyleLayer.h" #include @@ -27,60 +27,74 @@ #pragma mark - Accessing the Paint Attributes -- (void)setRasterOpacity:(id )rasterOpacity { - self.layer->setRasterOpacity(rasterOpacity.mbgl_floatPropertyValue); +- (void)setRasterOpacity:(MGLStyleValue *)rasterOpacity { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterOpacity); + self.layer->setRasterOpacity(mbglValue); } -- (id )rasterOpacity { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getRasterOpacity() ?: self.layer->getDefaultRasterOpacity()]; +- (MGLStyleValue *)rasterOpacity { + auto propertyValue = self.layer->getRasterOpacity() ?: self.layer->getDefaultRasterOpacity(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setRasterHueRotate:(id )rasterHueRotate { - self.layer->setRasterHueRotate(rasterHueRotate.mbgl_floatPropertyValue); +- (void)setRasterHueRotate:(MGLStyleValue *)rasterHueRotate { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterHueRotate); + self.layer->setRasterHueRotate(mbglValue); } -- (id )rasterHueRotate { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getRasterHueRotate() ?: self.layer->getDefaultRasterHueRotate()]; +- (MGLStyleValue *)rasterHueRotate { + auto propertyValue = self.layer->getRasterHueRotate() ?: self.layer->getDefaultRasterHueRotate(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setRasterBrightnessMin:(id )rasterBrightnessMin { - self.layer->setRasterBrightnessMin(rasterBrightnessMin.mbgl_floatPropertyValue); +- (void)setRasterBrightnessMin:(MGLStyleValue *)rasterBrightnessMin { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterBrightnessMin); + self.layer->setRasterBrightnessMin(mbglValue); } -- (id )rasterBrightnessMin { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getRasterBrightnessMin() ?: self.layer->getDefaultRasterBrightnessMin()]; +- (MGLStyleValue *)rasterBrightnessMin { + auto propertyValue = self.layer->getRasterBrightnessMin() ?: self.layer->getDefaultRasterBrightnessMin(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setRasterBrightnessMax:(id )rasterBrightnessMax { - self.layer->setRasterBrightnessMax(rasterBrightnessMax.mbgl_floatPropertyValue); +- (void)setRasterBrightnessMax:(MGLStyleValue *)rasterBrightnessMax { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterBrightnessMax); + self.layer->setRasterBrightnessMax(mbglValue); } -- (id )rasterBrightnessMax { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getRasterBrightnessMax() ?: self.layer->getDefaultRasterBrightnessMax()]; +- (MGLStyleValue *)rasterBrightnessMax { + auto propertyValue = self.layer->getRasterBrightnessMax() ?: self.layer->getDefaultRasterBrightnessMax(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setRasterSaturation:(id )rasterSaturation { - self.layer->setRasterSaturation(rasterSaturation.mbgl_floatPropertyValue); +- (void)setRasterSaturation:(MGLStyleValue *)rasterSaturation { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterSaturation); + self.layer->setRasterSaturation(mbglValue); } -- (id )rasterSaturation { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getRasterSaturation() ?: self.layer->getDefaultRasterSaturation()]; +- (MGLStyleValue *)rasterSaturation { + auto propertyValue = self.layer->getRasterSaturation() ?: self.layer->getDefaultRasterSaturation(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setRasterContrast:(id )rasterContrast { - self.layer->setRasterContrast(rasterContrast.mbgl_floatPropertyValue); +- (void)setRasterContrast:(MGLStyleValue *)rasterContrast { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterContrast); + self.layer->setRasterContrast(mbglValue); } -- (id )rasterContrast { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getRasterContrast() ?: self.layer->getDefaultRasterContrast()]; +- (MGLStyleValue *)rasterContrast { + auto propertyValue = self.layer->getRasterContrast() ?: self.layer->getDefaultRasterContrast(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setRasterFadeDuration:(id )rasterFadeDuration { - self.layer->setRasterFadeDuration(rasterFadeDuration.mbgl_floatPropertyValue); +- (void)setRasterFadeDuration:(MGLStyleValue *)rasterFadeDuration { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(rasterFadeDuration); + self.layer->setRasterFadeDuration(mbglValue); } -- (id )rasterFadeDuration { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getRasterFadeDuration() ?: self.layer->getDefaultRasterFadeDuration()]; +- (MGLStyleValue *)rasterFadeDuration { + auto propertyValue = self.layer->getRasterFadeDuration() ?: self.layer->getDefaultRasterFadeDuration(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } @end diff --git a/platform/darwin/src/MGLStyleAttribute.h b/platform/darwin/src/MGLStyleAttribute.h deleted file mode 100644 index 564f44ad00..0000000000 --- a/platform/darwin/src/MGLStyleAttribute.h +++ /dev/null @@ -1,25 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" -#import "MGLStyleLayer_Private.h" -#import "MGLStyleAttributeValue_Private.h" - -@interface MGLStyleAttribute : NSObject - -+ (id )mbgl_colorWithPropertyValueColor:(mbgl::style::PropertyValue)property; - -+ (id )mbgl_numberWithPropertyValueNumber:(mbgl::style::PropertyValue)property; - -+ (id )mbgl_boolWithPropertyValueBool:(mbgl::style::PropertyValue)property; - -+ (id )mbgl_stringWithPropertyValueString:(mbgl::style::PropertyValue)property; - -+ (id )mbgl_offsetWithPropertyValueOffset:(mbgl::style::PropertyValue>)property; - -+ (id )mbgl_paddingWithPropertyValuePadding:(mbgl::style::PropertyValue>)property; - -+ (id )mbgl_stringArrayWithPropertyValueStringArray:(mbgl::style::PropertyValue>)property; - -+ (id )mbgl_numberArrayWithPropertyValueNumberArray:(mbgl::style::PropertyValue>)property; - -@end diff --git a/platform/darwin/src/MGLStyleAttribute.mm b/platform/darwin/src/MGLStyleAttribute.mm deleted file mode 100644 index 9e3c22914b..0000000000 --- a/platform/darwin/src/MGLStyleAttribute.mm +++ /dev/null @@ -1,112 +0,0 @@ -#import "MGLStyleAttribute.h" - -#import "MGLStyleAttributeValue_Private.h" -#import "MGLStyleAttributeFunction_Private.h" -#import "NSValue+MGLStyleAttributeAdditions_Private.h" - -@interface MGLStyleAttribute() -@end - -@implementation MGLStyleAttribute - -+ (id)mbgl_colorWithPropertyValueColor:(mbgl::style::PropertyValue)property -{ - if (property.isConstant()) { - return [MGLColor mbgl_colorWithColor:property.asConstant()]; - } else if (property.isFunction()) { - return [MGLStyleAttributeFunction functionWithColorPropertyValue:property.asFunction()]; - } else { - return nil; - } -} - -+ (id )mbgl_numberWithPropertyValueNumber:(mbgl::style::PropertyValue)property -{ - if (property.isConstant()) { - return @(property.asConstant()); - } else if (property.isFunction()) { - return [MGLStyleAttributeFunction functionWithNumberPropertyValue:property.asFunction()]; - } else { - return nil; - } -} - -+ (id)mbgl_boolWithPropertyValueBool:(mbgl::style::PropertyValue)property -{ - if (property.isConstant()) { - return @(property.asConstant()); - } else if (property.isFunction()) { - return [MGLStyleAttributeFunction functionWithBoolPropertyValue:property.asFunction()]; - } else { - return nil; - } -} - -+ (id)mbgl_stringWithPropertyValueString:(mbgl::style::PropertyValue)property -{ - if (property.isConstant()) { - return @(property.asConstant().c_str()); - } else if (property.isFunction()) { - return [MGLStyleAttributeFunction functionWithStringPropertyValue:property.asFunction()]; - } else { - return nil; - } -} - -+ (id)mbgl_offsetWithPropertyValueOffset:(mbgl::style::PropertyValue >)property -{ - if (property.isConstant()) { - auto offset = property.asConstant(); - return [NSValue mgl_valueWithOffsetArray:offset]; - } else if (property.isFunction()) { - return [MGLStyleAttributeFunction functionWithOffsetPropertyValue:property.asFunction()]; - } else { - return nil; - } -} - -+ (id)mbgl_paddingWithPropertyValuePadding:(mbgl::style::PropertyValue >)property -{ - if (property.isConstant()) { - auto padding = property.asConstant(); - return [NSValue mgl_valueWithPaddingArray:padding]; - } else if (property.isFunction()) { - return [MGLStyleAttributeFunction functionWithPaddingPropertyValue:property.asFunction()]; - } else { - return nil; - } -} - -+ (id)mbgl_stringArrayWithPropertyValueStringArray:(mbgl::style::PropertyValue >)property -{ - if (property.isConstant()) { - auto strings = property.asConstant(); - NSMutableArray *convertedStrings = [[NSMutableArray alloc] initWithCapacity:strings.size()]; - for (auto string : strings) { - [convertedStrings addObject:@(string.c_str())]; - } - return convertedStrings; - } else if (property.isFunction()) { - return [MGLStyleAttributeFunction functionWithStringArrayPropertyValue:property.asFunction()]; - } else { - return nil; - } -} - -+ (id)mbgl_numberArrayWithPropertyValueNumberArray:(mbgl::style::PropertyValue >)property -{ - if (property.isConstant()) { - auto numbers = property.asConstant(); - NSMutableArray *convertedNumbers = [NSMutableArray arrayWithCapacity:numbers.size()]; - for (auto number : numbers) { - [convertedNumbers addObject:@(number)]; - } - return convertedNumbers; - } else if (property.isFunction()) { - return [MGLStyleAttributeFunction functionWithNumberArrayPropertyValue:property.asFunction()]; - } else { - return nil; - } -} - -@end diff --git a/platform/darwin/src/MGLStyleAttributeFunction.h b/platform/darwin/src/MGLStyleAttributeFunction.h deleted file mode 100644 index a676a8a715..0000000000 --- a/platform/darwin/src/MGLStyleAttributeFunction.h +++ /dev/null @@ -1,47 +0,0 @@ -#import - -#import "MGLTypes.h" -#import "MGLStyleAttributeValue.h" - - -NS_ASSUME_NONNULL_BEGIN - -@interface MGLStyleAttributeFunction : NSObject - -@property (nonatomic, copy) NS_DICTIONARY_OF(NSNumber *, id) *stops; - -@property (nonatomic, copy, nullable) NSNumber *base; - -@end - -@interface MGLStyleValue : NSObject - -+ (instancetype)valueWithRawValue:(T)rawValue; -+ (instancetype)valueWithBase:(CGFloat)base stops:(NSDictionary *> *)stops; -+ (instancetype)valueWithStops:(NSDictionary *> *)stops; - -@end - -@interface MGLStyleConstantValue : MGLStyleValue - -+ (instancetype)valueWithRawValue:(T)rawValue; - -- (instancetype)initWithRawValue:(T)rawValue; - -@property (nonatomic) T rawValue; - -@end - -@interface MGLStyleFunction : MGLStyleValue - -+ (instancetype)functionWithBase:(CGFloat)base stops:(NSDictionary *> *)stops; -+ (instancetype)functionWithStops:(NSDictionary *> *)stops; - -- (instancetype)initWithBase:(CGFloat)base stops:(NSDictionary *> *)stops; - -@property (nonatomic) CGFloat base; -@property (nonatomic, copy) NSDictionary *> *stops; - -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLStyleAttributeFunction.mm b/platform/darwin/src/MGLStyleAttributeFunction.mm deleted file mode 100644 index 337e299127..0000000000 --- a/platform/darwin/src/MGLStyleAttributeFunction.mm +++ /dev/null @@ -1,309 +0,0 @@ -#import "MGLStyleAttributeFunction.h" - -#import "MGLStyleLayer_Private.h" -#import "MGLStyleAttributeValue_Private.h" -#import "MGLStyleAttributeFunction_Private.h" - -@implementation MGLStyleValue - -+ (instancetype)valueWithRawValue:(id)rawValue { - return [MGLStyleConstantValue valueWithRawValue:rawValue]; -} - -+ (instancetype)valueWithBase:(CGFloat)base stops:(NSDictionary *)stops { - return [MGLStyleFunction functionWithBase:base stops:stops]; -} - -+ (instancetype)valueWithStops:(NSDictionary *)stops { - return [MGLStyleFunction functionWithStops:stops]; -} - -@end - -@implementation MGLStyleConstantValue - -+ (instancetype)valueWithRawValue:(id)rawValue { - return [[self alloc] initWithRawValue:rawValue]; -} - -- (instancetype)initWithRawValue:(id)rawValue { - if (self = [super init]) { - _rawValue = rawValue; - } - return self; -} - -@end - -@implementation MGLStyleFunction - -+ (instancetype)functionWithBase:(CGFloat)base stops:(NSDictionary *)stops { - return [[self alloc] initWithBase:base stops:stops]; -} - -+ (instancetype)functionWithStops:(NSDictionary *)stops { - return [[self alloc] initWithBase:1 stops:stops]; -} - -- (instancetype)init { - if (self = [super init]) { - _base = 1; - } - return self; -} - -- (instancetype)initWithBase:(CGFloat)base stops:(NSDictionary *)stops { - if (self = [self init]) { - _base = base; - _stops = stops; - } - return self; -} - -@end - - - - - -@interface MGLStyleAttributeFunction() -@end - -@implementation MGLStyleAttributeFunction - -- (instancetype)init -{ - if (self = [super init]) { - _base = @1; - } - return self; -} - -- (BOOL)isFunction -{ - return YES; -} - -- (mbgl::style::PropertyValue)mbgl_colorPropertyValue -{ - __block std::vector> stops; - [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLColor * _Nonnull color, BOOL * _Nonnull stop) { - NSAssert([color isKindOfClass:[MGLColor class]], @"Stops should be colors"); - stops.emplace_back(zoomKey.floatValue, color.mbgl_color); - }]; - return mbgl::style::Function({{stops}}, _base.floatValue); -} - -- (mbgl::style::PropertyValue)mbgl_floatPropertyValue -{ - __block std::vector> stops; - [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSNumber * _Nonnull number, BOOL * _Nonnull stop) { - NSAssert([number isKindOfClass:[NSNumber class]], @"Stops should be NSNumbers"); - stops.emplace_back(zoomKey.floatValue, number.floatValue); - }]; - return mbgl::style::Function({{stops}}, _base.floatValue); -} - -- (mbgl::style::PropertyValue)mbgl_boolPropertyValue -{ - __block std::vector> stops; - [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSNumber * _Nonnull number, BOOL * _Nonnull stop) { - NSAssert([number isKindOfClass:[NSNumber class]], @"Stops should be NSNumbers"); - stops.emplace_back(zoomKey.floatValue, number.boolValue); - }]; - return mbgl::style::Function({{stops}}, _base.floatValue); -} - -- (mbgl::style::PropertyValue)mbgl_stringPropertyValue -{ - __block std::vector> stops; - [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSString * _Nonnull string, BOOL * _Nonnull stop) { - NSAssert([string isKindOfClass:[NSString class]], @"Stops should be strings"); - stops.emplace_back(zoomKey.floatValue, string.UTF8String); - }]; - return mbgl::style::Function({{stops}}, _base.floatValue); -} - -- (mbgl::style::PropertyValue >)mbgl_stringArrayPropertyValue -{ - __block std::vector>> stops; - [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSArray * _Nonnull strings, BOOL * _Nonnull stop) { - NSAssert([strings isKindOfClass:[NSArray class]], @"Stops should be NSArray"); - std::vectorconvertedStrings; - for (NSString *string in strings) { - convertedStrings.emplace_back(string.UTF8String); - } - stops.emplace_back(zoomKey.floatValue, convertedStrings); - }]; - return mbgl::style::Function>({{stops}}, _base.floatValue); -} - -- (mbgl::style::PropertyValue >)mbgl_numberArrayPropertyValue -{ - __block std::vector>> stops; - [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSArray * _Nonnull numbers, BOOL * _Nonnull stop) { - NSAssert([numbers isKindOfClass:[NSArray class]], @"Stops should be NSArray"); - std::vectorconvertedNumbers; - for (NSNumber *number in numbers) { - convertedNumbers.emplace_back(number.floatValue); - } - stops.emplace_back(zoomKey.floatValue, convertedNumbers); - }]; - return mbgl::style::Function>({{stops}}, _base.floatValue); -} - -- (mbgl::style::PropertyValue >)mbgl_paddingPropertyValue -{ - __block std::vector>> stops; - [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSValue * _Nonnull padding, BOOL * _Nonnull stop) { - NSAssert([padding isKindOfClass:[NSValue class]], @"Stops should be NSValue"); - stops.emplace_back(zoomKey.floatValue, padding.mgl_paddingArrayValue); - }]; - return mbgl::style::Function>({{stops}}, _base.floatValue); -} - -- (mbgl::style::PropertyValue >)mbgl_offsetPropertyValue -{ - __block std::vector>> stops; - [self.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, NSValue * _Nonnull offset, BOOL * _Nonnull stop) { - NSAssert([offset isKindOfClass:[NSValue class]], @"Stops should be NSValue"); - stops.emplace_back(zoomKey.floatValue, offset.mgl_offsetArrayValue); - }]; - return mbgl::style::Function>({{stops}}, _base.floatValue); -} - -+ (instancetype)functionWithColorPropertyValue:(mbgl::style::Function)property -{ - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - auto stops = property.getStops(); - NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()]; - for (auto stop : stops) { - convertedStops[@(stop.first)] = [MGLColor mbgl_colorWithColor:stop.second]; - } - function.base = @(property.getBase()); - function.stops = convertedStops; - return function; -} - -+ (instancetype)functionWithNumberPropertyValue:(mbgl::style::Function)property -{ - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - auto stops = property.getStops(); - NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()]; - for (auto stop : stops) { - convertedStops[@(stop.first)] = @(stop.second); - } - function.base = @(property.getBase()); - function.stops = convertedStops; - return function; -} - -+ (instancetype)functionWithBoolPropertyValue:(mbgl::style::Function)property -{ - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - auto stops = property.getStops(); - NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()]; - for (auto stop : stops) { - convertedStops[@(stop.first)] = @(stop.second); - } - function.base = @(property.getBase()); - function.stops = convertedStops; - return function; -} - -+ (instancetype)functionWithStringPropertyValue:(mbgl::style::Function)property -{ - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - auto stops = property.getStops(); - NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()]; - for (auto stop : stops) { - convertedStops[@(stop.first)] = @(stop.second.c_str()); - } - function.base = @(property.getBase()); - function.stops = convertedStops; - return function; -} - -+ (instancetype)functionWithOffsetPropertyValue:(mbgl::style::Function >)property -{ - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - auto stops = property.getStops(); - NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()]; - for (auto stop : stops) { - convertedStops[@(stop.first)] = [NSValue mgl_valueWithOffsetArray:stop.second]; - } - function.base = @(property.getBase()); - function.stops = convertedStops; - return function; -} - -+ (instancetype)functionWithPaddingPropertyValue:(mbgl::style::Function >)property -{ - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - auto stops = property.getStops(); - NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()]; - for (auto stop : stops) { - convertedStops[@(stop.first)] = [NSValue mgl_valueWithPaddingArray:stop.second]; - } - function.base = @(property.getBase()); - function.stops = convertedStops; - return function; -} - -+ (instancetype)functionWithStringArrayPropertyValue:(mbgl::style::Function >)property -{ - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - auto stops = property.getStops(); - NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()]; - for (auto stop : stops) { - auto strings = stop.second; - NSMutableArray *convertedStrings = [NSMutableArray arrayWithCapacity:strings.size()]; - for (auto const& string: strings) { - [convertedStrings addObject:@(string.c_str())]; - } - convertedStops[@(stop.first)] = convertedStrings; - } - function.base = @(property.getBase()); - function.stops = convertedStops; - return function; -} - -+ (instancetype)functionWithNumberArrayPropertyValue:(mbgl::style::Function >)property -{ - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - auto stops = property.getStops(); - NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()]; - for (auto stop : stops) { - auto numbers = stop.second; - NSMutableArray *convertedNumbers = [NSMutableArray arrayWithCapacity:numbers.size()]; - for (auto const& number: numbers) { - [convertedNumbers addObject:@(number)]; - } - convertedStops[@(stop.first)] = convertedNumbers; - } - function.base = @(property.getBase()); - function.stops = convertedStops; - return function; -} - -- (NSString *)description -{ - return [NSString stringWithFormat:@"<%@: %p, base = %@; stops = %@>", - NSStringFromClass([self class]), (void *)self, - self.base, - self.stops]; -} - -- (BOOL)isEqual:(MGLStyleAttributeFunction *)other -{ - return ([other isKindOfClass:[self class]] - && (other.base == self.base || [other.base isEqualToNumber:self.base]) - && [other.stops isEqualToDictionary:self.stops]); -} - -- (NSUInteger)hash -{ - return self.base.hash + self.stops.hash; -} - -@end diff --git a/platform/darwin/src/MGLStyleAttributeFunction_Private.h b/platform/darwin/src/MGLStyleAttributeFunction_Private.h deleted file mode 100644 index 94a610c62a..0000000000 --- a/platform/darwin/src/MGLStyleAttributeFunction_Private.h +++ /dev/null @@ -1,220 +0,0 @@ -#import "MGLStyleAttributeFunction.h" - -#import "NSValue+MGLStyleAttributeAdditions_Private.h" - -#if TARGET_OS_IPHONE - #import "UIColor+MGLAdditions.h" -#else - #import "NSColor+MGLAdditions.h" -#endif - -#include -#include -#include -#include - -#include - -#define MGLSetEnumProperty(name, Name, MBGLType, ObjCType) \ - if (name.isFunction) { \ - NSAssert([name isKindOfClass:[MGLStyleAttributeFunction class]], @"" #name @" should be a function"); \ - \ - __block std::vector> stops; \ - [[(MGLStyleAttributeFunction *)name stops] enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull key, NSValue * _Nonnull obj, BOOL * _Nonnull stop) { \ - NSAssert([obj isKindOfClass:[NSValue class]], @"Stops in " #name @" should be NSValues"); \ - ObjCType value; \ - [obj getValue:&value]; \ - stops.emplace_back(key.floatValue, static_cast(value)); \ - }]; \ - auto function = mbgl::style::Function { \ - stops, \ - [(MGLStyleAttributeFunction *)name base].floatValue, \ - }; \ - self.layer->set##Name(function); \ - } else if (name) { \ - NSAssert([name isKindOfClass:[NSValue class]], @"" #name @"should be an NSValue"); \ - ObjCType value; \ - [(NSValue *)name getValue:&value]; \ - self.layer->set##Name({ static_cast(value) }); \ - } else { \ - self.layer->set##Name({}); \ - } - -#define MGLGetEnumProperty(Name, MBGLType, ObjCType) \ - const char *type = @encode(ObjCType); \ - mbgl::style::PropertyValue property = self.layer->get##Name() ?: self.layer->getDefault##Name(); \ - if (property.isConstant()) { \ - ObjCType value = static_cast(property.asConstant()); \ - return [NSValue value:&value withObjCType:type]; \ - } else if (property.isFunction()) { \ - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; \ - auto stops = property.asFunction().getStops(); \ - NSMutableDictionary *convertedStops = [NSMutableDictionary dictionaryWithCapacity:stops.size()]; \ - for (auto stop : stops) { \ - ObjCType value = static_cast(stop.second); \ - convertedStops[@(stop.first)] = [NSValue value:&value withObjCType:type]; \ - } \ - function.base = @(property.asFunction().getBase()); \ - function.stops = convertedStops; \ - return function; \ - } else { \ - return nil; \ - } - -@interface MGLStyleAttributeFunction(Private) - -+ (instancetype)functionWithColorPropertyValue:(mbgl::style::Function)property; - -+ (instancetype)functionWithNumberPropertyValue:(mbgl::style::Function)property; - -+ (instancetype)functionWithBoolPropertyValue:(mbgl::style::Function)property; - -+ (instancetype)functionWithStringPropertyValue:(mbgl::style::Function)property; - -+ (instancetype)functionWithOffsetPropertyValue:(mbgl::style::Function>)property; - -+ (instancetype)functionWithPaddingPropertyValue:(mbgl::style::Function>)property; - -+ (instancetype)functionWithStringArrayPropertyValue:(mbgl::style::Function>)property; - -+ (instancetype)functionWithNumberArrayPropertyValue:(mbgl::style::Function>)property; - -+ (instancetype)functionWithEnumProperyValue:(mbgl::style::Function)property type:(const char *)type; - -@end - -template -class MGLStyleValueTransformer { -public: - - MGLStyleValue *toStyleValue(const mbgl::style::PropertyValue &mbglValue) { - if (mbglValue.isConstant()) { - return toStyleConstantValue(mbglValue.asConstant()); - } else if (mbglValue.isFunction()) { - return toStyleFunction(mbglValue.asFunction()); - } else { - return nil; - } - } - - mbgl::style::PropertyValue toPropertyValue(MGLStyleValue *value) { - if ([value isKindOfClass:[MGLStyleConstantValue class]]) { - MBGLType mbglValue; - getMBGLValue([(MGLStyleConstantValue *)value rawValue], mbglValue); - return mbglValue; - } else if ([value isKindOfClass:[MGLStyleFunction class]]) { - MGLStyleFunction *function = (MGLStyleFunction *)value; - __block std::vector> mbglStops; - [function.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue * _Nonnull stopValue, BOOL * _Nonnull stop) { - NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); - auto mbglStopValue = toPropertyValue(stopValue); - NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); - mbglStops.emplace_back(zoomKey.floatValue, mbglStopValue.asConstant()); - }]; - return mbgl::style::Function({{mbglStops}}, function.base); - } else { - return {}; - } - } - -private: - - MGLStyleConstantValue *toStyleConstantValue(const MBGLType mbglValue) { - auto rawValue = toMGLRawStyleValue(mbglValue); - return [MGLStyleConstantValue valueWithRawValue:rawValue]; - } - - MGLStyleFunction *toStyleFunction(const mbgl::style::Function &mbglFunction) { - const auto &mbglStops = mbglFunction.getStops(); - NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()]; - for (const auto &mbglStop : mbglStops) { - auto rawValue = toMGLRawStyleValue(mbglStop.second); - stops[@(mbglStop.first)] = [MGLStyleValue valueWithRawValue:rawValue]; - } - return [MGLStyleFunction functionWithBase:mbglFunction.getBase() stops:stops]; - } - - NSNumber *toMGLRawStyleValue(const bool mbglStopValue) { - return @(mbglStopValue); - } - - NSNumber *toMGLRawStyleValue(const float mbglStopValue) { - return @(mbglStopValue); - } - - NSString *toMGLRawStyleValue(const std::string &mbglStopValue) { - return @(mbglStopValue.c_str()); - } - - // Offsets - NSValue *toMGLRawStyleValue(const std::array &mbglStopValue) { - return [NSValue mgl_valueWithOffsetArray:mbglStopValue]; - } - - // Padding - NSValue *toMGLRawStyleValue(const std::array &mbglStopValue) { - return [NSValue mgl_valueWithPaddingArray:mbglStopValue]; - } - - // Enumerations - template ::value>::type> - ObjCType toMGLRawStyleValue(const MBGLType &mbglStopValue) { - NSUInteger rawValue = static_cast(mbglStopValue); - return [NSValue value:&rawValue withObjCType:@encode(NSUInteger)]; - } - - MGLColor *toMGLRawStyleValue(const mbgl::Color mbglStopValue) { - return [MGLColor mbgl_colorWithColor:mbglStopValue]; - } - - ObjCType toMGLRawStyleValue(const std::vector &mbglStopValue) { - NSMutableArray *array = [NSMutableArray arrayWithCapacity:mbglStopValue.size()]; - for (const auto &mbglElement: mbglStopValue) { - [array addObject:toMGLRawStyleValue(mbglElement)]; - } - return array; - } - -private: - - void getMBGLValue(NSNumber *rawValue, bool &mbglValue) { - mbglValue = !!rawValue.boolValue; - } - - void getMBGLValue(NSNumber *rawValue, float &mbglValue) { - mbglValue = !!rawValue.boolValue; - } - - void getMBGLValue(NSString *rawValue, std::string &mbglValue) { - mbglValue = rawValue.UTF8String; - } - - // Offsets - void getMBGLValue(NSValue *rawValue, std::array &mbglValue) { - mbglValue = rawValue.mgl_offsetArrayValue; - } - - // Padding - void getMBGLValue(NSValue *rawValue, std::array &mbglValue) { - mbglValue = rawValue.mgl_paddingArrayValue; - } - - // Enumerations - template ::value>::type> - void getMBGLValue(ObjCType rawValue, MBGLType &mbglValue) { - [rawValue getValue:&mbglValue]; - } - - void getMBGLValue(MGLColor *rawValue, mbgl::Color &mbglValue) { - mbglValue = rawValue.mbgl_color; - } - - void getMBGLValue(ObjCType rawValue, std::vector &mbglValue) { - mbglValue.reserve(rawValue.count); - for (id obj in rawValue) { - MBGLType mbglElement; - getMBGLValue(obj, mbglElement); - mbglValue.push_back(mbglElement); - } - } -}; diff --git a/platform/darwin/src/MGLStyleAttributeValue.h b/platform/darwin/src/MGLStyleAttributeValue.h deleted file mode 100644 index 00829b0dca..0000000000 --- a/platform/darwin/src/MGLStyleAttributeValue.h +++ /dev/null @@ -1,5 +0,0 @@ -#import - -@protocol MGLStyleAttributeValue -@optional -@end diff --git a/platform/darwin/src/MGLStyleAttributeValue_Private.h b/platform/darwin/src/MGLStyleAttributeValue_Private.h deleted file mode 100644 index 4b8fd1cc01..0000000000 --- a/platform/darwin/src/MGLStyleAttributeValue_Private.h +++ /dev/null @@ -1,24 +0,0 @@ -#import - -#import "MGLStyleAttributeFunction_Private.h" - -#include - -@protocol MGLStyleAttributeValue_Private -- (BOOL)isFunction; -@optional - -// Convert darwin types to mbgl types -- (mbgl::style::PropertyValue)mbgl_colorPropertyValue; -- (mbgl::style::PropertyValue)mbgl_floatPropertyValue; -- (mbgl::style::PropertyValue)mbgl_boolPropertyValue; -- (mbgl::style::PropertyValue)mbgl_stringPropertyValue; -- (mbgl::style::PropertyValue>)mbgl_offsetPropertyValue; -- (mbgl::style::PropertyValue>)mbgl_paddingPropertyValue; -- (mbgl::style::PropertyValue >)mbgl_stringArrayPropertyValue; -- (mbgl::style::PropertyValue >)mbgl_numberArrayPropertyValue; - -// Convert mbgl types to darwin types -- (id )mbgl_colorPropertyValueWith:(mbgl::style::PropertyValue)color; - -@end diff --git a/platform/darwin/src/MGLStyleLayer.h.ejs b/platform/darwin/src/MGLStyleLayer.h.ejs index eb799f13be..b97d070b90 100644 --- a/platform/darwin/src/MGLStyleLayer.h.ejs +++ b/platform/darwin/src/MGLStyleLayer.h.ejs @@ -8,7 +8,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue.h" #import "MGL<%- (type === 'background' ? '' : (type === 'raster' ? 'Foreground' : @@ -92,7 +92,7 @@ typedef NS_ENUM(NSUInteger, MGL<%- camelize(property.name) %>) { <%- propertyReqs(property, layoutPropertiesByName, type) %> <% } -%> */ -@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) <%- propertyType(property, false, type) %> <%- camelizeWithLeadingLowercase(property.name) %>; +@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(property.name) %>; <% } -%> <% } -%> @@ -110,7 +110,7 @@ typedef NS_ENUM(NSUInteger, MGL<%- camelize(property.name) %>) { <%- propertyReqs(property, paintPropertiesByName, type) %> <% } -%> */ -@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) <%- propertyType(property, false, type) %> <%- camelizeWithLeadingLowercase(property.name) %>; +@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(property.name) %>; <% } -%> <% } -%> diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 8d3bba9958..3678e9ec52 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -9,7 +9,7 @@ #import "MGLSource.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue_Private.h" #import "MGL<%- camelize(type) %>StyleLayer.h" #include _layer.hpp> @@ -67,12 +67,14 @@ #pragma mark - Accessing the Layout Attributes <% for (const property of layoutProperties) { -%> -- (void)set<%- camelize(property.name) %>:(<%- propertyType(property, true, type) %>)<%- objCName(property) %> { - <%- setterImplementation(property, type) %> +- (void)set<%- camelize(property.name) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { + auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); + self.layer->set<%- camelize(property.name) %>(mbglValue); } -- (<%- propertyType(property, false, type) %>)<%- objCName(property) %> { - <%- getterImplementation(property, type) %> +- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { + auto propertyValue = self.layer->get<%- camelize(property.name) %>() ?: self.layer->getDefault<%- camelize(property.name) %>(); + return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); } <% } -%> @@ -81,12 +83,14 @@ #pragma mark - Accessing the Paint Attributes <% for (const property of paintProperties) { -%> -- (void)set<%- camelize(property.name) %>:(<%- propertyType(property, true, type) %>)<%- objCName(property) %> { - <%- setterImplementation(property, type) %> +- (void)set<%- camelize(property.name) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { + auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); + self.layer->set<%- camelize(property.name) %>(mbglValue); } -- (<%- propertyType(property, false, type) %>)<%- objCName(property) %> { - <%- getterImplementation(property, type) %> +- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { + auto propertyValue = self.layer->get<%- camelize(property.name) %>() ?: self.layer->getDefault<%- camelize(property.name) %>(); + return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); } <% } -%> diff --git a/platform/darwin/src/MGLStyleLayer_Private.h b/platform/darwin/src/MGLStyleLayer_Private.h index a499775a52..5fa01856ea 100644 --- a/platform/darwin/src/MGLStyleLayer_Private.h +++ b/platform/darwin/src/MGLStyleLayer_Private.h @@ -1,23 +1,9 @@ #import -#include #import "MGLStyleLayer.h" -#import "MGLStyleAttribute.h" - -#import "NSNumber+MGLStyleAttributeAdditions_Private.h" -#import "NSArray+MGLStyleAttributeAdditions_Private.h" -#import "NSString+MGLStyleAttributeAdditions_Private.h" -#import "NSValue+MGLStyleAttributeAdditions_Private.h" -#import "MGLStyleAttributeFunction_Private.h" -#import "MGLStyleAttributeValue_Private.h" +#import "MGLStyleValue_Private.h" -#if TARGET_OS_IPHONE - #import "UIColor+MGLAdditions.h" - #import "UIColor+MGLStyleAttributeAdditions_Private.h" -#else - #import "NSColor+MGLAdditions.h" - #import "NSColor+MGLStyleAttributeAdditions_Private.h" -#endif +#include @interface MGLStyleLayer (Private) diff --git a/platform/darwin/src/MGLStyleValue.h b/platform/darwin/src/MGLStyleValue.h new file mode 100644 index 0000000000..1f19a5e028 --- /dev/null +++ b/platform/darwin/src/MGLStyleValue.h @@ -0,0 +1,32 @@ +#import +#import + +@interface MGLStyleValue : NSObject + ++ (instancetype)valueWithRawValue:(T)rawValue; ++ (instancetype)valueWithBase:(CGFloat)base stops:(NSDictionary *> *)stops; ++ (instancetype)valueWithStops:(NSDictionary *> *)stops; + +@end + +@interface MGLStyleConstantValue : MGLStyleValue + ++ (instancetype)valueWithRawValue:(T)rawValue; + +- (instancetype)initWithRawValue:(T)rawValue; + +@property (nonatomic) T rawValue; + +@end + +@interface MGLStyleFunction : MGLStyleValue + ++ (instancetype)functionWithBase:(CGFloat)base stops:(NSDictionary *> *)stops; ++ (instancetype)functionWithStops:(NSDictionary *> *)stops; + +- (instancetype)initWithBase:(CGFloat)base stops:(NSDictionary *> *)stops; + +@property (nonatomic) CGFloat base; +@property (nonatomic, copy) NSDictionary *> *stops; + +@end diff --git a/platform/darwin/src/MGLStyleValue.mm b/platform/darwin/src/MGLStyleValue.mm new file mode 100644 index 0000000000..f8d5fd3a5d --- /dev/null +++ b/platform/darwin/src/MGLStyleValue.mm @@ -0,0 +1,71 @@ +#import "MGLStyleValue_Private.h" + +@implementation MGLStyleValue + ++ (instancetype)valueWithRawValue:(id)rawValue { + return [MGLStyleConstantValue valueWithRawValue:rawValue]; +} + ++ (instancetype)valueWithBase:(CGFloat)base stops:(NSDictionary *)stops { + return [MGLStyleFunction functionWithBase:base stops:stops]; +} + ++ (instancetype)valueWithStops:(NSDictionary *)stops { + return [MGLStyleFunction functionWithStops:stops]; +} + +@end + +@implementation MGLStyleConstantValue + ++ (instancetype)valueWithRawValue:(id)rawValue { + return [[self alloc] initWithRawValue:rawValue]; +} + +- (instancetype)initWithRawValue:(id)rawValue { + if (self = [super init]) { + _rawValue = rawValue; + } + return self; +} + +- (NSString *)description { + return [self.rawValue description]; +} + +- (BOOL)isEqual:(MGLStyleConstantValue *)other { + return [other isKindOfClass:[self class]] && [other.rawValue isEqual:self.rawValue]; +} + +- (NSUInteger)hash { + return [self.rawValue hash]; +} + +@end + +@implementation MGLStyleFunction + ++ (instancetype)functionWithBase:(CGFloat)base stops:(NSDictionary *)stops { + return [[self alloc] initWithBase:base stops:stops]; +} + ++ (instancetype)functionWithStops:(NSDictionary *)stops { + return [[self alloc] initWithBase:1 stops:stops]; +} + +- (instancetype)init { + if (self = [super init]) { + _base = 1; + } + return self; +} + +- (instancetype)initWithBase:(CGFloat)base stops:(NSDictionary *)stops { + if (self = [self init]) { + _base = base; + _stops = stops; + } + return self; +} + +@end diff --git a/platform/darwin/src/MGLStyleValue_Private.h b/platform/darwin/src/MGLStyleValue_Private.h new file mode 100644 index 0000000000..e48db02bf1 --- /dev/null +++ b/platform/darwin/src/MGLStyleValue_Private.h @@ -0,0 +1,150 @@ +#import + +#import "MGLStyleValue.h" + +#import "NSValue+MGLStyleAttributeAdditions.h" +#import "MGLTypes.h" + +#if TARGET_OS_IPHONE + #import "UIColor+MGLAdditions.h" +#else + #import "NSColor+MGLAdditions.h" +#endif + +#include + +template +class MGLStyleValueTransformer { +public: + + MGLStyleValue *toStyleValue(const mbgl::style::PropertyValue &mbglValue) { + if (mbglValue.isConstant()) { + return toStyleConstantValue(mbglValue.asConstant()); + } else if (mbglValue.isFunction()) { + return toStyleFunction(mbglValue.asFunction()); + } else { + return nil; + } + } + + mbgl::style::PropertyValue toPropertyValue(MGLStyleValue *value) { + if ([value isKindOfClass:[MGLStyleConstantValue class]]) { + MBGLType mbglValue; + getMBGLValue([(MGLStyleConstantValue *)value rawValue], mbglValue); + return mbglValue; + } else if ([value isKindOfClass:[MGLStyleFunction class]]) { + MGLStyleFunction *function = (MGLStyleFunction *)value; + __block std::vector> mbglStops; + [function.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue * _Nonnull stopValue, BOOL * _Nonnull stop) { + NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); + auto mbglStopValue = toPropertyValue(stopValue); + NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); + mbglStops.emplace_back(zoomKey.floatValue, mbglStopValue.asConstant()); + }]; + return mbgl::style::Function({{mbglStops}}, function.base); + } else { + return {}; + } + } + +private: + + MGLStyleConstantValue *toStyleConstantValue(const MBGLType mbglValue) { + auto rawValue = toMGLRawStyleValue(mbglValue); + return [MGLStyleConstantValue valueWithRawValue:rawValue]; + } + + MGLStyleFunction *toStyleFunction(const mbgl::style::Function &mbglFunction) { + const auto &mbglStops = mbglFunction.getStops(); + NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()]; + for (const auto &mbglStop : mbglStops) { + auto rawValue = toMGLRawStyleValue(mbglStop.second); + stops[@(mbglStop.first)] = [MGLStyleValue valueWithRawValue:rawValue]; + } + return [MGLStyleFunction functionWithBase:mbglFunction.getBase() stops:stops]; + } + + NSNumber *toMGLRawStyleValue(const bool mbglStopValue) { + return @(mbglStopValue); + } + + NSNumber *toMGLRawStyleValue(const float mbglStopValue) { + return @(mbglStopValue); + } + + NSString *toMGLRawStyleValue(const std::string &mbglStopValue) { + return @(mbglStopValue.c_str()); + } + + // Offsets + NSValue *toMGLRawStyleValue(const std::array &mbglStopValue) { + return [NSValue mgl_valueWithOffsetArray:mbglStopValue]; + } + + // Padding + NSValue *toMGLRawStyleValue(const std::array &mbglStopValue) { + return [NSValue mgl_valueWithPaddingArray:mbglStopValue]; + } + + // Enumerations + template ::value>::type> + ObjCType toMGLRawStyleValue(const MBGLType &mbglStopValue) { + NSUInteger rawValue = static_cast(mbglStopValue); + return [NSValue value:&rawValue withObjCType:@encode(NSUInteger)]; + } + + MGLColor *toMGLRawStyleValue(const mbgl::Color mbglStopValue) { + return [MGLColor mbgl_colorWithColor:mbglStopValue]; + } + + ObjCType toMGLRawStyleValue(const std::vector &mbglStopValue) { + NSMutableArray *array = [NSMutableArray arrayWithCapacity:mbglStopValue.size()]; + for (const auto &mbglElement: mbglStopValue) { + [array addObject:toMGLRawStyleValue(mbglElement)]; + } + return array; + } + +private: + + void getMBGLValue(NSNumber *rawValue, bool &mbglValue) { + mbglValue = !!rawValue.boolValue; + } + + void getMBGLValue(NSNumber *rawValue, float &mbglValue) { + mbglValue = rawValue.floatValue; + } + + void getMBGLValue(NSString *rawValue, std::string &mbglValue) { + mbglValue = rawValue.UTF8String; + } + + // Offsets + void getMBGLValue(NSValue *rawValue, std::array &mbglValue) { + mbglValue = rawValue.mgl_offsetArrayValue; + } + + // Padding + void getMBGLValue(NSValue *rawValue, std::array &mbglValue) { + mbglValue = rawValue.mgl_paddingArrayValue; + } + + // Enumerations + template ::value>::type> + void getMBGLValue(ObjCType rawValue, MBGLType &mbglValue) { + [rawValue getValue:&mbglValue]; + } + + void getMBGLValue(MGLColor *rawValue, mbgl::Color &mbglValue) { + mbglValue = rawValue.mbgl_color; + } + + void getMBGLValue(ObjCType rawValue, std::vector &mbglValue) { + mbglValue.reserve(rawValue.count); + for (id obj in rawValue) { + MBGLElement mbglElement; + getMBGLValue(obj, mbglElement); + mbglValue.push_back(mbglElement); + } + } +}; diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h index f8a130d54e..3fcecedca3 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.h +++ b/platform/darwin/src/MGLSymbolStyleLayer.h @@ -1,7 +1,7 @@ // This file is generated. // Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue.h" #import "MGLVectorStyleLayer.h" NS_ASSUME_NONNULL_BEGIN @@ -235,372 +235,372 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { /** Label placement relative to its geometry. - The default value of this property is an `NSValue` object containing `MGLSymbolPlacementPoint`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementPoint`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id symbolPlacement; +@property (nonatomic, null_resettable) MGLStyleValue *symbolPlacement; /** Distance between two symbol anchors. This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `250`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `250`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `symbolPlacement` is set to an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. + This property is only applied to the style if `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id symbolSpacing; +@property (nonatomic, null_resettable) MGLStyleValue *symbolSpacing; /** If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. - The default value of this property is an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id symbolAvoidEdges; +@property (nonatomic, null_resettable) MGLStyleValue *symbolAvoidEdges; /** If true, the icon will be visible even if it collides with other previously drawn symbols. - The default value of this property is an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconAllowOverlap; +@property (nonatomic, null_resettable) MGLStyleValue *iconAllowOverlap; /** If true, other symbols can be visible even if they collide with the icon. - The default value of this property is an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconIgnorePlacement; +@property (nonatomic, null_resettable) MGLStyleValue *iconIgnorePlacement; /** If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not. - The default value of this property is an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`, and `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconOptional; +@property (nonatomic, null_resettable) MGLStyleValue *iconOptional; /** In combination with `symbolPlacement`, determines the rotation behavior of icons. - The default value of this property is an `NSValue` object containing `MGLIconRotationAlignmentAuto`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLIconRotationAlignmentAuto`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconRotationAlignment; +@property (nonatomic, null_resettable) MGLStyleValue *iconRotationAlignment; /** Scale factor for icon. 1 is original size, 3 triples the size. - The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconSize; +@property (nonatomic, null_resettable) MGLStyleValue *iconSize; /** Scales the icon to fit around the associated text. - The default value of this property is an `NSValue` object containing `MGLIconTextFitNone`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLIconTextFitNone`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`, and `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconTextFit; +@property (nonatomic, null_resettable) MGLStyleValue *iconTextFit; /** Size of the additional area added to dimensions determined by `iconTextFit`, in clockwise order: top, right, bottom, left. This property is measured in points. - The default value of this property is an `NSValue` object containing `NSEdgeInsetsZero` or `UIEdgeInsetsZero`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `NSEdgeInsetsZero` or `UIEdgeInsetsZero`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `iconImage` is non-`nil`, and `textField` is non-`nil`, and `iconTextFit` is set to an `NSValue` object containing `MGLIconTextFitBoth`, `MGLIconTextFitWidth`, or `MGLIconTextFitHeight`. Otherwise, it is ignored. + This property is only applied to the style if `iconImage` is non-`nil`, and `textField` is non-`nil`, and `iconTextFit` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLIconTextFitBoth`, `MGLIconTextFitWidth`, or `MGLIconTextFitHeight`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconTextFitPadding; +@property (nonatomic, null_resettable) MGLStyleValue *iconTextFitPadding; /** A string with {tokens} replaced, referencing the data property to pull from. */ -@property (nonatomic, null_resettable) id iconImage; +@property (nonatomic, null_resettable) MGLStyleValue *iconImage; /** Rotates the icon clockwise. This property is measured in degrees. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconRotate; +@property (nonatomic, null_resettable) MGLStyleValue *iconRotate; /** Size of the additional area around the icon bounding box used for detecting symbol collisions. This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `2`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `2`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconPadding; +@property (nonatomic, null_resettable) MGLStyleValue *iconPadding; /** If true, the icon may be flipped to prevent it from being rendered upside-down. - The default value of this property is an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `iconImage` is non-`nil`, and `iconRotationAlignment` is set to an `NSValue` object containing `MGLIconRotationAlignmentMap`, and `symbolPlacement` is set to an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. + This property is only applied to the style if `iconImage` is non-`nil`, and `iconRotationAlignment` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLIconRotationAlignmentMap`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconKeepUpright; +@property (nonatomic, null_resettable) MGLStyleValue *iconKeepUpright; /** Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. - The default value of this property is an `NSValue` object containing a `CGVector` struct set to 0 from the left and 0 from the top. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing a `CGVector` struct set to 0 from the left and 0 from the top. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconOffset; +@property (nonatomic, null_resettable) MGLStyleValue *iconOffset; /** Orientation of text when map is pitched. - The default value of this property is an `NSValue` object containing `MGLTextPitchAlignmentAuto`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextPitchAlignmentAuto`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textPitchAlignment; +@property (nonatomic, null_resettable) MGLStyleValue *textPitchAlignment; /** In combination with `symbolPlacement`, determines the rotation behavior of the individual glyphs forming the text. - The default value of this property is an `NSValue` object containing `MGLTextRotationAlignmentAuto`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextRotationAlignmentAuto`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textRotationAlignment; +@property (nonatomic, null_resettable) MGLStyleValue *textRotationAlignment; /** Value to use for a text label. Feature properties are specified using tokens like {field_name}. - The default value of this property is the string ``. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing the string ``. Set this property to `nil` to reset it to the default value. */ -@property (nonatomic, null_resettable) id textField; +@property (nonatomic, null_resettable) MGLStyleValue *textField; /** Font stack to use for displaying text. - The default value of this property is the array `Open Sans Regular`, `Arial Unicode MS Regular`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing the array `Open Sans Regular`, `Arial Unicode MS Regular`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textFont; +@property (nonatomic, null_resettable) MGLStyleValue *> *textFont; /** Font size. This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `16`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `16`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textSize; +@property (nonatomic, null_resettable) MGLStyleValue *textSize; /** The maximum line width for text wrapping. This property is measured in ems. - The default value of this property is an `NSNumber` object containing the float `10`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `10`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textMaxWidth; +@property (nonatomic, null_resettable) MGLStyleValue *textMaxWidth; /** Text leading value for multi-line text. This property is measured in ems. - The default value of this property is an `NSNumber` object containing the float `1.2`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1.2`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textLineHeight; +@property (nonatomic, null_resettable) MGLStyleValue *textLineHeight; /** Text tracking amount. This property is measured in ems. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textLetterSpacing; +@property (nonatomic, null_resettable) MGLStyleValue *textLetterSpacing; /** Text justification options. - The default value of this property is an `NSValue` object containing `MGLTextJustifyCenter`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextJustifyCenter`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textJustify; +@property (nonatomic, null_resettable) MGLStyleValue *textJustify; /** Part of the text placed closest to the anchor. - The default value of this property is an `NSValue` object containing `MGLTextAnchorCenter`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextAnchorCenter`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textAnchor; +@property (nonatomic, null_resettable) MGLStyleValue *textAnchor; /** Maximum angle change between adjacent characters. This property is measured in degrees. - The default value of this property is an `NSNumber` object containing the float `45`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `45`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`, and `symbolPlacement` is set to an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. + This property is only applied to the style if `textField` is non-`nil`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textMaxAngle; +@property (nonatomic, null_resettable) MGLStyleValue *textMaxAngle; /** Rotates the text clockwise. This property is measured in degrees. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textRotate; +@property (nonatomic, null_resettable) MGLStyleValue *textRotate; /** Size of the additional area around the text bounding box used for detecting symbol collisions. This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `2`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `2`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textPadding; +@property (nonatomic, null_resettable) MGLStyleValue *textPadding; /** If true, the text may be flipped vertically to prevent it from being rendered upside-down. - The default value of this property is an `NSNumber` object containing `YES`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `YES`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`, and `textRotationAlignment` is set to an `NSValue` object containing `MGLTextRotationAlignmentMap`, and `symbolPlacement` is set to an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. + This property is only applied to the style if `textField` is non-`nil`, and `textRotationAlignment` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextRotationAlignmentMap`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textKeepUpright; +@property (nonatomic, null_resettable) MGLStyleValue *textKeepUpright; /** Specifies how to capitalize text, similar to the CSS `text-transform` property. - The default value of this property is an `NSValue` object containing `MGLTextTransformNone`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextTransformNone`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textTransform; +@property (nonatomic, null_resettable) MGLStyleValue *textTransform; /** Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. This property is measured in ems. - The default value of this property is an `NSValue` object containing a `CGVector` struct set to 0 ems from the left and 0 ems from the top. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing a `CGVector` struct set to 0 ems from the left and 0 ems from the top. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textOffset; +@property (nonatomic, null_resettable) MGLStyleValue *textOffset; /** If true, the text will be visible even if it collides with other previously drawn symbols. - The default value of this property is an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textAllowOverlap; +@property (nonatomic, null_resettable) MGLStyleValue *textAllowOverlap; /** If true, other symbols can be visible even if they collide with the text. - The default value of this property is an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textIgnorePlacement; +@property (nonatomic, null_resettable) MGLStyleValue *textIgnorePlacement; /** If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not. - The default value of this property is an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`, and `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textOptional; +@property (nonatomic, null_resettable) MGLStyleValue *textOptional; #pragma mark - Accessing the Paint Attributes /** The opacity at which the icon will be drawn. - The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconOpacity; +@property (nonatomic, null_resettable) MGLStyleValue *iconOpacity; #if TARGET_OS_IPHONE /** The color of the icon. This can only be used with sdf icons. - The default value of this property is `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconColor; +@property (nonatomic, null_resettable) MGLStyleValue *iconColor; #else /** The color of the icon. This can only be used with sdf icons. - The default value of this property is `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconColor; +@property (nonatomic, null_resettable) MGLStyleValue *iconColor; #endif #if TARGET_OS_IPHONE /** The color of the icon's halo. Icon halos can only be used with SDF icons. - The default value of this property is `UIColor.clearColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `UIColor.clearColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconHaloColor; +@property (nonatomic, null_resettable) MGLStyleValue *iconHaloColor; #else /** The color of the icon's halo. Icon halos can only be used with SDF icons. - The default value of this property is `NSColor.clearColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `NSColor.clearColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconHaloColor; +@property (nonatomic, null_resettable) MGLStyleValue *iconHaloColor; #endif /** @@ -608,90 +608,90 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconHaloWidth; +@property (nonatomic, null_resettable) MGLStyleValue *iconHaloWidth; /** Fade out the halo towards the outside. This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconHaloBlur; +@property (nonatomic, null_resettable) MGLStyleValue *iconHaloBlur; /** Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. This property is measured in points. - The default value of this property is an `NSValue` object containing a `CGVector` struct set to 0 points from the left and 0 points from the top. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing a `CGVector` struct set to 0 points from the left and 0 points from the top. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconTranslate; +@property (nonatomic, null_resettable) MGLStyleValue *iconTranslate; /** Controls the translation reference point. - The default value of this property is an `NSValue` object containing `MGLIconTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLIconTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImage` is non-`nil`, and `iconTranslate` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id iconTranslateAnchor; +@property (nonatomic, null_resettable) MGLStyleValue *iconTranslateAnchor; /** The opacity at which the text will be drawn. - The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textOpacity; +@property (nonatomic, null_resettable) MGLStyleValue *textOpacity; #if TARGET_OS_IPHONE /** The color with which the text will be drawn. - The default value of this property is `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `UIColor.blackColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textColor; +@property (nonatomic, null_resettable) MGLStyleValue *textColor; #else /** The color with which the text will be drawn. - The default value of this property is `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `NSColor.blackColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textColor; +@property (nonatomic, null_resettable) MGLStyleValue *textColor; #endif #if TARGET_OS_IPHONE /** The color of the text's halo, which helps it stand out from backgrounds. - The default value of this property is `UIColor.clearColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `UIColor.clearColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textHaloColor; +@property (nonatomic, null_resettable) MGLStyleValue *textHaloColor; #else /** The color of the text's halo, which helps it stand out from backgrounds. - The default value of this property is `NSColor.clearColor`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing `NSColor.clearColor`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textHaloColor; +@property (nonatomic, null_resettable) MGLStyleValue *textHaloColor; #endif /** @@ -699,42 +699,42 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textHaloWidth; +@property (nonatomic, null_resettable) MGLStyleValue *textHaloWidth; /** The halo's fadeout distance towards the outside. This property is measured in points. - The default value of this property is an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textHaloBlur; +@property (nonatomic, null_resettable) MGLStyleValue *textHaloBlur; /** Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up. This property is measured in points. - The default value of this property is an `NSValue` object containing a `CGVector` struct set to 0 points from the left and 0 points from the top. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing a `CGVector` struct set to 0 points from the left and 0 points from the top. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textTranslate; +@property (nonatomic, null_resettable) MGLStyleValue *textTranslate; /** Controls the translation reference point. - The default value of this property is an `NSValue` object containing `MGLTextTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextTranslateAnchorMap`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`, and `textTranslate` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) id textTranslateAnchor; +@property (nonatomic, null_resettable) MGLStyleValue *textTranslateAnchor; @end diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 01ac10f66f..a4c56fe297 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -4,7 +4,7 @@ #import "MGLSource.h" #import "NSPredicate+MGLAdditions.h" #import "MGLStyleLayer_Private.h" -#import "MGLStyleAttributeValue.h" +#import "MGLStyleValue_Private.h" #import "MGLSymbolStyleLayer.h" #include @@ -48,390 +48,486 @@ #pragma mark - Accessing the Layout Attributes -- (void)setSymbolPlacement:(id )symbolPlacement { - MGLSetEnumProperty(symbolPlacement, SymbolPlacement, SymbolPlacementType, MGLSymbolPlacement); +- (void)setSymbolPlacement:(MGLStyleValue *)symbolPlacement { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(symbolPlacement); + self.layer->setSymbolPlacement(mbglValue); } -- (id )symbolPlacement { - MGLGetEnumProperty(SymbolPlacement, SymbolPlacementType, MGLSymbolPlacement); +- (MGLStyleValue *)symbolPlacement { + auto propertyValue = self.layer->getSymbolPlacement() ?: self.layer->getDefaultSymbolPlacement(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setSymbolSpacing:(id )symbolSpacing { - self.layer->setSymbolSpacing(symbolSpacing.mbgl_floatPropertyValue); +- (void)setSymbolSpacing:(MGLStyleValue *)symbolSpacing { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(symbolSpacing); + self.layer->setSymbolSpacing(mbglValue); } -- (id )symbolSpacing { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getSymbolSpacing() ?: self.layer->getDefaultSymbolSpacing()]; +- (MGLStyleValue *)symbolSpacing { + auto propertyValue = self.layer->getSymbolSpacing() ?: self.layer->getDefaultSymbolSpacing(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setSymbolAvoidEdges:(id )symbolAvoidEdges { - self.layer->setSymbolAvoidEdges(symbolAvoidEdges.mbgl_boolPropertyValue); +- (void)setSymbolAvoidEdges:(MGLStyleValue *)symbolAvoidEdges { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(symbolAvoidEdges); + self.layer->setSymbolAvoidEdges(mbglValue); } -- (id )symbolAvoidEdges { - return [MGLStyleAttribute mbgl_boolWithPropertyValueBool:self.layer->getSymbolAvoidEdges() ?: self.layer->getDefaultSymbolAvoidEdges()]; +- (MGLStyleValue *)symbolAvoidEdges { + auto propertyValue = self.layer->getSymbolAvoidEdges() ?: self.layer->getDefaultSymbolAvoidEdges(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconAllowOverlap:(id )iconAllowOverlap { - self.layer->setIconAllowOverlap(iconAllowOverlap.mbgl_boolPropertyValue); +- (void)setIconAllowOverlap:(MGLStyleValue *)iconAllowOverlap { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconAllowOverlap); + self.layer->setIconAllowOverlap(mbglValue); } -- (id )iconAllowOverlap { - return [MGLStyleAttribute mbgl_boolWithPropertyValueBool:self.layer->getIconAllowOverlap() ?: self.layer->getDefaultIconAllowOverlap()]; +- (MGLStyleValue *)iconAllowOverlap { + auto propertyValue = self.layer->getIconAllowOverlap() ?: self.layer->getDefaultIconAllowOverlap(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconIgnorePlacement:(id )iconIgnorePlacement { - self.layer->setIconIgnorePlacement(iconIgnorePlacement.mbgl_boolPropertyValue); +- (void)setIconIgnorePlacement:(MGLStyleValue *)iconIgnorePlacement { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconIgnorePlacement); + self.layer->setIconIgnorePlacement(mbglValue); } -- (id )iconIgnorePlacement { - return [MGLStyleAttribute mbgl_boolWithPropertyValueBool:self.layer->getIconIgnorePlacement() ?: self.layer->getDefaultIconIgnorePlacement()]; +- (MGLStyleValue *)iconIgnorePlacement { + auto propertyValue = self.layer->getIconIgnorePlacement() ?: self.layer->getDefaultIconIgnorePlacement(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconOptional:(id )iconOptional { - self.layer->setIconOptional(iconOptional.mbgl_boolPropertyValue); +- (void)setIconOptional:(MGLStyleValue *)iconOptional { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconOptional); + self.layer->setIconOptional(mbglValue); } -- (id )iconOptional { - return [MGLStyleAttribute mbgl_boolWithPropertyValueBool:self.layer->getIconOptional() ?: self.layer->getDefaultIconOptional()]; +- (MGLStyleValue *)iconOptional { + auto propertyValue = self.layer->getIconOptional() ?: self.layer->getDefaultIconOptional(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconRotationAlignment:(id )iconRotationAlignment { - MGLSetEnumProperty(iconRotationAlignment, IconRotationAlignment, AlignmentType, MGLIconRotationAlignment); +- (void)setIconRotationAlignment:(MGLStyleValue *)iconRotationAlignment { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconRotationAlignment); + self.layer->setIconRotationAlignment(mbglValue); } -- (id )iconRotationAlignment { - MGLGetEnumProperty(IconRotationAlignment, AlignmentType, MGLIconRotationAlignment); +- (MGLStyleValue *)iconRotationAlignment { + auto propertyValue = self.layer->getIconRotationAlignment() ?: self.layer->getDefaultIconRotationAlignment(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconSize:(id )iconSize { - self.layer->setIconSize(iconSize.mbgl_floatPropertyValue); +- (void)setIconSize:(MGLStyleValue *)iconSize { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconSize); + self.layer->setIconSize(mbglValue); } -- (id )iconSize { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getIconSize() ?: self.layer->getDefaultIconSize()]; +- (MGLStyleValue *)iconSize { + auto propertyValue = self.layer->getIconSize() ?: self.layer->getDefaultIconSize(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconTextFit:(id )iconTextFit { - MGLSetEnumProperty(iconTextFit, IconTextFit, IconTextFitType, MGLIconTextFit); +- (void)setIconTextFit:(MGLStyleValue *)iconTextFit { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconTextFit); + self.layer->setIconTextFit(mbglValue); } -- (id )iconTextFit { - MGLGetEnumProperty(IconTextFit, IconTextFitType, MGLIconTextFit); +- (MGLStyleValue *)iconTextFit { + auto propertyValue = self.layer->getIconTextFit() ?: self.layer->getDefaultIconTextFit(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconTextFitPadding:(id )iconTextFitPadding { - self.layer->setIconTextFitPadding(iconTextFitPadding.mbgl_paddingPropertyValue); +- (void)setIconTextFitPadding:(MGLStyleValue *)iconTextFitPadding { + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(iconTextFitPadding); + self.layer->setIconTextFitPadding(mbglValue); } -- (id )iconTextFitPadding { - return [MGLStyleAttribute mbgl_paddingWithPropertyValuePadding:self.layer->getIconTextFitPadding() ?: self.layer->getDefaultIconTextFitPadding()]; +- (MGLStyleValue *)iconTextFitPadding { + auto propertyValue = self.layer->getIconTextFitPadding() ?: self.layer->getDefaultIconTextFitPadding(); + return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } -- (void)setIconImage:(id )iconImage { - self.layer->setIconImage(iconImage.mbgl_stringPropertyValue); +- (void)setIconImage:(MGLStyleValue *)iconImage { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconImage); + self.layer->setIconImage(mbglValue); } -- (id )iconImage { - return [MGLStyleAttribute mbgl_stringWithPropertyValueString:self.layer->getIconImage() ?: self.layer->getDefaultIconImage()]; +- (MGLStyleValue *)iconImage { + auto propertyValue = self.layer->getIconImage() ?: self.layer->getDefaultIconImage(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconRotate:(id )iconRotate { - self.layer->setIconRotate(iconRotate.mbgl_floatPropertyValue); +- (void)setIconRotate:(MGLStyleValue *)iconRotate { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconRotate); + self.layer->setIconRotate(mbglValue); } -- (id )iconRotate { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getIconRotate() ?: self.layer->getDefaultIconRotate()]; +- (MGLStyleValue *)iconRotate { + auto propertyValue = self.layer->getIconRotate() ?: self.layer->getDefaultIconRotate(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconPadding:(id )iconPadding { - self.layer->setIconPadding(iconPadding.mbgl_floatPropertyValue); +- (void)setIconPadding:(MGLStyleValue *)iconPadding { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconPadding); + self.layer->setIconPadding(mbglValue); } -- (id )iconPadding { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getIconPadding() ?: self.layer->getDefaultIconPadding()]; +- (MGLStyleValue *)iconPadding { + auto propertyValue = self.layer->getIconPadding() ?: self.layer->getDefaultIconPadding(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconKeepUpright:(id )iconKeepUpright { - self.layer->setIconKeepUpright(iconKeepUpright.mbgl_boolPropertyValue); +- (void)setIconKeepUpright:(MGLStyleValue *)iconKeepUpright { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconKeepUpright); + self.layer->setIconKeepUpright(mbglValue); } -- (id )iconKeepUpright { - return [MGLStyleAttribute mbgl_boolWithPropertyValueBool:self.layer->getIconKeepUpright() ?: self.layer->getDefaultIconKeepUpright()]; +- (MGLStyleValue *)iconKeepUpright { + auto propertyValue = self.layer->getIconKeepUpright() ?: self.layer->getDefaultIconKeepUpright(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconOffset:(id )iconOffset { - self.layer->setIconOffset(iconOffset.mbgl_offsetPropertyValue); +- (void)setIconOffset:(MGLStyleValue *)iconOffset { + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(iconOffset); + self.layer->setIconOffset(mbglValue); } -- (id )iconOffset { - return [MGLStyleAttribute mbgl_offsetWithPropertyValueOffset:self.layer->getIconOffset() ?: self.layer->getDefaultIconOffset()]; +- (MGLStyleValue *)iconOffset { + auto propertyValue = self.layer->getIconOffset() ?: self.layer->getDefaultIconOffset(); + return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } -- (void)setTextPitchAlignment:(id )textPitchAlignment { - MGLSetEnumProperty(textPitchAlignment, TextPitchAlignment, AlignmentType, MGLTextPitchAlignment); +- (void)setTextPitchAlignment:(MGLStyleValue *)textPitchAlignment { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textPitchAlignment); + self.layer->setTextPitchAlignment(mbglValue); } -- (id )textPitchAlignment { - MGLGetEnumProperty(TextPitchAlignment, AlignmentType, MGLTextPitchAlignment); +- (MGLStyleValue *)textPitchAlignment { + auto propertyValue = self.layer->getTextPitchAlignment() ?: self.layer->getDefaultTextPitchAlignment(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextRotationAlignment:(id )textRotationAlignment { - MGLSetEnumProperty(textRotationAlignment, TextRotationAlignment, AlignmentType, MGLTextRotationAlignment); +- (void)setTextRotationAlignment:(MGLStyleValue *)textRotationAlignment { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textRotationAlignment); + self.layer->setTextRotationAlignment(mbglValue); } -- (id )textRotationAlignment { - MGLGetEnumProperty(TextRotationAlignment, AlignmentType, MGLTextRotationAlignment); +- (MGLStyleValue *)textRotationAlignment { + auto propertyValue = self.layer->getTextRotationAlignment() ?: self.layer->getDefaultTextRotationAlignment(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextField:(id )textField { - self.layer->setTextField(textField.mbgl_stringPropertyValue); +- (void)setTextField:(MGLStyleValue *)textField { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textField); + self.layer->setTextField(mbglValue); } -- (id )textField { - return [MGLStyleAttribute mbgl_stringWithPropertyValueString:self.layer->getTextField() ?: self.layer->getDefaultTextField()]; +- (MGLStyleValue *)textField { + auto propertyValue = self.layer->getTextField() ?: self.layer->getDefaultTextField(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextFont:(id )textFont { - self.layer->setTextFont(textFont.mbgl_stringArrayPropertyValue); +- (void)setTextFont:(MGLStyleValue *> *)textFont { + auto mbglValue = MGLStyleValueTransformer, NSArray *, std::string>().toPropertyValue(textFont); + self.layer->setTextFont(mbglValue); } -- (id )textFont { - return [MGLStyleAttribute mbgl_stringArrayWithPropertyValueStringArray:self.layer->getTextFont() ?: self.layer->getDefaultTextFont()]; +- (MGLStyleValue *> *)textFont { + auto propertyValue = self.layer->getTextFont() ?: self.layer->getDefaultTextFont(); + return MGLStyleValueTransformer, NSArray *, std::string>().toStyleValue(propertyValue); } -- (void)setTextSize:(id )textSize { - self.layer->setTextSize(textSize.mbgl_floatPropertyValue); +- (void)setTextSize:(MGLStyleValue *)textSize { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textSize); + self.layer->setTextSize(mbglValue); } -- (id )textSize { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getTextSize() ?: self.layer->getDefaultTextSize()]; +- (MGLStyleValue *)textSize { + auto propertyValue = self.layer->getTextSize() ?: self.layer->getDefaultTextSize(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextMaxWidth:(id )textMaxWidth { - self.layer->setTextMaxWidth(textMaxWidth.mbgl_floatPropertyValue); +- (void)setTextMaxWidth:(MGLStyleValue *)textMaxWidth { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textMaxWidth); + self.layer->setTextMaxWidth(mbglValue); } -- (id )textMaxWidth { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getTextMaxWidth() ?: self.layer->getDefaultTextMaxWidth()]; +- (MGLStyleValue *)textMaxWidth { + auto propertyValue = self.layer->getTextMaxWidth() ?: self.layer->getDefaultTextMaxWidth(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextLineHeight:(id )textLineHeight { - self.layer->setTextLineHeight(textLineHeight.mbgl_floatPropertyValue); +- (void)setTextLineHeight:(MGLStyleValue *)textLineHeight { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textLineHeight); + self.layer->setTextLineHeight(mbglValue); } -- (id )textLineHeight { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getTextLineHeight() ?: self.layer->getDefaultTextLineHeight()]; +- (MGLStyleValue *)textLineHeight { + auto propertyValue = self.layer->getTextLineHeight() ?: self.layer->getDefaultTextLineHeight(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextLetterSpacing:(id )textLetterSpacing { - self.layer->setTextLetterSpacing(textLetterSpacing.mbgl_floatPropertyValue); +- (void)setTextLetterSpacing:(MGLStyleValue *)textLetterSpacing { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textLetterSpacing); + self.layer->setTextLetterSpacing(mbglValue); } -- (id )textLetterSpacing { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getTextLetterSpacing() ?: self.layer->getDefaultTextLetterSpacing()]; +- (MGLStyleValue *)textLetterSpacing { + auto propertyValue = self.layer->getTextLetterSpacing() ?: self.layer->getDefaultTextLetterSpacing(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextJustify:(id )textJustify { - MGLSetEnumProperty(textJustify, TextJustify, TextJustifyType, MGLTextJustify); +- (void)setTextJustify:(MGLStyleValue *)textJustify { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textJustify); + self.layer->setTextJustify(mbglValue); } -- (id )textJustify { - MGLGetEnumProperty(TextJustify, TextJustifyType, MGLTextJustify); +- (MGLStyleValue *)textJustify { + auto propertyValue = self.layer->getTextJustify() ?: self.layer->getDefaultTextJustify(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextAnchor:(id )textAnchor { - MGLSetEnumProperty(textAnchor, TextAnchor, TextAnchorType, MGLTextAnchor); +- (void)setTextAnchor:(MGLStyleValue *)textAnchor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textAnchor); + self.layer->setTextAnchor(mbglValue); } -- (id )textAnchor { - MGLGetEnumProperty(TextAnchor, TextAnchorType, MGLTextAnchor); +- (MGLStyleValue *)textAnchor { + auto propertyValue = self.layer->getTextAnchor() ?: self.layer->getDefaultTextAnchor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextMaxAngle:(id )textMaxAngle { - self.layer->setTextMaxAngle(textMaxAngle.mbgl_floatPropertyValue); +- (void)setTextMaxAngle:(MGLStyleValue *)textMaxAngle { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textMaxAngle); + self.layer->setTextMaxAngle(mbglValue); } -- (id )textMaxAngle { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getTextMaxAngle() ?: self.layer->getDefaultTextMaxAngle()]; +- (MGLStyleValue *)textMaxAngle { + auto propertyValue = self.layer->getTextMaxAngle() ?: self.layer->getDefaultTextMaxAngle(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextRotate:(id )textRotate { - self.layer->setTextRotate(textRotate.mbgl_floatPropertyValue); +- (void)setTextRotate:(MGLStyleValue *)textRotate { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textRotate); + self.layer->setTextRotate(mbglValue); } -- (id )textRotate { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getTextRotate() ?: self.layer->getDefaultTextRotate()]; +- (MGLStyleValue *)textRotate { + auto propertyValue = self.layer->getTextRotate() ?: self.layer->getDefaultTextRotate(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextPadding:(id )textPadding { - self.layer->setTextPadding(textPadding.mbgl_floatPropertyValue); +- (void)setTextPadding:(MGLStyleValue *)textPadding { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textPadding); + self.layer->setTextPadding(mbglValue); } -- (id )textPadding { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getTextPadding() ?: self.layer->getDefaultTextPadding()]; +- (MGLStyleValue *)textPadding { + auto propertyValue = self.layer->getTextPadding() ?: self.layer->getDefaultTextPadding(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextKeepUpright:(id )textKeepUpright { - self.layer->setTextKeepUpright(textKeepUpright.mbgl_boolPropertyValue); +- (void)setTextKeepUpright:(MGLStyleValue *)textKeepUpright { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textKeepUpright); + self.layer->setTextKeepUpright(mbglValue); } -- (id )textKeepUpright { - return [MGLStyleAttribute mbgl_boolWithPropertyValueBool:self.layer->getTextKeepUpright() ?: self.layer->getDefaultTextKeepUpright()]; +- (MGLStyleValue *)textKeepUpright { + auto propertyValue = self.layer->getTextKeepUpright() ?: self.layer->getDefaultTextKeepUpright(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextTransform:(id )textTransform { - MGLSetEnumProperty(textTransform, TextTransform, TextTransformType, MGLTextTransform); +- (void)setTextTransform:(MGLStyleValue *)textTransform { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textTransform); + self.layer->setTextTransform(mbglValue); } -- (id )textTransform { - MGLGetEnumProperty(TextTransform, TextTransformType, MGLTextTransform); +- (MGLStyleValue *)textTransform { + auto propertyValue = self.layer->getTextTransform() ?: self.layer->getDefaultTextTransform(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextOffset:(id )textOffset { - self.layer->setTextOffset(textOffset.mbgl_offsetPropertyValue); +- (void)setTextOffset:(MGLStyleValue *)textOffset { + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(textOffset); + self.layer->setTextOffset(mbglValue); } -- (id )textOffset { - return [MGLStyleAttribute mbgl_offsetWithPropertyValueOffset:self.layer->getTextOffset() ?: self.layer->getDefaultTextOffset()]; +- (MGLStyleValue *)textOffset { + auto propertyValue = self.layer->getTextOffset() ?: self.layer->getDefaultTextOffset(); + return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } -- (void)setTextAllowOverlap:(id )textAllowOverlap { - self.layer->setTextAllowOverlap(textAllowOverlap.mbgl_boolPropertyValue); +- (void)setTextAllowOverlap:(MGLStyleValue *)textAllowOverlap { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textAllowOverlap); + self.layer->setTextAllowOverlap(mbglValue); } -- (id )textAllowOverlap { - return [MGLStyleAttribute mbgl_boolWithPropertyValueBool:self.layer->getTextAllowOverlap() ?: self.layer->getDefaultTextAllowOverlap()]; +- (MGLStyleValue *)textAllowOverlap { + auto propertyValue = self.layer->getTextAllowOverlap() ?: self.layer->getDefaultTextAllowOverlap(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextIgnorePlacement:(id )textIgnorePlacement { - self.layer->setTextIgnorePlacement(textIgnorePlacement.mbgl_boolPropertyValue); +- (void)setTextIgnorePlacement:(MGLStyleValue *)textIgnorePlacement { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textIgnorePlacement); + self.layer->setTextIgnorePlacement(mbglValue); } -- (id )textIgnorePlacement { - return [MGLStyleAttribute mbgl_boolWithPropertyValueBool:self.layer->getTextIgnorePlacement() ?: self.layer->getDefaultTextIgnorePlacement()]; +- (MGLStyleValue *)textIgnorePlacement { + auto propertyValue = self.layer->getTextIgnorePlacement() ?: self.layer->getDefaultTextIgnorePlacement(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextOptional:(id )textOptional { - self.layer->setTextOptional(textOptional.mbgl_boolPropertyValue); +- (void)setTextOptional:(MGLStyleValue *)textOptional { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textOptional); + self.layer->setTextOptional(mbglValue); } -- (id )textOptional { - return [MGLStyleAttribute mbgl_boolWithPropertyValueBool:self.layer->getTextOptional() ?: self.layer->getDefaultTextOptional()]; +- (MGLStyleValue *)textOptional { + auto propertyValue = self.layer->getTextOptional() ?: self.layer->getDefaultTextOptional(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } #pragma mark - Accessing the Paint Attributes -- (void)setIconOpacity:(id )iconOpacity { - self.layer->setIconOpacity(iconOpacity.mbgl_floatPropertyValue); +- (void)setIconOpacity:(MGLStyleValue *)iconOpacity { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconOpacity); + self.layer->setIconOpacity(mbglValue); } -- (id )iconOpacity { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getIconOpacity() ?: self.layer->getDefaultIconOpacity()]; +- (MGLStyleValue *)iconOpacity { + auto propertyValue = self.layer->getIconOpacity() ?: self.layer->getDefaultIconOpacity(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconColor:(id )iconColor { - self.layer->setIconColor(iconColor.mbgl_colorPropertyValue); +- (void)setIconColor:(MGLStyleValue *)iconColor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconColor); + self.layer->setIconColor(mbglValue); } -- (id )iconColor { - return [MGLStyleAttribute mbgl_colorWithPropertyValueColor:self.layer->getIconColor() ?: self.layer->getDefaultIconColor()]; +- (MGLStyleValue *)iconColor { + auto propertyValue = self.layer->getIconColor() ?: self.layer->getDefaultIconColor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconHaloColor:(id )iconHaloColor { - self.layer->setIconHaloColor(iconHaloColor.mbgl_colorPropertyValue); +- (void)setIconHaloColor:(MGLStyleValue *)iconHaloColor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconHaloColor); + self.layer->setIconHaloColor(mbglValue); } -- (id )iconHaloColor { - return [MGLStyleAttribute mbgl_colorWithPropertyValueColor:self.layer->getIconHaloColor() ?: self.layer->getDefaultIconHaloColor()]; +- (MGLStyleValue *)iconHaloColor { + auto propertyValue = self.layer->getIconHaloColor() ?: self.layer->getDefaultIconHaloColor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconHaloWidth:(id )iconHaloWidth { - self.layer->setIconHaloWidth(iconHaloWidth.mbgl_floatPropertyValue); +- (void)setIconHaloWidth:(MGLStyleValue *)iconHaloWidth { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconHaloWidth); + self.layer->setIconHaloWidth(mbglValue); } -- (id )iconHaloWidth { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getIconHaloWidth() ?: self.layer->getDefaultIconHaloWidth()]; +- (MGLStyleValue *)iconHaloWidth { + auto propertyValue = self.layer->getIconHaloWidth() ?: self.layer->getDefaultIconHaloWidth(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconHaloBlur:(id )iconHaloBlur { - self.layer->setIconHaloBlur(iconHaloBlur.mbgl_floatPropertyValue); +- (void)setIconHaloBlur:(MGLStyleValue *)iconHaloBlur { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconHaloBlur); + self.layer->setIconHaloBlur(mbglValue); } -- (id )iconHaloBlur { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getIconHaloBlur() ?: self.layer->getDefaultIconHaloBlur()]; +- (MGLStyleValue *)iconHaloBlur { + auto propertyValue = self.layer->getIconHaloBlur() ?: self.layer->getDefaultIconHaloBlur(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconTranslate:(id )iconTranslate { - self.layer->setIconTranslate(iconTranslate.mbgl_offsetPropertyValue); +- (void)setIconTranslate:(MGLStyleValue *)iconTranslate { + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(iconTranslate); + self.layer->setIconTranslate(mbglValue); } -- (id )iconTranslate { - return [MGLStyleAttribute mbgl_offsetWithPropertyValueOffset:self.layer->getIconTranslate() ?: self.layer->getDefaultIconTranslate()]; +- (MGLStyleValue *)iconTranslate { + auto propertyValue = self.layer->getIconTranslate() ?: self.layer->getDefaultIconTranslate(); + return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } -- (void)setIconTranslateAnchor:(id )iconTranslateAnchor { - MGLSetEnumProperty(iconTranslateAnchor, IconTranslateAnchor, TranslateAnchorType, MGLIconTranslateAnchor); +- (void)setIconTranslateAnchor:(MGLStyleValue *)iconTranslateAnchor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconTranslateAnchor); + self.layer->setIconTranslateAnchor(mbglValue); } -- (id )iconTranslateAnchor { - MGLGetEnumProperty(IconTranslateAnchor, TranslateAnchorType, MGLIconTranslateAnchor); +- (MGLStyleValue *)iconTranslateAnchor { + auto propertyValue = self.layer->getIconTranslateAnchor() ?: self.layer->getDefaultIconTranslateAnchor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextOpacity:(id )textOpacity { - self.layer->setTextOpacity(textOpacity.mbgl_floatPropertyValue); +- (void)setTextOpacity:(MGLStyleValue *)textOpacity { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textOpacity); + self.layer->setTextOpacity(mbglValue); } -- (id )textOpacity { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getTextOpacity() ?: self.layer->getDefaultTextOpacity()]; +- (MGLStyleValue *)textOpacity { + auto propertyValue = self.layer->getTextOpacity() ?: self.layer->getDefaultTextOpacity(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextColor:(id )textColor { - self.layer->setTextColor(textColor.mbgl_colorPropertyValue); +- (void)setTextColor:(MGLStyleValue *)textColor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textColor); + self.layer->setTextColor(mbglValue); } -- (id )textColor { - return [MGLStyleAttribute mbgl_colorWithPropertyValueColor:self.layer->getTextColor() ?: self.layer->getDefaultTextColor()]; +- (MGLStyleValue *)textColor { + auto propertyValue = self.layer->getTextColor() ?: self.layer->getDefaultTextColor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextHaloColor:(id )textHaloColor { - self.layer->setTextHaloColor(textHaloColor.mbgl_colorPropertyValue); +- (void)setTextHaloColor:(MGLStyleValue *)textHaloColor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textHaloColor); + self.layer->setTextHaloColor(mbglValue); } -- (id )textHaloColor { - return [MGLStyleAttribute mbgl_colorWithPropertyValueColor:self.layer->getTextHaloColor() ?: self.layer->getDefaultTextHaloColor()]; +- (MGLStyleValue *)textHaloColor { + auto propertyValue = self.layer->getTextHaloColor() ?: self.layer->getDefaultTextHaloColor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextHaloWidth:(id )textHaloWidth { - self.layer->setTextHaloWidth(textHaloWidth.mbgl_floatPropertyValue); +- (void)setTextHaloWidth:(MGLStyleValue *)textHaloWidth { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textHaloWidth); + self.layer->setTextHaloWidth(mbglValue); } -- (id )textHaloWidth { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getTextHaloWidth() ?: self.layer->getDefaultTextHaloWidth()]; +- (MGLStyleValue *)textHaloWidth { + auto propertyValue = self.layer->getTextHaloWidth() ?: self.layer->getDefaultTextHaloWidth(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextHaloBlur:(id )textHaloBlur { - self.layer->setTextHaloBlur(textHaloBlur.mbgl_floatPropertyValue); +- (void)setTextHaloBlur:(MGLStyleValue *)textHaloBlur { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textHaloBlur); + self.layer->setTextHaloBlur(mbglValue); } -- (id )textHaloBlur { - return [MGLStyleAttribute mbgl_numberWithPropertyValueNumber:self.layer->getTextHaloBlur() ?: self.layer->getDefaultTextHaloBlur()]; +- (MGLStyleValue *)textHaloBlur { + auto propertyValue = self.layer->getTextHaloBlur() ?: self.layer->getDefaultTextHaloBlur(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextTranslate:(id )textTranslate { - self.layer->setTextTranslate(textTranslate.mbgl_offsetPropertyValue); +- (void)setTextTranslate:(MGLStyleValue *)textTranslate { + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(textTranslate); + self.layer->setTextTranslate(mbglValue); } -- (id )textTranslate { - return [MGLStyleAttribute mbgl_offsetWithPropertyValueOffset:self.layer->getTextTranslate() ?: self.layer->getDefaultTextTranslate()]; +- (MGLStyleValue *)textTranslate { + auto propertyValue = self.layer->getTextTranslate() ?: self.layer->getDefaultTextTranslate(); + return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } -- (void)setTextTranslateAnchor:(id )textTranslateAnchor { - MGLSetEnumProperty(textTranslateAnchor, TextTranslateAnchor, TranslateAnchorType, MGLTextTranslateAnchor); +- (void)setTextTranslateAnchor:(MGLStyleValue *)textTranslateAnchor { + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textTranslateAnchor); + self.layer->setTextTranslateAnchor(mbglValue); } -- (id )textTranslateAnchor { - MGLGetEnumProperty(TextTranslateAnchor, TranslateAnchorType, MGLTextTranslateAnchor); +- (MGLStyleValue *)textTranslateAnchor { + auto propertyValue = self.layer->getTextTranslateAnchor() ?: self.layer->getDefaultTextTranslateAnchor(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); } @end diff --git a/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.h deleted file mode 100644 index fa5193acf0..0000000000 --- a/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.h +++ /dev/null @@ -1,7 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" - -@interface NSArray (MGLStyleAttributeAdditions) - -@end diff --git a/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.mm deleted file mode 100644 index fb60cf0f72..0000000000 --- a/platform/darwin/src/NSArray+MGLStyleAttributeAdditions.mm +++ /dev/null @@ -1,36 +0,0 @@ -#import "NSArray+MGLStyleAttributeAdditions.h" - -#import "NSArray+MGLStyleAttributeAdditions_Private.h" -#import "MGLStyleAttributeValue_Private.h" - -#include - -@interface NSArray(Private) -@end - -@implementation NSArray (MGLStyleAttributeAdditions) - -- (mbgl::style::PropertyValue >)mbgl_stringArrayPropertyValue -{ - std::vectorfonts; - - for (NSString *font in self) { - fonts.emplace_back(font.UTF8String); - } - - return {{fonts}}; -} - -- (mbgl::style::PropertyValue >)mbgl_numberArrayPropertyValue -{ - std::vectorvalues; - - for (NSNumber *n in self) { - values.emplace_back(n.floatValue); - } - - return {{values}}; -} - - -@end diff --git a/platform/darwin/src/NSArray+MGLStyleAttributeAdditions_Private.h b/platform/darwin/src/NSArray+MGLStyleAttributeAdditions_Private.h deleted file mode 100644 index 1be02c01d2..0000000000 --- a/platform/darwin/src/NSArray+MGLStyleAttributeAdditions_Private.h +++ /dev/null @@ -1,9 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" - -#include - -@interface NSArray (MGLStyleAttributeAdditions_Private) - -@end diff --git a/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.h deleted file mode 100644 index 5a4f7af006..0000000000 --- a/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.h +++ /dev/null @@ -1,7 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" - -@interface NSColor (MGLStyleAttributeAdditions) - -@end diff --git a/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.m b/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.m deleted file mode 100644 index ac330343c8..0000000000 --- a/platform/darwin/src/NSColor+MGLStyleAttributeAdditions.m +++ /dev/null @@ -1,5 +0,0 @@ -#import "NSColor+MGLStyleAttributeAdditions.h" - -@implementation NSColor (MGLStyleAttributeAdditions) - -@end diff --git a/platform/darwin/src/NSColor+MGLStyleAttributeAdditions_Private.h b/platform/darwin/src/NSColor+MGLStyleAttributeAdditions_Private.h deleted file mode 100644 index 9a714cbd83..0000000000 --- a/platform/darwin/src/NSColor+MGLStyleAttributeAdditions_Private.h +++ /dev/null @@ -1,9 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" - -#include - -@interface NSColor (MGLStyleAttributeAdditions_Private) - -@end diff --git a/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.h deleted file mode 100644 index 162b5e94f5..0000000000 --- a/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.h +++ /dev/null @@ -1,7 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" - -@interface NSNumber (MGLStyleAttributeAdditions) - -@end diff --git a/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.mm deleted file mode 100644 index 163105d2fa..0000000000 --- a/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions.mm +++ /dev/null @@ -1,22 +0,0 @@ -#import "NSNumber+MGLStyleAttributeAdditions.h" - -#include - -@implementation NSNumber (MGLStyleAttributeAdditions) - -- (NSNumber *)numberValue -{ - return self; -} - -- (mbgl::style::PropertyValue)mbgl_boolPropertyValue -{ - return mbgl::style::PropertyValue { !!self.boolValue }; -} - -- (mbgl::style::PropertyValue)mbgl_floatPropertyValue -{ - return mbgl::style::PropertyValue { self.floatValue }; -} - -@end diff --git a/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions_Private.h b/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions_Private.h deleted file mode 100644 index 73e40bb3ad..0000000000 --- a/platform/darwin/src/NSNumber+MGLStyleAttributeAdditions_Private.h +++ /dev/null @@ -1,13 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" - -#include - -@interface NSNumber (MGLStyleAttributeAdditions_Private) - -- (mbgl::style::PropertyValue)mbgl_booleanPropertyValue; - -- (mbgl::style::PropertyValue)mbgl_numberPropertyValue; - -@end diff --git a/platform/darwin/src/NSString+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSString+MGLStyleAttributeAdditions.h deleted file mode 100644 index 2126335922..0000000000 --- a/platform/darwin/src/NSString+MGLStyleAttributeAdditions.h +++ /dev/null @@ -1,7 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" - -@interface NSString (MGLStyleAttributeAdditions) - -@end diff --git a/platform/darwin/src/NSString+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSString+MGLStyleAttributeAdditions.mm deleted file mode 100644 index ff88f5501a..0000000000 --- a/platform/darwin/src/NSString+MGLStyleAttributeAdditions.mm +++ /dev/null @@ -1,17 +0,0 @@ -#import "NSString+MGLStyleAttributeAdditions.h" - -#import "NSString+MGLStyleAttributeAdditions_Private.h" - -@implementation NSString (MGLStyleAttributeAdditions) - -- (BOOL)isFunction -{ - return NO; -} - -- (mbgl::style::PropertyValue)mbgl_stringPropertyValue -{ - return mbgl::style::PropertyValue {{ self.UTF8String }}; -} - -@end diff --git a/platform/darwin/src/NSString+MGLStyleAttributeAdditions_Private.h b/platform/darwin/src/NSString+MGLStyleAttributeAdditions_Private.h deleted file mode 100644 index 8e401e2996..0000000000 --- a/platform/darwin/src/NSString+MGLStyleAttributeAdditions_Private.h +++ /dev/null @@ -1,11 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" - -#include - -@interface NSString (MGLStyleAttributeAdditions_Private) - -- (mbgl::style::PropertyValue)mbgl_stringPropertyValue; - -@end diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h index 0ee0c78f87..60c1ee4075 100644 --- a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h +++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h @@ -1,7 +1,13 @@ #import -#import "MGLStyleAttributeValue.h" +#include -@interface NSValue (MGLStyleAttributeValue) +@interface NSValue (MGLStyleAttributeAdditions) + ++ (instancetype)mgl_valueWithOffsetArray:(std::array)offsetArray; ++ (instancetype)mgl_valueWithPaddingArray:(std::array)paddingArray; + +- (std::array)mgl_offsetArrayValue; +- (std::array)mgl_paddingArrayValue; @end diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm index 83266e7db5..59afe559d7 100644 --- a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm +++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm @@ -1,9 +1,5 @@ #import "NSValue+MGLStyleAttributeAdditions.h" -#import "NSValue+MGLStyleAttributeAdditions_Private.h" - -#include - #if TARGET_OS_IPHONE #import #define MGLEdgeInsets UIEdgeInsets @@ -32,16 +28,6 @@ return [NSValue value:&insets withObjCType:@encode(MGLEdgeInsets)]; } -- (BOOL)isFunction -{ - return NO; -} - -- (mbgl::style::PropertyValue>)mbgl_offsetPropertyValue -{ - return { self.mgl_offsetArrayValue }; -} - - (std::array)mgl_offsetArrayValue { NSAssert(strcmp(self.objCType, @encode(CGVector)) == 0, @"Value does not represent a CGVector"); @@ -53,11 +39,6 @@ }; } -- (mbgl::style::PropertyValue>)mbgl_paddingPropertyValue -{ - return { self.mgl_paddingArrayValue }; -} - - (std::array)mgl_paddingArrayValue { NSAssert(strcmp(self.objCType, @encode(MGLEdgeInsets)) == 0, @"Value does not represent an NSEdgeInsets/UIEdgeInsets"); diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions_Private.h b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions_Private.h deleted file mode 100644 index 28a9b10908..0000000000 --- a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions_Private.h +++ /dev/null @@ -1,15 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" - -#include - -@interface NSValue (MGLStyleAttributeAdditions_Private) - -+ (instancetype)mgl_valueWithOffsetArray:(std::array)offsetArray; -+ (instancetype)mgl_valueWithPaddingArray:(std::array)paddingArray; - -- (std::array)mgl_offsetArrayValue; -- (std::array)mgl_paddingArrayValue; - -@end diff --git a/platform/darwin/src/UIColor+MGLStyleAttributeAdditions_Private.h b/platform/darwin/src/UIColor+MGLStyleAttributeAdditions_Private.h deleted file mode 100644 index ef886dca5d..0000000000 --- a/platform/darwin/src/UIColor+MGLStyleAttributeAdditions_Private.h +++ /dev/null @@ -1,9 +0,0 @@ -#import - -#import "MGLStyleAttributeValue.h" - -#include - -@interface UIColor (MGLStyleAttributeAdditions_Private) - -@end diff --git a/platform/darwin/test/MGLCircleStyleLayerTests.m b/platform/darwin/test/MGLCircleStyleLayerTests.m index 995802ff18..54ba8be6c1 100644 --- a/platform/darwin/test/MGLCircleStyleLayerTests.m +++ b/platform/darwin/test/MGLCircleStyleLayerTests.m @@ -31,8 +31,10 @@ XCTAssertEqualObjects(gLayer.circleBlur, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.circleOpacity, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.circleTranslate, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.circleTranslateAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]], @"%@ is not equal to %@", gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]); - XCTAssert([(NSValue *)gLayer.circlePitchScale isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]], @"%@ is not equal to %@", gLayer.circlePitchScale, [MGLRuntimeStylingHelper testEnum:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]); + XCTAssert([gLayer.circleTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]); + XCTAssert([gLayer.circlePitchScale isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.circlePitchScale, [MGLRuntimeStylingHelper testEnum:MGLCirclePitchScaleViewport type:@encode(MGLCirclePitchScale)]); layer.circleRadius = [MGLRuntimeStylingHelper testNumberFunction]; layer.circleColor = [MGLRuntimeStylingHelper testColorFunction]; diff --git a/platform/darwin/test/MGLFillStyleLayerTests.m b/platform/darwin/test/MGLFillStyleLayerTests.m index 21c2a9de40..7b31207902 100644 --- a/platform/darwin/test/MGLFillStyleLayerTests.m +++ b/platform/darwin/test/MGLFillStyleLayerTests.m @@ -31,7 +31,8 @@ XCTAssertEqualObjects(gLayer.fillColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.fillOutlineColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.fillTranslate, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.fillTranslateAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLFillTranslateAnchorViewport type:@encode(MGLFillTranslateAnchor)]], @"%@ is not equal to %@", gLayer.fillTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLFillTranslateAnchorViewport type:@encode(MGLFillTranslateAnchor)]); + XCTAssert([gLayer.fillTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.fillTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLFillTranslateAnchorViewport type:@encode(MGLFillTranslateAnchor)]); XCTAssertEqualObjects(gLayer.fillPattern, [MGLRuntimeStylingHelper testString]); layer.fillAntialias = [MGLRuntimeStylingHelper testBoolFunction]; diff --git a/platform/darwin/test/MGLLineStyleLayerTests.m b/platform/darwin/test/MGLLineStyleLayerTests.m index 79f0619f8a..801bc12ff8 100644 --- a/platform/darwin/test/MGLLineStyleLayerTests.m +++ b/platform/darwin/test/MGLLineStyleLayerTests.m @@ -33,14 +33,17 @@ MGLLineStyleLayer *gLayer = (MGLLineStyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; XCTAssertTrue([gLayer isKindOfClass:[MGLLineStyleLayer class]]); - XCTAssert([(NSValue *)gLayer.lineCap isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLLineCapSquare type:@encode(MGLLineCap)]], @"%@ is not equal to %@", gLayer.lineCap, [MGLRuntimeStylingHelper testEnum:MGLLineCapSquare type:@encode(MGLLineCap)]); - XCTAssert([(NSValue *)gLayer.lineJoin isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLLineJoinMiter type:@encode(MGLLineJoin)]], @"%@ is not equal to %@", gLayer.lineJoin, [MGLRuntimeStylingHelper testEnum:MGLLineJoinMiter type:@encode(MGLLineJoin)]); + XCTAssert([gLayer.lineCap isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.lineCap, [MGLRuntimeStylingHelper testEnum:MGLLineCapSquare type:@encode(MGLLineCap)]); + XCTAssert([gLayer.lineJoin isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.lineJoin, [MGLRuntimeStylingHelper testEnum:MGLLineJoinMiter type:@encode(MGLLineJoin)]); XCTAssertEqualObjects(gLayer.lineMiterLimit, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.lineRoundLimit, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.lineOpacity, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.lineColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.lineTranslate, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.lineTranslateAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLLineTranslateAnchorViewport type:@encode(MGLLineTranslateAnchor)]], @"%@ is not equal to %@", gLayer.lineTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLLineTranslateAnchorViewport type:@encode(MGLLineTranslateAnchor)]); + XCTAssert([gLayer.lineTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.lineTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLLineTranslateAnchorViewport type:@encode(MGLLineTranslateAnchor)]); XCTAssertEqualObjects(gLayer.lineWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.lineGapWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.lineOffset, [MGLRuntimeStylingHelper testNumber]); diff --git a/platform/darwin/test/MGLRuntimeStylingHelper.h b/platform/darwin/test/MGLRuntimeStylingHelper.h index 6626d13901..8857dba9c5 100644 --- a/platform/darwin/test/MGLRuntimeStylingHelper.h +++ b/platform/darwin/test/MGLRuntimeStylingHelper.h @@ -1,35 +1,35 @@ #import #import "MGLTypes.h" -#import "MGLStyleAttributeFunction.h" +#import "MGLStyleValue.h" @interface MGLRuntimeStylingHelper : NSObject -+ (NSArray *)testPadding; -+ (MGLStyleAttributeFunction *)testPaddingFunction; ++ (MGLStyleConstantValue *)testPadding; ++ (MGLStyleFunction *)testPaddingFunction; -+ (NSArray *)testOffset; -+ (MGLStyleAttributeFunction *)testOffsetFunction; ++ (MGLStyleConstantValue *)testOffset; ++ (MGLStyleFunction *)testOffsetFunction; -+ (NSArray *)testFont; -+ (MGLStyleAttributeFunction *)testFontFunction; ++ (MGLStyleConstantValue *> *)testFont; ++ (MGLStyleFunction *> *)testFontFunction; -+ (NSArray *)testDashArray; -+ (MGLStyleAttributeFunction *)testDashArrayFunction; ++ (MGLStyleConstantValue *> *)testDashArray; ++ (MGLStyleFunction *> *)testDashArrayFunction; -+ (NSNumber *)testNumber; -+ (MGLStyleAttributeFunction *)testNumberFunction; ++ (MGLStyleConstantValue *)testNumber; ++ (MGLStyleFunction *)testNumberFunction; -+ (NSNumber *)testBool; -+ (MGLStyleAttributeFunction *)testBoolFunction; ++ (MGLStyleConstantValue *)testBool; ++ (MGLStyleFunction *)testBoolFunction; -+ (NSString *)testString; -+ (MGLStyleAttributeFunction *)testStringFunction; ++ (MGLStyleConstantValue *)testString; ++ (MGLStyleFunction *)testStringFunction; -+ (MGLColor *)testColor; -+ (MGLStyleAttributeFunction *)testColorFunction; ++ (MGLStyleConstantValue *)testColor; ++ (MGLStyleFunction *)testColorFunction; -+ (NSValue *)testEnum:(NSUInteger)value type:(const char *)type; -+ (MGLStyleAttributeFunction *)testEnumFunction:(NSUInteger)value type:(const char *)type; ++ (MGLStyleConstantValue *)testEnum:(NSUInteger)value type:(const char *)type; ++ (MGLStyleFunction *)testEnumFunction:(NSUInteger)value type:(const char *)type; @end diff --git a/platform/darwin/test/MGLRuntimeStylingHelper.m b/platform/darwin/test/MGLRuntimeStylingHelper.m index 29e80086ec..955c664f2c 100644 --- a/platform/darwin/test/MGLRuntimeStylingHelper.m +++ b/platform/darwin/test/MGLRuntimeStylingHelper.m @@ -10,7 +10,7 @@ @implementation MGLRuntimeStylingHelper -+ (NSValue *)testPadding ++ (MGLStyleConstantValue *)testPadding { MGLEdgeInsets insets = { .top = 1, @@ -18,129 +18,105 @@ .bottom = 1, .right = 1, }; - return [NSValue value:&insets withObjCType:@encode(MGLEdgeInsets)]; + return [MGLStyleConstantValue valueWithRawValue:[NSValue value:&insets withObjCType:@encode(MGLEdgeInsets)]]; } -+ (MGLStyleAttributeFunction *)testPaddingFunction ++ (MGLStyleFunction *)testPaddingFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testPadding, - }; - return function; + return [MGLStyleFunction functionWithStops:@{@(18): self.testPadding}]; } -+ (NSValue *)testOffset ++ (MGLStyleConstantValue *)testOffset { CGVector vector = CGVectorMake(1, 1); - return [NSValue value:&vector withObjCType:@encode(CGVector)]; + return [MGLStyleConstantValue valueWithRawValue:[NSValue value:&vector withObjCType:@encode(CGVector)]]; } -+ (MGLStyleAttributeFunction *)testOffsetFunction ++ (MGLStyleFunction *)testOffsetFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testOffset, - }; - return function; + return [MGLStyleFunction valueWithStops:@{ @(18): self.testOffset }]; } -+ (NSArray *)testFont ++ (MGLStyleConstantValue *> *)testFont { - return @[@"Open Sans Regular", @"Arial Unicode MS Regular"]; + return [MGLStyleConstantValue *> valueWithRawValue:@[@"Open Sans Regular", @"Arial Unicode MS Regular"]]; } -+ (MGLStyleAttributeFunction *)testFontFunction ++ (MGLStyleFunction *> *)testFontFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testFont, - }; - return function; + return [MGLStyleFunction *> valueWithStops:@{ @18: self.testFont }]; } -+ (NSArray *)testDashArray ++ (MGLStyleConstantValue *> *)testDashArray { - return @[@1, @2]; + return [MGLStyleConstantValue *> valueWithRawValue:@[@1, @2]]; } -+ (MGLStyleAttributeFunction *)testDashArrayFunction ++ (MGLStyleFunction *> *)testDashArrayFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testDashArray, - }; - return function; + return [MGLStyleFunction *> valueWithStops:@{ + @18: self.testDashArray, + }]; } -+ (NSNumber *)testNumber ++ (MGLStyleConstantValue *)testNumber { - return @1; + return [MGLStyleConstantValue valueWithRawValue:@1]; } -+ (MGLStyleAttributeFunction *)testNumberFunction ++ (MGLStyleFunction *)testNumberFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testNumber, - }; - return function; + return [MGLStyleFunction valueWithStops:@{ + @18: self.testNumber, + }]; } -+ (NSNumber *)testBool ++ (MGLStyleConstantValue *)testBool { - return @YES; + return [MGLStyleConstantValue valueWithRawValue:@YES]; } -+ (MGLStyleAttributeFunction *)testBoolFunction ++ (MGLStyleFunction *)testBoolFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testBool, - }; - return function; + return [MGLStyleFunction valueWithStops:@{ + @18: self.testBool, + }]; } -+ (NSString *)testString ++ (MGLStyleConstantValue *)testString { - return @"test"; + return [MGLStyleConstantValue valueWithRawValue:@"test"]; } -+ (MGLStyleAttributeFunction *)testStringFunction ++ (MGLStyleFunction *)testStringFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testString, - }; - return function; + return [MGLStyleFunction valueWithStops:@{ + @18: self.testString, + }]; } -+ (MGLColor *)testColor ++ (MGLStyleConstantValue *)testColor { - return [MGLColor redColor]; + return [MGLStyleConstantValue valueWithRawValue:[MGLColor redColor]]; } -+ (MGLStyleAttributeFunction *)testColorFunction ++ (MGLStyleFunction *)testColorFunction { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): self.testColor, - }; - return function; + return [MGLStyleFunction valueWithStops:@{ + @18: self.testColor, + }]; } -+ (NSValue *)testEnum:(NSUInteger)value type:(const char *)type ++ (MGLStyleConstantValue *)testEnum:(NSUInteger)value type:(const char *)type { - return [NSValue value:&value withObjCType:type]; + return [MGLStyleConstantValue valueWithRawValue:[NSValue value:&value withObjCType:type]]; } -+ (MGLStyleAttributeFunction *)testEnumFunction:(NSUInteger)value type:(const char *)type ++ (MGLStyleFunction *)testEnumFunction:(NSUInteger)value type:(const char *)type { - MGLStyleAttributeFunction *function = [[MGLStyleAttributeFunction alloc] init]; - function.stops = @{ - @(18): [self testEnum:value type:type], - }; - return function; + return [MGLStyleFunction valueWithStops:@{ + @18: [self testEnum:value type:type], + }]; } @end diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.m b/platform/darwin/test/MGLSymbolStyleLayerTests.m index 208c30a630..f60ae7c2a8 100644 --- a/platform/darwin/test/MGLSymbolStyleLayerTests.m +++ b/platform/darwin/test/MGLSymbolStyleLayerTests.m @@ -67,36 +67,44 @@ MGLSymbolStyleLayer *gLayer = (MGLSymbolStyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; XCTAssertTrue([gLayer isKindOfClass:[MGLSymbolStyleLayer class]]); - XCTAssert([(NSValue *)gLayer.symbolPlacement isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]], @"%@ is not equal to %@", gLayer.symbolPlacement, [MGLRuntimeStylingHelper testEnum:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]); + XCTAssert([gLayer.symbolPlacement isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.symbolPlacement, [MGLRuntimeStylingHelper testEnum:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]); XCTAssertEqualObjects(gLayer.symbolSpacing, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.symbolAvoidEdges, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconAllowOverlap, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconIgnorePlacement, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconOptional, [MGLRuntimeStylingHelper testBool]); - XCTAssert([(NSValue *)gLayer.iconRotationAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]], @"%@ is not equal to %@", gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]); + XCTAssert([gLayer.iconRotationAlignment isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]); XCTAssertEqualObjects(gLayer.iconSize, [MGLRuntimeStylingHelper testNumber]); - XCTAssert([(NSValue *)gLayer.iconTextFit isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]], @"%@ is not equal to %@", gLayer.iconTextFit, [MGLRuntimeStylingHelper testEnum:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]); + XCTAssert([gLayer.iconTextFit isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.iconTextFit, [MGLRuntimeStylingHelper testEnum:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]); XCTAssertEqualObjects(gLayer.iconTextFitPadding, [MGLRuntimeStylingHelper testPadding]); XCTAssertEqualObjects(gLayer.iconImage, [MGLRuntimeStylingHelper testString]); XCTAssertEqualObjects(gLayer.iconRotate, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.iconPadding, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.iconKeepUpright, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconOffset, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.textPitchAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]], @"%@ is not equal to %@", gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnum:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]); - XCTAssert([(NSValue *)gLayer.textRotationAlignment isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]], @"%@ is not equal to %@", gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]); + XCTAssert([gLayer.textPitchAlignment isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnum:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]); + XCTAssert([gLayer.textRotationAlignment isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]); XCTAssertEqualObjects(gLayer.textField, [MGLRuntimeStylingHelper testString]); XCTAssertEqualObjects(gLayer.textFont, [MGLRuntimeStylingHelper testFont]); XCTAssertEqualObjects(gLayer.textSize, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textMaxWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textLineHeight, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textLetterSpacing, [MGLRuntimeStylingHelper testNumber]); - XCTAssert([(NSValue *)gLayer.textJustify isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLTextJustifyRight type:@encode(MGLTextJustify)]], @"%@ is not equal to %@", gLayer.textJustify, [MGLRuntimeStylingHelper testEnum:MGLTextJustifyRight type:@encode(MGLTextJustify)]); - XCTAssert([(NSValue *)gLayer.textAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]], @"%@ is not equal to %@", gLayer.textAnchor, [MGLRuntimeStylingHelper testEnum:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]); + XCTAssert([gLayer.textJustify isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textJustify, [MGLRuntimeStylingHelper testEnum:MGLTextJustifyRight type:@encode(MGLTextJustify)]); + XCTAssert([gLayer.textAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textAnchor, [MGLRuntimeStylingHelper testEnum:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]); XCTAssertEqualObjects(gLayer.textMaxAngle, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textRotate, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textPadding, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textKeepUpright, [MGLRuntimeStylingHelper testBool]); - XCTAssert([(NSValue *)gLayer.textTransform isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLTextTransformLowercase type:@encode(MGLTextTransform)]], @"%@ is not equal to %@", gLayer.textTransform, [MGLRuntimeStylingHelper testEnum:MGLTextTransformLowercase type:@encode(MGLTextTransform)]); + XCTAssert([gLayer.textTransform isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textTransform, [MGLRuntimeStylingHelper testEnum:MGLTextTransformLowercase type:@encode(MGLTextTransform)]); XCTAssertEqualObjects(gLayer.textOffset, [MGLRuntimeStylingHelper testOffset]); XCTAssertEqualObjects(gLayer.textAllowOverlap, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.textIgnorePlacement, [MGLRuntimeStylingHelper testBool]); @@ -107,14 +115,16 @@ XCTAssertEqualObjects(gLayer.iconHaloWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.iconHaloBlur, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.iconTranslate, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.iconTranslateAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLIconTranslateAnchorViewport type:@encode(MGLIconTranslateAnchor)]], @"%@ is not equal to %@", gLayer.iconTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLIconTranslateAnchorViewport type:@encode(MGLIconTranslateAnchor)]); + XCTAssert([gLayer.iconTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.iconTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLIconTranslateAnchorViewport type:@encode(MGLIconTranslateAnchor)]); XCTAssertEqualObjects(gLayer.textOpacity, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.textHaloColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.textHaloWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textHaloBlur, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textTranslate, [MGLRuntimeStylingHelper testOffset]); - XCTAssert([(NSValue *)gLayer.textTranslateAnchor isEqualToValue:[MGLRuntimeStylingHelper testEnum:MGLTextTranslateAnchorViewport type:@encode(MGLTextTranslateAnchor)]], @"%@ is not equal to %@", gLayer.textTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLTextTranslateAnchorViewport type:@encode(MGLTextTranslateAnchor)]); + XCTAssert([gLayer.textTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLTextTranslateAnchorViewport type:@encode(MGLTextTranslateAnchor)]); layer.symbolPlacement = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]; layer.symbolSpacing = [MGLRuntimeStylingHelper testNumberFunction]; -- cgit v1.2.1