summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2017-11-10 20:04:20 -0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-11-12 13:17:57 -0200
commit92608f58858d77c17a65ae9b29758e74bb2da7d2 (patch)
treef4b0287febdea20ae58d4dc31be294d50253b254
parent465b345dd2d9e8ff95accecc84b6ec6ff24e0a2f (diff)
downloadqtlocation-mapboxgl-92608f58858d77c17a65ae9b29758e74bb2da7d2.tar.gz
[core] Fix build on Android + GCC and Android + armeabi
Sadly we don't have bots for these two setups.
-rw-r--r--include/mbgl/style/expression/parsing_context.hpp5
-rw-r--r--include/mbgl/style/expression/type.hpp3
-rw-r--r--include/mbgl/util/string.hpp8
-rw-r--r--src/mbgl/style/expression/array_assertion.cpp3
-rw-r--r--src/mbgl/style/expression/at.cpp5
-rw-r--r--src/mbgl/style/expression/case.cpp3
-rw-r--r--src/mbgl/style/expression/coercion.cpp3
-rw-r--r--src/mbgl/style/expression/compound_expression.cpp8
-rw-r--r--src/mbgl/style/expression/interpolate.cpp4
-rw-r--r--src/mbgl/style/expression/let.cpp3
-rw-r--r--src/mbgl/style/expression/literal.cpp4
-rw-r--r--src/mbgl/style/expression/match.cpp9
-rw-r--r--src/mbgl/style/expression/parsing_context.cpp6
-rw-r--r--src/mbgl/style/expression/step.cpp3
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 <mbgl/util/optional.hpp>
+#include <mbgl/util/string.hpp>
#include <mbgl/style/expression/type.hpp>
#include <mbgl/style/conversion.hpp>
@@ -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 <mbgl/util/optional.hpp>
+#include <mbgl/util/string.hpp>
#include <mbgl/util/variant.hpp>
#include <vector>
@@ -88,7 +89,7 @@ struct Array {
Array(Type itemType_, optional<std::size_t> 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<float>(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 <mbgl/style/expression/array_assertion.hpp>
#include <mbgl/style/expression/check_subtype.hpp>
+#include <mbgl/util/string.hpp>
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 <mbgl/style/expression/at.hpp>
+#include <mbgl/util/string.hpp>
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 <mbgl/style/expression/case.hpp>
+#include <mbgl/util/string.hpp>
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 <mbgl/style/expression/coercion.hpp>
#include <mbgl/style/expression/check_subtype.hpp>
#include <mbgl/style/expression/util.hpp>
+#include <mbgl/util/string.hpp>
namespace mbgl {
namespace style {
@@ -11,7 +12,7 @@ EvaluationResult toNumber(const Value& v) {
[](const double f) -> optional<double> { return f; },
[](const std::string& s) -> optional<double> {
try {
- return std::stof(s);
+ return util::stof(s);
} catch(std::exception) {
return optional<double>();
}
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 <mbgl/style/expression/check_subtype.hpp>
#include <mbgl/style/expression/util.hpp>
#include <mbgl/tile/geometry_tile_data.hpp>
+#include <mbgl/math/log2.hpp>
#include <mbgl/util/ignore.hpp>
+#include <mbgl/util/string.hpp>
namespace mbgl {
namespace style {
@@ -350,7 +352,7 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali
define("sqrt", [](double x) -> Result<double> { return sqrt(x); });
define("log10", [](double x) -> Result<double> { return log10(x); });
define("ln", [](double x) -> Result<double> { return log(x); });
- define("log2", [](double x) -> Result<double> { return log2(x); });
+ define("log2", [](double x) -> Result<double> { return util::log2(x); });
define("sin", [](double x) -> Result<double> { return sin(x); });
define("cos", [](double x) -> Result<double> { return cos(x); });
define("tan", [](double x) -> Result<double> { return tan(x); });
@@ -501,8 +503,8 @@ ParseResult createCompoundExpression(const std::string& name,
const std::vector<type::Type>& params = signature->params.get<std::vector<type::Type>>();
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 <mbgl/style/expression/interpolate.hpp>
+#include <mbgl/util/string.hpp>
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 <mbgl/style/expression/let.hpp>
#include <mbgl/style/conversion/get_json_type.hpp>
+#include <mbgl/util/string.hpp>
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 <mbgl/style/expression/literal.hpp>
+#include <mbgl/util/string.hpp>
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<Value> 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 <mbgl/style/expression/match.hpp>
#include <mbgl/style/expression/check_subtype.hpp>
#include <mbgl/style/expression/parsing_context.hpp>
+#include <mbgl/util/string.hpp>
namespace mbgl {
namespace style {
@@ -75,7 +76,7 @@ optional<InputType> 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<int64_t>(n)};
@@ -83,7 +84,7 @@ optional<InputType> 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<InputType> 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 <mbgl/style/conversion/get_json_type.hpp>
+#include <mbgl/util/string.hpp>
+
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<type::Type> 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<type::Type> expected_,
const std::map<std::string, std::shared_ptr<Expression>>& bindings) {
- ParsingContext child(key + "[" + std::to_string(index_) + "]",
+ ParsingContext child(key + "[" + util::toString(index_) + "]",
errors,
std::move(expected_),
std::make_shared<detail::Scope>(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 <mbgl/style/expression/step.hpp>
#include <mbgl/style/expression/get_covering_stops.hpp>
+#include <mbgl/util/string.hpp>
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();
}