Ignore:
Timestamp:
Oct 6, 2017, 11:36:55 AM (22 months ago)
Author:
cameron
Message:

StringOverride? properties (simple case conversion vs full case conversion)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/UCD-scripts/UCD_properties.py

    r5671 r5672  
    8181    reflexive_set_ranges = cformat.multiline_fill(['[%04x, %04x]' % (lo, hi) for (lo, hi) in uset_to_range_list(reflexive_set)], ',', 8),
    8282    reflexive_set_value = reflexive_set.showC(12),
     83    explicitly_defined_cp_count = len(cps),
     84    explicitly_defined_cps = cformat.multiline_fill(['0x%04x' % cp for cp in cps], ',', 8)
     85    ))
     86
     87def emit_string_override_property(f, property_code, overridden_code, override_set, cp_value_map):
     88    s = string.Template(r"""    namespace ${prop_enum_up}_ns {
     89        /** Code Point Ranges for ${prop_enum} overriding values from ${overridden}
     90        ${overridden_set_ranges}**/
     91
     92        const UnicodeSet overridden_set
     93        ${overridden_set_value};
     94
     95        const unsigned buffer_length = ${buffer_length};
     96        const static char __attribute__ ((aligned (32))) string_buffer[${allocation_length}] = u8R"__(${string_buffer})__";
     97
     98        const static std::vector<codepoint_t> defined_cps = {
     99        ${explicitly_defined_cps}};
     100        static StringOverridePropertyObject property_object(${prop_enum},
     101                                                    ${overridden}_ns::property_object,
     102                                                    overridden_set,
     103                                                    static_cast<const char *>(string_buffer),
     104                                                    buffer_length,
     105                                                    defined_cps);
     106    }
     107""")
     108    cps = sorted(cp_value_map.keys())
     109    string_buffer = ""
     110    for cp in cps:
     111        string_buffer += cp_value_map[cp] + "\n"
     112    buffer_length = len(string_buffer.encode("utf-8"))
     113    f.write(s.substitute(prop_enum = property_code,
     114    prop_enum_up = property_code.upper(),
     115    overridden = overridden_code.upper(),
     116    string_buffer = string_buffer,
     117    buffer_length = buffer_length,
     118    allocation_length = (buffer_length + 255) & -256,
     119    overridden_set_ranges = cformat.multiline_fill(['[%04x, %04x]' % (lo, hi) for (lo, hi) in uset_to_range_list(override_set)], ',', 8),
     120    overridden_set_value = override_set.showC(12),
    83121    explicitly_defined_cp_count = len(cps),
    84122    explicitly_defined_cps = cformat.multiline_fill(['0x%04x' % cp for cp in cps], ',', 8)
     
    239277        elif isinstance(property_object, StringPropertyObject):
    240278            emit_string_property(f, property_code, property_object.null_str_set, property_object.reflexive_set, property_object.cp_value_map)
     279        elif isinstance(property_object, StringOverridePropertyObject):
     280            emit_string_override_property(f, property_code, property_object.overridden_code, property_object.overridden_set, property_object.cp_value_map)
    241281        elif isinstance(property_object, NumericPropertyObject):
    242282            emit_numeric_property(f, property_code, property_object.NaN_set, property_object.cp_value_map)
     
    305345        parse_SpecialCasing_txt(self.property_object_map)
    306346        f = cformat.open_header_file_for_write(basename)
    307         cformat.write_imports(f, ['"PropertyAliases.h"', '"PropertyObjects.h"', '"PropertyValueAliases.h"', '"unicode_set.h"'])
     347        cformat.write_imports(f, ['"PropertyAliases.h"', '"PropertyObjects.h"', '"PropertyValueAliases.h"', '"UnicodeData.h"', '"unicode_set.h"'])
    308348        f.write("\nnamespace UCD {\n")
    309349        for p in ['lc', 'uc', 'tc']:
Note: See TracChangeset for help on using the changeset viewer.