diff options
Diffstat (limited to 'platform/darwin/scripts')
-rw-r--r-- | platform/darwin/scripts/generate-style-code.js | 45 | ||||
-rw-r--r-- | platform/darwin/scripts/style-spec-cocoa-conventions-v8.json | 19 |
2 files changed, 48 insertions, 16 deletions
diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index de0e7d69a0..9e79d0a321 100644 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -12,22 +12,33 @@ 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] in cocoaConventions[kind]) { - property.requires[i] = cocoaConventions[kind][requires[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(requires[i], function (values, name, require) { - if (require in cocoaConventions[kind]) { - require[cocoaConventions[kind][name]] = values; - } - }); } }; _.forOwn(spec[kind.replace(/^layout_/, 'paint_')], updateRequirements); @@ -51,6 +62,10 @@ 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)}`; } @@ -149,7 +164,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`'; @@ -157,7 +172,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.'; }; @@ -318,11 +333,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; @@ -330,7 +345,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}); diff --git a/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json b/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json index a144871a67..49cf515e3e 100644 --- a/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json +++ b/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json @@ -1,7 +1,21 @@ { "layout_symbol": { + "icon-allow-overlap": "icon-allows-overlap", "icon-image": "icon-image-name", - "icon-size": "icon-scale" + "icon-ignore-placement": "icon-ignores-placement", + "icon-keep-upright": "keeps-icon-upright", + "icon-optional": "is-icon-optional", + "icon-rotate": "icon-rotation", + "icon-size": "icon-scale", + "symbol-avoid-edges": "symbol-avoids-edges", + "text-allow-overlap": "text-allows-overlap", + "text-ignore-placement": "text-ignores-placement", + "text-justify": "text-justification", + "text-keep-upright": "keeps-text-upright", + "text-max-angle": "maximum-text-angle", + "text-max-width": "maximum-text-width", + "text-optional": "is-text-optional", + "text-rotate": "text-rotation" }, "paint_raster": { "raster-brightness-min": "minimum-raster-brightness", @@ -10,5 +24,8 @@ }, "paint_line": { "line-dasharray": "line-dash-pattern" + }, + "paint_fill": { + "fill-antialias": "is-fill-antialiased" } }
\ No newline at end of file |