mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Do not handle an invalid enum in idl_enum_to_string
We should never hit this case - so don't generate code for it, and instead put in a VERIFY_NOT_REACHED. Also improve the formatting of the generated code to closer match the serenity code style.
This commit is contained in:
parent
10add8aa8a
commit
4a62268d73
Notes:
sideshowbarker
2024-07-17 03:03:15 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/4a62268d73 Pull-request: https://github.com/SerenityOS/serenity/pull/24125
1 changed files with 7 additions and 5 deletions
|
@ -2622,19 +2622,21 @@ enum class @enum.type.name@ {
|
|||
)~~~");
|
||||
|
||||
enum_generator.append(R"~~~(
|
||||
inline String idl_enum_to_string(@enum.type.name@ value) {
|
||||
inline String idl_enum_to_string(@enum.type.name@ value)
|
||||
{
|
||||
switch (value) {
|
||||
)~~~");
|
||||
for (auto& entry : it.value.translated_cpp_names) {
|
||||
enum_generator.set("enum.entry", entry.value);
|
||||
enum_generator.set("enum.string", entry.key);
|
||||
enum_generator.append(R"~~~(
|
||||
case @enum.type.name@::@enum.entry@: return "@enum.string@"_string;
|
||||
case @enum.type.name@::@enum.entry@:
|
||||
return "@enum.string@"_string;
|
||||
)~~~");
|
||||
}
|
||||
enum_generator.append(R"~~~(
|
||||
default: return "<unknown>"_string;
|
||||
};
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue