LibGC+Everywhere: Factor out a LibGC from LibJS

Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
This commit is contained in:
Shannon Booth 2024-11-15 04:01:23 +13:00 committed by Andreas Kling
commit f87041bf3a
Notes: github-actions[bot] 2024-11-15 13:50:17 +00:00
1722 changed files with 9939 additions and 9906 deletions

View file

@ -18,9 +18,9 @@
namespace Web::DOMURL {
JS_DEFINE_ALLOCATOR(DOMURL);
GC_DEFINE_ALLOCATOR(DOMURL);
JS::NonnullGCPtr<DOMURL> DOMURL::create(JS::Realm& realm, URL::URL url, JS::NonnullGCPtr<URLSearchParams> query)
GC::Ref<DOMURL> DOMURL::create(JS::Realm& realm, URL::URL url, GC::Ref<URLSearchParams> query)
{
return realm.create<DOMURL>(realm, move(url), query);
}
@ -52,7 +52,7 @@ static Optional<URL::URL> parse_api_url(String const& url, Optional<String> cons
}
// https://url.spec.whatwg.org/#url-initialize
JS::NonnullGCPtr<DOMURL> DOMURL::initialize_a_url(JS::Realm& realm, URL::URL const& url_record)
GC::Ref<DOMURL> DOMURL::initialize_a_url(JS::Realm& realm, URL::URL const& url_record)
{
// 1. Let query be urlRecords query, if that is non-null; otherwise the empty string.
auto query = url_record.query().value_or(String {});
@ -71,7 +71,7 @@ JS::NonnullGCPtr<DOMURL> DOMURL::initialize_a_url(JS::Realm& realm, URL::URL con
}
// https://url.spec.whatwg.org/#dom-url-parse
JS::GCPtr<DOMURL> DOMURL::parse_for_bindings(JS::VM& vm, String const& url, Optional<String> const& base)
GC::Ptr<DOMURL> DOMURL::parse_for_bindings(JS::VM& vm, String const& url, Optional<String> const& base)
{
auto& realm = *vm.current_realm();
@ -89,7 +89,7 @@ JS::GCPtr<DOMURL> DOMURL::parse_for_bindings(JS::VM& vm, String const& url, Opti
}
// https://url.spec.whatwg.org/#dom-url-url
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMURL>> DOMURL::construct_impl(JS::Realm& realm, String const& url, Optional<String> const& base)
WebIDL::ExceptionOr<GC::Ref<DOMURL>> DOMURL::construct_impl(JS::Realm& realm, String const& url, Optional<String> const& base)
{
// 1. Let parsedURL be the result of running the API URL parser on url with base, if given.
auto parsed_url = parse_api_url(url, base);
@ -102,7 +102,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMURL>> DOMURL::construct_impl(JS::Realm&
return initialize_a_url(realm, parsed_url.value());
}
DOMURL::DOMURL(JS::Realm& realm, URL::URL url, JS::NonnullGCPtr<URLSearchParams> query)
DOMURL::DOMURL(JS::Realm& realm, URL::URL url, GC::Ref<URLSearchParams> query)
: PlatformObject(realm)
, m_url(move(url))
, m_query(move(query))
@ -124,7 +124,7 @@ void DOMURL::visit_edges(Cell::Visitor& visitor)
}
// https://w3c.github.io/FileAPI/#dfn-createObjectURL
WebIDL::ExceptionOr<String> DOMURL::create_object_url(JS::VM& vm, JS::NonnullGCPtr<FileAPI::Blob> object)
WebIDL::ExceptionOr<String> DOMURL::create_object_url(JS::VM& vm, GC::Ref<FileAPI::Blob> object)
{
// The createObjectURL(obj) static method must return the result of adding an entry to the blob URL store for obj.
return TRY_OR_THROW_OOM(vm, FileAPI::add_entry_to_blob_url_store(object));
@ -433,7 +433,7 @@ void DOMURL::set_search(String const& search)
}
// https://url.spec.whatwg.org/#dom-url-searchparams
JS::NonnullGCPtr<URLSearchParams const> DOMURL::search_params() const
GC::Ref<URLSearchParams const> DOMURL::search_params() const
{
// The searchParams getter steps are to return thiss query object.
return m_query;

View file

@ -18,18 +18,18 @@ namespace Web::DOMURL {
class DOMURL : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMURL, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(DOMURL);
GC_DECLARE_ALLOCATOR(DOMURL);
public:
[[nodiscard]] static JS::NonnullGCPtr<DOMURL> create(JS::Realm&, URL::URL, JS::NonnullGCPtr<URLSearchParams> query);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMURL>> construct_impl(JS::Realm&, String const& url, Optional<String> const& base = {});
[[nodiscard]] static GC::Ref<DOMURL> create(JS::Realm&, URL::URL, GC::Ref<URLSearchParams> query);
static WebIDL::ExceptionOr<GC::Ref<DOMURL>> construct_impl(JS::Realm&, String const& url, Optional<String> const& base = {});
virtual ~DOMURL() override;
static WebIDL::ExceptionOr<String> create_object_url(JS::VM&, JS::NonnullGCPtr<FileAPI::Blob> object);
static WebIDL::ExceptionOr<String> create_object_url(JS::VM&, GC::Ref<FileAPI::Blob> object);
static WebIDL::ExceptionOr<void> revoke_object_url(JS::VM&, StringView url);
static JS::GCPtr<DOMURL> parse_for_bindings(JS::VM&, String const& url, Optional<String> const& base = {});
static GC::Ptr<DOMURL> parse_for_bindings(JS::VM&, String const& url, Optional<String> const& base = {});
static bool can_parse(JS::VM&, String const& url, Optional<String> const& base = {});
WebIDL::ExceptionOr<String> href() const;
@ -70,7 +70,7 @@ public:
WebIDL::ExceptionOr<String> search() const;
void set_search(String const&);
JS::NonnullGCPtr<URLSearchParams const> search_params() const;
GC::Ref<URLSearchParams const> search_params() const;
WebIDL::ExceptionOr<String> hash() const;
void set_hash(String const&);
@ -81,15 +81,15 @@ public:
void set_query(Badge<URLSearchParams>, Optional<String> query) { m_url.set_query(move(query)); }
private:
DOMURL(JS::Realm&, URL::URL, JS::NonnullGCPtr<URLSearchParams> query);
DOMURL(JS::Realm&, URL::URL, GC::Ref<URLSearchParams> query);
static JS::NonnullGCPtr<DOMURL> initialize_a_url(JS::Realm&, URL::URL const&);
static GC::Ref<DOMURL> initialize_a_url(JS::Realm&, URL::URL const&);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
URL::URL m_url;
JS::NonnullGCPtr<URLSearchParams> m_query;
GC::Ref<URLSearchParams> m_query;
};
bool host_is_domain(URL::Host const&);

View file

@ -19,7 +19,7 @@
namespace Web::DOMURL {
JS_DEFINE_ALLOCATOR(URLSearchParams);
GC_DEFINE_ALLOCATOR(URLSearchParams);
URLSearchParams::URLSearchParams(JS::Realm& realm, Vector<QueryParam> list)
: PlatformObject(realm)
@ -125,13 +125,13 @@ Vector<QueryParam> url_decode(StringView input)
return output;
}
JS::NonnullGCPtr<URLSearchParams> URLSearchParams::create(JS::Realm& realm, Vector<QueryParam> list)
GC::Ref<URLSearchParams> URLSearchParams::create(JS::Realm& realm, Vector<QueryParam> list)
{
return realm.create<URLSearchParams>(realm, move(list));
}
// https://url.spec.whatwg.org/#urlsearchparams-initialize
JS::NonnullGCPtr<URLSearchParams> URLSearchParams::create(JS::Realm& realm, StringView init)
GC::Ref<URLSearchParams> URLSearchParams::create(JS::Realm& realm, StringView init)
{
// NOTE: We skip the other steps since we know it is a string at this point.
// b. Set querys list to the result of parsing init.
@ -140,7 +140,7 @@ JS::NonnullGCPtr<URLSearchParams> URLSearchParams::create(JS::Realm& realm, Stri
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
// https://url.spec.whatwg.org/#urlsearchparams-initialize
WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> URLSearchParams::construct_impl(JS::Realm& realm, Variant<Vector<Vector<String>>, OrderedHashMap<String, String>, String> const& init)
WebIDL::ExceptionOr<GC::Ref<URLSearchParams>> URLSearchParams::construct_impl(JS::Realm& realm, Variant<Vector<Vector<String>>, OrderedHashMap<String, String>, String> const& init)
{
auto& vm = realm.vm();

View file

@ -21,12 +21,12 @@ Vector<QueryParam> url_decode(StringView);
class URLSearchParams : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(URLSearchParams, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(URLSearchParams);
GC_DECLARE_ALLOCATOR(URLSearchParams);
public:
static JS::NonnullGCPtr<URLSearchParams> create(JS::Realm&, StringView);
static JS::NonnullGCPtr<URLSearchParams> create(JS::Realm&, Vector<QueryParam> list);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> construct_impl(JS::Realm&, Variant<Vector<Vector<String>>, OrderedHashMap<String, String>, String> const& init);
static GC::Ref<URLSearchParams> create(JS::Realm&, StringView);
static GC::Ref<URLSearchParams> create(JS::Realm&, Vector<QueryParam> list);
static WebIDL::ExceptionOr<GC::Ref<URLSearchParams>> construct_impl(JS::Realm&, Variant<Vector<Vector<String>>, OrderedHashMap<String, String>, String> const& init);
virtual ~URLSearchParams() override;
@ -57,7 +57,7 @@ private:
void update();
Vector<QueryParam> m_list;
JS::GCPtr<DOMURL> m_url;
GC::Ptr<DOMURL> m_url;
};
}

View file

@ -23,9 +23,9 @@ void Intrinsics::create_web_prototype_and_constructor<URLSearchParamsIteratorPro
namespace Web::DOMURL {
JS_DEFINE_ALLOCATOR(URLSearchParamsIterator);
GC_DEFINE_ALLOCATOR(URLSearchParamsIterator);
WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParamsIterator>> URLSearchParamsIterator::create(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind)
WebIDL::ExceptionOr<GC::Ref<URLSearchParamsIterator>> URLSearchParamsIterator::create(URLSearchParams const& url_search_params, JS::Object::PropertyKind iteration_kind)
{
return url_search_params.realm().create<URLSearchParamsIterator>(url_search_params, iteration_kind);
}

View file

@ -13,10 +13,10 @@ namespace Web::DOMURL {
class URLSearchParamsIterator : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(URLSearchParamsIterator, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(URLSearchParamsIterator);
GC_DECLARE_ALLOCATOR(URLSearchParamsIterator);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParamsIterator>> create(URLSearchParams const&, JS::Object::PropertyKind iteration_kind);
static WebIDL::ExceptionOr<GC::Ref<URLSearchParamsIterator>> create(URLSearchParams const&, JS::Object::PropertyKind iteration_kind);
virtual ~URLSearchParamsIterator() override;
@ -28,7 +28,7 @@ private:
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
JS::NonnullGCPtr<URLSearchParams const> m_url_search_params;
GC::Ref<URLSearchParams const> m_url_search_params;
JS::Object::PropertyKind m_iteration_kind;
size_t m_index { 0 };
};