MCPcopy Create free account
hub / github.com/alibaba/MNN / write_hpp

Function write_hpp

tools/script/gen_unicode_data.py:89–115  ·  view source on GitHub ↗
(out_dir)

Source from the content-addressed store, hash-verified

87
88
89def write_hpp(out_dir):
90 path = os.path.join(out_dir, "unicode_data.hpp")
91 with open(path, 'w') as f:
92 f.write("// Auto-generated by gen_unicode_data.py - DO NOT EDIT\n")
93 f.write("#ifndef UNICODE_DATA_HPP\n")
94 f.write("#define UNICODE_DATA_HPP\n\n")
95 f.write("#include <cstdint>\n")
96 f.write("#include <cstddef>\n\n")
97 f.write("namespace MNN {\nnamespace Unicode {\n\n")
98
99 f.write("enum Category : uint8_t {\n")
100 for i, c in enumerate(CATEGORIES):
101 f.write(f" CAT_{c} = {i},\n")
102 f.write(f" CAT_COUNT = {len(CATEGORIES)}\n")
103 f.write("};\n\n")
104
105 f.write("struct CategoryRange {\n uint32_t start;\n uint32_t end;\n uint8_t category;\n};\n\n")
106 f.write("struct CaseMapping {\n uint32_t from;\n uint32_t to;\n};\n\n")
107
108 f.write("extern const CategoryRange kCategoryRanges[];\n")
109 f.write("extern const size_t kCategoryRangesSize;\n\n")
110 f.write("extern const CaseMapping kToLower[];\n")
111 f.write("extern const size_t kToLowerSize;\n\n")
112
113 f.write("} // namespace Unicode\n} // namespace MNN\n\n")
114 f.write("#endif // UNICODE_DATA_HPP\n")
115 print(f" wrote {path}")
116
117
118

Callers 1

mainFunction · 0.85

Calls 4

openFunction · 0.85
printFunction · 0.85
joinMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected