mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +00:00
Meta+Userland: Allow generating C++ initializer code from GML
This does the exact same thing as the runtime initializer, except it is faster and can catch some errors much earlier. The code generator includes these important features: - Automatic include generation where necessary - Special-casing for TabWidget and ScrollableContainerWidget - No use of DeprecatedString where possible
This commit is contained in:
parent
1e67435ff5
commit
d1645efde9
6 changed files with 347 additions and 0 deletions
|
@ -188,6 +188,19 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
template<FallibleFunction<StringView, NonnullRefPtr<JsonValueNode>> Callback>
|
||||
ErrorOr<void> try_for_each_property(Callback callback) const
|
||||
{
|
||||
for (auto const& child : m_properties) {
|
||||
if (is<KeyValuePair>(child)) {
|
||||
auto const& property = static_cast<KeyValuePair const&>(*child);
|
||||
if (property.key() != "layout" && is<JsonValueNode>(property.value().ptr()))
|
||||
TRY(callback(property.key(), static_ptr_cast<JsonValueNode>(property.value())));
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_child_object(Callback callback) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue