diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-09-11 12:48:07 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-09-13 15:55:34 -0700 |
commit | 2c48b5a292f315feb1aa53a3a61b629bfe5f4a05 (patch) | |
tree | 53d35e83a5a52030629593074a3596d2a5818f7e /src/mbgl/style/expression/parsing_context.cpp | |
parent | c044dd88b22ca081a7256fe663acf7e3ebf284d8 (diff) | |
download | qtlocation-mapboxgl-2c48b5a292f315feb1aa53a3a61b629bfe5f4a05.tar.gz |
[core] Implement array assertion fallback behavior
This was added in gl-js in #7095.
Diffstat (limited to 'src/mbgl/style/expression/parsing_context.cpp')
-rw-r--r-- | src/mbgl/style/expression/parsing_context.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/mbgl/style/expression/parsing_context.cpp b/src/mbgl/style/expression/parsing_context.cpp index 3fe50aa1e4..29d04d96a2 100644 --- a/src/mbgl/style/expression/parsing_context.cpp +++ b/src/mbgl/style/expression/parsing_context.cpp @@ -6,7 +6,6 @@ #include <mbgl/style/expression/expression.hpp> #include <mbgl/style/expression/at.hpp> -#include <mbgl/style/expression/array_assertion.hpp> #include <mbgl/style/expression/assertion.hpp> #include <mbgl/style/expression/boolean_operator.hpp> #include <mbgl/style/expression/case.hpp> @@ -46,8 +45,7 @@ bool isConstant(const Expression& expression) { } bool isTypeAnnotation = expression.getKind() == Kind::Coercion || - expression.getKind() == Kind::Assertion || - expression.getKind() == Kind::ArrayAssertion; + expression.getKind() == Kind::Assertion; bool childrenConstant = true; expression.eachChild([&](const Expression& child) { @@ -105,7 +103,7 @@ const ExpressionRegistry& getExpressionRegistry() { {"<=", parseComparison}, {"all", All::parse}, {"any", Any::parse}, - {"array", ArrayAssertion::parse}, + {"array", Assertion::parse}, {"at", At::parse}, {"boolean", Assertion::parse}, {"case", Case::parse}, @@ -171,14 +169,10 @@ ParseResult ParsingContext::parse(const Convertible& value, TypeAnnotationOption if (expected) { const type::Type actual = (*parsed)->getType(); - if ((*expected == type::String || *expected == type::Number || *expected == type::Boolean || *expected == type::Object) && actual == type::Value) { + if ((*expected == type::String || *expected == type::Number || *expected == type::Boolean || *expected == type::Object || expected->is<type::Array>()) && actual == type::Value) { if (typeAnnotationOption == includeTypeAnnotations) { parsed = { std::make_unique<Assertion>(*expected, array(std::move(*parsed))) }; } - } else if (expected->is<type::Array>() && actual == type::Value) { - if (typeAnnotationOption == includeTypeAnnotations) { - parsed = { std::make_unique<ArrayAssertion>(expected->get<type::Array>(), std::move(*parsed)) }; - } } else if (*expected == type::Color && (actual == type::Value || actual == type::String)) { if (typeAnnotationOption == includeTypeAnnotations) { parsed = { std::make_unique<Coercion>(*expected, array(std::move(*parsed))) }; |