1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:58:11 +00:00

LibWeb: Make IDL-constructed objects aware of their JS wrapper

Having IDL constructors call FooWrapper::create(impl) directly was
creating a wrapper directly without telling the impl object about the
wrapper. This meant that we had wrapped C++ objects with a null
wrapper() pointer.
This commit is contained in:
Andreas Kling 2021-10-04 12:10:04 +02:00
parent 643e2dec2c
commit bf43b0f884

View file

@ -2442,7 +2442,11 @@ void generate_constructor_implementation(IDL::Interface const& interface)
#include <LibWeb/Bindings/@constructor_class@.h>
#include <LibWeb/Bindings/@prototype_class@.h>
#include <LibWeb/Bindings/@wrapper_class@.h>
#include <LibWeb/Bindings/CSSRuleWrapperFactory.h>
#include <LibWeb/Bindings/EventTargetWrapperFactory.h>
#include <LibWeb/Bindings/EventWrapperFactory.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/NodeWrapperFactory.h>
#include <LibWeb/Bindings/WindowObject.h>
#if __has_include(<LibWeb/Crypto/@name@.h>)
# include <LibWeb/Crypto/@name@.h>
@ -2538,7 +2542,7 @@ JS::Value @constructor_class@::construct(FunctionObject&)
generator.append(R"~~~(
if (should_return_empty(impl))
return JS::Value();
return @wrapper_class@::create(global_object, impl.release_value());
return wrap(global_object, *impl.release_value());
)~~~");
} else {
// Multiple constructor overloads - can't do that yet.