mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/CSS: Use underlying_type_for_enum() for Enums.json generator
Replacing the duplicate implementation.
This commit is contained in:
parent
c4bcbff59a
commit
3add623f22
Notes:
github-actions[bot]
2025-05-19 22:15:23 +00:00
Author: https://github.com/AtkinsSJ
Commit: 3add623f22
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4820
1 changed files with 1 additions and 12 deletions
|
@ -61,18 +61,7 @@ enum class Keyword;
|
|||
auto enum_generator = generator.fork();
|
||||
enum_generator.set("name:titlecase", title_casify(name));
|
||||
enum_generator.set("name:snakecase", snake_casify(name));
|
||||
|
||||
// Find the smallest possible type to use.
|
||||
auto member_max_value = members.size() - 1;
|
||||
if (NumericLimits<u8>::max() >= member_max_value) {
|
||||
enum_generator.set("enum_type", "u8"_string);
|
||||
} else if (NumericLimits<u16>::max() >= member_max_value) {
|
||||
enum_generator.set("enum_type", "u16"_string);
|
||||
} else if (NumericLimits<u32>::max() >= member_max_value) {
|
||||
enum_generator.set("enum_type", "u32"_string);
|
||||
} else {
|
||||
enum_generator.set("enum_type", "u64"_string);
|
||||
}
|
||||
enum_generator.set("enum_type", underlying_type_for_enum(members.size()));
|
||||
|
||||
enum_generator.appendln("enum class @name:titlecase@ : @enum_type@ {");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue