1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:38:12 +00:00

GMLCompiler: Add common pattern for a user-defined fallible initializer

Many widget classes need to run substantial initialization code after
they have been setup from GML. With this change, an
initialize_fallibles() function is called if available, allowing the
initialization to be invoked from the GML setup automatically. This
means that the GML-generated creation function can now be used directly
for many more cases, and reduces code duplication.
This commit is contained in:
kleines Filmröllchen 2024-01-25 14:11:38 +01:00 committed by Andrew Kaster
parent 8878e0c815
commit dec066fa5c
3 changed files with 24 additions and 0 deletions

View file

@ -334,6 +334,8 @@ static ErrorOr<void> generate_loader_for_object(GUI::GML::Object const& gml_obje
return {};
}));
TRY(append(generator, "TRY(::GUI::initialize(*@object_name@));"));
generator.append(TRY(String::repeated(' ', (indentation - 1) * 4)).bytes_as_string_view());
generator.appendln("}");