Skip to content

Commit ff92faa

Browse files
authored
avoiding macro clash (#854)
* avoiding macro clash * missed this one
1 parent ea07694 commit ff92faa

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

include/ada/url_pattern.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ enum class url_pattern_part_type : uint8_t {
4242

4343
enum class url_pattern_part_modifier : uint8_t {
4444
// The part does not have a modifier.
45-
NONE,
45+
none,
4646
// The part has an optional modifier indicated by the U+003F (?) code point.
47-
OPTIONAL,
47+
optional,
4848
// The part has a "zero or more" modifier indicated by the U+002A (*) code
4949
// point.
50-
ZERO_OR_MORE,
50+
zero_or_more,
5151
// The part has a "one or more" modifier indicated by the U+002B (+) code
5252
// point.
53-
ONE_OR_MORE,
53+
one_or_more,
5454
};
5555

5656
// @see https://urlpattern.spec.whatwg.org/#part

include/ada/url_pattern_helpers-inl.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,13 @@ inline ada_warn_unused std::optional<errors>
425425
Tokenizer::process_tokenizing_error(size_t next_position,
426426
size_t value_position) {
427427
// If tokenizer’s policy is "strict", then throw a TypeError.
428-
if (policy == token_policy::STRICT) {
428+
if (policy == token_policy::strict) {
429429
ada_log("process_tokenizing_error failed with next_position=",
430430
next_position, " value_position=", value_position);
431431
return errors::type_error;
432432
}
433433
// Assert: tokenizer’s policy is "lenient".
434-
ADA_ASSERT_TRUE(policy == token_policy::LENIENT);
434+
ADA_ASSERT_TRUE(policy == token_policy::lenient);
435435
// Run add a token with default length given tokenizer, "invalid-char", next
436436
// position, and value position.
437437
add_token_with_default_length(token_type::INVALID_CHAR, next_position,
@@ -535,7 +535,7 @@ url_pattern_parser<F>::maybe_add_part_from_the_pending_fixed_value() {
535535
// Append part to parser’s part list.
536536
parts.emplace_back(url_pattern_part_type::FIXED_TEXT,
537537
std::move(*encoded_value),
538-
url_pattern_part_modifier::NONE);
538+
url_pattern_part_modifier::none);
539539
return std::nullopt;
540540
}
541541

@@ -544,26 +544,26 @@ std::optional<errors> url_pattern_parser<F>::add_part(
544544
std::string_view prefix, token* name_token, token* regexp_or_wildcard_token,
545545
std::string_view suffix, token* modifier_token) {
546546
// Let modifier be "none".
547-
auto modifier = url_pattern_part_modifier::NONE;
547+
auto modifier = url_pattern_part_modifier::none;
548548
// If modifier token is not null:
549549
if (modifier_token) {
550550
// If modifier token’s value is "?" then set modifier to "optional".
551551
if (modifier_token->value == "?") {
552-
modifier = url_pattern_part_modifier::OPTIONAL;
552+
modifier = url_pattern_part_modifier::optional;
553553
} else if (modifier_token->value == "*") {
554554
// Otherwise if modifier token’s value is "*" then set modifier to
555555
// "zero-or-more".
556-
modifier = url_pattern_part_modifier::ZERO_OR_MORE;
556+
modifier = url_pattern_part_modifier::zero_or_more;
557557
} else if (modifier_token->value == "+") {
558558
// Otherwise if modifier token’s value is "+" then set modifier to
559559
// "one-or-more".
560-
modifier = url_pattern_part_modifier::ONE_OR_MORE;
560+
modifier = url_pattern_part_modifier::one_or_more;
561561
}
562562
}
563563
// If name token is null and regexp or wildcard token is null and modifier
564564
// is "none":
565565
if (!name_token && !regexp_or_wildcard_token &&
566-
modifier == url_pattern_part_modifier::NONE) {
566+
modifier == url_pattern_part_modifier::none) {
567567
// Append prefix to the end of parser’s pending fixed value.
568568
pending_fixed_value.append(prefix);
569569
return std::nullopt;
@@ -668,7 +668,7 @@ tl::expected<std::vector<url_pattern_part>, errors> parse_pattern_string(
668668
encoding_callback, generate_segment_wildcard_regexp(options));
669669
// Set parser’s token list to the result of running tokenize given input and
670670
// "strict".
671-
auto tokenize_result = tokenize(input, token_policy::STRICT);
671+
auto tokenize_result = tokenize(input, token_policy::strict);
672672
if (!tokenize_result) {
673673
ada_log("parse_pattern_string tokenize failed");
674674
return tl::unexpected(tokenize_result.error());
@@ -828,7 +828,7 @@ constructor_string_parser<regex_provider>::parse(std::string_view input) {
828828
ada_log("constructor_string_parser::parse input=", input);
829829
// Let parser be a new constructor string parser whose input is input and
830830
// token list is the result of running tokenize given input and "lenient".
831-
auto token_list = tokenize(input, token_policy::LENIENT);
831+
auto token_list = tokenize(input, token_policy::lenient);
832832
if (!token_list) {
833833
return tl::unexpected(token_list.error());
834834
}

include/ada/url_pattern_helpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ std::string to_string(token_type type);
3737

3838
// @see https://urlpattern.spec.whatwg.org/#tokenize-policy
3939
enum class token_policy {
40-
STRICT,
41-
LENIENT,
40+
strict,
41+
lenient,
4242
};
4343

4444
// @see https://urlpattern.spec.whatwg.org/#tokens

src/url_pattern_helpers.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ generate_regular_expression_and_name_list(
2222
// If part's type is "fixed-text":
2323
if (part.type == url_pattern_part_type::FIXED_TEXT) {
2424
// If part's modifier is "none"
25-
if (part.modifier == url_pattern_part_modifier::NONE) {
25+
if (part.modifier == url_pattern_part_modifier::none) {
2626
// Append the result of running escape a regexp string given part's
2727
// value
2828
result += escape_regexp_string(part.value);
@@ -68,8 +68,8 @@ generate_regular_expression_and_name_list(
6868
// string
6969
if (part.prefix.empty() && part.suffix.empty()) {
7070
// If part's modifier is "none" or "optional"
71-
if (part.modifier == url_pattern_part_modifier::NONE ||
72-
part.modifier == url_pattern_part_modifier::OPTIONAL) {
71+
if (part.modifier == url_pattern_part_modifier::none ||
72+
part.modifier == url_pattern_part_modifier::optional) {
7373
// (<regexp value>)<modifier>
7474
result += "(" + regexp_value + ")" +
7575
convert_modifier_to_string(part.modifier);
@@ -82,8 +82,8 @@ generate_regular_expression_and_name_list(
8282
}
8383

8484
// If part's modifier is "none" or "optional"
85-
if (part.modifier == url_pattern_part_modifier::NONE ||
86-
part.modifier == url_pattern_part_modifier::OPTIONAL) {
85+
if (part.modifier == url_pattern_part_modifier::none ||
86+
part.modifier == url_pattern_part_modifier::optional) {
8787
// (?:<prefix>(<regexp value>)<suffix>)<modifier>
8888
result += "(?:" + escape_regexp_string(part.prefix) + "(" + regexp_value +
8989
")" + escape_regexp_string(part.suffix) + ")" +
@@ -92,8 +92,8 @@ generate_regular_expression_and_name_list(
9292
}
9393

9494
// Assert: part's modifier is "zero-or-more" or "one-or-more"
95-
ADA_ASSERT_TRUE(part.modifier == url_pattern_part_modifier::ZERO_OR_MORE ||
96-
part.modifier == url_pattern_part_modifier::ONE_OR_MORE);
95+
ADA_ASSERT_TRUE(part.modifier == url_pattern_part_modifier::zero_or_more ||
96+
part.modifier == url_pattern_part_modifier::one_or_more);
9797

9898
// Assert: part's prefix is not the empty string or part's suffix is not the
9999
// empty string
@@ -131,7 +131,7 @@ generate_regular_expression_and_name_list(
131131
result.append(")");
132132

133133
// If part's modifier is "zero-or-more" then append "?" to the end of result
134-
if (part.modifier == url_pattern_part_modifier::ZERO_OR_MORE) {
134+
if (part.modifier == url_pattern_part_modifier::zero_or_more) {
135135
result += "?";
136136
}
137137
}
@@ -162,13 +162,13 @@ std::string convert_modifier_to_string(url_pattern_part_modifier modifier) {
162162
// TODO: Optimize this.
163163
switch (modifier) {
164164
// If modifier is "zero-or-more", then return "*".
165-
case url_pattern_part_modifier::ZERO_OR_MORE:
165+
case url_pattern_part_modifier::zero_or_more:
166166
return "*";
167167
// If modifier is "optional", then return "?".
168-
case url_pattern_part_modifier::OPTIONAL:
168+
case url_pattern_part_modifier::optional:
169169
return "?";
170170
// If modifier is "one-or-more", then return "+".
171-
case url_pattern_part_modifier::ONE_OR_MORE:
171+
case url_pattern_part_modifier::one_or_more:
172172
return "+";
173173
// Return the empty string.
174174
default:
@@ -855,7 +855,7 @@ std::string generate_pattern_string(
855855
// If part’s type is "fixed-text" then:
856856
if (part.type == url_pattern_part_type::FIXED_TEXT) {
857857
// If part’s modifier is "none" then:
858-
if (part.modifier == url_pattern_part_modifier::NONE) {
858+
if (part.modifier == url_pattern_part_modifier::none) {
859859
// Append the result of running escape a pattern string given part’s
860860
// value to the end of result.
861861
result.append(escape_pattern_string(part.value));
@@ -895,7 +895,7 @@ std::string generate_pattern_string(
895895
// - next part’s suffix is the empty string
896896
if (!needs_grouping && custom_name &&
897897
part.type == url_pattern_part_type::SEGMENT_WILDCARD &&
898-
part.modifier == url_pattern_part_modifier::NONE &&
898+
part.modifier == url_pattern_part_modifier::none &&
899899
next_part.has_value() && next_part->prefix.empty() &&
900900
next_part->suffix.empty()) {
901901
// If next part’s type is "fixed-text":
@@ -978,7 +978,7 @@ std::string generate_pattern_string(
978978
if (!custom_name &&
979979
(!previous_part.has_value() ||
980980
previous_part->type == url_pattern_part_type::FIXED_TEXT ||
981-
previous_part->modifier != url_pattern_part_modifier::NONE ||
981+
previous_part->modifier != url_pattern_part_modifier::none ||
982982
needs_grouping || !part.prefix.empty())) {
983983
result.append("*");
984984
} else {

tests/wpt_urlpattern_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ TEST(wpt_urlpattern_tests, test_regex_difference) {
4343

4444
TEST(wpt_urlpattern_tests, parser_tokenize_basic_tests) {
4545
auto tokenize_result =
46-
tokenize("*", ada::url_pattern_helpers::token_policy::STRICT);
46+
tokenize("*", ada::url_pattern_helpers::token_policy::strict);
4747
ASSERT_TRUE(tokenize_result);
4848
}
4949

0 commit comments

Comments
 (0)