Skip to content

Commit 3633aed

Browse files
committedFeb 24, 2025·
feat: Ada 3.1.1
1 parent b31fc5f commit 3633aed

File tree

2 files changed

+802
-784
lines changed

2 files changed

+802
-784
lines changed
 

‎test-app/runtime/src/main/cpp/ada/ada.cpp

+53-53
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2025-02-11 09:47:50 -0500. Do not edit! */
1+
/* auto-generated on 2025-02-23 20:08:55 -0500. Do not edit! */
22
/* begin file src/ada.cpp */
33
#include "ada.h"
44
/* begin file src/checkers.cpp */
@@ -64,23 +64,24 @@ ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept {
6464
// encoding.
6565
static constexpr std::array<uint8_t, 256> path_signature_table =
6666
[]() consteval {
67-
std::array<uint8_t, 256> result{};
68-
for (size_t i = 0; i < 256; i++) {
69-
if (i <= 0x20 || i == 0x22 || i == 0x23 || i == 0x3c || i == 0x3e ||
70-
i == 0x3f || i == 0x60 || i == 0x7b || i == 0x7d || i > 0x7e) {
71-
result[i] = 1;
72-
} else if (i == 0x25) {
73-
result[i] = 8;
74-
} else if (i == 0x2e) {
75-
result[i] = 4;
76-
} else if (i == 0x5c) {
77-
result[i] = 2;
78-
} else {
79-
result[i] = 0;
80-
}
81-
}
82-
return result;
83-
}();
67+
std::array<uint8_t, 256> result{};
68+
for (size_t i = 0; i < 256; i++) {
69+
if (i <= 0x20 || i == 0x22 || i == 0x23 || i == 0x3c || i == 0x3e ||
70+
i == 0x3f || i == 0x60 || i == 0x7b || i == 0x7d || i > 0x7e) {
71+
result[i] = 1;
72+
} else if (i == 0x25) {
73+
result[i] = 8;
74+
} else if (i == 0x2e) {
75+
result[i] = 4;
76+
} else if (i == 0x5c) {
77+
result[i] = 2;
78+
} else {
79+
result[i] = 0;
80+
}
81+
}
82+
return result;
83+
}
84+
();
8485

8586
ada_really_inline constexpr uint8_t path_signature(
8687
std::string_view input) noexcept {
@@ -15225,7 +15226,7 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) {
1522515226
namespace ada {
1522615227

1522715228
tl::expected<url_pattern_init, errors> url_pattern_init::process(
15228-
url_pattern_init init, std::string_view type,
15229+
url_pattern_init init, url_pattern_init::process_type type,
1522915230
std::optional<std::string_view> protocol,
1523015231
std::optional<std::string_view> username,
1523115232
std::optional<std::string_view> password,
@@ -15287,8 +15288,8 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(
1528715288
// If type is not "pattern" and init contains none of "protocol",
1528815289
// "hostname", "port" and "username", then set result["username"] to the
1528915290
// result of processing a base URL string given baseURL’s username and type.
15290-
if (type != "pattern" && !init.protocol && !init.hostname && !init.port &&
15291-
!init.username) {
15291+
if (type != process_type::pattern && !init.protocol && !init.hostname &&
15292+
!init.port && !init.username) {
1529215293
result.username = url_pattern_helpers::process_base_url_string(
1529315294
base_url->get_username(), type);
1529415295
}
@@ -15298,8 +15299,8 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(
1529815299
// "hostname", "port", "username" and "password", then set
1529915300
// result["password"] to the result of processing a base URL string given
1530015301
// baseURL’s password and type.
15301-
if (type != "pattern" && !init.protocol && !init.hostname && !init.port &&
15302-
!init.username && !init.password) {
15302+
if (type != process_type::pattern && !init.protocol && !init.hostname &&
15303+
!init.port && !init.username && !init.password) {
1530315304
result.password = url_pattern_helpers::process_base_url_string(
1530415305
base_url->get_password(), type);
1530515306
}
@@ -15418,6 +15419,8 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(
1541815419
!url_pattern_helpers::is_absolute_pathname(*result.pathname, type)) {
1541915420
// Let baseURLPath be the result of running process a base URL string
1542015421
// given the result of URL path serializing baseURL and type.
15422+
// TODO: Optimization opportunity: Avoid returning a string if no slash
15423+
// exist.
1542115424
std::string base_url_path = url_pattern_helpers::process_base_url_string(
1542215425
base_url->get_pathname(), type);
1542315426

@@ -15430,12 +15433,12 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(
1543015433
if (slash_index != std::string::npos) {
1543115434
// Let new pathname be the code point substring from 0 to slash index +
1543215435
// 1 within baseURLPath.
15433-
std::string new_pathname = base_url_path.substr(0, slash_index + 1);
15436+
base_url_path.resize(slash_index + 1);
1543415437
// Append result["pathname"] to the end of new pathname.
1543515438
ADA_ASSERT_TRUE(result.pathname.has_value());
15436-
new_pathname.append(result.pathname.value());
15439+
base_url_path.append(std::move(*result.pathname));
1543715440
// Set result["pathname"] to new pathname.
15438-
result.pathname = std::move(new_pathname);
15441+
result.pathname = std::move(base_url_path);
1543915442
}
1544015443
}
1544115444

@@ -15473,56 +15476,56 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(
1547315476
}
1547415477

1547515478
tl::expected<std::string, errors> url_pattern_init::process_protocol(
15476-
std::string_view value, std::string_view type) {
15479+
std::string_view value, process_type type) {
1547715480
ada_log("process_protocol=", value, " [", type, "]");
1547815481
// Let strippedValue be the given value with a single trailing U+003A (:)
1547915482
// removed, if any.
1548015483
if (value.ends_with(":")) {
1548115484
value.remove_suffix(1);
1548215485
}
1548315486
// If type is "pattern" then return strippedValue.
15484-
if (type == "pattern") {
15487+
if (type == process_type::pattern) {
1548515488
return std::string(value);
1548615489
}
1548715490
// Return the result of running canonicalize a protocol given strippedValue.
1548815491
return url_pattern_helpers::canonicalize_protocol(value);
1548915492
}
1549015493

1549115494
tl::expected<std::string, errors> url_pattern_init::process_username(
15492-
std::string_view value, std::string_view type) {
15495+
std::string_view value, process_type type) {
1549315496
// If type is "pattern" then return value.
15494-
if (type == "pattern") {
15497+
if (type == process_type::pattern) {
1549515498
return std::string(value);
1549615499
}
1549715500
// Return the result of running canonicalize a username given value.
1549815501
return url_pattern_helpers::canonicalize_username(value);
1549915502
}
1550015503

1550115504
tl::expected<std::string, errors> url_pattern_init::process_password(
15502-
std::string_view value, std::string_view type) {
15505+
std::string_view value, process_type type) {
1550315506
// If type is "pattern" then return value.
15504-
if (type == "pattern") {
15507+
if (type == process_type::pattern) {
1550515508
return std::string(value);
1550615509
}
1550715510
// Return the result of running canonicalize a password given value.
1550815511
return url_pattern_helpers::canonicalize_password(value);
1550915512
}
1551015513

1551115514
tl::expected<std::string, errors> url_pattern_init::process_hostname(
15512-
std::string_view value, std::string_view type) {
15515+
std::string_view value, process_type type) {
1551315516
ada_log("process_hostname value=", value, " type=", type);
1551415517
// If type is "pattern" then return value.
15515-
if (type == "pattern") {
15518+
if (type == process_type::pattern) {
1551615519
return std::string(value);
1551715520
}
1551815521
// Return the result of running canonicalize a hostname given value.
1551915522
return url_pattern_helpers::canonicalize_hostname(value);
1552015523
}
1552115524

1552215525
tl::expected<std::string, errors> url_pattern_init::process_port(
15523-
std::string_view port, std::string_view protocol, std::string_view type) {
15526+
std::string_view port, std::string_view protocol, process_type type) {
1552415527
// If type is "pattern" then return portValue.
15525-
if (type == "pattern") {
15528+
if (type == process_type::pattern) {
1552615529
return std::string(port);
1552715530
}
1552815531
// Return the result of running canonicalize a port given portValue and
@@ -15531,9 +15534,9 @@ tl::expected<std::string, errors> url_pattern_init::process_port(
1553115534
}
1553215535

1553315536
tl::expected<std::string, errors> url_pattern_init::process_pathname(
15534-
std::string_view value, std::string_view protocol, std::string_view type) {
15537+
std::string_view value, std::string_view protocol, process_type type) {
1553515538
// If type is "pattern" then return pathnameValue.
15536-
if (type == "pattern") {
15539+
if (type == process_type::pattern) {
1553715540
return std::string(value);
1553815541
}
1553915542

@@ -15549,31 +15552,31 @@ tl::expected<std::string, errors> url_pattern_init::process_pathname(
1554915552
}
1555015553

1555115554
tl::expected<std::string, errors> url_pattern_init::process_search(
15552-
std::string_view value, std::string_view type) {
15555+
std::string_view value, process_type type) {
1555315556
// Let strippedValue be the given value with a single leading U+003F (?)
1555415557
// removed, if any.
1555515558
if (value.starts_with("?")) {
1555615559
value.remove_prefix(1);
1555715560
}
1555815561
ADA_ASSERT_TRUE(!value.starts_with("?"));
1555915562
// If type is "pattern" then return strippedValue.
15560-
if (type == "pattern") {
15563+
if (type == process_type::pattern) {
1556115564
return std::string(value);
1556215565
}
1556315566
// Return the result of running canonicalize a search given strippedValue.
1556415567
return url_pattern_helpers::canonicalize_search(value);
1556515568
}
1556615569

1556715570
tl::expected<std::string, errors> url_pattern_init::process_hash(
15568-
std::string_view value, std::string_view type) {
15571+
std::string_view value, process_type type) {
1556915572
// Let strippedValue be the given value with a single leading U+0023 (#)
1557015573
// removed, if any.
1557115574
if (value.starts_with("#")) {
1557215575
value.remove_prefix(1);
1557315576
}
1557415577
ADA_ASSERT_TRUE(!value.starts_with("#"));
1557515578
// If type is "pattern" then return strippedValue.
15576-
if (type == "pattern") {
15579+
if (type == process_type::pattern) {
1557715580
return std::string(value);
1557815581
}
1557915582
// Return the result of running canonicalize a hash given strippedValue.
@@ -15599,7 +15602,6 @@ generate_regular_expression_and_name_list(
1559915602

1560015603
// Let name list be a new list
1560115604
std::vector<std::string> name_list{};
15602-
const std::string full_wildcard_regexp_value = ".*";
1560315605

1560415606
// For each part of part list:
1560515607
for (const url_pattern_part& part : part_list) {
@@ -15645,7 +15647,7 @@ generate_regular_expression_and_name_list(
1564515647
// Otherwise if part's type is "full-wildcard"
1564615648
else if (part.type == url_pattern_part_type::FULL_WILDCARD) {
1564715649
// then set regexp value to full wildcard regexp value.
15648-
regexp_value = full_wildcard_regexp_value;
15650+
regexp_value = ".*";
1564915651
}
1565015652

1565115653
// If part's prefix is the empty string and part's suffix is the empty
@@ -15724,7 +15726,7 @@ generate_regular_expression_and_name_list(
1572415726
result += "$";
1572515727

1572615728
// Return (result, name list)
15727-
return {result, name_list};
15729+
return {std::move(result), std::move(name_list)};
1572815730
}
1572915731

1573015732
bool is_ipv6_address(std::string_view input) noexcept {
@@ -16387,33 +16389,31 @@ std::string escape_regexp_string(std::string_view input) {
1638716389
}
1638816390

1638916391
std::string process_base_url_string(std::string_view input,
16390-
std::string_view type) {
16392+
url_pattern_init::process_type type) {
1639116393
// If type is not "pattern" return input.
16392-
if (type != "pattern") {
16394+
if (type != url_pattern_init::process_type::pattern) {
1639316395
return std::string(input);
1639416396
}
1639516397
// Return the result of escaping a pattern string given input.
1639616398
return escape_pattern_string(input);
1639716399
}
1639816400

16399-
constexpr bool is_absolute_pathname(std::string_view input,
16400-
std::string_view type) noexcept {
16401+
constexpr bool is_absolute_pathname(
16402+
std::string_view input, url_pattern_init::process_type type) noexcept {
1640116403
// If input is the empty string, then return false.
1640216404
if (input.empty()) [[unlikely]] {
1640316405
return false;
1640416406
}
1640516407
// If input[0] is U+002F (/), then return true.
1640616408
if (input.starts_with("/")) return true;
1640716409
// If type is "url", then return false.
16408-
if (type == "url") return false;
16410+
if (type == url_pattern_init::process_type::url) return false;
1640916411
// If input’s code point length is less than 2, then return false.
1641016412
if (input.size() < 2) return false;
1641116413
// If input[0] is U+005C (\) and input[1] is U+002F (/), then return true.
16412-
if (input.starts_with("\\/")) return true;
1641316414
// If input[0] is U+007B ({) and input[1] is U+002F (/), then return true.
16414-
if (input.starts_with("{/")) return true;
1641516415
// Return false.
16416-
return false;
16416+
return input[1] == '/' && (input[0] == '\\' || input[0] == '{');
1641716417
}
1641816418

1641916419
std::string generate_pattern_string(

0 commit comments

Comments
 (0)
Please sign in to comment.