mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-31 23:42:52 +00:00
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:
parent
ce23efc5f6
commit
f87041bf3a
Notes:
github-actions[bot]
2024-11-15 13:50:17 +00:00
Author: https://github.com/shannonbooth
Commit: f87041bf3a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2345
1722 changed files with 9939 additions and 9906 deletions
|
@ -137,7 +137,7 @@ static StringView sequence_storage_type_to_cpp_storage_type_name(SequenceStorage
|
|||
case SequenceStorageType::Vector:
|
||||
return "Vector"sv;
|
||||
case SequenceStorageType::MarkedVector:
|
||||
return "JS::MarkedVector"sv;
|
||||
return "GC::MarkedVector"sv;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -171,13 +171,13 @@ static ByteString union_type_to_variant(UnionType const& union_type, Interface c
|
|||
CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
|
||||
{
|
||||
if (is_platform_object(type) || type.name() == "WindowProxy"sv)
|
||||
return { .name = ByteString::formatted("JS::Handle<{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
return { .name = ByteString::formatted("GC::Root<{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
|
||||
if (is_javascript_builtin(type))
|
||||
return { .name = ByteString::formatted("JS::Handle<JS::{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
return { .name = ByteString::formatted("GC::Root<JS::{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
|
||||
if (interface.callback_functions.contains(type.name()))
|
||||
return { .name = "JS::Handle<WebIDL::CallbackType>", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
return { .name = "GC::Root<WebIDL::CallbackType>", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
|
||||
if (type.is_string())
|
||||
return { .name = "String", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
|
@ -213,19 +213,19 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
|
|||
return { .name = "JS::Value", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
|
||||
if (type.name() == "object")
|
||||
return { .name = "JS::Handle<JS::Object>", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
return { .name = "GC::Root<JS::Object>", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
|
||||
if (type.name() == "BufferSource")
|
||||
return { .name = "JS::Handle<WebIDL::BufferSource>", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
return { .name = "GC::Root<WebIDL::BufferSource>", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
|
||||
if (type.name() == "ArrayBufferView")
|
||||
return { .name = "JS::Handle<WebIDL::ArrayBufferView>", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
return { .name = "GC::Root<WebIDL::ArrayBufferView>", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
|
||||
if (type.name() == "File")
|
||||
return { .name = "JS::Handle<FileAPI::File>", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
return { .name = "GC::Root<FileAPI::File>", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
|
||||
if (type.name() == "Function")
|
||||
return { .name = "JS::NonnullGCPtr<WebIDL::CallbackType>", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
return { .name = "GC::Ref<WebIDL::CallbackType>", .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
|
||||
if (type.name() == "sequence") {
|
||||
auto& parameterized_type = verify_cast<ParameterizedType>(type);
|
||||
|
@ -577,7 +577,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
JS::GCPtr<@parameter.type.name@> @cpp_name@;
|
||||
GC::Ptr<@parameter.type.name@> @cpp_name@;
|
||||
if (!@js_name@@js_suffix@.is_undefined()) {
|
||||
if (!@js_name@@js_suffix@.is_object() || !is<@parameter.type.name@>(@js_name@@js_suffix@.as_object()))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@");
|
||||
|
@ -589,13 +589,13 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
} else {
|
||||
if (explicit_null) {
|
||||
scoped_generator.append(R"~~~(
|
||||
Optional<JS::GCPtr<@parameter.type.name@>> @cpp_name@;
|
||||
Optional<GC::Ptr<@parameter.type.name@>> @cpp_name@;
|
||||
if (maybe_@js_name@@js_suffix@.has_value()) {
|
||||
auto @js_name@@js_suffix@ = maybe_@js_name@@js_suffix@.release_value();
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
JS::GCPtr<@parameter.type.name@> @cpp_name@;
|
||||
GC::Ptr<@parameter.type.name@> @cpp_name@;
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -675,42 +675,42 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
// 2. Perform ? Call(promiseCapability.[[Resolve]], undefined, « V »).
|
||||
TRY(JS::call(vm, *promise_capability->resolve(), JS::js_undefined(), @js_name@@js_suffix@));
|
||||
// 3. Return promiseCapability.
|
||||
auto @cpp_name@ = JS::make_handle(promise_capability);
|
||||
auto @cpp_name@ = GC::make_root(promise_capability);
|
||||
)~~~");
|
||||
} else if (parameter.type->name() == "object") {
|
||||
if (parameter.type->is_nullable()) {
|
||||
scoped_generator.append(R"~~~(
|
||||
Optional<JS::Handle<JS::Object>> @cpp_name@;
|
||||
Optional<GC::Root<JS::Object>> @cpp_name@;
|
||||
if (!@js_name@@js_suffix@.is_null() && !@js_name@@js_suffix@.is_undefined())
|
||||
@cpp_name@ = JS::make_handle(TRY(@js_name@@js_suffix@.to_object(vm)));
|
||||
@cpp_name@ = GC::make_root(TRY(@js_name@@js_suffix@.to_object(vm)));
|
||||
)~~~");
|
||||
} else if (optional) {
|
||||
scoped_generator.append(R"~~~(
|
||||
Optional<JS::Handle<JS::Object>> @cpp_name@;
|
||||
Optional<GC::Root<JS::Object>> @cpp_name@;
|
||||
if (!@js_name@@js_suffix@.is_undefined())
|
||||
@cpp_name@ = JS::make_handle(TRY(@js_name@@js_suffix@.to_object(vm)));
|
||||
@cpp_name@ = GC::make_root(TRY(@js_name@@js_suffix@.to_object(vm)));
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
auto @cpp_name@ = JS::make_handle(TRY(@js_name@@js_suffix@.to_object(vm)));
|
||||
auto @cpp_name@ = GC::make_root(TRY(@js_name@@js_suffix@.to_object(vm)));
|
||||
)~~~");
|
||||
}
|
||||
} else if (is_javascript_builtin(parameter.type) || parameter.type->name() == "BufferSource"sv) {
|
||||
if (optional) {
|
||||
scoped_generator.append(R"~~~(
|
||||
Optional<JS::Handle<WebIDL::BufferSource>> @cpp_name@;
|
||||
Optional<GC::Root<WebIDL::BufferSource>> @cpp_name@;
|
||||
if (!@js_name@@js_suffix@.is_undefined()) {
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
JS::Handle<WebIDL::BufferSource> @cpp_name@;
|
||||
GC::Root<WebIDL::BufferSource> @cpp_name@;
|
||||
)~~~");
|
||||
}
|
||||
scoped_generator.append(R"~~~(
|
||||
if (!@js_name@@js_suffix@.is_object() || !(is<JS::TypedArrayBase>(@js_name@@js_suffix@.as_object()) || is<JS::ArrayBuffer>(@js_name@@js_suffix@.as_object()) || is<JS::DataView>(@js_name@@js_suffix@.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@");
|
||||
|
||||
@cpp_name@ = JS::make_handle(realm.create<WebIDL::BufferSource>(@js_name@@js_suffix@.as_object()));
|
||||
@cpp_name@ = GC::make_root(realm.create<WebIDL::BufferSource>(@js_name@@js_suffix@.as_object()));
|
||||
)~~~");
|
||||
|
||||
if (optional) {
|
||||
|
@ -724,7 +724,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (!@js_name@@js_suffix@.is_object() || !(is<JS::TypedArrayBase>(@js_name@@js_suffix@.as_object()) || is<JS::DataView>(@js_name@@js_suffix@.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@");
|
||||
|
||||
auto @cpp_name@ = JS::make_handle(realm.create<WebIDL::ArrayBufferView>(@js_name@@js_suffix@.as_object()));
|
||||
auto @cpp_name@ = GC::make_root(realm.create<WebIDL::ArrayBufferView>(@js_name@@js_suffix@.as_object()));
|
||||
)~~~");
|
||||
if (optional) {
|
||||
scoped_generator.append(R"~~~(
|
||||
|
@ -734,7 +734,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
} else if (parameter.type->name() == "any") {
|
||||
if (variadic) {
|
||||
scoped_generator.append(R"~~~(
|
||||
JS::MarkedVector<JS::Value> @cpp_name@ { vm.heap() };
|
||||
GC::MarkedVector<JS::Value> @cpp_name@ { vm.heap() };
|
||||
|
||||
if (vm.argument_count() > @js_suffix@) {
|
||||
@cpp_name@.ensure_capacity(vm.argument_count() - @js_suffix@);
|
||||
|
@ -918,7 +918,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
// 2. Return the IDL callback function type value that represents a reference to the same object that V represents, with the incumbent settings object as the callback context.
|
||||
if (parameter.type->is_nullable() || callback_function.is_legacy_treat_non_object_as_null) {
|
||||
callback_function_generator.append(R"~~~(
|
||||
JS::GCPtr<WebIDL::CallbackType> @cpp_name@;
|
||||
GC::Ptr<WebIDL::CallbackType> @cpp_name@;
|
||||
if (@js_name@@js_suffix@.is_object())
|
||||
@cpp_name@ = vm.heap().allocate<WebIDL::CallbackType>(@js_name@@js_suffix@.as_object(), HTML::incumbent_settings_object(), @operation_returns_promise@);
|
||||
)~~~");
|
||||
|
@ -1191,14 +1191,14 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
|
||||
union_platform_object_type_generator.append(R"~~~(
|
||||
if (is<@platform_object_type@>(@js_name@@js_suffix@_object))
|
||||
return JS::make_handle(static_cast<@platform_object_type@&>(@js_name@@js_suffix@_object));
|
||||
return GC::make_root(static_cast<@platform_object_type@&>(@js_name@@js_suffix@_object));
|
||||
)~~~");
|
||||
}
|
||||
|
||||
// 2. If types includes object, then return the IDL value that is a reference to the object V.
|
||||
if (includes_object) {
|
||||
union_generator.append(R"~~~(
|
||||
return JS::make_handle(@js_name@@js_suffix@_object);
|
||||
return GC::make_root(@js_name@@js_suffix@_object);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -1218,7 +1218,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (includes_window_proxy) {
|
||||
union_generator.append(R"~~~(
|
||||
if (is<WindowProxy>(@js_name@@js_suffix@_object))
|
||||
return JS::make_handle(static_cast<WindowProxy&>(@js_name@@js_suffix@_object));
|
||||
return GC::make_root(static_cast<WindowProxy&>(@js_name@@js_suffix@_object));
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -1227,8 +1227,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (any_of(types, [](auto const& type) { return type->name() == "BufferSource"; }) && !includes_object) {
|
||||
union_generator.append(R"~~~(
|
||||
if (is<JS::ArrayBuffer>(@js_name@@js_suffix@_object) || is<JS::DataView>(@js_name@@js_suffix@_object) || is<JS::TypedArrayBase>(@js_name@@js_suffix@_object)) {
|
||||
JS::NonnullGCPtr<WebIDL::BufferSource> source_object = realm.create<WebIDL::BufferSource>(@js_name@@js_suffix@_object);
|
||||
return JS::make_handle(source_object);
|
||||
GC::Ref<WebIDL::BufferSource> source_object = realm.create<WebIDL::BufferSource>(@js_name@@js_suffix@_object);
|
||||
return GC::make_root(source_object);
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
@ -1239,7 +1239,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (any_of(types, [](auto const& type) { return type->name() == "ArrayBuffer"; }) || includes_object) {
|
||||
union_generator.append(R"~~~(
|
||||
if (is<JS::ArrayBuffer>(@js_name@@js_suffix@_object))
|
||||
return JS::make_handle(@js_name@@js_suffix@_object);
|
||||
return GC::make_root(@js_name@@js_suffix@_object);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -1249,7 +1249,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (any_of(types, [](auto const& type) { return type->name() == "DataView"; }) || includes_object) {
|
||||
union_generator.append(R"~~~(
|
||||
if (is<JS::DataView>(@js_name@@js_suffix@_object))
|
||||
return JS::make_handle(@js_name@@js_suffix@_object);
|
||||
return GC::make_root(@js_name@@js_suffix@_object);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -1263,7 +1263,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
if (has_typed_array_name || includes_object) {
|
||||
union_generator.append(R"~~~(
|
||||
if (is<JS::TypedArrayBase>(@js_name@@js_suffix@_object))
|
||||
return JS::make_handle(@js_name@@js_suffix@_object);
|
||||
return GC::make_root(@js_name@@js_suffix@_object);
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -1589,7 +1589,7 @@ static void generate_arguments(SourceGenerator& generator, Vector<IDL::Parameter
|
|||
auto parameter_name = make_input_acceptable_cpp(parameter.name.to_snakecase());
|
||||
|
||||
if (parameter.variadic) {
|
||||
// JS::MarkedVector is non-copyable, and the implementations likely want ownership of the
|
||||
// GC::MarkedVector is non-copyable, and the implementations likely want ownership of the
|
||||
// list, so we move() it into the parameter list.
|
||||
parameter_names.append(ByteString::formatted("move({})", parameter_name));
|
||||
} else {
|
||||
|
@ -1765,7 +1765,7 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
|||
)~~~");
|
||||
}
|
||||
|
||||
// If the type is a platform object we currently return a Vector<JS::Handle<T>> from the
|
||||
// If the type is a platform object we currently return a Vector<GC::Root<T>> from the
|
||||
// C++ implementation, thus allowing us to unwrap the element (a handle) like below.
|
||||
// This might need to change if we switch to a MarkedVector.
|
||||
if (is_platform_object(sequence_generic_type.parameters().first())) {
|
||||
|
@ -1801,7 +1801,7 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
|||
)~~~");
|
||||
} else if (type.name() == "Promise") {
|
||||
scoped_generator.append(R"~~~(
|
||||
@result_expression@ JS::NonnullGCPtr { verify_cast<JS::Promise>(*@value@->promise()) };
|
||||
@result_expression@ GC::Ref { verify_cast<JS::Promise>(*@value@->promise()) };
|
||||
)~~~");
|
||||
} else if (type.name() == "ArrayBufferView" || type.name() == "BufferSource") {
|
||||
scoped_generator.append(R"~~~(
|
||||
|
@ -2279,7 +2279,7 @@ static void generate_overload_arbiter(SourceGenerator& generator, auto const& ov
|
|||
|
||||
if (is_constructor == IsConstructor::Yes) {
|
||||
function_generator.append(R"~~~(
|
||||
JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::construct(JS::FunctionObject& new_target)
|
||||
JS::ThrowCompletionOr<GC::Ref<JS::Object>> @constructor_class@::construct(JS::FunctionObject& new_target)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
WebIDL::log_trace(vm, "@constructor_class@::construct");
|
||||
|
@ -2549,7 +2549,7 @@ static void generate_html_constructor(SourceGenerator& generator, IDL::Construct
|
|||
return JS::throw_completion(WebIDL::InvalidStateError::create(realm, "Custom element has already been constructed"_string));
|
||||
|
||||
// 12. Perform ? element.[[SetPrototypeOf]](prototype).
|
||||
auto actual_element = element.get<JS::Handle<DOM::Element>>();
|
||||
auto actual_element = element.get<GC::Root<DOM::Element>>();
|
||||
TRY(actual_element->internal_set_prototype_of(&prototype.as_object()));
|
||||
|
||||
// 13. Replace the last entry in definition's construction stack with an already constructed marker.
|
||||
|
@ -2569,7 +2569,7 @@ static void generate_constructor(SourceGenerator& generator, IDL::Constructor co
|
|||
constructor_generator.set("overload_suffix", constructor.is_overloaded ? ByteString::number(constructor.overload_index) : ByteString::empty());
|
||||
|
||||
constructor_generator.append(R"~~~(
|
||||
JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::construct@overload_suffix@([[maybe_unused]] FunctionObject& new_target)
|
||||
JS::ThrowCompletionOr<GC::Ref<JS::Object>> @constructor_class@::construct@overload_suffix@([[maybe_unused]] FunctionObject& new_target)
|
||||
{
|
||||
WebIDL::log_trace(vm(), "@constructor_class@::construct@overload_suffix@");
|
||||
)~~~");
|
||||
|
@ -2677,7 +2677,7 @@ static void generate_constructors(SourceGenerator& generator, IDL::Interface con
|
|||
if (interface.constructors.is_empty()) {
|
||||
// No constructor
|
||||
generator.append(R"~~~(
|
||||
JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::construct([[maybe_unused]] FunctionObject& new_target)
|
||||
JS::ThrowCompletionOr<GC::Ref<JS::Object>> @constructor_class@::construct([[maybe_unused]] FunctionObject& new_target)
|
||||
{
|
||||
WebIDL::log_trace(vm(), "@constructor_class@::construct");
|
||||
)~~~");
|
||||
|
@ -3004,7 +3004,7 @@ static void generate_named_properties_object_declarations(IDL::Interface const&
|
|||
generator.append(R"~~~(
|
||||
class @named_properties_class@ : public JS::Object {
|
||||
JS_OBJECT(@named_properties_class@, JS::Object);
|
||||
JS_DECLARE_ALLOCATOR(@named_properties_class@);
|
||||
GC_DECLARE_ALLOCATOR(@named_properties_class@);
|
||||
public:
|
||||
explicit @named_properties_class@(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
@ -3020,7 +3020,7 @@ private:
|
|||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<JS::Realm> m_realm; // [[Realm]]
|
||||
GC::Ref<JS::Realm> m_realm; // [[Realm]]
|
||||
};
|
||||
)~~~");
|
||||
}
|
||||
|
@ -3038,7 +3038,7 @@ static void generate_named_properties_object_definitions(IDL::Interface const& i
|
|||
generator.append(R"~~~(
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
JS_DEFINE_ALLOCATOR(@named_properties_class@);
|
||||
GC_DEFINE_ALLOCATOR(@named_properties_class@);
|
||||
|
||||
@named_properties_class@::@named_properties_class@(JS::Realm& realm)
|
||||
: JS::Object(realm, nullptr, MayInterfereWithIndexedPropertyAccess::Yes)
|
||||
|
@ -3859,7 +3859,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@)
|
|||
{
|
||||
WebIDL::log_trace(vm, "@class_name@::@attribute.setter_callback@");
|
||||
auto this_value = vm.this_value();
|
||||
JS::GCPtr<Window> window;
|
||||
GC::Ptr<Window> window;
|
||||
if (this_value.is_object()) {
|
||||
if (is<WindowProxy>(this_value.as_object())) {
|
||||
auto& window_proxy = static_cast<WindowProxy&>(this_value.as_object());
|
||||
|
@ -4025,7 +4025,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::get_size)
|
|||
WebIDL::log_trace(vm, "@class_name@::size");
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
||||
JS::NonnullGCPtr<JS::Set> set = impl->set_entries();
|
||||
GC::Ref<JS::Set> set = impl->set_entries();
|
||||
|
||||
return set->set_size();
|
||||
}
|
||||
|
@ -4037,7 +4037,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::entries)
|
|||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
||||
JS::NonnullGCPtr<JS::Set> set = impl->set_entries();
|
||||
GC::Ref<JS::Set> set = impl->set_entries();
|
||||
|
||||
return TRY(throw_dom_exception_if_needed(vm, [&] { return JS::SetIterator::create(realm, *set, Object::PropertyKind::KeyAndValue); }));
|
||||
}
|
||||
|
@ -4049,7 +4049,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::values)
|
|||
auto& realm = *vm.current_realm();
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
||||
JS::NonnullGCPtr<JS::Set> set = impl->set_entries();
|
||||
GC::Ref<JS::Set> set = impl->set_entries();
|
||||
|
||||
return TRY(throw_dom_exception_if_needed(vm, [&] { return JS::SetIterator::create(realm, *set, Object::PropertyKind::Value); }));
|
||||
}
|
||||
|
@ -4060,7 +4060,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::for_each)
|
|||
WebIDL::log_trace(vm, "@class_name@::for_each");
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
||||
JS::NonnullGCPtr<JS::Set> set = impl->set_entries();
|
||||
GC::Ref<JS::Set> set = impl->set_entries();
|
||||
|
||||
auto callback = vm.argument(0);
|
||||
if (!callback.is_function())
|
||||
|
@ -4080,7 +4080,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::has)
|
|||
WebIDL::log_trace(vm, "@class_name@::has");
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
||||
JS::NonnullGCPtr<JS::Set> set = impl->set_entries();
|
||||
GC::Ref<JS::Set> set = impl->set_entries();
|
||||
|
||||
auto value_arg = vm.argument(0);
|
||||
if (!value_arg.is_object() && !is<@value_type@>(value_arg.as_object())) {
|
||||
|
@ -4102,7 +4102,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::add)
|
|||
WebIDL::log_trace(vm, "@class_name@::add");
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
||||
JS::NonnullGCPtr<JS::Set> set = impl->set_entries();
|
||||
GC::Ref<JS::Set> set = impl->set_entries();
|
||||
|
||||
auto value_arg = vm.argument(0);
|
||||
if (!value_arg.is_object() && !is<@value_type@>(value_arg.as_object())) {
|
||||
|
@ -4126,7 +4126,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::delete_)
|
|||
WebIDL::log_trace(vm, "@class_name@::delete_");
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
||||
JS::NonnullGCPtr<JS::Set> set = impl->set_entries();
|
||||
GC::Ref<JS::Set> set = impl->set_entries();
|
||||
|
||||
auto value_arg = vm.argument(0);
|
||||
if (!value_arg.is_object() && !is<@value_type@>(value_arg.as_object())) {
|
||||
|
@ -4148,7 +4148,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::clear)
|
|||
WebIDL::log_trace(vm, "@class_name@::clear");
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
||||
JS::NonnullGCPtr<JS::Set> set = impl->set_entries();
|
||||
GC::Ref<JS::Set> set = impl->set_entries();
|
||||
|
||||
set->set_clear();
|
||||
|
||||
|
@ -4174,7 +4174,7 @@ namespace Web::Bindings {
|
|||
|
||||
class @namespace_class@ final : public JS::Object {
|
||||
JS_OBJECT(@namespace_class@, JS::Object);
|
||||
JS_DECLARE_ALLOCATOR(@namespace_class@);
|
||||
GC_DECLARE_ALLOCATOR(@namespace_class@);
|
||||
public:
|
||||
explicit @namespace_class@(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
@ -4301,7 +4301,7 @@ void generate_namespace_implementation(IDL::Interface const& interface, StringBu
|
|||
generator.append(R"~~~(
|
||||
namespace Web::Bindings {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(@namespace_class@);
|
||||
GC_DEFINE_ALLOCATOR(@namespace_class@);
|
||||
|
||||
@namespace_class@::@namespace_class@(JS::Realm& realm)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().object_prototype())
|
||||
|
@ -4389,14 +4389,14 @@ namespace Web::Bindings {
|
|||
|
||||
class @constructor_class@ : public JS::NativeFunction {
|
||||
JS_OBJECT(@constructor_class@, JS::NativeFunction);
|
||||
JS_DECLARE_ALLOCATOR(@constructor_class@);
|
||||
GC_DECLARE_ALLOCATOR(@constructor_class@);
|
||||
public:
|
||||
explicit @constructor_class@(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual ~@constructor_class@() override;
|
||||
|
||||
virtual JS::ThrowCompletionOr<JS::Value> call() override;
|
||||
virtual JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct(JS::FunctionObject& new_target) override;
|
||||
virtual JS::ThrowCompletionOr<GC::Ref<JS::Object>> construct(JS::FunctionObject& new_target) override;
|
||||
|
||||
private:
|
||||
virtual bool has_constructor() const override { return true; }
|
||||
|
@ -4422,7 +4422,7 @@ private:
|
|||
for (auto i = 0u; i < overload_set.value.size(); ++i) {
|
||||
constructor_generator.set("overload_suffix", ByteString::number(i));
|
||||
constructor_generator.append(R"~~~(
|
||||
JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> construct@overload_suffix@(JS::FunctionObject& new_target);
|
||||
JS::ThrowCompletionOr<GC::Ref<JS::Object>> construct@overload_suffix@(JS::FunctionObject& new_target);
|
||||
)~~~");
|
||||
}
|
||||
}
|
||||
|
@ -4484,7 +4484,7 @@ void generate_constructor_implementation(IDL::Interface const& interface, String
|
|||
|
||||
generator.append(R"~~~(
|
||||
#include <LibIDL/Types.h>
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibJS/Runtime/ArrayBuffer.h>
|
||||
#include <LibJS/Runtime/DataView.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
@ -4526,7 +4526,7 @@ void generate_constructor_implementation(IDL::Interface const& interface, String
|
|||
generator.append(R"~~~(
|
||||
namespace Web::Bindings {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(@constructor_class@);
|
||||
GC_DEFINE_ALLOCATOR(@constructor_class@);
|
||||
|
||||
@constructor_class@::@constructor_class@(JS::Realm& realm)
|
||||
: NativeFunction("@name@"sv, realm.intrinsics().function_prototype())
|
||||
|
@ -4654,7 +4654,7 @@ namespace Web::Bindings {
|
|||
|
||||
class @prototype_class@ : public JS::Object {
|
||||
JS_OBJECT(@prototype_class@, JS::Object);
|
||||
JS_DECLARE_ALLOCATOR(@prototype_class@);
|
||||
GC_DECLARE_ALLOCATOR(@prototype_class@);
|
||||
public:
|
||||
explicit @prototype_class@(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
@ -4770,7 +4770,7 @@ void generate_prototype_implementation(IDL::Interface const& interface, StringBu
|
|||
generator.append(R"~~~(
|
||||
namespace Web::Bindings {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(@prototype_class@);
|
||||
GC_DEFINE_ALLOCATOR(@prototype_class@);
|
||||
|
||||
@prototype_class@::@prototype_class@([[maybe_unused]] JS::Realm& realm))~~~");
|
||||
if (interface.name == "DOMException") {
|
||||
|
@ -4848,7 +4848,7 @@ namespace Web::Bindings {
|
|||
|
||||
class @prototype_class@ : public JS::Object {
|
||||
JS_OBJECT(@prototype_class@, JS::Object);
|
||||
JS_DECLARE_ALLOCATOR(@prototype_class@);
|
||||
GC_DECLARE_ALLOCATOR(@prototype_class@);
|
||||
public:
|
||||
explicit @prototype_class@(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
@ -4895,7 +4895,7 @@ void generate_iterator_prototype_implementation(IDL::Interface const& interface,
|
|||
generator.append(R"~~~(
|
||||
namespace Web::Bindings {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(@prototype_class@);
|
||||
GC_DEFINE_ALLOCATOR(@prototype_class@);
|
||||
|
||||
@prototype_class@::@prototype_class@(JS::Realm& realm)
|
||||
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().iterator_prototype())
|
||||
|
|
|
@ -64,7 +64,7 @@ static ErrorOr<void> generate_intrinsic_definitions(StringView output_path, Vect
|
|||
SourceGenerator generator(builder);
|
||||
|
||||
generator.append(R"~~~(
|
||||
#include <LibJS/Heap/DeferGC.h>
|
||||
#include <LibGC/DeferGC.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>)~~~");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue