Skip to content

Commit

Permalink
deps: update ada to 2.6.3
Browse files Browse the repository at this point in the history
PR-URL: #49340
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
nodejs-github-bot committed Sep 30, 2023
1 parent 51f4ff2 commit a20a328
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 19 deletions.
20 changes: 18 additions & 2 deletions deps/ada/ada.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* auto-generated on 2023-07-23 15:03:22 -0400. Do not edit! */
/* auto-generated on 2023-08-26 17:38:28 -0400. Do not edit! */
/* begin file src/ada.cpp */
#include "ada.h"
/* begin file src/checkers.cpp */
Expand Down Expand Up @@ -11231,6 +11231,7 @@ bool url::parse_ipv4(std::string_view input) {
} else {
host = ada::serializers::ipv4(ipv4); // We have to reserialize the address.
}
host_type = IPV4;
return true;
}

Expand Down Expand Up @@ -11460,6 +11461,7 @@ bool url::parse_ipv6(std::string_view input) {
}
host = ada::serializers::ipv6(address);
ada_log("parse_ipv6 ", *host);
host_type = IPV6;
return true;
}

Expand Down Expand Up @@ -12569,7 +12571,6 @@ result_type parse_url(std::string_view user_input,
// If c is U+002F (/) and remaining starts with U+002F (/),
// then set state to special authority ignore slashes state and increase
// pointer by 1.
state = ada::state::SPECIAL_AUTHORITY_IGNORE_SLASHES;
std::string_view view = helpers::substring(url_data, input_position);
if (ada::checkers::begins_with(view, "//")) {
input_position += 2;
Expand Down Expand Up @@ -14021,6 +14022,7 @@ bool url_aggregator::parse_ipv4(std::string_view input) {
update_base_hostname(
ada::serializers::ipv4(ipv4)); // We have to reserialize the address.
}
host_type = IPV4;
ADA_ASSERT_TRUE(validate());
return true;
}
Expand Down Expand Up @@ -14256,6 +14258,7 @@ bool url_aggregator::parse_ipv6(std::string_view input) {
update_base_hostname(ada::serializers::ipv6(address));
ada_log("parse_ipv6 ", get_hostname());
ADA_ASSERT_TRUE(validate());
host_type = IPV6;
return true;
}

Expand Down Expand Up @@ -14890,6 +14893,11 @@ void ada_free(ada_url result) noexcept {
delete r;
}

ada_url ada_copy(ada_url input) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(input);
return new ada::result<ada::url_aggregator>(r);
}

bool ada_is_valid(ada_url result) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
return r.has_value();
Expand Down Expand Up @@ -15007,6 +15015,14 @@ ada_string ada_get_protocol(ada_url result) noexcept {
return ada_string_create(out.data(), out.length());
}

uint8_t ada_get_url_host_type(ada_url result) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
if (!r) {
return 0;
}
return r->host_type;
}

bool ada_set_href(ada_url result, const char* input, size_t length) noexcept {
ada::result<ada::url_aggregator>& r = get_instance(result);
if (!r) {
Expand Down
143 changes: 129 additions & 14 deletions deps/ada/ada.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* auto-generated on 2023-07-23 15:03:22 -0400. Do not edit! */
/* auto-generated on 2023-08-26 17:38:28 -0400. Do not edit! */
/* begin file include/ada.h */
/**
* @file ada.h
Expand Down Expand Up @@ -1008,6 +1008,7 @@ ada_really_inline bool bit_at(const uint8_t a[], const uint8_t i) {
#define ADA_CHECKERS_INL_H


#include <algorithm>
#include <string_view>
#include <cstring>

Expand Down Expand Up @@ -1058,7 +1059,7 @@ ada_really_inline constexpr bool begins_with(std::string_view view,
std::string_view prefix) {
// in C++20, you have view.begins_with(prefix)
return view.size() >= prefix.size() &&
(view.substr(0, prefix.size()) == prefix);
std::equal(prefix.begin(), prefix.end(), view.begin());
}

} // namespace ada::checkers
Expand Down Expand Up @@ -1406,6 +1407,25 @@ constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept;

namespace ada {

/**
* Type of URL host as an enum.
*/
enum url_host_type : uint8_t {
/**
* Represents common URLs such as "https://www.google.com"
*/
DEFAULT = 0,
/**
* Represents ipv4 addresses such as "http://127.0.0.1"
*/
IPV4 = 1,
/**
* Represents ipv6 addresses such as
* "http://[2001:db8:3333:4444:5555:6666:7777:8888]"
*/
IPV6 = 2,
};

/**
* @brief Base class of URL implementations
*
Expand All @@ -1428,6 +1448,11 @@ struct url_base {
*/
bool has_opaque_path{false};

/**
* URL hosts type
*/
url_host_type host_type = url_host_type::DEFAULT;

/**
* @private
*/
Expand Down Expand Up @@ -1768,8 +1793,8 @@ inline int fast_digit_count(uint32_t x) noexcept {
#define TL_EXPECTED_HPP

#define TL_EXPECTED_VERSION_MAJOR 1
#define TL_EXPECTED_VERSION_MINOR 0
#define TL_EXPECTED_VERSION_PATCH 1
#define TL_EXPECTED_VERSION_MINOR 1
#define TL_EXPECTED_VERSION_PATCH 0

#include <exception>
#include <functional>
Expand Down Expand Up @@ -1802,6 +1827,16 @@ inline int fast_digit_count(uint32_t x) noexcept {
#define TL_EXPECTED_GCC55
#endif

#if !defined(TL_ASSERT)
// can't have assert in constexpr in C++11 and GCC 4.9 has a compiler bug
#if (__cplusplus > 201103L) && !defined(TL_EXPECTED_GCC49)
#include <cassert>
#define TL_ASSERT(x) assert(x)
#else
#define TL_ASSERT(x)
#endif
#endif

#if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 9 && \
!defined(__clang__))
// GCC < 5 doesn't support overloading on const&& for member functions
Expand Down Expand Up @@ -1957,6 +1992,7 @@ template <typename E>
#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
throw std::forward<E>(e);
#else
(void)e;
#ifdef _MSC_VER
__assume(0);
#else
Expand Down Expand Up @@ -2597,7 +2633,7 @@ struct expected_operations_base : expected_storage_base<T, E> {
geterr().~unexpected<E>();
construct(std::move(rhs).get());
} else {
assign_common(rhs);
assign_common(std::move(rhs));
}
}

Expand Down Expand Up @@ -2960,7 +2996,7 @@ struct default_constructor_tag {
};

// expected_default_ctor_base will ensure that expected has a deleted default
// constructor if T is not default constructible.
// consturctor if T is not default constructible.
// This specialization is for when T is default constructible
template <class T, class E,
bool Enable =
Expand Down Expand Up @@ -3255,6 +3291,53 @@ class expected : private detail::expected_move_assign_base<T, E>,
return map_error_impl(std::move(*this), std::forward<F>(f));
}
#endif
#endif
#if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \
!defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55)
template <class F>
TL_EXPECTED_11_CONSTEXPR auto transform_error(F &&f) & {
return map_error_impl(*this, std::forward<F>(f));
}
template <class F>
TL_EXPECTED_11_CONSTEXPR auto transform_error(F &&f) && {
return map_error_impl(std::move(*this), std::forward<F>(f));
}
template <class F>
constexpr auto transform_error(F &&f) const & {
return map_error_impl(*this, std::forward<F>(f));
}
template <class F>
constexpr auto transform_error(F &&f) const && {
return map_error_impl(std::move(*this), std::forward<F>(f));
}
#else
template <class F>
TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval<expected &>(),
std::declval<F &&>()))
transform_error(F &&f) & {
return map_error_impl(*this, std::forward<F>(f));
}
template <class F>
TL_EXPECTED_11_CONSTEXPR decltype(map_error_impl(std::declval<expected &&>(),
std::declval<F &&>()))
transform_error(F &&f) && {
return map_error_impl(std::move(*this), std::forward<F>(f));
}
template <class F>
constexpr decltype(map_error_impl(std::declval<const expected &>(),
std::declval<F &&>()))
transform_error(F &&f) const & {
return map_error_impl(*this, std::forward<F>(f));
}

#ifndef TL_EXPECTED_NO_CONSTRR
template <class F>
constexpr decltype(map_error_impl(std::declval<const expected &&>(),
std::declval<F &&>()))
transform_error(F &&f) const && {
return map_error_impl(std::move(*this), std::forward<F>(f));
}
#endif
#endif
template <class F>
expected TL_EXPECTED_11_CONSTEXPR or_else(F &&f) & {
Expand Down Expand Up @@ -3697,27 +3780,37 @@ class expected : private detail::expected_move_assign_base<T, E>,
}
}

constexpr const T *operator->() const { return valptr(); }
TL_EXPECTED_11_CONSTEXPR T *operator->() { return valptr(); }
constexpr const T *operator->() const {
TL_ASSERT(has_value());
return valptr();
}
TL_EXPECTED_11_CONSTEXPR T *operator->() {
TL_ASSERT(has_value());
return valptr();
}

template <class U = T,
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
constexpr const U &operator*() const & {
TL_ASSERT(has_value());
return val();
}
template <class U = T,
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
TL_EXPECTED_11_CONSTEXPR U &operator*() & {
TL_ASSERT(has_value());
return val();
}
template <class U = T,
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
constexpr const U &&operator*() const && {
TL_ASSERT(has_value());
return std::move(val());
}
template <class U = T,
detail::enable_if_t<!std::is_void<U>::value> * = nullptr>
TL_EXPECTED_11_CONSTEXPR U &&operator*() && {
TL_ASSERT(has_value());
return std::move(val());
}

Expand Down Expand Up @@ -3753,10 +3846,22 @@ class expected : private detail::expected_move_assign_base<T, E>,
return std::move(val());
}

constexpr const E &error() const & { return err().value(); }
TL_EXPECTED_11_CONSTEXPR E &error() & { return err().value(); }
constexpr const E &&error() const && { return std::move(err().value()); }
TL_EXPECTED_11_CONSTEXPR E &&error() && { return std::move(err().value()); }
constexpr const E &error() const & {
TL_ASSERT(!has_value());
return err().value();
}
TL_EXPECTED_11_CONSTEXPR E &error() & {
TL_ASSERT(!has_value());
return err().value();
}
constexpr const E &&error() const && {
TL_ASSERT(!has_value());
return std::move(err().value());
}
TL_EXPECTED_11_CONSTEXPR E &&error() && {
TL_ASSERT(!has_value());
return std::move(err().value());
}

template <class U>
constexpr T value_or(U &&v) const & {
Expand Down Expand Up @@ -6609,6 +6714,7 @@ struct url_search_params {
* @see https://url.spec.whatwg.org/#dom-urlsearchparams-has
*/
inline bool has(std::string_view key) noexcept;
inline bool has(std::string_view key, std::string_view value) noexcept;

/**
* @see https://url.spec.whatwg.org/#dom-urlsearchparams-set
Expand Down Expand Up @@ -6733,6 +6839,15 @@ inline bool url_search_params::has(const std::string_view key) noexcept {
return entry != params.end();
}

inline bool url_search_params::has(std::string_view key,
std::string_view value) noexcept {
auto entry =
std::find_if(params.begin(), params.end(), [&key, &value](auto &param) {
return param.first == key && param.second == value;
});
return entry != params.end();
}

inline std::string url_search_params::to_string() {
auto character_set = ada::character_sets::WWW_FORM_URLENCODED_PERCENT_ENCODE;
std::string out{};
Expand Down Expand Up @@ -6807,14 +6922,14 @@ inline void url_search_params::sort() {
#ifndef ADA_ADA_VERSION_H
#define ADA_ADA_VERSION_H

#define ADA_VERSION "2.6.0"
#define ADA_VERSION "2.6.3"

namespace ada {

enum {
ADA_VERSION_MAJOR = 2,
ADA_VERSION_MINOR = 6,
ADA_VERSION_REVISION = 0,
ADA_VERSION_REVISION = 3,
};

} // namespace ada
Expand Down
2 changes: 2 additions & 0 deletions deps/ada/ada_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool ada_can_parse_with_base(const char* input, size_t input_length,

void ada_free(ada_url result);
void ada_free_owned_string(ada_owned_string owned);
ada_url ada_copy(ada_url input);

bool ada_is_valid(ada_url result);

Expand All @@ -67,6 +68,7 @@ ada_string ada_get_hostname(ada_url result);
ada_string ada_get_pathname(ada_url result);
ada_string ada_get_search(ada_url result);
ada_string ada_get_protocol(ada_url result);
uint8_t ada_get_url_host_type(ada_url result);

// url_aggregator setters
// if ada_is_valid(result)) is false, the setters have no effect
Expand Down
6 changes: 3 additions & 3 deletions doc/contributing/maintaining/maintaining-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ All dependencies are located within the `deps` directory.
This a list of all the dependencies:

* [acorn 8.10.0][]
* [ada 2.6.0][]
* [ada 2.6.3][]
* [base64 0.5.0][]
* [brotli 1.0.9][]
* [c-ares 1.19.0][]
Expand Down Expand Up @@ -150,7 +150,7 @@ The [acorn](https://github.com/acornjs/acorn) dependency is a JavaScript parser.
[acorn-walk](https://github.com/acornjs/acorn/tree/master/acorn-walk) is
an abstract syntax tree walker for the ESTree format.

### ada 2.6.0
### ada 2.6.3

The [ada](https://github.com/ada-url/ada) dependency is a
fast and spec-compliant URL parser written in C++.
Expand Down Expand Up @@ -319,7 +319,7 @@ it comes from the Chromium team's zlib fork which incorporated
performance improvements not currently available in standard zlib.

[acorn 8.10.0]: #acorn-8100
[ada 2.6.0]: #ada-260
[ada 2.6.3]: #ada-263
[base64 0.5.0]: #base64-050
[brotli 1.0.9]: #brotli-109
[c-ares 1.19.0]: #c-ares-1190
Expand Down

0 comments on commit a20a328

Please sign in to comment.