mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:27:34 +00:00
LibWeb: Support the "ImplementedAs" IDL attribute on functions
This commit is contained in:
parent
e56c56128b
commit
5b5d7857e3
1 changed files with 8 additions and 1 deletions
|
@ -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", function.name);
|
||||||
function_generator.set("function.name:snakecase", function.name.to_snakecase());
|
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"~~~(
|
function_generator.append(R"~~~(
|
||||||
JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::@function.name:snakecase@)
|
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.set(".arguments", arguments_builder.string_view());
|
||||||
|
|
||||||
function_generator.append(R"~~~(
|
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))
|
if (should_return_empty(retval))
|
||||||
return JS::Value();
|
return JS::Value();
|
||||||
)~~~");
|
)~~~");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue