1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 10:18:15 +09:00

LibWeb: Rename "identifier" and "ValueID" to "Keyword" where correct

For a long time, we've used two terms, inconsistently:
- "Identifier" is a spec term, but refers to a sequence of alphanumeric
  characters, which may or may not be a keyword. (Keywords are a
  subset of all identifiers.)
- "ValueID" is entirely non-spec, and is directly called a "keyword" in
  the CSS specs.

So to avoid confusion as much as possible, let's align with the spec
terminology. I've attempted to change variable names as well, but
obviously we use Keywords in a lot of places in LibWeb and so I may
have missed some.

One exception is that I've not renamed "valid-identifiers" in
Properties.json... I'd like to combine that and the "valid-types" array
together eventually, so there's no benefit to doing an extra rename
now.
This commit is contained in:
Sam Atkins 2024-08-14 14:06:03 +01:00 committed by Sam Atkins
parent 9559f0f123
commit 6a74b01644
Notes: github-actions[bot] 2024-08-15 12:59:33 +00:00
48 changed files with 702 additions and 702 deletions

View file

@ -17,15 +17,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
StringView generated_header_path;
StringView generated_implementation_path;
StringView identifiers_json_path;
StringView json_path;
Core::ArgsParser args_parser;
args_parser.add_option(generated_header_path, "Path to the Enums header file to generate", "generated-header-path", 'h', "generated-header-path");
args_parser.add_option(generated_implementation_path, "Path to the Enums implementation file to generate", "generated-implementation-path", 'c', "generated-implementation-path");
args_parser.add_option(identifiers_json_path, "Path to the JSON file to read from", "json-path", 'j', "json-path");
args_parser.add_option(json_path, "Path to the JSON file to read from", "json-path", 'j', "json-path");
args_parser.parse(arguments);
auto json = TRY(read_entire_file_as_json(identifiers_json_path));
auto json = TRY(read_entire_file_as_json(json_path));
VERIFY(json.is_object());
auto enums_data = json.as_object();
@ -50,7 +50,7 @@ ErrorOr<void> generate_header_file(JsonObject& enums_data, Core::File& file)
namespace Web::CSS {
enum class ValueID;
enum class Keyword;
)~~~");
@ -87,8 +87,8 @@ enum class ValueID;
}
enum_generator.appendln("};");
enum_generator.appendln("Optional<@name:titlecase@> value_id_to_@name:snakecase@(ValueID);");
enum_generator.appendln("ValueID to_value_id(@name:titlecase@);");
enum_generator.appendln("Optional<@name:titlecase@> keyword_to_@name:snakecase@(Keyword);");
enum_generator.appendln("Keyword to_keyword(@name:titlecase@);");
enum_generator.appendln("StringView to_string(@name:titlecase@);");
enum_generator.append("\n");
});
@ -106,7 +106,7 @@ ErrorOr<void> generate_implementation_file(JsonObject& enums_data, Core::File& f
generator.append(R"~~~(
#include <LibWeb/CSS/Enums.h>
#include <LibWeb/CSS/ValueID.h>
#include <LibWeb/CSS/Keyword.h>
namespace Web::CSS {
)~~~");
@ -120,9 +120,9 @@ namespace Web::CSS {
enum_generator.set("name:snakecase", snake_casify(name));
enum_generator.append(R"~~~(
Optional<@name:titlecase@> value_id_to_@name:snakecase@(ValueID value_id)
Optional<@name:titlecase@> keyword_to_@name:snakecase@(Keyword keyword)
{
switch (value_id) {)~~~");
switch (keyword) {)~~~");
for (auto& member : members.values()) {
auto member_generator = enum_generator.fork();
@ -136,7 +136,7 @@ Optional<@name:titlecase@> value_id_to_@name:snakecase@(ValueID value_id)
member_generator.set("member:titlecase", title_casify(member_name));
}
member_generator.append(R"~~~(
case ValueID::@valueid:titlecase@:
case Keyword::@valueid:titlecase@:
return @name:titlecase@::@member:titlecase@;)~~~");
}
@ -148,7 +148,7 @@ Optional<@name:titlecase@> value_id_to_@name:snakecase@(ValueID value_id)
)~~~");
enum_generator.append(R"~~~(
ValueID to_value_id(@name:titlecase@ @name:snakecase@_value)
Keyword to_keyword(@name:titlecase@ @name:snakecase@_value)
{
switch (@name:snakecase@_value) {)~~~");
@ -161,7 +161,7 @@ ValueID to_value_id(@name:titlecase@ @name:snakecase@_value)
member_generator.append(R"~~~(
case @name:titlecase@::@member:titlecase@:
return ValueID::@member:titlecase@;)~~~");
return Keyword::@member:titlecase@;)~~~");
}
enum_generator.append(R"~~~(