mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
LibWeb: Actually instantiate all the web constructors/prototypes
We now instantiate all the generated web API constructors and expose them on the window object. We also set the generated prototypes on instantiated wrappers. Also, we should obviously find a way to generate this code. :^)
This commit is contained in:
parent
252a98042d
commit
ee7fa49b88
4 changed files with 349 additions and 7 deletions
|
@ -560,6 +560,7 @@ void generate_implementation(const IDL::Interface& interface)
|
|||
StringBuilder builder;
|
||||
SourceGenerator generator { builder };
|
||||
|
||||
generator.set("name", interface.name);
|
||||
generator.set("wrapper_class", interface.wrapper_class);
|
||||
generator.set("wrapper_base_class", interface.wrapper_base_class);
|
||||
generator.set("fully_qualified_name", interface.fully_qualified_name);
|
||||
|
@ -603,16 +604,17 @@ namespace Web::Bindings {
|
|||
if (interface.wrapper_base_class == "Wrapper") {
|
||||
generator.append(R"~~~(
|
||||
@wrapper_class@::@wrapper_class@(JS::GlobalObject& global_object, @fully_qualified_name@& impl)
|
||||
: Wrapper(*global_object.object_prototype())
|
||||
, m_impl(impl)
|
||||
: Wrapper(*global_object.object_prototype())
|
||||
, m_impl(impl)
|
||||
{
|
||||
}
|
||||
)~~~");
|
||||
} else {
|
||||
generator.append(R"~~~(
|
||||
@wrapper_class@::@wrapper_class@(JS::GlobalObject& global_object, @fully_qualified_name@& impl)
|
||||
: @wrapper_base_class@(global_object, impl)
|
||||
: @wrapper_base_class@(global_object, impl)
|
||||
{
|
||||
set_prototype(static_cast<WindowObject&>(global_object).web_prototype("@name@"));
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue