diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-07-20 15:40:47 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-07-23 21:59:20 +0300 |
commit | d13ebedadbd6ef9d6308c3399d0d88b140de421d (patch) | |
tree | 9fbcd5274b408ee3a194560b6c5d4760aa118fb2 /include/mbgl/style/conversion | |
parent | 3821f74079f88b6a5b3b0ea210fe529132a3494f (diff) | |
download | qtlocation-mapboxgl-upstream/expressions-rtti-refactor.tar.gz |
[core] Replace expressions RTTI with enums + static castupstream/expressions-rtti-refactor
Diffstat (limited to 'include/mbgl/style/conversion')
-rw-r--r-- | include/mbgl/style/conversion/data_driven_property_value.hpp | 8 | ||||
-rw-r--r-- | include/mbgl/style/conversion/property_value.hpp | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/include/mbgl/style/conversion/data_driven_property_value.hpp b/include/mbgl/style/conversion/data_driven_property_value.hpp index f1bd1bdbb7..59d197b216 100644 --- a/include/mbgl/style/conversion/data_driven_property_value.hpp +++ b/include/mbgl/style/conversion/data_driven_property_value.hpp @@ -47,13 +47,17 @@ struct Converter<DataDrivenPropertyValue<T>> { return {}; } else if (!(*expression).isFeatureConstant() || !(*expression).isZoomConstant()) { return { std::move(*expression) }; - } else { + } else if ((*expression).getExpression().getKind() == Kind::Literal) { optional<T> constant = fromExpressionValue<T>( - dynamic_cast<const Literal&>((*expression).getExpression()).getValue()); + static_cast<const Literal&>((*expression).getExpression()).getValue()); if (!constant) { return {}; } return DataDrivenPropertyValue<T>(*constant); + } else { + assert(false); + error = { "expected a literal expression" }; + return {}; } } diff --git a/include/mbgl/style/conversion/property_value.hpp b/include/mbgl/style/conversion/property_value.hpp index db23074c5e..b03655a848 100644 --- a/include/mbgl/style/conversion/property_value.hpp +++ b/include/mbgl/style/conversion/property_value.hpp @@ -54,13 +54,17 @@ struct Converter<PropertyValue<T>> { return {}; } else if (!(*expression).isZoomConstant()) { return { std::move(*expression) }; - } else { + } else if ((*expression).getExpression().getKind() == Kind::Literal) { optional<T> constant = fromExpressionValue<T>( - dynamic_cast<const Literal&>((*expression).getExpression()).getValue()); + static_cast<const Literal&>((*expression).getExpression()).getValue()); if (!constant) { return {}; } return PropertyValue<T>(*constant); + } else { + assert(false); + error = { "expected a literal expression" }; + return {}; } } }; |