diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-12-16 08:09:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-16 08:09:42 -0800 |
commit | 3f26e88c49d3afeb3754a877b8473deb4bf2cded (patch) | |
tree | bc1dc3211623211302201d07219c46fdaf055487 /platform/darwin/src/MGLStyleLayer.mm.ejs | |
parent | b8466946e5eac5a4359206c19fe6e659ae9cf6c1 (diff) | |
download | qtlocation-mapboxgl-3f26e88c49d3afeb3754a877b8473deb4bf2cded.tar.gz |
Use appropriate part of speech for properties (#7457)
* [ios, macos] Use appropriate part of speech for properties
Fixed overridden property references in requirements lists. Boolean-typed properties can now have getters beginning with “is”.
Renamed a number of layout properties according to the following rules: Boolean-typed properties should include a verb; other properties must be noun phrases; all properties must be grammatical.
* [ios, macos] Added style spec names as unavailable aliases
Renamed properties now have aliases based on their style specification names, marked unavailable, for wayfinding purposes.
* [ios, macos] Fixed autosynthesis warnings
* [ios, macos] Moved style layer test template to test folder
* [ios, macos] Customized iconOptional getter
* [ios, macos] Avoid autosynthesis of aliases
* [ios, macos] Test that property names are grammatical
Run property getter names through a basic battery of tests to see if they’re grammatical. Most part-of-speech tagging tests are guarded by a compile-time flag, off by default, because NSLinguisticTagger does a poor job of telling nouns from verbs, and we’ve intentionally kept many words in property names that could be read as either verbs or nouns (like “transform” or “scale”).
Diffstat (limited to 'platform/darwin/src/MGLStyleLayer.mm.ejs')
-rw-r--r-- | platform/darwin/src/MGLStyleLayer.mm.ejs | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 3b446dd02e..6178eaad51 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -21,9 +21,9 @@ namespace mbgl { <% if (layoutProperties.length) { -%> <% for (const property of layoutProperties) { -%> <% if (property.type == "enum") { -%> - MBGL_DEFINE_ENUM(MGL<%- camelize(originalPropertyName(property)) %>, { + MBGL_DEFINE_ENUM(MGL<%- camelize(property.name) %>, { <% for (const value in property.values) { -%> - { MGL<%- camelize(originalPropertyName(property)) %><%- camelize(value) %>, "<%-value%>" }, + { MGL<%- camelize(property.name) %><%- camelize(value) %>, "<%-value%>" }, <% } -%> }); @@ -33,9 +33,9 @@ namespace mbgl { <% if (paintProperties.length) { -%> <% for (const property of paintProperties) { -%> <% if (property.type == "enum") { -%> - MBGL_DEFINE_ENUM(MGL<%- camelize(originalPropertyName(property)) %>, { + MBGL_DEFINE_ENUM(MGL<%- camelize(property.name) %>, { <% for (const value in property.values) { -%> - { MGL<%- camelize(originalPropertyName(property)) %><%- camelize(value) %>, "<%-value%>" }, + { MGL<%- camelize(property.name) %><%- camelize(value) %>, "<%-value%>" }, <% } -%> }); @@ -167,7 +167,7 @@ namespace mbgl { MGLAssertStyleLayerIsValid(); <% if (property.type == "enum") { -%> - auto mbglValue = MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumPropertyValue(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); <% } else { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); @@ -175,17 +175,27 @@ namespace mbgl { <% } -%> } -- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { +- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCGetter(property) %> { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>(); <% if (property.type == "enum") { -%> - return MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue); <% } else { -%> return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); <% } -%> } +<% if (property.original) { %> +- (void)set<%- camelize(originalPropertyName(property)) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> { + self.<%- camelizeWithLeadingLowercase(property.name) %> = <%- camelizeWithLeadingLowercase(originalPropertyName(property)) %>; +} + +- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> { + return self.<%- objCGetter(property) %>; +} + +<% } -%> <% } -%> <% } -%> <% if (paintProperties.length) { -%> @@ -196,7 +206,7 @@ namespace mbgl { MGLAssertStyleLayerIsValid(); <% if (property.type == "enum") { -%> - auto mbglValue = MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumPropertyValue(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); <% } else { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); @@ -204,17 +214,23 @@ namespace mbgl { <% } -%> } -- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { +- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCGetter(property) %> { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>(); <% if (property.type == "enum") { -%> - return MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue); <% } else { -%> return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); <% } -%> } +<% if (property.original) { %> +- (void)set<%- camelize(originalPropertyName(property)) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> { + NSAssert(NO, @"Use -set<%- camelize(property.name) %>: instead."); +} + +<% } -%> <% } -%> <% } -%> |