summaryrefslogtreecommitdiff
path: root/platform/darwin/scripts/generate-style-code.js
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-11-14 16:59:30 -0800
committerJesse Bounds <jesse@rebounds.net>2016-11-22 19:53:54 -0800
commit13e0f9e527366dce43f59055fde17818f443e356 (patch)
tree83b3ca4e2b0f103575c28335ac39fc76b7ec33a5 /platform/darwin/scripts/generate-style-code.js
parent4e4e05ef50808a27d7a9a46c830d05165bd85e94 (diff)
downloadqtlocation-mapboxgl-13e0f9e527366dce43f59055fde17818f443e356.tar.gz
[ios, macos] Refactor runtime styling enumeration properties
Correctly map SDK runtime styling enumerations to mbgl equivalents. Also, add category methods to NSValue so enums can be wrapped up with less of the details of how they are layed out in memory in Objective-C.
Diffstat (limited to 'platform/darwin/scripts/generate-style-code.js')
-rw-r--r--platform/darwin/scripts/generate-style-code.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js
index 80d7504de4..9090bb40e6 100644
--- a/platform/darwin/scripts/generate-style-code.js
+++ b/platform/darwin/scripts/generate-style-code.js
@@ -301,6 +301,8 @@ global.mbglType = function(property) {
const layerH = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.h.ejs', 'utf8'), { strict: true });
const layerM = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.mm.ejs', 'utf8'), { strict: true});
const testLayers = ejs.compile(fs.readFileSync('platform/darwin/src/MGLRuntimeStylingTests.m.ejs', 'utf8'), { strict: true});
+const categoryH = ejs.compile(fs.readFileSync('platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h.ejs', 'utf8'), { strict: true});
+const categoryM = ejs.compile(fs.readFileSync('platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm.ejs', 'utf8'), { strict: true});
const layers = Object.keys(spec.layer.type.values).map((type) => {
const layoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => {
@@ -345,8 +347,28 @@ ${macosComment}${decl}
});
}
+var allLayoutProperties = [];
+var allPaintProperties = [];
+var allTypes = [];
+
for (var layer of layers) {
+ allLayoutProperties.push(layer.layoutProperties);
+ allPaintProperties.push(layer.paintProperties);
+ allTypes.push(layer.type);
+ const containsEnumerationProperties = _.filter(layer.layoutProperties, function(property){ return property["type"] === "enum"; }).length || _.filter(layer.paintProperties, function(property){ return property["type"] === "enum"; }).length;
+ layer.containsEnumerationProperties = containsEnumerationProperties;
+
fs.writeFileSync(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.h`, duplicatePlatformDecls(layerH(layer)));
fs.writeFileSync(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.mm`, layerM(layer));
fs.writeFileSync(`platform/darwin/test/${prefix}${camelize(layer.type)}${suffix}Tests.m`, testLayers(layer));
}
+
+fs.writeFileSync(`platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h`, categoryH({
+ layoutProperties: _.flatten(allLayoutProperties),
+ paintProperties: _.flatten(allPaintProperties),
+ types: allTypes
+}));
+fs.writeFileSync(`platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm`, categoryM({
+ layoutProperties: _.flatten(allLayoutProperties),
+ paintProperties: _.flatten(allPaintProperties)
+}));