summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-08 11:16:06 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-08 11:50:36 +0100
commit0d515dea5d318b56a39525129689e4c89e9f8bc6 (patch)
tree09b9eaa6f60c45df2a99b0ff1578ec3c86ca251a /Userland/Libraries
parent79bc07e5af2bed550712a6cbdc6e70614904289a (diff)
downloadserenity-0d515dea5d318b56a39525129689e4c89e9f8bc6.zip
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
index 8db678edd1..0b7b167d9f 100644
--- a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
+++ b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
@@ -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@();
)~~~");
}