From feae5e22ee4910a1508f2120c8131b2f8531bae8 Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Thu, 4 May 2017 17:26:42 +0300 Subject: [core] generated accessor methods on light --- scripts/generate-style-code.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index 9629c8fe45..c169c4ecd5 100644 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -18,6 +18,10 @@ global.isDataDriven = function (property) { return property['property-function'] === true; }; +global.isLightProperty = function (property) { + return property['light-property'] === true; +}; + global.evaluatedType = function (property) { if (/-translate-anchor$/.test(property.name)) { return 'TranslateAnchorType'; @@ -25,6 +29,9 @@ global.evaluatedType = function (property) { if (/-(rotation|pitch|illumination)-alignment$/.test(property.name)) { return 'AlignmentType'; } + if (/position/.test(property.name)) { + return 'Position'; + } switch (property.type) { case 'boolean': return 'bool'; @@ -33,7 +40,7 @@ global.evaluatedType = function (property) { case 'string': return 'std::string'; case 'enum': - return `${camelize(property.name)}Type`; + return (isLightProperty(property) ? 'Light' : '') + `${camelize(property.name)}Type`; case 'color': return `Color`; case 'array': @@ -177,3 +184,17 @@ for (const layer of layers) { const propertySettersHpp = ejs.compile(fs.readFileSync('include/mbgl/style/conversion/make_property_setters.hpp.ejs', 'utf8'), {strict: true}); writeIfModified('include/mbgl/style/conversion/make_property_setters.hpp', propertySettersHpp({layers: layers})); + +// Light +const lightProperties = Object.keys(spec[`light`]).reduce((memo, name) => { + var property = spec[`light`][name]; + property.name = name; + property['light-property'] = true; + memo.push(property); + return memo; +}, []); + +const lightHpp = ejs.compile(fs.readFileSync('include/mbgl/style/light.hpp.ejs', 'utf8'), {strict: true}); +const lightCpp = ejs.compile(fs.readFileSync('src/mbgl/style/light.cpp.ejs', 'utf8'), {strict: true}); +writeIfModified(`include/mbgl/style/light.hpp`, lightHpp({properties: lightProperties})); +writeIfModified(`src/mbgl/style/light.cpp`, lightCpp({properties: lightProperties})); -- cgit v1.2.1