Ignore:
Timestamp:
Jan 19, 2015, 8:43:56 PM (5 years ago)
Author:
cameron
Message:

Generator support for precompiled property cpp files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/charsetcompiler/generate_UCD_property_functions.py

    r4424 r4428  
    4848Unicode_template_var = Template("struct_${property}_%s.cc")
    4949
     50install_fn_header = r"""
     51void install_property_%s_fn_ptrs(pablo::PabloCompiler & p);
     52"""
    5053install_fn = r"""
    5154void install_property_%s_fn_ptrs(pablo::PabloCompiler & p) {
     
    6467        (self.property_value_list, self.property_value_enum_integer, self.property_value_full_name_map, self.property_value_lookup_map, self.missing_specs) = parse_PropertyValueAlias_txt(self.property_lookup_map)
    6568
    66     def generate_enumerated_property_template(self, filename_root, property_code):
    67         f = cformat.open_header_file_for_write(os.path.basename("ucd_precompiled_%s" % property_code), 'generate_UCD_property_functions.py')
    68         cformat.write_imports(f, ['"pablo/pablo_compiler.h"'])
    69         f.write(Unicode_pablo_template)
     69    def generate_enumerated_property_header_and_template(self, filename_root, property_code):
     70        hf = cformat.open_header_file_for_write(os.path.basename("precompiled_%s" % property_code), 'generate_UCD_property_functions.py')
     71        cformat.write_imports(hf, ['"pablo/pablo_compiler.h"'])
    7072        pc = property_code.lower()
     73        hf.write(install_fn_header % pc)
     74        cformat.close_header_file(hf)
     75        tf = cformat.open_cpp_file_for_write(os.path.basename("precompiled_%s" % property_code), 'generate_UCD_property_functions.py')
     76        cformat.write_imports(tf, ['"icgrep.h"'])
     77        tf.write(Unicode_pablo_template)
    7178        vlist = self.property_value_list[property_code]
    7279        for v in vlist:
    73             f.write(Unicode_property_fn_template.substitute({'property': pc, 'value': v}))
     80            tf.write(Unicode_property_fn_template.substitute({'property': pc, 'value': v}))
    7481        install_stmt = "  p.InstallExternalFunction(\"__get_%s_%%s\", (void *) & __get_%s_%%s);\n" % (pc, pc)
    7582        install_list = [install_stmt % (k, k) for k in vlist]
    76         f.write(install_fn % (pc, "".join(install_list)))
    77         cformat.close_header_file(f)
    78        
     83        tf.write(install_fn % (pc, "".join(install_list)))
     84        cformat.close_cpp_file(tf)
     85
    7986    def generate_enumerated_property_file(self, filename_root, property_code):
    8087        vlist = self.property_value_list[property_code]
     
    108115        f.close()
    109116
    110     def generate_binary_property_template(self, filename_root):
     117    def generate_binary_property_header_and_template(self, filename_root):
    111118        (props, prop_map) = parse_UCD_codepoint_name_map(filename_root + '.txt', self.property_lookup_map)
    112119        lprops = [p.lower() for p in props]
    113         f = cformat.open_header_file_for_write(os.path.basename("ucd_precompiled_%s" % filename_root.lower()), 'generate_UCD_property_functions.py')
    114         cformat.write_imports(f, ['"pablo/pablo_compiler.h"'])
    115         f.write(Unicode_pablo_template)
     120        hf = cformat.open_header_file_for_write(os.path.basename("precompiled_%s" % filename_root.lower()), 'generate_UCD_property_functions.py')
     121        cformat.write_imports(hf, ['"pablo/pablo_compiler.h"'])
     122        hf.write(install_fn_header % filename_root)
     123        cformat.close_header_file(hf)
     124        tf = cformat.open_cpp_file_for_write(os.path.basename("precompiled_%s" % filename_root.lower()), 'generate_UCD_property_functions.py')
     125        cformat.write_imports(tf, ['"icgrep.h"'])
     126        tf.write(Unicode_pablo_template)
    116127        for p in lprops:
    117             f.write(Unicode_property_fn_template.substitute({'property': p, 'value': 'Y'}))
     128            tf.write(Unicode_property_fn_template.substitute({'property': p, 'value': 'Y'}))
    118129        install_stmt = "  p.InstallExternalFunction(\"__get_%s_Y\", (void *) & __get_%s_Y);\n"
    119130        install_list = [install_stmt % (p, p) for p in lprops]
    120         f.write(install_fn % (filename_root, "".join(install_list)))
    121         cformat.close_header_file(f)
     131        tf.write(install_fn % (filename_root, "".join(install_list)))
     132        cformat.close_cpp_file(tf)
    122133       
    123134    def generate_binary_properties_file(self, filename_root):
     
    145156    #
    146157    # The Block property
    147     ucd.generate_enumerated_property_template('Blocks', 'blk')
     158    ucd.generate_enumerated_property_header_and_template('Blocks', 'blk')
    148159    ucd.generate_enumerated_property_file('Blocks', 'blk')
    149160    #
    150161    # Scripts
    151     ucd.generate_enumerated_property_template('Scripts', 'sc')
     162    ucd.generate_enumerated_property_header_and_template('Scripts', 'sc')
    152163    ucd.generate_enumerated_property_file('Scripts', 'sc')
    153164    #
    154165    # Script Extensions
    155     ucd.generate_enumerated_property_template('ScriptExtensions', 'scx')
     166    ucd.generate_enumerated_property_header_and_template('ScriptExtensions', 'scx')
    156167    ucd.generate_ScriptExtensions_pablo()
    157168    #
    158169    # General Category
    159     ucd.generate_enumerated_property_template('GeneralCategory', 'gc')
     170    ucd.generate_enumerated_property_header_and_template('GeneralCategory', 'gc')
    160171    ucd.generate_enumerated_property_file('extracted/DerivedGeneralCategory', 'gc')
    161172    #
    162173    # Core Properties
    163     ucd.generate_binary_property_template('DerivedCoreProperties')
     174    ucd.generate_binary_property_header_and_template('DerivedCoreProperties')
    164175    ucd.generate_binary_properties_file('DerivedCoreProperties')
    165176    #
    166     ucd.generate_binary_property_template('PropList')
     177    ucd.generate_binary_property_header_and_template('PropList')
    167178    ucd.generate_binary_properties_file('PropList')
    168179
Note: See TracChangeset for help on using the changeset viewer.