mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-30 21:28:59 +00:00
Meta: Set constructor prototype in IDLGenerators
Without this, retrieving `__proto__` from any interface will always yield an instance of `FunctionPrototype`.
This commit is contained in:
parent
db43ed03a8
commit
614b93beca
Notes:
github-actions[bot]
2024-11-26 12:45:02 +00:00
Author: https://github.com/gmta
Commit: 614b93beca
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2586
Reviewed-by: https://github.com/tcl3 ✅
4 changed files with 34 additions and 4 deletions
|
@ -4513,6 +4513,8 @@ void generate_constructor_implementation(IDL::Interface const& interface, String
|
|||
generator.set("prototype_class", interface.prototype_class);
|
||||
generator.set("constructor_class", interface.constructor_class);
|
||||
generator.set("fully_qualified_name", interface.fully_qualified_name);
|
||||
generator.set("parent_name", interface.parent_name);
|
||||
generator.set("prototype_base_class", interface.prototype_base_class);
|
||||
|
||||
generator.append(R"~~~(
|
||||
#include <LibIDL/Types.h>
|
||||
|
@ -4535,6 +4537,10 @@ void generate_constructor_implementation(IDL::Interface const& interface, String
|
|||
#include <LibWeb/WebIDL/Tracing.h>
|
||||
#include <LibWeb/WebIDL/Types.h>
|
||||
|
||||
#if __has_include(<LibWeb/Bindings/@prototype_base_class@.h>)
|
||||
# include <LibWeb/Bindings/@prototype_base_class@.h>
|
||||
#endif
|
||||
|
||||
)~~~");
|
||||
|
||||
if (interface.constructors.size() == 1) {
|
||||
|
@ -4586,6 +4592,15 @@ void @constructor_class@::initialize(JS::Realm& realm)
|
|||
[[maybe_unused]] u8 default_attributes = JS::Attribute::Enumerable;
|
||||
|
||||
Base::initialize(realm);
|
||||
)~~~");
|
||||
|
||||
if (interface.prototype_base_class != "ObjectPrototype") {
|
||||
generator.append(R"~~~(
|
||||
set_prototype(&ensure_web_constructor<@prototype_base_class@>(realm, "@parent_name@"_fly_string));
|
||||
)~~~");
|
||||
}
|
||||
|
||||
generator.append(R"~~~(
|
||||
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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue