Changeset 4619 for proto


Ignore:
Timestamp:
Jun 26, 2015, 3:32:49 PM (4 years ago)
Author:
nmedfort
Message:

Corrected bug in generated UCD code that prevented including the predefined UnicodeSets? in more than one file and removed quad_count.

Location:
proto/charsetcompiler/UCD
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/charsetcompiler/UCD/UCD_properties.py

    r4389 r4619  
    3333"""
    3434
    35 PropertyValueAliases_template = r"""
    36 namespace UCD {
    37   enum binary_value_t {N, Y};
    38 %s
    39 
    40   const std::vector<std::string> value_name[] = {
    41 %s};
    42 
    43   const std::unordered_map<std::string, int> property_value_alias_map[] = {
    44 %s};
    45 
    46 }
    47 """
    48 
    4935EnumeratedProperty_template = r"""
    5036  namespace %s_ns {
     
    6046"""
    6147
    62    
    6348CodepointProperties = ['scf', 'slc', 'suc', 'stc']
    6449
     
    126111        basename = os.path.basename(filename_root)
    127112        f = cformat.open_header_file_for_write(os.path.basename(filename_root))
    128         cformat.write_imports(f, ["<vector>", '"unicode_set.h"', '"PropertyAliases.h"', '"PropertyValueAliases.h"'])
     113        cformat.write_imports(f, ['"PropertyObjects.h"', '"PropertyValueAliases.h"', '"unicode_set.h"'])
    129114        f.write("\nnamespace UCD {\n")
    130115        f.write("  namespace %s_ns {\n" % property_code.upper())
     
    134119        print "%s: %s bytes" % (basename, sum([value_map[v].bytes() for v in value_map.keys()]))
    135120        set_list = ['%s_Set' % v.lower() for v in self.property_value_list[property_code]]
    136         f.write("    EnumeratedPropertyObject property_object\n")
     121        f.write("    static EnumeratedPropertyObject property_object\n")
    137122        f.write("      {%s,\n" % property_code)
    138123        f.write("       %s_ns::enum_names,\n" % property_code.upper())
     
    152137        basename = os.path.basename(filename_root)
    153138        f = cformat.open_header_file_for_write(basename)
    154         cformat.write_imports(f, ["<vector>", '"PropertyAliases.h"', '"PropertyValueAliases.h"', '"unicode_set.h"'])
     139        cformat.write_imports(f, ['"PropertyObjects.h"', '"PropertyValueAliases.h"', '"unicode_set.h"'])
    155140        f.write("\nnamespace UCD {\n")
    156141        f.write("  namespace SCX_ns {\n")
     
    160145        print "%s: %s bytes" % (basename, sum([value_map[v].bytes() for v in value_map.keys()]))
    161146        set_list = ['%s_Ext' % v.lower() for v in self.property_value_list['sc']]
    162         f.write("    EnumeratedPropertyObject property_object\n")
     147        f.write("    static EnumeratedPropertyObject property_object\n")
    163148        f.write("      {%s,\n" % property_code)
    164149        f.write("       SC_ns::enum_names,\n")
     
    172157        self.property_data_headers.append(basename)
    173158
    174 
    175159    def generate_binary_properties_file(self, filename_root):
    176160        (props, prop_map) = parse_UCD_codepoint_name_map(filename_root + '.txt', self.property_lookup_map)
    177161        basename = os.path.basename(filename_root)
    178162        f = cformat.open_header_file_for_write(basename)
    179         cformat.write_imports(f, ["<vector>", '"unicode_set.h"', '"PropertyAliases.h"'])
     163        cformat.write_imports(f, ['"PropertyAliases.h"', '"unicode_set.h"', "<vector>"])
    180164        f.write("\nnamespace UCD {\n")
    181165        print "%s: %s bytes" % (basename, sum([prop_map[p].bytes() for p in prop_map.keys()]))
     
    183167            f.write("  namespace %s_ns {\n    const UnicodeSet codepoint_set \n" % p.upper())
    184168            f.write(prop_map[p].showC(6) + ";\n")
    185             f.write("    BinaryPropertyObject property_object{%s, codepoint_set};\n  }\n" % p)
     169            f.write("    static BinaryPropertyObject property_object{%s, codepoint_set};\n  }\n" % p)
    186170        f.write("}\n\n")
    187171        cformat.close_header_file(f)
     
    191175    def generate_PropertyObjectTable_h(self):
    192176        f = cformat.open_header_file_for_write('PropertyObjectTable')
    193         cformat.write_imports(f, ['"PropertyObjects.h"', '"PropertyAliases.h"'])
     177        cformat.write_imports(f, ['"PropertyObjects.h"', '"PropertyAliases.h"', '<array>'])
    194178        cformat.write_imports(f, ['"%s.h"' % fname for fname in self.property_data_headers])
    195179        f.write("\nnamespace UCD {\n")
     
    201185            elif k == 'String':
    202186                if p in CodepointProperties:
    203                     objlist.append("new UnsupportedPropertyObject(%s, CodepointProperty)" % p)
     187                    objlist.append("new UnsupportedPropertyObject(%s, PropertyObject::ClassTypeId::CodepointProperty)" % p)
    204188                else:
    205                     objlist.append("new UnsupportedPropertyObject(%s, StringProperty)" % p)
     189                    objlist.append("new UnsupportedPropertyObject(%s, PropertyObject::ClassTypeId::StringProperty)" % p)
    206190            elif k == 'Binary' and p in self.supported_props:
    207191                objlist.append("&%s_ns::property_object" % p.upper())
    208192            else:
    209                 objlist.append("new UnsupportedPropertyObject(%s, %sProperty)" % (p, k))
    210         f.write("\n  PropertyObject* property_object_table[] = {\n    ")
    211         f.write(",\n    ".join(objlist) + '  };\n}\n')
     193                objlist.append("new UnsupportedPropertyObject(%s, PropertyObject::ClassTypeId::%sProperty)" % (p, k))
     194        f.write("\n  const std::array<PropertyObject *, %i> property_object_table = {{\n    " % len(objlist))
     195        f.write(",\n    ".join(objlist) + '  }};\n}\n')
    212196        cformat.close_header_file(f)
    213197
  • proto/charsetcompiler/UCD/unicode_set.py

    r4457 r4619  
    7171      setrep += (" " * indent) + " {"
    7272      setrep += cformat.multiline_fill(formatted_quads, ',', indent+2)
    73       setrep += '},\n'
    74       setrep += (" " * indent) + " %i}" % self.quad_count
     73      setrep += '}}\n'
    7574      return setrep
    7675
Note: See TracChangeset for help on using the changeset viewer.