1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

LibWeb: Port Intrinsics from DeprecatedString

This commit is contained in:
Shannon Booth 2023-11-22 12:55:21 +13:00 committed by Tim Flynn
parent 9cd36839d2
commit 96af80acd1
279 changed files with 305 additions and 304 deletions

View file

@ -2597,7 +2597,7 @@ void @named_properties_class@::initialize(JS::Realm& realm)
} else {
generator.append(R"~~~(
set_prototype(&ensure_web_prototype<@prototype_base_class@>(realm, "@parent_name@"));
set_prototype(&ensure_web_prototype<@prototype_base_class@>(realm, "@parent_name@"_fly_string));
)~~~");
}
@ -2743,12 +2743,12 @@ void @class_name@::initialize(JS::Realm& realm)
)~~~");
} else if (is_global_interface && interface.supports_named_properties()) {
generator.append(R"~~~(
set_prototype(&ensure_web_prototype<@prototype_name@>(realm, "@name@"));
set_prototype(&ensure_web_prototype<@prototype_name@>(realm, "@name@"_fly_string));
)~~~");
} else {
generator.append(R"~~~(
set_prototype(&ensure_web_prototype<@prototype_base_class@>(realm, "@parent_name@"));
set_prototype(&ensure_web_prototype<@prototype_base_class@>(realm, "@parent_name@"_fly_string));
)~~~");
}
@ -3877,7 +3877,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::constru
// 2. Set prototype to the interface prototype object for interface in targetRealm.
VERIFY(target_realm);
prototype = &Bindings::ensure_web_prototype<@prototype_class@>(*target_realm, "@name@"sv);
prototype = &Bindings::ensure_web_prototype<@prototype_class@>(*target_realm, "@name@"_fly_string);
}
// 7. Set instance.[[Prototype]] to prototype.
@ -3903,7 +3903,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::constru
// 2. Set prototype to the interface prototype object of realm whose interface is the same as the interface of the active function object.
VERIFY(function_realm);
prototype = &Bindings::ensure_web_prototype<@prototype_class@>(*function_realm, "@name@"sv);
prototype = &Bindings::ensure_web_prototype<@prototype_class@>(*function_realm, "@name@"_fly_string);
}
VERIFY(prototype.is_object());
@ -3937,7 +3937,7 @@ void @constructor_class@::initialize(JS::Realm& realm)
[[maybe_unused]] u8 default_attributes = JS::Attribute::Enumerable;
Base::initialize(realm);
define_direct_property(vm.names.prototype, &ensure_web_prototype<@prototype_class@>(realm, "@namespaced_name@"), 0);
define_direct_property(vm.names.prototype, &ensure_web_prototype<@prototype_class@>(realm, "@namespaced_name@"_fly_string), 0);
define_direct_property(vm.names.length, JS::Value(@constructor.length@), JS::Attribute::Configurable);
)~~~");
@ -4179,7 +4179,7 @@ void @prototype_class@::initialize(JS::Realm& realm)
generator.set("namespaced_name", interface.namespaced_name);
generator.append(R"~~~(
define_direct_property(vm().well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm(), "@namespaced_name@"_string), JS::Attribute::Configurable);
set_prototype(&ensure_web_prototype<@prototype_class@>(realm, "@named_properties_class@"));
set_prototype(&ensure_web_prototype<@prototype_class@>(realm, "@named_properties_class@"_fly_string));
)~~~");
}
generator.append(R"~~~(

View file

@ -168,7 +168,7 @@ template<>
void Intrinsics::create_web_namespace<@namespace_class@>(JS::Realm& realm)
{
auto namespace_object = heap().allocate<@namespace_class@>(realm, realm);
m_namespaces.set("@interface_name@"sv, namespace_object);
m_namespaces.set("@interface_name@"_fly_string, namespace_object);
[[maybe_unused]] static constexpr u8 attr = JS::Attribute::Writable | JS::Attribute::Configurable;)~~~");
@ -180,7 +180,7 @@ void Intrinsics::create_web_namespace<@namespace_class@>(JS::Realm& realm)
gen.set("owned_prototype_class", interface.prototype_class);
gen.append(R"~~~(
namespace_object->define_intrinsic_accessor("@owned_interface_name@", attr, [](auto& realm) -> JS::Value { return &Bindings::ensure_web_constructor<@owned_prototype_class@>(realm, "@interface_name@.@owned_interface_name@"sv); });)~~~");
namespace_object->define_intrinsic_accessor("@owned_interface_name@", attr, [](auto& realm) -> JS::Value { return &Bindings::ensure_web_constructor<@owned_prototype_class@>(realm, "@interface_name@.@owned_interface_name@"_fly_string); });)~~~");
}
gen.append(R"~~~(
@ -204,16 +204,16 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea
gen.set("named_properties_class", named_properties_class);
gen.append(R"~~~(
auto named_properties_object = heap().allocate<@named_properties_class@>(realm, realm);
m_prototypes.set("@named_properties_class@"sv, named_properties_object);
m_prototypes.set("@named_properties_class@"_fly_string, named_properties_object);
)~~~");
}
gen.append(R"~~~(
auto prototype = heap().allocate<@prototype_class@>(realm, realm);
m_prototypes.set("@interface_name@"sv, prototype);
m_prototypes.set("@interface_name@"_fly_string, prototype);
auto constructor = heap().allocate<@constructor_class@>(realm, realm);
m_constructors.set("@interface_name@"sv, constructor);
m_constructors.set("@interface_name@"_fly_string, constructor);
prototype->define_direct_property(vm.names.constructor, constructor.ptr(), JS::Attribute::Writable | JS::Attribute::Configurable);
constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@interface_name@"_string), JS::Attribute::Configurable);
@ -224,7 +224,7 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea
gen.set("legacy_constructor_class", legacy_constructor->constructor_class);
gen.append(R"~~~(
auto legacy_constructor = heap().allocate<@legacy_constructor_class@>(realm, realm);
m_constructors.set("@legacy_interface_name@"sv, legacy_constructor);
m_constructors.set("@legacy_interface_name@"_fly_string, legacy_constructor);
legacy_constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@legacy_interface_name@"_string), JS::Attribute::Configurable);)~~~");
}
@ -334,12 +334,12 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
gen.set("prototype_class", prototype_class);
gen.append(R"~~~(
global.define_intrinsic_accessor("@interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"sv); });)~~~");
global.define_intrinsic_accessor("@interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@interface_name@"_fly_string); });)~~~");
if (legacy_constructor.has_value()) {
gen.set("legacy_interface_name", legacy_constructor->name);
gen.append(R"~~~(
global.define_intrinsic_accessor("@legacy_interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@legacy_interface_name@"sv); });)~~~");
global.define_intrinsic_accessor("@legacy_interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_constructor<@prototype_class@>(realm, "@legacy_interface_name@"_fly_string); });)~~~");
}
};
@ -348,7 +348,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
gen.set("namespace_class", namespace_class);
gen.append(R"~~~(
global.define_intrinsic_accessor("@interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_namespace<@namespace_class@>(realm, "@interface_name@"sv); });)~~~");
global.define_intrinsic_accessor("@interface_name@", attr, [](auto& realm) -> JS::Value { return &ensure_web_namespace<@namespace_class@>(realm, "@interface_name@"_fly_string); });)~~~");
};
for (auto& interface : exposed_interfaces) {