source: icGREP/icgrep-devel/UCD-scripts/UnicodeNameData.py @ 5653

Last change on this file since 5653 was 5642, checked in by cameron, 22 months ago

Minor updates to UCD generation for consistency with manual edits

File size: 1.0 KB
Line 
1#
2# UnicodeNameData.py
3#
4# Robert D. Cameron
5# March 2, 2016
6#
7# Licensed under Open Software License 3.0.
8#
9#
10import re, string, os.path, cformat
11import UCD_config
12from UCD_parser import *
13
14
15UnicodeNameData_cpp_template = r"""
16#include "UnicodeNameData.h"
17const int Unamesize = %s;
18char __attribute__ ((aligned (32))) Unamedata[Unamesize + %s] = "%s";
19
20char * getUnicodeNameDataPtr() {
21  return Unamedata;
22}
23int getUnicodeNameDataSize() {
24  return Unamesize-1;
25}
26"""
27
28
29def genUnicodeNameData():
30    parsed_data = parse_UnicodeData_txt()
31    name_data_string = ""
32    name_data_len = 0
33    for record in parsed_data:
34        (cp, name, gc, ccc, bidic, decomp, decval, digitval, numval, bidim, uc, lc, tc) = record
35        name_data_string += cp + ";" + name + "\\n"
36        name_data_len += len(cp) + len(name) + 2
37    f = open(UCD_config.UCD_output_dir + '/UnicodeNameData.cpp', 'w')
38    f.write(UnicodeNameData_cpp_template % (name_data_len + 1, 255 - (name_data_len % 256), name_data_string))
39    f.close()
40
41if __name__ == "__main__":
42  genUnicodeNameData()
Note: See TracBrowser for help on using the repository browser.