diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-04-25 13:59:09 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-02 14:51:39 -0700 |
commit | cadc617c762d453cca2c9bac41f9c1db984c5fac (patch) | |
tree | 5a15363a54ef81b0106693dd83c70bfdf7761393 /scripts | |
parent | ba4a8a97316d65ab595bb7edf759f463bbd10049 (diff) | |
download | qtlocation-mapboxgl-cadc617c762d453cca2c9bac41f9c1db984c5fac.tar.gz |
[core] Introduce PropertyValue<T>
PropertyValue<T> represents the three possible types of style property value: undefined, constant, or function.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/generate-style-code.js | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index 2904a1429a..b26e0520f6 100644 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -77,10 +77,12 @@ const layerHpp = ejs.compile(`<% #pragma once #include <mbgl/style/layer.hpp> -<% if (type === 'line' || type === 'symbol') { %> +#include <mbgl/style/property_value.hpp> + +<% if (type === 'line' || type === 'symbol') { -%> #include <vector> -<% } -%> +<% } -%> namespace mbgl { class <%- camelize(type) %>Layer : public Layer { @@ -106,16 +108,16 @@ public: // Layout properties <% for (const property of layoutProperties) { -%> - Function<<%- propertyType(property) %>> get<%- camelize(property.name) %>() const; - void set<%- camelize(property.name) %>(Function<<%- propertyType(property) %>>); + PropertyValue<<%- propertyType(property) %>> get<%- camelize(property.name) %>() const; + void set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>>); <% } -%> <% } -%> // Paint properties <% for (const property of paintProperties) { -%> - Function<<%- propertyType(property) %>> get<%- camelize(property.name) %>() const; - void set<%- camelize(property.name) %>(Function<<%- propertyType(property) %>>); + PropertyValue<<%- propertyType(property) %>> get<%- camelize(property.name) %>() const; + void set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>>); <% } -%> // Private implementation @@ -194,23 +196,23 @@ const std::string& <%- camelize(type) %>Layer::getSourceLayer() const { // Layout properties <% for (const property of layoutProperties) { -%> -Function<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { - return *impl->layout.<%- camelizeWithLeadingLowercase(property.name) %>.parsedValue; +PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { + return impl->layout.<%- camelizeWithLeadingLowercase(property.name) %>.get(); } -void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(Function<<%- propertyType(property) %>> value) { - impl->layout.<%- camelizeWithLeadingLowercase(property.name) %>.parsedValue = value; +void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value) { + impl->layout.<%- camelizeWithLeadingLowercase(property.name) %>.set(value); } <% } -%> // Paint properties <% for (const property of paintProperties) { %> -Function<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { - return impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.values.at(ClassID::Default); +PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%- camelize(property.name) %>() const { + return impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.get(); } -void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(Function<<%- propertyType(property) %>> value) { - impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.values.emplace(ClassID::Default, value); +void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value) { + impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.set(value); } <% } -%> @@ -255,7 +257,7 @@ public: <% for (const property of paintProperties) { -%> <% if (/-pattern$/.test(property.name) || property.name === 'line-dasharray') { -%> - PaintProperty<<%- propertyType(property) %>, CrossFadedFunctionEvaluator> <%- camelizeWithLeadingLowercase(property.name) %> { <%- defaultValue(property) %> }; + PaintProperty<<%- propertyType(property) %>, CrossFadedPropertyEvaluator> <%- camelizeWithLeadingLowercase(property.name) %> { <%- defaultValue(property) %> }; <% } else if (property.name === 'fill-outline-color') { -%> PaintProperty<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %> { {{ 0, 0, 0, -1 }} }; <% } else { -%> |