mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
LibWeb: Allow specifying a custom C++ implementation for IDL attributes
The "ImplementedAs" extended attribute can now be specified on IDL attributes to provide the name of a custom C++ implementation instead of assuming it will have the same name as the attribute.
This commit is contained in:
parent
79bc07e5af
commit
0d515dea5d
Notes:
sideshowbarker
2024-07-18 21:37:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0d515dea5d3
@ -1300,6 +1300,13 @@ static @fully_qualified_name@* impl_from(JS::VM& vm, JS::GlobalObject& global_ob
|
|||||||
attribute_generator.set("attribute.setter_callback", attribute.setter_callback_name);
|
attribute_generator.set("attribute.setter_callback", attribute.setter_callback_name);
|
||||||
attribute_generator.set("attribute.name:snakecase", attribute.name.to_snakecase());
|
attribute_generator.set("attribute.name:snakecase", attribute.name.to_snakecase());
|
||||||
|
|
||||||
|
if (attribute.extended_attributes.contains("ImplementedAs")) {
|
||||||
|
auto implemented_as = attribute.extended_attributes.get("ImplementedAs").value();
|
||||||
|
attribute_generator.set("attribute.cpp_getter_name", implemented_as);
|
||||||
|
} else {
|
||||||
|
attribute_generator.set("attribute.cpp_getter_name", attribute.name.to_snakecase());
|
||||||
|
}
|
||||||
|
|
||||||
if (attribute.extended_attributes.contains("Reflect")) {
|
if (attribute.extended_attributes.contains("Reflect")) {
|
||||||
auto attribute_name = attribute.extended_attributes.get("Reflect").value();
|
auto attribute_name = attribute.extended_attributes.get("Reflect").value();
|
||||||
if (attribute_name.is_null())
|
if (attribute_name.is_null())
|
||||||
@ -1338,7 +1345,7 @@ JS_DEFINE_NATIVE_GETTER(@prototype_class@::@attribute.getter_callback@)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
attribute_generator.append(R"~~~(
|
attribute_generator.append(R"~~~(
|
||||||
auto retval = impl->@attribute.name:snakecase@();
|
auto retval = impl->@attribute.cpp_getter_name@();
|
||||||
)~~~");
|
)~~~");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user