Add array support for icon-padding (#2845)

This commit is contained in:
Alexey Kon
2024-09-20 17:17:33 -07:00
committed by GitHub
parent 58dd529790
commit 9d553c2843
56 changed files with 902 additions and 104 deletions

View File

@@ -131,6 +131,9 @@ template std::optional<PropertyExpression<LineJoinType>> convertFunctionToExpres
Error&,
bool);
template std::optional<PropertyExpression<Color>> convertFunctionToExpression<Color>(const Convertible&, Error&, bool);
template std::optional<PropertyExpression<Padding>> convertFunctionToExpression<Padding>(const Convertible&,
Error&,
bool);
template std::optional<PropertyExpression<Position>> convertFunctionToExpression<Position>(const Convertible&,
Error&,
bool);
@@ -209,6 +212,7 @@ enum class FunctionType {
bool interpolatable(type::Type type) noexcept {
return type.match([&](const type::NumberType&) { return true; },
[&](const type::ColorType&) { return true; },
[&](const type::PaddingType&) { return true; },
[&](const type::Array& array) { return array.N && array.itemType == type::Number; },
[&](const auto&) { return false; });
}
@@ -246,6 +250,13 @@ std::optional<std::unique_ptr<Expression>> convertLiteral(type::Type type,
}
return literal(*result);
},
[&](const type::PaddingType&) -> std::optional<std::unique_ptr<Expression>> {
auto result = convert<Padding>(value, error);
if (!result) {
return std::nullopt;
}
return literal(*result);
},
[&](const type::Array& array) -> std::optional<std::unique_ptr<Expression>> {
if (!isArray(value)) {
error.message = "value must be an array";
@@ -779,6 +790,9 @@ std::optional<std::unique_ptr<Expression>> convertFunctionToExpression(type::Typ
[&](const type::ColorType&) -> std::optional<std::unique_ptr<Expression>> {
return toColor(get(literal(*property)), defaultExpr());
},
[&](const type::PaddingType&) -> std::optional<std::unique_ptr<Expression>> {
return toPadding(get(literal(*property)), defaultExpr());
},
[&](const type::Array& array) -> std::optional<std::unique_ptr<Expression>> {
return assertion(array, get(literal(*property)), defaultExpr());
},