diff --git a/CodeGen/BMapBindings/ExpFctsLexer.g4 b/CodeGen/BMapBindings/ExpFctsLexer.g4 index a705b40..1a31e83 100644 --- a/CodeGen/BMapBindings/ExpFctsLexer.g4 +++ b/CodeGen/BMapBindings/ExpFctsLexer.g4 @@ -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' ; diff --git a/CodeGen/BMapBindings/ExtractBMapFctDecl.py b/CodeGen/BMapBindings/ExtractBMapFctDecl.py index 209c9f5..ec257f0 100644 --- a/CodeGen/BMapBindings/ExtractBMapFctDecl.py +++ b/CodeGen/BMapBindings/ExtractBMapFctDecl.py @@ -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') diff --git a/CodeGen/UniversalEncoding/EncodingTable.csv b/CodeGen/UniversalEncoding/EncodingTable.csv index ebfd1f6..ffe38df 100644 --- a/CodeGen/UniversalEncoding/EncodingTable.csv +++ b/CodeGen/UniversalEncoding/EncodingTable.csv @@ -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 diff --git a/CodeGen/UniversalEncoding/UniversalEncoding.py b/CodeGen/UniversalEncoding/UniversalEncoding.py index d2565d7..e3fe6ba 100644 --- a/CodeGen/UniversalEncoding/UniversalEncoding.py +++ b/CodeGen/UniversalEncoding/UniversalEncoding.py @@ -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) diff --git a/CodeGen/VectorGen/VxVectors.py b/CodeGen/VectorGen/VxVectors.py index a369c22..5d4a011 100644 --- a/CodeGen/VectorGen/VxVectors.py +++ b/CodeGen/VectorGen/VxVectors.py @@ -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', ))) diff --git a/LibCmo/CK2/CKFileOthers.cpp b/LibCmo/CK2/CKFileOthers.cpp index 95f7c76..1e6c978 100644 --- a/LibCmo/CK2/CKFileOthers.cpp +++ b/LibCmo/CK2/CKFileOthers.cpp @@ -323,12 +323,12 @@ namespace LibCmo::CK2 { CKFileVisitor::CKFileVisitor(CKFileReader* reader) : m_IsReader(true), m_Reader(reader), m_Writer(nullptr), m_Ctx(reader->m_Ctx) { - if (reader == nullptr) LIBCMO_PANIC("Reader is nullptr."); + if (reader == nullptr) throw LogicException("Reader is nullptr."); } CKFileVisitor::CKFileVisitor(CKFileWriter* writer) : m_IsReader(false), m_Reader(nullptr), m_Writer(writer), m_Ctx(writer->m_Ctx) { - if (writer == nullptr) LIBCMO_PANIC("Writer is nullptr."); + if (writer == nullptr) throw LogicException("Writer is nullptr."); } CKFileVisitor::CKFileVisitor(const CKFileVisitor& rhs) : diff --git a/LibCmo/CK2/CKStateChunk.hpp b/LibCmo/CK2/CKStateChunk.hpp index 2cd1f18..8b037ac 100644 --- a/LibCmo/CK2/CKStateChunk.hpp +++ b/LibCmo/CK2/CKStateChunk.hpp @@ -56,7 +56,7 @@ namespace LibCmo::CK2 { m_Host(host), m_ConsumedSize(init_size) {} YYCC_DEF_CLS_COPY_MOVE(LockedReadBufferDeleter); - void operator()(LIBCMO_UNUSED const void* buf); + void operator()(const void* /*buf*/); void SetConsumedSize(CKDWORD newsize); private: CKStateChunk* m_Host; @@ -70,7 +70,7 @@ namespace LibCmo::CK2 { m_Host(host), m_ConsumedSize(init_size) {} YYCC_DEF_CLS_COPY_MOVE(LockedWriteBufferDeleter); - void operator()(LIBCMO_UNUSED const void* buf); + void operator()(const void* /*buf*/); void SetConsumedSize(CKDWORD newsize); private: CKStateChunk* m_Host; diff --git a/LibCmo/CK2/CKStateChunkOthers.cpp b/LibCmo/CK2/CKStateChunkOthers.cpp index f588371..d68dc18 100644 --- a/LibCmo/CK2/CKStateChunkOthers.cpp +++ b/LibCmo/CK2/CKStateChunkOthers.cpp @@ -101,7 +101,7 @@ namespace LibCmo::CK2 { #pragma region Self Used Data Struct - void CKStateChunk::LockedReadBufferDeleter::operator()(LIBCMO_UNUSED const void* buf) { + void CKStateChunk::LockedReadBufferDeleter::operator()(const void* /*buf*/) { if (m_Host == nullptr) return; m_Host->UnLockReadBuffer(m_ConsumedSize); } @@ -110,7 +110,7 @@ namespace LibCmo::CK2 { m_ConsumedSize = newsize; } - void CKStateChunk::LockedWriteBufferDeleter::operator()(LIBCMO_UNUSED const void* buf) { + void CKStateChunk::LockedWriteBufferDeleter::operator()(const void* /*buf*/) { if (m_Host == nullptr) return; m_Host->UnLockWriteBuffer(m_ConsumedSize); } diff --git a/LibCmo/CK2/MgrImpls/CKBaseManager.hpp b/LibCmo/CK2/MgrImpls/CKBaseManager.hpp index 15a2b1f..c4c526c 100644 --- a/LibCmo/CK2/MgrImpls/CKBaseManager.hpp +++ b/LibCmo/CK2/MgrImpls/CKBaseManager.hpp @@ -90,7 +90,7 @@ namespace LibCmo::CK2::MgrImpls { data for your manager. @see CKStateChunk, LoadData */ - virtual bool SaveData(LIBCMO_UNUSED CKStateChunk* chunk, LIBCMO_UNUSED CKFileVisitor* SavedFile) { + virtual bool SaveData([[maybe_unused]] CKStateChunk* chunk, [[maybe_unused]] CKFileVisitor* SavedFile) { return false; // default value is false to indicate this manager do not need save any data. } /** @@ -102,7 +102,7 @@ namespace LibCmo::CK2::MgrImpls { + During a load operation, each manager is automatically called if there was a chunk saved in the file with SaveData. @see CKStateChunk, SaveData */ - virtual CKERROR LoadData(LIBCMO_UNUSED CKStateChunk* chunk, LIBCMO_UNUSED CKFileVisitor* LoadedFile) { + virtual CKERROR LoadData([[maybe_unused]] CKStateChunk* chunk, [[maybe_unused]] CKFileVisitor* LoadedFile) { return CKERROR::CKERR_OK; } @@ -138,7 +138,7 @@ namespace LibCmo::CK2::MgrImpls { CKMANAGER_FUNC_OnSequenceToBeDeleted for this function to get called. @see Main Virtools Events, CKContext::DestroyObjects, SequenceDeleted */ - virtual CKERROR SequenceToBeDeleted(LIBCMO_UNUSED const CK_ID* objids, LIBCMO_UNUSED CKDWORD count) { return CKERROR::CKERR_OK; } + virtual CKERROR SequenceToBeDeleted([[maybe_unused]] const CK_ID* objids, [[maybe_unused]] CKDWORD count) { return CKERROR::CKERR_OK; } /** @brief Called after objects have been deleted. @return CK_OK if successful or an error code otherwise. @@ -150,7 +150,7 @@ namespace LibCmo::CK2::MgrImpls { CKMANAGER_FUNC_OnSequenceDeleted for this function to get called. @see Main Virtools Events, CKContext::DestroyObjects, SequenceToBeDeleted */ - virtual CKERROR SequenceDeleted(LIBCMO_UNUSED const CK_ID* objids, LIBCMO_UNUSED CKDWORD count) { return CKERROR::CKERR_OK; } + virtual CKERROR SequenceDeleted([[maybe_unused]] const CK_ID* objids, [[maybe_unused]] CKDWORD count) { return CKERROR::CKERR_OK; } protected: diff --git a/LibCmo/CMakeLists.txt b/LibCmo/CMakeLists.txt index fe5e9ff..a078e56 100644 --- a/LibCmo/CMakeLists.txt +++ b/LibCmo/CMakeLists.txt @@ -87,7 +87,7 @@ PUBLIC "$" "$" PRIVATE - YYCC::YYCCommonplace + YYCC::YYCCommonplace ZLIB::ZLIB stb::stb-image $<$>:Iconv::Iconv> @@ -108,7 +108,7 @@ PROPERTIES CXX_EXTENSION OFF ) target_compile_definitions(LibCmo -# LibCmo build type +# Expose LibCmo build type PUBLIC "$<$:LIBCMO_BUILD_DEBUG>" "$<$:LIBCMO_BUILD_RELEASE>" diff --git a/LibCmo/VTEncoding.cpp b/LibCmo/VTEncoding.cpp index a65045a..e10878d 100644 --- a/LibCmo/VTEncoding.cpp +++ b/LibCmo/VTEncoding.cpp @@ -216,6 +216,7 @@ namespace LibCmo::EncodingHelper { { u8"u8", u8"utf_8" }, { u8"utf", u8"utf_8" }, { u8"utf8", u8"utf_8" }, + { u8"utf-8", u8"utf_8" }, { u8"cp65001", u8"utf_8" }, }; @@ -235,8 +236,9 @@ namespace LibCmo::EncodingHelper { } #if YYCC_OS == YYCC_OS_WINDOWS - - static const std::map c_WinCPMap { + + static const std::map c_WinCPMap { + { u8"ascii", static_cast(437u) }, { u8"big5", static_cast(950u) }, { u8"cp037", static_cast(037u) }, { u8"cp437", static_cast(437u) }, @@ -273,10 +275,13 @@ namespace LibCmo::EncodingHelper { { u8"cp1256", static_cast(1256u) }, { u8"cp1257", static_cast(1257u) }, { u8"cp1258", static_cast(1258u) }, + { u8"euc_jp", static_cast(20932u) }, { u8"euc_kr", static_cast(51949u) }, + { u8"gb2312", static_cast(936u) }, { u8"gbk", static_cast(936u) }, { u8"gb18030", static_cast(54936u) }, { u8"hz", static_cast(52936u) }, + { u8"iso2022_jp", static_cast(50220u) }, { u8"iso2022_kr", static_cast(50225u) }, { u8"latin_1", static_cast(28591u) }, { u8"iso8859_2", static_cast(28592u) }, @@ -312,7 +317,7 @@ namespace LibCmo::EncodingHelper { } #else - + static const std::map c_IconvMap { { u8"ascii", "ASCII" }, { u8"big5", "BIG5" }, @@ -335,7 +340,8 @@ namespace LibCmo::EncodingHelper { { u8"cp1258", "CP1258" }, { u8"euc_jp", "EUC-JP" }, { u8"euc_kr", "EUC-KR" }, - { u8"gbk", "CP936" }, + { u8"gb2312", "CP936" }, + { u8"gbk", "GBK" }, { u8"gb18030", "GB18030" }, { u8"hz", "HZ" }, { u8"iso2022_jp", "ISO-2022-JP" }, diff --git a/LibCmo/VxMath/VxTypes.hpp b/LibCmo/VxMath/VxTypes.hpp index 8d93c92..0242858 100644 --- a/LibCmo/VxMath/VxTypes.hpp +++ b/LibCmo/VxMath/VxTypes.hpp @@ -290,7 +290,7 @@ namespace LibCmo::VxMath { struct VxQuaternion { CKFLOAT x, y, z, w; - VxQuaternion() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) {} // set your custom init. + VxQuaternion() : x(0.0f), y(0.0f), z(0.0f), w(1.0f) {} // set your custom init. VxQuaternion(CKFLOAT _x, CKFLOAT _y, CKFLOAT _z, CKFLOAT _w) : x(_x), y(_y), z(_z), w(_w) {} YYCC_DEF_CLS_COPY_MOVE(VxQuaternion); CKFLOAT& operator[](size_t i) { @@ -318,7 +318,7 @@ namespace LibCmo::VxMath { struct VxColor { CKFLOAT r, g, b, a; - VxColor() : r(0.0f), g(0.0f), b(0.0f), a(0.0f) {} // set your custom init. + VxColor() : r(0.0f), g(0.0f), b(0.0f), a(1.0f) {} // set your custom init. VxColor(CKFLOAT _r, CKFLOAT _g, CKFLOAT _b, CKFLOAT _a) : r(_r), g(_g), b(_b), a(_a) {} VxColor(CKDWORD argb) { FromARGB(argb); } YYCC_DEF_CLS_COPY_MOVE(VxColor);