mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +00:00
LibWeb: More fully implement the LegacyNamespace IDL extended attribute
Interfaces with a LegacyNamespace extended attribute should have their constructors defined on the namespace identified by the LegacyNamespace attribute value.
This commit is contained in:
parent
a277e645d3
commit
aa06dd7f21
1 changed files with 16 additions and 1 deletions
|
@ -159,6 +159,21 @@ void Intrinsics::create_web_namespace<@namespace_class@>(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
auto namespace_object = heap().allocate<@namespace_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
auto namespace_object = heap().allocate<@namespace_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||||
m_namespaces.set("@interface_name@"sv, namespace_object);
|
m_namespaces.set("@interface_name@"sv, namespace_object);
|
||||||
|
|
||||||
|
[[maybe_unused]] static constexpr u8 attr = JS::Attribute::Writable | JS::Attribute::Configurable;)~~~");
|
||||||
|
|
||||||
|
for (auto& interface : exposed_interfaces) {
|
||||||
|
if (interface.extended_attributes.get("LegacyNamespace"sv) != name)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
gen.set("owned_interface_name", interface.name);
|
||||||
|
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); });)~~~");
|
||||||
|
}
|
||||||
|
|
||||||
|
gen.append(R"~~~(
|
||||||
}
|
}
|
||||||
)~~~");
|
)~~~");
|
||||||
};
|
};
|
||||||
|
@ -316,7 +331,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global)
|
||||||
|
|
||||||
if (interface.is_namespace)
|
if (interface.is_namespace)
|
||||||
add_namespace(gen, interface.name, interface.namespace_class);
|
add_namespace(gen, interface.name, interface.namespace_class);
|
||||||
else
|
else if (!interface.extended_attributes.contains("LegacyNamespace"sv))
|
||||||
add_interface(gen, interface.namespaced_name, interface.prototype_class, lookup_legacy_constructor(interface));
|
add_interface(gen, interface.namespaced_name, interface.prototype_class, lookup_legacy_constructor(interface));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue