diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/generate-style-code.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index c002718038..ae25a856a8 100755 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -19,6 +19,29 @@ global.isLightProperty = function (property) { return property['light-property'] === true; }; +global.isOverridable = function (property) { + return ['text-color'].includes(property.name); +}; + +global.expressionType = function (property) { + switch (property.type) { + case 'boolean': + return 'BooleanType'; + case 'number': + case 'enum': + return 'NumberType'; + case 'string': + return 'StringType'; + case 'color': + return `ColorType`; + case 'formatted': + return `FormattedType`; + case 'array': + return `Array<${expressionType({type: property.value})}>`; + default: throw new Error(`unknown type for ${property.name}`) + } +}; + global.evaluatedType = function (property) { if (/-translate-anchor$/.test(property.name)) { return 'TranslateAnchorType'; @@ -93,6 +116,8 @@ global.layoutPropertyType = function (property) { global.paintPropertyType = function (property, type) { switch (property['property-type']) { case 'data-driven': + if (isOverridable(property)) + return `DataDrivenPaintProperty<${evaluatedType(property)}, ${attributeUniformType(property, type)}, true>`; return `DataDrivenPaintProperty<${evaluatedType(property)}, ${attributeUniformType(property, type)}>`; case 'cross-faded-data-driven': return `CrossFadedDataDrivenPaintProperty<${evaluatedType(property)}, ${attributeUniformType(property, type)}>`; |