diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-12-20 12:41:40 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-12-20 12:41:40 -0800 |
commit | a6b1773a44d4ef086eb30967cb041cb64312650a (patch) | |
tree | ec293e38c9ec3ef1f32195f0d5071f73b88497ed /platform/darwin/scripts/generate-style-code.js | |
parent | dad57df38ef86363da9bff2e62f3fddc5688f0cf (diff) | |
parent | e2fde9cc4eff3de5ab2f513d0c24ad5471d147e6 (diff) | |
download | qtlocation-mapboxgl-a6b1773a44d4ef086eb30967cb041cb64312650a.tar.gz |
Merge branch 'release-ios-v3.4.0' into 1ec5-release-ios-v3.4.0-beta.5-master
Also reran make style-code and manually discarded anything related to fill extrusion layers.
Diffstat (limited to 'platform/darwin/scripts/generate-style-code.js')
-rw-r--r-- | platform/darwin/scripts/generate-style-code.js | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index 6b54b5219b..e7041ad9f3 100644 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -15,9 +15,37 @@ const suffix = 'StyleLayer'; // Rename properties and keep `original` for use with setters and getters _.forOwn(cocoaConventions, function (properties, kind) { _.forOwn(properties, function (newName, oldName) { - spec[kind][newName] = spec[kind][oldName]; - spec[kind][newName].original = oldName; + let property = spec[kind][oldName]; + if (newName.startsWith('is-')) { + property.getter = newName; + newName = newName.substr(3); + } + if (newName !== oldName) { + property.original = oldName; + } delete spec[kind][oldName]; + spec[kind][newName] = property; + + // Update requirements in other properties. + let updateRequirements = function (property, name) { + let requires = property.requires || []; + for (let i = 0; i < requires.length; i++) { + if (requires[i] === oldName) { + property.requires[i] = newName; + } + if (typeof requires[i] !== 'string') { + let prop = name; + _.forOwn(requires[i], function (values, name, require) { + if (name === oldName) { + require[newName] = values; + delete require[name]; + } + }); + } + } + }; + _.forOwn(spec[kind.replace(/^layout_/, 'paint_')], updateRequirements); + _.forOwn(spec[kind.replace(/^paint_/, 'layout_')], updateRequirements); }) }); @@ -25,12 +53,16 @@ global.objCName = function (property) { return camelizeWithLeadingLowercase(property.name); } +global.objCGetter = function (property) { + return camelizeWithLeadingLowercase(property.getter || property.name); +} + global.objCType = function (layerType, propertyName) { return `${prefix}${camelize(propertyName)}`; } global.arrayType = function (property) { - return property.type === 'array' ? property.name.split('-').pop() : false; + return property.type === 'array' ? originalPropertyName(property).split('-').pop() : false; }; global.testImplementation = function (property, layerType, isFunction) { @@ -123,7 +155,7 @@ global.propertyDoc = function (propertyName, property, layerType) { return doc.replace(/(p)ixel/gi, '$1oint').replace(/(\d)px\b/g, '$1pt'); }; -global.propertyReqs = function (property, layoutPropertiesByName, type) { +global.propertyReqs = function (property, propertiesByName, type) { return 'This property is only applied to the style if ' + property.requires.map(function (req) { if (typeof req === 'string') { return '`' + camelizeWithLeadingLowercase(req) + '` is non-`nil`'; @@ -131,7 +163,7 @@ global.propertyReqs = function (property, layoutPropertiesByName, type) { return '`' + camelizeWithLeadingLowercase(req['!']) + '` is set to `nil`'; } else { let name = Object.keys(req)[0]; - return '`' + camelizeWithLeadingLowercase(name) + '` is set to an `MGLStyleValue` object containing ' + describeValue(req[name], layoutPropertiesByName[name], type); + return '`' + camelizeWithLeadingLowercase(name) + '` is set to an `MGLStyleValue` object containing ' + describeValue(req[name], propertiesByName[name], type); } }).join(', and ') + '. Otherwise, it is ignored.'; }; @@ -292,11 +324,11 @@ global.setSourceLayer = function() { } global.mbglType = function(property) { - let mbglType = camelize(property.name) + 'Type'; - if (/-translate-anchor$/.test(property.name)) { + let mbglType = camelize(originalPropertyName(property)) + 'Type'; + if (/-translate-anchor$/.test(originalPropertyName(property))) { mbglType = 'TranslateAnchorType'; } - if (/-(rotation|pitch)-alignment$/.test(property.name)) { + if (/-(rotation|pitch)-alignment$/.test(originalPropertyName(property))) { mbglType = 'AlignmentType'; } return mbglType; @@ -304,7 +336,7 @@ 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 testLayers = ejs.compile(fs.readFileSync('platform/darwin/test/MGLStyleLayerTests.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}); |