From 92608f58858d77c17a65ae9b29758e74bb2da7d2 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 10 Nov 2017 20:04:20 -0200 Subject: [core] Fix build on Android + GCC and Android + armeabi Sadly we don't have bots for these two setups. --- include/mbgl/style/expression/parsing_context.hpp | 5 +++-- include/mbgl/style/expression/type.hpp | 3 ++- include/mbgl/util/string.hpp | 8 ++++++++ src/mbgl/style/expression/array_assertion.cpp | 3 ++- src/mbgl/style/expression/at.cpp | 5 +++-- src/mbgl/style/expression/case.cpp | 3 ++- src/mbgl/style/expression/coercion.cpp | 3 ++- src/mbgl/style/expression/compound_expression.cpp | 8 +++++--- src/mbgl/style/expression/interpolate.cpp | 4 ++-- src/mbgl/style/expression/let.cpp | 3 ++- src/mbgl/style/expression/literal.cpp | 4 ++-- src/mbgl/style/expression/match.cpp | 9 +++++---- src/mbgl/style/expression/parsing_context.cpp | 6 ++++-- src/mbgl/style/expression/step.cpp | 3 ++- 14 files changed, 44 insertions(+), 23 deletions(-) diff --git a/include/mbgl/style/expression/parsing_context.hpp b/include/mbgl/style/expression/parsing_context.hpp index 65c5ebe188..a983789cbd 100644 --- a/include/mbgl/style/expression/parsing_context.hpp +++ b/include/mbgl/style/expression/parsing_context.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -104,11 +105,11 @@ public: } void error(std::string message, std::size_t child) { - errors->push_back({message, key + "[" + std::to_string(child) + "]"}); + errors->push_back({message, key + "[" + util::toString(child) + "]"}); } void error(std::string message, std::size_t child, std::size_t grandchild) { - errors->push_back({message, key + "[" + std::to_string(child) + "][" + std::to_string(grandchild) + "]"}); + errors->push_back({message, key + "[" + util::toString(child) + "][" + util::toString(grandchild) + "]"}); } void appendErrors(ParsingContext&& ctx) { diff --git a/include/mbgl/style/expression/type.hpp b/include/mbgl/style/expression/type.hpp index d801cd3ac9..da59eb001c 100644 --- a/include/mbgl/style/expression/type.hpp +++ b/include/mbgl/style/expression/type.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -88,7 +89,7 @@ struct Array { Array(Type itemType_, optional N_) : itemType(std::move(itemType_)), N(std::move(N_)) {} std::string getName() const { if (N) { - return "array<" + toString(itemType) + ", " + std::to_string(*N) + ">"; + return "array<" + toString(itemType) + ", " + util::toString(*N) + ">"; } else if (itemType == Value) { return "array"; } else { diff --git a/include/mbgl/util/string.hpp b/include/mbgl/util/string.hpp index 82d317c620..13498ccb92 100644 --- a/include/mbgl/util/string.hpp +++ b/include/mbgl/util/string.hpp @@ -25,6 +25,10 @@ inline int stoi(const std::string &str) return atoi(str.c_str()); } +inline float stof(const std::string &str) { + return static_cast(atof(str.c_str())); +} + } // namespace std #endif @@ -65,5 +69,9 @@ inline std::string toString(std::exception_ptr error) { } } +inline float stof(const std::string& str) { + return std::stof(str); +} + } // namespace util } // namespace mbgl diff --git a/src/mbgl/style/expression/array_assertion.cpp b/src/mbgl/style/expression/array_assertion.cpp index a62f67fbb5..29f6a47b10 100644 --- a/src/mbgl/style/expression/array_assertion.cpp +++ b/src/mbgl/style/expression/array_assertion.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace mbgl { namespace style { @@ -36,7 +37,7 @@ ParseResult ArrayAssertion::parse(const Convertible& value, ParsingContext& ctx) auto length = arrayLength(value); if (length < 2 || length > 4) { - ctx.error("Expected 1, 2, or 3 arguments, but found " + std::to_string(length - 1) + " instead."); + ctx.error("Expected 1, 2, or 3 arguments, but found " + util::toString(length - 1) + " instead."); return ParseResult(); } diff --git a/src/mbgl/style/expression/at.cpp b/src/mbgl/style/expression/at.cpp index d9beb63b52..e447d33bc7 100644 --- a/src/mbgl/style/expression/at.cpp +++ b/src/mbgl/style/expression/at.cpp @@ -1,4 +1,5 @@ #include +#include namespace mbgl { @@ -21,7 +22,7 @@ EvaluationResult At::evaluate(const EvaluationContext& params) const { if (i < 0 || i >= inputArray.size()) { return EvaluationError { "Array index out of bounds: " + stringify(i) + - " > " + std::to_string(inputArray.size()) + "." + " > " + util::toString(inputArray.size()) + "." }; } if (i != std::floor(i)) { @@ -43,7 +44,7 @@ ParseResult At::parse(const Convertible& value, ParsingContext& ctx) { std::size_t length = arrayLength(value); if (length != 3) { - ctx.error("Expected 2 arguments, but found " + std::to_string(length - 1) + " instead."); + ctx.error("Expected 2 arguments, but found " + util::toString(length - 1) + " instead."); return ParseResult(); } diff --git a/src/mbgl/style/expression/case.cpp b/src/mbgl/style/expression/case.cpp index a435b71fc5..049f258606 100644 --- a/src/mbgl/style/expression/case.cpp +++ b/src/mbgl/style/expression/case.cpp @@ -1,4 +1,5 @@ #include +#include namespace mbgl { namespace style { @@ -38,7 +39,7 @@ ParseResult Case::parse(const Convertible& value, ParsingContext& ctx) { assert(isArray(value)); auto length = arrayLength(value); if (length < 4) { - ctx.error("Expected at least 3 arguments, but found only " + std::to_string(length - 1) + "."); + ctx.error("Expected at least 3 arguments, but found only " + util::toString(length - 1) + "."); return ParseResult(); } diff --git a/src/mbgl/style/expression/coercion.cpp b/src/mbgl/style/expression/coercion.cpp index f2042ffd8f..8ed8e160dd 100644 --- a/src/mbgl/style/expression/coercion.cpp +++ b/src/mbgl/style/expression/coercion.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace mbgl { namespace style { @@ -11,7 +12,7 @@ EvaluationResult toNumber(const Value& v) { [](const double f) -> optional { return f; }, [](const std::string& s) -> optional { try { - return std::stof(s); + return util::stof(s); } catch(std::exception) { return optional(); } diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index c1e0639562..fa79357560 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -2,7 +2,9 @@ #include #include #include +#include #include +#include namespace mbgl { namespace style { @@ -350,7 +352,7 @@ std::unordered_map initiali define("sqrt", [](double x) -> Result { return sqrt(x); }); define("log10", [](double x) -> Result { return log10(x); }); define("ln", [](double x) -> Result { return log(x); }); - define("log2", [](double x) -> Result { return log2(x); }); + define("log2", [](double x) -> Result { return util::log2(x); }); define("sin", [](double x) -> Result { return sin(x); }); define("cos", [](double x) -> Result { return cos(x); }); define("tan", [](double x) -> Result { return tan(x); }); @@ -501,8 +503,8 @@ ParseResult createCompoundExpression(const std::string& name, const std::vector& params = signature->params.get>(); if (params.size() != args.size()) { signatureContext.error( - "Expected " + std::to_string(params.size()) + - " arguments, but found " + std::to_string(args.size()) + " instead." + "Expected " + util::toString(params.size()) + + " arguments, but found " + util::toString(args.size()) + " instead." ); continue; } diff --git a/src/mbgl/style/expression/interpolate.cpp b/src/mbgl/style/expression/interpolate.cpp index 020aba9dce..5ddfca8e9f 100644 --- a/src/mbgl/style/expression/interpolate.cpp +++ b/src/mbgl/style/expression/interpolate.cpp @@ -1,5 +1,5 @@ - #include +#include namespace mbgl { namespace style { @@ -73,7 +73,7 @@ ParseResult parseInterpolate(const Convertible& value, ParsingContext& ctx) { std::size_t minArgs = 4; if (length - 1 < minArgs) { - ctx.error("Expected at least 4 arguments, but found only " + std::to_string(length - 1) + "."); + ctx.error("Expected at least 4 arguments, but found only " + util::toString(length - 1) + "."); return ParseResult(); } diff --git a/src/mbgl/style/expression/let.cpp b/src/mbgl/style/expression/let.cpp index 8e206d3582..561e8515d4 100644 --- a/src/mbgl/style/expression/let.cpp +++ b/src/mbgl/style/expression/let.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace mbgl { namespace style { @@ -24,7 +25,7 @@ ParseResult Let::parse(const Convertible& value, ParsingContext& ctx) { std::size_t length = arrayLength(value); if (length < 4) { - ctx.error("Expected at least 3 arguments, but found " + std::to_string(length - 1) + " instead."); + ctx.error("Expected at least 3 arguments, but found " + util::toString(length - 1) + " instead."); return ParseResult(); } diff --git a/src/mbgl/style/expression/literal.cpp b/src/mbgl/style/expression/literal.cpp index fc11878bea..7e79fcbfe6 100644 --- a/src/mbgl/style/expression/literal.cpp +++ b/src/mbgl/style/expression/literal.cpp @@ -1,5 +1,5 @@ - #include +#include namespace mbgl { namespace style { @@ -70,7 +70,7 @@ ParseResult Literal::parse(const Convertible& value, ParsingContext& ctx) { } else if (isArray(value)) { // object or array value, quoted with ["literal", value] if (arrayLength(value) != 2) { - ctx.error("'literal' expression requires exactly one argument, but found " + std::to_string(arrayLength(value) - 1) + " instead."); + ctx.error("'literal' expression requires exactly one argument, but found " + util::toString(arrayLength(value) - 1) + " instead."); return ParseResult(); } const optional parsedValue = parseValue(arrayMember(value, 1), ctx); diff --git a/src/mbgl/style/expression/match.cpp b/src/mbgl/style/expression/match.cpp index 6336eba1e6..35356747c9 100644 --- a/src/mbgl/style/expression/match.cpp +++ b/src/mbgl/style/expression/match.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace mbgl { namespace style { @@ -75,7 +76,7 @@ optional parseInputValue(const Convertible& input, ParsingContext& pa value->match( [&] (uint64_t n) { if (!Value::isSafeInteger(n)) { - parentContext.error("Branch labels must be integers no larger than " + std::to_string(Value::maxSafeInteger()) + ".", index); + parentContext.error("Branch labels must be integers no larger than " + util::toString(Value::maxSafeInteger()) + ".", index); } else { type = {type::Number}; result = {static_cast(n)}; @@ -83,7 +84,7 @@ optional parseInputValue(const Convertible& input, ParsingContext& pa }, [&] (int64_t n) { if (!Value::isSafeInteger(n)) { - parentContext.error("Branch labels must be integers no larger than " + std::to_string(Value::maxSafeInteger()) + ".", index); + parentContext.error("Branch labels must be integers no larger than " + util::toString(Value::maxSafeInteger()) + ".", index); } else { type = {type::Number}; result = {n}; @@ -91,7 +92,7 @@ optional parseInputValue(const Convertible& input, ParsingContext& pa }, [&] (double n) { if (!Value::isSafeInteger(n)) { - parentContext.error("Branch labels must be integers no larger than " + std::to_string(Value::maxSafeInteger()) + ".", index); + parentContext.error("Branch labels must be integers no larger than " + util::toString(Value::maxSafeInteger()) + ".", index); } else if (n != std::floor(n)) { parentContext.error("Numeric branch labels must be integer values.", index); } else { @@ -167,7 +168,7 @@ ParseResult parseMatch(const Convertible& value, ParsingContext& ctx) { auto length = arrayLength(value); if (length < 5) { ctx.error( - "Expected at least 4 arguments, but found only " + std::to_string(length - 1) + "." + "Expected at least 4 arguments, but found only " + util::toString(length - 1) + "." ); return ParseResult(); } diff --git a/src/mbgl/style/expression/parsing_context.cpp b/src/mbgl/style/expression/parsing_context.cpp index 81cbdede59..501ba2749f 100644 --- a/src/mbgl/style/expression/parsing_context.cpp +++ b/src/mbgl/style/expression/parsing_context.cpp @@ -23,6 +23,8 @@ #include +#include + namespace mbgl { namespace style { namespace expression { @@ -55,7 +57,7 @@ bool isConstant(const Expression& expression) { using namespace mbgl::style::conversion; ParseResult ParsingContext::parse(const Convertible& value, std::size_t index_, optional expected_) { - ParsingContext child(key + "[" + std::to_string(index_) + "]", + ParsingContext child(key + "[" + util::toString(index_) + "]", errors, std::move(expected_), scope); @@ -64,7 +66,7 @@ ParseResult ParsingContext::parse(const Convertible& value, std::size_t index_, ParseResult ParsingContext::parse(const Convertible& value, std::size_t index_, optional expected_, const std::map>& bindings) { - ParsingContext child(key + "[" + std::to_string(index_) + "]", + ParsingContext child(key + "[" + util::toString(index_) + "]", errors, std::move(expected_), std::make_shared(bindings, scope)); diff --git a/src/mbgl/style/expression/step.cpp b/src/mbgl/style/expression/step.cpp index 2720e9257a..bfcb6fd270 100644 --- a/src/mbgl/style/expression/step.cpp +++ b/src/mbgl/style/expression/step.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace mbgl { @@ -50,7 +51,7 @@ ParseResult Step::parse(const mbgl::style::conversion::Convertible& value, Parsi auto length = arrayLength(value); if (length - 1 < 4) { - ctx.error("Expected at least 4 arguments, but found only " + std::to_string(length - 1) + "."); + ctx.error("Expected at least 4 arguments, but found only " + util::toString(length - 1) + "."); return ParseResult(); } -- cgit v1.2.1