1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 01:27:42 +00:00

LibWeb: Stop generating C++ includes for non-code-generating IDL files

Specifically, IDL files that do not include interface or enumeration
declarations do not generate any code, and as such should not be
included.
This commit is contained in:
Idan Horowitz 2022-03-30 23:30:12 +03:00 committed by Andreas Kling
parent eb34015748
commit f0cd28dedd
4 changed files with 25 additions and 7 deletions

View file

@ -141,7 +141,10 @@ Optional<NonnullOwnPtr<Interface>> Parser::resolve_import(auto path)
report_parsing_error(String::formatted("Failed to open {}: {}", real_path, file_or_error.error()), filename, input, lexer.tell());
auto data = file_or_error.value()->read_all();
return Parser(real_path, data, import_base_path).parse();
auto result = Parser(real_path, data, import_base_path).parse();
if (result->will_generate_code())
required_imported_paths.set(real_path);
return result;
}
NonnullRefPtr<Type> Parser::parse_type()
@ -745,13 +748,16 @@ NonnullOwnPtr<Interface> Parser::parse()
lexer.ignore();
auto maybe_interface = resolve_import(path);
if (maybe_interface.has_value()) {
for (auto& entry : maybe_interface.value()->imported_paths)
for (auto& entry : maybe_interface.value()->all_imported_paths)
s_all_imported_paths.set(entry);
for (auto& entry : maybe_interface.value()->required_imported_paths)
required_imported_paths.set(entry);
imports.append(maybe_interface.release_value());
}
consume_whitespace();
}
interface->imported_paths = s_all_imported_paths;
interface->all_imported_paths = s_all_imported_paths;
interface->required_imported_paths = required_imported_paths;
if (lexer.consume_specific('['))
interface->extended_attributes = parse_extended_attributes();
@ -828,6 +834,8 @@ NonnullOwnPtr<Interface> Parser::parse()
}
// FIXME: Add support for overloading constructors
if (interface->will_generate_code())
interface->required_imported_paths.set(this_module);
interface->imported_modules = move(imports);
return interface;