[core] Fix build on Android + GCC and Android + armeabi

Sadly we don't have bots for these two setups.
This commit is contained in:
Thiago Marcos P. Santos
2017-11-10 20:04:20 -02:00
parent 465b345dd2
commit 92608f5885
14 changed files with 44 additions and 23 deletions

View File

@@ -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) {

View File

@@ -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 {

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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>();
}

View File

@@ -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;
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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();
}

View File

@@ -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));

View File

@@ -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();
}