diff options
author | Anand Thakker <github@anandthakker.net> | 2017-10-20 14:24:33 -0400 |
---|---|---|
committer | Anand Thakker <github@anandthakker.net> | 2017-10-25 11:53:48 -0400 |
commit | 3b60ad31f3a37a214759ca2dd8d0a64bd4a56ed7 (patch) | |
tree | 189db905d40e40d36f985054fcf564a53a11e410 | |
parent | 134dce72d12b037e58a9dd237cc6d83682b00a4b (diff) | |
download | qtlocation-mapboxgl-3b60ad31f3a37a214759ca2dd8d0a64bd4a56ed7.tar.gz |
mbgl::Color => Color
-rw-r--r-- | include/mbgl/style/expression/value.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/expression/coercion.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/expression/compound_expression.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/expression/curve.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/expression/match.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/expression/util.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/expression/util.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/expression/value.cpp | 8 |
8 files changed, 15 insertions, 13 deletions
diff --git a/include/mbgl/style/expression/value.hpp b/include/mbgl/style/expression/value.hpp index 18f4e3ba99..454844994f 100644 --- a/include/mbgl/style/expression/value.hpp +++ b/include/mbgl/style/expression/value.hpp @@ -21,7 +21,7 @@ using ValueBase = variant< bool, double, std::string, - mbgl::Color, + Color, mapbox::util::recursive_wrapper<std::vector<Value>>, mapbox::util::recursive_wrapper<std::unordered_map<std::string, Value>>>; struct Value : ValueBase { diff --git a/src/mbgl/style/expression/coercion.cpp b/src/mbgl/style/expression/coercion.cpp index 911dc8b989..c29a42c218 100644 --- a/src/mbgl/style/expression/coercion.cpp +++ b/src/mbgl/style/expression/coercion.cpp @@ -29,7 +29,7 @@ EvaluationResult toNumber(const Value& v) { EvaluationResult toColor(const Value& colorValue) { return colorValue.match( [&](const std::string& colorString) -> EvaluationResult { - const optional<mbgl::Color> result = mbgl::Color::parse(colorString); + const optional<Color> result = Color::parse(colorString); if (result) { return *result; } else { @@ -44,7 +44,7 @@ EvaluationResult toColor(const Value& colorValue) { return item.template is<double>(); }); if ((len == 3 || len == 4) && isNumeric) { - Result<mbgl::Color> c = {rgba( + Result<Color> c = {rgba( components[0].template get<double>(), components[1].template get<double>(), components[2].template get<double>(), diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index 5fc6228986..3e8ebcf7b2 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -210,7 +210,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali define("to-string", [](const Value& value) -> Result<std::string> { return value.match( - [](const mbgl::Color& c) -> Result<std::string> { return c.stringify(); }, // avoid quoting + [](const Color& c) -> Result<std::string> { return c.stringify(); }, // avoid quoting [](const auto& v) -> Result<std::string> { return stringify(v); } ); }); @@ -224,7 +224,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali [&] (const auto&) { return true; } ); }); - define("to-rgba", [](const mbgl::Color& color) -> Result<std::array<double, 4>> { + define("to-rgba", [](const Color& color) -> Result<std::array<double, 4>> { return std::array<double, 4> {{ color.r, color.g, color.b, color.a }}; }); diff --git a/src/mbgl/style/expression/curve.cpp b/src/mbgl/style/expression/curve.cpp index 028ccaf928..417f9cf5c7 100644 --- a/src/mbgl/style/expression/curve.cpp +++ b/src/mbgl/style/expression/curve.cpp @@ -201,7 +201,7 @@ ParseResult parseCurve(const mbgl::style::conversion::Convertible& value, Parsin }, [&](const type::ColorType&) -> ParseResult { return interpolator.match([&](const auto& interpolator_) { - return ParseResult(std::make_unique<Curve<mbgl::Color>>( + return ParseResult(std::make_unique<Curve<Color>>( *outputType, interpolator_, std::move(*input), std::move(stops) )); }); diff --git a/src/mbgl/style/expression/match.cpp b/src/mbgl/style/expression/match.cpp index dd3349e9f9..a420799b7a 100644 --- a/src/mbgl/style/expression/match.cpp +++ b/src/mbgl/style/expression/match.cpp @@ -229,6 +229,8 @@ ParseResult parseMatch(const mbgl::style::conversion::Convertible& value, Parsin return create<std::string>(*outputType, std::move(*input), std::move(branches), std::move(*otherwise), ctx); }, [&](const auto&) { + // unreachable: inputType is set by parseInputValue(), which only + // accepts string and (integer) numeric values. assert(false); return ParseResult(); } diff --git a/src/mbgl/style/expression/util.cpp b/src/mbgl/style/expression/util.cpp index 09c6c3c23d..637922dfbd 100644 --- a/src/mbgl/style/expression/util.cpp +++ b/src/mbgl/style/expression/util.cpp @@ -13,7 +13,7 @@ std::string stringifyColor(double r, double g, double b, double a) { stringify(a); } -Result<mbgl::Color> rgba(double r, double g, double b, double a) { +Result<Color> rgba(double r, double g, double b, double a) { if ( r < 0 || r > 255 || g < 0 || g > 255 || @@ -30,7 +30,7 @@ Result<mbgl::Color> rgba(double r, double g, double b, double a) { "]: 'a' must be between 0 and 1." }; } - return mbgl::Color(r / 255, g / 255, b / 255, a); + return Color(r / 255, g / 255, b / 255, a); } } // namespace expression diff --git a/src/mbgl/style/expression/util.hpp b/src/mbgl/style/expression/util.hpp index 192e11da4e..b6fc408ed9 100644 --- a/src/mbgl/style/expression/util.hpp +++ b/src/mbgl/style/expression/util.hpp @@ -7,7 +7,7 @@ namespace mbgl { namespace style { namespace expression { -Result<mbgl::Color> rgba(double r, double g, double b, double a); +Result<Color> rgba(double r, double g, double b, double a); } // namespace expression } // namespace style diff --git a/src/mbgl/style/expression/value.cpp b/src/mbgl/style/expression/value.cpp index b0ae9d3217..6be936c299 100644 --- a/src/mbgl/style/expression/value.cpp +++ b/src/mbgl/style/expression/value.cpp @@ -11,7 +11,7 @@ type::Type typeOf(const Value& value) { [&](bool) -> type::Type { return type::Boolean; }, [&](double) -> type::Type { return type::Number; }, [&](const std::string&) -> type::Type { return type::String; }, - [&](const mbgl::Color&) -> type::Type { return type::Color; }, + [&](const Color&) -> type::Type { return type::Color; }, [&](const NullValue&) -> type::Type { return type::Null; }, [&](const std::unordered_map<std::string, Value>&) -> type::Type { return type::Object; }, [&](const std::vector<Value>& arr) -> type::Type { @@ -45,7 +45,7 @@ void writeJSON(rapidjson::Writer<rapidjson::StringBuffer>& writer, const Value& f == std::floor(f) ? writer.Int(f) : writer.Double(f); }, [&] (const std::string& s) { writer.String(s); }, - [&] (const mbgl::Color& c) { writer.String(c.stringify()); }, + [&] (const Color& c) { writer.String(c.stringify()); }, [&] (const std::vector<Value>& arr) { writer.StartArray(); for(const auto& item : arr) { @@ -90,7 +90,7 @@ struct FromMBGLValue { Value operator()(const std::string& s) { return s; } Value operator()(const bool& b) { return b; } - Value operator()(const mbgl::NullValue) { return Null; } + Value operator()(const NullValue) { return Null; } Value operator()(const double& v) { return v; } Value operator()(const uint64_t& v) { return static_cast<double>(v); @@ -232,7 +232,7 @@ template <> type::Type valueTypeToExpressionType<NullValue>() { return type::Nul template <> type::Type valueTypeToExpressionType<bool>() { return type::Boolean; } template <> type::Type valueTypeToExpressionType<double>() { return type::Number; } template <> type::Type valueTypeToExpressionType<std::string>() { return type::String; } -template <> type::Type valueTypeToExpressionType<mbgl::Color>() { return type::Color; } +template <> type::Type valueTypeToExpressionType<Color>() { return type::Color; } template <> type::Type valueTypeToExpressionType<std::unordered_map<std::string, Value>>() { return type::Object; } template <> type::Type valueTypeToExpressionType<std::vector<Value>>() { return type::Array(type::Value); } |