summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/generate-style-code.js23
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}));