Ignore:
Timestamp:
Jul 28, 2018, 6:26:56 PM (15 months ago)
Author:
cameron
Message:

GetStringValue? method for string properties

File:
1 edited

Legend:

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

    r5770 r6134  
    5252        ${reflexive_set_value}
    5353
    54         const unsigned buffer_length = ${buffer_length};
     54        const static std::vector<unsigned> buffer_offsets = {
     55        ${buffer_offsets}};
    5556        const static char string_buffer LLVM_ALIGNAS(32) [${allocation_length}] = u8R"__(${string_buffer})__";
    5657
     
    6162                                                    std::move(reflexive_set),
    6263                                                    static_cast<const char *>(string_buffer),
    63                                                     buffer_length,
     64                                                    std::move(buffer_offsets),
    6465                                                    std::move(defined_cps));
    6566    }
     
    6768    cps = sorted(cp_value_map.keys())
    6869    string_buffer = ""
     70    buffer_offsets = [0]
    6971    for cp in cps:
    7072        string_buffer += cp_value_map[cp] + "\n"
    71     buffer_length = len(string_buffer.encode("utf-8"))
     73        buffer_offsets.append(len(string_buffer.encode("utf-8")))
     74    buffer_length = buffer_offsets[-1]
    7275    f.write(s.substitute(prop_enum = property_code,
    7376                         prop_enum_up = property_code.upper(),
    7477                         string_buffer = string_buffer,
    75                          buffer_length = buffer_length,
     78                         buffer_offsets = cformat.multiline_fill(['%i' % o for o in buffer_offsets], ',', 8),
    7679                         allocation_length = (buffer_length + 255) & -256,
    7780                         null_set_ranges = cformat.multiline_fill(['[%04x, %04x]' % (lo, hi) for (lo, hi) in uset_to_range_list(null_set)], ',', 8),
     
    9093        ${overridden_set_value}
    9194
    92         const unsigned buffer_length = ${buffer_length};
     95        const static std::vector<unsigned> buffer_offsets = {
     96        ${buffer_offsets}};
    9397        const static char string_buffer LLVM_ALIGNAS(32) [${allocation_length}] = u8R"__(${string_buffer})__";
    9498
     
    99103                                                    std::move(explicitly_defined_set),
    100104                                                    static_cast<const char *>(string_buffer),
    101                                                     buffer_length,
     105                                                    std::move(buffer_offsets),
    102106                                                    std::move(defined_cps));
    103107    }
     
    105109    cps = sorted(cp_value_map.keys())
    106110    string_buffer = ""
     111    buffer_offsets = [0]
    107112    for cp in cps:
    108113        string_buffer += cp_value_map[cp] + "\n"
    109     buffer_length = len(string_buffer.encode("utf-8"))
     114        buffer_offsets.append(len(string_buffer.encode("utf-8")))
     115    buffer_length = buffer_offsets[-1]
    110116    f.write(s.substitute(prop_enum = property_code,
    111117                         prop_enum_up = property_code.upper(),
    112118                         overridden = overridden_code.upper(),
    113119                         string_buffer = string_buffer,
    114                          buffer_length = buffer_length,
     120                         buffer_offsets = cformat.multiline_fill(['%i' % o for o in buffer_offsets], ',', 8),
    115121                         allocation_length = (buffer_length + 255) & -256,
    116122                         overridden_set_ranges = cformat.multiline_fill(['[%04x, %04x]' % (lo, hi) for (lo, hi) in uset_to_range_list(override_set)], ',', 8),
     
    294300};
    295301
    296 UCD::UnicodeSet * caseInsensitize(UCD::UnicodeSet * const cc);
     302UCD::UnicodeSet caseInsensitize(const UCD::UnicodeSet & cc);
    297303
    298304"""
     
    519525        fold_data = parse_CaseFolding_txt(self.property_object_map)
    520526        cm = simple_CaseClosure_map(fold_data)
    521         f = cformat.open_header_file_for_write(basename, 'casefold.py')
     527        f = cformat.open_header_file_for_write(basename, 'UCD_properties.py')
    522528        cformat.write_imports(f, ['"PropertyAliases.h"', '"PropertyObjects.h"', '"PropertyValueAliases.h"', '"unicode_set.h"', '<vector>'])
    523529        f.write(foldDeclarations)
Note: See TracChangeset for help on using the changeset viewer.