This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ports mapbox/mapbox-gl-js#4777 (and its several follow-ups)
- Loading branch information
1 parent
9aac976
commit f648cfe
Showing
167 changed files
with
6,460 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include <mbgl/style/expression/parsing_context.hpp> | ||
#include <mbgl/style/expression/type.hpp> | ||
#include <mbgl/style/conversion.hpp> | ||
|
||
#include <memory> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
namespace conversion { | ||
|
||
using namespace mbgl::style::expression; | ||
|
||
template<> struct Converter<std::unique_ptr<Expression>> { | ||
optional<std::unique_ptr<Expression>> operator()(const Convertible& value, Error& error, type::Type expected) const { | ||
ParsingContext ctx(optional<type::Type> {expected}); | ||
ParseResult parsed = ctx.parse(value); | ||
if (parsed) { | ||
return std::move(*parsed); | ||
} | ||
std::string combinedError; | ||
for (const ParsingError& parsingError : ctx.getErrors()) { | ||
if (combinedError.size() > 0) { | ||
combinedError += "\n"; | ||
} | ||
if (parsingError.key.size() > 0) { | ||
combinedError += parsingError.key + ": "; | ||
} | ||
combinedError += parsingError.message; | ||
} | ||
error = { combinedError }; | ||
return {}; | ||
}; | ||
}; | ||
|
||
} // namespace conversion | ||
} // namespace style | ||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include <mbgl/style/conversion.hpp> | ||
#include <string> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
namespace conversion { | ||
|
||
std::string getJSONType(const Convertible& value); | ||
|
||
} // namespace conversion | ||
} // namespace style | ||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include <mbgl/style/expression/expression.hpp> | ||
#include <mbgl/style/expression/type.hpp> | ||
#include <mbgl/style/expression/parsing_context.hpp> | ||
#include <mbgl/style/conversion.hpp> | ||
|
||
#include <memory> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
namespace expression { | ||
|
||
class ArrayAssertion : public Expression { | ||
public: | ||
ArrayAssertion(type::Array type_, std::unique_ptr<Expression> input_) : | ||
Expression(type_), | ||
input(std::move(input_)) | ||
{} | ||
|
||
static ParseResult parse(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx); | ||
|
||
EvaluationResult evaluate(const EvaluationContext& params) const override; | ||
void eachChild(const std::function<void(const Expression&)>& visit) const override; | ||
|
||
bool operator==(const Expression& e) const override { | ||
if (auto rhs = dynamic_cast<const ArrayAssertion*>(&e)) { | ||
return getType() == rhs->getType() && *input == *(rhs->input); | ||
} | ||
return false; | ||
} | ||
|
||
private: | ||
std::unique_ptr<Expression> input; | ||
}; | ||
|
||
} // namespace expression | ||
} // namespace style | ||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
#include <mbgl/style/expression/expression.hpp> | ||
#include <mbgl/style/conversion.hpp> | ||
#include <mbgl/style/expression/parsing_context.hpp> | ||
#include <memory> | ||
#include <vector> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
namespace expression { | ||
|
||
class Assertion : public Expression { | ||
public: | ||
Assertion(type::Type type_, std::vector<std::unique_ptr<Expression>> inputs_) : | ||
Expression(type_), | ||
inputs(std::move(inputs_)) | ||
{} | ||
|
||
static ParseResult parse(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx); | ||
|
||
EvaluationResult evaluate(const EvaluationContext& params) const override; | ||
void eachChild(const std::function<void(const Expression&)>& visit) const override; | ||
|
||
bool operator==(const Expression& e) const override; | ||
|
||
private: | ||
std::vector<std::unique_ptr<Expression>> inputs; | ||
}; | ||
|
||
} // namespace expression | ||
} // namespace style | ||
} // namespace mbgl | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include <mbgl/style/expression/expression.hpp> | ||
#include <mbgl/style/conversion.hpp> | ||
#include <memory> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
namespace expression { | ||
|
||
class At : public Expression { | ||
public: | ||
At(std::unique_ptr<Expression> index_, std::unique_ptr<Expression> input_) : | ||
Expression(input_->getType().get<type::Array>().itemType), | ||
index(std::move(index_)), | ||
input(std::move(input_)) | ||
{} | ||
|
||
static ParseResult parse(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx); | ||
|
||
EvaluationResult evaluate(const EvaluationContext& params) const override; | ||
void eachChild(const std::function<void(const Expression&)>&) const override; | ||
|
||
bool operator==(const Expression& e) const override { | ||
if (auto rhs = dynamic_cast<const At*>(&e)) { | ||
return *index == *(rhs->index) && *input == *(rhs->input); | ||
} | ||
return false; | ||
} | ||
|
||
private: | ||
std::unique_ptr<Expression> index; | ||
std::unique_ptr<Expression> input; | ||
}; | ||
|
||
} // namespace expression | ||
} // namespace style | ||
} // namespace mbgl |
Oops, something went wrong.