mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00: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
1 changed files with 8 additions and 1 deletions
|
@ -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.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")) {
|
||||
auto attribute_name = attribute.extended_attributes.get("Reflect").value();
|
||||
if (attribute_name.is_null())
|
||||
|
@ -1338,7 +1345,7 @@ JS_DEFINE_NATIVE_GETTER(@prototype_class@::@attribute.getter_callback@)
|
|||
}
|
||||
} else {
|
||||
attribute_generator.append(R"~~~(
|
||||
auto retval = impl->@attribute.name:snakecase@();
|
||||
auto retval = impl->@attribute.cpp_getter_name@();
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue