Skip to content

Commit

Permalink
Meta: Use property aliases for BidirectionalClass enum values
Browse files Browse the repository at this point in the history
Changes the generated UnicodeData.h from

    enum class BidirectionalClass : BidirectionalClassUnderlyingType {
        AL,
        AN,
        B,
        ...
    };

to

    enum class BidirectionalClass : BidirectionalClassUnderlyingType {
        AL,
        AN,
        B,
        ...
        Arabic_Letter = AL,
        Arabic_Number = AN,
        Boundary_Neutral = BN,
        ...
    };
  • Loading branch information
nico committed Nov 23, 2024
1 parent 03e1dfb commit 64db7ee
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ struct UnicodeData {

HashTable<ByteString> bidirectional_classes;
Vector<CodePointBidiClass> code_point_bidirectional_classes;
Vector<Alias> bidirectional_class_aliases;
};

static ByteString sanitize_entry(ByteString const& entry)
Expand Down Expand Up @@ -842,7 +843,7 @@ namespace Unicode {
generate_enum("WordBreakProperty"sv, {}, unicode_data.word_break_props.keys());
generate_enum("SentenceBreakProperty"sv, {}, unicode_data.sentence_break_props.keys());
generate_enum("CompatibilityFormattingTag"sv, "Canonical"sv, unicode_data.compatibility_tags);
generate_enum("BidirectionalClass"sv, {}, unicode_data.bidirectional_classes.values());
generate_enum("BidirectionalClass"sv, {}, unicode_data.bidirectional_classes.values(), unicode_data.bidirectional_class_aliases);

generator.append(R"~~~(
struct SpecialCasing {
Expand Down Expand Up @@ -1916,6 +1917,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)

populate_general_category_unions(unicode_data.general_categories);
TRY(parse_unicode_data(*unicode_data_file, unicode_data));
TRY(parse_value_alias_list(*prop_value_alias_file, "bc"sv, unicode_data.bidirectional_classes.values(), unicode_data.bidirectional_class_aliases));
TRY(parse_value_alias_list(*prop_value_alias_file, "gc"sv, unicode_data.general_categories.keys(), unicode_data.general_category_aliases));
TRY(parse_value_alias_list(*prop_value_alias_file, "sc"sv, unicode_data.script_list.keys(), unicode_data.script_aliases, false));
TRY(normalize_script_extensions(unicode_data.script_extensions, unicode_data.script_list, unicode_data.script_aliases));
Expand Down

0 comments on commit 64db7ee

Please sign in to comment.