Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] map image type to string until we have a dedicated implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed Oct 14, 2019
1 parent 5093a01 commit aa43802
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 37 deletions.
3 changes: 2 additions & 1 deletion expression-test/expression_test_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ optional<Value> toValue(const JSValue& jsvalue) {

style::expression::type::Type stringToType(const std::string& type) {
using namespace style::expression;
if (type == "string"s || type == "number-format"s) {
if (type == "string"s || type == "number-format"s ||
type == "image"s) { // TODO: replace once we implement image expressions
return type::String;
} else if (type == "number"s) {
return type::Number;
Expand Down
4 changes: 4 additions & 0 deletions platform/node/test/ignores.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"expression-tests/legacy/interval/composite": "https://github.com/mapbox/mapbox-gl-native/issues/12747",
"expression-tests/legacy/interval/composite-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747",
"expression-tests/legacy/interval/tokens-zoom": "https://github.com/mapbox/mapbox-gl-native/issues/12747",
"expression-tests/image/basic": "https://github.com/mapbox/mapbox-gl-native/issues/15800",
"expression-tests/image/compound": "https://github.com/mapbox/mapbox-gl-native/issues/15800",
"expression-tests/image/coalesce": "https://github.com/mapbox/mapbox-gl-native/issues/15800",
"expression-tests/image/implicit-assert": "https://github.com/mapbox/mapbox-gl-native/issues/15800",
"query-tests/geometry/multilinestring": "needs investigation",
"query-tests/geometry/multipolygon": "needs investigation",
"query-tests/geometry/polygon": "needs investigation",
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/style/expression/assertion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Assertion::Assertion(type::Type type_, std::vector<std::unique_ptr<Expression>>
}

ParseResult Assertion::parse(const Convertible& value, ParsingContext& ctx) {
static std::unordered_map<std::string, type::Type> types {
static std::unordered_map<std::string, type::Type> types{
{"string", type::String},
{"image", type::String}, // TODO: replace once we implement image expressions
{"number", type::Number},
{"boolean", type::Boolean},
{"object", type::Object}
};
{"object", type::Object}};

std::size_t length = arrayLength(value);

Expand Down
66 changes: 34 additions & 32 deletions src/mbgl/style/expression/parsing_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,38 +100,40 @@ ParseResult ParsingContext::parse(const Convertible& value, std::size_t index_,
}

using ParseFunction = ParseResult (*)(const conversion::Convertible&, ParsingContext&);
MAPBOX_ETERNAL_CONSTEXPR const auto expressionRegistry = mapbox::eternal::hash_map<mapbox::eternal::string, ParseFunction>({
{"==", parseComparison},
{"!=", parseComparison},
{">", parseComparison},
{"<", parseComparison},
{">=", parseComparison},
{"<=", parseComparison},
{"all", All::parse},
{"any", Any::parse},
{"array", Assertion::parse},
{"at", At::parse},
{"boolean", Assertion::parse},
{"case", Case::parse},
{"coalesce", Coalesce::parse},
{"collator", CollatorExpression::parse},
{"format", FormatExpression::parse},
{"interpolate", parseInterpolate},
{"length", Length::parse},
{"let", Let::parse},
{"literal", Literal::parse},
{"match", parseMatch},
{"number", Assertion::parse},
{"number-format", NumberFormat::parse},
{"object", Assertion::parse},
{"step", Step::parse},
{"string", Assertion::parse},
{"to-boolean", Coercion::parse},
{"to-color", Coercion::parse},
{"to-number", Coercion::parse},
{"to-string", Coercion::parse},
{"var", Var::parse},
});
MAPBOX_ETERNAL_CONSTEXPR const auto expressionRegistry =
mapbox::eternal::hash_map<mapbox::eternal::string, ParseFunction>({
{"==", parseComparison},
{"!=", parseComparison},
{">", parseComparison},
{"<", parseComparison},
{">=", parseComparison},
{"<=", parseComparison},
{"all", All::parse},
{"any", Any::parse},
{"array", Assertion::parse},
{"at", At::parse},
{"boolean", Assertion::parse},
{"case", Case::parse},
{"coalesce", Coalesce::parse},
{"collator", CollatorExpression::parse},
{"format", FormatExpression::parse},
{"image", Assertion::parse}, // TODO: replace once we implement image expressions
{"interpolate", parseInterpolate},
{"length", Length::parse},
{"let", Let::parse},
{"literal", Literal::parse},
{"match", parseMatch},
{"number", Assertion::parse},
{"number-format", NumberFormat::parse},
{"object", Assertion::parse},
{"step", Step::parse},
{"string", Assertion::parse},
{"to-boolean", Coercion::parse},
{"to-color", Coercion::parse},
{"to-number", Coercion::parse},
{"to-string", Coercion::parse},
{"var", Var::parse},
});

bool isExpression(const std::string& name) {
return expressionRegistry.contains(name.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/text/shaping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ AnchorAlignment AnchorAlignment::getAnchorAlignment(style::SymbolAnchorType anch
result.horizontalAlign = 0.0f;
break;
default:
break;
break;
}

switch (anchor) {
Expand Down

0 comments on commit aa43802

Please sign in to comment.