Changeset 4172 for proto


Ignore:
Timestamp:
Sep 13, 2014, 5:34:02 AM (5 years ago)
Author:
cameron
Message:

Fixes for PropertyAliases?.h PropertyValueAliases?.h

File:
1 edited

Legend:

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

    r4155 r4172  
    5757
    5858PropertyAliases_template = r"""
     59#include <unordered_map>
    5960namespace UCD {
    6061  enum property_t {
    6162%s
    6263  };
    63   const std::string[] property_full_name = {
     64  const std::string property_full_name[] = {
    6465%s
    6566  };
    66   const std::unordered_map<std::string, property> alias_map = {
     67  const std::unordered_map<std::string, property_t> alias_map = {
    6768%s
    6869  };
     
    8485   (property_enum_name_list, full_name_map, property_lookup_map) = parse_PropertyAlias_txt()
    8586   f = open('PropertyAliases.h', 'w')
    86    enum_text = multiline_join(property_enum_name_list, enums_per_line, ',')
     87   enum_text = multiline_join([e.lower() for e in property_enum_name_list], enums_per_line, ',')
    8788   full_name_text = multiline_join(['"%s"' % full_name_map[e] for e in property_enum_name_list], 2, ',')
    88    map_text = multiline_join(['{"%s", %s}' % (k, property_lookup_map[k]) for k in sorted(property_lookup_map.keys())], 2, ',')
     89   map_text = multiline_join(['{"%s", %s}' % (k, property_lookup_map[k].lower()) for k in sorted(property_lookup_map.keys())], 2, ',')
    8990   f.write(PropertyAliases_template % (enum_text, full_name_text, map_text))
    9091   f.close()
     
    156157
    157158PropertyValueAliases_template = r"""
     159#include <unordered_map>
    158160namespace UCD {
    159   enum %s_value_t {
    160 %s
    161   };
    162   const std::string[] %s_value_name = {
    163 %s
    164   };
    165   const std::unordered_map<std::string, property> %s_alias_map = {
    166 %s
    167   };
     161  namespace %s {
     162    enum value_t {
     163%s
     164    };
     165    const std::string value_name[] = {
     166%s
     167    };
     168    const std::unordered_map<std::string, value_t> alias_map = {
     169%s
     170    };
     171  }
    168172}
    169173"""
     
    177181       if property_value_list[p] == ['N', 'Y']: continue # skip boolean properties
    178182       if p == 'ccc':
    179          enum_text = multiline_join(["%s = %s" % (e, property_value_enum_integer[p][e]) for e in property_value_list['ccc']], 4, ',')
     183         enum_text = multiline_join(["%s = %s" % (e, property_value_enum_integer[p][e]) for e in property_value_list['ccc']], 4, ',', '', 6)
    180184       else: enum_text = multiline_join(property_value_list[p], 4, ',')
    181        full_name_text = multiline_join(['"%s"' % (property_value_full_name_map[p][e]) for e in property_value_list[p]], 2, ',')
    182        map_text = multiline_join(['{"%s", %s}' % (k, property_value_lookup_map[p][k]) for k in sorted(property_value_lookup_map[p].keys())], 2, ',')
    183        f.write(PropertyValueAliases_template % (p, enum_text, p, full_name_text, p, map_text))
     185       full_name_text = multiline_join(['"%s"' % (property_value_full_name_map[p][e]) for e in property_value_list[p]], 4, ',',  '', 6)
     186       map_text = multiline_join(['{"%s", %s}' % (k, property_value_lookup_map[p][k]) for k in sorted(property_value_lookup_map[p].keys())], 4, ',', '', 6)
     187       f.write(PropertyValueAliases_template % (p.upper(), enum_text, full_name_text, map_text))
    184188   f.close()
    185189   
Note: See TracChangeset for help on using the changeset viewer.