Changeset 4387


Ignore:
Timestamp:
Jan 1, 2015, 4:35:28 PM (4 years ago)
Author:
cameron
Message:

Updated generator files for new predefined property support

Location:
proto/charsetcompiler
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • proto/charsetcompiler/Makefile

    r4379 r4387  
    1717
    1818gc:
    19         python $(PABLO_COMPILER) DerivedGeneralCategory.pablo -Z -t gc.h -o src/gc.h
     19        python $(PABLO_COMPILER) DerivedGeneralCategory.pablo -Z -t ucd_precompiled_gc.h -o src/precompiled_gc.h
    2020
    2121sc:
    22         python $(PABLO_COMPILER) Scripts.pablo -Z -t sc.h -o src/sc.h
     22        python $(PABLO_COMPILER) Scripts.pablo -Z -t ucd_precompiled_sc.h -o src/precompiled_sc.h
    2323
    2424scx:
    25         python $(PABLO_COMPILER) ScriptExtensions.pablo -Z -t scx.h -o src/scx.h
     25        python $(PABLO_COMPILER) ScriptExtensions.pablo -Z -t ucd_precompiled_scx.h -o src/precompiled_scx.h
    2626
     27blk:
     28        python $(PABLO_COMPILER) Blocks.pablo -Z -t ucd_precompiled_blk.h -o src/precompiled_blk.h
     29
  • proto/charsetcompiler/UCD/UCD_parser.py

    r4375 r4387  
    133133        property_value_lookup_map[prop_code][canonicalize(value_preferred_full_name)] = value_enum
    134134        for a in value_aliases: property_value_lookup_map[prop_code][canonicalize(a)] = value_enum
     135    # Special case for scx:
     136    property_value_list['scx'] = property_value_list['sc']
     137    property_value_enum_integer['scx'] = property_value_enum_integer['sc']
     138    property_value_full_name_map['scx'] = property_value_full_name_map['sc']
     139    property_value_lookup_map['scx'] = property_value_lookup_map['sc']
    135140    return (property_value_list, property_value_enum_integer, property_value_full_name_map, property_value_lookup_map, missing_specs)
    136141
  • proto/charsetcompiler/UCD/UCD_properties.py

    r4381 r4387  
    5252    const std::vector<std::string> value_names = {
    5353      %s};
    54     const std::unordered_map<std::string, int> aliases_only_map = {
     54    const std::unordered_map<std::string, int> aliases_only_map = std::unordered_map<std::string, int> {
    5555      %s};
    5656  }
  • proto/charsetcompiler/generate_UCD_property_functions.py

    r4379 r4387  
    1616
    1717Unicode_property_fn_template = Template(r"""
    18 Property_${property}_${value} * f${property}_${value} = nullptr;
     18Property_${property}_${value} f${property}_${value};
    1919
    2020extern "C" {
    2121    BitBlock __get_${property}_${value} (Basis_bits & basis_bits) {
    22         if (f${property}_${value} == nullptr) f${property}_${value} = new Property_${property}_${value}();
    2322        Struct_${property}_${value} output;
    24         f${property}_${value} -> do_block(basis_bits, output);
     23        f${property}_${value} . do_block(basis_bits, output);
    2524        return output.cc;
    2625    }
     
    4948Unicode_template_var = Template("struct_${property}_%s.cc")
    5049
     50install_fn = r"""
     51void install_property_%s_fn_ptrs(pablo::PabloCompiler & p) {
     52  %s
     53}
     54"""
    5155
    5256class UCD_generator():
     
    6165
    6266    def generate_enumerated_property_template(self, filename_root, property_code):
    63        f = cformat.open_header_file_for_write(os.path.basename(property_code))
     67       f = cformat.open_header_file_for_write(os.path.basename("ucd_precompiled_%s" % property_code))
     68       cformat.write_imports(f, ['"pablo/pablo_compiler.h"'])
    6469       f.write(Unicode_pablo_template)
     70       pc = property_code.lower()
    6571       vlist = self.property_value_list[property_code]
    6672       for v in vlist:
    67           f.write(Unicode_property_fn_template.substitute({'property': property_code.lower(), 'value': v}))
     73          f.write(Unicode_property_fn_template.substitute({'property': pc, 'value': v}))
     74       install_stmt = "  p.InstallExternalFunction(\"__get_%s_%%s\", (void *) & __get_%s_%%s);\n" % (pc, pc)
     75       install_list = [install_stmt % (k, k) for k in vlist]
     76       f.write(install_fn % (pc, "".join(install_list)))
    6877       cformat.close_header_file(f)
    6978       
    70     def generate_enumerated_property_file(self, filename_root, property_code, default_value = None):
     79    def generate_enumerated_property_file(self, filename_root, property_code):
    7180       vlist = self.property_value_list[property_code]
    7281       canon_map = self.property_value_lookup_map[property_code]
    73        (prop_values, value_map) = parse_UCD_enumerated_property_map(property_code, vlist, canon_map, filename_root + '.txt', default_value)
     82       (prop_values, value_map) = parse_UCD_enumerated_property_map(property_code, vlist, canon_map, filename_root + '.txt')
    7483       basename = os.path.basename(filename_root)
    7584       f = open(basename + ".pablo", "wb")
    76        for k in value_map.keys():
     85       for k in vlist:
    7786         parms = {'property' : property_code.lower(), 'value' : k}
    7887         f.write(Unicode_CC_struct.substitute(parms))
     
    8695       filename_root = 'ScriptExtensions'
    8796       property_code = 'scx'
    88        (prop_values, value_map) = parse_ScriptExtensions_txt(self.property_value_list['sc'], self.property_value_lookup_map['sc'])
     97       vlist = self.property_value_list['sc']
     98       (prop_values, value_map) = parse_ScriptExtensions_txt(vlist, self.property_value_lookup_map['sc'])
    8999       basename = os.path.basename(filename_root)
    90100       f = open(basename + ".pablo", "wb")
    91        for k in value_map.keys():
     101       for k in vlist:
    92102         parms = {'property' : 'scx', 'value' : k}
    93103         f.write(Unicode_CC_struct.substitute(parms))
     
    110120   #
    111121   # The Block property
    112    #ucd.generate_enumerated_property_file('Blocks', 'blk')
     122   ucd.generate_enumerated_property_template('Blocks', 'blk')
     123   ucd.generate_enumerated_property_file('Blocks', 'blk')
    113124   #
    114125   # Scripts
     
    117128   #
    118129   # Script Extensions
    119    #ucd.generate_enumerated_property_template('ScriptExtensions', 'scx')
     130   ucd.generate_enumerated_property_template('ScriptExtensions', 'scx')
    120131   ucd.generate_ScriptExtensions_pablo()
    121132   #
Note: See TracChangeset for help on using the changeset viewer.