fix: fix issues

- fix BMapBindings generator due to the rename of LIBCMO_EXPORT -> BMAP_EXPORT.
- fix relative path issue in Python scripts within CodeGen.
- remove all references to LIBCMO_PANIC. use exception instead to tell user they are fool.
- basically finish universal encoding tables. add lost encoding name.
This commit is contained in:
2024-08-17 23:29:08 +08:00
parent e682a87d25
commit 9903b61cac
12 changed files with 49 additions and 29 deletions

View File

@ -1,7 +1,7 @@
lexer grammar ExpFctsLexer;
// keywords
EXPFCTS_EXPORT: 'LIBCMO_EXPORT' ;
EXPFCTS_EXPORT: 'BMAP_EXPORT' ;
EXPFCTS_FILE_DECL: 'BMPARAM_FILE_DECL' ;
EXPFCTS_MESHTRANS_DECL: 'BMPARAM_MESHTRANS_DECL' ;
EXPFCTS_OBJECT_DECL: 'BMPARAM_OBJECT_DECL' ;

View File

@ -9,7 +9,10 @@ with open(src_file, 'r', encoding='utf-8') as fsrc:
fulltext: str = fsrc.read()
# do findall and write into file
with open(dst_file, 'w', encoding='utf-8') as fdst:
for item in re.findall('^LIBCMO_EXPORT[^;]+;', fulltext, re.MULTILINE):
# We should not only match BMAP_EXPORT,
# because it may match the defination of BMAP_EXPORT.
# So we add a bool at head because all BMap functions return bool.
for item in re.findall('^BMAP_EXPORT[ \\t]+bool[ \\t]+[^;]+;', fulltext, re.MULTILINE):
fdst.write(item)
fdst.write('\n')

View File

@ -1,5 +1,5 @@
Encoding Alias Code Page Iconv Identifier
ascii 646, us-ascii ASCII
ascii 646, us-ascii 437 ASCII
big5 big5-tw, csbig5 950 BIG5
big5hkscs big5-hkscs, hkscs BIG5-HKSCS
cp037 IBM037, IBM039 037
@ -42,15 +42,15 @@ cp1255 windows-1255 1255 CP1255
cp1256 windows-1256 1256 CP1256
cp1257 windows-1257 1257 CP1257
cp1258 windows-1258 1258 CP1258
euc_jp eucjp, ujis, u-jis EUC-JP
euc_jp eucjp, ujis, u-jis 20932 EUC-JP
euc_jis_2004 jisx0213, eucjis2004
euc_jisx0213 eucjisx0213
euc_kr euckr, korean, ksc5601, ks_c-5601, ks_c-5601-1987, ksx1001, ks_x-1001 51949 EUC-KR
gb2312 chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, gb2312-80, iso-ir-58
gbk 936, cp936, ms936 936 CP936
gb2312 chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, gb2312-80, iso-ir-58 936 CP936
gbk 936, cp936, ms936 936 GBK
gb18030 gb18030-2000 54936 GB18030
hz hzgb, hz-gb, hz-gb-2312 52936 HZ
iso2022_jp csiso2022jp, iso2022jp, iso-2022-jp ISO-2022-JP
iso2022_jp csiso2022jp, iso2022jp, iso-2022-jp 50220 ISO-2022-JP
iso2022_jp_1 iso2022jp-1, iso-2022-jp-1 ISO-2022-JP-1
iso2022_jp_2 iso2022jp-2, iso-2022-jp-2 ISO-2022-JP-2
iso2022_jp_2004 iso2022jp-2004, iso-2022-jp-2004
@ -94,5 +94,5 @@ utf_16 U16, utf16 UTF16
utf_16_be UTF-16BE UTF-16BE
utf_16_le UTF-16LE UTF-16LE
utf_7 U7, unicode-1-1-utf-7 65000 UTF-7
utf_8 U8, UTF, utf8, cp65001 65001 UTF-8
utf_8 U8, UTF, utf8, utf-8, cp65001 65001 UTF-8
utf_8_sig

1 Encoding Alias Code Page Iconv Identifier
2 ascii 646, us-ascii 437 ASCII
3 big5 big5-tw, csbig5 950 BIG5
4 big5hkscs big5-hkscs, hkscs BIG5-HKSCS
5 cp037 IBM037, IBM039 037
42 cp1256 windows-1256 1256 CP1256
43 cp1257 windows-1257 1257 CP1257
44 cp1258 windows-1258 1258 CP1258
45 euc_jp eucjp, ujis, u-jis 20932 EUC-JP
46 euc_jis_2004 jisx0213, eucjis2004
47 euc_jisx0213 eucjisx0213
48 euc_kr euckr, korean, ksc5601, ks_c-5601, ks_c-5601-1987, ksx1001, ks_x-1001 51949 EUC-KR
49 gb2312 chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, gb2312-80, iso-ir-58 936 CP936
50 gbk 936, cp936, ms936 936 CP936 GBK
51 gb18030 gb18030-2000 54936 GB18030
52 hz hzgb, hz-gb, hz-gb-2312 52936 HZ
53 iso2022_jp csiso2022jp, iso2022jp, iso-2022-jp 50220 ISO-2022-JP
54 iso2022_jp_1 iso2022jp-1, iso-2022-jp-1 ISO-2022-JP-1
55 iso2022_jp_2 iso2022jp-2, iso-2022-jp-2 ISO-2022-JP-2
56 iso2022_jp_2004 iso2022jp-2004, iso-2022-jp-2004
94 utf_16_be UTF-16BE UTF-16BE
95 utf_16_le UTF-16LE UTF-16LE
96 utf_7 U7, unicode-1-1-utf-7 65000 UTF-7
97 utf_8 U8, UTF, utf8, cp65001 U8, UTF, utf8, utf-8, cp65001 65001 UTF-8
98 utf_8_sig

View File

@ -1,5 +1,6 @@
import typing
import io
import os
class LanguageToken:
m_Name: str
@ -48,8 +49,13 @@ def write_iconv_map(fs: io.TextIOWrapper, data: tuple[LanguageToken, ...]) -> No
fs.write('};\n')
if __name__ == '__main__':
with open('EncodingTable.csv', 'r', encoding='utf-8') as fr:
with open('UEncodingTable.cpp', 'w', encoding='utf-8') as fw:
# get file path
self_path: str = os.path.dirname(__file__)
csv_file: str = os.path.join(self_path, 'EncodingTable.csv')
cpp_file: str = os.path.join(self_path, 'EncodingTable.cpp')
# process files
with open(csv_file, 'r', encoding='utf-8') as fr:
with open(cpp_file, 'w', encoding='utf-8') as fw:
data = extract_data(fr)
token = extract_token(data)
write_alias_map(fw, token)

View File

@ -1,3 +1,4 @@
import os
def GetTmplDecl(svars: tuple[str]) -> str:
return f'CKFLOAT {", ".join(svars)};'
@ -151,7 +152,11 @@ struct {sname} {{
#{GetTmplOperAssignMove(sname, svars)}
if __name__ == '__main__':
with open('VxTypes.hpp', 'w', encoding='utf-8') as fs:
# get file path
self_path: str = os.path.dirname(__file__)
cpp_file: str = os.path.join(self_path, 'VxTypes.hpp')
# generate files
with open(cpp_file, 'w', encoding='utf-8') as fs:
fs.write(GetTmplVector('VxVector2', ('x', 'y', )))
fs.write(GetTmplVector('VxVector3', ('x', 'y', 'z', )))
fs.write(GetTmplVector('VxVector4', ('x', 'y', 'z', 'w', )))