LibWeb: Support the "ImplementedAs" IDL attribute on functions

This commit is contained in:
Luke 2021-04-06 17:08:29 +01:00 committed by Andreas Kling
parent e56c56128b
commit 5b5d7857e3
Notes: sideshowbarker 2024-07-18 20:42:49 +09:00

View File

@ -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();
)~~~");