LibIDL: Pass partial interface extended attributes onto its members

This commit is contained in:
Luke Wilde 2025-07-24 13:06:45 +01:00 committed by Andreas Kling
commit bd51bc6874
Notes: github-actions[bot] 2025-07-25 09:48:16 +00:00
3 changed files with 36 additions and 7 deletions

View file

@ -813,13 +813,14 @@ void Parser::parse_interface(Interface& interface)
consume_whitespace(); consume_whitespace();
} }
void Parser::parse_partial_interface(Interface& parent) void Parser::parse_partial_interface(HashMap<ByteString, ByteString> extended_attributes, Interface& parent)
{ {
assert_string("partial"sv); assert_string("partial"sv);
consume_whitespace(); consume_whitespace();
assert_string("interface"sv); assert_string("interface"sv);
auto partial_interface = make<Interface>(); auto partial_interface = make<Interface>();
partial_interface->extended_attributes = move(extended_attributes);
parse_interface(*partial_interface); parse_interface(*partial_interface);
parent.partial_interfaces.append(move(partial_interface)); parent.partial_interfaces.append(move(partial_interface));
} }
@ -1063,7 +1064,7 @@ void Parser::parse_non_interface_entities(bool allow_interface, Interface& inter
} else if (lexer.next_is("typedef")) { } else if (lexer.next_is("typedef")) {
parse_typedef(interface); parse_typedef(interface);
} else if (lexer.next_is("partial interface"sv)) { } else if (lexer.next_is("partial interface"sv)) {
parse_partial_interface(interface); parse_partial_interface(extended_attributes, interface);
} else if (lexer.next_is("interface mixin")) { } else if (lexer.next_is("interface mixin")) {
parse_interface_mixin(interface); parse_interface_mixin(interface);
} else if (lexer.next_is("callback")) { } else if (lexer.next_is("callback")) {

View file

@ -45,7 +45,7 @@ private:
HashMap<ByteString, ByteString> parse_extended_attributes(); HashMap<ByteString, ByteString> parse_extended_attributes();
void parse_attribute(HashMap<ByteString, ByteString>& extended_attributes, Interface&, IsStatic is_static = IsStatic::No); void parse_attribute(HashMap<ByteString, ByteString>& extended_attributes, Interface&, IsStatic is_static = IsStatic::No);
void parse_interface(Interface&); void parse_interface(Interface&);
void parse_partial_interface(Interface& parent); void parse_partial_interface(HashMap<ByteString, ByteString> extended_attributes, Interface& parent);
void parse_namespace(Interface&); void parse_namespace(Interface&);
void parse_non_interface_entities(bool allow_interface, Interface&); void parse_non_interface_entities(bool allow_interface, Interface&);
void parse_enumeration(HashMap<ByteString, ByteString>, Interface&); void parse_enumeration(HashMap<ByteString, ByteString>, Interface&);

View file

@ -307,11 +307,39 @@ void EffectiveOverloadSet::remove_all_other_entries()
void Interface::extend_with_partial_interface(Interface const& partial) void Interface::extend_with_partial_interface(Interface const& partial)
{ {
attributes.extend(partial.attributes); for (auto const& attribute : partial.attributes) {
static_attributes.extend(partial.static_attributes); auto attribute_copy = attribute;
for (auto const& [key, value] : partial.extended_attributes) {
attribute_copy.extended_attributes.set(key, value);
}
attributes.append(move(attribute_copy));
}
for (auto const& static_attribute : partial.static_attributes) {
auto static_attribute_copy = static_attribute;
for (auto const& [key, value] : partial.extended_attributes) {
static_attribute_copy.extended_attributes.set(key, value);
}
static_attributes.append(move(static_attribute_copy));
}
constants.extend(partial.constants); constants.extend(partial.constants);
functions.extend(partial.functions);
static_functions.extend(partial.static_functions); for (auto const& function : partial.functions) {
auto function_copy = function;
for (auto const& [key, value] : partial.extended_attributes) {
function_copy.extended_attributes.set(key, value);
}
functions.append(move(function_copy));
}
for (auto const& static_function : partial.static_functions) {
auto static_function_copy = static_function;
for (auto const& [key, value] : partial.extended_attributes) {
static_function_copy.extended_attributes.set(key, value);
}
static_functions.append(move(static_function_copy));
}
} }
} }