diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-05-04 17:26:42 +0300 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-05-08 19:39:55 +0300 |
commit | feae5e22ee4910a1508f2120c8131b2f8531bae8 (patch) | |
tree | b5ca0ba87b42bcc732070485b5ccea2c3f832840 /scripts | |
parent | 20810f988a735e0d43f9abff9260ea0784cd218c (diff) | |
download | qtlocation-mapboxgl-feae5e22ee4910a1508f2120c8131b2f8531bae8.tar.gz |
[core] generated accessor methods on light
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/generate-style-code.js | 23 |
1 files changed, 22 insertions, 1 deletions
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})); |