summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-12-08 12:09:21 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-12-09 09:35:21 -0800
commit3b2a4216a2e3929a557dbddd0d239758641c285f (patch)
treefc30966e6d1253e040b6092f1c53eb2fd22632e7 /scripts
parent4a2f53e6e51b4759cacd89790db99783bf211343 (diff)
downloadqtlocation-mapboxgl-3b2a4216a2e3929a557dbddd0d239758641c285f.tar.gz
[core] Implement circle-stroke properties
Also includes stubs for fill-extrusion layer, because most of the code was auto-generated.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/generate-style-code.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js
index 005bc022df..f2acb12a2a 100644
--- a/scripts/generate-style-code.js
+++ b/scripts/generate-style-code.js
@@ -3,12 +3,12 @@
const fs = require('fs');
const ejs = require('ejs');
const spec = require('mapbox-gl-style-spec').latest;
-var colorParser = require('csscolorparser');
+const colorParser = require('csscolorparser');
require('./style-code');
function parseCSSColor(str) {
- var color = colorParser.parseCSSColor(str);
+ const color = colorParser.parseCSSColor(str);
return [
color[0] / 255 * color[3], color[1] / 255 * color[3], color[2] / 255 * color[3], color[3]
];
@@ -40,7 +40,7 @@ global.propertyType = function (property) {
}
default: throw new Error(`unknown type for ${property.name}`)
}
-}
+};
global.defaultValue = function (property) {
// https://github.com/mapbox/mapbox-gl-native/issues/5258
@@ -64,7 +64,7 @@ global.defaultValue = function (property) {
return `${propertyType(property)}::${camelize(property.default)}`;
}
case 'color':
- var color = parseCSSColor(property.default).join(', ');
+ const color = parseCSSColor(property.default).join(', ');
switch (color) {
case '0, 0, 0, 0':
return '{}';
@@ -85,7 +85,7 @@ global.defaultValue = function (property) {
default:
return property.default;
}
-}
+};
const layerHpp = ejs.compile(fs.readFileSync('include/mbgl/style/layers/layer.hpp.ejs', 'utf8'), {strict: true});
const layerCpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer.cpp.ejs', 'utf8'), {strict: true});
@@ -118,11 +118,13 @@ const layers = Object.keys(spec.layer.type.values).map((type) => {
});
for (const layer of layers) {
- writeIfModified(`include/mbgl/style/layers/${layer.type}_layer.hpp`, layerHpp(layer));
- writeIfModified(`src/mbgl/style/layers/${layer.type}_layer.cpp`, layerCpp(layer));
+ const layerFileName = layer.type.replace('-', '_');
+
+ writeIfModified(`include/mbgl/style/layers/${layerFileName}_layer.hpp`, layerHpp(layer));
+ writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer.cpp`, layerCpp(layer));
- writeIfModified(`src/mbgl/style/layers/${layer.type}_layer_properties.hpp`, propertiesHpp(layer));
- writeIfModified(`src/mbgl/style/layers/${layer.type}_layer_properties.cpp`, propertiesCpp(layer));
+ writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.hpp`, propertiesHpp(layer));
+ writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.cpp`, propertiesCpp(layer));
}
const propertySettersHpp = ejs.compile(fs.readFileSync('include/mbgl/style/conversion/make_property_setters.hpp.ejs', 'utf8'), {strict: true});