mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
LibWeb: Support the "ImplementedAs" IDL attribute on functions
This commit is contained in:
parent
e56c56128b
commit
5b5d7857e3
Notes:
sideshowbarker
2024-07-18 20:42:49 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/5b5d7857e3b Pull-request: https://github.com/SerenityOS/serenity/pull/6158
@ -1426,6 +1426,13 @@ JS_DEFINE_NATIVE_SETTER(@prototype_class@::@attribute.setter_callback@)
|
||||
function_generator.set("function.name", function.name);
|
||||
function_generator.set("function.name:snakecase", function.name.to_snakecase());
|
||||
|
||||
if (function.extended_attributes.contains("ImplementedAs")) {
|
||||
auto implemented_as = function.extended_attributes.get("ImplementedAs").value();
|
||||
function_generator.set("function.cpp_name", implemented_as);
|
||||
} else {
|
||||
function_generator.set("function.cpp_name", function.name.to_snakecase());
|
||||
}
|
||||
|
||||
function_generator.append(R"~~~(
|
||||
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::@function.name:snakecase@)
|
||||
{
|
||||
@ -1441,7 +1448,7 @@ JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::@function.name:snakecase@)
|
||||
function_generator.set(".arguments", arguments_builder.string_view());
|
||||
|
||||
function_generator.append(R"~~~(
|
||||
auto retval = throw_dom_exception_if_needed(vm, global_object, [&] { return impl->@function.name:snakecase@(@.arguments@); });
|
||||
auto retval = throw_dom_exception_if_needed(vm, global_object, [&] { return impl->@function.cpp_name@(@.arguments@); });
|
||||
if (should_return_empty(retval))
|
||||
return JS::Value();
|
||||
)~~~");
|
||||
|
Loading…
Reference in New Issue
Block a user