LibIDL: Allow overwriting the generated attribute callback name

This will allow the CSSStyleDeclaration IDL attribute generator to
implement it's own C++ acceptable identifier sanitization and
deduplication.
This commit is contained in:
Luke Wilde 2024-11-14 16:17:41 +00:00 committed by Andreas Kling
commit d95ae629ee
Notes: github-actions[bot] 2024-11-14 18:51:27 +00:00
2 changed files with 14 additions and 5 deletions

View file

@ -326,8 +326,16 @@ void Parser::parse_attribute(HashMap<ByteString, ByteString>& extended_attribute
assert_specific(';');
auto getter_callback_name = ByteString::formatted("{}_getter", name.to_snakecase());
auto setter_callback_name = ByteString::formatted("{}_setter", name.to_snakecase());
ByteString attribute_callback_name;
auto custom_callback_name = extended_attributes.find("AttributeCallbackName");
if (custom_callback_name != extended_attributes.end()) {
attribute_callback_name = custom_callback_name->value;
} else {
attribute_callback_name = name.to_snakecase().replace("-"sv, "_"sv, ReplaceMode::All);
}
auto getter_callback_name = ByteString::formatted("{}_getter", attribute_callback_name);
auto setter_callback_name = ByteString::formatted("{}_setter", attribute_callback_name);
Attribute attribute {
inherit,