Skip to content

Commit

Permalink
deps: update ada to 2.7.2
Browse files Browse the repository at this point in the history
PR-URL: #50338
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
  • Loading branch information
nodejs-github-bot authored and targos committed Oct 26, 2023
1 parent 6885fc9 commit ac717df
Show file tree
Hide file tree
Showing 4 changed files with 605 additions and 113 deletions.
277 changes: 268 additions & 9 deletions deps/ada/ada.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* auto-generated on 2023-09-30 20:34:30 -0400. Do not edit! */
/* auto-generated on 2023-10-22 19:50:50 -0400. Do not edit! */
/* begin file src/ada.cpp */
#include "ada.h"
/* begin file src/checkers.cpp */
Expand Down Expand Up @@ -11674,10 +11674,9 @@ ada_really_inline void url::parse_path(std::string_view input) {
path = "/";
}
}
return;
}

std::string url::to_string() const {
[[nodiscard]] std::string url::to_string() const {
if (!is_valid) {
return "null";
}
Expand Down Expand Up @@ -11797,7 +11796,7 @@ namespace ada {
return host.value_or("");
}

[[nodiscard]] const std::string_view url::get_pathname() const noexcept {
[[nodiscard]] std::string_view url::get_pathname() const noexcept {
return path;
}

Expand Down Expand Up @@ -12983,7 +12982,7 @@ template url_aggregator parse_url<url_aggregator>(

namespace ada {

bool url_components::check_offset_consistency() const noexcept {
[[nodiscard]] bool url_components::check_offset_consistency() const noexcept {
/**
* https://user:pass@example.com:1234/foo/bar?baz#quux
* | | | | ^^^^| | |
Expand Down Expand Up @@ -13059,7 +13058,7 @@ bool url_components::check_offset_consistency() const noexcept {
return true;
}

std::string url_components::to_string() const {
[[nodiscard]] std::string url_components::to_string() const {
std::string answer;
auto back = std::back_insert_iterator(answer);
answer.append("{\n");
Expand Down Expand Up @@ -13847,7 +13846,7 @@ bool url_aggregator::set_hostname(const std::string_view input) {
return helpers::substring(buffer, 0, components.protocol_end);
}

std::string ada::url_aggregator::to_string() const {
[[nodiscard]] std::string ada::url_aggregator::to_string() const {
ada_log("url_aggregator::to_string buffer:", buffer, "[", buffer.size(),
" bytes]");
if (!is_valid) {
Expand Down Expand Up @@ -14292,7 +14291,7 @@ bool url_aggregator::parse_opaque_host(std::string_view input) {
return true;
}

std::string url_aggregator::to_diagram() const {
[[nodiscard]] std::string url_aggregator::to_diagram() const {
if (!is_valid) {
return "invalid";
}
Expand Down Expand Up @@ -14449,7 +14448,7 @@ std::string url_aggregator::to_diagram() const {
return answer;
}

bool url_aggregator::validate() const noexcept {
[[nodiscard]] bool url_aggregator::validate() const noexcept {
if (!is_valid) {
return true;
}
Expand Down Expand Up @@ -14817,6 +14816,11 @@ ada::result<ada::url_aggregator>& get_instance(void* result) noexcept {

extern "C" {
typedef void* ada_url;
typedef void* ada_url_search_params;
typedef void* ada_strings;
typedef void* ada_url_search_params_keys_iter;
typedef void* ada_url_search_params_values_iter;
typedef void* ada_url_search_params_entries_iter;

struct ada_string {
const char* data;
Expand All @@ -14828,6 +14832,11 @@ struct ada_owned_string {
size_t length;
};

struct ada_string_pair {
ada_string key;
ada_string value;
};

ada_string ada_string_create(const char* data, size_t length) {
ada_string out{};
out.data = data;
Expand Down Expand Up @@ -15267,6 +15276,256 @@ ada_owned_string ada_idna_to_ascii(const char* input, size_t length) {
return owned;
}

ada_url_search_params ada_parse_search_params(const char* input,
size_t length) {
return new ada::result<ada::url_search_params>(
ada::url_search_params(std::string_view(input, length)));
}

void ada_free_search_params(ada_url_search_params result) {
ada::result<ada::url_search_params>* r =
(ada::result<ada::url_search_params>*)result;
delete r;
}

ada_owned_string ada_search_params_to_string(ada_url_search_params result) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (!r) return ada_owned_string{NULL, 0};
std::string out = r->to_string();
ada_owned_string owned{};
owned.length = out.size();
owned.data = new char[owned.length];
memcpy((void*)owned.data, out.data(), owned.length);
return owned;
}

size_t ada_search_params_size(ada_url_search_params result) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (!r) return 0;
return r->size();
}

void ada_search_params_sort(ada_url_search_params result) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (r) r->sort();
}

void ada_search_params_append(ada_url_search_params result, const char* key,
size_t key_length, const char* value,
size_t value_length) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (r) {
r->append(std::string_view(key, key_length),
std::string_view(value, value_length));
}
}

void ada_search_params_set(ada_url_search_params result, const char* key,
size_t key_length, const char* value,
size_t value_length) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (r) {
r->set(std::string_view(key, key_length),
std::string_view(value, value_length));
}
}

void ada_search_params_remove(ada_url_search_params result, const char* key,
size_t key_length) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (r) {
r->remove(std::string_view(key, key_length));
}
}

void ada_search_params_remove_value(ada_url_search_params result,
const char* key, size_t key_length,
const char* value, size_t value_length) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (r) {
r->remove(std::string_view(key, key_length),
std::string_view(value, value_length));
}
}

bool ada_search_params_has(ada_url_search_params result, const char* key,
size_t key_length) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (!r) return false;
return r->has(std::string_view(key, key_length));
}

bool ada_search_params_has_value(ada_url_search_params result, const char* key,
size_t key_length, const char* value,
size_t value_length) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (!r) return false;
return r->has(std::string_view(key, key_length),
std::string_view(value, value_length));
}

ada_string ada_search_params_get(ada_url_search_params result, const char* key,
size_t key_length) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (!r) return ada_string_create(NULL, 0);
auto found = r->get(std::string_view(key, key_length));
if (!found.has_value()) return ada_string_create(NULL, 0);
return ada_string_create(found->data(), found->length());
}

ada_strings ada_search_params_get_all(ada_url_search_params result,
const char* key, size_t key_length) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (!r) {
return new ada::result<std::vector<std::string>>(
std::vector<std::string>());
}
return new ada::result<std::vector<std::string>>(
r->get_all(std::string_view(key, key_length)));
}

ada_url_search_params_keys_iter ada_search_params_get_keys(
ada_url_search_params result) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (!r) {
return new ada::result<ada::url_search_params_keys_iter>(
ada::url_search_params_keys_iter());
}
return new ada::result<ada::url_search_params_keys_iter>(r->get_keys());
}

ada_url_search_params_values_iter ada_search_params_get_values(
ada_url_search_params result) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (!r) {
return new ada::result<ada::url_search_params_values_iter>(
ada::url_search_params_values_iter());
}
return new ada::result<ada::url_search_params_values_iter>(r->get_values());
}

ada_url_search_params_entries_iter ada_search_params_get_entries(
ada_url_search_params result) {
ada::result<ada::url_search_params>& r =
*(ada::result<ada::url_search_params>*)result;
if (!r) {
return new ada::result<ada::url_search_params_entries_iter>(
ada::url_search_params_entries_iter());
}
return new ada::result<ada::url_search_params_entries_iter>(r->get_entries());
}

void ada_free_strings(ada_strings result) {
ada::result<std::vector<std::string>>* r =
(ada::result<std::vector<std::string>>*)result;
delete r;
}

size_t ada_strings_size(ada_strings result) {
ada::result<std::vector<std::string>>* r =
(ada::result<std::vector<std::string>>*)result;
if (!r) return 0;
return (*r)->size();
}

ada_string ada_strings_get(ada_strings result, size_t index) {
ada::result<std::vector<std::string>>* r =
(ada::result<std::vector<std::string>>*)result;
if (!r) return ada_string_create(NULL, 0);
std::string_view view = (*r)->at(index);
return ada_string_create(view.data(), view.length());
}

void ada_free_search_params_keys_iter(ada_url_search_params_keys_iter result) {
ada::result<ada::url_search_params_keys_iter>* r =
(ada::result<ada::url_search_params_keys_iter>*)result;
delete r;
}

ada_string ada_search_params_keys_iter_next(
ada_url_search_params_keys_iter result) {
ada::result<ada::url_search_params_keys_iter>* r =
(ada::result<ada::url_search_params_keys_iter>*)result;
if (!r) return ada_string_create(NULL, 0);
auto next = (*r)->next();
if (!next.has_value()) return ada_string_create(NULL, 0);
return ada_string_create(next->data(), next->length());
}

bool ada_search_params_keys_iter_has_next(
ada_url_search_params_keys_iter result) {
ada::result<ada::url_search_params_keys_iter>* r =
(ada::result<ada::url_search_params_keys_iter>*)result;
if (!r) return false;
return (*r)->has_next();
}

void ada_free_search_params_values_iter(
ada_url_search_params_values_iter result) {
ada::result<ada::url_search_params_values_iter>* r =
(ada::result<ada::url_search_params_values_iter>*)result;
delete r;
}

ada_string ada_search_params_values_iter_next(
ada_url_search_params_values_iter result) {
ada::result<ada::url_search_params_values_iter>* r =
(ada::result<ada::url_search_params_values_iter>*)result;
if (!r) return ada_string_create(NULL, 0);
auto next = (*r)->next();
if (!next.has_value()) return ada_string_create(NULL, 0);
return ada_string_create(next->data(), next->length());
}

bool ada_search_params_values_iter_has_next(
ada_url_search_params_values_iter result) {
ada::result<ada::url_search_params_values_iter>* r =
(ada::result<ada::url_search_params_values_iter>*)result;
if (!r) return false;
return (*r)->has_next();
}

void ada_free_search_params_entries_iter(
ada_url_search_params_entries_iter result) {
ada::result<ada::url_search_params_entries_iter>* r =
(ada::result<ada::url_search_params_entries_iter>*)result;
delete r;
}

ada_string_pair ada_search_params_entries_iter_next(
ada_url_search_params_entries_iter result) {
ada::result<ada::url_search_params_entries_iter>* r =
(ada::result<ada::url_search_params_entries_iter>*)result;
if (!r) return {ada_string_create(NULL, 0), ada_string_create(NULL, 0)};
auto next = (*r)->next();
if (!next.has_value())
return {ada_string_create(NULL, 0), ada_string_create(NULL, 0)};
return ada_string_pair{
ada_string_create(next->first.data(), next->first.length()),
ada_string_create(next->second.data(), next->second.length())};
}

bool ada_search_params_entries_iter_has_next(
ada_url_search_params_entries_iter result) {
ada::result<ada::url_search_params_entries_iter>* r =
(ada::result<ada::url_search_params_entries_iter>*)result;
if (!r) return false;
return (*r)->has_next();
}

} // extern "C"
/* end file src/ada_c.cpp */
/* end file src/ada.cpp */
Loading

0 comments on commit ac717df

Please sign in to comment.