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
Port Collator expressions to core/iOS/Android/Qt #11869
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fa1f5fe
[core, vendor] Create vendored nunicode 1.8.
ChrisLoer b23d8d0
[core] Introduce LanguageTag for parsing BCP 47 tags
ChrisLoer 8c5eac7
[core] Introduce "collator" expressions
ChrisLoer 2665ce4
[core] Default "collator" implementation
ChrisLoer 0a7a9d3
[ios, macos] Darwin "collator" implementation
ChrisLoer 3253fc8
[android] Android "collator" implementation
ChrisLoer ff4dda4
[test] Remove "collator" ignores
ChrisLoer 66f1d18
[ios, macos] Try to make darwin "resolvedLocale" BCP 47 compliant
ChrisLoer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Empty file.
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,5 @@ | ||
add_vendor_target(nunicode STATIC) | ||
|
||
target_compile_definitions(nunicode | ||
PRIVATE "-DNU_BUILD_STATIC" | ||
) |
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,29 @@ | ||
#pragma once | ||
|
||
#include <mbgl/util/feature.hpp> | ||
#include <mbgl/util/optional.hpp> | ||
|
||
#include <string> | ||
#include <memory> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
namespace expression { | ||
|
||
class Collator { | ||
public: | ||
Collator(bool caseSensitive, bool diacriticSensitive, optional<std::string> locale = {}); | ||
|
||
bool operator==(const Collator& other) const; | ||
|
||
int compare(const std::string& lhs, const std::string& rhs) const; | ||
|
||
std::string resolvedLocale() const; | ||
private: | ||
class Impl; | ||
std::shared_ptr<Impl> impl; | ||
}; | ||
|
||
} // 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,44 @@ | ||
#pragma once | ||
|
||
#include <mbgl/style/expression/expression.hpp> | ||
#include <mbgl/style/expression/parsing_context.hpp> | ||
#include <mbgl/style/conversion.hpp> | ||
|
||
#include <memory> | ||
|
||
namespace mbgl { | ||
namespace style { | ||
namespace expression { | ||
|
||
class CollatorExpression : public Expression { | ||
public: | ||
CollatorExpression(std::unique_ptr<Expression> caseSensitive, | ||
std::unique_ptr<Expression> diacriticSensitive, | ||
optional<std::unique_ptr<Expression>> locale); | ||
|
||
EvaluationResult evaluate(const EvaluationContext&) const override; | ||
static ParseResult parse(const mbgl::style::conversion::Convertible&, ParsingContext&); | ||
|
||
void eachChild(const std::function<void(const Expression&)>&) const override; | ||
|
||
bool operator==(const Expression& e) const override; | ||
|
||
std::vector<optional<Value>> possibleOutputs() const override { | ||
// Technically the set of possible outputs is the combinatoric set of Collators produced | ||
// by all possibleOutputs of locale/caseSensitive/diacriticSensitive | ||
// But for the primary use of Collators in comparison operators, we ignore the Collator's | ||
// possibleOutputs anyway, so we can get away with leaving this undefined for now. | ||
return { nullopt }; | ||
} | ||
|
||
mbgl::Value serialize() const override; | ||
std::string getOperator() const override { return "collator"; } | ||
private: | ||
std::unique_ptr<Expression> caseSensitive; | ||
std::unique_ptr<Expression> diacriticSensitive; | ||
optional<std::unique_ptr<Expression>> locale; | ||
}; | ||
|
||
} // 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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, why the
NOLINT
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a complaint about not using the
default
constructor (which actually wouldn't compile on all platforms). I never figured out why -- I wonder if it has some magic relation to being ordered last in the variant declaration? I'll try switching that withErrorType
and see what happens.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, still get the error without the // NOLINT: