mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Add exception support in IDL constructors
This commit is contained in:
parent
d398943c37
commit
68bfb46a6f
Notes:
sideshowbarker
2024-07-18 19:05:49 +09:00
Author: https://github.com/Dexesttp Commit: https://github.com/SerenityOS/serenity/commit/68bfb46a6fe Pull-request: https://github.com/SerenityOS/serenity/pull/6610 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg
1 changed files with 6 additions and 3 deletions
|
@ -977,6 +977,7 @@ void generate_constructor_implementation(const IDL::Interface& interface)
|
|||
#include <LibWeb/Bindings/@constructor_class@.h>
|
||||
#include <LibWeb/Bindings/@prototype_class@.h>
|
||||
#include <LibWeb/Bindings/@wrapper_class@.h>
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#if __has_include(<LibWeb/CSS/@name@.h>)
|
||||
# include <LibWeb/CSS/@name@.h>
|
||||
|
@ -1050,15 +1051,17 @@ JS::Value @constructor_class@::construct(Function&)
|
|||
generator.set(".constructor_arguments", arguments_builder.string_view());
|
||||
|
||||
generator.append(R"~~~(
|
||||
auto impl = @fully_qualified_name@::create_with_global_object(window, @.constructor_arguments@);
|
||||
auto impl = throw_dom_exception_if_needed(vm, global_object, [&] { return @fully_qualified_name@::create_with_global_object(window, @.constructor_arguments@); });
|
||||
)~~~");
|
||||
} else {
|
||||
generator.append(R"~~~(
|
||||
auto impl = @fully_qualified_name@::create_with_global_object(window);
|
||||
auto impl = throw_dom_exception_if_needed(vm, global_object, [&] { return @fully_qualified_name@::create_with_global_object(window); });
|
||||
)~~~");
|
||||
}
|
||||
generator.append(R"~~~(
|
||||
return @wrapper_class@::create(global_object, impl);
|
||||
if (should_return_empty(impl))
|
||||
return JS::Value();
|
||||
return @wrapper_class@::create(global_object, impl.release_value());
|
||||
)~~~");
|
||||
} else {
|
||||
// Multiple constructor overloads - can't do that yet.
|
||||
|
|
Loading…
Reference in a new issue