Add array support for icon-padding (#2845)
This commit is contained in:
@@ -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());
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user