diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-09-26 14:14:44 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-10-23 09:56:43 -0700 |
commit | 4b2e1cddb4645fb6d2c5f9634dbeb7c21516cede (patch) | |
tree | f11bd97ea5abf17bc6956f254796f1e8cf4a96f9 /src/mbgl/style/conversion/make_property_setters.hpp.ejs | |
parent | bb58ddaea8c2d9da9551601318944d9d143ee247 (diff) | |
download | qtlocation-mapboxgl-4b2e1cddb4645fb6d2c5f9634dbeb7c21516cede.tar.gz |
Replace compile-time polymorphism with runtime polymorphism in the conversion system
Diffstat (limited to 'src/mbgl/style/conversion/make_property_setters.hpp.ejs')
-rw-r--r-- | src/mbgl/style/conversion/make_property_setters.hpp.ejs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mbgl/style/conversion/make_property_setters.hpp.ejs b/src/mbgl/style/conversion/make_property_setters.hpp.ejs new file mode 100644 index 0000000000..2975cb19f2 --- /dev/null +++ b/src/mbgl/style/conversion/make_property_setters.hpp.ejs @@ -0,0 +1,46 @@ +#pragma once + +// This file is generated. Edit make_property_setters.hpp.ejs, then run `make style-code`. + +#include <mbgl/style/conversion/property_setter.hpp> + +<% for (const layer of locals.layers) { -%> +#include <mbgl/style/layers/<%- layer.type.replace('-', '_') %>_layer.hpp> +<% } -%> + +#include <unordered_map> + +namespace mbgl { +namespace style { +namespace conversion { + +inline auto makeLayoutPropertySetters() { + std::unordered_map<std::string, PropertySetter> result; + + result["visibility"] = &setVisibility; + +<% for (const layer of locals.layers) { -%> +<% for (const property of layer.layoutProperties) { -%> + result["<%- property.name %>"] = &setProperty<<%- camelize(layer.type) %>Layer, <%- propertyValueType(property) %>, &<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>>; +<% } -%> + +<% } -%> + return result; +} + +inline auto makePaintPropertySetters() { + std::unordered_map<std::string, PropertySetter> result; + +<% for (const layer of locals.layers) { -%> +<% for (const property of layer.paintProperties) { -%> + result["<%- property.name %>"] = &setProperty<<%- camelize(layer.type) %>Layer, <%- propertyValueType(property) %>, &<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>>; + result["<%- property.name %>-transition"] = &setTransition<<%- camelize(layer.type) %>Layer, &<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>Transition>; +<% } -%> + +<% } -%> + return result; +} + +} // namespace conversion +} // namespace style +} // namespace mbgl |