Compare commits
26 Commits
v0.1.0
...
334580acdc
Author | SHA1 | Date | |
---|---|---|---|
334580acdc | |||
2ce5203ac7 | |||
5e5eed03f5 | |||
7c88b3614a | |||
8ef1c6e30a | |||
85ff80cbf7 | |||
65861143bf | |||
3735a202f3 | |||
34015d2d1c | |||
bd96f26cfd | |||
0db8007fcb | |||
88ce33c358 | |||
d74b4645f0 | |||
0447381896 | |||
1028aad155 | |||
a7c1028926 | |||
f7708c28e0 | |||
35d508b1b9 | |||
1483466211 | |||
9903b61cac | |||
e682a87d25 | |||
f870d4dde3 | |||
afa06339b2 | |||
da575e42f5 | |||
a2fb376231 | |||
8a1fc03965 |
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -1,2 +1,4 @@
|
|||||||
*.fods eol=lf
|
Doxyfile.in eol=lf
|
||||||
|
*.bat eol=crlf
|
||||||
|
*.sh eol=lf
|
||||||
|
*.fods eol=lf
|
||||||
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -5,9 +5,10 @@
|
|||||||
*.nms
|
*.nms
|
||||||
*.vmo
|
*.vmo
|
||||||
|
|
||||||
# Ignore temporary folders
|
# Ignore temporary Visual Studio files and folders
|
||||||
/out/
|
temp/
|
||||||
/temp/
|
out/
|
||||||
|
CMakeSettings.json
|
||||||
|
|
||||||
# -------------------- VSCode --------------------
|
# -------------------- VSCode --------------------
|
||||||
.vscode/
|
.vscode/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "BMExports.hpp"
|
#include "BMExports.hpp"
|
||||||
#include <IronPad.hpp>
|
#include <YYCCommonplace.hpp>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -54,8 +54,11 @@ _Ty CheckGeneralObject(BMap::BMFile* possible_bmfile, LibCmo::CK2::CK_ID possibl
|
|||||||
bool BMInit() {
|
bool BMInit() {
|
||||||
if (CheckInited()) return false;
|
if (CheckInited()) return false;
|
||||||
|
|
||||||
// register IronPad
|
// register exception handler if we are in Windows.
|
||||||
IronPad::IronPadRegister();
|
#if YYCC_OS == YYCC_OS_WINDOWS
|
||||||
|
YYCC::ExceptionHelper::Register();
|
||||||
|
#endif
|
||||||
|
|
||||||
// and startup CK environment
|
// and startup CK environment
|
||||||
LibCmo::CK2::CKStartUp();
|
LibCmo::CK2::CKStartUp();
|
||||||
|
|
||||||
@ -84,8 +87,11 @@ bool BMDispose() {
|
|||||||
|
|
||||||
// shutdown CK environment
|
// shutdown CK environment
|
||||||
LibCmo::CK2::CKShutdown();
|
LibCmo::CK2::CKShutdown();
|
||||||
// unregister iron pad
|
|
||||||
IronPad::IronPadUnregister();
|
// unregister exception handler if we are in Windows
|
||||||
|
#if YYCC_OS == YYCC_OS_WINDOWS
|
||||||
|
YYCC::ExceptionHelper::Unregister();
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -721,14 +727,14 @@ bool BMMaterial_SetZFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::
|
|||||||
|
|
||||||
#pragma region CKMesh
|
#pragma region CKMesh
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMesh_GetLitMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXMESH_LITMODE, out_mode)) {
|
bool BMMesh_GetLitMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXMESH_LITMODE, out_mode)) {
|
||||||
auto obj = CheckCKMesh(bmfile, objid);
|
auto obj = CheckCKMesh(bmfile, objid);
|
||||||
if (obj == nullptr) return false;
|
if (obj == nullptr) return false;
|
||||||
|
|
||||||
BMPARAM_OUT_ASSIGN(out_mode, obj->GetLitMode());
|
BMPARAM_OUT_ASSIGN(out_mode, obj->GetLitMode());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LIBCMO_EXPORT bool BMMesh_SetLitMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXMESH_LITMODE, mode)) {
|
bool BMMesh_SetLitMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXMESH_LITMODE, mode)) {
|
||||||
auto obj = CheckCKMesh(bmfile, objid);
|
auto obj = CheckCKMesh(bmfile, objid);
|
||||||
if (obj == nullptr) return false;
|
if (obj == nullptr) return false;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
All exported interface functions will always return a bool to indicate whether current operations is successful.
|
All exported interface functions will always return a bool to indicate whether current operations is successful.
|
||||||
The layout of interface functions' parameters is Essential Param -> Input Param -> Out Param.
|
The layout of interface functions' parameters is Essential Param -> Input Param -> Out Param.
|
||||||
A example is in there: `LIBCMO_EXPORT bool BMSomeFunc(BMPARAM_OBJECT_DECL, BMPARAM_IN(LibCmo::CK2::CK_ID, someobj), BMPARAM_OUT(LibCmo::CKSTRING, out_name));`
|
A example is in there: `BMAP_EXPORT bool BMSomeFunc(BMPARAM_OBJECT_DECL, BMPARAM_IN(LibCmo::CK2::CK_ID, someobj), BMPARAM_OUT(LibCmo::CKSTRING, out_name));`
|
||||||
First param is `BMPARAM_OBJECT_DECL`. It is essential param for this function. In this exmaple, it is the combination of BMFile* and CK_ID. If your provide invalid value for them, the function will failed immediately.
|
First param is `BMPARAM_OBJECT_DECL`. It is essential param for this function. In this exmaple, it is the combination of BMFile* and CK_ID. If your provide invalid value for them, the function will failed immediately.
|
||||||
Second param is `BMPARAM_IN(LibCmo::CK2::CK_ID, someobj)`. It declare this function accept a Object ID for underlying function calling.
|
Second param is `BMPARAM_IN(LibCmo::CK2::CK_ID, someobj)`. It declare this function accept a Object ID for underlying function calling.
|
||||||
Last param is `BMPARAM_OUT(LibCmo::CKSTRING, out_name)`. It is the return value of this function. Only will be filled when this function success.
|
Last param is `BMPARAM_OUT(LibCmo::CKSTRING, out_name)`. It is the return value of this function. Only will be filled when this function success.
|
||||||
@ -31,7 +31,46 @@ Each CK_ID also should be used with its corresponding BMFile*, because each BMfi
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ===== Interface Used Macro =====
|
#pragma region Macros for Exporting Functions
|
||||||
|
|
||||||
|
// Reference: https://stackoverflow.com/questions/2164827/explicitly-exporting-shared-library-functions-in-linux
|
||||||
|
// Generate macro for import and export respectively.
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
// Microsoft
|
||||||
|
#define BMAP_RAW_EXPORT __declspec(dllexport)
|
||||||
|
#define BMAP_RAW_IMPORT __declspec(dllimport)
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
// GCC
|
||||||
|
#define BMAP_RAW_EXPORT __attribute__((visibility("default")))
|
||||||
|
#define BMAP_RAW_IMPORT
|
||||||
|
#elif defined(__clang__)
|
||||||
|
// Clang
|
||||||
|
#define BMAP_RAW_EXPORT __attribute__((visibility("default")))
|
||||||
|
#define BMAP_RAW_IMPORT
|
||||||
|
#else
|
||||||
|
// Do nothing and hope for the best?
|
||||||
|
#define BMAP_RAW_EXPORT
|
||||||
|
#define BMAP_RAW_IMPORT
|
||||||
|
#pragma error "Unknown dynamic link import/export semantics."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Choosee import or export command according to special macro.
|
||||||
|
#if defined(BMAP_EXPORTING)
|
||||||
|
#define BMAP_NAKED_EXPORT BMAP_RAW_EXPORT
|
||||||
|
#else
|
||||||
|
#define BMAP_NAKED_EXPORT BMAP_RAW_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Create real export macro according to whether in C++ environment.
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define BMAP_EXPORT extern "C" BMAP_NAKED_EXPORT
|
||||||
|
#else
|
||||||
|
#define BMAP_EXPORT BMAP_NAKED_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Interface Used Macros
|
||||||
|
|
||||||
/** The first param used by BMFile function family */
|
/** The first param used by BMFile function family */
|
||||||
#define BMPARAM_FILE_DECL(_bmfile) BMap::BMFile* _bmfile
|
#define BMPARAM_FILE_DECL(_bmfile) BMap::BMFile* _bmfile
|
||||||
@ -61,16 +100,18 @@ bool some_interface_func(BMPARAM_OUT(Type_t, param_name)) {
|
|||||||
/** Visit value for out param in function body. */
|
/** Visit value for out param in function body. */
|
||||||
#define BMPARAM_OUT_VAL(_name) (*(_name))
|
#define BMPARAM_OUT_VAL(_name) (*(_name))
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Init / Dispose
|
#pragma region Init / Dispose
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMInit();
|
BMAP_EXPORT bool BMInit();
|
||||||
LIBCMO_EXPORT bool BMDispose();
|
BMAP_EXPORT bool BMDispose();
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region BMFile
|
#pragma region BMFile
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMFile_Load(
|
BMAP_EXPORT bool BMFile_Load(
|
||||||
BMPARAM_IN(LibCmo::CKSTRING, file_name),
|
BMPARAM_IN(LibCmo::CKSTRING, file_name),
|
||||||
BMPARAM_IN(LibCmo::CKSTRING, temp_folder),
|
BMPARAM_IN(LibCmo::CKSTRING, temp_folder),
|
||||||
BMPARAM_IN(LibCmo::CKSTRING, texture_folder),
|
BMPARAM_IN(LibCmo::CKSTRING, texture_folder),
|
||||||
@ -79,7 +120,7 @@ LIBCMO_EXPORT bool BMFile_Load(
|
|||||||
BMPARAM_IN(LibCmo::CKSTRING*, encodings),
|
BMPARAM_IN(LibCmo::CKSTRING*, encodings),
|
||||||
BMPARAM_OUT(BMap::BMFile*, out_file)
|
BMPARAM_OUT(BMap::BMFile*, out_file)
|
||||||
);
|
);
|
||||||
LIBCMO_EXPORT bool BMFile_Create(
|
BMAP_EXPORT bool BMFile_Create(
|
||||||
BMPARAM_IN(LibCmo::CKSTRING, temp_folder),
|
BMPARAM_IN(LibCmo::CKSTRING, temp_folder),
|
||||||
BMPARAM_IN(LibCmo::CKSTRING, texture_folder),
|
BMPARAM_IN(LibCmo::CKSTRING, texture_folder),
|
||||||
BMPARAM_IN(BMap::NakedOutputCallback, raw_callback),
|
BMPARAM_IN(BMap::NakedOutputCallback, raw_callback),
|
||||||
@ -87,170 +128,170 @@ LIBCMO_EXPORT bool BMFile_Create(
|
|||||||
BMPARAM_IN(LibCmo::CKSTRING*, encodings),
|
BMPARAM_IN(LibCmo::CKSTRING*, encodings),
|
||||||
BMPARAM_OUT(BMap::BMFile*, out_file)
|
BMPARAM_OUT(BMap::BMFile*, out_file)
|
||||||
);
|
);
|
||||||
LIBCMO_EXPORT bool BMFile_Save(
|
BMAP_EXPORT bool BMFile_Save(
|
||||||
BMPARAM_IN(BMap::BMFile*, map_file),
|
BMPARAM_IN(BMap::BMFile*, map_file),
|
||||||
BMPARAM_IN(LibCmo::CKSTRING, file_name),
|
BMPARAM_IN(LibCmo::CKSTRING, file_name),
|
||||||
BMPARAM_IN(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, texture_save_opt),
|
BMPARAM_IN(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, texture_save_opt),
|
||||||
BMPARAM_IN(bool, use_compress),
|
BMPARAM_IN(bool, use_compress),
|
||||||
BMPARAM_IN(LibCmo::CKINT, compreess_level)
|
BMPARAM_IN(LibCmo::CKINT, compreess_level)
|
||||||
);
|
);
|
||||||
LIBCMO_EXPORT bool BMFile_Free(
|
BMAP_EXPORT bool BMFile_Free(
|
||||||
BMPARAM_IN(BMap::BMFile*, map_file)
|
BMPARAM_IN(BMap::BMFile*, map_file)
|
||||||
);
|
);
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMFile_GetGroupCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
BMAP_EXPORT bool BMFile_GetGroupCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
LIBCMO_EXPORT bool BMFile_GetGroup(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_GetGroup(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
LIBCMO_EXPORT bool BMFile_CreateGroup(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_CreateGroup(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
LIBCMO_EXPORT bool BMFile_Get3dObjectCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
BMAP_EXPORT bool BMFile_Get3dObjectCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
LIBCMO_EXPORT bool BMFile_Get3dObject(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_Get3dObject(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
LIBCMO_EXPORT bool BMFile_Create3dObject(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_Create3dObject(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
LIBCMO_EXPORT bool BMFile_GetMeshCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
BMAP_EXPORT bool BMFile_GetMeshCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
LIBCMO_EXPORT bool BMFile_GetMesh(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_GetMesh(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
LIBCMO_EXPORT bool BMFile_CreateMesh(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_CreateMesh(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
LIBCMO_EXPORT bool BMFile_GetMaterialCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
BMAP_EXPORT bool BMFile_GetMaterialCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
LIBCMO_EXPORT bool BMFile_GetMaterial(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_GetMaterial(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
LIBCMO_EXPORT bool BMFile_CreateMaterial(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_CreateMaterial(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
LIBCMO_EXPORT bool BMFile_GetTextureCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
BMAP_EXPORT bool BMFile_GetTextureCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
LIBCMO_EXPORT bool BMFile_GetTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_GetTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
LIBCMO_EXPORT bool BMFile_CreateTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_CreateTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region BMMeshTransition
|
#pragma region BMMeshTransition
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_New(BMPARAM_OUT(BMap::BMMeshTransition*, out_trans));
|
BMAP_EXPORT bool BMMeshTrans_New(BMPARAM_OUT(BMap::BMMeshTransition*, out_trans));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_Delete(BMPARAM_IN(BMap::BMMeshTransition*, trans));
|
BMAP_EXPORT bool BMMeshTrans_Delete(BMPARAM_IN(BMap::BMMeshTransition*, trans));
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareVertexCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
|
BMAP_EXPORT bool BMMeshTrans_PrepareVertexCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareVertex(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem));
|
BMAP_EXPORT bool BMMeshTrans_PrepareVertex(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareNormalCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
|
BMAP_EXPORT bool BMMeshTrans_PrepareNormalCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareNormal(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem));
|
BMAP_EXPORT bool BMMeshTrans_PrepareNormal(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareUVCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
|
BMAP_EXPORT bool BMMeshTrans_PrepareUVCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareUV(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector2*, out_mem));
|
BMAP_EXPORT bool BMMeshTrans_PrepareUV(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector2*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareMtlSlotCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
|
BMAP_EXPORT bool BMMeshTrans_PrepareMtlSlotCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareMtlSlot(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CK2::CK_ID*, out_mem));
|
BMAP_EXPORT bool BMMeshTrans_PrepareMtlSlot(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CK2::CK_ID*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
|
BMAP_EXPORT bool BMMeshTrans_PrepareFaceCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceVertexIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
|
BMAP_EXPORT bool BMMeshTrans_PrepareFaceVertexIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceNormalIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
|
BMAP_EXPORT bool BMMeshTrans_PrepareFaceNormalIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceUVIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
|
BMAP_EXPORT bool BMMeshTrans_PrepareFaceUVIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceMtlSlot(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
|
BMAP_EXPORT bool BMMeshTrans_PrepareFaceMtlSlot(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMeshTrans_Parse(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(BMap::BMFile*, bmfile), BMPARAM_IN(LibCmo::CK2::CK_ID, objid));
|
BMAP_EXPORT bool BMMeshTrans_Parse(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(BMap::BMFile*, bmfile), BMPARAM_IN(LibCmo::CK2::CK_ID, objid));
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region CKObject
|
#pragma region CKObject
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMObject_GetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKSTRING, out_name));
|
BMAP_EXPORT bool BMObject_GetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKSTRING, out_name));
|
||||||
LIBCMO_EXPORT bool BMObject_SetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, name));
|
BMAP_EXPORT bool BMObject_SetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, name));
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region CKGroup
|
#pragma region CKGroup
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMGroup_AddObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, memberid));
|
BMAP_EXPORT bool BMGroup_AddObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, memberid));
|
||||||
LIBCMO_EXPORT bool BMGroup_GetObjectCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
BMAP_EXPORT bool BMGroup_GetObjectCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
LIBCMO_EXPORT bool BMGroup_GetObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, pos), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_objid));
|
BMAP_EXPORT bool BMGroup_GetObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, pos), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_objid));
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region CKTexture
|
#pragma region CKTexture
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMTexture_GetFileName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKSTRING, out_filename));
|
BMAP_EXPORT bool BMTexture_GetFileName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKSTRING, out_filename));
|
||||||
LIBCMO_EXPORT bool BMTexture_LoadImage(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, filename));
|
BMAP_EXPORT bool BMTexture_LoadImage(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, filename));
|
||||||
LIBCMO_EXPORT bool BMTexture_SaveImage(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, filename));
|
BMAP_EXPORT bool BMTexture_SaveImage(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, filename));
|
||||||
LIBCMO_EXPORT bool BMTexture_GetSaveOptions(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, out_saveopt));
|
BMAP_EXPORT bool BMTexture_GetSaveOptions(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, out_saveopt));
|
||||||
LIBCMO_EXPORT bool BMTexture_SetSaveOptions(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, saveopt));
|
BMAP_EXPORT bool BMTexture_SetSaveOptions(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, saveopt));
|
||||||
LIBCMO_EXPORT bool BMTexture_GetVideoFormat(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VX_PIXELFORMAT, out_vfmt));
|
BMAP_EXPORT bool BMTexture_GetVideoFormat(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VX_PIXELFORMAT, out_vfmt));
|
||||||
LIBCMO_EXPORT bool BMTexture_SetVideoFormat(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VX_PIXELFORMAT, vfmt));
|
BMAP_EXPORT bool BMTexture_SetVideoFormat(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VX_PIXELFORMAT, vfmt));
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region CKMaterial
|
#pragma region CKMaterial
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetDiffuse(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val));
|
BMAP_EXPORT bool BMMaterial_GetDiffuse(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetDiffuse(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col));
|
BMAP_EXPORT bool BMMaterial_SetDiffuse(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetAmbient(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val));
|
BMAP_EXPORT bool BMMaterial_GetAmbient(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetAmbient(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col));
|
BMAP_EXPORT bool BMMaterial_SetAmbient(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetSpecular(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val));
|
BMAP_EXPORT bool BMMaterial_GetSpecular(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetSpecular(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col));
|
BMAP_EXPORT bool BMMaterial_SetSpecular(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetEmissive(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val));
|
BMAP_EXPORT bool BMMaterial_GetEmissive(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetEmissive(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col));
|
BMAP_EXPORT bool BMMaterial_SetEmissive(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetSpecularPower(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val));
|
BMAP_EXPORT bool BMMaterial_GetSpecularPower(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetSpecularPower(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val));
|
BMAP_EXPORT bool BMMaterial_SetSpecularPower(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val));
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetTexture(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_texid));
|
BMAP_EXPORT bool BMMaterial_GetTexture(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_texid));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetTexture(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, texid));
|
BMAP_EXPORT bool BMMaterial_SetTexture(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, texid));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetTextureBorderColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_val));
|
BMAP_EXPORT bool BMMaterial_GetTextureBorderColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetTextureBorderColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, val));
|
BMAP_EXPORT bool BMMaterial_SetTextureBorderColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, val));
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetTextureBlendMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_BLENDMODE, out_val));
|
BMAP_EXPORT bool BMMaterial_GetTextureBlendMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_BLENDMODE, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetTextureBlendMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_BLENDMODE, val));
|
BMAP_EXPORT bool BMMaterial_SetTextureBlendMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_BLENDMODE, val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetTextureMinMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_FILTERMODE, out_val));
|
BMAP_EXPORT bool BMMaterial_GetTextureMinMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_FILTERMODE, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetTextureMinMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_FILTERMODE, val));
|
BMAP_EXPORT bool BMMaterial_SetTextureMinMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_FILTERMODE, val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetTextureMagMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_FILTERMODE, out_val));
|
BMAP_EXPORT bool BMMaterial_GetTextureMagMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_FILTERMODE, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetTextureMagMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_FILTERMODE, val));
|
BMAP_EXPORT bool BMMaterial_SetTextureMagMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_FILTERMODE, val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetTextureAddressMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_ADDRESSMODE, out_val));
|
BMAP_EXPORT bool BMMaterial_GetTextureAddressMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_ADDRESSMODE, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetTextureAddressMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_ADDRESSMODE, val));
|
BMAP_EXPORT bool BMMaterial_SetTextureAddressMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_ADDRESSMODE, val));
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetSourceBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXBLEND_MODE, out_val));
|
BMAP_EXPORT bool BMMaterial_GetSourceBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXBLEND_MODE, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetSourceBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXBLEND_MODE, val));
|
BMAP_EXPORT bool BMMaterial_SetSourceBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXBLEND_MODE, val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetDestBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXBLEND_MODE, out_val));
|
BMAP_EXPORT bool BMMaterial_GetDestBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXBLEND_MODE, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetDestBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXBLEND_MODE, val));
|
BMAP_EXPORT bool BMMaterial_SetDestBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXBLEND_MODE, val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetFillMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXFILL_MODE, out_val));
|
BMAP_EXPORT bool BMMaterial_GetFillMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXFILL_MODE, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetFillMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXFILL_MODE, val));
|
BMAP_EXPORT bool BMMaterial_SetFillMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXFILL_MODE, val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetShadeMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXSHADE_MODE, out_val));
|
BMAP_EXPORT bool BMMaterial_GetShadeMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXSHADE_MODE, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetShadeMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXSHADE_MODE, val));
|
BMAP_EXPORT bool BMMaterial_SetShadeMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXSHADE_MODE, val));
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetAlphaTestEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val));
|
BMAP_EXPORT bool BMMaterial_GetAlphaTestEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetAlphaTestEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled));
|
BMAP_EXPORT bool BMMaterial_SetAlphaTestEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetAlphaBlendEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val));
|
BMAP_EXPORT bool BMMaterial_GetAlphaBlendEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetAlphaBlendEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled));
|
BMAP_EXPORT bool BMMaterial_SetAlphaBlendEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetPerspectiveCorrectionEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val));
|
BMAP_EXPORT bool BMMaterial_GetPerspectiveCorrectionEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetPerspectiveCorrectionEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled));
|
BMAP_EXPORT bool BMMaterial_SetPerspectiveCorrectionEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetZWriteEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val));
|
BMAP_EXPORT bool BMMaterial_GetZWriteEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetZWriteEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled));
|
BMAP_EXPORT bool BMMaterial_SetZWriteEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetTwoSidedEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val));
|
BMAP_EXPORT bool BMMaterial_GetTwoSidedEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetTwoSidedEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled));
|
BMAP_EXPORT bool BMMaterial_SetTwoSidedEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled));
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetAlphaRef(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKBYTE, out_val));
|
BMAP_EXPORT bool BMMaterial_GetAlphaRef(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKBYTE, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetAlphaRef(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKBYTE, val));
|
BMAP_EXPORT bool BMMaterial_SetAlphaRef(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKBYTE, val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetAlphaFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXCMPFUNC, out_val));
|
BMAP_EXPORT bool BMMaterial_GetAlphaFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXCMPFUNC, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetAlphaFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXCMPFUNC, val));
|
BMAP_EXPORT bool BMMaterial_SetAlphaFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXCMPFUNC, val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_GetZFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXCMPFUNC, out_val));
|
BMAP_EXPORT bool BMMaterial_GetZFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXCMPFUNC, out_val));
|
||||||
LIBCMO_EXPORT bool BMMaterial_SetZFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXCMPFUNC, val));
|
BMAP_EXPORT bool BMMaterial_SetZFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXCMPFUNC, val));
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region CKMesh
|
#pragma region CKMesh
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMesh_GetLitMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXMESH_LITMODE, out_mode));
|
BMAP_EXPORT bool BMMesh_GetLitMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXMESH_LITMODE, out_mode));
|
||||||
LIBCMO_EXPORT bool BMMesh_SetLitMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXMESH_LITMODE, mode));
|
BMAP_EXPORT bool BMMesh_SetLitMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXMESH_LITMODE, mode));
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMesh_GetVertexCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
BMAP_EXPORT bool BMMesh_GetVertexCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
LIBCMO_EXPORT bool BMMesh_SetVertexCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, count));
|
BMAP_EXPORT bool BMMesh_SetVertexCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, count));
|
||||||
LIBCMO_EXPORT bool BMMesh_GetVertexPositions(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem));
|
BMAP_EXPORT bool BMMesh_GetVertexPositions(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMesh_GetVertexNormals(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem));
|
BMAP_EXPORT bool BMMesh_GetVertexNormals(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMesh_GetVertexUVs(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxVector2*, out_mem));
|
BMAP_EXPORT bool BMMesh_GetVertexUVs(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxVector2*, out_mem));
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMesh_GetFaceCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
BMAP_EXPORT bool BMMesh_GetFaceCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
LIBCMO_EXPORT bool BMMesh_SetFaceCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, count));
|
BMAP_EXPORT bool BMMesh_SetFaceCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, count));
|
||||||
LIBCMO_EXPORT bool BMMesh_GetFaceIndices(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKWORD*, out_mem));
|
BMAP_EXPORT bool BMMesh_GetFaceIndices(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKWORD*, out_mem));
|
||||||
LIBCMO_EXPORT bool BMMesh_GetFaceMaterialSlotIndexs(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKWORD*, out_mem));
|
BMAP_EXPORT bool BMMesh_GetFaceMaterialSlotIndexs(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKWORD*, out_mem));
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BMMesh_GetMaterialSlotCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
BMAP_EXPORT bool BMMesh_GetMaterialSlotCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
LIBCMO_EXPORT bool BMMesh_SetMaterialSlotCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, count));
|
BMAP_EXPORT bool BMMesh_SetMaterialSlotCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, count));
|
||||||
LIBCMO_EXPORT bool BMMesh_GetMaterialSlot(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, index), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_mtlid));
|
BMAP_EXPORT bool BMMesh_GetMaterialSlot(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, index), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_mtlid));
|
||||||
LIBCMO_EXPORT bool BMMesh_SetMaterialSlot(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, index), BMPARAM_IN(LibCmo::CK2::CK_ID, mtlid));
|
BMAP_EXPORT bool BMMesh_SetMaterialSlot(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, index), BMPARAM_IN(LibCmo::CK2::CK_ID, mtlid));
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region CK3dObject
|
#pragma region CK3dObject
|
||||||
|
|
||||||
LIBCMO_EXPORT bool BM3dObject_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxMatrix, out_mat));
|
BMAP_EXPORT bool BM3dObject_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxMatrix, out_mat));
|
||||||
LIBCMO_EXPORT bool BM3dObject_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxMatrix, mat));
|
BMAP_EXPORT bool BM3dObject_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxMatrix, mat));
|
||||||
LIBCMO_EXPORT bool BM3dObject_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_meshid));
|
BMAP_EXPORT bool BM3dObject_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_meshid));
|
||||||
LIBCMO_EXPORT bool BM3dObject_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, meshid));
|
BMAP_EXPORT bool BM3dObject_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, meshid));
|
||||||
LIBCMO_EXPORT bool BM3dObject_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_isVisible));
|
BMAP_EXPORT bool BM3dObject_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_isVisible));
|
||||||
LIBCMO_EXPORT bool BM3dObject_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, is_visible));
|
BMAP_EXPORT bool BM3dObject_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, is_visible));
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
@ -255,6 +255,7 @@ namespace BMap {
|
|||||||
cache.emplace_back(encodings[i]);
|
cache.emplace_back(encodings[i]);
|
||||||
}
|
}
|
||||||
m_Context->SetEncoding(cache);
|
m_Context->SetEncoding(cache);
|
||||||
|
m_IsInitError = m_IsInitError || !m_Context->IsValidEncoding();
|
||||||
|
|
||||||
// set default texture save mode is external
|
// set default texture save mode is external
|
||||||
m_Context->SetGlobalImagesSaveOptions(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_EXTERNAL);
|
m_Context->SetGlobalImagesSaveOptions(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_EXTERNAL);
|
||||||
@ -305,6 +306,8 @@ namespace BMap {
|
|||||||
case LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE:
|
case LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE:
|
||||||
m_ObjTextures.emplace_back(fileobj.CreatedObjectId);
|
m_ObjTextures.emplace_back(fileobj.CreatedObjectId);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break; // skip unknow objects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <VTUserAll.hpp>
|
#include <VTAll.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
@ -14,7 +14,7 @@ namespace BMap {
|
|||||||
public:
|
public:
|
||||||
BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, NakedOutputCallback raw_callback, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING* encodings, bool is_reader);
|
BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, NakedOutputCallback raw_callback, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING* encodings, bool is_reader);
|
||||||
~BMFile();
|
~BMFile();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(BMFile);
|
YYCC_DEL_CLS_COPY_MOVE(BMFile);
|
||||||
|
|
||||||
// ===== safe visit functions =====
|
// ===== safe visit functions =====
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ namespace BMap {
|
|||||||
public:
|
public:
|
||||||
BMMeshTransition();
|
BMMeshTransition();
|
||||||
~BMMeshTransition();
|
~BMMeshTransition();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(BMMeshTransition);
|
YYCC_DEL_CLS_COPY_MOVE(BMMeshTransition);
|
||||||
|
|
||||||
bool PrepareVertexCount(LibCmo::CKDWORD count);
|
bool PrepareVertexCount(LibCmo::CKDWORD count);
|
||||||
LibCmo::VxMath::VxVector3* PrepareVertex();
|
LibCmo::VxMath::VxVector3* PrepareVertex();
|
||||||
|
@ -1,188 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<VCProjectVersion>16.0</VCProjectVersion>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<ProjectGuid>{0f0a8b98-35d7-4b8e-af0a-041b1bd80fd2}</ProjectGuid>
|
|
||||||
<RootNamespace>BMap</RootNamespace>
|
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="Shared">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\LibRef.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\LibRef.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\LibRef.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\LibRef.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>LIBCMO_EXPORTING;LIBCMO_BUILD_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
<AdditionalIncludeDirectories>../LibCmo;../IronPad;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>zlibwapi.lib;LibCmo.lib;IronPad.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x86\ZlibDllReleaseWithoutAsm;$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SolutionDir)out\$(Platform)\$(Configuration)\IronPad;</AdditionalLibraryDirectories>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>LIBCMO_EXPORTING;LIBCMO_BUILD_RELEASE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
<AdditionalIncludeDirectories>../LibCmo;../IronPad;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>zlibwapi.lib;LibCmo.lib;IronPad.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x86\ZlibDllReleaseWithoutAsm;$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SolutionDir)out\$(Platform)\$(Configuration)\IronPad;</AdditionalLibraryDirectories>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>LIBCMO_EXPORTING;LIBCMO_BUILD_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
<AdditionalIncludeDirectories>../LibCmo;../IronPad;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>zlibwapi.lib;LibCmo.lib;IronPad.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x64\ZlibDllReleaseWithoutAsm;$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SolutionDir)out\$(Platform)\$(Configuration)\IronPad;</AdditionalLibraryDirectories>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>LIBCMO_EXPORTING;LIBCMO_BUILD_RELEASE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
<AdditionalIncludeDirectories>../LibCmo;../IronPad;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>zlibwapi.lib;LibCmo.lib;IronPad.lib;Dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>$(ZLIB_PATH)\contrib\vstudio\vc14\x64\ZlibDllReleaseWithoutAsm;$(SolutionDir)out\$(Platform)\$(Configuration)\LibCmo;$(SolutionDir)out\$(Platform)\$(Configuration)\IronPad;</AdditionalLibraryDirectories>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="BMap.hpp" />
|
|
||||||
<ClInclude Include="BMExports.hpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="BMap.cpp" />
|
|
||||||
<ClCompile Include="BMExports.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Sources">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Headers">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resources">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="BMap.hpp">
|
|
||||||
<Filter>Headers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="BMExports.hpp">
|
|
||||||
<Filter>Headers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="BMap.cpp">
|
|
||||||
<Filter>Sources</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="BMExports.cpp">
|
|
||||||
<Filter>Sources</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -1,65 +1,57 @@
|
|||||||
cmake_minimum_required(VERSION 3.12)
|
# Create shared library
|
||||||
project(BMap LANGUAGES CXX)
|
add_library(BMap SHARED "")
|
||||||
|
# Setup sources
|
||||||
# add libcmo if not existed
|
target_sources(BMap
|
||||||
if (NOT TARGET LibCmo)
|
|
||||||
add_subdirectory("../LibCmo" "LibCmo.out")
|
|
||||||
endif ()
|
|
||||||
# add ironpad if not existed
|
|
||||||
if (NOT TARGET IronPad)
|
|
||||||
add_subdirectory("../IronPad" "IronPad.out")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# hide all function in default
|
|
||||||
# fix imported library PIC issue (i don't know why. just make it works)
|
|
||||||
set_target_properties(LibCmo
|
|
||||||
PROPERTIES
|
|
||||||
CXX_VISIBILITY_PRESET hidden
|
|
||||||
POSITION_INDEPENDENT_CODE ON
|
|
||||||
)
|
|
||||||
set_target_properties(IronPad
|
|
||||||
PROPERTIES
|
|
||||||
CXX_VISIBILITY_PRESET hidden
|
|
||||||
POSITION_INDEPENDENT_CODE ON
|
|
||||||
)
|
|
||||||
|
|
||||||
# setup sources
|
|
||||||
set(bmap_headers ".")
|
|
||||||
set(bmap_sources
|
|
||||||
BMap.cpp
|
|
||||||
BMExports.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# generate shared library
|
|
||||||
add_library(BMap
|
|
||||||
SHARED
|
|
||||||
${bmap_sources}
|
|
||||||
)
|
|
||||||
target_link_libraries(BMap
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
LibCmo
|
BMap.cpp
|
||||||
IronPad
|
BMExports.cpp
|
||||||
)
|
)
|
||||||
|
# Setup headers
|
||||||
|
target_sources(BMap
|
||||||
|
PRIVATE
|
||||||
|
FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
BMap.hpp
|
||||||
|
BMExports.hpp
|
||||||
|
)
|
||||||
|
# Setup header infomation
|
||||||
target_include_directories(BMap
|
target_include_directories(BMap
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${bmap_headers}
|
"${CMAKE_CURRENT_LIST_DIR}"
|
||||||
|
YYCC::YYCCommonplace
|
||||||
|
LibCmo
|
||||||
)
|
)
|
||||||
|
# Setup linked library infomation
|
||||||
# set project standard
|
target_link_libraries(BMap
|
||||||
|
PRIVATE
|
||||||
|
YYCC::YYCCommonplace
|
||||||
|
LibCmo
|
||||||
|
)
|
||||||
|
# Setup C++ standard
|
||||||
set_target_properties(BMap
|
set_target_properties(BMap
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
CXX_STANDARD 20
|
CXX_STANDARD 20
|
||||||
CXX_STANDARD_REQUIRED 20
|
CXX_STANDARD_REQUIRED 20
|
||||||
CXX_EXTENSION OFF
|
CXX_EXTENSION OFF
|
||||||
)
|
)
|
||||||
# set default visibility to hidden
|
# Setup project macros
|
||||||
set_target_properties(BMap
|
|
||||||
PROPERTIES
|
|
||||||
CXX_VISIBILITY_PRESET hidden
|
|
||||||
)
|
|
||||||
# add export used macro flag
|
|
||||||
target_compile_definitions(BMap
|
target_compile_definitions(BMap
|
||||||
PUBLIC
|
# Enable export macro
|
||||||
LIBCMO_EXPORTING
|
PRIVATE
|
||||||
|
BMAP_EXPORTING
|
||||||
|
# Order Unicode charset for private using
|
||||||
|
PRIVATE
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:UNICODE>
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:_UNICODE>
|
||||||
|
)
|
||||||
|
# Order build as UTF-8 in MSVC
|
||||||
|
target_compile_options(BMap
|
||||||
|
PRIVATE
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Install BMap only on Release mode
|
||||||
|
install(TARGETS BMap
|
||||||
|
CONFIGURATIONS Release
|
||||||
|
RUNTIME DESTINATION ${YYCC_INSTALL_BIN_PATH}
|
||||||
|
)
|
||||||
|
398
BMapBindings/BMapSharp/.gitignore
vendored
Normal file
398
BMapBindings/BMapSharp/.gitignore
vendored
Normal file
@ -0,0 +1,398 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.tlog
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||||
|
*.vbp
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||||
|
*.dsw
|
||||||
|
*.dsp
|
||||||
|
|
||||||
|
# Visual Studio 6 technical files
|
||||||
|
*.ncb
|
||||||
|
*.aps
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# Visual Studio History (VSHistory) files
|
||||||
|
.vshistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
*.sln.iml
|
28
BMapBindings/BMapSharp/BMapSharp.sln
Normal file
28
BMapBindings/BMapSharp/BMapSharp.sln
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.0.31903.59
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMapSharp", "BMapSharp\BMapSharp.csproj", "{604F426A-EC91-4E17-BE58-74565B24946C}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMapSharpTestbench", "BMapSharpTestbench\BMapSharpTestbench.csproj", "{3490D77F-119B-48EF-AA0B-E715EBE80DAA}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{604F426A-EC91-4E17-BE58-74565B24946C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{604F426A-EC91-4E17-BE58-74565B24946C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{604F426A-EC91-4E17-BE58-74565B24946C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{604F426A-EC91-4E17-BE58-74565B24946C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3490D77F-119B-48EF-AA0B-E715EBE80DAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3490D77F-119B-48EF-AA0B-E715EBE80DAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3490D77F-119B-48EF-AA0B-E715EBE80DAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3490D77F-119B-48EF-AA0B-E715EBE80DAA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
364
BMapBindings/BMapSharp/BMapSharp/.editorconfig
Normal file
364
BMapBindings/BMapSharp/BMapSharp/.editorconfig
Normal file
@ -0,0 +1,364 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
# All files
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
|
||||||
|
# Xml files
|
||||||
|
[*.xml]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# C# files
|
||||||
|
[*.cs]
|
||||||
|
|
||||||
|
#### Core EditorConfig Options ####
|
||||||
|
|
||||||
|
# Indentation and spacing
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
|
|
||||||
|
# New line preferences
|
||||||
|
end_of_line = crlf
|
||||||
|
insert_final_newline = false
|
||||||
|
|
||||||
|
#### .NET Coding Conventions ####
|
||||||
|
[*.{cs,vb}]
|
||||||
|
|
||||||
|
# Organize usings
|
||||||
|
dotnet_separate_import_directive_groups = false
|
||||||
|
dotnet_sort_system_directives_first = false
|
||||||
|
file_header_template = unset
|
||||||
|
|
||||||
|
# this. and Me. preferences
|
||||||
|
dotnet_style_qualification_for_event = false:silent
|
||||||
|
dotnet_style_qualification_for_field = false:silent
|
||||||
|
dotnet_style_qualification_for_method = false:silent
|
||||||
|
dotnet_style_qualification_for_property = false:silent
|
||||||
|
|
||||||
|
# Language keywords vs BCL types preferences
|
||||||
|
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
|
||||||
|
dotnet_style_predefined_type_for_member_access = true:silent
|
||||||
|
|
||||||
|
# Parentheses preferences
|
||||||
|
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
|
||||||
|
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
|
||||||
|
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
|
||||||
|
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
|
||||||
|
|
||||||
|
# Modifier preferences
|
||||||
|
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
|
||||||
|
|
||||||
|
# Expression-level preferences
|
||||||
|
dotnet_style_coalesce_expression = true:suggestion
|
||||||
|
dotnet_style_collection_initializer = true:suggestion
|
||||||
|
dotnet_style_explicit_tuple_names = true:suggestion
|
||||||
|
dotnet_style_null_propagation = true:suggestion
|
||||||
|
dotnet_style_object_initializer = true:suggestion
|
||||||
|
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
||||||
|
dotnet_style_prefer_auto_properties = true:suggestion
|
||||||
|
dotnet_style_prefer_compound_assignment = true:suggestion
|
||||||
|
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
|
||||||
|
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
|
||||||
|
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
|
||||||
|
dotnet_style_prefer_inferred_tuple_names = true:suggestion
|
||||||
|
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
|
||||||
|
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
|
||||||
|
dotnet_style_prefer_simplified_interpolation = true:suggestion
|
||||||
|
|
||||||
|
# Field preferences
|
||||||
|
dotnet_style_readonly_field = true:warning
|
||||||
|
|
||||||
|
# Parameter preferences
|
||||||
|
dotnet_code_quality_unused_parameters = all:suggestion
|
||||||
|
|
||||||
|
# Suppression preferences
|
||||||
|
dotnet_remove_unnecessary_suppression_exclusions = none
|
||||||
|
|
||||||
|
#### C# Coding Conventions ####
|
||||||
|
[*.cs]
|
||||||
|
|
||||||
|
# var preferences
|
||||||
|
csharp_style_var_elsewhere = false:silent
|
||||||
|
csharp_style_var_for_built_in_types = false:silent
|
||||||
|
csharp_style_var_when_type_is_apparent = false:silent
|
||||||
|
|
||||||
|
# Expression-bodied members
|
||||||
|
csharp_style_expression_bodied_accessors = true:silent
|
||||||
|
csharp_style_expression_bodied_constructors = false:silent
|
||||||
|
csharp_style_expression_bodied_indexers = true:silent
|
||||||
|
csharp_style_expression_bodied_lambdas = true:suggestion
|
||||||
|
csharp_style_expression_bodied_local_functions = false:silent
|
||||||
|
csharp_style_expression_bodied_methods = false:silent
|
||||||
|
csharp_style_expression_bodied_operators = false:silent
|
||||||
|
csharp_style_expression_bodied_properties = true:silent
|
||||||
|
|
||||||
|
# Pattern matching preferences
|
||||||
|
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
|
||||||
|
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
|
||||||
|
csharp_style_prefer_not_pattern = true:suggestion
|
||||||
|
csharp_style_prefer_pattern_matching = true:silent
|
||||||
|
csharp_style_prefer_switch_expression = true:suggestion
|
||||||
|
|
||||||
|
# Null-checking preferences
|
||||||
|
csharp_style_conditional_delegate_call = true:suggestion
|
||||||
|
|
||||||
|
# Modifier preferences
|
||||||
|
csharp_prefer_static_local_function = true:warning
|
||||||
|
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
|
||||||
|
|
||||||
|
# Code-block preferences
|
||||||
|
csharp_prefer_braces = true:silent
|
||||||
|
csharp_prefer_simple_using_statement = true:suggestion
|
||||||
|
|
||||||
|
# Expression-level preferences
|
||||||
|
csharp_prefer_simple_default_expression = true:suggestion
|
||||||
|
csharp_style_deconstructed_variable_declaration = true:suggestion
|
||||||
|
csharp_style_inlined_variable_declaration = true:suggestion
|
||||||
|
csharp_style_pattern_local_over_anonymous_function = true:suggestion
|
||||||
|
csharp_style_prefer_index_operator = true:suggestion
|
||||||
|
csharp_style_prefer_range_operator = true:suggestion
|
||||||
|
csharp_style_throw_expression = true:suggestion
|
||||||
|
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
|
||||||
|
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
|
||||||
|
|
||||||
|
# 'using' directive preferences
|
||||||
|
csharp_using_directive_placement = outside_namespace:silent
|
||||||
|
|
||||||
|
#### C# Formatting Rules ####
|
||||||
|
|
||||||
|
# New line preferences
|
||||||
|
csharp_new_line_before_catch = false
|
||||||
|
csharp_new_line_before_else = false
|
||||||
|
csharp_new_line_before_finally = false
|
||||||
|
csharp_new_line_before_members_in_anonymous_types = true
|
||||||
|
csharp_new_line_before_members_in_object_initializers = true
|
||||||
|
csharp_new_line_before_open_brace = none
|
||||||
|
csharp_new_line_between_query_expression_clauses = true
|
||||||
|
|
||||||
|
# Indentation preferences
|
||||||
|
csharp_indent_block_contents = true
|
||||||
|
csharp_indent_braces = false
|
||||||
|
csharp_indent_case_contents = true
|
||||||
|
csharp_indent_case_contents_when_block = true
|
||||||
|
csharp_indent_labels = one_less_than_current
|
||||||
|
csharp_indent_switch_labels = true
|
||||||
|
|
||||||
|
# Space preferences
|
||||||
|
csharp_space_after_cast = false
|
||||||
|
csharp_space_after_colon_in_inheritance_clause = true
|
||||||
|
csharp_space_after_comma = true
|
||||||
|
csharp_space_after_dot = false
|
||||||
|
csharp_space_after_keywords_in_control_flow_statements = true
|
||||||
|
csharp_space_after_semicolon_in_for_statement = true
|
||||||
|
csharp_space_around_binary_operators = before_and_after
|
||||||
|
csharp_space_around_declaration_statements = false
|
||||||
|
csharp_space_before_colon_in_inheritance_clause = true
|
||||||
|
csharp_space_before_comma = false
|
||||||
|
csharp_space_before_dot = false
|
||||||
|
csharp_space_before_open_square_brackets = false
|
||||||
|
csharp_space_before_semicolon_in_for_statement = false
|
||||||
|
csharp_space_between_empty_square_brackets = false
|
||||||
|
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||||
|
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||||
|
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_parentheses = false
|
||||||
|
csharp_space_between_square_brackets = false
|
||||||
|
|
||||||
|
# Wrapping preferences
|
||||||
|
csharp_preserve_single_line_blocks = true
|
||||||
|
csharp_preserve_single_line_statements = true
|
||||||
|
|
||||||
|
#### Naming styles ####
|
||||||
|
[*.{cs,vb}]
|
||||||
|
|
||||||
|
# Naming rules
|
||||||
|
|
||||||
|
dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.symbols = types_and_namespaces
|
||||||
|
dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.interfaces_should_be_ipascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.interfaces_should_be_ipascalcase.symbols = interfaces
|
||||||
|
dotnet_naming_rule.interfaces_should_be_ipascalcase.style = ipascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.type_parameters_should_be_tpascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.type_parameters_should_be_tpascalcase.symbols = type_parameters
|
||||||
|
dotnet_naming_rule.type_parameters_should_be_tpascalcase.style = tpascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.methods_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.methods_should_be_pascalcase.symbols = methods
|
||||||
|
dotnet_naming_rule.methods_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.properties_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.properties_should_be_pascalcase.symbols = properties
|
||||||
|
dotnet_naming_rule.properties_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.events_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.events_should_be_pascalcase.symbols = events
|
||||||
|
dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables
|
||||||
|
dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.local_constants_should_be_camelcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.local_constants_should_be_camelcase.symbols = local_constants
|
||||||
|
dotnet_naming_rule.local_constants_should_be_camelcase.style = camelcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters
|
||||||
|
dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields
|
||||||
|
dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields
|
||||||
|
dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields
|
||||||
|
dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields
|
||||||
|
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields
|
||||||
|
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields
|
||||||
|
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields
|
||||||
|
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums
|
||||||
|
dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.local_functions_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.local_functions_should_be_pascalcase.symbols = local_functions
|
||||||
|
dotnet_naming_rule.local_functions_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.non_field_members_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.non_field_members_should_be_pascalcase.symbols = non_field_members
|
||||||
|
dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
# Symbol specifications
|
||||||
|
|
||||||
|
dotnet_naming_symbols.interfaces.applicable_kinds = interface
|
||||||
|
dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.interfaces.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.enums.applicable_kinds = enum
|
||||||
|
dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.enums.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.events.applicable_kinds = event
|
||||||
|
dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.events.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.methods.applicable_kinds = method
|
||||||
|
dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.methods.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.properties.applicable_kinds = property
|
||||||
|
dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.properties.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.public_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal
|
||||||
|
dotnet_naming_symbols.public_fields.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.private_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.private_fields.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.private_static_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.private_static_fields.required_modifiers = static
|
||||||
|
|
||||||
|
dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum
|
||||||
|
dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.types_and_namespaces.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
|
||||||
|
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.non_field_members.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.type_parameters.applicable_kinds = namespace
|
||||||
|
dotnet_naming_symbols.type_parameters.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.type_parameters.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.private_constant_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.private_constant_fields.required_modifiers = const
|
||||||
|
|
||||||
|
dotnet_naming_symbols.local_variables.applicable_kinds = local
|
||||||
|
dotnet_naming_symbols.local_variables.applicable_accessibilities = local
|
||||||
|
dotnet_naming_symbols.local_variables.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.local_constants.applicable_kinds = local
|
||||||
|
dotnet_naming_symbols.local_constants.applicable_accessibilities = local
|
||||||
|
dotnet_naming_symbols.local_constants.required_modifiers = const
|
||||||
|
|
||||||
|
dotnet_naming_symbols.parameters.applicable_kinds = parameter
|
||||||
|
dotnet_naming_symbols.parameters.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.parameters.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.public_constant_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal
|
||||||
|
dotnet_naming_symbols.public_constant_fields.required_modifiers = const
|
||||||
|
|
||||||
|
dotnet_naming_symbols.public_static_readonly_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.public_static_readonly_fields.applicable_accessibilities = public, internal
|
||||||
|
dotnet_naming_symbols.public_static_readonly_fields.required_modifiers = readonly, static
|
||||||
|
|
||||||
|
dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readonly, static
|
||||||
|
|
||||||
|
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
|
||||||
|
dotnet_naming_symbols.local_functions.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.local_functions.required_modifiers =
|
||||||
|
|
||||||
|
# Naming styles
|
||||||
|
|
||||||
|
dotnet_naming_style.pascalcase.required_prefix =
|
||||||
|
dotnet_naming_style.pascalcase.required_suffix =
|
||||||
|
dotnet_naming_style.pascalcase.word_separator =
|
||||||
|
dotnet_naming_style.pascalcase.capitalization = pascal_case
|
||||||
|
|
||||||
|
dotnet_naming_style.ipascalcase.required_prefix = I
|
||||||
|
dotnet_naming_style.ipascalcase.required_suffix =
|
||||||
|
dotnet_naming_style.ipascalcase.word_separator =
|
||||||
|
dotnet_naming_style.ipascalcase.capitalization = pascal_case
|
||||||
|
|
||||||
|
dotnet_naming_style.tpascalcase.required_prefix = T
|
||||||
|
dotnet_naming_style.tpascalcase.required_suffix =
|
||||||
|
dotnet_naming_style.tpascalcase.word_separator =
|
||||||
|
dotnet_naming_style.tpascalcase.capitalization = pascal_case
|
||||||
|
|
||||||
|
dotnet_naming_style._camelcase.required_prefix = _
|
||||||
|
dotnet_naming_style._camelcase.required_suffix =
|
||||||
|
dotnet_naming_style._camelcase.word_separator =
|
||||||
|
dotnet_naming_style._camelcase.capitalization = camel_case
|
||||||
|
|
||||||
|
dotnet_naming_style.camelcase.required_prefix =
|
||||||
|
dotnet_naming_style.camelcase.required_suffix =
|
||||||
|
dotnet_naming_style.camelcase.word_separator =
|
||||||
|
dotnet_naming_style.camelcase.capitalization = camel_case
|
||||||
|
|
||||||
|
dotnet_naming_style.s_camelcase.required_prefix = s_
|
||||||
|
dotnet_naming_style.s_camelcase.required_suffix =
|
||||||
|
dotnet_naming_style.s_camelcase.word_separator =
|
||||||
|
dotnet_naming_style.s_camelcase.capitalization = camel_case
|
||||||
|
|
1097
BMapBindings/BMapSharp/BMapSharp/BMap.cs
Normal file
1097
BMapBindings/BMapSharp/BMapSharp/BMap.cs
Normal file
File diff suppressed because it is too large
Load Diff
23
BMapBindings/BMapSharp/BMapSharp/BMapSharp.csproj
Normal file
23
BMapBindings/BMapSharp/BMapSharp/BMapSharp.csproj
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
|
||||||
|
<PackageId>BMapSharp</PackageId>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Authors>yyc12345</Authors>
|
||||||
|
<Company>BearKidsTeam</Company>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="$([System.OperatingSystem]::IsWindows())">
|
||||||
|
<DefineConstants>BMAP_OS_WINDOWS</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="$([System.OperatingSystem]::IsLinux()) Or $([System.OperatingSystem]::IsFreeBSD())">
|
||||||
|
<DefineConstants>BMAP_OS_LINUX</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="$([System.OperatingSystem]::IsMacOS())">
|
||||||
|
<DefineConstants>BMAP_OS_MACOS</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
266
BMapBindings/BMapSharp/BMapSharp/BMapWrapper.cs
Normal file
266
BMapBindings/BMapSharp/BMapSharp/BMapWrapper.cs
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using BMapSharp.VirtoolsTypes;
|
||||||
|
|
||||||
|
namespace BMapSharp.BMapWrapper {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The guard of native BMap environment.
|
||||||
|
/// This class initialize native BMap environment when constructing and free it when destructing.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class BMapGuard : SafeHandle {
|
||||||
|
private static readonly IntPtr MAGIC_HANDLE = (IntPtr)61;
|
||||||
|
internal BMapGuard() : base(Utils.INVALID_PTR, true) {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMInit());
|
||||||
|
this.handle = MAGIC_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsInvalid => this.handle == Utils.INVALID_PTR;
|
||||||
|
protected override bool ReleaseHandle() {
|
||||||
|
return BMap.BMDispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Utils {
|
||||||
|
/// <summary>The representation of invalid raw pointer.</summary>
|
||||||
|
internal static readonly IntPtr INVALID_PTR = IntPtr.Zero;
|
||||||
|
/// <summary>The representation of invalid CK_ID.</summary>
|
||||||
|
internal static readonly uint INVALID_CKID = 0u;
|
||||||
|
/// <summary>
|
||||||
|
/// The function used as callback for BMap.
|
||||||
|
/// It just writes the data in console.
|
||||||
|
/// </summary>
|
||||||
|
internal static void BMapSharpCallback(string msg) {
|
||||||
|
Console.WriteLine(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly BMapGuard Singleton = new BMapGuard();
|
||||||
|
public static bool IsBMapAvailable() {
|
||||||
|
return !Singleton.IsInvalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class AbstractPointer : SafeHandle {
|
||||||
|
internal AbstractPointer(IntPtr raw_pointer) : base(Utils.INVALID_PTR, true) {
|
||||||
|
this.handle = raw_pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsInvalid => this.handle == Utils.INVALID_PTR;
|
||||||
|
protected override bool ReleaseHandle() => throw new NotImplementedException();
|
||||||
|
|
||||||
|
protected bool isValid() => this.handle != Utils.INVALID_PTR;
|
||||||
|
protected IntPtr getPointer() => this.handle;
|
||||||
|
|
||||||
|
// protected AbstractPointer(IntPtr raw_pointer) : base(raw_pointer, true) {}
|
||||||
|
|
||||||
|
// protected IntPtr GetPointer() => this.handle;
|
||||||
|
// public override bool IsInvalid { get { return this.handle == Utils.INVALID_PTR; } }
|
||||||
|
|
||||||
|
// #region IComparable
|
||||||
|
|
||||||
|
// public int CompareTo(AbstractPointer other) {
|
||||||
|
// return m_RawPointer.CompareTo(other.m_RawPointer);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region IEquatable
|
||||||
|
|
||||||
|
// public override bool Equals(object obj) => this.Equals(obj as AbstractPointer);
|
||||||
|
// public bool Equals(AbstractPointer other) {
|
||||||
|
// if (other is null) return false;
|
||||||
|
// if (Object.ReferenceEquals(this, other)) return true;
|
||||||
|
// // if (this.GetType() != other.GetType()) return false;
|
||||||
|
// return this.m_RawPointer == other.m_RawPointer;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public static bool operator ==(AbstractPointer lhs, AbstractPointer rhs) {
|
||||||
|
// if (lhs is null) {
|
||||||
|
// if (rhs is null) return true;
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// return lhs.Equals(rhs);
|
||||||
|
// }
|
||||||
|
// public static bool operator !=(AbstractPointer lhs, AbstractPointer rhs) => !(lhs == rhs);
|
||||||
|
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
#region Misc
|
||||||
|
|
||||||
|
public override int GetHashCode() => this.handle.GetHashCode();
|
||||||
|
public override string ToString() => this.handle.ToString();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class AbstractCKObject {
|
||||||
|
internal AbstractCKObject(IntPtr raw_pointer, uint ckid) {
|
||||||
|
m_RawPointer = raw_pointer;
|
||||||
|
m_CKID = ckid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly IntPtr m_RawPointer;
|
||||||
|
private readonly uint m_CKID;
|
||||||
|
protected bool isValid() => m_RawPointer != Utils.INVALID_PTR && m_RawPointer != Utils.INVALID_CKID;
|
||||||
|
protected IntPtr getPointer() => m_RawPointer;
|
||||||
|
protected uint getCKID() => m_CKID;
|
||||||
|
|
||||||
|
// private uint m_CKID;
|
||||||
|
|
||||||
|
// protected AbstractCKObject(IntPtr raw_pointer, uint ckid) : base(raw_pointer) {
|
||||||
|
// m_CKID = ckid;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// protected override bool IsValid() => base.IsValid() && m_CKID != Utils.INVALID_CKID;
|
||||||
|
// protected uint GetCKID() => m_CKID;
|
||||||
|
|
||||||
|
// #region IComparable
|
||||||
|
|
||||||
|
// public int CompareTo(AbstractCKObject other) {
|
||||||
|
// var ret = base.CompareTo((AbstractPointer)other);
|
||||||
|
// if (ret != 0) return ret;
|
||||||
|
// return m_CKID.CompareTo(other.m_CKID);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region IEquatable
|
||||||
|
|
||||||
|
// public override bool Equals(object obj) => this.Equals(obj as AbstractCKObject);
|
||||||
|
// public bool Equals(AbstractCKObject other) {
|
||||||
|
// if (other is null) return false;
|
||||||
|
// if (Object.ReferenceEquals(this, other)) return true;
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public static bool operator ==(AbstractCKObject left, AbstractCKObject right) =>
|
||||||
|
// ((AbstractPointer)left == (AbstractPointer)right) && left.m_CKID == right.m_CKID;
|
||||||
|
// public static bool operator !=(AbstractCKObject left, AbstractCKObject right) =>
|
||||||
|
// ((AbstractPointer)left != (AbstractPointer)right) || left.m_CKID != right.m_CKID;
|
||||||
|
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
#region Misc
|
||||||
|
|
||||||
|
public override int GetHashCode() => HashCode.Combine(m_RawPointer, m_CKID);
|
||||||
|
public override string ToString() => $"{m_RawPointer}, {m_CKID}";
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BMObject : AbstractCKObject {
|
||||||
|
internal BMObject(nint raw_pointer, uint ckid) : base(raw_pointer, ckid) {}
|
||||||
|
|
||||||
|
public string GetName() {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMObject_GetName(
|
||||||
|
this.getPointer(), this.getCKID(), out string out_name
|
||||||
|
));
|
||||||
|
return out_name;
|
||||||
|
}
|
||||||
|
public void SetName(string name) {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMObject_SetName(
|
||||||
|
this.getPointer(), this.getCKID(), name
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BMTexture : BMObject {
|
||||||
|
internal BMTexture(nint raw_pointer, uint ckid) : base(raw_pointer, ckid) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BMMaterial : BMObject {
|
||||||
|
internal BMMaterial(nint raw_pointer, uint ckid) : base(raw_pointer, ckid) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BMMesh : BMObject {
|
||||||
|
internal BMMesh(nint raw_pointer, uint ckid) : base(raw_pointer, ckid) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BM3dObject : BMObject {
|
||||||
|
internal BM3dObject(nint raw_pointer, uint ckid) : base(raw_pointer, ckid) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BMGroup : BMObject {
|
||||||
|
internal BMGroup(nint raw_pointer, uint ckid) : base(raw_pointer, ckid) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class BMFileReader : AbstractPointer {
|
||||||
|
private static IntPtr AllocateHandle(string file_name, string temp_folder, string texture_folder, string[] encodings) {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_Load(
|
||||||
|
file_name, temp_folder, texture_folder,
|
||||||
|
Utils.BMapSharpCallback,
|
||||||
|
(uint)encodings.Length, encodings,
|
||||||
|
out IntPtr out_file
|
||||||
|
));
|
||||||
|
return out_file;
|
||||||
|
}
|
||||||
|
protected override bool ReleaseHandle() {
|
||||||
|
return BMap.BMFile_Free(this.handle);
|
||||||
|
}
|
||||||
|
public BMFileReader(string file_name, string temp_folder, string texture_folder, string[] encodings)
|
||||||
|
: base(AllocateHandle(file_name, temp_folder, texture_folder, encodings)) {}
|
||||||
|
|
||||||
|
public uint GetTextureCount() {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_GetTextureCount(this.getPointer(), out uint out_count));
|
||||||
|
return out_count;
|
||||||
|
}
|
||||||
|
public IEnumerable<BMTexture> GetTextures() {
|
||||||
|
uint count = GetTextureCount();
|
||||||
|
for (uint i = 0; i < count; ++i) {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_GetTexture(this.getPointer(), i, out uint out_id));
|
||||||
|
yield return new BMTexture(this.getPointer(), out_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint GetMaterialCount() {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_GetMaterialCount(this.getPointer(), out uint out_count));
|
||||||
|
return out_count;
|
||||||
|
}
|
||||||
|
public IEnumerable<BMMaterial> GetMaterials() {
|
||||||
|
uint count = GetMaterialCount();
|
||||||
|
for (uint i = 0; i < count; ++i) {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_GetMaterial(this.getPointer(), i, out uint out_id));
|
||||||
|
yield return new BMMaterial(this.getPointer(), out_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint GetMeshCount() {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_GetMeshCount(this.getPointer(), out uint out_count));
|
||||||
|
return out_count;
|
||||||
|
}
|
||||||
|
public IEnumerable<BMMesh> GetMeshs() {
|
||||||
|
uint count = GetMeshCount();
|
||||||
|
for (uint i = 0; i < count; ++i) {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_GetMesh(this.getPointer(), i, out uint out_id));
|
||||||
|
yield return new BMMesh(this.getPointer(), out_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Get3dObjectCount() {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_Get3dObjectCount(this.getPointer(), out uint out_count));
|
||||||
|
return out_count;
|
||||||
|
}
|
||||||
|
public IEnumerable<BM3dObject> Get3dObjects() {
|
||||||
|
uint count = Get3dObjectCount();
|
||||||
|
for (uint i = 0; i < count; ++i) {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_Get3dObject(this.getPointer(), i, out uint out_id));
|
||||||
|
yield return new BM3dObject(this.getPointer(), out_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint GetGroupCount() {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_GetGroupCount(this.getPointer(), out uint out_count));
|
||||||
|
return out_count;
|
||||||
|
}
|
||||||
|
public IEnumerable<BMGroup> GetGroups() {
|
||||||
|
uint count = GetGroupCount();
|
||||||
|
for (uint i = 0; i < count; ++i) {
|
||||||
|
BMapException.ThrowIfFailed(BMap.BMFile_GetGroup(this.getPointer(), i, out uint out_id));
|
||||||
|
yield return new BMGroup(this.getPointer(), out_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
287
BMapBindings/BMapSharp/BMapSharp/VirtoolsTypes.cs
Normal file
287
BMapBindings/BMapSharp/BMapSharp/VirtoolsTypes.cs
Normal file
@ -0,0 +1,287 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
|
namespace BMapSharp.VirtoolsTypes {
|
||||||
|
|
||||||
|
// NOTE: Structures defined in there is only served for marshaling.
|
||||||
|
// You should not use them in hash set or anything else,
|
||||||
|
// because they do not have proper hash function and compare function.
|
||||||
|
// You should use the managed type generated by them instead.
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
|
||||||
|
public struct VxVector2 {
|
||||||
|
[MarshalAs(UnmanagedType.R4)]
|
||||||
|
public float X, Y;
|
||||||
|
|
||||||
|
public VxVector2(float _x = 0.0f, float _y = 0.0f) {
|
||||||
|
X = _x;
|
||||||
|
Y = _y;
|
||||||
|
}
|
||||||
|
public void FromManaged(Vector2 vec) {
|
||||||
|
X = vec.X;
|
||||||
|
Y = vec.Y;
|
||||||
|
}
|
||||||
|
public Vector2 ToManaged() {
|
||||||
|
return new Vector2(X, Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
|
||||||
|
public struct VxVector3 {
|
||||||
|
[MarshalAs(UnmanagedType.R4)]
|
||||||
|
public float X, Y, Z;
|
||||||
|
|
||||||
|
public VxVector3(float _x = 0.0f, float _y = 0.0f, float _z = 0.0f) {
|
||||||
|
X = _x;
|
||||||
|
Y = _y;
|
||||||
|
Z = _z;
|
||||||
|
}
|
||||||
|
public void FromManaged(Vector3 vec) {
|
||||||
|
X = vec.X;
|
||||||
|
Y = vec.Y;
|
||||||
|
Z = vec.Z;
|
||||||
|
}
|
||||||
|
public Vector3 ToManaged() {
|
||||||
|
return new Vector3(X, Y, Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
|
||||||
|
public struct VxColor {
|
||||||
|
[MarshalAs(UnmanagedType.R4)]
|
||||||
|
public float A, R, G, B;
|
||||||
|
|
||||||
|
public VxColor(float _r, float _g, float _b, float _a) {
|
||||||
|
A = _a;
|
||||||
|
R = _r;
|
||||||
|
G = _g;
|
||||||
|
B = _b;
|
||||||
|
Regulate();
|
||||||
|
}
|
||||||
|
public void FromManagedRGBA(Vector4 col) {
|
||||||
|
R = col.X;
|
||||||
|
G = col.Y;
|
||||||
|
B = col.Z;
|
||||||
|
A = col.W;
|
||||||
|
Regulate();
|
||||||
|
}
|
||||||
|
public Vector4 ToManagedRGBA() {
|
||||||
|
return new Vector4(R, G, B, A);
|
||||||
|
}
|
||||||
|
public void FromManagedRGB(Vector3 col) {
|
||||||
|
R = col.X;
|
||||||
|
G = col.Y;
|
||||||
|
B = col.Z;
|
||||||
|
Regulate();
|
||||||
|
}
|
||||||
|
public Vector3 ToManagedRGB() {
|
||||||
|
return new Vector3(R, G, B);
|
||||||
|
}
|
||||||
|
public void FromDword(uint val) {
|
||||||
|
B = (val & 0xFFu) / 255.0f;
|
||||||
|
val >>= 8;
|
||||||
|
G = (val & 0xFFu) / 255.0f;
|
||||||
|
val >>= 8;
|
||||||
|
R = (val & 0xFFu) / 255.0f;
|
||||||
|
val >>= 8;
|
||||||
|
A = (val & 0xFFu) / 255.0f;
|
||||||
|
}
|
||||||
|
public uint ToDword() {
|
||||||
|
// regulate self first
|
||||||
|
Regulate();
|
||||||
|
// build result
|
||||||
|
uint val = 0u;
|
||||||
|
val |= (uint)(A * 255.0f);
|
||||||
|
val <<= 8;
|
||||||
|
val |= (uint)(R * 255.0f);
|
||||||
|
val <<= 8;
|
||||||
|
val |= (uint)(G * 255.0f);
|
||||||
|
val <<= 8;
|
||||||
|
val |= (uint)(B * 255.0f);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
public static float ClampFactor(float factor) {
|
||||||
|
return System.Math.Clamp(factor, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
public void Regulate() {
|
||||||
|
A = ClampFactor(A);
|
||||||
|
R = ClampFactor(R);
|
||||||
|
G = ClampFactor(G);
|
||||||
|
B = ClampFactor(B);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
|
||||||
|
public struct VxMatrix {
|
||||||
|
[MarshalAs(UnmanagedType.R4)]
|
||||||
|
public float M11, M12, M13, M14;
|
||||||
|
[MarshalAs(UnmanagedType.R4)]
|
||||||
|
public float M21, M22, M23, M24;
|
||||||
|
[MarshalAs(UnmanagedType.R4)]
|
||||||
|
public float M31, M32, M33, M34;
|
||||||
|
[MarshalAs(UnmanagedType.R4)]
|
||||||
|
public float M41, M42, M43, M44;
|
||||||
|
|
||||||
|
public VxMatrix(float m11 = 1.0f, float m12 = 0.0f, float m13 = 0.0f, float m14 = 0.0f,
|
||||||
|
float m21 = 0.0f, float m22 = 1.0f, float m23 = 0.0f, float m24 = 0.0f,
|
||||||
|
float m31 = 0.0f, float m32 = 0.0f, float m33 = 1.0f, float m34 = 0.0f,
|
||||||
|
float m41 = 0.0f, float m42 = 0.0f, float m43 = 0.0f, float m44 = 1.0f) {
|
||||||
|
M11 = m11; M12 = m12; M13 = m13; M14 = m14;
|
||||||
|
M21 = m21; M22 = m22; M23 = m23; M24 = m24;
|
||||||
|
M31 = m31; M32 = m32; M33 = m33; M34 = m34;
|
||||||
|
M41 = m41; M42 = m42; M43 = m43; M44 = m44;
|
||||||
|
}
|
||||||
|
public void Reset() {
|
||||||
|
M11 = 1.0f; M12 = 0.0f; M13 = 0.0f; M14 = 0.0f;
|
||||||
|
M21 = 0.0f; M22 = 1.0f; M23 = 0.0f; M24 = 0.0f;
|
||||||
|
M31 = 0.0f; M32 = 0.0f; M33 = 1.0f; M34 = 0.0f;
|
||||||
|
M41 = 0.0f; M42 = 0.0f; M43 = 0.0f; M44 = 1.0f;
|
||||||
|
}
|
||||||
|
public void FromManaged(Matrix4x4 mat) {
|
||||||
|
M11 = mat.M11; M12 = mat.M12; M13 = mat.M13; M14 = mat.M14;
|
||||||
|
M21 = mat.M21; M22 = mat.M22; M23 = mat.M23; M24 = mat.M24;
|
||||||
|
M31 = mat.M31; M32 = mat.M32; M33 = mat.M33; M34 = mat.M34;
|
||||||
|
M41 = mat.M41; M42 = mat.M42; M43 = mat.M43; M44 = mat.M44;
|
||||||
|
}
|
||||||
|
public Matrix4x4 ToManaged() {
|
||||||
|
return new Matrix4x4(
|
||||||
|
M11, M12, M13, M14,
|
||||||
|
M21, M22, M23, M24,
|
||||||
|
M31, M32, M33, M34,
|
||||||
|
M41, M42, M43, M44
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Ansi)]
|
||||||
|
public struct CKFaceIndices {
|
||||||
|
[MarshalAs(UnmanagedType.U4)]
|
||||||
|
public uint I1, I2, I3;
|
||||||
|
|
||||||
|
public CKFaceIndices(uint i1 = 0u, uint i2 = 0u, uint i3 = 0u) {
|
||||||
|
I1 = i1;
|
||||||
|
I2 = i2;
|
||||||
|
I3 = i3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CK_TEXTURE_SAVEOPTIONS : uint {
|
||||||
|
CKTEXTURE_RAWDATA = 0, /**< Save raw data inside file. The bitmap is saved in a raw 32 bit per pixel format. */
|
||||||
|
CKTEXTURE_EXTERNAL = 1, /**< Store only the file name for the texture. The bitmap file must be present in the bitmap paths when loading the composition. */
|
||||||
|
CKTEXTURE_IMAGEFORMAT = 2, /**< Save using format specified. The bitmap data will be converted to the specified format by the correspondant bitmap plugin and saved inside file. */
|
||||||
|
CKTEXTURE_USEGLOBAL = 3, /**< Use Global settings, that is the settings given with CKContext::SetGlobalImagesSaveOptions. (Not valid when using CKContext::SetImagesSaveOptions). */
|
||||||
|
CKTEXTURE_INCLUDEORIGINALFILE = 4, /**< Insert original image file inside CMO file. The bitmap file that was used originally for the texture or sprite will be append to the composition file and extracted when the file is loaded. */
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VX_PIXELFORMAT : uint {
|
||||||
|
UNKNOWN_PF = 0, /**< Unknown pixel format */
|
||||||
|
_32_ARGB8888 = 1, /**< 32-bit ARGB pixel format with alpha */
|
||||||
|
_32_RGB888 = 2, /**< 32-bit RGB pixel format without alpha */
|
||||||
|
_24_RGB888 = 3, /**< 24-bit RGB pixel format */
|
||||||
|
_16_RGB565 = 4, /**< 16-bit RGB pixel format */
|
||||||
|
_16_RGB555 = 5, /**< 16-bit RGB pixel format (5 bits per color) */
|
||||||
|
_16_ARGB1555 = 6, /**< 16-bit ARGB pixel format (5 bits per color + 1 bit for alpha) */
|
||||||
|
_16_ARGB4444 = 7, /**< 16-bit ARGB pixel format (4 bits per color) */
|
||||||
|
_8_RGB332 = 8, /**< 8-bit RGB pixel format */
|
||||||
|
_8_ARGB2222 = 9, /**< 8-bit ARGB pixel format */
|
||||||
|
_32_ABGR8888 = 10, /**< 32-bit ABGR pixel format */
|
||||||
|
_32_RGBA8888 = 11, /**< 32-bit RGBA pixel format */
|
||||||
|
_32_BGRA8888 = 12, /**< 32-bit BGRA pixel format */
|
||||||
|
_32_BGR888 = 13, /**< 32-bit BGR pixel format */
|
||||||
|
_24_BGR888 = 14, /**< 24-bit BGR pixel format */
|
||||||
|
_16_BGR565 = 15, /**< 16-bit BGR pixel format */
|
||||||
|
_16_BGR555 = 16, /**< 16-bit BGR pixel format (5 bits per color) */
|
||||||
|
_16_ABGR1555 = 17, /**< 16-bit ABGR pixel format (5 bits per color + 1 bit for alpha) */
|
||||||
|
_16_ABGR4444 = 18, /**< 16-bit ABGR pixel format (4 bits per color) */
|
||||||
|
_DXT1 = 19, /**< S3/DirectX Texture Compression 1 */
|
||||||
|
_DXT2 = 20, /**< S3/DirectX Texture Compression 2 */
|
||||||
|
_DXT3 = 21, /**< S3/DirectX Texture Compression 3 */
|
||||||
|
_DXT4 = 22, /**< S3/DirectX Texture Compression 4 */
|
||||||
|
_DXT5 = 23, /**< S3/DirectX Texture Compression 5 */
|
||||||
|
_16_V8U8 = 24, /**< 16-bit Bump Map format format (8 bits per color) */
|
||||||
|
_32_V16U16 = 25, /**< 32-bit Bump Map format format (16 bits per color) */
|
||||||
|
_16_L6V5U5 = 26, /**< 16-bit Bump Map format format with luminance */
|
||||||
|
_32_X8L8V8U8 = 27, /**< 32-bit Bump Map format format with luminance */
|
||||||
|
_8_ABGR8888_CLUT = 28, /**< 8 bits indexed CLUT (ABGR) */
|
||||||
|
_8_ARGB8888_CLUT = 29, /**< 8 bits indexed CLUT (ARGB) */
|
||||||
|
_4_ABGR8888_CLUT = 30, /**< 4 bits indexed CLUT (ABGR) */
|
||||||
|
_4_ARGB8888_CLUT = 31, /**< 4 bits indexed CLUT (ARGB) */
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VXTEXTURE_BLENDMODE : uint {
|
||||||
|
VXTEXTUREBLEND_DECAL = 1, /**< Texture replace any material information */
|
||||||
|
VXTEXTUREBLEND_MODULATE = 2, /**< Texture and material are combine. Alpha information of the texture replace material alpha component. */
|
||||||
|
VXTEXTUREBLEND_DECALALPHA = 3, /**< Alpha information in the texture specify how material and texture are combined. Alpha information of the texture replace material alpha component. */
|
||||||
|
VXTEXTUREBLEND_MODULATEALPHA = 4, /**< Alpha information in the texture specify how material and texture are combined */
|
||||||
|
VXTEXTUREBLEND_DECALMASK = 5,
|
||||||
|
VXTEXTUREBLEND_MODULATEMASK = 6,
|
||||||
|
VXTEXTUREBLEND_COPY = 7, /**< Equivalent to DECAL */
|
||||||
|
VXTEXTUREBLEND_ADD = 8,
|
||||||
|
VXTEXTUREBLEND_DOTPRODUCT3 = 9, /**< Perform a Dot Product 3 between texture (normal map) and a referential vector given in VXRENDERSTATE_TEXTUREFACTOR. */
|
||||||
|
VXTEXTUREBLEND_MAX = 10,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VXTEXTURE_FILTERMODE : uint {
|
||||||
|
VXTEXTUREFILTER_NEAREST = 1, /**< No Filter */
|
||||||
|
VXTEXTUREFILTER_LINEAR = 2, /**< Bilinear Interpolation */
|
||||||
|
VXTEXTUREFILTER_MIPNEAREST = 3, /**< Mip mapping */
|
||||||
|
VXTEXTUREFILTER_MIPLINEAR = 4, /**< Mip Mapping with Bilinear interpolation */
|
||||||
|
VXTEXTUREFILTER_LINEARMIPNEAREST = 5, /**< Mip Mapping with Bilinear interpolation between mipmap levels. */
|
||||||
|
VXTEXTUREFILTER_LINEARMIPLINEAR = 6, /**< Trilinear Filtering */
|
||||||
|
VXTEXTUREFILTER_ANISOTROPIC = 7, /**< Anisotropic filtering */
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VXTEXTURE_ADDRESSMODE : uint {
|
||||||
|
VXTEXTURE_ADDRESSWRAP = 1, /**< Default mesh wrap mode is used (see CKMesh::SetWrapMode) */
|
||||||
|
VXTEXTURE_ADDRESSMIRROR = 2, /**< Texture coordinates outside the range [0..1] are flipped evenly. */
|
||||||
|
VXTEXTURE_ADDRESSCLAMP = 3, /**< Texture coordinates greater than 1.0 are set to 1.0, and values less than 0.0 are set to 0.0. */
|
||||||
|
VXTEXTURE_ADDRESSBORDER = 4, /**< When texture coordinates are greater than 1.0 or less than 0.0 texture is set to a color defined in CKMaterial::SetTextureBorderColor. */
|
||||||
|
VXTEXTURE_ADDRESSMIRRORONCE = 5, /**< */
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VXBLEND_MODE : uint {
|
||||||
|
VXBLEND_ZERO = 1, /**< Blend factor is (0, 0, 0, 0). */
|
||||||
|
VXBLEND_ONE = 2, /**< Blend factor is (1, 1, 1, 1). */
|
||||||
|
VXBLEND_SRCCOLOR = 3, /**< Blend factor is (Rs, Gs, Bs, As). */
|
||||||
|
VXBLEND_INVSRCCOLOR = 4, /**< Blend factor is (1-Rs, 1-Gs, 1-Bs, 1-As). */
|
||||||
|
VXBLEND_SRCALPHA = 5, /**< Blend factor is (As, As, As, As). */
|
||||||
|
VXBLEND_INVSRCALPHA = 6, /**< Blend factor is (1-As, 1-As, 1-As, 1-As). */
|
||||||
|
VXBLEND_DESTALPHA = 7, /**< Blend factor is (Ad, Ad, Ad, Ad). */
|
||||||
|
VXBLEND_INVDESTALPHA = 8, /**< Blend factor is (1-Ad, 1-Ad, 1-Ad, 1-Ad). */
|
||||||
|
VXBLEND_DESTCOLOR = 9, /**< Blend factor is (Rd, Gd, Bd, Ad). */
|
||||||
|
VXBLEND_INVDESTCOLOR = 10, /**< Blend factor is (1-Rd, 1-Gd, 1-Bd, 1-Ad). */
|
||||||
|
VXBLEND_SRCALPHASAT = 11, /**< Blend factor is (f, f, f, 1); f = min(As, 1-Ad). */
|
||||||
|
// VXBLEND_BOTHSRCALPHA = 12, /**< Source blend factor is (As, As, As, As) and destination blend factor is (1-As, 1-As, 1-As, 1-As) */
|
||||||
|
// VXBLEND_BOTHINVSRCALPHA = 13, /**< Source blend factor is (1-As, 1-As, 1-As, 1-As) and destination blend factor is (As, As, As, As) */
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VXFILL_MODE : uint {
|
||||||
|
VXFILL_POINT = 1, /**< Vertices rendering */
|
||||||
|
VXFILL_WIREFRAME = 2, /**< Edges rendering */
|
||||||
|
VXFILL_SOLID = 3, /**< Face rendering */
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VXSHADE_MODE : uint {
|
||||||
|
VXSHADE_FLAT = 1, /**< Flat Shading */
|
||||||
|
VXSHADE_GOURAUD = 2, /**< Gouraud Shading */
|
||||||
|
VXSHADE_PHONG = 3, /**< Phong Shading (Not yet supported by most implementation) */
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VXCMPFUNC : uint {
|
||||||
|
VXCMP_NEVER = 1, /**< Always fail the test. */
|
||||||
|
VXCMP_LESS = 2, /**< Accept if value if less than current value. */
|
||||||
|
VXCMP_EQUAL = 3, /**< Accept if value if equal than current value. */
|
||||||
|
VXCMP_LESSEQUAL = 4, /**< Accept if value if less or equal than current value. */
|
||||||
|
VXCMP_GREATER = 5, /**< Accept if value if greater than current value. */
|
||||||
|
VXCMP_NOTEQUAL = 6, /**< Accept if value if different than current value. */
|
||||||
|
VXCMP_GREATEREQUAL = 7, /**< Accept if value if greater or equal current value. */
|
||||||
|
VXCMP_ALWAYS = 8, /**< Always accept the test. */
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum VXMESH_LITMODE : uint {
|
||||||
|
VX_PRELITMESH = 0, /**< Lighting use color information store with vertices */
|
||||||
|
VX_LITMESH = 1, /**< Lighting is done by renderer using normals and face material information. */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
364
BMapBindings/BMapSharp/BMapSharpTestbench/.editorconfig
Normal file
364
BMapBindings/BMapSharp/BMapSharpTestbench/.editorconfig
Normal file
@ -0,0 +1,364 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
# All files
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
|
||||||
|
# Xml files
|
||||||
|
[*.xml]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
# C# files
|
||||||
|
[*.cs]
|
||||||
|
|
||||||
|
#### Core EditorConfig Options ####
|
||||||
|
|
||||||
|
# Indentation and spacing
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
|
|
||||||
|
# New line preferences
|
||||||
|
end_of_line = crlf
|
||||||
|
insert_final_newline = false
|
||||||
|
|
||||||
|
#### .NET Coding Conventions ####
|
||||||
|
[*.{cs,vb}]
|
||||||
|
|
||||||
|
# Organize usings
|
||||||
|
dotnet_separate_import_directive_groups = false
|
||||||
|
dotnet_sort_system_directives_first = false
|
||||||
|
file_header_template = unset
|
||||||
|
|
||||||
|
# this. and Me. preferences
|
||||||
|
dotnet_style_qualification_for_event = false:silent
|
||||||
|
dotnet_style_qualification_for_field = false:silent
|
||||||
|
dotnet_style_qualification_for_method = false:silent
|
||||||
|
dotnet_style_qualification_for_property = false:silent
|
||||||
|
|
||||||
|
# Language keywords vs BCL types preferences
|
||||||
|
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
|
||||||
|
dotnet_style_predefined_type_for_member_access = true:silent
|
||||||
|
|
||||||
|
# Parentheses preferences
|
||||||
|
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
|
||||||
|
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
|
||||||
|
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
|
||||||
|
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
|
||||||
|
|
||||||
|
# Modifier preferences
|
||||||
|
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
|
||||||
|
|
||||||
|
# Expression-level preferences
|
||||||
|
dotnet_style_coalesce_expression = true:suggestion
|
||||||
|
dotnet_style_collection_initializer = true:suggestion
|
||||||
|
dotnet_style_explicit_tuple_names = true:suggestion
|
||||||
|
dotnet_style_null_propagation = true:suggestion
|
||||||
|
dotnet_style_object_initializer = true:suggestion
|
||||||
|
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
||||||
|
dotnet_style_prefer_auto_properties = true:suggestion
|
||||||
|
dotnet_style_prefer_compound_assignment = true:suggestion
|
||||||
|
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
|
||||||
|
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
|
||||||
|
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
|
||||||
|
dotnet_style_prefer_inferred_tuple_names = true:suggestion
|
||||||
|
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
|
||||||
|
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
|
||||||
|
dotnet_style_prefer_simplified_interpolation = true:suggestion
|
||||||
|
|
||||||
|
# Field preferences
|
||||||
|
dotnet_style_readonly_field = true:warning
|
||||||
|
|
||||||
|
# Parameter preferences
|
||||||
|
dotnet_code_quality_unused_parameters = all:suggestion
|
||||||
|
|
||||||
|
# Suppression preferences
|
||||||
|
dotnet_remove_unnecessary_suppression_exclusions = none
|
||||||
|
|
||||||
|
#### C# Coding Conventions ####
|
||||||
|
[*.cs]
|
||||||
|
|
||||||
|
# var preferences
|
||||||
|
csharp_style_var_elsewhere = false:silent
|
||||||
|
csharp_style_var_for_built_in_types = false:silent
|
||||||
|
csharp_style_var_when_type_is_apparent = false:silent
|
||||||
|
|
||||||
|
# Expression-bodied members
|
||||||
|
csharp_style_expression_bodied_accessors = true:silent
|
||||||
|
csharp_style_expression_bodied_constructors = false:silent
|
||||||
|
csharp_style_expression_bodied_indexers = true:silent
|
||||||
|
csharp_style_expression_bodied_lambdas = true:suggestion
|
||||||
|
csharp_style_expression_bodied_local_functions = false:silent
|
||||||
|
csharp_style_expression_bodied_methods = false:silent
|
||||||
|
csharp_style_expression_bodied_operators = false:silent
|
||||||
|
csharp_style_expression_bodied_properties = true:silent
|
||||||
|
|
||||||
|
# Pattern matching preferences
|
||||||
|
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
|
||||||
|
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
|
||||||
|
csharp_style_prefer_not_pattern = true:suggestion
|
||||||
|
csharp_style_prefer_pattern_matching = true:silent
|
||||||
|
csharp_style_prefer_switch_expression = true:suggestion
|
||||||
|
|
||||||
|
# Null-checking preferences
|
||||||
|
csharp_style_conditional_delegate_call = true:suggestion
|
||||||
|
|
||||||
|
# Modifier preferences
|
||||||
|
csharp_prefer_static_local_function = true:warning
|
||||||
|
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
|
||||||
|
|
||||||
|
# Code-block preferences
|
||||||
|
csharp_prefer_braces = true:silent
|
||||||
|
csharp_prefer_simple_using_statement = true:suggestion
|
||||||
|
|
||||||
|
# Expression-level preferences
|
||||||
|
csharp_prefer_simple_default_expression = true:suggestion
|
||||||
|
csharp_style_deconstructed_variable_declaration = true:suggestion
|
||||||
|
csharp_style_inlined_variable_declaration = true:suggestion
|
||||||
|
csharp_style_pattern_local_over_anonymous_function = true:suggestion
|
||||||
|
csharp_style_prefer_index_operator = true:suggestion
|
||||||
|
csharp_style_prefer_range_operator = true:suggestion
|
||||||
|
csharp_style_throw_expression = true:suggestion
|
||||||
|
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
|
||||||
|
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
|
||||||
|
|
||||||
|
# 'using' directive preferences
|
||||||
|
csharp_using_directive_placement = outside_namespace:silent
|
||||||
|
|
||||||
|
#### C# Formatting Rules ####
|
||||||
|
|
||||||
|
# New line preferences
|
||||||
|
csharp_new_line_before_catch = false
|
||||||
|
csharp_new_line_before_else = false
|
||||||
|
csharp_new_line_before_finally = false
|
||||||
|
csharp_new_line_before_members_in_anonymous_types = true
|
||||||
|
csharp_new_line_before_members_in_object_initializers = true
|
||||||
|
csharp_new_line_before_open_brace = none
|
||||||
|
csharp_new_line_between_query_expression_clauses = true
|
||||||
|
|
||||||
|
# Indentation preferences
|
||||||
|
csharp_indent_block_contents = true
|
||||||
|
csharp_indent_braces = false
|
||||||
|
csharp_indent_case_contents = true
|
||||||
|
csharp_indent_case_contents_when_block = true
|
||||||
|
csharp_indent_labels = one_less_than_current
|
||||||
|
csharp_indent_switch_labels = true
|
||||||
|
|
||||||
|
# Space preferences
|
||||||
|
csharp_space_after_cast = false
|
||||||
|
csharp_space_after_colon_in_inheritance_clause = true
|
||||||
|
csharp_space_after_comma = true
|
||||||
|
csharp_space_after_dot = false
|
||||||
|
csharp_space_after_keywords_in_control_flow_statements = true
|
||||||
|
csharp_space_after_semicolon_in_for_statement = true
|
||||||
|
csharp_space_around_binary_operators = before_and_after
|
||||||
|
csharp_space_around_declaration_statements = false
|
||||||
|
csharp_space_before_colon_in_inheritance_clause = true
|
||||||
|
csharp_space_before_comma = false
|
||||||
|
csharp_space_before_dot = false
|
||||||
|
csharp_space_before_open_square_brackets = false
|
||||||
|
csharp_space_before_semicolon_in_for_statement = false
|
||||||
|
csharp_space_between_empty_square_brackets = false
|
||||||
|
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||||
|
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||||
|
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_parentheses = false
|
||||||
|
csharp_space_between_square_brackets = false
|
||||||
|
|
||||||
|
# Wrapping preferences
|
||||||
|
csharp_preserve_single_line_blocks = true
|
||||||
|
csharp_preserve_single_line_statements = true
|
||||||
|
|
||||||
|
#### Naming styles ####
|
||||||
|
[*.{cs,vb}]
|
||||||
|
|
||||||
|
# Naming rules
|
||||||
|
|
||||||
|
dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.symbols = types_and_namespaces
|
||||||
|
dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.interfaces_should_be_ipascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.interfaces_should_be_ipascalcase.symbols = interfaces
|
||||||
|
dotnet_naming_rule.interfaces_should_be_ipascalcase.style = ipascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.type_parameters_should_be_tpascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.type_parameters_should_be_tpascalcase.symbols = type_parameters
|
||||||
|
dotnet_naming_rule.type_parameters_should_be_tpascalcase.style = tpascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.methods_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.methods_should_be_pascalcase.symbols = methods
|
||||||
|
dotnet_naming_rule.methods_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.properties_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.properties_should_be_pascalcase.symbols = properties
|
||||||
|
dotnet_naming_rule.properties_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.events_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.events_should_be_pascalcase.symbols = events
|
||||||
|
dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables
|
||||||
|
dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.local_constants_should_be_camelcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.local_constants_should_be_camelcase.symbols = local_constants
|
||||||
|
dotnet_naming_rule.local_constants_should_be_camelcase.style = camelcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters
|
||||||
|
dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields
|
||||||
|
dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields
|
||||||
|
dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields
|
||||||
|
dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields
|
||||||
|
dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields
|
||||||
|
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields
|
||||||
|
dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields
|
||||||
|
dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums
|
||||||
|
dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.local_functions_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.local_functions_should_be_pascalcase.symbols = local_functions
|
||||||
|
dotnet_naming_rule.local_functions_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
dotnet_naming_rule.non_field_members_should_be_pascalcase.severity = suggestion
|
||||||
|
dotnet_naming_rule.non_field_members_should_be_pascalcase.symbols = non_field_members
|
||||||
|
dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase
|
||||||
|
|
||||||
|
# Symbol specifications
|
||||||
|
|
||||||
|
dotnet_naming_symbols.interfaces.applicable_kinds = interface
|
||||||
|
dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.interfaces.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.enums.applicable_kinds = enum
|
||||||
|
dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.enums.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.events.applicable_kinds = event
|
||||||
|
dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.events.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.methods.applicable_kinds = method
|
||||||
|
dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.methods.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.properties.applicable_kinds = property
|
||||||
|
dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.properties.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.public_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal
|
||||||
|
dotnet_naming_symbols.public_fields.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.private_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.private_fields.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.private_static_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.private_static_fields.required_modifiers = static
|
||||||
|
|
||||||
|
dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum
|
||||||
|
dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.types_and_namespaces.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
|
||||||
|
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.non_field_members.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.type_parameters.applicable_kinds = namespace
|
||||||
|
dotnet_naming_symbols.type_parameters.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.type_parameters.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.private_constant_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.private_constant_fields.required_modifiers = const
|
||||||
|
|
||||||
|
dotnet_naming_symbols.local_variables.applicable_kinds = local
|
||||||
|
dotnet_naming_symbols.local_variables.applicable_accessibilities = local
|
||||||
|
dotnet_naming_symbols.local_variables.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.local_constants.applicable_kinds = local
|
||||||
|
dotnet_naming_symbols.local_constants.applicable_accessibilities = local
|
||||||
|
dotnet_naming_symbols.local_constants.required_modifiers = const
|
||||||
|
|
||||||
|
dotnet_naming_symbols.parameters.applicable_kinds = parameter
|
||||||
|
dotnet_naming_symbols.parameters.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.parameters.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.public_constant_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal
|
||||||
|
dotnet_naming_symbols.public_constant_fields.required_modifiers = const
|
||||||
|
|
||||||
|
dotnet_naming_symbols.public_static_readonly_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.public_static_readonly_fields.applicable_accessibilities = public, internal
|
||||||
|
dotnet_naming_symbols.public_static_readonly_fields.required_modifiers = readonly, static
|
||||||
|
|
||||||
|
dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readonly, static
|
||||||
|
|
||||||
|
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
|
||||||
|
dotnet_naming_symbols.local_functions.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.local_functions.required_modifiers =
|
||||||
|
|
||||||
|
# Naming styles
|
||||||
|
|
||||||
|
dotnet_naming_style.pascalcase.required_prefix =
|
||||||
|
dotnet_naming_style.pascalcase.required_suffix =
|
||||||
|
dotnet_naming_style.pascalcase.word_separator =
|
||||||
|
dotnet_naming_style.pascalcase.capitalization = pascal_case
|
||||||
|
|
||||||
|
dotnet_naming_style.ipascalcase.required_prefix = I
|
||||||
|
dotnet_naming_style.ipascalcase.required_suffix =
|
||||||
|
dotnet_naming_style.ipascalcase.word_separator =
|
||||||
|
dotnet_naming_style.ipascalcase.capitalization = pascal_case
|
||||||
|
|
||||||
|
dotnet_naming_style.tpascalcase.required_prefix = T
|
||||||
|
dotnet_naming_style.tpascalcase.required_suffix =
|
||||||
|
dotnet_naming_style.tpascalcase.word_separator =
|
||||||
|
dotnet_naming_style.tpascalcase.capitalization = pascal_case
|
||||||
|
|
||||||
|
dotnet_naming_style._camelcase.required_prefix = _
|
||||||
|
dotnet_naming_style._camelcase.required_suffix =
|
||||||
|
dotnet_naming_style._camelcase.word_separator =
|
||||||
|
dotnet_naming_style._camelcase.capitalization = camel_case
|
||||||
|
|
||||||
|
dotnet_naming_style.camelcase.required_prefix =
|
||||||
|
dotnet_naming_style.camelcase.required_suffix =
|
||||||
|
dotnet_naming_style.camelcase.word_separator =
|
||||||
|
dotnet_naming_style.camelcase.capitalization = camel_case
|
||||||
|
|
||||||
|
dotnet_naming_style.s_camelcase.required_prefix = s_
|
||||||
|
dotnet_naming_style.s_camelcase.required_suffix =
|
||||||
|
dotnet_naming_style.s_camelcase.word_separator =
|
||||||
|
dotnet_naming_style.s_camelcase.capitalization = camel_case
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
12
BMapBindings/BMapSharp/BMapSharpTestbench/Program.cs
Normal file
12
BMapBindings/BMapSharp/BMapSharpTestbench/Program.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BMapSharpTestbench // Note: actual namespace depends on the project name.
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
BMapBindings/BMapSharp/README.md
Normal file
7
BMapBindings/BMapSharp/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# BMapSharp
|
||||||
|
|
||||||
|
The core of BMapSharp project is placed within `BMapSharp` subdirectory. This directory also contain a testbench project of `BMapSharp`, called `BMapSharpTestbench`. You can build it and do basic test for `BMapSharp`.
|
||||||
|
|
||||||
|
The native BMap library should be placed together with managed `BMapSharp` dynamic library. I use gitignore file to filter all native binary so you need put them manually. The native BMap library must be named as `BMap.dll` (in Windows), `BMap.so` (in Linux or BSD), or `BMap.dylib` (in macOS). If you still can not load BMap or your system is not listed above, you should name it as `BMap.bin`.
|
||||||
|
|
||||||
|
The most content of `VirtoolsTypes.cs` is generated by EnumsMigration, and the most content of `BMap.cs` is generated by BMapBindings. You should watch these file changes if corresponding C++ code or structures are changed.
|
3
BMapBindings/PyBMap/.gitignore
vendored
3
BMapBindings/PyBMap/.gitignore
vendored
@ -9,9 +9,6 @@
|
|||||||
*.dylib
|
*.dylib
|
||||||
*.bin
|
*.bin
|
||||||
|
|
||||||
# Ignore testbench file.
|
|
||||||
testbench.py
|
|
||||||
|
|
||||||
# -------------------- Python --------------------
|
# -------------------- Python --------------------
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
@ -78,12 +78,13 @@ elif sys.platform.startswith('darwin'):
|
|||||||
else:
|
else:
|
||||||
_g_BMapLibName = "BMap.bin"
|
_g_BMapLibName = "BMap.bin"
|
||||||
|
|
||||||
|
_g_BMapLibPath: str = os.path.join(os.path.dirname(__file__), _g_BMapLibName)
|
||||||
|
|
||||||
_g_BMapModule: ctypes.CDLL | None = None
|
_g_BMapModule: ctypes.CDLL | None = None
|
||||||
try:
|
try:
|
||||||
_g_BMapModule = ctypes.cdll.LoadLibrary(
|
_g_BMapModule = ctypes.cdll.LoadLibrary(_g_BMapLibPath)
|
||||||
os.path.join(os.path.dirname(__file__), _g_BMapLibName)
|
|
||||||
)
|
|
||||||
except:
|
except:
|
||||||
|
print(f'Fail to load native BMap dynamic library file "{_g_BMapLibPath}".')
|
||||||
_g_BMapModule = None
|
_g_BMapModule = None
|
||||||
|
|
||||||
def is_bmap_available() -> bool:
|
def is_bmap_available() -> bool:
|
||||||
@ -107,6 +108,8 @@ def _create_bmap_func(fct_name: str, fct_params: list[typing.Any]) -> typing.Cal
|
|||||||
|
|
||||||
#region Function Defines
|
#region Function Defines
|
||||||
|
|
||||||
|
##### GENERATED FUNCTIONS BEGIN #####
|
||||||
|
|
||||||
## BMInit
|
## BMInit
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BMInit = _create_bmap_func('BMInit', [])
|
BMInit = _create_bmap_func('BMInit', [])
|
||||||
@ -781,5 +784,6 @@ BM3dObject_GetVisibility = _create_bmap_func('BM3dObject_GetVisibility', [bm_voi
|
|||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BM3dObject_SetVisibility = _create_bmap_func('BM3dObject_SetVisibility', [bm_void_p, bm_CKID, bm_bool])
|
BM3dObject_SetVisibility = _create_bmap_func('BM3dObject_SetVisibility', [bm_void_p, bm_CKID, bm_bool])
|
||||||
|
|
||||||
#endregion
|
##### GENERATED FUNCTIONS END #####
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# PyBMap
|
# PyBMap
|
||||||
|
|
||||||
The real scripts are placed in sub PyBMap folder. This folder is served for testbench scripts placing. Place any testbench files (e.g. `testbench.py`) in there what you want and don't sumbit them (`testbench.py` is explicitly excluded by gitignore file).
|
The real scripts are placed in sub PyBMap folder. This folder is served for testbench scripts placing. You can run `testbench.py` to do a basic test for PyBMap but you may need some essential files to run this testbench which were written in `testbench.py`.
|
||||||
|
|
||||||
The native BMap library should be placed in sub PyBMap folder, and I have used gitignore file to filter them. The native BMap library must be named as `BMap.dll` (in Windows), `BMap.so` (in Linux or BSD), or `BMap.dylib` (in macOS). If you still can not load BMap or your system is not listed above, you should name it as `BMap.bin`.
|
The native BMap library should be placed in sub PyBMap folder, and I have used gitignore file to filter them. The native BMap library must be named as `BMap.dll` (in Windows), `BMap.so` (in Linux or BSD), or `BMap.dylib` (in macOS). If you still can not load BMap or your system is not listed above, you should name it as `BMap.bin`.
|
||||||
|
|
||||||
|
Please note the most content of `virtools_types.py` are generated by EnumsMigration sub-project. Additionally the most content of `bmap.py` is generated by BMapBindings. So if some structs are updated, do not forget checking these files.
|
||||||
|
35
BMapBindings/PyBMap/testbench.py
Normal file
35
BMapBindings/PyBMap/testbench.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import os
|
||||||
|
import PyBMap.bmap_wrapper as bmap
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
input(f'Python PID is {os.getpid()}. Waiting for debugger, press any key to continue...')
|
||||||
|
|
||||||
|
file_name: str = 'Level_02.NMO'
|
||||||
|
temp_folder: str = 'Temp'
|
||||||
|
texture_folder: str = 'F:\\Ballance\\Ballance\\Textures'
|
||||||
|
encodings: tuple[str, ...] = ('cp1252', )
|
||||||
|
with bmap.BMFileReader(file_name, temp_folder, texture_folder, encodings) as reader:
|
||||||
|
print('===== Groups =====')
|
||||||
|
for gp in reader.get_groups():
|
||||||
|
print(gp.get_name())
|
||||||
|
|
||||||
|
print('===== Objects =====')
|
||||||
|
for obj in reader.get_3dobjects():
|
||||||
|
print(obj.get_name())
|
||||||
|
|
||||||
|
print('===== Meshes =====')
|
||||||
|
for mesh in reader.get_meshs():
|
||||||
|
print(mesh.get_name())
|
||||||
|
|
||||||
|
print('===== Materials =====')
|
||||||
|
for mtl in reader.get_materials():
|
||||||
|
print(mtl.get_name())
|
||||||
|
|
||||||
|
print('===== Textures =====')
|
||||||
|
for tex in reader.get_textures():
|
||||||
|
print(tex.get_name())
|
||||||
|
|
||||||
|
print('===== END =====')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
7
CMake/LibCmoConfig.cmake.in
Normal file
7
CMake/LibCmoConfig.cmake.in
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
# Include targets file
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/LibCmoTargets.cmake")
|
||||||
|
|
||||||
|
check_required_components(LibCmo)
|
9
CMake/custom_import_iconv.cmake
Normal file
9
CMake/custom_import_iconv.cmake
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
if (WIN32)
|
||||||
|
# In Windows, we should not import Iconv.
|
||||||
|
# Send a notice to programmer.
|
||||||
|
message("Windows environment detected, skip finding Iconv!")
|
||||||
|
else ()
|
||||||
|
# In non-Windows, we simply import Iconv from CMake preset.
|
||||||
|
# It will produce Iconv::Iconv target for including and linking.
|
||||||
|
find_package(Iconv REQUIRED)
|
||||||
|
endif ()
|
14
CMake/custom_import_stb.cmake
Normal file
14
CMake/custom_import_stb.cmake
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Check stb path variable
|
||||||
|
if (NOT DEFINED STB_IMAGE_PATH)
|
||||||
|
message(FATAL_ERROR "You must set STB_IMAGE_PATH variable to the root directory of std-image repository.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Add library
|
||||||
|
add_library(stb-image INTERFACE IMPORTED)
|
||||||
|
# Add alias for it
|
||||||
|
add_library(stb::stb-image ALIAS stb-image)
|
||||||
|
# Setup header files
|
||||||
|
set_target_properties(stb-image PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES
|
||||||
|
"${STB_IMAGE_PATH}"
|
||||||
|
)
|
11
CMake/custom_import_yycc.cmake
Normal file
11
CMake/custom_import_yycc.cmake
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
# Check YYCC path environment variable
|
||||||
|
if (NOT DEFINED YYCC_PATH)
|
||||||
|
message(FATAL_ERROR "You must set YYCC_PATH variable to one of YYCC CMake distribution installation path.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Find YYCC library
|
||||||
|
# It will produce YYCC::YYCCommonplace target for including and linking.
|
||||||
|
find_package(YYCCommonplace REQUIRED
|
||||||
|
HINTS ${YYCC_PATH} NO_DEFAULT_PATH
|
||||||
|
)
|
34
CMake/custom_import_zlib.cmake
Normal file
34
CMake/custom_import_zlib.cmake
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
if (WIN32)
|
||||||
|
# In Windows, we use custom way to import ZLib.
|
||||||
|
# Before using this CMake file in Windows, you should do following steps first.
|
||||||
|
# 1. Get ZLib repository: https://github.com/madler/zlib
|
||||||
|
# 2. Navigate to `contrib/vstudio` and choose a proper Visual Studio project according to your environment.
|
||||||
|
# 3. Open project file and build. Then you will get the built binary.
|
||||||
|
# 4. The directory binary located is the argument you should passed to ZLIB_BINARY_PATH, for example: `contrib/vstudio/vc14/x64/ZlibDllRelease`
|
||||||
|
|
||||||
|
# Check ZLib path variable
|
||||||
|
if (NOT DEFINED ZLIB_HEADER_PATH)
|
||||||
|
message(FATAL_ERROR "You must set ZLIB_HEADER_PATH to the root directory of ZLib repository.")
|
||||||
|
endif()
|
||||||
|
if (NOT DEFINED ZLIB_BINARY_PATH)
|
||||||
|
message(FATAL_ERROR "You must set ZLIB_BINARY_PATH to the directory where include binary built by contributed Visual Studio project.")
|
||||||
|
endif()
|
||||||
|
# Add imported library
|
||||||
|
add_library(ZLIB INTERFACE IMPORTED)
|
||||||
|
# Add alias for it to let it has the same behavior with CMake imported ZLib.
|
||||||
|
add_library(ZLIB::ZLIB ALIAS ZLIB)
|
||||||
|
# Setup header files
|
||||||
|
set_target_properties(ZLIB PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES
|
||||||
|
"${ZLIB_HEADER_PATH}"
|
||||||
|
)
|
||||||
|
# Setup lib files
|
||||||
|
set_target_properties(ZLIB PROPERTIES
|
||||||
|
INTERFACE_LINK_LIBRARIES
|
||||||
|
"${ZLIB_BINARY_PATH}/zlibwapi.lib"
|
||||||
|
)
|
||||||
|
else ()
|
||||||
|
# In non-Windows, we simply import ZLib from CMake preset.
|
||||||
|
# It will produce ZLIB::ZLIB target for including and linking.
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
endif ()
|
77
CMakeLists.txt
Normal file
77
CMakeLists.txt
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.23)
|
||||||
|
project(NeMo
|
||||||
|
VERSION 0.2.0
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
# Provide options
|
||||||
|
option(NEMO_BUILD_UNVIRT "Build Unvirt, the console interface operator of LibCmo." ON)
|
||||||
|
option(NEMO_BUILD_BMAP "Build BMap, the example use of LibCmo which can read and write Ballance game map." OFF)
|
||||||
|
option(NEMO_BUILD_DOC "Build document of LibCmo and all related stuff." OFF)
|
||||||
|
|
||||||
|
# Setup install path from CMake provided install path for convenient use.
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
set(NEMO_INSTALL_INCLUDE_PATH ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH
|
||||||
|
"Public header install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
||||||
|
set(NEMO_INSTALL_LIB_PATH ${CMAKE_INSTALL_LIBDIR} CACHE PATH
|
||||||
|
"Library install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
||||||
|
set(NEMO_INSTALL_BIN_PATH ${CMAKE_INSTALL_BINDIR} CACHE PATH
|
||||||
|
"Binary install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
||||||
|
set(NEMO_INSTALL_DOC_PATH ${CMAKE_INSTALL_DOCDIR} CACHE PATH
|
||||||
|
"Non-arch doc install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
||||||
|
|
||||||
|
# Import essential packages
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/CMake/custom_import_zlib.cmake)
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/CMake/custom_import_iconv.cmake)
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/CMake/custom_import_yycc.cmake)
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/CMake/custom_import_stb.cmake)
|
||||||
|
|
||||||
|
# If we are not in Windows environment, and we need to build shared library BMap,
|
||||||
|
# we should enable PIC (position independent code), otherwise build process will fail.
|
||||||
|
# Also we should let all symbols in final dll be hidden (not exported) in default.
|
||||||
|
# Because we only want export functions we ordered.
|
||||||
|
if ((NOT WIN32) AND NEMO_BUILD_BMAP)
|
||||||
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||||
|
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE True)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Import build targets
|
||||||
|
add_subdirectory(LibCmo)
|
||||||
|
if (NEMO_BUILD_UNVIRT)
|
||||||
|
add_subdirectory(Unvirt)
|
||||||
|
endif ()
|
||||||
|
if (NEMO_BUILD_BMAP)
|
||||||
|
add_subdirectory(BMap)
|
||||||
|
endif ()
|
||||||
|
if (NEMO_BUILD_DOC)
|
||||||
|
add_subdirectory(Documents)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Install target and package
|
||||||
|
# Install target
|
||||||
|
install(EXPORT LibCmoTargets
|
||||||
|
FILE LibCmoTargets.cmake
|
||||||
|
NAMESPACE NeMo::
|
||||||
|
DESTINATION ${YYCC_INSTALL_LIB_PATH}/cmake/LibCmo
|
||||||
|
)
|
||||||
|
# Package configuration file
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
write_basic_package_version_file(
|
||||||
|
LibCmoConfigVersion.cmake
|
||||||
|
VERSION ${PACKAGE_VERSION}
|
||||||
|
COMPATIBILITY SameMinorVersion
|
||||||
|
)
|
||||||
|
configure_package_config_file(
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/CMake/LibCmoConfig.cmake.in
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/LibCmoConfig.cmake"
|
||||||
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LibCmo
|
||||||
|
)
|
||||||
|
# Copy package files to install destination
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/LibCmoConfig.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/LibCmoConfigVersion.cmake"
|
||||||
|
DESTINATION
|
||||||
|
${CMAKE_INSTALL_LIBDIR}/cmake/LibCmo
|
||||||
|
)
|
@ -1,12 +1,273 @@
|
|||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CSharpWriter {
|
public class CSharpWriter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class represent the C# type corresponding to extracted variable type.
|
||||||
|
*/
|
||||||
|
private static class CsInteropType {
|
||||||
|
public CsInteropType() {
|
||||||
|
mMarshalAs = null;
|
||||||
|
mCsType = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The argument of MarshalAsAttribute constructor. In generation, this field
|
||||||
|
* should be used like this: "[MarshalAs(THIS)]" (for parameter) or "[return:
|
||||||
|
* MarshalAs(THIS)]" (for return value).
|
||||||
|
*/
|
||||||
|
public String mMarshalAs;
|
||||||
|
/**
|
||||||
|
* The C# type used in interop function declaration for corresponding parameter.
|
||||||
|
*/
|
||||||
|
public String mCsType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* C# specified function which get C# used interop MarshalAs constructor
|
||||||
|
* arguments and C# type used in interop function declaration.
|
||||||
|
*
|
||||||
|
* @param vt The instance of {@linkplain VariableType} for fetching interop
|
||||||
|
* type.
|
||||||
|
* @return The corresponding interop type of given variable type.
|
||||||
|
*/
|
||||||
|
private static CsInteropType getCsInteropType(ExpFctParamDecl paramdecl) {
|
||||||
|
// get essential variable type properties first
|
||||||
|
VariableType vt = paramdecl.mVarType;
|
||||||
|
String vt_base_type = vt.getBaseType();
|
||||||
|
int vt_pointer_level = vt.getPointerLevel();
|
||||||
|
|
||||||
|
// create return value
|
||||||
|
CsInteropType ret = new CsInteropType();
|
||||||
|
|
||||||
|
// use "switch" to check variable type
|
||||||
|
switch (vt_base_type) {
|
||||||
|
case "CKSTRING":
|
||||||
|
// only allow 0 and 1 pointer level for string.
|
||||||
|
switch (vt_pointer_level) {
|
||||||
|
case 0:
|
||||||
|
ret.mMarshalAs = "UnmanagedType.LPUTF8Str";
|
||||||
|
ret.mCsType = "string";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ret.mMarshalAs = "UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringArrayMarshaler)";
|
||||||
|
ret.mCsType = "string[]";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "CKDWORD":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.U4";
|
||||||
|
ret.mCsType = "uint";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "CKWORD":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.U2";
|
||||||
|
ret.mCsType = "ushort";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "CKINT":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.I4";
|
||||||
|
ret.mCsType = "int";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "bool":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.U1";
|
||||||
|
ret.mCsType = "bool";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "CKFLOAT":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.R4";
|
||||||
|
ret.mCsType = "float";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "CKBYTE":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.U1";
|
||||||
|
ret.mCsType = "byte";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
case "CK_ID":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.U4";
|
||||||
|
ret.mCsType = "uint";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "NakedOutputCallback":
|
||||||
|
// callback actually is a function pointer
|
||||||
|
// so it only allow base type without any pointer level.
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.FunctionPtr";
|
||||||
|
ret.mCsType = "OutputCallback";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "BMFile":
|
||||||
|
// In any case, BMFile only should be raw pointer
|
||||||
|
if (vt_pointer_level != 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "BMMeshTransition":
|
||||||
|
// In any case, BMMeshTransition only should be raw pointer
|
||||||
|
if (vt_pointer_level != 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "VxVector3":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.Struct";
|
||||||
|
ret.mCsType = "VxVector3";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "VxVector2":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.Struct";
|
||||||
|
ret.mCsType = "VxVector2";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "VxColor":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.Struct";
|
||||||
|
ret.mCsType = "VxColor";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "VxMatrix":
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.Struct";
|
||||||
|
ret.mCsType = "VxMatrix";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "CK_TEXTURE_SAVEOPTIONS":
|
||||||
|
case "VX_PIXELFORMAT":
|
||||||
|
case "VXTEXTURE_BLENDMODE":
|
||||||
|
case "VXTEXTURE_FILTERMODE":
|
||||||
|
case "VXTEXTURE_ADDRESSMODE":
|
||||||
|
case "VXBLEND_MODE":
|
||||||
|
case "VXFILL_MODE":
|
||||||
|
case "VXSHADE_MODE":
|
||||||
|
case "VXCMPFUNC":
|
||||||
|
case "VXMESH_LITMODE":
|
||||||
|
// all enum share the same underlying type.
|
||||||
|
if (vt_pointer_level == 0) {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.U4";
|
||||||
|
ret.mCsType = "uint";
|
||||||
|
} else {
|
||||||
|
ret.mMarshalAs = "UnmanagedType.SysInt";
|
||||||
|
ret.mCsType = "IntPtr";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check whether we successfully get result
|
||||||
|
if (ret.mMarshalAs == null || ret.mCsType == null) {
|
||||||
|
throw new IllegalArgumentException("Unexpected type: " + vt.toCType());
|
||||||
|
}
|
||||||
|
|
||||||
|
// return value
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public static void writeCSharpCode(Vector<ExpFctDecl> data) throws Exception {
|
public static void writeCSharpCode(Vector<ExpFctDecl> data) throws Exception {
|
||||||
OutputStreamWriter writer = CommonHelper.openWriter("dest/BMExports.cs");
|
OutputStreamWriter writer = CommonHelper.openWriter("dest/BMExports.cs");
|
||||||
writer.write("// WIP");
|
IndentHelper helper = new IndentHelper(writer);
|
||||||
|
|
||||||
|
// write function decls
|
||||||
|
for (ExpFctDecl fctdecl : data) {
|
||||||
|
// write annotation
|
||||||
|
// summary (just plain function name)
|
||||||
|
helper.printf("/// <summary>%s</summary>", fctdecl.mFctName);
|
||||||
|
// parameter list
|
||||||
|
for (ExpFctParamDecl paramdecl : fctdecl.mFctParams) {
|
||||||
|
helper.printf("/// <param name=\"%s\">Type: %s. %s%s</param>", paramdecl.mVarName,
|
||||||
|
paramdecl.mVarType.toCType(), (paramdecl.mIsInput ? "" : "This is OUT parameter. "),
|
||||||
|
paramdecl.mVarDesc);
|
||||||
|
}
|
||||||
|
// return value
|
||||||
|
helper.puts("/// <returns>True if no error, otherwise False.</returns>");
|
||||||
|
|
||||||
|
// write real function declaration
|
||||||
|
// first, write DllImportAttribute
|
||||||
|
helper.printf(
|
||||||
|
"[DllImport(g_DllName, EntryPoint = \"%s\", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]",
|
||||||
|
fctdecl.mFctName);
|
||||||
|
// second, write return value MarshalAsAttribute
|
||||||
|
helper.printf("[return: MarshalAs(UnmanagedType.U1)]");
|
||||||
|
// then, before we write function body, we need origanize its parameter list
|
||||||
|
// first
|
||||||
|
Vector<String> cs_param_list = new Vector<String>();
|
||||||
|
for (ExpFctParamDecl paramdecl : fctdecl.mFctParams) {
|
||||||
|
// create string builder
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
// push in out symbol
|
||||||
|
if (paramdecl.mIsInput) {
|
||||||
|
sb.append("[In, ");
|
||||||
|
} else {
|
||||||
|
sb.append("[Out, ");
|
||||||
|
}
|
||||||
|
// get interop type now
|
||||||
|
CsInteropType interop_type = getCsInteropType(paramdecl);
|
||||||
|
// push MarshalAsAttribute
|
||||||
|
sb.append("MarshalAs(");
|
||||||
|
sb.append(interop_type.mMarshalAs);
|
||||||
|
sb.append(")] ");
|
||||||
|
// push out keyword if parameter is out parameter
|
||||||
|
if (!paramdecl.mIsInput) {
|
||||||
|
sb.append("out ");
|
||||||
|
}
|
||||||
|
// push parameter cs type
|
||||||
|
sb.append(interop_type.mCsType);
|
||||||
|
sb.append(" ");
|
||||||
|
// push parameter name
|
||||||
|
sb.append(paramdecl.mVarName);
|
||||||
|
// insert built string into list
|
||||||
|
cs_param_list.add(sb.toString());
|
||||||
|
}
|
||||||
|
// join built parameter list and output real function declaration
|
||||||
|
helper.printf("internal static extern bool %s(%s);", fctdecl.mFctName,
|
||||||
|
cs_param_list.stream().collect(Collectors.joining(", ")));
|
||||||
|
}
|
||||||
|
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
import java.io.FileInputStream;
|
//import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStreamReader;
|
//import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class CommonHelper {
|
public class CommonHelper {
|
||||||
|
|
||||||
public static InputStreamReader openReader(String filename) throws Exception {
|
// public static InputStreamReader openReader(String filename) throws Exception {
|
||||||
FileInputStream fs = new FileInputStream(filename);
|
// FileInputStream fs = new FileInputStream(filename);
|
||||||
return new InputStreamReader(fs, StandardCharsets.UTF_8);
|
// return new InputStreamReader(fs, StandardCharsets.UTF_8);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static OutputStreamWriter openWriter(String filename) throws Exception {
|
public static OutputStreamWriter openWriter(String filename) throws Exception {
|
||||||
FileOutputStream fs = new FileOutputStream(filename);
|
FileOutputStream fs = new FileOutputStream(filename);
|
||||||
return new OutputStreamWriter(fs, StandardCharsets.UTF_8);
|
return new OutputStreamWriter(fs, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeSnippet(OutputStreamWriter writer, String snippet_path) throws Exception {
|
// public static void writeSnippet(OutputStreamWriter writer, String snippet_path) throws Exception {
|
||||||
// open snippet
|
// // open snippet
|
||||||
InputStreamReader reader = openReader(snippet_path);
|
// InputStreamReader reader = openReader(snippet_path);
|
||||||
// write into writer
|
// // write into writer
|
||||||
reader.transferTo(writer);
|
// reader.transferTo(writer);
|
||||||
reader.close();
|
// reader.close();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static String getDoxygenInOutStr(boolean isInput) {
|
public static String getDoxygenInOutStr(boolean isInput) {
|
||||||
return isInput ? "in" : "out";
|
return isInput ? "in" : "out";
|
||||||
|
@ -1,16 +1,29 @@
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class represent an export BMap function.
|
||||||
|
*/
|
||||||
public class ExpFctDecl {
|
public class ExpFctDecl {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of this function.
|
||||||
|
*/
|
||||||
public String mFctName;
|
public String mFctName;
|
||||||
|
/**
|
||||||
|
* The return value type of this function.
|
||||||
|
*/
|
||||||
public VariableType mFctRetType;
|
public VariableType mFctRetType;
|
||||||
|
/**
|
||||||
|
* The parameters (arguments) list of this function. Each items are
|
||||||
|
* {@linkplain ExpFctParamDecl} and represent parameter one by one from left to
|
||||||
|
* right.
|
||||||
|
*/
|
||||||
public Vector<ExpFctParamDecl> mFctParams;
|
public Vector<ExpFctParamDecl> mFctParams;
|
||||||
|
|
||||||
public ExpFctDecl() {
|
public ExpFctDecl() {
|
||||||
mFctName = "";
|
mFctName = "";
|
||||||
mFctRetType = new VariableType();
|
mFctRetType = new VariableType();
|
||||||
mFctParams = new Vector<ExpFctParamDecl>();
|
mFctParams = new Vector<ExpFctParamDecl>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,16 +1,48 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* The class represent a single parameter (argument) of function. This class
|
||||||
|
* usually is the member of {@linkplain ExpFctDecl}.
|
||||||
|
*/
|
||||||
public class ExpFctParamDecl {
|
public class ExpFctParamDecl {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of this parameter.
|
||||||
|
*/
|
||||||
public VariableType mVarType;
|
public VariableType mVarType;
|
||||||
|
/**
|
||||||
|
* The name of this parameter.
|
||||||
|
*/
|
||||||
public String mVarName;
|
public String mVarName;
|
||||||
|
/**
|
||||||
|
* True if this paramter is marked as input parameter, otherwise false.
|
||||||
|
* <p>
|
||||||
|
* Input parameter and output paramter is commonly used in C/C++ code. By using
|
||||||
|
* this feature, each function can receive multiple arguments and return
|
||||||
|
* multiple arguments without defining a struct to hold it.
|
||||||
|
* <p>
|
||||||
|
* The type of input parameter is itself. However, the type of output parameter
|
||||||
|
* is the pointer of itself. So you may need get its pointer type when
|
||||||
|
* processing output paramter, especially for the scenario that the target
|
||||||
|
* language do not support explicit output parameter keyword.
|
||||||
|
*/
|
||||||
public boolean mIsInput;
|
public boolean mIsInput;
|
||||||
|
/**
|
||||||
|
* The description of this parameter.
|
||||||
|
* <p>
|
||||||
|
* This description is generated by this program. It will indicate the
|
||||||
|
* underlying C++ type to tell end user how to treat this paramter because some
|
||||||
|
* target languages' native calling style can not represent these detail.
|
||||||
|
* <p>
|
||||||
|
* In this program, this field must be written as a annotation of corresponding
|
||||||
|
* function.
|
||||||
|
*/
|
||||||
public String mVarDesc;
|
public String mVarDesc;
|
||||||
|
|
||||||
public ExpFctParamDecl() {
|
public ExpFctParamDecl() {
|
||||||
mVarType = new VariableType();
|
mVarType = new VariableType();
|
||||||
mVarName = "";
|
mVarName = "";
|
||||||
mVarDesc = "";
|
mVarDesc = "";
|
||||||
mIsInput = true;
|
mIsInput = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
lexer grammar ExpFctsLexer;
|
lexer grammar ExpFctsLexer;
|
||||||
|
|
||||||
// keywords
|
// keywords
|
||||||
EXPFCTS_EXPORT: 'LIBCMO_EXPORT' ;
|
EXPFCTS_EXPORT: 'BMAP_EXPORT' ;
|
||||||
EXPFCTS_FILE_DECL: 'BMPARAM_FILE_DECL' ;
|
EXPFCTS_FILE_DECL: 'BMPARAM_FILE_DECL' ;
|
||||||
EXPFCTS_MESHTRANS_DECL: 'BMPARAM_MESHTRANS_DECL' ;
|
EXPFCTS_MESHTRANS_DECL: 'BMPARAM_MESHTRANS_DECL' ;
|
||||||
EXPFCTS_OBJECT_DECL: 'BMPARAM_OBJECT_DECL' ;
|
EXPFCTS_OBJECT_DECL: 'BMPARAM_OBJECT_DECL' ;
|
||||||
|
@ -9,7 +9,10 @@ with open(src_file, 'r', encoding='utf-8') as fsrc:
|
|||||||
fulltext: str = fsrc.read()
|
fulltext: str = fsrc.read()
|
||||||
# do findall and write into file
|
# do findall and write into file
|
||||||
with open(dst_file, 'w', encoding='utf-8') as fdst:
|
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(item)
|
||||||
fdst.write('\n')
|
fdst.write('\n')
|
||||||
|
|
||||||
|
@ -39,19 +39,29 @@ public class PythonWriter {
|
|||||||
return Collections.unmodifiableMap(cache);
|
return Collections.unmodifiableMap(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String pythonTypeGetter(ExpFctParamDecl paramdecl) {
|
private static String pythonTypeGetter(ExpFctParamDecl paramdecl) throws IllegalArgumentException {
|
||||||
VariableType vt = paramdecl.mVarType;
|
VariableType vt = paramdecl.mVarType;
|
||||||
if (!paramdecl.mIsInput) {
|
if (!paramdecl.mIsInput) {
|
||||||
vt = vt.getPointerOfThis();
|
vt = vt.getPointerOfThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create string builder for build final type string
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
// add type prefix
|
||||||
sb.append("bm_");
|
sb.append("bm_");
|
||||||
sb.append(g_CppTypeMap.get(vt.getBaseType()));
|
// try getting cpp type from base type
|
||||||
|
String cpp_type = g_CppTypeMap.get(vt.getBaseType());
|
||||||
|
if (cpp_type == null) {
|
||||||
|
throw new IllegalArgumentException("Unexpected type: " + vt.toCType());
|
||||||
|
}
|
||||||
|
// assign cpp type
|
||||||
|
sb.append(cpp_type);
|
||||||
|
// add pointer suffix
|
||||||
if (vt.isPointer()) {
|
if (vt.isPointer()) {
|
||||||
sb.append("_");
|
sb.append("_");
|
||||||
sb.append(String.join("", Collections.nCopies(vt.getPointerLevel(), "p")));
|
sb.append(String.join("", Collections.nCopies(vt.getPointerLevel(), "p")));
|
||||||
}
|
}
|
||||||
|
// return built type string.
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,15 +69,7 @@ public class PythonWriter {
|
|||||||
OutputStreamWriter writer = CommonHelper.openWriter("dest/BMExports.py");
|
OutputStreamWriter writer = CommonHelper.openWriter("dest/BMExports.py");
|
||||||
IndentHelper helper = new IndentHelper(writer);
|
IndentHelper helper = new IndentHelper(writer);
|
||||||
|
|
||||||
// write snippet
|
|
||||||
CommonHelper.writeSnippet(writer, "snippets/header.py");
|
|
||||||
|
|
||||||
// write function decls
|
// write function decls
|
||||||
|
|
||||||
helper.puts("");
|
|
||||||
helper.puts("#region Function Defines");
|
|
||||||
helper.puts("");
|
|
||||||
|
|
||||||
for (ExpFctDecl fctdecl : data) {
|
for (ExpFctDecl fctdecl : data) {
|
||||||
// write annotation
|
// write annotation
|
||||||
// function name
|
// function name
|
||||||
@ -87,10 +89,6 @@ public class PythonWriter {
|
|||||||
.stream().map(value -> pythonTypeGetter(value)).collect(Collectors.joining(", ")));
|
.stream().map(value -> pythonTypeGetter(value)).collect(Collectors.joining(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
helper.puts("");
|
|
||||||
helper.puts("#endregion");
|
|
||||||
helper.puts("");
|
|
||||||
|
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,28 +2,51 @@ import java.util.Collections;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class represent the type of each parameters and function return value.
|
||||||
|
*/
|
||||||
public class VariableType {
|
public class VariableType {
|
||||||
/**
|
/**
|
||||||
* The base type of this variable which remove all ending stars. Each item is a
|
* The base type of this variable removing all ending stars (remove all pointer
|
||||||
* part of namespace string. If no namespace, this Vector will only have one
|
* levels) Each item in this a part of namespace and the last one must be the
|
||||||
* item.
|
* type itself (without any namespace restriction). If no namespace restriction
|
||||||
|
* for this type, this Vector will only have one item.
|
||||||
|
* <p>
|
||||||
|
* For end user, it is enough that knowing the last item is type itself.
|
||||||
*/
|
*/
|
||||||
private Vector<String> mBaseType;
|
private Vector<String> mBaseType;
|
||||||
/**
|
/**
|
||||||
* The pointer level of this type. It is equal with the count of stars.
|
* The pointer level of this type. It is equal to the count of trailing star of
|
||||||
|
* this field in C style representation.
|
||||||
*/
|
*/
|
||||||
private int mPointerLevel;
|
private int mPointerLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct an empty varible type. This is commonly used constructor.
|
||||||
|
*/
|
||||||
public VariableType() {
|
public VariableType() {
|
||||||
mBaseType = new Vector<String>();
|
mBaseType = new Vector<String>();
|
||||||
mPointerLevel = 0;
|
mPointerLevel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor used for cloning self. This constructor is only can be used
|
||||||
|
* by self.
|
||||||
|
*
|
||||||
|
* @param base_type The hierarchy of the variable type.
|
||||||
|
* @param pointer_level The pointer level of new created variable type.
|
||||||
|
*/
|
||||||
private VariableType(Vector<String> base_type, int pointer_level) {
|
private VariableType(Vector<String> base_type, int pointer_level) {
|
||||||
mBaseType = (Vector<String>) base_type.clone();
|
mBaseType = (Vector<String>) base_type.clone();
|
||||||
mPointerLevel = pointer_level;
|
mPointerLevel = pointer_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set this variable type with a type string in C/C++ style. For example
|
||||||
|
* "NSTest::NSTest2::MyType**".
|
||||||
|
*
|
||||||
|
* @param ctype The type string in C/C++ style.
|
||||||
|
*/
|
||||||
public void fromCType(String ctype) {
|
public void fromCType(String ctype) {
|
||||||
if (ctype.isEmpty())
|
if (ctype.isEmpty())
|
||||||
throw new IllegalArgumentException("empty string can not be parsed.");
|
throw new IllegalArgumentException("empty string can not be parsed.");
|
||||||
@ -43,7 +66,7 @@ public class VariableType {
|
|||||||
namepart = ctype.substring(0, star_pos);
|
namepart = ctype.substring(0, star_pos);
|
||||||
mPointerLevel = len - star_pos;
|
mPointerLevel = len - star_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve name part
|
// resolve name part
|
||||||
mBaseType.clear();
|
mBaseType.clear();
|
||||||
for (String item : namepart.split("::")) {
|
for (String item : namepart.split("::")) {
|
||||||
@ -51,31 +74,78 @@ public class VariableType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a type string represented by this variable type in C/C++ style.
|
||||||
|
*
|
||||||
|
* @return The type string in C/C++ style.
|
||||||
|
*/
|
||||||
public String toCType() {
|
public String toCType() {
|
||||||
return mBaseType.stream().collect(Collectors.joining("::"))
|
return mBaseType.stream().collect(Collectors.joining("::"))
|
||||||
+ String.join("", Collections.nCopies(mPointerLevel, "*"));
|
+ String.join("", Collections.nCopies(mPointerLevel, "*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the base type of this variable type without any namespace. It just simply
|
||||||
|
* get the last entry in type hierarchy.
|
||||||
|
*
|
||||||
|
* @return The base type string without namespace prefix.
|
||||||
|
*/
|
||||||
public String getBaseType() {
|
public String getBaseType() {
|
||||||
return mBaseType.lastElement();
|
return mBaseType.lastElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether this variable type is a pointer. This function just check
|
||||||
|
* whether the pointer level of this variavle type is zero.
|
||||||
|
*
|
||||||
|
* @return True if it is pointer, otherwise false.
|
||||||
|
*/
|
||||||
public boolean isPointer() {
|
public boolean isPointer() {
|
||||||
return mPointerLevel != 0;
|
return mPointerLevel != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the pointer level of this variable type. You can simply assume the
|
||||||
|
* pointer level is equal to the count of trailing star.
|
||||||
|
*
|
||||||
|
* @return The pointer level integer. Zero means that this type is not a
|
||||||
|
* pointer.
|
||||||
|
*/
|
||||||
public int getPointerLevel() {
|
public int getPointerLevel() {
|
||||||
return mPointerLevel;
|
return mPointerLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the clone of the type hierarchy of this variable type.
|
||||||
|
* <p>
|
||||||
|
* It is rarely used. This only should be used when you need the namespace
|
||||||
|
* hierarchy of this variable type.
|
||||||
|
*
|
||||||
|
* @return The clone of current variable type hierarchy.
|
||||||
|
*/
|
||||||
public Vector<String> getBaseTypeHierarchy() {
|
public Vector<String> getBaseTypeHierarchy() {
|
||||||
return (Vector<String>) mBaseType.clone();
|
return (Vector<String>) mBaseType.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether this type is a valid one. It actually check whether type
|
||||||
|
* hierarchy include at least one entry.
|
||||||
|
*
|
||||||
|
* @return True if no problem of this type, otherwise false.
|
||||||
|
*/
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return mBaseType.size() != 0;
|
return mBaseType.size() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new created variable type which is the pointer of this variable
|
||||||
|
* type.
|
||||||
|
* <p>
|
||||||
|
* In internal implementation, it just create a clone of current variable type
|
||||||
|
* with the increase of pointer level by 1.
|
||||||
|
*
|
||||||
|
* @return The new created pointer type of this variable type.
|
||||||
|
*/
|
||||||
public VariableType getPointerOfThis() {
|
public VariableType getPointerOfThis() {
|
||||||
return new VariableType(mBaseType, mPointerLevel + 1);
|
return new VariableType(mBaseType, mPointerLevel + 1);
|
||||||
}
|
}
|
||||||
|
@ -1,106 +0,0 @@
|
|||||||
import ctypes, os, sys, typing
|
|
||||||
|
|
||||||
#region Type Defines
|
|
||||||
|
|
||||||
class BMapException(Exception):
|
|
||||||
"""
|
|
||||||
The exception thrown by BMap bindings.
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
bm_CKSTRING = ctypes.c_char_p
|
|
||||||
bm_CKSTRING_p = ctypes.POINTER(bm_CKSTRING)
|
|
||||||
bm_CKDWORD = ctypes.c_uint32
|
|
||||||
bm_CKDWORD_p = ctypes.POINTER(bm_CKDWORD)
|
|
||||||
bm_CKDWORD_pp = ctypes.POINTER(bm_CKDWORD_p)
|
|
||||||
bm_CKWORD = ctypes.c_uint16
|
|
||||||
bm_CKWORD_p = ctypes.POINTER(bm_CKWORD)
|
|
||||||
bm_CKWORD_pp = ctypes.POINTER(bm_CKWORD_p)
|
|
||||||
bm_CKID = ctypes.c_uint32
|
|
||||||
bm_CKID_p = ctypes.POINTER(bm_CKID)
|
|
||||||
bm_CKID_pp = ctypes.POINTER(bm_CKID_p)
|
|
||||||
bm_CKFLOAT = ctypes.c_float
|
|
||||||
bm_CKFLOAT_p = ctypes.POINTER(bm_CKFLOAT)
|
|
||||||
bm_CKINT = ctypes.c_int32
|
|
||||||
bm_CKBYTE = ctypes.c_uint8
|
|
||||||
bm_CKBYTE_p = ctypes.POINTER(bm_CKBYTE)
|
|
||||||
|
|
||||||
bm_enum = bm_CKDWORD
|
|
||||||
bm_enum_p = ctypes.POINTER(bm_enum)
|
|
||||||
bm_bool = ctypes.c_bool
|
|
||||||
bm_bool_p = ctypes.POINTER(bm_bool)
|
|
||||||
bm_void_p = ctypes.c_void_p
|
|
||||||
bm_void_pp = ctypes.POINTER(ctypes.c_void_p)
|
|
||||||
|
|
||||||
bm_callback = ctypes.CFUNCTYPE(None, bm_CKSTRING)
|
|
||||||
|
|
||||||
class bm_VxVector2(ctypes.Structure):
|
|
||||||
_fields_ = [
|
|
||||||
('x', bm_CKFLOAT),
|
|
||||||
('y', bm_CKFLOAT),
|
|
||||||
]
|
|
||||||
bm_VxVector2_p = ctypes.POINTER(bm_VxVector2)
|
|
||||||
bm_VxVector2_pp = ctypes.POINTER(bm_VxVector2_p)
|
|
||||||
class bm_VxVector3(ctypes.Structure):
|
|
||||||
_fields_ = [
|
|
||||||
('x', bm_CKFLOAT),
|
|
||||||
('y', bm_CKFLOAT),
|
|
||||||
('z', bm_CKFLOAT),
|
|
||||||
]
|
|
||||||
bm_VxVector3_p = ctypes.POINTER(bm_VxVector3)
|
|
||||||
bm_VxVector3_pp = ctypes.POINTER(bm_VxVector3_p)
|
|
||||||
class bm_VxColor(ctypes.Structure):
|
|
||||||
_fields_ = [
|
|
||||||
('r', bm_CKFLOAT),
|
|
||||||
('g', bm_CKFLOAT),
|
|
||||||
('b', bm_CKFLOAT),
|
|
||||||
('a', bm_CKFLOAT),
|
|
||||||
]
|
|
||||||
bm_VxColor_p = ctypes.POINTER(bm_VxColor)
|
|
||||||
class bm_VxMatrix(ctypes.Structure):
|
|
||||||
_fields_ = list(
|
|
||||||
(f'i{idx}', bm_CKFLOAT) for idx in range(16)
|
|
||||||
)
|
|
||||||
bm_VxMatrix_p = ctypes.POINTER(bm_VxMatrix)
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region BMap Loader
|
|
||||||
|
|
||||||
_g_BMapLibName: str
|
|
||||||
|
|
||||||
if sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
|
|
||||||
_g_BMapLibName = "BMap.dll"
|
|
||||||
elif sys.platform.startswith('linux') or sys.platform.startswith('freebsd'):
|
|
||||||
_g_BMapLibName = "BMap.so"
|
|
||||||
elif sys.platform.startswith('darwin'):
|
|
||||||
_g_BMapLibName = "BMap.dylib"
|
|
||||||
else:
|
|
||||||
_g_BMapLibName = "BMap.bin"
|
|
||||||
|
|
||||||
_g_BMapModule: ctypes.CDLL | None = None
|
|
||||||
try:
|
|
||||||
_g_BMapModule = ctypes.cdll.LoadLibrary(
|
|
||||||
os.path.join(os.path.dirname(__file__), _g_BMapLibName)
|
|
||||||
)
|
|
||||||
except:
|
|
||||||
_g_BMapModule = None
|
|
||||||
|
|
||||||
def is_bmap_available() -> bool:
|
|
||||||
return _g_BMapModule is not None
|
|
||||||
|
|
||||||
def _bmap_error_check(result: bool, func, args):
|
|
||||||
if not result:
|
|
||||||
raise BMapException("BMap operation failed.")
|
|
||||||
return result
|
|
||||||
|
|
||||||
def _create_bmap_func(fct_name: str, fct_params: list[typing.Any]) -> typing.Callable[..., bm_bool]:
|
|
||||||
if _g_BMapModule is None: return None
|
|
||||||
|
|
||||||
cache: typing.Callable[..., bm_bool] = getattr(_g_BMapModule, fct_name)
|
|
||||||
cache.argtypes = fct_params
|
|
||||||
cache.restype = bm_bool
|
|
||||||
cache.errcheck = _bmap_error_check
|
|
||||||
return cache
|
|
||||||
|
|
||||||
#endregion
|
|
3
CodeGen/EnumsMigration/.gitignore
vendored
3
CodeGen/EnumsMigration/.gitignore
vendored
@ -2,7 +2,7 @@
|
|||||||
dest/*
|
dest/*
|
||||||
!dest/*.gitkeep
|
!dest/*.gitkeep
|
||||||
|
|
||||||
# Antlr output
|
# ===== ANTLR Output =====
|
||||||
*.interp
|
*.interp
|
||||||
*.tokens
|
*.tokens
|
||||||
|
|
||||||
@ -10,6 +10,7 @@ CKGeneralLexer*.java
|
|||||||
CKEnumsParser*.java
|
CKEnumsParser*.java
|
||||||
CKDefinesParser*.java
|
CKDefinesParser*.java
|
||||||
|
|
||||||
|
# ===== Eclipse Java =====
|
||||||
# Eclipse projects
|
# Eclipse projects
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
|
168
CodeGen/EnumsMigration/CSharpWriter.java
Normal file
168
CodeGen/EnumsMigration/CSharpWriter.java
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write enum declarations and accessible value into CSharp format.
|
||||||
|
*/
|
||||||
|
public class CSharpWriter {
|
||||||
|
|
||||||
|
// =========== C# Enum Declaration Writer ===========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get corredponding C# underlying type of given enum.
|
||||||
|
* <p>
|
||||||
|
* This is C# specific function.
|
||||||
|
*
|
||||||
|
* @param canUnsigned The parameter stored in Enum_t that indicate whether this
|
||||||
|
* enum can use unsigned int as its underlying type.
|
||||||
|
* @return The string form of its underlying type.
|
||||||
|
*/
|
||||||
|
private static String getEnumUnderlyingType(boolean canUnsigned) {
|
||||||
|
return canUnsigned ? "uint" : "int";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal real enum declaration writer.
|
||||||
|
*
|
||||||
|
* @param writer {@linkplain java.io.OutputStreamWriter} instance for writing.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private static void internalWriteEnums(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog)
|
||||||
|
throws Exception {
|
||||||
|
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.CSharp);
|
||||||
|
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
||||||
|
// write enum comment
|
||||||
|
indent.briefComment(enum_t.mEnumComment);
|
||||||
|
|
||||||
|
// write enum start
|
||||||
|
// write flasg attribute if it is
|
||||||
|
if (enum_t.mUseFlags) {
|
||||||
|
indent.puts("[Flags]");
|
||||||
|
}
|
||||||
|
indent.printf("public enum %s : %s {", enum_t.mEnumName, getEnumUnderlyingType(enum_t.mCanUnsigned));
|
||||||
|
indent.inc();
|
||||||
|
|
||||||
|
// write enum entries
|
||||||
|
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
||||||
|
// write entry self
|
||||||
|
if (enumEntry_t.mEntryValue == null) {
|
||||||
|
indent.printf("%s,", enumEntry_t.mEntryName);
|
||||||
|
} else {
|
||||||
|
indent.printf("%s = %s,", enumEntry_t.mEntryName, enumEntry_t.mEntryValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write entry comment after member
|
||||||
|
indent.afterMemberComment(enumEntry_t.mEntryComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write enum tail
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an enum declaration collection into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum declaration collection writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for
|
||||||
|
* writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeEnums(String filename, EnumsHelper.EnumCollection_t prog) throws Exception {
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteEnums(fs, prog);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a single enum declaration into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum declaration collection writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param _enum {@linkplain EnumsHelper.Enum_t} instance for writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeEnum(String filename, EnumsHelper.Enum_t _enum) throws Exception {
|
||||||
|
// create collection from single enum
|
||||||
|
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
|
||||||
|
col.mEnums.add(_enum);
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteEnums(fs, col);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========== C# Enum Accessible Value Writer ===========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal real enum accessible value writer.
|
||||||
|
*
|
||||||
|
* @param writer {@linkplain java.io.OutputStreamWriter} instance for writing.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private static void internalWriteAccVals(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog)
|
||||||
|
throws Exception {
|
||||||
|
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.CSharp);
|
||||||
|
// write enum collections
|
||||||
|
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
||||||
|
// write enum desc header
|
||||||
|
indent.printf(
|
||||||
|
"public static readonly System.Collections.Generic.Dictionary<%s, string> %s = new System.Collections.Generic.Dictionary<%s, string>() {",
|
||||||
|
enum_t.mEnumName, enum_t.mEnumName, enum_t.mEnumName);
|
||||||
|
indent.inc();
|
||||||
|
|
||||||
|
// write enum desc entries
|
||||||
|
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
||||||
|
indent.printf("{ %s.%s, \"%s\" },", enum_t.mEnumName, enumEntry_t.mEntryName, enumEntry_t.mEntryName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write enum tail
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("};");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an enum accessible value collection into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum accessible value collection
|
||||||
|
* writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for
|
||||||
|
* writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeAccVals(String filename, EnumsHelper.EnumCollection_t prog) throws Exception {
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteAccVals(fs, prog);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a single enum accessible value into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum accessible value collection
|
||||||
|
* writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param _enum {@linkplain EnumsHelper.Enum_t} instance for writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeAccVal(String filename, EnumsHelper.Enum_t _enum) throws Exception {
|
||||||
|
// create a collection with single enum.
|
||||||
|
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
|
||||||
|
col.mEnums.add(_enum);
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteAccVals(fs, col);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
}
|
@ -1,28 +0,0 @@
|
|||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The nameof values writer for CK_CLASSID.
|
|
||||||
*/
|
|
||||||
public class ClassidWriter {
|
|
||||||
|
|
||||||
public static void writeAccVal(String filename, EnumsHelper.Enum_t classids) throws Exception {
|
|
||||||
OutputStreamWriter writer = CommonHelper.openOutputFile(filename);
|
|
||||||
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.CPP);
|
|
||||||
|
|
||||||
indent.puts("const CkClassidReflectionArray CK_CLASSID {");
|
|
||||||
indent.inc();
|
|
||||||
for (EnumsHelper.EnumEntry_t entry : classids.mEntries) {
|
|
||||||
EnumsHelper.EnumEntryWithHierarchy_t specialized = (EnumsHelper.EnumEntryWithHierarchy_t) entry;
|
|
||||||
|
|
||||||
String hierarchy = specialized.mHierarchy.stream().map(value -> value.mEntryName)
|
|
||||||
.collect(Collectors.joining("\", \""));
|
|
||||||
indent.printf("{ LibCmo::CK2::CK_CLASSID::%s, { { \"%s\" } } },", entry.mEntryName, hierarchy);
|
|
||||||
}
|
|
||||||
indent.dec();
|
|
||||||
indent.puts("};");
|
|
||||||
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -4,7 +4,6 @@ import java.io.OutputStreamWriter;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.antlr.v4.runtime.*;
|
import org.antlr.v4.runtime.*;
|
||||||
|
|
||||||
@ -110,17 +109,6 @@ public class CommonHelper {
|
|||||||
return numstr.replaceFirst("[ulUL]+$", "");
|
return numstr.replaceFirst("[ulUL]+$", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get underlying type of enum.
|
|
||||||
*
|
|
||||||
* @param canUnsigned The parameter stored in Enum_t that indiccate whether this
|
|
||||||
* enum can use unsigned int as its underlying type.
|
|
||||||
* @return The string form of its underlying type.
|
|
||||||
*/
|
|
||||||
public static String getEnumUnderlyingType(boolean canUnsigned) {
|
|
||||||
return canUnsigned ? "CKDWORD" : "CKINT";
|
|
||||||
}
|
|
||||||
|
|
||||||
// =========== Parts ===========
|
// =========== Parts ===========
|
||||||
|
|
||||||
enum CKParts {
|
enum CKParts {
|
||||||
@ -128,7 +116,7 @@ public class CommonHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum LangType {
|
enum LangType {
|
||||||
CPP, Python
|
Cpp, Python, CSharp
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCKPartsNamespace(CKParts parts) {
|
public static String getCKPartsNamespace(CKParts parts) {
|
||||||
|
273
CodeGen/EnumsMigration/CppWriter.java
Normal file
273
CodeGen/EnumsMigration/CppWriter.java
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write enum declarations and accessible value into C++ format.
|
||||||
|
*/
|
||||||
|
public class CppWriter {
|
||||||
|
|
||||||
|
// =========== C++ Enum Declaration Writer ===========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get corredponding C++ underlying type of given enum.
|
||||||
|
* <p>
|
||||||
|
* This is C++ specific function.
|
||||||
|
*
|
||||||
|
* @param canUnsigned The parameter stored in Enum_t that indicate whether this
|
||||||
|
* enum can use unsigned int as its underlying type.
|
||||||
|
* @return The string form of its underlying type.
|
||||||
|
*/
|
||||||
|
private static String getEnumUnderlyingType(boolean canUnsigned) {
|
||||||
|
return canUnsigned ? "CKDWORD" : "CKINT";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal real enum declarations writer.
|
||||||
|
*
|
||||||
|
* @param writer {@linkplain java.io.OutputStreamWriter} instance for writing.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private static void internalWriteEnums(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog)
|
||||||
|
throws Exception {
|
||||||
|
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.Cpp);
|
||||||
|
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
||||||
|
// write enum comment
|
||||||
|
indent.briefComment(enum_t.mEnumComment);
|
||||||
|
|
||||||
|
// write enum start
|
||||||
|
indent.printf("enum class %s : %s {", enum_t.mEnumName, getEnumUnderlyingType(enum_t.mCanUnsigned));
|
||||||
|
indent.inc();
|
||||||
|
|
||||||
|
// write enum entries
|
||||||
|
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
||||||
|
// write entry self
|
||||||
|
if (enumEntry_t.mEntryValue == null) {
|
||||||
|
indent.printf("%s,", enumEntry_t.mEntryName);
|
||||||
|
} else {
|
||||||
|
indent.printf("%s = %s,", enumEntry_t.mEntryName, enumEntry_t.mEntryValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write entry comment after member
|
||||||
|
indent.afterMemberComment(enumEntry_t.mEntryComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write enum tail
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("};");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an enum collection into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum collection writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for
|
||||||
|
* writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeEnums(String filename, EnumsHelper.EnumCollection_t prog) throws Exception {
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteEnums(fs, prog);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a single enum into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum collection writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param _enum {@linkplain EnumsHelper.Enum_t} instance for writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeEnum(String filename, EnumsHelper.Enum_t _enum) throws Exception {
|
||||||
|
// create an collection from single enum declaration
|
||||||
|
// for suit the argument requirement of real writer.
|
||||||
|
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
|
||||||
|
col.mEnums.add(_enum);
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteEnums(fs, col);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========== C++ Enum Accessible Value Writer ===========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal real enum collection accessible value writer.
|
||||||
|
*
|
||||||
|
* @param writer {@linkplain java.io.OutputStreamWriter} instance for writing.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for writing.
|
||||||
|
* @param parts The part of these enum declarations. It will indicate the
|
||||||
|
* namespace where find given enum collection.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private static void internalWriteAccVals(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog,
|
||||||
|
CommonHelper.CKParts parts) throws Exception {
|
||||||
|
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.Cpp);
|
||||||
|
|
||||||
|
// write type defination (just to let user know what the type is)
|
||||||
|
indent.puts("// struct GeneralReflection { const char8_t* mName; };");
|
||||||
|
indent.puts("// template<typename _Ty, std::enable_if_t<std::is_enum_v<_Ty>, int> = 0>");
|
||||||
|
indent.puts("// using GeneralReflectionArray = std::vector<std::pair<_Ty, GeneralReflection>>;");
|
||||||
|
|
||||||
|
indent.puts("");
|
||||||
|
indent.puts("");
|
||||||
|
indent.puts("");
|
||||||
|
|
||||||
|
// write declarations
|
||||||
|
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
||||||
|
indent.printf("extern const GeneralReflectionArray<LibCmo::%s::%s> %s;",
|
||||||
|
CommonHelper.getCKPartsNamespace(parts), enum_t.mEnumName, enum_t.mEnumName);
|
||||||
|
}
|
||||||
|
|
||||||
|
indent.puts("");
|
||||||
|
indent.puts("");
|
||||||
|
indent.puts("");
|
||||||
|
|
||||||
|
// write implements
|
||||||
|
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
||||||
|
// write enum desc header
|
||||||
|
indent.printf("const GeneralReflectionArray<LibCmo::%s::%s> %s {", CommonHelper.getCKPartsNamespace(parts),
|
||||||
|
enum_t.mEnumName, enum_t.mEnumName);
|
||||||
|
indent.inc();
|
||||||
|
|
||||||
|
// write enum desc entries
|
||||||
|
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
||||||
|
indent.printf("{ LibCmo::%s::%s::%s, { u8\"%s\" } },", CommonHelper.getCKPartsNamespace(parts),
|
||||||
|
enum_t.mEnumName, enumEntry_t.mEntryName, enumEntry_t.mEntryName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write enum tail
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("};");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an enum collection accessible value into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum collection accessible value
|
||||||
|
* writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for
|
||||||
|
* writing.
|
||||||
|
* @param parts The part of these enum declarations.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeAccVals(String filename, EnumsHelper.EnumCollection_t prog, CommonHelper.CKParts parts)
|
||||||
|
throws Exception {
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteAccVals(fs, prog, parts);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a single enum accessible value into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum collection accessible value
|
||||||
|
* writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param _enum {@linkplain EnumsHelper.Enum_t} instance for writing.
|
||||||
|
* @param parts The part of these enum declarations.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeAccVal(String filename, EnumsHelper.Enum_t _enum, CommonHelper.CKParts parts)
|
||||||
|
throws Exception {
|
||||||
|
// create a enum collection to fulfill the requirement of internal writer.
|
||||||
|
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
|
||||||
|
col.mEnums.add(_enum);
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteAccVals(fs, col, parts);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========== Specialized C++ Enum Accessible Value Writer ===========
|
||||||
|
// Only accessible value part of CERROR and CK_CLASSID need to be specialized.
|
||||||
|
// The enum self do not need special treat. Just write them normally.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specialized CKERROR accessible value writer.
|
||||||
|
* <p>
|
||||||
|
* The declaration of CKERROR do not need special treat. It is okey to use
|
||||||
|
* common writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param errors The {@linkplain EnumsHelper.Enum_t} instance storing CKERROR.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeCkErrorAccVal(String filename, EnumsHelper.Enum_t errors) throws Exception {
|
||||||
|
OutputStreamWriter writer = CommonHelper.openOutputFile(filename);
|
||||||
|
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.Cpp);
|
||||||
|
|
||||||
|
// write type defination (just to let user know what the type is)
|
||||||
|
indent.puts("// struct CkErrorReflection { const char8_t* mName; const char8_t* mDescription; };");
|
||||||
|
indent.puts("// using CkErrorReflectionArray = std::vector<std::pair<LibCmo::CK2::CKERROR, CkErrorReflection>>;");
|
||||||
|
|
||||||
|
indent.puts("");
|
||||||
|
indent.puts("");
|
||||||
|
indent.puts("");
|
||||||
|
|
||||||
|
// write implementation
|
||||||
|
indent.puts("const CkErrorReflectionArray CKERROR {");
|
||||||
|
indent.inc();
|
||||||
|
for (EnumsHelper.EnumEntry_t entry : errors.mEntries) {
|
||||||
|
String comment = CommonHelper.escapeString(entry.mEntryComment);
|
||||||
|
if (comment == null)
|
||||||
|
comment = "";
|
||||||
|
|
||||||
|
indent.printf("{ LibCmo::CK2::CKERROR::%s, { u8\"%s\", u8\"%s\" } },", entry.mEntryName, entry.mEntryName,
|
||||||
|
comment);
|
||||||
|
}
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("};");
|
||||||
|
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specialized CK_CLASSID accessible value writer.
|
||||||
|
* <p>
|
||||||
|
* The declaration of CK_CLASSID do not need special treat. It is okey to use
|
||||||
|
* common writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param classids The {@linkplain EnumsHelper.Enum_t} instance storing
|
||||||
|
* CK_CLASSID.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeCkClassidAccVal(String filename, EnumsHelper.Enum_t classids) throws Exception {
|
||||||
|
OutputStreamWriter writer = CommonHelper.openOutputFile(filename);
|
||||||
|
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.Cpp);
|
||||||
|
|
||||||
|
// write type defination (just to let user know what the type is)
|
||||||
|
indent.puts("// struct CkClassidReflection { std::vector<const char8_t*> mHierarchy; };");
|
||||||
|
indent.puts("// using CkClassidReflectionArray = std::vector<std::pair<LibCmo::CK2::CK_CLASSID, CkClassidReflection>>;");
|
||||||
|
|
||||||
|
indent.puts("");
|
||||||
|
indent.puts("");
|
||||||
|
indent.puts("");
|
||||||
|
|
||||||
|
indent.puts("const CkClassidReflectionArray CK_CLASSID {");
|
||||||
|
indent.inc();
|
||||||
|
for (EnumsHelper.EnumEntry_t entry : classids.mEntries) {
|
||||||
|
EnumsHelper.EnumEntryWithHierarchy_t specialized = (EnumsHelper.EnumEntryWithHierarchy_t) entry;
|
||||||
|
|
||||||
|
String hierarchy = specialized.mHierarchy.stream().map(value -> value.mEntryName)
|
||||||
|
.collect(Collectors.joining("\", u8\""));
|
||||||
|
indent.printf("{ LibCmo::CK2::CK_CLASSID::%s, { { u8\"%s\" } } },", entry.mEntryName, hierarchy);
|
||||||
|
}
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("};");
|
||||||
|
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
}
|
@ -1,26 +0,0 @@
|
|||||||
import java.io.OutputStreamWriter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The nameof values writer for CKERROR
|
|
||||||
*/
|
|
||||||
public class ErrorsWriter {
|
|
||||||
public static void writeAccVal(String filename, EnumsHelper.Enum_t errors) throws Exception {
|
|
||||||
OutputStreamWriter writer = CommonHelper.openOutputFile(filename);
|
|
||||||
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.CPP);
|
|
||||||
|
|
||||||
indent.puts("const CkErrorReflectionArray CKERROR {");
|
|
||||||
indent.inc();
|
|
||||||
for (EnumsHelper.EnumEntry_t entry : errors.mEntries) {
|
|
||||||
String comment = CommonHelper.escapeString(entry.mEntryComment);
|
|
||||||
if (comment == null)
|
|
||||||
comment = "";
|
|
||||||
|
|
||||||
indent.printf("{ LibCmo::CK2::CKERROR::%s, { \"%s\", \"%s\" } },", entry.mEntryName, entry.mEntryName,
|
|
||||||
comment);
|
|
||||||
}
|
|
||||||
indent.dec();
|
|
||||||
indent.puts("};");
|
|
||||||
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,212 +0,0 @@
|
|||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic Enum Writer. Including Data Type Defination and Nameof Values.
|
|
||||||
*/
|
|
||||||
public class GeneralWriter {
|
|
||||||
|
|
||||||
public static void writeEnums(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog) throws Exception {
|
|
||||||
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.CPP);
|
|
||||||
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
|
||||||
// write enum comment
|
|
||||||
indent.briefComment(enum_t.mEnumComment);
|
|
||||||
|
|
||||||
// write enum start
|
|
||||||
indent.printf("enum class %s : %s {", enum_t.mEnumName,
|
|
||||||
CommonHelper.getEnumUnderlyingType(enum_t.mCanUnsigned));
|
|
||||||
indent.inc();
|
|
||||||
|
|
||||||
// write enum entries
|
|
||||||
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
|
||||||
// write entry self
|
|
||||||
if (enumEntry_t.mEntryValue == null) {
|
|
||||||
indent.printf("%s,", enumEntry_t.mEntryName);
|
|
||||||
} else {
|
|
||||||
indent.printf("%s = %s,", enumEntry_t.mEntryName, enumEntry_t.mEntryValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write entry comment after member
|
|
||||||
indent.afterMemberComment(enumEntry_t.mEntryComment);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write enum tail
|
|
||||||
indent.dec();
|
|
||||||
indent.puts("};");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeEnums(String filename, EnumsHelper.EnumCollection_t prog) throws Exception {
|
|
||||||
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
|
||||||
writeEnums(fs, prog);
|
|
||||||
fs.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeEnum(OutputStreamWriter writer, EnumsHelper.Enum_t _enum) throws Exception {
|
|
||||||
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
|
|
||||||
col.mEnums.add(_enum);
|
|
||||||
writeEnums(writer, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeEnum(String filename, EnumsHelper.Enum_t _enum) throws Exception {
|
|
||||||
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
|
||||||
writeEnum(fs, _enum);
|
|
||||||
fs.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeAccVals(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog,
|
|
||||||
CommonHelper.CKParts parts) throws Exception {
|
|
||||||
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.CPP);
|
|
||||||
// write decls
|
|
||||||
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
|
||||||
indent.printf("extern const GeneralReflectionArray<LibCmo::%s::%s> %s;",
|
|
||||||
CommonHelper.getCKPartsNamespace(parts), enum_t.mEnumName, enum_t.mEnumName);
|
|
||||||
}
|
|
||||||
|
|
||||||
indent.puts("");
|
|
||||||
indent.puts("");
|
|
||||||
indent.puts("");
|
|
||||||
|
|
||||||
// write implements
|
|
||||||
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
|
||||||
// write enum desc header
|
|
||||||
indent.printf("const GeneralReflectionArray<LibCmo::%s::%s> %s {", CommonHelper.getCKPartsNamespace(parts),
|
|
||||||
enum_t.mEnumName, enum_t.mEnumName);
|
|
||||||
indent.inc();
|
|
||||||
|
|
||||||
// write enum desc entries
|
|
||||||
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
|
||||||
indent.printf("{ LibCmo::%s::%s::%s, {\"%s\"} },", CommonHelper.getCKPartsNamespace(parts),
|
|
||||||
enum_t.mEnumName, enumEntry_t.mEntryName, enumEntry_t.mEntryName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write enum tail
|
|
||||||
indent.dec();
|
|
||||||
indent.puts("};");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeAccVals(String filename, EnumsHelper.EnumCollection_t prog, CommonHelper.CKParts parts)
|
|
||||||
throws Exception {
|
|
||||||
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
|
||||||
writeAccVals(fs, prog, parts);
|
|
||||||
fs.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeAccVal(OutputStreamWriter writer, EnumsHelper.Enum_t _enum, CommonHelper.CKParts parts)
|
|
||||||
throws Exception {
|
|
||||||
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
|
|
||||||
col.mEnums.add(_enum);
|
|
||||||
writeAccVals(writer, col, parts);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeAccVal(String filename, EnumsHelper.Enum_t _enum, CommonHelper.CKParts parts)
|
|
||||||
throws Exception {
|
|
||||||
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
|
||||||
writeAccVal(fs, _enum, parts);
|
|
||||||
fs.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writePyEnums(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog) throws Exception {
|
|
||||||
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.Python);
|
|
||||||
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
|
||||||
// write enum start
|
|
||||||
indent.printf("class %s(enum.IntEnum):", enum_t.mEnumName);
|
|
||||||
indent.inc();
|
|
||||||
|
|
||||||
// write enum comment
|
|
||||||
indent.briefComment(enum_t.mEnumComment);
|
|
||||||
|
|
||||||
// write enum entries
|
|
||||||
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
|
||||||
// write entry self
|
|
||||||
if (enumEntry_t.mEntryValue == null) {
|
|
||||||
indent.printf("%s = auto()", enumEntry_t.mEntryName);
|
|
||||||
} else {
|
|
||||||
indent.printf("%s = %s", enumEntry_t.mEntryName,
|
|
||||||
CommonHelper.convertToPythonNumber(enumEntry_t.mEntryValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
// write entry comment after member
|
|
||||||
indent.afterMemberComment(enumEntry_t.mEntryComment);
|
|
||||||
}
|
|
||||||
|
|
||||||
// enum tail
|
|
||||||
indent.dec();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writePyEnums(String filename, EnumsHelper.EnumCollection_t prog) throws Exception {
|
|
||||||
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
|
||||||
writePyEnums(fs, prog);
|
|
||||||
fs.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writePyEnum(OutputStreamWriter writer, EnumsHelper.Enum_t _enum) throws Exception {
|
|
||||||
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
|
|
||||||
col.mEnums.add(_enum);
|
|
||||||
writePyEnums(writer, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writePyEnum(String filename, EnumsHelper.Enum_t _enum) throws Exception {
|
|
||||||
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
|
||||||
writePyEnum(fs, _enum);
|
|
||||||
fs.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String extractHumanReadableEntryName(String entry_name) {
|
|
||||||
// remove first part (any content before underline '_')
|
|
||||||
entry_name = entry_name.replaceFirst("^[a-zA-Z0-9]+_", "");
|
|
||||||
|
|
||||||
// lower all chars except first char
|
|
||||||
if (entry_name.length() < 1)
|
|
||||||
return entry_name;
|
|
||||||
else
|
|
||||||
return entry_name.substring(0, 1) + entry_name.substring(1).toLowerCase(Locale.ROOT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writePyAccVals(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog) throws Exception {
|
|
||||||
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.Python);
|
|
||||||
|
|
||||||
// write implements
|
|
||||||
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
|
||||||
// write enum desc header
|
|
||||||
indent.printf("g_Annotation_%s: dict[int, EnumAnnotation] = {", enum_t.mEnumName);
|
|
||||||
indent.inc();
|
|
||||||
|
|
||||||
// write enum desc entries
|
|
||||||
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
|
||||||
String comment = "";
|
|
||||||
if (enumEntry_t.mEntryComment != null) {
|
|
||||||
comment = CommonHelper.escapeString(enumEntry_t.mEntryComment);
|
|
||||||
}
|
|
||||||
|
|
||||||
indent.printf("%s.%s.value: EnumAnnotation(\"%s\", \"%s\"),", enum_t.mEnumName, enumEntry_t.mEntryName,
|
|
||||||
extractHumanReadableEntryName(enumEntry_t.mEntryName), comment);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write enum tail
|
|
||||||
indent.dec();
|
|
||||||
indent.puts("}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writePyAccVals(String filename, EnumsHelper.EnumCollection_t prog) throws Exception {
|
|
||||||
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
|
||||||
writePyAccVals(fs, prog);
|
|
||||||
fs.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writePyAccVal(OutputStreamWriter writer, EnumsHelper.Enum_t _enum) throws Exception {
|
|
||||||
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
|
|
||||||
col.mEnums.add(_enum);
|
|
||||||
writePyAccVals(writer, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writePyAccVal(String filename, EnumsHelper.Enum_t _enum) throws Exception {
|
|
||||||
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
|
||||||
writePyAccVal(fs, _enum);
|
|
||||||
fs.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -8,7 +8,8 @@ public class IndentHelper {
|
|||||||
|
|
||||||
// set indent chars
|
// set indent chars
|
||||||
switch (mLangType) {
|
switch (mLangType) {
|
||||||
case CPP:
|
case Cpp:
|
||||||
|
case CSharp:
|
||||||
mIndentChars = CommonHelper.getIndentString(true);
|
mIndentChars = CommonHelper.getIndentString(true);
|
||||||
break;
|
break;
|
||||||
case Python:
|
case Python:
|
||||||
@ -67,7 +68,8 @@ public class IndentHelper {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
switch (mLangType) {
|
switch (mLangType) {
|
||||||
case CPP:
|
case Cpp:
|
||||||
|
case CSharp:
|
||||||
puts("/**");
|
puts("/**");
|
||||||
|
|
||||||
mWriter.write(System.lineSeparator());
|
mWriter.write(System.lineSeparator());
|
||||||
@ -100,7 +102,8 @@ public class IndentHelper {
|
|||||||
|
|
||||||
mWriter.write(mIndentChars);
|
mWriter.write(mIndentChars);
|
||||||
switch (mLangType) {
|
switch (mLangType) {
|
||||||
case CPP:
|
case Cpp:
|
||||||
|
case CSharp:
|
||||||
mWriter.write(String.format("/**< %s */", CommonHelper.removeEol(comment)));
|
mWriter.write(String.format("/**< %s */", CommonHelper.removeEol(comment)));
|
||||||
break;
|
break;
|
||||||
case Python:
|
case Python:
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
import java.io.OutputStreamWriter;
|
|
||||||
|
|
||||||
import org.antlr.v4.runtime.*;
|
import org.antlr.v4.runtime.*;
|
||||||
import org.antlr.v4.runtime.tree.*;
|
import org.antlr.v4.runtime.tree.*;
|
||||||
|
|
||||||
public class MainRunner {
|
public class MainRunner {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract an enums collection from given file.
|
||||||
|
* <p>
|
||||||
|
* This function is the most commonly used function for extracting enums.
|
||||||
|
* <p>
|
||||||
|
* This function is used for a file which only contain enum declarations. This
|
||||||
|
* is not suit for extracting CKERROR and CK_CLASSID. For these declarations,
|
||||||
|
* please use their specialized extractor as described following.
|
||||||
|
*
|
||||||
|
* @param infile The file for reading.
|
||||||
|
* @return An {@linkplain EnumsHelper.EnumCollection_t} instance.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
private static EnumsHelper.EnumCollection_t getEnumsCollection(String infile) throws Exception {
|
private static EnumsHelper.EnumCollection_t getEnumsCollection(String infile) throws Exception {
|
||||||
CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile);
|
CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile);
|
||||||
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
|
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
|
||||||
@ -20,6 +31,21 @@ public class MainRunner {
|
|||||||
return worker.getEnums();
|
return worker.getEnums();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a series of "#define" syntax as an enum.
|
||||||
|
* <p>
|
||||||
|
* This function will assume that given file only contain C++ "#define" syntax.
|
||||||
|
* After reading it, it will re-organize it as an enum and return. This only is
|
||||||
|
* used by CKERROR now. But it suit for more scenarios if there are something
|
||||||
|
* like CKERROR in future.
|
||||||
|
*
|
||||||
|
* @param infile The file for reading.
|
||||||
|
* @param assignedEnumName The desired name of organized enum instance.
|
||||||
|
* Contemporary this field should always be "CKERROR"
|
||||||
|
* because no one else is using it.
|
||||||
|
* @return An {@linkplain EnumsHelper.Enum_t} instance.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
private static EnumsHelper.Enum_t organiseDefines(String infile, String assignedEnumName) throws Exception {
|
private static EnumsHelper.Enum_t organiseDefines(String infile, String assignedEnumName) throws Exception {
|
||||||
CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile);
|
CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile);
|
||||||
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
|
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
|
||||||
@ -38,6 +64,22 @@ public class MainRunner {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract a series of macro define as an enum, considering its indent to build
|
||||||
|
* hierarchy.
|
||||||
|
* <p>
|
||||||
|
* This is specialized enum extractor of CK_CLASSID. The given file should use a
|
||||||
|
* series "#define" syntax to describe enum, and use Tab as the indent before
|
||||||
|
* each "#define" syntax to indicate its hierarchy.
|
||||||
|
*
|
||||||
|
* @param infile The file for reading.
|
||||||
|
* @return An {@linkplain EnumsHelper.Enum_t} instance. Actually it is an
|
||||||
|
* instance to {@linkplain EnumsHelper.Enum_t} whose entries is
|
||||||
|
* {@linkplain EnumsHelper.EnumEntryWithHierarchy_t}, the child class of
|
||||||
|
* {@linkplain EnumsHelper.EnumEntry_t} (the entry type of common
|
||||||
|
* {@linkplain EnumsHelper.Enum_t}) with extra hierarchy infos.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
private static EnumsHelper.Enum_t organiseClassid(String infile) throws Exception {
|
private static EnumsHelper.Enum_t organiseClassid(String infile) throws Exception {
|
||||||
CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile);
|
CommonHelper.InputFilePair pair = CommonHelper.openInputFile(infile);
|
||||||
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
|
CKGeneralLexer lexer = new CKGeneralLexer(pair.mAntlrStream);
|
||||||
@ -59,57 +101,74 @@ public class MainRunner {
|
|||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
// =========== CKERROR ===========
|
// =========== CKERROR ===========
|
||||||
EnumsHelper.Enum_t ckerror = organiseDefines("src/CKError.txt", "CKERROR");
|
EnumsHelper.Enum_t ckerror = organiseDefines("src/CKERROR.txt", "CKERROR");
|
||||||
GeneralWriter.writeEnum("dest/CKError.hpp", ckerror);
|
CppWriter.writeEnum("dest/CKERROR.hpp", ckerror);
|
||||||
GeneralWriter.writePyEnum("dest/CKError.py", ckerror);
|
PythonWriter.writeEnum("dest/CKERROR.py", ckerror);
|
||||||
ErrorsWriter.writeAccVal("dest/CKError.AccVal.hpp", ckerror);
|
CSharpWriter.writeEnum("dest/CKERROR.cs", ckerror);
|
||||||
GeneralWriter.writePyAccVal("dest/CKError.AccVal.py", ckerror);
|
CppWriter.writeCkErrorAccVal("dest/CKERROR.AccVal.hpp", ckerror);
|
||||||
|
PythonWriter.writeAccVal("dest/CKERROR.AccVal.py", ckerror);
|
||||||
|
CSharpWriter.writeAccVal("dest/CKERROR.AccVal.cs", ckerror);
|
||||||
|
|
||||||
// =========== CK_CLASSID ===========
|
// =========== CK_CLASSID ===========
|
||||||
EnumsHelper.Enum_t classid = organiseClassid("src/CK_CLASSID.txt");
|
EnumsHelper.Enum_t classid = organiseClassid("src/CK_CLASSID.txt");
|
||||||
GeneralWriter.writeEnum("dest/CK_CLASSID.hpp", classid);
|
CppWriter.writeEnum("dest/CK_CLASSID.hpp", classid);
|
||||||
GeneralWriter.writePyEnum("dest/CK_CLASSID.py", classid);
|
PythonWriter.writeEnum("dest/CK_CLASSID.py", classid);
|
||||||
ClassidWriter.writeAccVal("dest/CK_CLASSID.AccVal.hpp", classid);
|
CSharpWriter.writeEnum("dest/CK_CLASSID.cs", classid);
|
||||||
GeneralWriter.writePyAccVal("dest/CK_CLASSID.AccVal.py", classid);
|
CppWriter.writeCkClassidAccVal("dest/CK_CLASSID.AccVal.hpp", classid);
|
||||||
|
PythonWriter.writeAccVal("dest/CK_CLASSID.AccVal.py", classid);
|
||||||
|
|
||||||
// =========== Define2 ===========
|
// =========== Define2 ===========
|
||||||
// Define2 do not need values.
|
// Define2 do not need annotation output.
|
||||||
|
// Because they are CKStateChunk used value which are not exposed to outside.
|
||||||
EnumsHelper.EnumCollection_t def2 = getEnumsCollection("src/Defines2.txt");
|
EnumsHelper.EnumCollection_t def2 = getEnumsCollection("src/Defines2.txt");
|
||||||
GeneralWriter.writeEnums("dest/CK_CLASSID.hpp", def2);
|
CppWriter.writeEnums("dest/Defines2.hpp", def2);
|
||||||
GeneralWriter.writePyEnums("dest/CK_CLASSID.py", def2);
|
PythonWriter.writeEnums("dest/Defines2.py", def2);
|
||||||
|
CSharpWriter.writeEnums("dest/Defines2.cs", def2);
|
||||||
|
|
||||||
// =========== Combined enums ===========
|
// =========== Combined enums ===========
|
||||||
EnumsHelper.EnumCollection_t ck2Enums = getEnumsCollection("src/CKEnums.txt"),
|
EnumsHelper.EnumCollection_t ck2Enums = getEnumsCollection("src/CKEnums.txt"),
|
||||||
vxEnums = getEnumsCollection("src/VxEnums.txt");
|
vxEnums = getEnumsCollection("src/VxEnums.txt");
|
||||||
GeneralWriter.writeEnums("dest/CKEnums.hpp", ck2Enums);
|
|
||||||
GeneralWriter.writePyEnums("dest/CKEnums.py", ck2Enums);
|
CppWriter.writeEnums("dest/CKEnums.hpp", ck2Enums);
|
||||||
GeneralWriter.writeAccVals("dest/CKEnums.AccVal.hpp", ck2Enums, CommonHelper.CKParts.CK2);
|
PythonWriter.writeEnums("dest/CKEnums.py", ck2Enums);
|
||||||
GeneralWriter.writePyAccVals("dest/CKEnums.AccVal.py", ck2Enums);
|
CSharpWriter.writeEnums("dest/CKEnums.cs", ck2Enums);
|
||||||
GeneralWriter.writeEnums("dest/VxEnums.hpp", vxEnums);
|
CppWriter.writeAccVals("dest/CKEnums.AccVal.hpp", ck2Enums, CommonHelper.CKParts.CK2);
|
||||||
GeneralWriter.writePyEnums("dest/VxEnums.py", vxEnums);
|
PythonWriter.writeAccVals("dest/CKEnums.AccVal.py", ck2Enums);
|
||||||
GeneralWriter.writeAccVals("dest/VxEnums.AccVal.hpp", vxEnums, CommonHelper.CKParts.VxMath);
|
CSharpWriter.writeAccVals("dest/CKEnums.AccVal.cs", ck2Enums);
|
||||||
GeneralWriter.writePyAccVals("dest/VxEnums.AccVal.py", vxEnums);
|
|
||||||
|
CppWriter.writeEnums("dest/VxEnums.hpp", vxEnums);
|
||||||
|
PythonWriter.writeEnums("dest/VxEnums.py", vxEnums);
|
||||||
|
CSharpWriter.writeEnums("dest/VxEnums.cs", vxEnums);
|
||||||
|
CppWriter.writeAccVals("dest/VxEnums.AccVal.hpp", vxEnums, CommonHelper.CKParts.VxMath);
|
||||||
|
PythonWriter.writeAccVals("dest/VxEnums.AccVal.py", vxEnums);
|
||||||
|
CSharpWriter.writeAccVals("dest/VxEnums.AccVal.cs", vxEnums);
|
||||||
|
|
||||||
// =========== Single enums ===========
|
// =========== Single enums ===========
|
||||||
EnumsHelper.Enum_t single;
|
EnumsHelper.Enum_t single;
|
||||||
|
|
||||||
single = organiseDefines("src/CK_STATECHUNK_CHUNKVERSION.txt", "CK_STATECHUNK_CHUNKVERSION");
|
single = organiseDefines("src/CK_STATECHUNK_CHUNKVERSION.txt", "CK_STATECHUNK_CHUNKVERSION");
|
||||||
GeneralWriter.writeEnum("dest/CK_STATECHUNK_CHUNKVERSION.hpp", single);
|
CppWriter.writeEnum("dest/CK_STATECHUNK_CHUNKVERSION.hpp", single);
|
||||||
GeneralWriter.writePyEnum("dest/CK_STATECHUNK_CHUNKVERSION.py", single);
|
PythonWriter.writeEnum("dest/CK_STATECHUNK_CHUNKVERSION.py", single);
|
||||||
GeneralWriter.writeAccVal("dest/CK_STATECHUNK_CHUNKVERSION.AccVal.hpp", single, CommonHelper.CKParts.CK2);
|
CSharpWriter.writeEnum("dest/CK_STATECHUNK_CHUNKVERSION.cs", single);
|
||||||
GeneralWriter.writePyAccVal("dest/CK_STATECHUNK_CHUNKVERSION.AccVal.py", single);
|
CppWriter.writeAccVal("dest/CK_STATECHUNK_CHUNKVERSION.AccVal.hpp", single, CommonHelper.CKParts.CK2);
|
||||||
|
PythonWriter.writeAccVal("dest/CK_STATECHUNK_CHUNKVERSION.AccVal.py", single);
|
||||||
|
CSharpWriter.writeAccVal("dest/CK_STATECHUNK_CHUNKVERSION.AccVal.cs", single);
|
||||||
|
|
||||||
single = organiseDefines("src/CK_STATECHUNK_DATAVERSION.txt", "CK_STATECHUNK_DATAVERSION");
|
single = organiseDefines("src/CK_STATECHUNK_DATAVERSION.txt", "CK_STATECHUNK_DATAVERSION");
|
||||||
GeneralWriter.writeEnum("dest/CK_STATECHUNK_DATAVERSION.hpp", single);
|
CppWriter.writeEnum("dest/CK_STATECHUNK_DATAVERSION.hpp", single);
|
||||||
GeneralWriter.writePyEnum("dest/CK_STATECHUNK_DATAVERSION.py", single);
|
PythonWriter.writeEnum("dest/CK_STATECHUNK_DATAVERSION.py", single);
|
||||||
GeneralWriter.writeAccVal("dest/CK_STATECHUNK_DATAVERSION.AccVal.hpp", single, CommonHelper.CKParts.CK2);
|
CSharpWriter.writeEnum("dest/CK_STATECHUNK_DATAVERSION.cs", single);
|
||||||
GeneralWriter.writePyAccVal("dest/CK_STATECHUNK_DATAVERSION.AccVal.py", single);
|
CppWriter.writeAccVal("dest/CK_STATECHUNK_DATAVERSION.AccVal.hpp", single, CommonHelper.CKParts.CK2);
|
||||||
|
PythonWriter.writeAccVal("dest/CK_STATECHUNK_DATAVERSION.AccVal.py", single);
|
||||||
|
CSharpWriter.writeAccVal("dest/CK_STATECHUNK_DATAVERSION.AccVal.cs", single);
|
||||||
|
|
||||||
single = organiseDefines("src/CK_BITMAPDATA_FLAGS.txt", "CK_BITMAPDATA_FLAGS");
|
single = organiseDefines("src/CK_BITMAPDATA_FLAGS.txt", "CK_BITMAPDATA_FLAGS");
|
||||||
GeneralWriter.writeEnum("dest/CK_BITMAPDATA_FLAGS.hpp", single);
|
CppWriter.writeEnum("dest/CK_BITMAPDATA_FLAGS.hpp", single);
|
||||||
GeneralWriter.writePyEnum("dest/CK_BITMAPDATA_FLAGS.py", single);
|
PythonWriter.writeEnum("dest/CK_BITMAPDATA_FLAGS.py", single);
|
||||||
GeneralWriter.writeAccVal("dest/CK_BITMAPDATA_FLAGS.AccVal.hpp", single, CommonHelper.CKParts.CK2);
|
CSharpWriter.writeEnum("dest/CK_BITMAPDATA_FLAGS.cs", single);
|
||||||
GeneralWriter.writePyAccVal("dest/CK_BITMAPDATA_FLAGS.AccVal.py", single);
|
CppWriter.writeAccVal("dest/CK_BITMAPDATA_FLAGS.AccVal.hpp", single, CommonHelper.CKParts.CK2);
|
||||||
|
PythonWriter.writeAccVal("dest/CK_BITMAPDATA_FLAGS.AccVal.py", single);
|
||||||
|
CSharpWriter.writeAccVal("dest/CK_BITMAPDATA_FLAGS.AccVal.cs", single);
|
||||||
|
|
||||||
// print message.
|
// print message.
|
||||||
System.out.println("DONE!");
|
System.out.println("DONE!");
|
||||||
|
185
CodeGen/EnumsMigration/PythonWriter.java
Normal file
185
CodeGen/EnumsMigration/PythonWriter.java
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write enum declarations and accessible value into Python format.
|
||||||
|
*/
|
||||||
|
public class PythonWriter {
|
||||||
|
|
||||||
|
// =========== Python Enum Declaration Writer ===========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal real enum declaration writer.
|
||||||
|
*
|
||||||
|
* @param writer {@linkplain java.io.OutputStreamWriter} instance for writing.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private static void internalWriteEnums(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog)
|
||||||
|
throws Exception {
|
||||||
|
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.Python);
|
||||||
|
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
||||||
|
// write enum start
|
||||||
|
indent.printf("class %s(enum.IntEnum):", enum_t.mEnumName);
|
||||||
|
indent.inc();
|
||||||
|
|
||||||
|
// write enum comment
|
||||||
|
indent.briefComment(enum_t.mEnumComment);
|
||||||
|
|
||||||
|
// write enum entries
|
||||||
|
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
||||||
|
// write entry self
|
||||||
|
if (enumEntry_t.mEntryValue == null) {
|
||||||
|
indent.printf("%s = auto()", enumEntry_t.mEntryName);
|
||||||
|
} else {
|
||||||
|
indent.printf("%s = %s", enumEntry_t.mEntryName,
|
||||||
|
CommonHelper.convertToPythonNumber(enumEntry_t.mEntryValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
// write entry comment after member
|
||||||
|
indent.afterMemberComment(enumEntry_t.mEntryComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
// enum tail
|
||||||
|
indent.dec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an enum declaration collection into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum declaration collection writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for
|
||||||
|
* writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeEnums(String filename, EnumsHelper.EnumCollection_t prog) throws Exception {
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteEnums(fs, prog);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a single enum declaration into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum declaration collection writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param _enum {@linkplain EnumsHelper.Enum_t} instance for writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeEnum(String filename, EnumsHelper.Enum_t _enum) throws Exception {
|
||||||
|
// create collection from single enum
|
||||||
|
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
|
||||||
|
col.mEnums.add(_enum);
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteEnums(fs, col);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========== Python Enum Accessible Value Writer ===========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try generate human readable name from enum entry name.
|
||||||
|
* <p>
|
||||||
|
* This function is only served for Python code generation.
|
||||||
|
* <p>
|
||||||
|
* As you noticed, almost entries of CK enums are fully capital and splitted by
|
||||||
|
* underline. This is really not good for human reading, especially those who
|
||||||
|
* are not programmer. So this function will try give these programmer-oriented
|
||||||
|
* entry name a human readable name as its display name. However, this extract
|
||||||
|
* method is not perfect. It simply do some split and replacement so the
|
||||||
|
* generated content may still not good for reader.
|
||||||
|
*
|
||||||
|
* @param entry_name The name of enum entry
|
||||||
|
* @return A human readable entry name. No guaranteen that return value is must
|
||||||
|
* human readable.
|
||||||
|
*/
|
||||||
|
private static String extractHumanReadableEntryName(String entry_name) {
|
||||||
|
// remove first part (any content before underline '_')
|
||||||
|
entry_name = entry_name.replaceFirst("^[a-zA-Z0-9]+_", "");
|
||||||
|
|
||||||
|
// lower all chars except first char
|
||||||
|
if (entry_name.length() < 1)
|
||||||
|
return entry_name;
|
||||||
|
else
|
||||||
|
return entry_name.substring(0, 1) + entry_name.substring(1).toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal real enum accessible value writer.
|
||||||
|
*
|
||||||
|
* @param writer {@linkplain java.io.OutputStreamWriter} instance for writing.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private static void internalWriteAccVals(OutputStreamWriter writer, EnumsHelper.EnumCollection_t prog)
|
||||||
|
throws Exception {
|
||||||
|
IndentHelper indent = new IndentHelper(writer, CommonHelper.LangType.Python);
|
||||||
|
|
||||||
|
// write implements
|
||||||
|
for (EnumsHelper.Enum_t enum_t : prog.mEnums) {
|
||||||
|
// write enum desc header
|
||||||
|
indent.printf("g_Annotation_%s: dict[int, EnumAnnotation] = {", enum_t.mEnumName);
|
||||||
|
indent.inc();
|
||||||
|
|
||||||
|
// write enum desc entries
|
||||||
|
for (EnumsHelper.EnumEntry_t enumEntry_t : enum_t.mEntries) {
|
||||||
|
String comment = "";
|
||||||
|
if (enumEntry_t.mEntryComment != null) {
|
||||||
|
comment = CommonHelper.escapeString(enumEntry_t.mEntryComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
indent.printf("%s.%s.value: EnumAnnotation(\"%s\", \"%s\"),", enum_t.mEnumName, enumEntry_t.mEntryName,
|
||||||
|
extractHumanReadableEntryName(enumEntry_t.mEntryName), comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
// write enum tail
|
||||||
|
indent.dec();
|
||||||
|
indent.puts("}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an enum accessible value collection into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum accessible value collection
|
||||||
|
* writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param prog {@linkplain EnumsHelper.EnumCollection_t} instance for
|
||||||
|
* writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeAccVals(String filename, EnumsHelper.EnumCollection_t prog) throws Exception {
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteAccVals(fs, prog);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a single enum accessible value into given file.
|
||||||
|
* <p>
|
||||||
|
* Actually this is a wrapper of internal enum accessible value collection
|
||||||
|
* writer.
|
||||||
|
*
|
||||||
|
* @param filename The name of written file.
|
||||||
|
* @param _enum {@linkplain EnumsHelper.Enum_t} instance for writing.
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void writeAccVal(String filename, EnumsHelper.Enum_t _enum) throws Exception {
|
||||||
|
// create a collection with single enum.
|
||||||
|
EnumsHelper.EnumCollection_t col = new EnumsHelper.EnumCollection_t();
|
||||||
|
col.mEnums.add(_enum);
|
||||||
|
// open file and write
|
||||||
|
OutputStreamWriter fs = CommonHelper.openOutputFile(filename);
|
||||||
|
internalWriteAccVals(fs, col);
|
||||||
|
fs.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,10 @@
|
|||||||
# Code Gen
|
# Enums Migration
|
||||||
|
|
||||||
A helper program to generate some definations.
|
A helper program to migrate existing Virtools enum declarations into other formats.
|
||||||
|
|
||||||
|
Original Virtools SDK have various enum declarations. All of them are defined as C format and their formation are not uniform. This sub-project will use laxer and parser to recognize these diverse declarations, extract them as a series of uniform Java data struct and output them as C++ code (as C++ enum class syntax for LibCmo using), Python code (for PyBMap using), and C# code (for BMapSharp using).
|
||||||
|
|
||||||
|
The steps processing existing enum declaration is called migration as this sub-project name told.
|
||||||
|
|
||||||
```
|
```
|
||||||
antlr4 CKGeneralLexer.g4
|
antlr4 CKGeneralLexer.g4
|
||||||
|
2
CodeGen/UniversalEncoding/.gitignore
vendored
Normal file
2
CodeGen/UniversalEncoding/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Result
|
||||||
|
*.cpp
|
98
CodeGen/UniversalEncoding/EncodingTable.csv
Normal file
98
CodeGen/UniversalEncoding/EncodingTable.csv
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
Encoding Alias Code Page Iconv Identifier
|
||||||
|
ascii 646, us-ascii 437 ASCII
|
||||||
|
big5 big5-tw, csbig5 950 BIG5
|
||||||
|
big5hkscs big5-hkscs, hkscs BIG5-HKSCS
|
||||||
|
cp037 IBM037, IBM039 037
|
||||||
|
cp273 273, IBM273, csIBM273
|
||||||
|
cp424 EBCDIC-CP-HE, IBM424
|
||||||
|
cp437 437, IBM437 437
|
||||||
|
cp500 EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500 500
|
||||||
|
cp720 720
|
||||||
|
cp737 737
|
||||||
|
cp775 IBM775 775
|
||||||
|
cp850 850, IBM850 850 CP850
|
||||||
|
cp852 852, IBM852 852
|
||||||
|
cp855 855, IBM855 855
|
||||||
|
cp856
|
||||||
|
cp857 857, IBM857 857
|
||||||
|
cp858 858, IBM858 858
|
||||||
|
cp860 860, IBM860 860
|
||||||
|
cp861 861, CP-IS, IBM861 861
|
||||||
|
cp862 862, IBM862 862 CP862
|
||||||
|
cp863 863, IBM863 863
|
||||||
|
cp864 IBM864 864
|
||||||
|
cp865 865, IBM865 865
|
||||||
|
cp866 866, IBM866 866 CP866
|
||||||
|
cp869 869, CP-GR, IBM869 869
|
||||||
|
cp874 874 CP874
|
||||||
|
cp875 875
|
||||||
|
cp932 932, ms932, mskanji, ms-kanji, windows-31j 932 CP932
|
||||||
|
cp949 949, ms949, uhc 949 CP949
|
||||||
|
cp950 950, ms950 950 CP950
|
||||||
|
cp1006
|
||||||
|
cp1026 ibm1026 1026
|
||||||
|
cp1125 1125, ibm1125, cp866u, ruscii
|
||||||
|
cp1140 ibm1140 1140
|
||||||
|
cp1250 windows-1250 1250 CP1250
|
||||||
|
cp1251 windows-1251 1251 CP1251
|
||||||
|
cp1252 windows-1252 1252 CP1252
|
||||||
|
cp1253 windows-1253 1253 CP1253
|
||||||
|
cp1254 windows-1254 1254 CP1254
|
||||||
|
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 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 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 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
|
||||||
|
iso2022_jp_3 iso2022jp-3, iso-2022-jp-3
|
||||||
|
iso2022_jp_ext iso2022jp-ext, iso-2022-jp-ext
|
||||||
|
iso2022_kr csiso2022kr, iso2022kr, iso-2022-kr 50225 ISO-2022-KR
|
||||||
|
latin_1 iso-8859-1, iso8859-1, 8859, cp819, latin, latin1, L1 28591 ISO-8859-1
|
||||||
|
iso8859_2 iso-8859-2, latin2, L2 28592 ISO-8859-2
|
||||||
|
iso8859_3 iso-8859-3, latin3, L3 28593 ISO-8859-3
|
||||||
|
iso8859_4 iso-8859-4, latin4, L4 28594 ISO-8859-4
|
||||||
|
iso8859_5 iso-8859-5, cyrillic 28595 ISO-8859-5
|
||||||
|
iso8859_6 iso-8859-6, arabic 28596 ISO-8859-6
|
||||||
|
iso8859_7 iso-8859-7, greek, greek8 28597 ISO-8859-7
|
||||||
|
iso8859_8 iso-8859-8, hebrew 28598 ISO-8859-8
|
||||||
|
iso8859_9 iso-8859-9, latin5, L5 28599 ISO-8859-9
|
||||||
|
iso8859_10 iso-8859-10, latin6, L6 ISO-8859-10
|
||||||
|
iso8859_11 iso-8859-11, thai ISO-8859-11
|
||||||
|
iso8859_13 iso-8859-13, latin7, L7 28603 ISO-8859-13
|
||||||
|
iso8859_14 iso-8859-14, latin8, L8 ISO-8859-14
|
||||||
|
iso8859_15 iso-8859-15, latin9, L9 28605 ISO-8859-15
|
||||||
|
iso8859_16 iso-8859-16, latin10, L10 ISO-8859-16
|
||||||
|
johab cp1361, ms1361 1361 JOHAB
|
||||||
|
koi8_r
|
||||||
|
koi8_t KOI8-T
|
||||||
|
koi8_u
|
||||||
|
kz1048 kz_1048, strk1048_2002, rk1048
|
||||||
|
mac_cyrillic maccyrillic 10007 MacCyrillic
|
||||||
|
mac_greek macgreek 10006 MacGreek
|
||||||
|
mac_iceland maciceland 10079 MacIceland
|
||||||
|
mac_latin2 maclatin2, maccentraleurope, mac_centeuro
|
||||||
|
mac_roman macroman, macintosh MacRoman
|
||||||
|
mac_turkish macturkish 10081 MacTurkish
|
||||||
|
ptcp154 csptcp154, pt154, cp154, cyrillic-asian PT154
|
||||||
|
shift_jis csshiftjis, shiftjis, sjis, s_jis 932 SHIFT_JIS
|
||||||
|
shift_jis_2004 shiftjis2004, sjis_2004, sjis2004
|
||||||
|
shift_jisx0213 shiftjisx0213, sjisx0213, s_jisx0213
|
||||||
|
utf_32 U32, utf32 UTF-32
|
||||||
|
utf_32_be UTF-32BE UTF-32BE
|
||||||
|
utf_32_le UTF-32LE UTF-32LE
|
||||||
|
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, utf-8, cp65001 65001 UTF-8
|
||||||
|
utf_8_sig
|
|
63
CodeGen/UniversalEncoding/UniversalEncoding.py
Normal file
63
CodeGen/UniversalEncoding/UniversalEncoding.py
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import typing
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
|
||||||
|
class LanguageToken:
|
||||||
|
m_Name: str
|
||||||
|
m_Alias: tuple[str, ...]
|
||||||
|
m_CodePage: str | None
|
||||||
|
m_IconvCode: str | None
|
||||||
|
|
||||||
|
def __init__(self, name: str, alias: typing.Iterator[str], code_page: str, iconv_code: str):
|
||||||
|
self.m_Name = name.lower()
|
||||||
|
self.m_Alias = tuple(map(lambda x: x.lower(), alias))
|
||||||
|
self.m_CodePage = None if code_page == '' else code_page
|
||||||
|
self.m_IconvCode = None if iconv_code == '' else iconv_code
|
||||||
|
|
||||||
|
def extract_data(fs: io.TextIOWrapper) -> tuple[str, ...]:
|
||||||
|
# remove first line to remove table header
|
||||||
|
return fs.readlines()[1:]
|
||||||
|
|
||||||
|
def extract_token(csv_data: tuple[str, ...]) -> tuple[LanguageToken, ...]:
|
||||||
|
ret: list[LanguageToken] = []
|
||||||
|
for line in csv_data:
|
||||||
|
line = line.strip('\n')
|
||||||
|
line_sp = line.split('\t')
|
||||||
|
alias_sp = filter(lambda x: x != '', map(lambda x: x.strip(), line_sp[1].split(',')))
|
||||||
|
ret.append(LanguageToken(line_sp[0], alias_sp, line_sp[2], line_sp[3]))
|
||||||
|
return tuple(ret)
|
||||||
|
|
||||||
|
def write_alias_map(fs: io.TextIOWrapper, data: tuple[LanguageToken, ...]) -> None:
|
||||||
|
fs.write('static const std::map<std::u8string, std::u8string> c_AliasMap {\n')
|
||||||
|
for i in data:
|
||||||
|
for j in i.m_Alias:
|
||||||
|
fs.write(f'\t{{ u8"{j}", u8"{i.m_Name}" }},\n')
|
||||||
|
fs.write('};\n')
|
||||||
|
|
||||||
|
def write_win_cp_map(fs: io.TextIOWrapper, data: tuple[LanguageToken, ...]) -> None:
|
||||||
|
fs.write('static const std::map<std::u8string, UINT> c_WinCPMap {\n')
|
||||||
|
for i in data:
|
||||||
|
if i.m_CodePage is not None:
|
||||||
|
fs.write(f'\t{{ u8"{i.m_Name}", static_cast<UINT>({i.m_CodePage}u) }},\n')
|
||||||
|
fs.write('};\n')
|
||||||
|
|
||||||
|
def write_iconv_map(fs: io.TextIOWrapper, data: tuple[LanguageToken, ...]) -> None:
|
||||||
|
fs.write('static const std::map<std::u8string, std::string> c_IconvMap {\n')
|
||||||
|
for i in data:
|
||||||
|
if i.m_IconvCode is not None:
|
||||||
|
fs.write(f'\t{{ u8"{i.m_Name}", "{i.m_IconvCode}" }},\n')
|
||||||
|
fs.write('};\n')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# 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)
|
||||||
|
write_win_cp_map(fw, token)
|
||||||
|
write_iconv_map(fw, token)
|
1
CodeGen/VectorGen/.gitignore
vendored
1
CodeGen/VectorGen/.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
# Result
|
# Result
|
||||||
|
|
||||||
*.hpp
|
*.hpp
|
||||||
|
3
CodeGen/VectorGen/README.md
Normal file
3
CodeGen/VectorGen/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Vector Generator
|
||||||
|
|
||||||
|
Vector types (LibCmo::Vector3 and etc) and Vector-like types (LibCmo::Color and etc) nearly have similar declaration except slight differences (basically is the count of factors). Manually writing these declarations is boring and easy to cause potential invisible bugs. So we use a Python script to generate these declarations batchly to prevent any defects indroduced above.
|
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
def GetTmplDecl(svars: tuple[str]) -> str:
|
def GetTmplDecl(svars: tuple[str]) -> str:
|
||||||
return f'CKFLOAT {", ".join(svars)};'
|
return f'CKFLOAT {", ".join(svars)};'
|
||||||
@ -33,13 +34,13 @@ def GetTmplOperOffset(sname: str, svars: tuple[str]) -> str:
|
|||||||
return f"""\tCKFLOAT& operator[](size_t i) {{
|
return f"""\tCKFLOAT& operator[](size_t i) {{
|
||||||
\t\tswitch (i) {{
|
\t\tswitch (i) {{
|
||||||
\t\t\t{sp.join(map(lambda x: f'case {x}: return {svars[x]};', range(len(svars))))}
|
\t\t\t{sp.join(map(lambda x: f'case {x}: return {svars[x]};', range(len(svars))))}
|
||||||
\t\t\tdefault: return {svars[0]};
|
\t\t\tdefault: throw LogicException("Invalid index for {sname}::operator[].");
|
||||||
\t\t}}
|
\t\t}}
|
||||||
\t}}
|
\t}}
|
||||||
\tconst CKFLOAT& operator[](size_t i) const {{
|
\tconst CKFLOAT& operator[](size_t i) const {{
|
||||||
\t\tswitch (i) {{
|
\t\tswitch (i) {{
|
||||||
\t\t\t{sp.join(map(lambda x: f'case {x}: return {svars[x]};', range(len(svars))))}
|
\t\t\t{sp.join(map(lambda x: f'case {x}: return {svars[x]};', range(len(svars))))}
|
||||||
\t\t\tdefault: return {svars[0]};
|
\t\t\tdefault: throw LogicException("Invalid index for {sname}::operator[].");
|
||||||
\t\t}}
|
\t\t}}
|
||||||
\t}}"""
|
\t}}"""
|
||||||
|
|
||||||
@ -120,13 +121,14 @@ struct {sname} {{
|
|||||||
\t{GetTmplDecl(svars)}
|
\t{GetTmplDecl(svars)}
|
||||||
\t{GetTmplCtor1(sname, svars)}
|
\t{GetTmplCtor1(sname, svars)}
|
||||||
\t{GetTmplCtor2(sname, svars)}
|
\t{GetTmplCtor2(sname, svars)}
|
||||||
\tLIBCMO_DEFAULT_COPY_MOVE({sname});
|
\tYYCC_DEF_CLS_COPY_MOVE({sname});
|
||||||
{GetTmplOperOffset(sname, svars)}
|
{GetTmplOperOffset(sname, svars)}
|
||||||
{GetTmplOperAddMinus(sname, svars, '+')}
|
{GetTmplOperAddMinus(sname, svars, '+')}
|
||||||
{GetTmplOperAddMinus(sname, svars, '-')}
|
{GetTmplOperAddMinus(sname, svars, '-')}
|
||||||
{GetTmplOperMul(sname, svars)}
|
{GetTmplOperMul(sname, svars)}
|
||||||
{GetTmplOperDiv(sname, svars)}
|
{GetTmplOperDiv(sname, svars)}
|
||||||
{GetTmplOperEqual(sname, svars)}
|
{GetTmplOperEqual(sname, svars)}
|
||||||
|
{GetTmplOperSpaceship(sname, svars)}
|
||||||
{GetTmplLength(sname, svars)}
|
{GetTmplLength(sname, svars)}
|
||||||
{GetTmplNormalize(sname, svars)}
|
{GetTmplNormalize(sname, svars)}
|
||||||
}};
|
}};
|
||||||
@ -138,20 +140,25 @@ struct {sname} {{
|
|||||||
\t{GetTmplDecl(svars)}
|
\t{GetTmplDecl(svars)}
|
||||||
\t{GetTmplCtor1(sname, svars)} // set your custom init.
|
\t{GetTmplCtor1(sname, svars)} // set your custom init.
|
||||||
\t{GetTmplCtor2(sname, svars)}
|
\t{GetTmplCtor2(sname, svars)}
|
||||||
\tLIBCMO_DEFAULT_COPY_MOVE({sname});
|
\tYYCC_DEF_CLS_COPY_MOVE({sname});
|
||||||
{GetTmplOperOffset(sname, svars)}
|
{GetTmplOperOffset(sname, svars)}
|
||||||
{GetTmplOperEqual(sname, svars)}
|
{GetTmplOperEqual(sname, svars)}
|
||||||
|
{GetTmplOperSpaceship(sname, svars)}
|
||||||
}};
|
}};
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# use LIBCMO_DEFAULT_COPY_MOVE instead of these outputs.
|
# use YYCC_DEF_CLS_COPY_MOVE instead of these outputs.
|
||||||
#\t{GetTmplCopyCtor(sname, svars)}
|
#\t{GetTmplCopyCtor(sname, svars)}
|
||||||
#\t{GetTmplMoveCtor(sname, svars)}
|
#\t{GetTmplMoveCtor(sname, svars)}
|
||||||
#{GetTmplOperAssignCopy(sname, svars)}
|
#{GetTmplOperAssignCopy(sname, svars)}
|
||||||
#{GetTmplOperAssignMove(sname, svars)}
|
#{GetTmplOperAssignMove(sname, svars)}
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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('VxVector2', ('x', 'y', )))
|
||||||
fs.write(GetTmplVector('VxVector3', ('x', 'y', 'z', )))
|
fs.write(GetTmplVector('VxVector3', ('x', 'y', 'z', )))
|
||||||
fs.write(GetTmplVector('VxVector4', ('x', 'y', 'z', 'w', )))
|
fs.write(GetTmplVector('VxVector4', ('x', 'y', 'z', 'w', )))
|
||||||
|
18
Documents/CMakeLists.txt
Normal file
18
Documents/CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Configure Doxygen config file
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/Doxyfile.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add custom target
|
||||||
|
add_custom_target (NeMoDocuments
|
||||||
|
doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
COMMENT "Generating LibCmo documentation" VERBATIM
|
||||||
|
)
|
||||||
|
|
||||||
|
# Install built documentation
|
||||||
|
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
||||||
|
DESTINATION ${NEMO_INSTALL_DOC_PATH}
|
||||||
|
)
|
2778
Documents/Doxyfile.in
Normal file
2778
Documents/Doxyfile.in
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,33 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.12)
|
|
||||||
project(IronPad LANGUAGES CXX)
|
|
||||||
|
|
||||||
# add libcmo if not existed
|
|
||||||
if (NOT TARGET LibCmo)
|
|
||||||
add_subdirectory("../LibCmo" "LibCmo.out")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# setup sources
|
|
||||||
set(ironpad_headers ".")
|
|
||||||
set(ironpad_src IronPad.cpp)
|
|
||||||
|
|
||||||
# create static library
|
|
||||||
add_library(IronPad
|
|
||||||
STATIC
|
|
||||||
${ironpad_src}
|
|
||||||
)
|
|
||||||
target_link_libraries(IronPad
|
|
||||||
PRIVATE
|
|
||||||
LibCmo
|
|
||||||
)
|
|
||||||
target_include_directories(IronPad
|
|
||||||
PUBLIC
|
|
||||||
${ironpad_headers}
|
|
||||||
)
|
|
||||||
|
|
||||||
# set project standard
|
|
||||||
set_target_properties(IronPad
|
|
||||||
PROPERTIES
|
|
||||||
CXX_STANDARD 20
|
|
||||||
CXX_STANDARD_REQUIRED 20
|
|
||||||
CXX_EXTENSION OFF
|
|
||||||
)
|
|
@ -1,334 +0,0 @@
|
|||||||
#include "IronPad.hpp"
|
|
||||||
|
|
||||||
// only include these header on windows.
|
|
||||||
// in other words, include these header when ironpad enabled.
|
|
||||||
#if defined(IRONPAD_ENABLED)
|
|
||||||
#include <Windows.h>
|
|
||||||
#include <DbgHelp.h>
|
|
||||||
#include <filesystem>
|
|
||||||
#include <cstdarg>
|
|
||||||
#include <cstdio>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace IronPad {
|
|
||||||
|
|
||||||
#if defined(IRONPAD_ENABLED)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief true if the exception handler already registered.
|
|
||||||
* This variable is served for singleton.
|
|
||||||
*/
|
|
||||||
static bool g_IsRegistered = false;
|
|
||||||
/**
|
|
||||||
* @brief true if a exception handler is running.
|
|
||||||
* This variable is served for blocking possible infinity recursive exception handling.
|
|
||||||
*/
|
|
||||||
static bool g_IsProcessing = false;
|
|
||||||
/**
|
|
||||||
* @brief The backup of original exception handler.
|
|
||||||
*/
|
|
||||||
LPTOP_LEVEL_EXCEPTION_FILTER g_ProcBackup;
|
|
||||||
|
|
||||||
#pragma region Exception Handler Detail
|
|
||||||
|
|
||||||
|
|
||||||
static HMODULE GetCurrentModule() {
|
|
||||||
// Reference: https://stackoverflow.com/questions/557081/how-do-i-get-the-hmodule-for-the-currently-executing-code
|
|
||||||
HMODULE hModule = NULL;
|
|
||||||
GetModuleHandleExW(
|
|
||||||
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, // get address and do not inc ref counter.
|
|
||||||
(LPCWSTR)GetCurrentModule,
|
|
||||||
&hModule);
|
|
||||||
|
|
||||||
return hModule;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* UExceptionGetCodeName(DWORD code) {
|
|
||||||
switch (code) {
|
|
||||||
case EXCEPTION_ACCESS_VIOLATION:
|
|
||||||
return "access violation";
|
|
||||||
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
|
||||||
return "array index out of bound";
|
|
||||||
case EXCEPTION_BREAKPOINT:
|
|
||||||
return "breakpoint reached";
|
|
||||||
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
|
||||||
return "misaligned data access";
|
|
||||||
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
|
||||||
return "operand had denormal value";
|
|
||||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
|
||||||
return "floating-point division by zero";
|
|
||||||
case EXCEPTION_FLT_INEXACT_RESULT:
|
|
||||||
return "no decimal fraction representation for value";
|
|
||||||
case EXCEPTION_FLT_INVALID_OPERATION:
|
|
||||||
return "invalid floating-point operation";
|
|
||||||
case EXCEPTION_FLT_OVERFLOW:
|
|
||||||
return "floating-point overflow";
|
|
||||||
case EXCEPTION_FLT_STACK_CHECK:
|
|
||||||
return "floating-point stack corruption";
|
|
||||||
case EXCEPTION_FLT_UNDERFLOW:
|
|
||||||
return "floating-point underflow";
|
|
||||||
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
|
||||||
return "illegal instruction";
|
|
||||||
case EXCEPTION_IN_PAGE_ERROR:
|
|
||||||
return "inaccessible page";
|
|
||||||
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
|
||||||
return "integer division by zero";
|
|
||||||
case EXCEPTION_INT_OVERFLOW:
|
|
||||||
return "integer overflow";
|
|
||||||
case EXCEPTION_INVALID_DISPOSITION:
|
|
||||||
return "documentation says this should never happen";
|
|
||||||
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
|
|
||||||
return "can't continue after a noncontinuable exception";
|
|
||||||
case EXCEPTION_PRIV_INSTRUCTION:
|
|
||||||
return "attempted to execute a privileged instruction";
|
|
||||||
case EXCEPTION_SINGLE_STEP:
|
|
||||||
return "one instruction has been executed";
|
|
||||||
case EXCEPTION_STACK_OVERFLOW:
|
|
||||||
return "stack overflow";
|
|
||||||
default:
|
|
||||||
return "unknown exception";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void UExceptionFormat(std::FILE* fs, const char* fmt, ...) {
|
|
||||||
// write to file
|
|
||||||
va_list arg1;
|
|
||||||
va_start(arg1, fmt);
|
|
||||||
std::vfprintf(fs, fmt, arg1);
|
|
||||||
va_end(arg1);
|
|
||||||
// write to stdout
|
|
||||||
va_list arg2;
|
|
||||||
va_start(arg2, fmt);
|
|
||||||
std::vfprintf(stdout, fmt, arg2);
|
|
||||||
va_end(arg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void UExceptionPrint(std::FILE* fs, const char* strl) {
|
|
||||||
// write to file
|
|
||||||
std::fputs(strl, fs);
|
|
||||||
// write to stdout
|
|
||||||
std::fputs(strl, stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void UExceptionBacktrace(FILE* fs, LPCONTEXT context, int maxdepth) {
|
|
||||||
// setup loading symbol options
|
|
||||||
SymSetOptions(SymGetOptions() | SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES); // lazy load symbol, and load line number.
|
|
||||||
|
|
||||||
// setup handle
|
|
||||||
HANDLE process = GetCurrentProcess();
|
|
||||||
HANDLE thread = GetCurrentThread();
|
|
||||||
|
|
||||||
// init symbol
|
|
||||||
if (!SymInitialize(process, 0, TRUE)) {
|
|
||||||
// fail to load. return
|
|
||||||
UExceptionPrint(fs, "Lost symbol file!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== CORE DUMP ==========
|
|
||||||
// prepare frame. setup correct fields
|
|
||||||
// references:
|
|
||||||
// https://github.com/rust-lang/backtrace-rs/blob/9ed25b581cfd2ee60e5a3b9054fd023bf6dced90/src/backtrace/dbghelp.rs
|
|
||||||
// https://sourceforge.net/p/predef/wiki/Architectures/
|
|
||||||
DWORD machine_type = 0;
|
|
||||||
STACKFRAME64 frame;
|
|
||||||
memset(&frame, 0, sizeof(frame));
|
|
||||||
#if defined(_M_IX86) || defined(__i386__)
|
|
||||||
// x86
|
|
||||||
machine_type = IMAGE_FILE_MACHINE_I386;
|
|
||||||
frame.AddrPC.Offset = context->Eip;
|
|
||||||
frame.AddrStack.Offset = context->Esp;
|
|
||||||
frame.AddrFrame.Offset = context->Ebp;
|
|
||||||
#elif defined(_M_AMD64) || defined(__amd64__)
|
|
||||||
// amd64
|
|
||||||
machine_type = IMAGE_FILE_MACHINE_AMD64;
|
|
||||||
frame.AddrPC.Offset = context->Rip;
|
|
||||||
frame.AddrStack.Offset = context->Rsp;
|
|
||||||
frame.AddrFrame.Offset = context->Rbp;
|
|
||||||
#elif defined(_M_ARM) || defined(__arm__)
|
|
||||||
// arm (32bit)
|
|
||||||
machine_type = IMAGE_FILE_MACHINE_ARMNT;
|
|
||||||
frame.AddrPC.Offset = context->Pc;
|
|
||||||
frame.AddrStack.Offset = context->Sp;
|
|
||||||
frame.AddrFrame.Offset = context->R11;
|
|
||||||
#elif defined(_M_ARM64) || defined(__aarch64__)
|
|
||||||
// arm64
|
|
||||||
machine_type = IMAGE_FILE_MACHINE_ARM64;
|
|
||||||
frame.AddrPC.Offset = context->Pc;
|
|
||||||
frame.AddrStack.Offset = context->Sp;
|
|
||||||
frame.AddrFrame.Offset = context->DUMMYUNIONNAME.DUMMYSTRUCTNAME.Fp;
|
|
||||||
#else
|
|
||||||
#error "Unsupported platform"
|
|
||||||
//IA-64 anybody?
|
|
||||||
|
|
||||||
#endif
|
|
||||||
frame.AddrPC.Mode = AddrModeFlat;
|
|
||||||
frame.AddrStack.Mode = AddrModeFlat;
|
|
||||||
frame.AddrFrame.Mode = AddrModeFlat;
|
|
||||||
|
|
||||||
// other variables
|
|
||||||
char module_name_raw[MAX_PATH];
|
|
||||||
|
|
||||||
// stack walker
|
|
||||||
while (StackWalk64(machine_type, process, thread, &frame, context,
|
|
||||||
0, SymFunctionTableAccess64, SymGetModuleBase64, 0)) {
|
|
||||||
|
|
||||||
// depth breaker
|
|
||||||
--maxdepth;
|
|
||||||
if (maxdepth < 0) {
|
|
||||||
UExceptionPrint(fs, "...\n"); // indicate there are some frames not listed
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get module name
|
|
||||||
DWORD64 module_base = SymGetModuleBase64(process, frame.AddrPC.Offset);
|
|
||||||
const char* module_name = "[unknown module]";
|
|
||||||
if (module_base && GetModuleFileNameA((HINSTANCE)module_base, module_name_raw, MAX_PATH)) {
|
|
||||||
module_name = module_name_raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get source file and line
|
|
||||||
const char* source_file = "[unknow_source_file]";
|
|
||||||
DWORD64 source_file_line = 0;
|
|
||||||
DWORD dwDisplacement;
|
|
||||||
IMAGEHLP_LINE64 winline;
|
|
||||||
winline.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
|
||||||
if (SymGetLineFromAddr64(process, frame.AddrPC.Offset, &dwDisplacement, &winline)) {
|
|
||||||
source_file = winline.FileName;
|
|
||||||
source_file_line = winline.LineNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
// write to file
|
|
||||||
UExceptionFormat(fs, "0x%016llx(rel: 0x%016llx)[%s]\t%s#%llu\n",
|
|
||||||
frame.AddrPC.Offset, frame.AddrPC.Offset - module_base, module_name,
|
|
||||||
source_file, source_file_line
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== END CORE DUMP ==========
|
|
||||||
|
|
||||||
// free symbol
|
|
||||||
SymCleanup(process);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void UExceptionCoreDump(LPCWSTR filename, LPEXCEPTION_POINTERS info) {
|
|
||||||
// open file and write
|
|
||||||
HANDLE hFile = CreateFileW(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
||||||
if (hFile != INVALID_HANDLE_VALUE) {
|
|
||||||
MINIDUMP_EXCEPTION_INFORMATION exception_info;
|
|
||||||
exception_info.ThreadId = GetCurrentThreadId();
|
|
||||||
exception_info.ExceptionPointers = info;
|
|
||||||
exception_info.ClientPointers = TRUE;
|
|
||||||
MiniDumpWriteDump(
|
|
||||||
GetCurrentProcess(), GetCurrentProcessId(), hFile,
|
|
||||||
MiniDumpNormal,
|
|
||||||
&exception_info,
|
|
||||||
NULL, NULL
|
|
||||||
);
|
|
||||||
CloseHandle(hFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static LONG WINAPI UExceptionImpl(LPEXCEPTION_POINTERS info) {
|
|
||||||
// detect loop calling
|
|
||||||
if (g_IsProcessing) {
|
|
||||||
goto end_proc;
|
|
||||||
}
|
|
||||||
// start process
|
|
||||||
g_IsProcessing = true;
|
|
||||||
|
|
||||||
{
|
|
||||||
// get main folder first
|
|
||||||
std::filesystem::path ironpad_path;
|
|
||||||
WCHAR module_path[MAX_PATH];
|
|
||||||
std::memset(module_path, 0, sizeof(module_path));
|
|
||||||
if (GetModuleFileNameW(GetCurrentModule(), module_path, MAX_PATH) == 0) {
|
|
||||||
goto failed;
|
|
||||||
}
|
|
||||||
ironpad_path = module_path;
|
|
||||||
ironpad_path = ironpad_path.parent_path();
|
|
||||||
|
|
||||||
// create 2 filename
|
|
||||||
auto logfilename = ironpad_path / "IronPad.log";
|
|
||||||
auto dmpfilename = ironpad_path / "IronPad.dmp";
|
|
||||||
std::fputc('\n', stdout);
|
|
||||||
std::fprintf(stdout, "Exception Log: %s\n", logfilename.string().c_str());
|
|
||||||
std::fprintf(stdout, "Exception Coredump: %s\n", dmpfilename.string().c_str());
|
|
||||||
|
|
||||||
// output log file
|
|
||||||
{
|
|
||||||
std::FILE* fs = _wfopen(logfilename.wstring().c_str(), L"w");
|
|
||||||
if (fs == nullptr) {
|
|
||||||
goto failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// record exception type first
|
|
||||||
PEXCEPTION_RECORD rec = info->ExceptionRecord;
|
|
||||||
fprintf(fs, "Unhandled exception occured at 0x%08p: %s (%lu).\n",
|
|
||||||
rec->ExceptionAddress,
|
|
||||||
UExceptionGetCodeName(rec->ExceptionCode),
|
|
||||||
rec->ExceptionCode
|
|
||||||
);
|
|
||||||
|
|
||||||
// special proc for 2 exceptions
|
|
||||||
if (rec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION || rec->ExceptionCode == EXCEPTION_IN_PAGE_ERROR) {
|
|
||||||
if (rec->NumberParameters >= 2) {
|
|
||||||
const char* op =
|
|
||||||
rec->ExceptionInformation[0] == 0 ? "read" :
|
|
||||||
rec->ExceptionInformation[0] == 1 ? "written" : "executed";
|
|
||||||
fprintf(fs, "The data at memory address 0x%016" PRIxPTR " could not be %s.\n",
|
|
||||||
rec->ExceptionInformation[1], op);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// output stacktrace
|
|
||||||
UExceptionBacktrace(fs, info->ContextRecord, 1024);
|
|
||||||
|
|
||||||
std::fclose(fs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// output minidump
|
|
||||||
{
|
|
||||||
UExceptionCoreDump(dmpfilename.wstring().c_str(), info);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// end process
|
|
||||||
failed:
|
|
||||||
g_IsProcessing = false;
|
|
||||||
// if backup proc can be run, run it
|
|
||||||
// otherwise directly return.
|
|
||||||
end_proc:
|
|
||||||
if (g_ProcBackup != nullptr) {
|
|
||||||
return g_ProcBackup(info);
|
|
||||||
} else {
|
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
void IronPadRegister() {
|
|
||||||
if (g_IsRegistered) return;
|
|
||||||
g_ProcBackup = SetUnhandledExceptionFilter(UExceptionImpl);
|
|
||||||
g_IsRegistered = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IronPadUnregister() {
|
|
||||||
if (!g_IsRegistered) return;
|
|
||||||
SetUnhandledExceptionFilter(g_ProcBackup);
|
|
||||||
g_IsRegistered = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// blank implement
|
|
||||||
|
|
||||||
void IronPadRegister() {}
|
|
||||||
void IronPadUnregister() {}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// only include VTUtils to get essential macro
|
|
||||||
#include <VTUtils.hpp>
|
|
||||||
|
|
||||||
#if defined(LIBCMO_BUILD_RELEASE) && defined(LIBCMO_OS_WIN32)
|
|
||||||
#define IRONPAD_ENABLED 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Debug IronPad used. Force enable IronPad.
|
|
||||||
//#define IRONPAD_ENABLED 1
|
|
||||||
|
|
||||||
namespace IronPad {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Register IronPad.
|
|
||||||
* @detail This function frequently called at the start of program.
|
|
||||||
*/
|
|
||||||
void IronPadRegister();
|
|
||||||
/**
|
|
||||||
* @brief Unregiister IronPad
|
|
||||||
* @detail This function frequently called at the end of program.
|
|
||||||
*/
|
|
||||||
void IronPadUnregister();
|
|
||||||
|
|
||||||
}
|
|
@ -1,186 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<VCProjectVersion>16.0</VCProjectVersion>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<ProjectGuid>{a6454164-2153-45ae-bdb8-19c77014e0cc}</ProjectGuid>
|
|
||||||
<RootNamespace>IronPad</RootNamespace>
|
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="Shared">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\LibRef.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\LibRef.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\LibRef.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\LibRef.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
<OutDir>$(SolutionDir)out\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
|
|
||||||
<IntDir>$(SolutionDir)temp\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>LIBCMO_BUILD_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
<AdditionalIncludeDirectories>../LibCmo;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>LIBCMO_BUILD_RELEASE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
<AdditionalIncludeDirectories>../LibCmo;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>LIBCMO_BUILD_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
<AdditionalIncludeDirectories>../LibCmo;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalLibraryDirectories>
|
|
||||||
</AdditionalLibraryDirectories>
|
|
||||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level4</WarningLevel>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>LIBCMO_BUILD_RELEASE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
<AdditionalIncludeDirectories>../LibCmo;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalLibraryDirectories>
|
|
||||||
</AdditionalLibraryDirectories>
|
|
||||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="IronPad.hpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="IronPad.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Sources">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Headers">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Resources">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="IronPad.hpp">
|
|
||||||
<Filter>Headers</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="IronPad.cpp">
|
|
||||||
<Filter>Sources</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../VTAll.hpp"
|
#include "../VTInternal.hpp"
|
||||||
|
|
||||||
namespace LibCmo::CK2 {
|
namespace LibCmo::CK2 {
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ namespace LibCmo::CK2 {
|
|||||||
CKBitmapSlot() :
|
CKBitmapSlot() :
|
||||||
m_ImageData(), m_FileName() {}
|
m_ImageData(), m_FileName() {}
|
||||||
~CKBitmapSlot() {}
|
~CKBitmapSlot() {}
|
||||||
LIBCMO_DEFAULT_COPY_MOVE(CKBitmapSlot);
|
YYCC_DEF_CLS_COPY_MOVE(CKBitmapSlot);
|
||||||
|
|
||||||
VxMath::VxImageDescEx m_ImageData;
|
VxMath::VxImageDescEx m_ImageData;
|
||||||
XContainer::XString m_FileName;
|
XContainer::XString m_FileName;
|
||||||
@ -36,7 +36,7 @@ namespace LibCmo::CK2 {
|
|||||||
public:
|
public:
|
||||||
CKBitmapData(CKContext* ctx);
|
CKBitmapData(CKContext* ctx);
|
||||||
~CKBitmapData();
|
~CKBitmapData();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKBitmapData);
|
YYCC_DEL_CLS_COPY_MOVE(CKBitmapData);
|
||||||
|
|
||||||
#pragma region RW Funcs
|
#pragma region RW Funcs
|
||||||
|
|
||||||
@ -60,48 +60,48 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create a black image with full alpha in specified slot.
|
* @brief Create a black image with full alpha in specified slot.
|
||||||
* @param Width[in] Image width
|
* @param[in] Width Image width
|
||||||
* @param Height[in] Image height
|
* @param[in] Height Image height
|
||||||
* @param Slot[in] The slot placing image.
|
* @param[in] Slot The slot placing image.
|
||||||
* @return True if creating success.
|
* @return True if creating success.
|
||||||
*/
|
*/
|
||||||
bool CreateImage(CKDWORD Width, CKDWORD Height, CKDWORD Slot);
|
bool CreateImage(CKDWORD Width, CKDWORD Height, CKDWORD Slot);
|
||||||
/**
|
/**
|
||||||
* @brief Load image into specified slot.
|
* @brief Load image into specified slot.
|
||||||
* @param filename[in] The file name of loading image.
|
* @param[in] filename The file name of loading image.
|
||||||
* @param slot[in] The slot placing loaded image.
|
* @param[in] slot The slot placing loaded image.
|
||||||
* @return True if load successfully.
|
* @return True if load successfully.
|
||||||
*/
|
*/
|
||||||
bool LoadImage(CKSTRING filename, CKDWORD slot);
|
bool LoadImage(CKSTRING filename, CKDWORD slot);
|
||||||
/**
|
/**
|
||||||
* @brief Save image for specified slot.
|
* @brief Save image for specified slot.
|
||||||
* @param filename[in] The file name of saving image.
|
* @param[in] filename The file name of saving image.
|
||||||
* @param slot[in] The slot will be saved.
|
* @param[in] slot The slot will be saved.
|
||||||
* @param isForceThisFmt[in] True to use this class specified format to save image. Otherwise use the format evaluated by the image file name.
|
* @param[in] isForceThisFmt True to use this class specified format to save image. Otherwise use the format evaluated by the image file name.
|
||||||
* @return True if success.
|
* @return True if success.
|
||||||
*/
|
*/
|
||||||
bool SaveImage(CKSTRING filename, CKDWORD slot, bool isForceThisFmt = false);
|
bool SaveImage(CKSTRING filename, CKDWORD slot, bool isForceThisFmt = false);
|
||||||
/**
|
/**
|
||||||
* @brief Get specified slot image descriptor.
|
* @brief Get specified slot image descriptor.
|
||||||
* @param slot[in] The slot to get.
|
* @param[in] slot The slot to get.
|
||||||
* @return The descriptor. nullptr if failed.
|
* @return The descriptor. nullptr if failed.
|
||||||
*/
|
*/
|
||||||
VxMath::VxImageDescEx* GetImageDesc(CKDWORD slot);
|
VxMath::VxImageDescEx* GetImageDesc(CKDWORD slot);
|
||||||
/**
|
/**
|
||||||
* @brief Release specified slot image.
|
* @brief Release specified slot image.
|
||||||
* @param slot[in] The slot to free.
|
* @param[in] slot The slot to free.
|
||||||
*/
|
*/
|
||||||
void ReleaseImage(CKDWORD slot);
|
void ReleaseImage(CKDWORD slot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set associated file name for specified slot.
|
* @brief Set associated file name for specified slot.
|
||||||
* @param slot[in] The slot to set.
|
* @param[in] slot The slot to set.
|
||||||
* @param filename[in] The associated file name.
|
* @param[in] filename The associated file name.
|
||||||
*/
|
*/
|
||||||
bool SetSlotFileName(CKDWORD slot, CKSTRING filename);
|
bool SetSlotFileName(CKDWORD slot, CKSTRING filename);
|
||||||
/**
|
/**
|
||||||
* @brief Get associated file name for specified slot.
|
* @brief Get associated file name for specified slot.
|
||||||
* @param slot[in] The slot to get.
|
* @param[in] slot The slot to get.
|
||||||
* @return The file name. nullptr if failed.
|
* @return The file name. nullptr if failed.
|
||||||
*/
|
*/
|
||||||
CKSTRING GetSlotFileName(CKDWORD slot) const;
|
CKSTRING GetSlotFileName(CKDWORD slot) const;
|
||||||
@ -132,7 +132,7 @@ namespace LibCmo::CK2 {
|
|||||||
void SetSaveOptions(CK_TEXTURE_SAVEOPTIONS opts);
|
void SetSaveOptions(CK_TEXTURE_SAVEOPTIONS opts);
|
||||||
/**
|
/**
|
||||||
@brief Enables or disables the color key transparency.
|
@brief Enables or disables the color key transparency.
|
||||||
@param Transparency[in] TRUE activates transparency, FALSE disables it.
|
@param[in] Transparency TRUE activates transparency, FALSE disables it.
|
||||||
@remark
|
@remark
|
||||||
+ 0x00000000 (black) is the default transparent color.
|
+ 0x00000000 (black) is the default transparent color.
|
||||||
+ Setting on the transparency and a transparent color automatically
|
+ Setting on the transparency and a transparent color automatically
|
||||||
@ -149,7 +149,7 @@ namespace LibCmo::CK2 {
|
|||||||
bool IsTransparent() const;
|
bool IsTransparent() const;
|
||||||
/**
|
/**
|
||||||
@brief Sets the transparent color.
|
@brief Sets the transparent color.
|
||||||
@param Color[in] A 32 bit ARGB transparent color.
|
@param[in] Color A 32 bit ARGB transparent color.
|
||||||
@remark
|
@remark
|
||||||
+ 0x00000000 (black) is the default transparent color.
|
+ 0x00000000 (black) is the default transparent color.
|
||||||
+ Setting on the transparency and a transparent color automatically
|
+ Setting on the transparency and a transparent color automatically
|
||||||
@ -168,7 +168,7 @@ namespace LibCmo::CK2 {
|
|||||||
CKDWORD GetTransparentColor() const;
|
CKDWORD GetTransparentColor() const;
|
||||||
/**
|
/**
|
||||||
@brief Sets pick threshold value.
|
@brief Sets pick threshold value.
|
||||||
@param pt[in] Pick threshold value to be set.
|
@param[in] pt Pick threshold value to be set.
|
||||||
@remark
|
@remark
|
||||||
+ The pick threshold is used when picking object with
|
+ The pick threshold is used when picking object with
|
||||||
transparent textures.
|
transparent textures.
|
||||||
|
@ -26,7 +26,7 @@ namespace LibCmo::CK2 {
|
|||||||
m_OutputCallback(nullptr) {
|
m_OutputCallback(nullptr) {
|
||||||
|
|
||||||
// setup save format
|
// setup save format
|
||||||
m_GlobalImagesSaveFormat.m_Ext.SetExt("bmp");
|
m_GlobalImagesSaveFormat.m_Ext.SetExt(u8"bmp");
|
||||||
|
|
||||||
// setup managers
|
// setup managers
|
||||||
m_ObjectManager = new MgrImpls::CKObjectManager(this);
|
m_ObjectManager = new MgrImpls::CKObjectManager(this);
|
||||||
@ -42,6 +42,8 @@ namespace LibCmo::CK2 {
|
|||||||
for (auto& mgrptr : m_ManagerList) {
|
for (auto& mgrptr : m_ManagerList) {
|
||||||
delete mgrptr;
|
delete mgrptr;
|
||||||
}
|
}
|
||||||
|
// free encoding
|
||||||
|
this->ClearEncoding();
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
@ -252,23 +254,18 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
void CKContext::OutputToConsole(CKSTRING str) {
|
void CKContext::OutputToConsole(CKSTRING str) {
|
||||||
if (m_OutputCallback == nullptr) return;
|
if (m_OutputCallback == nullptr) return;
|
||||||
|
if (str == nullptr) return;
|
||||||
m_OutputCallback(str);
|
m_OutputCallback(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKContext::OutputToConsoleEx(CKSTRING fmt, ...) {
|
void CKContext::OutputToConsoleEx(CKSTRING fmt, ...) {
|
||||||
if (m_OutputCallback == nullptr) return;
|
if (m_OutputCallback == nullptr) return;
|
||||||
|
if (fmt == nullptr) return;
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
|
|
||||||
XContainer::XString result;
|
XContainer::XString result;
|
||||||
int count = std::vsnprintf(nullptr, 0, fmt, argptr);
|
YYCC::StringHelper::VPrintf(fmt, argptr);
|
||||||
result.resize(count);
|
|
||||||
// count + 1 for NUL terminator. but we don't need allocate space for it (resize with count). let it write into the reserved tail of std::string.
|
|
||||||
int write_result = std::vsnprintf(result.data(), count + 1, fmt, argptr);
|
|
||||||
|
|
||||||
if (write_result < 0 || write_result > count) return;
|
|
||||||
|
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
// use c_str(), not XContainer::NSXString::ToCKSTRING because we want make sure this paramter is not nullptr.
|
// use c_str(), not XContainer::NSXString::ToCKSTRING because we want make sure this paramter is not nullptr.
|
||||||
@ -284,48 +281,71 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
#pragma region Encoding utilities
|
#pragma region Encoding utilities
|
||||||
|
|
||||||
void CKContext::GetUtf8String(const XContainer::XString& native_name, XContainer::XString& u8_name) {
|
bool CKContext::GetUTF8String(const std::string& native_name, XContainer::XString& u8_name) {
|
||||||
bool success = false;
|
bool conv_success = false, has_valid_token = false;
|
||||||
for (const auto& token : this->m_NameEncoding) {
|
for (const auto& token : this->m_NameEncoding) {
|
||||||
success = LibCmo::EncodingHelper::GetUtf8VirtoolsName(native_name, u8_name, token);
|
if (token == EncodingHelper::INVALID_ENCODING_TOKEN) continue;
|
||||||
if (success) break;
|
has_valid_token = true;
|
||||||
|
conv_success = EncodingHelper::ToUTF8(native_name, u8_name, token);
|
||||||
|
if (conv_success) break;
|
||||||
}
|
}
|
||||||
|
// fallback if failed.
|
||||||
// fallback
|
if (!conv_success) {
|
||||||
if (!success) {
|
if (!has_valid_token) {
|
||||||
u8_name = native_name;
|
throw RuntimeException("Try to get UTF8 string from ordinary string in CKContext but giving empty encoding candidate.");
|
||||||
this->OutputToConsole("Error when converting to UTF8 string.");
|
} else {
|
||||||
|
u8_name.clear();
|
||||||
|
this->OutputToConsole(u8"Error when converting to UTF8 string from ordinary string. The string will leave to blank.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// return value
|
||||||
|
return conv_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKContext::GetNativeString(const XContainer::XString& u8_name, XContainer::XString& native_name) {
|
bool CKContext::GetOrdinaryString(const XContainer::XString& u8_name, std::string& native_name) {
|
||||||
bool success = false;
|
bool conv_success = false, has_valid_token = false;
|
||||||
for (const auto& token : this->m_NameEncoding) {
|
for (const auto& token : this->m_NameEncoding) {
|
||||||
success = LibCmo::EncodingHelper::GetNativeVirtoolsName(u8_name, native_name, token);
|
if (token == EncodingHelper::INVALID_ENCODING_TOKEN) continue;
|
||||||
if (success) break;
|
has_valid_token = true;
|
||||||
|
conv_success = EncodingHelper::ToOrdinary(u8_name, native_name, token);
|
||||||
|
if (conv_success) break;
|
||||||
}
|
}
|
||||||
|
// fallback if failed.
|
||||||
// fallback
|
if (!conv_success) {
|
||||||
if (!success) {
|
if (!has_valid_token) {
|
||||||
native_name = u8_name;
|
throw RuntimeException("Try to get ordinary string from UTF8 string in CKContext but giving empty encoding candidate.");
|
||||||
this->OutputToConsole("Error when converting to native string.");
|
} else {
|
||||||
|
native_name.clear();
|
||||||
|
this->OutputToConsole(u8"Error when converting to ordinary string from UTF8 string. The string will leave to blank.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// return value
|
||||||
|
return conv_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKContext::SetEncoding(const XContainer::XArray<XContainer::XString>& encoding_series) {
|
void CKContext::SetEncoding(const XContainer::XArray<XContainer::XString>& encoding_seq) {
|
||||||
// free all current series
|
// free all current series
|
||||||
for (const auto& encoding : this->m_NameEncoding) {
|
this->ClearEncoding();
|
||||||
LibCmo::EncodingHelper::DestroyEncodingToken(encoding);
|
// add new encoding
|
||||||
|
for (const auto& encoding_str : encoding_seq) {
|
||||||
|
this->m_NameEncoding.emplace_back(LibCmo::EncodingHelper::CreateEncodingToken(encoding_str));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKContext::ClearEncoding() {
|
||||||
|
for (const auto& token : this->m_NameEncoding) {
|
||||||
|
if (token == EncodingHelper::INVALID_ENCODING_TOKEN) continue;
|
||||||
|
LibCmo::EncodingHelper::DestroyEncodingToken(token);
|
||||||
}
|
}
|
||||||
this->m_NameEncoding.clear();
|
this->m_NameEncoding.clear();
|
||||||
|
|
||||||
// add new encoding
|
|
||||||
for (const auto& encoding_str : encoding_series) {
|
|
||||||
this->m_NameEncoding.push_back(LibCmo::EncodingHelper::CreateEncodingToken(encoding_str));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CKContext::IsValidEncoding() {
|
||||||
|
for (const auto& token : this->m_NameEncoding) {
|
||||||
|
if (token != EncodingHelper::INVALID_ENCODING_TOKEN) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../VTAll.hpp"
|
#include "../VTInternal.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@ -21,7 +21,7 @@ namespace LibCmo::CK2 {
|
|||||||
public:
|
public:
|
||||||
CKContext();
|
CKContext();
|
||||||
~CKContext();
|
~CKContext();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKContext);
|
YYCC_DEL_CLS_COPY_MOVE(CKContext);
|
||||||
|
|
||||||
// ========== Engine runtime ==========
|
// ========== Engine runtime ==========
|
||||||
public:
|
public:
|
||||||
@ -100,18 +100,77 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
// ========== Encoding utilities ==========
|
// ========== Encoding utilities ==========
|
||||||
public:
|
public:
|
||||||
void GetUtf8String(const XContainer::XString& native_name, XContainer::XString& u8_name);
|
/**
|
||||||
void GetNativeString(const XContainer::XString& u8_name, XContainer::XString& native_name);
|
* @brief Convert given ordinary string to UTF8 string.
|
||||||
|
* @param[in] native_name The input ordinary string.
|
||||||
|
* @param[out] u8_name The output UTF8 string.
|
||||||
|
* @return True if convertion is success, otherwise false.
|
||||||
|
* @exception RuntimeException Raised when perform this operation with a blank encoding sequence.
|
||||||
|
* @remarks
|
||||||
|
* The encoding of ordinary is specified by encoding sequence.
|
||||||
|
* If we fail to do convertion, the result will leave to blank and output a message to CKContext.
|
||||||
|
* However, if you use this function with blank encoding sequence, it will raise exception.
|
||||||
|
* So becore using this function, please make sure that you have checked by calling IsValidEncoding().
|
||||||
|
*/
|
||||||
|
bool GetUTF8String(const std::string& native_name, XContainer::XString& u8_name);
|
||||||
|
/**
|
||||||
|
* @brief Convert given UTF8 string to ordinary string.
|
||||||
|
* @param[in] u8_name The input UTF8 string.
|
||||||
|
* @param[out] native_name The output ordinary string.
|
||||||
|
* @return True if convertion is success, otherwise false.
|
||||||
|
* @exception RuntimeException Raised when perform this operation with a blank encoding sequence.
|
||||||
|
* @remarks
|
||||||
|
* The encoding of ordinary is specified by encoding sequence.
|
||||||
|
* If we fail to do convertion, the result will leave to blank and output a message to CKContext.
|
||||||
|
* However, if you use this function with blank encoding sequence, it will raise exception.
|
||||||
|
* So becore using this function, please make sure that you have checked by calling IsValidEncoding().
|
||||||
|
*/
|
||||||
|
bool GetOrdinaryString(const XContainer::XString& u8_name, std::string& native_name);
|
||||||
|
/**
|
||||||
|
* @brief Set the encoding sequence.
|
||||||
|
* @param[in] encoding_series The encoding name in this sequence.
|
||||||
|
* @remarks
|
||||||
|
* \li The order in encoding sequence is important. The encoding name with lower index will be used for convertion first.
|
||||||
|
* \li Encoding sequence will be used for performing GetUTF8String() and GetOrdinaryString().
|
||||||
|
* We will try using it to do convertion from top to bottom (if one failed we will continue trying to use next one to do convertion).
|
||||||
|
*/
|
||||||
void SetEncoding(const XContainer::XArray<XContainer::XString>& encoding_series);
|
void SetEncoding(const XContainer::XArray<XContainer::XString>& encoding_series);
|
||||||
|
/**
|
||||||
|
* @brief Clear specified encoding sequence.
|
||||||
|
*/
|
||||||
|
void ClearEncoding();
|
||||||
|
/**
|
||||||
|
* @brief Check whether current encoding sequence at least has one valid encoding for convertion.
|
||||||
|
* @return True if it is, otherwise false.
|
||||||
|
*/
|
||||||
|
bool IsValidEncoding();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XContainer::XArray<EncodingHelper::ENCODING_TOKEN> m_NameEncoding;
|
XContainer::XArray<EncodingHelper::EncodingToken> m_NameEncoding;
|
||||||
|
|
||||||
// ========== Print utilities ==========
|
// ========== Print utilities ==========
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief The callback prototype.
|
||||||
|
* @details It accept a CKSTRING representing the string need to be printed.
|
||||||
|
* The passed CKSTRING is guaranteen that it can not be nullptr.
|
||||||
|
*/
|
||||||
using OutputCallback = std::function<void(CKSTRING)>;
|
using OutputCallback = std::function<void(CKSTRING)>;
|
||||||
|
/**
|
||||||
|
* @brief Output plain message.
|
||||||
|
* @param[in] str Plain message. nullptr is allowed but not suggested.
|
||||||
|
*/
|
||||||
void OutputToConsole(CKSTRING str);
|
void OutputToConsole(CKSTRING str);
|
||||||
|
/**
|
||||||
|
* @brief Output message with given format.
|
||||||
|
* @param[in] fmt The format string. nullptr is allowed but not suggested.
|
||||||
|
* @param[in] ... The arguments of format string.
|
||||||
|
*/
|
||||||
void OutputToConsoleEx(CKSTRING fmt, ...);
|
void OutputToConsoleEx(CKSTRING fmt, ...);
|
||||||
|
/**
|
||||||
|
* @brief Set the callback for message printing.
|
||||||
|
* @param[in] cb The function pointer to callback. nullptr to remove callback.
|
||||||
|
*/
|
||||||
void SetOutputCallback(OutputCallback cb);
|
void SetOutputCallback(OutputCallback cb);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
namespace LibCmo::CK2 {
|
namespace LibCmo::CK2 {
|
||||||
|
|
||||||
#pragma region Preregistred Managers
|
#pragma region Preregistred Manager GUIDs
|
||||||
|
|
||||||
// Virtools Managers GUID second data is 0
|
// Virtools Managers GUID second DWORD must be 0
|
||||||
|
|
||||||
constexpr const CKDWORD OBJECT_MANAGER_GUID1 = 0x7cbb3b91;
|
constexpr const CKDWORD OBJECT_MANAGER_GUID1 = 0x7cbb3b91;
|
||||||
constexpr const CKDWORD ATTRIBUTE_MANAGER_GUID1 = 0x3d242466;
|
constexpr const CKDWORD ATTRIBUTE_MANAGER_GUID1 = 0x3d242466;
|
||||||
@ -26,31 +26,31 @@ namespace LibCmo::CK2 {
|
|||||||
constexpr const CKDWORD PATH_MANAGER_GUID1 = 0x15fd54b9;
|
constexpr const CKDWORD PATH_MANAGER_GUID1 = 0x15fd54b9;
|
||||||
constexpr const CKDWORD VARIABLE_MANAGER_GUID1 = 0x98cc3cc9;
|
constexpr const CKDWORD VARIABLE_MANAGER_GUID1 = 0x98cc3cc9;
|
||||||
|
|
||||||
constexpr const CKGUID OBJECT_MANAGER_GUID{ OBJECT_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID OBJECT_MANAGER_GUID { OBJECT_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID ATTRIBUTE_MANAGER_GUID{ ATTRIBUTE_MANAGER_GUID1, 0 };
|
constexpr const CKGUID ATTRIBUTE_MANAGER_GUID { ATTRIBUTE_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID MESSAGE_MANAGER_GUID{ MESSAGE_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID MESSAGE_MANAGER_GUID { MESSAGE_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID TIME_MANAGER_GUID{ TIME_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID TIME_MANAGER_GUID { TIME_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID SOUND_MANAGER_GUID{ SOUND_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID SOUND_MANAGER_GUID { SOUND_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID MIDI_MANAGER_GUID{ MIDI_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID MIDI_MANAGER_GUID { MIDI_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID INPUT_MANAGER_GUID{ INPUT_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID INPUT_MANAGER_GUID { INPUT_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID BEHAVIOR_MANAGER_GUID{ BEHAVIOR_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID BEHAVIOR_MANAGER_GUID { BEHAVIOR_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID FLOOR_MANAGER_GUID{ FLOOR_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID FLOOR_MANAGER_GUID { FLOOR_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID COLLISION_MANAGER_GUID{ COLLISION_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID COLLISION_MANAGER_GUID { COLLISION_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID GRID_MANAGER_GUID{ GRID_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID GRID_MANAGER_GUID { GRID_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID INTERFACE_MANAGER_GUID{ INTERFACE_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID INTERFACE_MANAGER_GUID { INTERFACE_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID RENDER_MANAGER_GUID{ RENDER_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID RENDER_MANAGER_GUID { RENDER_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID PARAMETER_MANAGER_GUID{ PARAMETER_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID PARAMETER_MANAGER_GUID { PARAMETER_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID PATH_MANAGER_GUID{ PATH_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID PATH_MANAGER_GUID { PATH_MANAGER_GUID1, 0 };
|
||||||
constexpr const CKGUID VARIABLE_MANAGER_GUID{ VARIABLE_MANAGER_GUID1 ,0 };
|
constexpr const CKGUID VARIABLE_MANAGER_GUID { VARIABLE_MANAGER_GUID1, 0 };
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Misc Constant
|
#pragma region Misc Constant Variables
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The identifier of Virtools file.
|
* @brief The identifier of Virtools file.
|
||||||
*/
|
*/
|
||||||
constexpr const CKCHAR CKNEMOFI[] = "Nemo Fi";
|
constexpr const CKCHAR CKNEMOFI[] = u8"Nemo Fi";
|
||||||
/**
|
/**
|
||||||
* @brief Current Version of CK Engine (Day/Month/Year)
|
* @brief Current Version of CK Engine (Day/Month/Year)
|
||||||
*/
|
*/
|
||||||
@ -65,8 +65,7 @@ namespace LibCmo::CK2 {
|
|||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Common Used Struct
|
#pragma region Common Used Struct
|
||||||
|
|
||||||
// a stupid forward decl to remove something
|
|
||||||
/**
|
/**
|
||||||
* @brief Storage class for filename extensions
|
* @brief Storage class for filename extensions
|
||||||
*/
|
*/
|
||||||
@ -97,10 +96,10 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
void SetExt(CKSTRING s) {
|
void SetExt(CKSTRING s) {
|
||||||
if (s == nullptr) {
|
if (s == nullptr) {
|
||||||
m_Data[0] = '\0';
|
m_Data[0] = u8'\0';
|
||||||
} else {
|
} else {
|
||||||
if (s[0] == '.') ++s; // skip dot
|
if (s[0] == u8'.') ++s; // skip dot
|
||||||
size_t len = std::strlen(s);
|
CKDWORD len = CKStrLen(s);
|
||||||
if (len > (c_DataLen - 1)) len = c_DataLen - 1;
|
if (len > (c_DataLen - 1)) len = c_DataLen - 1;
|
||||||
std::memcpy(m_Data, s, len);
|
std::memcpy(m_Data, s, len);
|
||||||
}
|
}
|
||||||
@ -122,13 +121,13 @@ namespace LibCmo::CK2 {
|
|||||||
static constexpr size_t c_DataLen = 4u;
|
static constexpr size_t c_DataLen = 4u;
|
||||||
CKCHAR m_Data[c_DataLen];
|
CKCHAR m_Data[c_DataLen];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The struct describe the bitmap handler's infomation,
|
* @brief Bitmap readers image description
|
||||||
* including its GUID and supported file extension.
|
* @details
|
||||||
* This struct also will store some parameters related to bitmap handler,
|
* The struct describe the bitmap handler's infomation, including its GUID and supported file extension.
|
||||||
* such as jpeg compress level and etc. But currently there are no
|
* This struct also will store some parameters related to bitmap handler, such as jpeg compress level and etc.
|
||||||
* such parameters.
|
* But currently there are no such parameters.
|
||||||
*/
|
*/
|
||||||
class CKBitmapProperties {
|
class CKBitmapProperties {
|
||||||
public:
|
public:
|
||||||
@ -136,7 +135,7 @@ namespace LibCmo::CK2 {
|
|||||||
m_ReaderGuid(), m_Ext() {}
|
m_ReaderGuid(), m_Ext() {}
|
||||||
CKBitmapProperties(const CKGUID& guid, CKSTRING ext) :
|
CKBitmapProperties(const CKGUID& guid, CKSTRING ext) :
|
||||||
m_ReaderGuid(guid), m_Ext(ext) {}
|
m_ReaderGuid(guid), m_Ext(ext) {}
|
||||||
LIBCMO_DEFAULT_COPY_MOVE(CKBitmapProperties);
|
YYCC_DEF_CLS_COPY_MOVE(CKBitmapProperties);
|
||||||
|
|
||||||
CKGUID m_ReaderGuid; /**< CKGUID that uniquely identifies the reader that created this properties structure */
|
CKGUID m_ReaderGuid; /**< CKGUID that uniquely identifies the reader that created this properties structure */
|
||||||
CKFileExtension m_Ext; /**< File Extension of the image being described by this structure */
|
CKFileExtension m_Ext; /**< File Extension of the image being described by this structure */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../VTAll.hpp"
|
#include "../VTInternal.hpp"
|
||||||
|
|
||||||
namespace LibCmo::XContainer {
|
namespace LibCmo::XContainer {
|
||||||
using XIntArray = XArray<CKINT>;
|
using XIntArray = XArray<CKINT>;
|
||||||
@ -40,7 +40,7 @@ namespace LibCmo::CK2 {
|
|||||||
~CKBufferParser() {
|
~CKBufferParser() {
|
||||||
if (this->m_NeedManualFree) delete[](this->m_MemBegin);
|
if (this->m_NeedManualFree) delete[](this->m_MemBegin);
|
||||||
}
|
}
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKBufferParser);
|
YYCC_DEL_CLS_COPY_MOVE(CKBufferParser);
|
||||||
|
|
||||||
const void* GetPtr(CKINT extraoff = 0) { return (this->m_MemBegin + m_MemPos + extraoff); }
|
const void* GetPtr(CKINT extraoff = 0) { return (this->m_MemBegin + m_MemPos + extraoff); }
|
||||||
void* GetMutablePtr(CKINT extraoff = 0) { return (this->m_MemBegin + m_MemPos + extraoff); }
|
void* GetMutablePtr(CKINT extraoff = 0) { return (this->m_MemBegin + m_MemPos + extraoff); }
|
||||||
@ -67,7 +67,6 @@ namespace LibCmo::CK2 {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(push)
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
struct CKRawFileInfo {
|
struct CKRawFileInfo {
|
||||||
CKBYTE NeMo[8];
|
CKBYTE NeMo[8];
|
||||||
@ -87,7 +86,7 @@ namespace LibCmo::CK2 {
|
|||||||
CKDWORD ProductBuild;
|
CKDWORD ProductBuild;
|
||||||
CKDWORD Hdr1UnPackSize;
|
CKDWORD Hdr1UnPackSize;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack()
|
||||||
|
|
||||||
class CKFileInfo {
|
class CKFileInfo {
|
||||||
public:
|
public:
|
||||||
@ -97,7 +96,7 @@ namespace LibCmo::CK2 {
|
|||||||
ObjectCount(0u), ManagerCount(0u), MaxIDSaved(0u), Crc(0u),
|
ObjectCount(0u), ManagerCount(0u), MaxIDSaved(0u), Crc(0u),
|
||||||
Hdr1PackSize(0u), Hdr1UnPackSize(0u), DataPackSize(0u), DataUnPackSize(0u) {}
|
Hdr1PackSize(0u), Hdr1UnPackSize(0u), DataPackSize(0u), DataUnPackSize(0u) {}
|
||||||
~CKFileInfo() {}
|
~CKFileInfo() {}
|
||||||
LIBCMO_DEFAULT_COPY_MOVE(CKFileInfo);
|
YYCC_DEF_CLS_COPY_MOVE(CKFileInfo);
|
||||||
|
|
||||||
CKDWORD ProductVersion; /**< Virtools Version (Dev/Creation). (CK_VIRTOOLS_VERSION) */
|
CKDWORD ProductVersion; /**< Virtools Version (Dev/Creation). (CK_VIRTOOLS_VERSION) */
|
||||||
CKDWORD ProductBuild; /**< Virtools Build Number. */
|
CKDWORD ProductBuild; /**< Virtools Build Number. */
|
||||||
@ -156,7 +155,7 @@ namespace LibCmo::CK2 {
|
|||||||
CKFilePluginDependencies() :
|
CKFilePluginDependencies() :
|
||||||
m_PluginCategory(CK_PLUGIN_TYPE::CKPLUGIN_MANAGER_DLL), m_Guids() {}
|
m_PluginCategory(CK_PLUGIN_TYPE::CKPLUGIN_MANAGER_DLL), m_Guids() {}
|
||||||
~CKFilePluginDependencies() {}
|
~CKFilePluginDependencies() {}
|
||||||
LIBCMO_DEFAULT_COPY_MOVE(CKFilePluginDependencies);
|
YYCC_DEF_CLS_COPY_MOVE(CKFilePluginDependencies);
|
||||||
|
|
||||||
CK_PLUGIN_TYPE m_PluginCategory;
|
CK_PLUGIN_TYPE m_PluginCategory;
|
||||||
XContainer::XArray<CKGUID> m_Guids;
|
XContainer::XArray<CKGUID> m_Guids;
|
||||||
@ -188,7 +187,7 @@ namespace LibCmo::CK2 {
|
|||||||
public:
|
public:
|
||||||
CKFileReader(CKContext* ctx);
|
CKFileReader(CKContext* ctx);
|
||||||
~CKFileReader();
|
~CKFileReader();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKFileReader);
|
YYCC_DEL_CLS_COPY_MOVE(CKFileReader);
|
||||||
|
|
||||||
// ========== Loading ==========
|
// ========== Loading ==========
|
||||||
CKERROR ShallowLoad(CKSTRING u8_filename);
|
CKERROR ShallowLoad(CKSTRING u8_filename);
|
||||||
@ -211,7 +210,7 @@ namespace LibCmo::CK2 {
|
|||||||
// XContainer::XClassArray<XContainer::XIntArray> m_IndexByClassId; /**< List of index in the m_FileObjects table sorted by ClassID */
|
// XContainer::XClassArray<XContainer::XIntArray> m_IndexByClassId; /**< List of index in the m_FileObjects table sorted by ClassID */
|
||||||
/**
|
/**
|
||||||
* @brief List of files that should be inserted in the CMO file.
|
* @brief List of files that should be inserted in the CMO file.
|
||||||
* @remark Each item is just file name, not the full path to file.
|
* @remarks Each item is just file name, not the full path to file.
|
||||||
*/
|
*/
|
||||||
XContainer::XArray<XContainer::XString> m_IncludedFiles;
|
XContainer::XArray<XContainer::XString> m_IncludedFiles;
|
||||||
CKFileInfo m_FileInfo; /**< Headers summary */
|
CKFileInfo m_FileInfo; /**< Headers summary */
|
||||||
@ -229,7 +228,7 @@ namespace LibCmo::CK2 {
|
|||||||
CKFileWriter(CKContext* ctx);
|
CKFileWriter(CKContext* ctx);
|
||||||
CKFileWriter(CKContext* ctx, CKFileReader* reader, bool is_shallow);
|
CKFileWriter(CKContext* ctx, CKFileReader* reader, bool is_shallow);
|
||||||
~CKFileWriter();
|
~CKFileWriter();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKFileWriter);
|
YYCC_DEL_CLS_COPY_MOVE(CKFileWriter);
|
||||||
|
|
||||||
// ========== Saving Preparing ==========
|
// ========== Saving Preparing ==========
|
||||||
bool AddSavedObject(ObjImpls::CKObject* obj, CKDWORD flags = CK_STATESAVE_ALL);
|
bool AddSavedObject(ObjImpls::CKObject* obj, CKDWORD flags = CK_STATESAVE_ALL);
|
||||||
@ -242,37 +241,36 @@ namespace LibCmo::CK2 {
|
|||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief A helper function to check whether given file can be written.
|
* @brief A helper function to check whether given file can be written.
|
||||||
* @param filename[in] The name of file to be wriiten
|
* @param[in] filename The name of file to be wriiten
|
||||||
* @return CKERROR::CK_OK if can write.
|
* @return CKERROR::CK_OK if can write.
|
||||||
*/
|
*/
|
||||||
CKERROR PrepareFile(CKSTRING filename);
|
CKERROR PrepareFile(CKSTRING filename);
|
||||||
/**
|
/**
|
||||||
* @brief Internal used Object Adder.
|
* @brief Internal used Object Adder.
|
||||||
*
|
* @details
|
||||||
* This function is used by AddSavedObject() and Copy from reader constructor.
|
* This function is used by AddSavedObject() and Copy from reader constructor.
|
||||||
* This function accept a object pointer, and try adding them.
|
* This function accept an object pointer, and try adding them.
|
||||||
* And set m_IncludedFiles and m_ObjectsHashTable properly.
|
* And set m_IncludedFiles and m_ObjectsHashTable properly.
|
||||||
*
|
* @param[in] obj The pointer to added object.
|
||||||
* @param obj The pointer to added object.
|
* @param[in] flags The flag used when saving this object.
|
||||||
* @param flags The flag used when saving this object.
|
|
||||||
* @return True if success.
|
* @return True if success.
|
||||||
*/
|
*/
|
||||||
bool InternalObjectAdder(ObjImpls::CKObject* obj, CKDWORD flags = CK_STATESAVE_ALL);
|
bool InternalObjectAdder(ObjImpls::CKObject* obj, CKDWORD flags = CK_STATESAVE_ALL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_Done; /**< True if this writer is already written into file. A written CKFileWriter can no be written again. */
|
bool m_Done; /**< True if this writer is already written into file. A written CKFileWriter can no be written again. */
|
||||||
/**
|
/**
|
||||||
* @brief True if this writer is not allowed to add objects.
|
* @brief True if this writer is not allowed to add objects.
|
||||||
* @remark
|
* @remarks
|
||||||
* + This field should be false in default.
|
* \li This field should be false in default.
|
||||||
* + This field usually be set when importing from reader.
|
* \li This field usually be set when importing from reader.
|
||||||
*/
|
*/
|
||||||
bool m_DisableAddingObject;
|
bool m_DisableAddingObject;
|
||||||
/**
|
/**
|
||||||
* @brief True if this writer is not allowed to add files.
|
* @brief True if this writer is not allowed to add files.
|
||||||
* @remark
|
* @remarks
|
||||||
* + This field should be false in default.
|
* \li This field should be false in default.
|
||||||
* + This field usually be set when importing from reader.
|
* \li This field usually be set when importing from reader.
|
||||||
*/
|
*/
|
||||||
bool m_DisableAddingFile;
|
bool m_DisableAddingFile;
|
||||||
|
|
||||||
@ -282,7 +280,7 @@ namespace LibCmo::CK2 {
|
|||||||
XContainer::XArray<CKFilePluginDependencies> m_PluginsDep; /**< Plugins dependencies for this file */
|
XContainer::XArray<CKFilePluginDependencies> m_PluginsDep; /**< Plugins dependencies for this file */
|
||||||
/**
|
/**
|
||||||
* @brief List of files that should be inserted in the CMO file.
|
* @brief List of files that should be inserted in the CMO file.
|
||||||
* @remark Each item is the full path to file.
|
* @remarks Each item is the full path to file.
|
||||||
*/
|
*/
|
||||||
XContainer::XArray<XContainer::XString> m_IncludedFiles;
|
XContainer::XArray<XContainer::XString> m_IncludedFiles;
|
||||||
XContainer::XHashTable<CK_ID, CKDWORD> m_ObjectsHashTable; /**< A Object ID to save index hash table. */
|
XContainer::XHashTable<CK_ID, CKDWORD> m_ObjectsHashTable; /**< A Object ID to save index hash table. */
|
||||||
|
@ -323,12 +323,12 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
CKFileVisitor::CKFileVisitor(CKFileReader* reader) :
|
CKFileVisitor::CKFileVisitor(CKFileReader* reader) :
|
||||||
m_IsReader(true), m_Reader(reader), m_Writer(nullptr), m_Ctx(reader->m_Ctx) {
|
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) :
|
CKFileVisitor::CKFileVisitor(CKFileWriter* writer) :
|
||||||
m_IsReader(false), m_Reader(nullptr), m_Writer(writer), m_Ctx(writer->m_Ctx) {
|
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) :
|
CKFileVisitor::CKFileVisitor(const CKFileVisitor& rhs) :
|
||||||
|
@ -18,12 +18,14 @@ namespace LibCmo::CK2 {
|
|||||||
CKERROR CKFileReader::ShallowLoad(CKSTRING u8_filename) {
|
CKERROR CKFileReader::ShallowLoad(CKSTRING u8_filename) {
|
||||||
// check document status
|
// check document status
|
||||||
if (this->m_Done) return CKERROR::CKERR_CANCELLED;
|
if (this->m_Done) return CKERROR::CKERR_CANCELLED;
|
||||||
|
// check CKContext encoding sequence
|
||||||
|
if (!this->m_Ctx->IsValidEncoding()) return CKERROR::CKERR_CANCELLED;
|
||||||
|
|
||||||
// check file and open memory
|
// check file and open memory
|
||||||
if (u8_filename == nullptr) return CKERROR::CKERR_INVALIDPARAMETER;
|
if (u8_filename == nullptr) return CKERROR::CKERR_INVALIDPARAMETER;
|
||||||
std::unique_ptr<VxMath::VxMemoryMappedFile> mappedFile(new VxMath::VxMemoryMappedFile(u8_filename));
|
std::unique_ptr<VxMath::VxMemoryMappedFile> mappedFile(new VxMath::VxMemoryMappedFile(u8_filename));
|
||||||
if (!mappedFile->IsValid()) {
|
if (!mappedFile->IsValid()) {
|
||||||
this->m_Ctx->OutputToConsoleEx("Fail to create Memory File for \"%s\".", u8_filename);
|
this->m_Ctx->OutputToConsoleEx(u8"Fail to create Memory File for \"%s\".", u8_filename);
|
||||||
return CKERROR::CKERR_INVALIDFILE;
|
return CKERROR::CKERR_INVALIDFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +37,8 @@ namespace LibCmo::CK2 {
|
|||||||
if (err != CKERROR::CKERR_OK) return err;
|
if (err != CKERROR::CKERR_OK) return err;
|
||||||
|
|
||||||
// other data will be free automatically
|
// other data will be free automatically
|
||||||
|
// set done flag and return
|
||||||
|
this->m_Done = true;
|
||||||
return CKERROR::CKERR_OK;
|
return CKERROR::CKERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +46,7 @@ namespace LibCmo::CK2 {
|
|||||||
std::unique_ptr<CKBufferParser> parser(new CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false));
|
std::unique_ptr<CKBufferParser> parser(new CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false));
|
||||||
parser->SetCursor(ParserPtr->GetCursor());
|
parser->SetCursor(ParserPtr->GetCursor());
|
||||||
|
|
||||||
XContainer::XString name_conv;
|
std::string name_conv;
|
||||||
|
|
||||||
// ========== read header ==========
|
// ========== read header ==========
|
||||||
// check header size
|
// check header size
|
||||||
@ -93,7 +97,7 @@ namespace LibCmo::CK2 {
|
|||||||
gotten_crc = CKComputeDataCRC(parser->GetPtr(), this->m_FileInfo.DataPackSize, gotten_crc);
|
gotten_crc = CKComputeDataCRC(parser->GetPtr(), this->m_FileInfo.DataPackSize, gotten_crc);
|
||||||
|
|
||||||
if (gotten_crc != this->m_FileInfo.Crc) {
|
if (gotten_crc != this->m_FileInfo.Crc) {
|
||||||
this->m_Ctx->OutputToConsole("Virtools file CRC error.");
|
this->m_Ctx->OutputToConsole(u8"Virtools file CRC error.");
|
||||||
return CKERROR::CKERR_FILECRCERROR;
|
return CKERROR::CKERR_FILECRCERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +133,8 @@ namespace LibCmo::CK2 {
|
|||||||
if (namelen != 0) {
|
if (namelen != 0) {
|
||||||
name_conv.resize(namelen);
|
name_conv.resize(namelen);
|
||||||
parser->Read(name_conv.data(), namelen);
|
parser->Read(name_conv.data(), namelen);
|
||||||
m_Ctx->GetUtf8String(name_conv, fileobj.Name);
|
if (!m_Ctx->GetUTF8String(name_conv, fileobj.Name))
|
||||||
|
m_Ctx->OutputToConsole(u8"Fail to get UTF8 name for CKObject when reading file header. Some objects name will leave to blank.");
|
||||||
} else {
|
} else {
|
||||||
XContainer::NSXString::FromCKSTRING(fileobj.Name, nullptr);
|
XContainer::NSXString::FromCKSTRING(fileobj.Name, nullptr);
|
||||||
}
|
}
|
||||||
@ -197,7 +202,7 @@ namespace LibCmo::CK2 {
|
|||||||
std::unique_ptr<CKBufferParser> parser(new CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false));
|
std::unique_ptr<CKBufferParser> parser(new CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false));
|
||||||
parser->SetCursor(ParserPtr->GetCursor());
|
parser->SetCursor(ParserPtr->GetCursor());
|
||||||
|
|
||||||
XContainer::XString name_conv;
|
std::string name_conv;
|
||||||
|
|
||||||
// ========== compress feature process ==========
|
// ========== compress feature process ==========
|
||||||
if (EnumsHelper::Has(this->m_FileInfo.FileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) ||
|
if (EnumsHelper::Has(this->m_FileInfo.FileWriteMode, CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD) ||
|
||||||
@ -219,7 +224,7 @@ namespace LibCmo::CK2 {
|
|||||||
0u
|
0u
|
||||||
);
|
);
|
||||||
if (gotten_crc != this->m_FileInfo.Crc) {
|
if (gotten_crc != this->m_FileInfo.Crc) {
|
||||||
this->m_Ctx->OutputToConsole("Virtools file CRC error.");
|
this->m_Ctx->OutputToConsole(u8"Virtools file CRC error.");
|
||||||
return CKERROR::CKERR_FILECRCERROR;
|
return CKERROR::CKERR_FILECRCERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +312,8 @@ namespace LibCmo::CK2 {
|
|||||||
// read filename
|
// read filename
|
||||||
if (filenamelen != 0) {
|
if (filenamelen != 0) {
|
||||||
parser->Read(name_conv.data(), filenamelen);
|
parser->Read(name_conv.data(), filenamelen);
|
||||||
m_Ctx->GetUtf8String(name_conv, file);
|
if (!m_Ctx->GetUTF8String(name_conv, file))
|
||||||
|
m_Ctx->OutputToConsole(u8"Fail to get UTF8 name for included file when reading file body. Some included files may be stripped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// read file body length
|
// read file body length
|
||||||
@ -316,12 +322,12 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
// read file body
|
// read file body
|
||||||
XContainer::XString tempfilename = m_Ctx->GetPathManager()->GetTempFilePath(file.c_str());
|
XContainer::XString tempfilename = m_Ctx->GetPathManager()->GetTempFilePath(file.c_str());
|
||||||
FILE* fp = EncodingHelper::U8FOpen(tempfilename.c_str(), "wb");
|
FILE* fp = YYCC::IOHelper::UTF8FOpen(tempfilename.c_str(), u8"wb");
|
||||||
if (fp != nullptr) {
|
if (fp != nullptr) {
|
||||||
std::fwrite(parser->GetPtr(), sizeof(CKBYTE), filebodylen, fp);
|
std::fwrite(parser->GetPtr(), sizeof(CKBYTE), filebodylen, fp);
|
||||||
std::fclose(fp);
|
std::fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
m_Ctx->OutputToConsoleEx("Fail to open temp file: %s", tempfilename.c_str());
|
m_Ctx->OutputToConsoleEx(u8"Fail to open temp file: %s", tempfilename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// move to next
|
// move to next
|
||||||
@ -335,6 +341,8 @@ namespace LibCmo::CK2 {
|
|||||||
CKERROR CKFileReader::DeepLoad(CKSTRING u8_filename) {
|
CKERROR CKFileReader::DeepLoad(CKSTRING u8_filename) {
|
||||||
// check document status
|
// check document status
|
||||||
if (this->m_Done) return CKERROR::CKERR_CANCELLED;
|
if (this->m_Done) return CKERROR::CKERR_CANCELLED;
|
||||||
|
// check CKContext encoding sequence
|
||||||
|
if (!this->m_Ctx->IsValidEncoding()) return CKERROR::CKERR_CANCELLED;
|
||||||
|
|
||||||
// ========== prepare work ==========
|
// ========== prepare work ==========
|
||||||
CKERROR err = CKERROR::CKERR_OK;
|
CKERROR err = CKERROR::CKERR_OK;
|
||||||
@ -342,6 +350,8 @@ namespace LibCmo::CK2 {
|
|||||||
// get shallow document first
|
// get shallow document first
|
||||||
err = this->ShallowLoad(u8_filename);
|
err = this->ShallowLoad(u8_filename);
|
||||||
if (err != CKERROR::CKERR_OK) return err;
|
if (err != CKERROR::CKERR_OK) return err;
|
||||||
|
// reset done flag because we need further processing
|
||||||
|
this->m_Done = false;
|
||||||
|
|
||||||
// ========== create object first ==========
|
// ========== create object first ==========
|
||||||
for (auto& obj : this->m_FileObjects) {
|
for (auto& obj : this->m_FileObjects) {
|
||||||
@ -387,6 +397,10 @@ namespace LibCmo::CK2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ========== finalize work ==========
|
// ========== finalize work ==========
|
||||||
|
|
||||||
|
|
||||||
|
// set done flag and return
|
||||||
|
this->m_Done = true;
|
||||||
return CKERROR::CKERR_OK;
|
return CKERROR::CKERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,11 @@ namespace LibCmo::CK2 {
|
|||||||
CKERROR CKFileWriter::Save(CKSTRING u8_filename) {
|
CKERROR CKFileWriter::Save(CKSTRING u8_filename) {
|
||||||
// check document status
|
// check document status
|
||||||
if (this->m_Done) return CKERROR::CKERR_CANCELLED;
|
if (this->m_Done) return CKERROR::CKERR_CANCELLED;
|
||||||
|
// check CKContext encoding sequence
|
||||||
|
if (!this->m_Ctx->IsValidEncoding()) return CKERROR::CKERR_CANCELLED;
|
||||||
|
|
||||||
// encoding conv helper
|
// encoding conv helper
|
||||||
XContainer::XString name_conv;
|
std::string name_conv;
|
||||||
|
|
||||||
// try detect filename legality
|
// try detect filename legality
|
||||||
CKERROR err = PrepareFile(u8_filename);
|
CKERROR err = PrepareFile(u8_filename);
|
||||||
@ -89,7 +91,8 @@ namespace LibCmo::CK2 {
|
|||||||
sumHdrObjSize += 4 * CKSizeof(CKDWORD);
|
sumHdrObjSize += 4 * CKSizeof(CKDWORD);
|
||||||
if (XContainer::NSXString::ToCKSTRING(obj.Name) != nullptr) {
|
if (XContainer::NSXString::ToCKSTRING(obj.Name) != nullptr) {
|
||||||
// += Name size
|
// += Name size
|
||||||
m_Ctx->GetNativeString(obj.Name, name_conv);
|
if (!m_Ctx->GetOrdinaryString(obj.Name, name_conv))
|
||||||
|
m_Ctx->OutputToConsole(u8"Fail to get ordinary string for CKObject name when computing the size of saved file. It may cause application crash or saved file has blank object name.");
|
||||||
sumHdrObjSize += static_cast<CKDWORD>(name_conv.size());
|
sumHdrObjSize += static_cast<CKDWORD>(name_conv.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +179,8 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
if (XContainer::NSXString::ToCKSTRING(obj.Name) != nullptr) {
|
if (XContainer::NSXString::ToCKSTRING(obj.Name) != nullptr) {
|
||||||
// if have name, write it
|
// if have name, write it
|
||||||
m_Ctx->GetNativeString(obj.Name, name_conv);
|
if (!m_Ctx->GetOrdinaryString(obj.Name, name_conv))
|
||||||
|
m_Ctx->OutputToConsole(u8"Fail to get ordinary string for CKObject name when saving file. Some objects may be saved with blank name.");
|
||||||
CKDWORD namelen = static_cast<CKDWORD>(name_conv.size());
|
CKDWORD namelen = static_cast<CKDWORD>(name_conv.size());
|
||||||
hdrparser->Write(&namelen);
|
hdrparser->Write(&namelen);
|
||||||
hdrparser->Write(name_conv.data(), namelen);
|
hdrparser->Write(name_conv.data(), namelen);
|
||||||
@ -299,7 +303,7 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
// ========== Open File & Write Essential Data ==========
|
// ========== Open File & Write Essential Data ==========
|
||||||
// open file and test
|
// open file and test
|
||||||
FILE* fs = EncodingHelper::U8FOpen(u8_filename, "wb");
|
FILE* fs = YYCC::IOHelper::UTF8FOpen(u8_filename, u8"wb");
|
||||||
if (fs == nullptr) return CKERROR::CKERR_CANTWRITETOFILE;
|
if (fs == nullptr) return CKERROR::CKERR_CANTWRITETOFILE;
|
||||||
// write small header + header + data
|
// write small header + header + data
|
||||||
std::fwrite(&rawHeader, sizeof(CKRawFileInfo), 1, fs);
|
std::fwrite(&rawHeader, sizeof(CKRawFileInfo), 1, fs);
|
||||||
@ -316,7 +320,8 @@ namespace LibCmo::CK2 {
|
|||||||
m_Ctx->GetPathManager()->GetFileName(filename);
|
m_Ctx->GetPathManager()->GetFileName(filename);
|
||||||
|
|
||||||
// write filename
|
// write filename
|
||||||
m_Ctx->GetNativeString(filename, name_conv);
|
if (!m_Ctx->GetOrdinaryString(filename, name_conv))
|
||||||
|
m_Ctx->OutputToConsole(u8"Fail to get ordinary string for included file when saving file. Some included files may not be saved correctly.");
|
||||||
CKDWORD filenamelen = static_cast<CKDWORD>(name_conv.size());
|
CKDWORD filenamelen = static_cast<CKDWORD>(name_conv.size());
|
||||||
std::fwrite(&filenamelen, sizeof(CKDWORD), 1, fs);
|
std::fwrite(&filenamelen, sizeof(CKDWORD), 1, fs);
|
||||||
std::fwrite(name_conv.data(), sizeof(CKBYTE), filenamelen, fs);
|
std::fwrite(name_conv.data(), sizeof(CKBYTE), filenamelen, fs);
|
||||||
@ -336,7 +341,7 @@ namespace LibCmo::CK2 {
|
|||||||
std::fwrite(&filebodylen, sizeof(CKDWORD), 1, fs);
|
std::fwrite(&filebodylen, sizeof(CKDWORD), 1, fs);
|
||||||
|
|
||||||
// report error
|
// report error
|
||||||
m_Ctx->OutputToConsoleEx("Fail to open temp file: %" PRI_CKSTRING, fentry.c_str());
|
m_Ctx->OutputToConsoleEx(u8"Fail to open temp file: %" PRI_CKSTRING, fentry.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// release mapped file
|
// release mapped file
|
||||||
@ -347,6 +352,8 @@ namespace LibCmo::CK2 {
|
|||||||
// close file
|
// close file
|
||||||
std::fclose(fs);
|
std::fclose(fs);
|
||||||
|
|
||||||
|
// set done flag and return
|
||||||
|
this->m_Done = true;
|
||||||
return CKERROR::CKERR_OK;
|
return CKERROR::CKERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +363,7 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
// try open file to check whether we can write it.
|
// try open file to check whether we can write it.
|
||||||
CKERROR err;
|
CKERROR err;
|
||||||
FILE* tryfile = EncodingHelper::U8FOpen(filename, "ab");
|
FILE* tryfile = YYCC::IOHelper::UTF8FOpen(filename, u8"ab");
|
||||||
if (tryfile == nullptr) {
|
if (tryfile == nullptr) {
|
||||||
err = CKERROR::CKERR_CANTWRITETOFILE;
|
err = CKERROR::CKERR_CANTWRITETOFILE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "../VTUtils.hpp"
|
#include "../VTUtils.hpp"
|
||||||
#if defined(LIBCMO_OS_WIN32)
|
#if YYCC_OS == YYCC_OS_WINDOWS
|
||||||
#define ZLIB_WINAPI
|
#define ZLIB_WINAPI
|
||||||
#endif
|
#endif
|
||||||
#include <zconf.h>
|
#include <zconf.h>
|
||||||
@ -23,41 +23,56 @@
|
|||||||
|
|
||||||
namespace LibCmo::CK2 {
|
namespace LibCmo::CK2 {
|
||||||
|
|
||||||
#pragma region Compression utilities
|
#pragma region Compression Utilities
|
||||||
|
|
||||||
void* CKPackData(const void* Data, CKDWORD size, CKDWORD& NewSize, CKINT compressionlevel) {
|
void* CKPackData(const void* Data, CKDWORD size, CKDWORD& NewSize, CKINT compressionlevel) {
|
||||||
uLong boundary = compressBound(static_cast<uLong>(size));
|
// check argument
|
||||||
CKBYTE* DestBuffer = new CKBYTE[boundary];
|
if (Data == nullptr && size != 0u)
|
||||||
|
throw LogicException("Data passed in CKPackData should not be nullptr.");
|
||||||
|
|
||||||
|
// get boundary and allocate buffer.
|
||||||
|
uLong boundary = compressBound(static_cast<uLong>(size));
|
||||||
|
std::unique_ptr<CKBYTE[]> DestBuffer(new CKBYTE[boundary]);
|
||||||
|
|
||||||
|
// do compress
|
||||||
uLongf _destLen = static_cast<uLongf>(boundary);
|
uLongf _destLen = static_cast<uLongf>(boundary);
|
||||||
if (compress2(
|
if (compress2(
|
||||||
reinterpret_cast<Bytef*>(DestBuffer), &_destLen,
|
reinterpret_cast<Bytef*>(DestBuffer.get()), &_destLen,
|
||||||
static_cast<const Bytef*>(Data), static_cast<uLong>(size),
|
static_cast<const Bytef*>(Data), static_cast<uLong>(size),
|
||||||
static_cast<int>(compressionlevel)) != Z_OK) {
|
static_cast<int>(compressionlevel)) != Z_OK) {
|
||||||
NewSize = 0;
|
// failed
|
||||||
delete[] DestBuffer;
|
NewSize = 0u;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewSize = static_cast<CKDWORD>(_destLen);
|
NewSize = static_cast<CKDWORD>(_destLen);
|
||||||
return DestBuffer;
|
return DestBuffer.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void* CKUnPackData(CKDWORD DestSize, const void* SrcBuffer, CKDWORD SrcSize) {
|
void* CKUnPackData(CKDWORD DestSize, const void* SrcBuffer, CKDWORD SrcSize) {
|
||||||
CKBYTE* DestBuffer = new CKBYTE[DestSize];
|
// check argument
|
||||||
|
if (SrcBuffer == nullptr && SrcSize != 0u)
|
||||||
|
throw LogicException("Data passed in CKUnPackData should not be nullptr.");
|
||||||
|
|
||||||
|
// allocate buffer
|
||||||
|
std::unique_ptr<CKBYTE[]> DestBuffer(new CKBYTE[DestSize]);
|
||||||
|
|
||||||
uLongf cache = DestSize;
|
uLongf cache = DestSize;
|
||||||
if (uncompress(
|
if (uncompress(
|
||||||
reinterpret_cast<Bytef*>(DestBuffer), &cache,
|
reinterpret_cast<Bytef*>(DestBuffer.get()), &cache,
|
||||||
static_cast<const Bytef*>(SrcBuffer), static_cast<uLong>(SrcSize)) != Z_OK) {
|
static_cast<const Bytef*>(SrcBuffer), static_cast<uLong>(SrcSize)) != Z_OK) {
|
||||||
delete[] DestBuffer;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DestBuffer;
|
return DestBuffer.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
CKDWORD CKComputeDataCRC(const void* data, CKDWORD size, CKDWORD PreviousCRC) {
|
CKDWORD CKComputeDataCRC(const void* data, CKDWORD size, CKDWORD PreviousCRC) {
|
||||||
|
// check argument
|
||||||
|
if (data == nullptr && size != 0u)
|
||||||
|
throw LogicException("Data passed in CKComputeDataCRC should not be nullptr.");
|
||||||
|
|
||||||
|
// compute
|
||||||
return static_cast<CKDWORD>(adler32(
|
return static_cast<CKDWORD>(adler32(
|
||||||
static_cast<uLong>(PreviousCRC),
|
static_cast<uLong>(PreviousCRC),
|
||||||
static_cast<const Bytef*>(data),
|
static_cast<const Bytef*>(data),
|
||||||
@ -69,42 +84,50 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
#pragma region String Utilities
|
#pragma region String Utilities
|
||||||
|
|
||||||
bool CKStrEqual(CKSTRING str1, CKSTRING str2) {
|
template<bool bCaseSenstive>
|
||||||
|
static bool InternalStrEqual(CKSTRING str1, CKSTRING str2) {
|
||||||
if (str1 == nullptr) {
|
if (str1 == nullptr) {
|
||||||
if (str2 == nullptr) return true;
|
if (str2 == nullptr) return true;
|
||||||
else return false;
|
else return false;
|
||||||
} else {
|
} else {
|
||||||
if (str2 == nullptr) return false;
|
if (str2 == nullptr) return false;
|
||||||
else {
|
else {
|
||||||
return std::strcmp(str1, str2) == 0;
|
// do real compare
|
||||||
}
|
while (*str1 != u8'\0' && *str2 != u8'\0') {
|
||||||
}
|
// compare char
|
||||||
}
|
if constexpr (bCaseSenstive) {
|
||||||
|
if (*str1 != *str2) return false;
|
||||||
bool CKStrEqualI(CKSTRING str1, CKSTRING str2) {
|
} else {
|
||||||
if (str1 == nullptr) {
|
if (std::tolower(*str1) != std::tolower(*str2)) return false;
|
||||||
if (str2 == nullptr) return true;
|
}
|
||||||
else return false;
|
// inc step
|
||||||
} else {
|
|
||||||
if (str2 == nullptr) return false;
|
|
||||||
else {
|
|
||||||
// do real cmp
|
|
||||||
size_t i = 0;
|
|
||||||
while (str1[i] != '\0' && str2[i] != '\0') {
|
|
||||||
if (std::tolower(str1[i]) != std::tolower(str2[i])) return false;
|
|
||||||
++str1;
|
++str1;
|
||||||
++str2;
|
++str2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// !XOR the result, if both of them is zero, return true(1)
|
// if both of them is zero, return true, otherwise false.
|
||||||
return !((str1[i] != '\0') ^ (str2[i] != '\0'));
|
return *str1 == u8'\0' && *str2 == u8'\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool CKStrEqual(CKSTRING str1, CKSTRING str2) {
|
||||||
|
return InternalStrEqual<true>(str1, str2);
|
||||||
|
}
|
||||||
|
bool CKStrEqualI(CKSTRING str1, CKSTRING str2) {
|
||||||
|
return InternalStrEqual<false>(str1, str2);
|
||||||
|
}
|
||||||
|
|
||||||
bool CKStrEmpty(CKSTRING strl) {
|
bool CKStrEmpty(CKSTRING strl) {
|
||||||
if (strl == nullptr) return true;
|
if (strl == nullptr) return true;
|
||||||
return strl[0] == '\0';
|
return strl[0] == u8'\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
CKDWORD CKStrLen(CKSTRING strl) {
|
||||||
|
if (strl == nullptr) return 0u;
|
||||||
|
size_t len = std::strlen(YYCC::EncodingHelper::ToOrdinary(strl));
|
||||||
|
if (len > static_cast<size_t>(std::numeric_limits<CKDWORD>::max()))
|
||||||
|
throw RuntimeException("Exceed maximum value when cast size_t to CKDWORD.");
|
||||||
|
return static_cast<CKDWORD>(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
@ -112,7 +135,7 @@ namespace LibCmo::CK2 {
|
|||||||
#pragma region CKClass Registration
|
#pragma region CKClass Registration
|
||||||
|
|
||||||
static XContainer::XArray<CKClassDesc> g_CKClassInfo;
|
static XContainer::XArray<CKClassDesc> g_CKClassInfo;
|
||||||
|
|
||||||
static bool GetClassIdIndex(CK_CLASSID cid, size_t& intcid) {
|
static bool GetClassIdIndex(CK_CLASSID cid, size_t& intcid) {
|
||||||
intcid = static_cast<size_t>(cid);
|
intcid = static_cast<size_t>(cid);
|
||||||
if (intcid >= g_CKClassInfo.size()) return false;
|
if (intcid >= g_CKClassInfo.size()) return false;
|
||||||
@ -123,7 +146,7 @@ namespace LibCmo::CK2 {
|
|||||||
void CKClassNeedNotificationFrom(CK_CLASSID listener, CK_CLASSID listenTo) {
|
void CKClassNeedNotificationFrom(CK_CLASSID listener, CK_CLASSID listenTo) {
|
||||||
size_t idxListener, idxListenTo;
|
size_t idxListener, idxListenTo;
|
||||||
if (!GetClassIdIndex(listener, idxListener) || !GetClassIdIndex(listenTo, idxListenTo)) return;
|
if (!GetClassIdIndex(listener, idxListener) || !GetClassIdIndex(listenTo, idxListenTo)) return;
|
||||||
|
|
||||||
XContainer::NSXBitArray::Set(g_CKClassInfo[idxListener].ToBeNotify, static_cast<CKDWORD>(idxListenTo));
|
XContainer::NSXBitArray::Set(g_CKClassInfo[idxListener].ToBeNotify, static_cast<CKDWORD>(idxListenTo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,8 +196,8 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
CKSTRING CKClassIDToString(CK_CLASSID cid) {
|
CKSTRING CKClassIDToString(CK_CLASSID cid) {
|
||||||
const CKClassDesc* desc = CKGetClassDesc(cid);
|
const CKClassDesc* desc = CKGetClassDesc(cid);
|
||||||
if (desc == nullptr) return "Undefined Type";
|
if (desc == nullptr) return u8"Undefined Type";
|
||||||
else return desc->NameFct();
|
return desc->NameFct();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKIsChildClassOf(CK_CLASSID child, CK_CLASSID parent) {
|
bool CKIsChildClassOf(CK_CLASSID child, CK_CLASSID parent) {
|
||||||
@ -233,18 +256,18 @@ namespace LibCmo::CK2 {
|
|||||||
This relation is represented in ToBeNotify, a pure relation without any inhertance hierarchy.
|
This relation is represented in ToBeNotify, a pure relation without any inhertance hierarchy.
|
||||||
|
|
||||||
Ok, now we assume A have children AA, B also have children BB.
|
Ok, now we assume A have children AA, B also have children BB.
|
||||||
Because B is a businessman, so his children BB also is a bussinessman.
|
Because B is a businessman, so his children BB also is a businessman.
|
||||||
B and BB have the same goods so A can buy his stuff from both of B and BB.
|
B and BB have the same goods so A can buy his stuff from both of B and BB.
|
||||||
This is the first step executed by ComputeParentsNotifyTable().
|
This is the first step executed by ComputeParentsNotifyTable().
|
||||||
In this step, the function expand existing business relations to all possible business relations (expand to businessman's children)
|
In this step, the function expand existing business relations to all possible business relations (expand to businessman's children)
|
||||||
|
|
||||||
Image there is a candy store, C. Because AA still is a kids.
|
Image there is a candy store, C. Because AA still is a kids.
|
||||||
So AA want to buy something from C. Now C is in his ToBeNotify.
|
So AA want to buy something from C. Now C is in his ToBeNotify.
|
||||||
Additionally, A, the parent of AA, force AA to buy something from B, just for A himself.
|
Additionally, A, the parent of AA, force AA to buy something from B, just for A himself.
|
||||||
For AA, he does not need want to buy something from B, but his parent A order he to do.
|
For AA, he does not need want to buy something from B, but his parent A order he to do.
|
||||||
This is the second step executed by ComputeParentsNotifyTable().
|
This is the second step executed by ComputeParentsNotifyTable().
|
||||||
For AA, his parent's relations also need to be merged after he processed his relations with C like I introduced previously.
|
For AA, his parent's relations also need to be merged after he processed his relations with C like I introduced previously.
|
||||||
|
|
||||||
Now, AA have a full business list writing all trades he can do.
|
Now, AA have a full business list writing all trades he can do.
|
||||||
This is represented as CommonToBeNotify.
|
This is represented as CommonToBeNotify.
|
||||||
In this time, AA's ToBeNotify only have C, but his CommonToBeNotify have B, BB and C.
|
In this time, AA's ToBeNotify only have C, but his CommonToBeNotify have B, BB and C.
|
||||||
@ -254,7 +277,7 @@ namespace LibCmo::CK2 {
|
|||||||
Because a full trades list are created from A side.
|
Because a full trades list are created from A side.
|
||||||
The better solution is just ask the guest: do you want to buy something from me?
|
The better solution is just ask the guest: do you want to buy something from me?
|
||||||
This operation will fill ToNotify and is implemented at ComputeHierarchyTable().
|
This operation will fill ToNotify and is implemented at ComputeHierarchyTable().
|
||||||
|
|
||||||
At the end of this story,
|
At the end of this story,
|
||||||
All bussiness man can use ToNofity to see whom they want to sell something to.
|
All bussiness man can use ToNofity to see whom they want to sell something to.
|
||||||
And all buyer can use CommonToBeNofity to check who they can buy something from.
|
And all buyer can use CommonToBeNofity to check who they can buy something from.
|
||||||
@ -267,7 +290,7 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
// find direct parent
|
// find direct parent
|
||||||
CKClassDesc& parent = g_CKClassInfo[static_cast<size_t>(desc.Parent)];
|
CKClassDesc& parent = g_CKClassInfo[static_cast<size_t>(desc.Parent)];
|
||||||
if (!parent.IsValid) LIBCMO_PANIC("No such CK_CLASSID.");
|
if (!parent.IsValid) throw LogicException("No such CK_CLASSID.");
|
||||||
|
|
||||||
// if it is not self inheritance, call recursively
|
// if it is not self inheritance, call recursively
|
||||||
if (desc.Self != desc.Parent) {
|
if (desc.Self != desc.Parent) {
|
||||||
@ -281,26 +304,26 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
// set derivation level
|
// set derivation level
|
||||||
desc.DerivationLevel = parent.DerivationLevel + 1;
|
desc.DerivationLevel = parent.DerivationLevel + 1;
|
||||||
|
|
||||||
// set done
|
// set done
|
||||||
desc.Done = true;
|
desc.Done = true;
|
||||||
}
|
}
|
||||||
static void ComputeParentsNotifyTable(CKClassDesc& desc) {
|
static void ComputeParentsNotifyTable(CKClassDesc& desc) {
|
||||||
// if it has done, do not process it again.
|
// if it has done, do not process it again.
|
||||||
if (desc.Done) return;
|
if (desc.Done) return;
|
||||||
|
|
||||||
// find direct parent
|
// find direct parent
|
||||||
CKClassDesc& parent = g_CKClassInfo[static_cast<size_t>(desc.Parent)];
|
CKClassDesc& parent = g_CKClassInfo[static_cast<size_t>(desc.Parent)];
|
||||||
if (!parent.IsValid) LIBCMO_PANIC("No such CK_CLASSID.");
|
if (!parent.IsValid) throw LogicException("No such CK_CLASSID.");
|
||||||
|
|
||||||
// if it is not self inheritance, call recursively
|
// if it is not self inheritance, call recursively
|
||||||
if (desc.Self != desc.Parent) {
|
if (desc.Self != desc.Parent) {
|
||||||
ComputeParentsNotifyTable(parent);
|
ComputeParentsNotifyTable(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add all children of ToBeNofity list
|
// add all children of ToBeNofity list
|
||||||
for (CKDWORD idx = 0; idx < desc.ToBeNotify.size(); ++idx) {
|
for (CKDWORD idx = 0; idx < desc.ToBeNotify.size(); ++idx) {
|
||||||
if (!XContainer::NSXBitArray::IsSet(desc.ToBeNotify, idx))
|
if (!XContainer::NSXBitArray::IsSet(desc.ToBeNotify, idx))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CKClassDesc& target = g_CKClassInfo[idx];
|
CKClassDesc& target = g_CKClassInfo[idx];
|
||||||
@ -352,7 +375,7 @@ namespace LibCmo::CK2 {
|
|||||||
if (!item.IsValid || item.RegisterFct == nullptr) continue;
|
if (!item.IsValid || item.RegisterFct == nullptr) continue;
|
||||||
item.RegisterFct();
|
item.RegisterFct();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== Build Notify Hierarchy =====
|
// ===== Build Notify Hierarchy =====
|
||||||
// set array first
|
// set array first
|
||||||
for (auto& item : g_CKClassInfo) {
|
for (auto& item : g_CKClassInfo) {
|
||||||
@ -398,13 +421,13 @@ CKClassRegister(cid, parentCid, \
|
|||||||
nullptr, \
|
nullptr, \
|
||||||
[](CKContext* ctx, CK_ID id, CKSTRING name) -> ObjImpls::CKObject* { return new clsname(ctx, id, name); }, \
|
[](CKContext* ctx, CK_ID id, CKSTRING name) -> ObjImpls::CKObject* { return new clsname(ctx, id, name); }, \
|
||||||
[](CKContext* ctx, ObjImpls::CKObject* obj) -> void { delete obj; }, \
|
[](CKContext* ctx, ObjImpls::CKObject* obj) -> void { delete obj; }, \
|
||||||
[]() -> CKSTRING { return strName; });
|
[]() -> CKSTRING { return u8 ## strName; });
|
||||||
#define EasyClassRegWithNotify(clsname, cid, parentCid, strName, notifyCids) \
|
#define EasyClassRegWithNotify(clsname, cid, parentCid, strName, notifyCids) \
|
||||||
CKClassRegister(cid, parentCid, \
|
CKClassRegister(cid, parentCid, \
|
||||||
[]() -> void { NeedNotificationWrapper(cid, notifyCids); }, \
|
[]() -> void { NeedNotificationWrapper(cid, notifyCids); }, \
|
||||||
[](CKContext* ctx, CK_ID id, CKSTRING name) -> ObjImpls::CKObject* { return new clsname(ctx, id, name); }, \
|
[](CKContext* ctx, CK_ID id, CKSTRING name) -> ObjImpls::CKObject* { return new clsname(ctx, id, name); }, \
|
||||||
[](CKContext* ctx, ObjImpls::CKObject* obj) -> void { delete obj; }, \
|
[](CKContext* ctx, ObjImpls::CKObject* obj) -> void { delete obj; }, \
|
||||||
[]() -> CKSTRING { return strName; });
|
[]() -> CKSTRING { return u8 ## strName; });
|
||||||
|
|
||||||
EasyClassReg(ObjImpls::CKObject, CK_CLASSID::CKCID_OBJECT, CK_CLASSID::CKCID_OBJECT, "Basic Object");
|
EasyClassReg(ObjImpls::CKObject, CK_CLASSID::CKCID_OBJECT, CK_CLASSID::CKCID_OBJECT, "Basic Object");
|
||||||
EasyClassReg(ObjImpls::CKSceneObject, CK_CLASSID::CKCID_SCENEOBJECT, CK_CLASSID::CKCID_OBJECT, "Scene Object");
|
EasyClassReg(ObjImpls::CKSceneObject, CK_CLASSID::CKCID_SCENEOBJECT, CK_CLASSID::CKCID_OBJECT, "Scene Object");
|
||||||
@ -426,7 +449,7 @@ CKClassRegister(cid, parentCid, \
|
|||||||
}
|
}
|
||||||
|
|
||||||
CKERROR CKShutdown() {
|
CKERROR CKShutdown() {
|
||||||
// free class indo
|
// free class infos
|
||||||
g_CKClassInfo.clear();
|
g_CKClassInfo.clear();
|
||||||
|
|
||||||
return CKERROR::CKERR_OK;
|
return CKERROR::CKERR_OK;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "CKTypes.hpp"
|
#include "CKTypes.hpp"
|
||||||
#include "../XContainer/XTypes.hpp"
|
#include "../XContainer/XTypes.hpp"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace LibCmo::CK2 {
|
namespace LibCmo::CK2 {
|
||||||
|
|
||||||
@ -10,87 +11,114 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Compress a buffer
|
* @brief Compress a buffer
|
||||||
* @param[in] Data A pointer to the buffer to coompress
|
* @param[in] Data A pointer to the buffer to compress. nullptr is not allowed.
|
||||||
* @param[in] size Size of the source buffer.
|
* @param[in] size Size of the source buffer.
|
||||||
* @param[out] NewSize A reference that will be filled with the size of the compressed buffer. 0 if failed.
|
* @param[out] NewSize A reference that will be filled with the size of the compressed buffer. 0 if failed.
|
||||||
* @param[in] compressionlevel 0-9
|
* @param[in] compressionlevel 0-9 Greater level smaller result size.
|
||||||
* @return
|
* @return
|
||||||
* A pointer to the compressed buffer. nullptr if failed.
|
* A pointer to the compressed buffer. nullptr if failed.
|
||||||
* The return pointer should be freed by `delete[]` manually.
|
* The return pointer should be freed by \c delete[] manually.
|
||||||
* @remark
|
* @remarks
|
||||||
* The size of allocated return value may greater than the passed value of NewSize.
|
* The size of allocated return value may greater than the passed value of NewSize.
|
||||||
* NewSize only indicate the size of the part storing useful data in return value.
|
* NewSize only indicate the size of the part storing useful data in return value.
|
||||||
* @see CKUnPackData, CKComputeDataCRC
|
* @exception LogicException Raised if given buffer is nullptr and size is not equal to zero.
|
||||||
|
* @see CKUnPackData(), CKComputeDataCRC()
|
||||||
*/
|
*/
|
||||||
void* CKPackData(const void* Data, CKDWORD size, CKDWORD& NewSize, CKINT compressionlevel);
|
void* CKPackData(const void* Data, CKDWORD size, CKDWORD& NewSize, CKINT compressionlevel);
|
||||||
/**
|
/**
|
||||||
* @brief Decompress a buffer
|
* @brief Decompress a buffer
|
||||||
* @param[in] DestSize Expected size of the decompressed buffer.
|
* @param[in] DestSize Expected size of the decompressed buffer.
|
||||||
* @param[in] SrcBuffer Compressed buffer.
|
* @param[in] SrcBuffer Compressed buffer. nullptr is not allowed.
|
||||||
* @param[in] SrcSize Size of the compressed buffer.
|
* @param[in] SrcSize Size of the compressed buffer.
|
||||||
* @return
|
* @return
|
||||||
* A pointer to the decompressed buffer or nullptr if there was a error.
|
* A pointer to the decompressed buffer or nullptr if there was a error.
|
||||||
* The return pointer should be freed by `delete[]` manually.
|
* The return pointer should be freed by \c delete[] manually.
|
||||||
* @see CKPackData, CKComputeDataCRC
|
* @exception LogicException Raised if given buffer is nullptr and size is not equal to zero.
|
||||||
|
* @see CKPackData(), CKComputeDataCRC()
|
||||||
*/
|
*/
|
||||||
void* CKUnPackData(CKDWORD DestSize, const void* SrcBuffer, CKDWORD SrcSize);
|
void* CKUnPackData(CKDWORD DestSize, const void* SrcBuffer, CKDWORD SrcSize);
|
||||||
/**
|
/**
|
||||||
* @brief Computes a CRC for a buffer.
|
* @brief Computes a CRC for a buffer.
|
||||||
* @param[in] data A pointer to the buffer to create a CRC for.
|
* @param[in] data A pointer to the buffer to create a CRC for. nullptr is not allowed.
|
||||||
* @param[in] size Size of the source buffer.
|
* @param[in] size Size of the source buffer.
|
||||||
* @param[in] PreviousCRC
|
* @param[in] PreviousCRC
|
||||||
* The first time a CRC is computed this value should be 0,
|
* The first time a CRC is computed this value should be 0,
|
||||||
* but it can be use to compute a single CRC for a several buffers
|
* but it can be use to compute a single CRC for a several buffers
|
||||||
* by using the currently computed CRC for previous buffers in this value.
|
* by using the currently computed CRC for previous buffers in this value.
|
||||||
* @return CRC of the buffer.
|
* @return CRC of the buffer.
|
||||||
* @see CKPackData, CKUnPackData
|
* @exception LogicException Raised if given buffer is nullptr and size is not equal to zero.
|
||||||
|
* @see CKPackData(), CKUnPackData()
|
||||||
*/
|
*/
|
||||||
CKDWORD CKComputeDataCRC(const void* data, CKDWORD size, CKDWORD PreviousCRC = 0);
|
CKDWORD CKComputeDataCRC(const void* data, CKDWORD size, CKDWORD PreviousCRC = 0);
|
||||||
|
|
||||||
// ========== String Utilities ==========
|
// ========== String Utilities ==========
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check whether 2 string is equal. Case senstive.
|
* @brief Check whether two string is equal. Case senstive.
|
||||||
* @param str1[in] String 1
|
* @param[in] str1 First string. nullptr is allowed but not suggested.
|
||||||
* @param str2[in] String 2
|
* @param[in] str2 Second string. nullptr is allowed but not suggested.
|
||||||
* @return True if 2 string is equal.
|
* @return True if two string is equal, otherwise false.
|
||||||
* @see CKStrIEqual
|
* @remarks
|
||||||
|
* nullptr string is not equal to any other string.
|
||||||
|
* However two nullptr string is equal.
|
||||||
|
* @see CKStrEqualI()
|
||||||
*/
|
*/
|
||||||
bool CKStrEqual(CKSTRING str1, CKSTRING str2);
|
bool CKStrEqual(CKSTRING str1, CKSTRING str2);
|
||||||
/**
|
/**
|
||||||
* @brief Check whther 2 string is equal. Case insenstive.
|
* @brief Check whther two string is equal. Case insenstive.
|
||||||
* @param str1
|
* @param[in] str1 First string. nullptr is allowed but not suggested.
|
||||||
* @param str2
|
* @param[in] str2 Second string. nullptr is allowed but not suggested.
|
||||||
* @return True if 2 string is equal.
|
* @return True if two string is equal, otherwise false.
|
||||||
* @see CKStrEqual
|
* @remarks
|
||||||
|
* nullptr string is not equal to any other string.
|
||||||
|
* However two nullptr string is equal.
|
||||||
|
* @see CKStrEqual()
|
||||||
*/
|
*/
|
||||||
bool CKStrEqualI(CKSTRING str1, CKSTRING str2);
|
bool CKStrEqualI(CKSTRING str1, CKSTRING str2);
|
||||||
/**
|
/**
|
||||||
* @brief Check whether string is empty
|
* @brief Check whether string is empty
|
||||||
* @param strl
|
* @param[in] strl String for checking. nullptr is allowed but not suggested.
|
||||||
* @return True if string is empty.
|
* @return True if string is empty, otherwise false.
|
||||||
|
* @remarks nullptr string is seen as empty string.
|
||||||
*/
|
*/
|
||||||
bool CKStrEmpty(CKSTRING strl);
|
bool CKStrEmpty(CKSTRING strl);
|
||||||
|
/**
|
||||||
|
* @brief Get the length of given string.
|
||||||
|
* @param[in] strl String for getting length. nullptr is allowed but not suggested.
|
||||||
|
* @return String length in UTF8 code unit.
|
||||||
|
* @remarks nullptr string will return 0 instead.
|
||||||
|
* @exception RuntimeException Raised if the length of string exceed the maximum value of CKDWORD.
|
||||||
|
*/
|
||||||
|
CKDWORD CKStrLen(CKSTRING strl);
|
||||||
|
|
||||||
// ========== Class registration utilities ==========
|
// ========== Class registration utilities ==========
|
||||||
|
|
||||||
|
/// @brief Function pointer which do extra stuff when registry this class.
|
||||||
using CKClassRegisterFct = std::function<void()>;
|
using CKClassRegisterFct = std::function<void()>;
|
||||||
|
/// @brief Function pointer which create ObjImpls::CKObject pointer by given CKContext, CK_ID and name.
|
||||||
using CKClassCreationFct = std::function<ObjImpls::CKObject* (CKContext*, CK_ID, CKSTRING)>;
|
using CKClassCreationFct = std::function<ObjImpls::CKObject* (CKContext*, CK_ID, CKSTRING)>;
|
||||||
|
/// @brief Function pointer which free given ObjImpls::CKObject pointer.
|
||||||
using CKClassReleaseFct = std::function<void(CKContext*, ObjImpls::CKObject*)>;
|
using CKClassReleaseFct = std::function<void(CKContext*, ObjImpls::CKObject*)>;
|
||||||
|
/// @brief Function pointer which return the name of class.
|
||||||
using CKClassNameFct = std::function<CKSTRING()>;
|
using CKClassNameFct = std::function<CKSTRING()>;
|
||||||
//using CKClassDependenciesFct = std::function<CKSTRING(CKINT, CKINT)>;
|
//using CKClassDependenciesFct = std::function<CKSTRING(CKINT, CKINT)>;
|
||||||
//using CKClassDependenciesCountFct = std::function<CKINT(CKINT)>;
|
//using CKClassDependenciesCountFct = std::function<CKINT(CKINT)>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The representation of a registered class.
|
||||||
|
*/
|
||||||
struct CKClassDesc {
|
struct CKClassDesc {
|
||||||
|
// Variables used when building class hierarchy table
|
||||||
bool IsValid; /**< True if this CKClassDesc is a valid one. Because CK_CLASSID may not be consecutive. */
|
bool IsValid; /**< True if this CKClassDesc is a valid one. Because CK_CLASSID may not be consecutive. */
|
||||||
bool Done;
|
bool Done; /**< Temporary variable indicating this item has been processed when creating table. */
|
||||||
// Initialized upon class registration
|
|
||||||
CK_CLASSID Self;
|
// Variables initialized upon class registration
|
||||||
CK_CLASSID Parent; // Class Identifier of parent class
|
CK_CLASSID Self; /**< Class identifier of self */
|
||||||
CKClassRegisterFct RegisterFct; // Pointer to Class Specific Registration function
|
CK_CLASSID Parent; /**< Class identifier of parent class */
|
||||||
CKClassCreationFct CreationFct; // Pointer to Class instance creation function
|
CKClassRegisterFct RegisterFct; /**< Function pointer which do extra stuff when registry this class. */
|
||||||
CKClassReleaseFct ReleaseFct; // Pointer to Class instance release function
|
CKClassCreationFct CreationFct; /**< Function pointer which create ObjImpls::CKObject pointer by given CKContext, CK_ID and name. */
|
||||||
CKClassNameFct NameFct; // Pointer to Class name function
|
CKClassReleaseFct ReleaseFct; /**< Function pointer which free given ObjImpls::CKObject pointer. */
|
||||||
|
CKClassNameFct NameFct; /**< Function pointer which return the name of class. */
|
||||||
//CKClassDependenciesFct DependsFct; // Pointer to Class dependencies function (Copy,delete,replace...)
|
//CKClassDependenciesFct DependsFct; // Pointer to Class dependencies function (Copy,delete,replace...)
|
||||||
//CKClassDependenciesCountFct DependsCountFct; // Pointer to Class dependencies Count function (Copy,delete,replace...)
|
//CKClassDependenciesCountFct DependsCountFct; // Pointer to Class dependencies Count function (Copy,delete,replace...)
|
||||||
|
|
||||||
@ -102,13 +130,13 @@ namespace LibCmo::CK2 {
|
|||||||
//CKDWORD DefaultSaveDependencies;
|
//CKDWORD DefaultSaveDependencies;
|
||||||
//CKGUID Parameter; // Associated parameter GUID
|
//CKGUID Parameter; // Associated parameter GUID
|
||||||
|
|
||||||
// Initialized when building class hierarchy table
|
// Variables initialized after building class hierarchy table
|
||||||
CKINT DerivationLevel; // O => CKObject , etc..
|
CKINT DerivationLevel; /**< How many parent level it has. 0 for CKObject, etc.. */
|
||||||
XContainer::XBitArray Parents; // Bit Mask of parents classes
|
XContainer::XBitArray Parents; /**< Bit Mask of parents classes */
|
||||||
XContainer::XBitArray Children; // Bit Mask of children classes
|
XContainer::XBitArray Children; /**< Bit Mask of children classes */
|
||||||
XContainer::XBitArray ToBeNotify; // User specified notify list, only for current class. If any deleted objects match class id in this XBitArray, notify the host of this XBitArray.
|
XContainer::XBitArray ToBeNotify; /**< User specified notify list, only for current class. If any deleted objects match class id in this XBitArray, notify the host of this XBitArray. */
|
||||||
XContainer::XBitArray CommonToBeNotify; // Same as ToBeNotify, but merging all parents' notify list.
|
XContainer::XBitArray CommonToBeNotify; /**< Same as ToBeNotify, but merging all parents' notify list. */
|
||||||
XContainer::XBitArray ToNotify; // The ClassID to notify when an object of this class is deleted (inverse of ToBeNotify)
|
XContainer::XBitArray ToNotify; /**< The ClassID to notify when an object of this class is deleted (inverse of ToBeNotify) */
|
||||||
|
|
||||||
CKClassDesc() :
|
CKClassDesc() :
|
||||||
IsValid(false),
|
IsValid(false),
|
||||||
@ -118,44 +146,114 @@ namespace LibCmo::CK2 {
|
|||||||
DerivationLevel(0),
|
DerivationLevel(0),
|
||||||
Parents(), Children(), ToBeNotify(), CommonToBeNotify()
|
Parents(), Children(), ToBeNotify(), CommonToBeNotify()
|
||||||
{}
|
{}
|
||||||
LIBCMO_DEFAULT_COPY_MOVE(CKClassDesc);
|
YYCC_DEF_CLS_COPY_MOVE(CKClassDesc);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ========== CKClass Registration ==========
|
// ========== CKClass Registration ==========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Order that first class id will be notified when deleting object whose class id is second argument
|
||||||
|
* @param[in] listener The id of class will be notified.
|
||||||
|
* @param[in] listenTo The id of class which first argument interested in.
|
||||||
|
* @remarks If one of given class ids is invalid, this function simply return and do nothing.
|
||||||
|
*/
|
||||||
void CKClassNeedNotificationFrom(CK_CLASSID listener, CK_CLASSID listenTo);
|
void CKClassNeedNotificationFrom(CK_CLASSID listener, CK_CLASSID listenTo);
|
||||||
|
/**
|
||||||
|
* @brief Get an usable class id for registration.
|
||||||
|
* @details This function is usually used by plugin to registering classes.
|
||||||
|
* Because all embedded Virtools classes has constant class id.
|
||||||
|
* @return An usable class id for registration.
|
||||||
|
*/
|
||||||
CK_CLASSID CKClassGetNewIdentifier();
|
CK_CLASSID CKClassGetNewIdentifier();
|
||||||
|
/**
|
||||||
|
* @brief Register a new class.
|
||||||
|
* @param[in] cid The id of this class.
|
||||||
|
* @param[in] parentCid The id of parent class.
|
||||||
|
* @param[in] regFct Pointer to class specific registration function which do extra stuff when registry this class.
|
||||||
|
* @param[in] createFct Pointer to class instance creation function
|
||||||
|
* @param[in] relFct Pointer to class instance release function
|
||||||
|
* @param[in] nameFct Pointer to class name function
|
||||||
|
*/
|
||||||
void CKClassRegister(CK_CLASSID cid, CK_CLASSID parentCid,
|
void CKClassRegister(CK_CLASSID cid, CK_CLASSID parentCid,
|
||||||
CKClassRegisterFct regFct, CKClassCreationFct createFct, CKClassReleaseFct relFct, CKClassNameFct nameFct);
|
CKClassRegisterFct regFct, CKClassCreationFct createFct, CKClassReleaseFct relFct, CKClassNameFct nameFct);
|
||||||
|
|
||||||
// ========== Class Hierarchy Management ==========
|
// ========== Class Hierarchy Management ==========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get total count of registered classes.
|
||||||
|
* @return The total count of registered classes.
|
||||||
|
*/
|
||||||
CKDWORD CKGetClassCount();
|
CKDWORD CKGetClassCount();
|
||||||
|
/**
|
||||||
|
* @brief Get the class description struct by given class id.
|
||||||
|
* @param[in] cid Class id for fetching.
|
||||||
|
* @return The pointer to corresponding class description.
|
||||||
|
* If given class id is invalid, this function will return nullptr.
|
||||||
|
* According to this, caller can utilize this function to validate class id.
|
||||||
|
*/
|
||||||
const CKClassDesc* CKGetClassDesc(CK_CLASSID cid);
|
const CKClassDesc* CKGetClassDesc(CK_CLASSID cid);
|
||||||
|
/**
|
||||||
|
* @brief Get the name representation of given class id.
|
||||||
|
* @param[in] cid Class id for fetching.
|
||||||
|
* @return The name of given class id.
|
||||||
|
* If given class id is invalid, it return a predefined name.
|
||||||
|
*/
|
||||||
CKSTRING CKClassIDToString(CK_CLASSID cid);
|
CKSTRING CKClassIDToString(CK_CLASSID cid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check whether first class is second class' child class.
|
||||||
|
* @param[in] child The id of first class assumed as child class.
|
||||||
|
* @param[in] parent The id of second class assumed as parent class.
|
||||||
|
* @return True if relation is satisfied, otherwise false.
|
||||||
|
* If one of given class ids is invalid, this function always return false.
|
||||||
|
*/
|
||||||
bool CKIsChildClassOf(CK_CLASSID child, CK_CLASSID parent);
|
bool CKIsChildClassOf(CK_CLASSID child, CK_CLASSID parent);
|
||||||
|
/**
|
||||||
|
* @brief Get the parent class id of given class id.
|
||||||
|
* @param[in] child The id to class which need to find parent class.
|
||||||
|
* @return The parent class id.
|
||||||
|
* If given class id is invalid, this function always return the class id of CKObject.
|
||||||
|
*/
|
||||||
CK_CLASSID CKGetParentClassID(CK_CLASSID child);
|
CK_CLASSID CKGetParentClassID(CK_CLASSID child);
|
||||||
|
/**
|
||||||
|
* @brief Get the cloest common parent of given two classes.
|
||||||
|
* @param[in] cid1 The id of first class finding common parent.
|
||||||
|
* @param[in] cid2 The id of second class finding common parent.
|
||||||
|
* @return The cloest common parent class id.
|
||||||
|
*/
|
||||||
CK_CLASSID CKGetCommonParent(CK_CLASSID cid1, CK_CLASSID cid2);
|
CK_CLASSID CKGetCommonParent(CK_CLASSID cid1, CK_CLASSID cid2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check whether 'listener' need notified by the deletion of 'deletedObjCid'
|
* @brief Check whether object whose class id is first argument, need to be notified when the objects whose class id is second argument, is deleting.
|
||||||
* @param listener
|
* @param[in] listener The class id of checking whether need to be notified.
|
||||||
* @param deletedObjCid
|
* @param[in] deletedObjCid The class id of deleting object.
|
||||||
* @return true if need notify
|
* @return True if it need to be notified, otherwise false.
|
||||||
|
* If the class id of checking is invalid, this function always return false.
|
||||||
*/
|
*/
|
||||||
bool CKIsNeedNotify(CK_CLASSID listener, CK_CLASSID deletedObjCid);
|
bool CKIsNeedNotify(CK_CLASSID listener, CK_CLASSID deletedObjCid);
|
||||||
/**
|
/**
|
||||||
* @brief Get all object cid need to be notified when 'delObjCids' matched objects are deleting.
|
* @brief Get all class ids need to be notified when objects whose class id included in \c delObjCids are deleting.
|
||||||
* @param delObjCids
|
* @param[in] delObjCids The bit array representing class ids which need to be queried.
|
||||||
* @param cidCount
|
* @return The queried bit array representing class ids need to be notified.
|
||||||
* @return
|
* @see CKIsNeedNotify()
|
||||||
*/
|
*/
|
||||||
XContainer::XBitArray CKGetAllNotifyClassID(const XContainer::XBitArray& delObjCids);
|
XContainer::XBitArray CKGetAllNotifyClassID(const XContainer::XBitArray& delObjCids);
|
||||||
|
|
||||||
// ========== Initializations functions ==========
|
// ========== Initializations Functions ==========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize CK engine.
|
||||||
|
* @details You must call this function before anything.
|
||||||
|
* @return Error code about initializing.
|
||||||
|
* @see CKShutdown()
|
||||||
|
*/
|
||||||
CKERROR CKStartUp();
|
CKERROR CKStartUp();
|
||||||
|
/**
|
||||||
|
* @brief Shutdown CK engine.
|
||||||
|
* @details You must call this function after you have done all things.
|
||||||
|
* @return Error code about shutdown.
|
||||||
|
* @see CKStartUp()
|
||||||
|
*/
|
||||||
CKERROR CKShutdown();
|
CKERROR CKShutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../VTAll.hpp"
|
#include "../VTInternal.hpp"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -54,9 +54,9 @@ namespace LibCmo::CK2 {
|
|||||||
LockedReadBufferDeleter() : m_Host(nullptr), m_ConsumedSize(0) {}
|
LockedReadBufferDeleter() : m_Host(nullptr), m_ConsumedSize(0) {}
|
||||||
LockedReadBufferDeleter(CKStateChunk* host, CKDWORD init_size) :
|
LockedReadBufferDeleter(CKStateChunk* host, CKDWORD init_size) :
|
||||||
m_Host(host), m_ConsumedSize(init_size) {}
|
m_Host(host), m_ConsumedSize(init_size) {}
|
||||||
LIBCMO_DEFAULT_COPY_MOVE(LockedReadBufferDeleter);
|
YYCC_DEF_CLS_COPY_MOVE(LockedReadBufferDeleter);
|
||||||
|
|
||||||
void operator()(LIBCMO_UNUSED const void* buf);
|
void operator()(const void* /*buf*/);
|
||||||
void SetConsumedSize(CKDWORD newsize);
|
void SetConsumedSize(CKDWORD newsize);
|
||||||
private:
|
private:
|
||||||
CKStateChunk* m_Host;
|
CKStateChunk* m_Host;
|
||||||
@ -68,9 +68,9 @@ namespace LibCmo::CK2 {
|
|||||||
LockedWriteBufferDeleter() : m_Host(nullptr), m_ConsumedSize(0) {}
|
LockedWriteBufferDeleter() : m_Host(nullptr), m_ConsumedSize(0) {}
|
||||||
LockedWriteBufferDeleter(CKStateChunk* host, CKDWORD init_size) :
|
LockedWriteBufferDeleter(CKStateChunk* host, CKDWORD init_size) :
|
||||||
m_Host(host), m_ConsumedSize(init_size) {}
|
m_Host(host), m_ConsumedSize(init_size) {}
|
||||||
LIBCMO_DEFAULT_COPY_MOVE(LockedWriteBufferDeleter);
|
YYCC_DEF_CLS_COPY_MOVE(LockedWriteBufferDeleter);
|
||||||
|
|
||||||
void operator()(LIBCMO_UNUSED const void* buf);
|
void operator()(const void* /*buf*/);
|
||||||
void SetConsumedSize(CKDWORD newsize);
|
void SetConsumedSize(CKDWORD newsize);
|
||||||
private:
|
private:
|
||||||
CKStateChunk* m_Host;
|
CKStateChunk* m_Host;
|
||||||
@ -82,7 +82,7 @@ namespace LibCmo::CK2 {
|
|||||||
BufferDeleter() : m_Host(nullptr), m_BufSize(0) {}
|
BufferDeleter() : m_Host(nullptr), m_BufSize(0) {}
|
||||||
BufferDeleter(CKStateChunk* host, CKDWORD bufsize) :
|
BufferDeleter(CKStateChunk* host, CKDWORD bufsize) :
|
||||||
m_Host(host), m_BufSize(bufsize) {}
|
m_Host(host), m_BufSize(bufsize) {}
|
||||||
LIBCMO_DEFAULT_COPY_MOVE(BufferDeleter);
|
YYCC_DEF_CLS_COPY_MOVE(BufferDeleter);
|
||||||
|
|
||||||
void operator()(const void* buf);
|
void operator()(const void* buf);
|
||||||
CKDWORD GetBufferSize() const;
|
CKDWORD GetBufferSize() const;
|
||||||
|
@ -101,7 +101,7 @@ namespace LibCmo::CK2 {
|
|||||||
|
|
||||||
#pragma region Self Used Data Struct
|
#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;
|
if (m_Host == nullptr) return;
|
||||||
m_Host->UnLockReadBuffer(m_ConsumedSize);
|
m_Host->UnLockReadBuffer(m_ConsumedSize);
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ namespace LibCmo::CK2 {
|
|||||||
m_ConsumedSize = newsize;
|
m_ConsumedSize = newsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKStateChunk::LockedWriteBufferDeleter::operator()(LIBCMO_UNUSED const void* buf) {
|
void CKStateChunk::LockedWriteBufferDeleter::operator()(const void* /*buf*/) {
|
||||||
if (m_Host == nullptr) return;
|
if (m_Host == nullptr) return;
|
||||||
m_Host->UnLockWriteBuffer(m_ConsumedSize);
|
m_Host->UnLockWriteBuffer(m_ConsumedSize);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ namespace LibCmo::CK2 {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// failed, report to context
|
// failed, report to context
|
||||||
m_BindContext->OutputToConsoleEx("CKStateChunk::LockReadBuffer at buffer pos %" PRIuCKDWORD ".", this->m_Parser.m_CurrentPos);
|
m_BindContext->OutputToConsoleEx(u8"CKStateChunk::LockReadBuffer at buffer pos %" PRIuCKDWORD ".", this->m_Parser.m_CurrentPos);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ namespace LibCmo::CK2 {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// failed, report to context
|
// failed, report to context
|
||||||
m_BindContext->OutputToConsoleEx("CKStateChunk::UnLockReadBuffer at buffer pos %" PRIuCKDWORD ".", this->m_Parser.m_CurrentPos);
|
m_BindContext->OutputToConsoleEx(u8"CKStateChunk::UnLockReadBuffer at buffer pos %" PRIuCKDWORD ".", this->m_Parser.m_CurrentPos);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ namespace LibCmo::CK2 {
|
|||||||
// MARK: the written string has NULL terminal.
|
// MARK: the written string has NULL terminal.
|
||||||
// strByteSize also include NULL terminal,
|
// strByteSize also include NULL terminal,
|
||||||
// so we need minus 1 when resizing (not ReadByteData, because we still need read NULL terminal to skip it.)
|
// so we need minus 1 when resizing (not ReadByteData, because we still need read NULL terminal to skip it.)
|
||||||
XContainer::XString cache;
|
std::string cache;
|
||||||
cache.resize(strByteSize - 1);
|
cache.resize(strByteSize - 1);
|
||||||
if (!this->ReadByteData(cache.data(), strByteSize)) {
|
if (!this->ReadByteData(cache.data(), strByteSize)) {
|
||||||
strl->clear();
|
strl->clear();
|
||||||
@ -148,7 +148,13 @@ namespace LibCmo::CK2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// convert encoding
|
// convert encoding
|
||||||
m_BindContext->GetUtf8String(cache, *strl);
|
if (!m_BindContext->GetUTF8String(cache, *strl)) {
|
||||||
|
m_BindContext->OutputToConsole(u8"Fail to get UTF8 string when reading CKStateChunk. Some objects may be loaded incorrectly.");
|
||||||
|
strl->clear();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// okey
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ namespace LibCmo::CK2 {
|
|||||||
*ppData = this->m_pData + this->m_Parser.m_CurrentPos;
|
*ppData = this->m_pData + this->m_Parser.m_CurrentPos;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
m_BindContext->OutputToConsoleEx("CKStateChunk::LockWriteBuffer at buffer pos %" PRIuCKDWORD ".", this->m_Parser.m_CurrentPos);
|
m_BindContext->OutputToConsoleEx(u8"CKStateChunk::LockWriteBuffer at buffer pos %" PRIuCKDWORD ".", this->m_Parser.m_CurrentPos);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ namespace LibCmo::CK2 {
|
|||||||
this->m_Parser.m_CurrentPos += size_in_dword;
|
this->m_Parser.m_CurrentPos += size_in_dword;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
m_BindContext->OutputToConsoleEx("CKStateChunk::UnLockWriteBuffer at buffer pos %" PRIuCKDWORD ".", this->m_Parser.m_CurrentPos);
|
m_BindContext->OutputToConsoleEx(u8"CKStateChunk::UnLockWriteBuffer at buffer pos %" PRIuCKDWORD ".", this->m_Parser.m_CurrentPos);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,8 +137,9 @@ namespace LibCmo::CK2 {
|
|||||||
if (strl == nullptr) return false;
|
if (strl == nullptr) return false;
|
||||||
|
|
||||||
// convert encoding
|
// convert encoding
|
||||||
XContainer::XString cache;
|
std::string cache;
|
||||||
m_BindContext->GetNativeString(*strl, cache);
|
if (!m_BindContext->GetOrdinaryString(*strl, cache))
|
||||||
|
m_BindContext->OutputToConsole(u8"Fail to get ordinary string when saving CKStateChunk. Some objects may be saved incorrectly.");
|
||||||
|
|
||||||
if (cache.empty()) {
|
if (cache.empty()) {
|
||||||
// write zero string
|
// write zero string
|
||||||
|
@ -12,83 +12,88 @@
|
|||||||
namespace LibCmo {
|
namespace LibCmo {
|
||||||
|
|
||||||
// Types.
|
// Types.
|
||||||
// These types is general types used in every module.
|
// These types are general types used in every module.
|
||||||
// So we declare them in LibCmo, not LibCmo::CK2 to make sure every module can use it.
|
// So we declare them in LibCmo, not LibCmo::CK2 to make sure every module can use it.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief General Const String Type. Encoding Unrelated.
|
* @brief The representation of constant UTF8 string pointer.
|
||||||
*/
|
*/
|
||||||
using CKSTRING = const char*;
|
using CKSTRING = const char8_t*;
|
||||||
/**
|
/**
|
||||||
* @brief Changeble CKSTRING.
|
* @brief The representation of mutable CKSTRING (UTF8 string pointer).
|
||||||
* @see CKSTRING
|
* @see CKSTRING
|
||||||
*/
|
*/
|
||||||
using CKMUTSTRING = char*;
|
using CKMUTSTRING = char8_t*;
|
||||||
/**
|
/**
|
||||||
* @brief The Representation of Single Character (1 byte). Encoding Unrelated.
|
* @brief The representation of single UTF8 code unit (1 byte).
|
||||||
* @remark
|
* @remarks
|
||||||
* + Only used with string process.
|
* \li Only used with string process.
|
||||||
* + For memory representation and moving, use CKBYTE instead.
|
* \li For memory representation and operating, use CKBYTE instead.
|
||||||
* @see CKBYTE
|
* @see CKSTRING, CKBYTE
|
||||||
*/
|
*/
|
||||||
using CKCHAR = char;
|
using CKCHAR = char8_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Always Represent a Byte (1 byte, unsigned). Platform Independent.
|
* @brief Platform independent representation of a byte (1 byte, unsigned).
|
||||||
* @remark
|
* @remarks
|
||||||
* + This type should only be used when representing memory data or position.
|
* \li This type should only be used when representing memory data or position.
|
||||||
* + If you want to represent a char, or a sequence of chars, use CKCHAR instead.
|
* \li If you want to represent a character code unit, or a sequence of chars, use CKCHAR instead.
|
||||||
* @see CKCHAR
|
* @see CKCHAR
|
||||||
*/
|
*/
|
||||||
using CKBYTE = uint8_t;
|
using CKBYTE = uint8_t;
|
||||||
/**
|
/**
|
||||||
* @brief Always Represent a WORD (2 byte, unsigned). Platform Independent.
|
* @brief Platform independent representation of a WORD (2 byte, unsigned).
|
||||||
*/
|
*/
|
||||||
using CKWORD = uint16_t;
|
using CKWORD = uint16_t;
|
||||||
/**
|
/**
|
||||||
* @brief Always Represent a DWORD (4 byte, unsigned). Platform Independent.
|
* @brief Platform independent representation of a DWORD (4 byte, unsigned).
|
||||||
* @see CKINT
|
* @see CKINT
|
||||||
*/
|
*/
|
||||||
using CKDWORD = uint32_t;
|
using CKDWORD = uint32_t;
|
||||||
/**
|
/**
|
||||||
* @brief Always Represent a QWORD (8 byte, unsigned). Platform Independent.
|
* @brief Platform independent representation of a QWORD (8 byte, unsigned).
|
||||||
*/
|
*/
|
||||||
using CKQWORD = uint64_t;
|
using CKQWORD = uint64_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The Int type used in LibCmo.
|
* @brief Platform independent representation of \c int.
|
||||||
* @remark
|
* @remarks
|
||||||
* + All 'int' type in original Virtools SDK should be replaced with CKINT in this project if needed.
|
* \li All \c int type presented in original Virtools SDK should be replaced by this type, CKINT, in this project if needed.
|
||||||
* + This type also can be seen as the equvalent of signed CKDWORD.
|
* \li This type also can be seen as the equvalent of signed CKDWORD.
|
||||||
* @see CKDWORD
|
* @see CKDWORD
|
||||||
*/
|
*/
|
||||||
using CKINT = int32_t;
|
using CKINT = int32_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Always Represent a float (32 bit). Platform Independent.
|
* @brief Platform independent representation of a float (32 bit floating point type).
|
||||||
*/
|
*/
|
||||||
using CKFLOAT = float;
|
using CKFLOAT = float;
|
||||||
/**
|
/**
|
||||||
* @brief Always Represent a double (64 bit). Platform Independent.
|
* @brief Platform independent representation of a double (64 bit floating point type).
|
||||||
*/
|
*/
|
||||||
using CKDOUBLE = double;
|
using CKDOUBLE = double;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Represent a x86 Platform Pointer.
|
* @brief Platform independent representation of a x86 pointer.
|
||||||
* @remark
|
* @remark
|
||||||
* + This type only can be used when replacing pointer in old Virtools struct / class.
|
* \li This type only should be used when replacing pointer in old Virtools struct / class.
|
||||||
* + Due to Virtools shitty design, in some cases we need read data with x86 memory layout from file.
|
* \li Due to Virtools shitty design, in some cases we need read data with x86 memory layout from file.
|
||||||
* So we use this type to replace native pointer in struct existed in Virtools SDK to make sure this
|
* So we use this type to replace native pointer in struct existed in Virtools SDK
|
||||||
* program can run perfectly on x64 and more architectures.
|
* to make sure this program can run perfectly on x64 and more architectures.
|
||||||
* + A example can be found in CKTexture::Load().
|
* \li A example usage can be found in CK2::ObjImpls::CKTexture::Load().
|
||||||
*/
|
*/
|
||||||
using CKPTR = uint32_t;
|
using CKPTR = uint32_t;
|
||||||
|
|
||||||
// Format constants for the std::fprintf family of functions
|
// Format macro for \c std::printf family of functions
|
||||||
|
|
||||||
#define PRI_CKSTRING "s"
|
#define PRI_CKSTRING "s"
|
||||||
#define PRI_CKCHAR "c"
|
#define PRI_CKCHAR "c"
|
||||||
|
|
||||||
|
#define CKBYTE_C(v) UINT8_C(v)
|
||||||
|
#define CKWORD_C(v) UINT16_C(v)
|
||||||
|
#define CKDWORD_C(v) UINT32_C(v)
|
||||||
|
#define CKQWORD_C(v) UINT64_C(v)
|
||||||
|
|
||||||
#define PRIuCKBYTE PRIu8
|
#define PRIuCKBYTE PRIu8
|
||||||
#define PRIuCKWORD PRIu16
|
#define PRIuCKWORD PRIu16
|
||||||
#define PRIuCKDWORD PRIu32
|
#define PRIuCKDWORD PRIu32
|
||||||
@ -104,6 +109,8 @@ namespace LibCmo {
|
|||||||
#define PRIXCKDWORD PRIX32
|
#define PRIXCKDWORD PRIX32
|
||||||
#define PRIXCKQWORD PRIX64
|
#define PRIXCKQWORD PRIX64
|
||||||
|
|
||||||
|
#define CKINT_C(v) INT32_C(v)
|
||||||
|
|
||||||
#define PRIiCKINT PRIi32
|
#define PRIiCKINT PRIi32
|
||||||
|
|
||||||
#define PRIfCKFLOAT "f"
|
#define PRIfCKFLOAT "f"
|
||||||
@ -113,33 +120,46 @@ namespace LibCmo {
|
|||||||
|
|
||||||
#define PRIxCKPTR PRIx32
|
#define PRIxCKPTR PRIx32
|
||||||
#define PRIXCKPTR PRIX32
|
#define PRIXCKPTR PRIX32
|
||||||
|
|
||||||
/*
|
/**
|
||||||
The convenient sizeof which return CKDWORD, not size_t.
|
* @brief The convenient sizeof macro which return \c CKDWORD instead of \c size_t.
|
||||||
|
* @details This macro is frequently used in LibCmo.
|
||||||
|
* Because LibCmo use \c CKDWORD, not \c size_t everywhere.
|
||||||
*/
|
*/
|
||||||
#define CKSizeof(_Ty) (static_cast<LibCmo::CKDWORD>(sizeof(_Ty)))
|
#define CKSizeof(_Ty) (static_cast<::LibCmo::CKDWORD>(sizeof(_Ty)))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== CK2 Section ==========
|
// ========== CK2 Section ==========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The CK2 part of LibCmo. The main part of LibCmo.
|
||||||
|
* @details
|
||||||
|
* This namespace include most implementations of LibCmo,
|
||||||
|
* including important CKContext, CKStateChunk and etc.
|
||||||
|
*/
|
||||||
namespace LibCmo::CK2 {
|
namespace LibCmo::CK2 {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Unique Identifier for all Objects instanciated in a given CKContext
|
* @brief Unique identifier for all CK2 objects instantiated in CKContext
|
||||||
@remarks
|
* @remarks
|
||||||
+ Each instance of CKObject and derived classes are automatically given a global unique
|
* \li Each instance of ObjImpls::CKObject and derived classes are automatically given a global unique ID at creation time.
|
||||||
ID at creation time. This ID can be accessed through the CKObject::GetID method.
|
* This ID can be accessed through the ObjImpls::CKObject::GetID() method.
|
||||||
It is safer, though a bit slower, to reference object through their global ID than through
|
* It is safer, though a bit slower, to reference object through their global ID than through a direct pointer.
|
||||||
a direct pointer reference. In any case the referenced object may be deleted even though
|
* In some cases the referenced object may be deleted even though the client has a object ID for it.
|
||||||
the client object has a ID for it. The client object should verify that the referenced object
|
* The client should verify that the referenced object still exists when used via CKContext::GetObject().
|
||||||
still exists when used with the CKGetObject function.
|
* \li The global ID for an instance remains unique and unchanged through a application session,
|
||||||
+ The global ID for an instance remains unique and unchanged through a application session, but there
|
* but there is no guarateen that this ID will be the same when a level is saved and loaded back again.
|
||||||
is no garanty that this ID will be the same when a level is saved and loaded back again.
|
* @see ObjImpls::CKObject::GetID(), CKContext::GetObject()
|
||||||
@see CKObject::GetID, CKContext::GetObject
|
|
||||||
*/
|
*/
|
||||||
using CK_ID = CKDWORD;
|
using CK_ID = CKDWORD;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The enumeration of all CK2 errors
|
||||||
|
* @details
|
||||||
|
* Some CK2, Vx, XContainer functions will try to return a error code to indicate
|
||||||
|
* whether given operation has been done successfully.
|
||||||
|
*/
|
||||||
enum class CKERROR : CKINT {
|
enum class CKERROR : CKINT {
|
||||||
CKERR_OK = 0, /**< Operation successful */
|
CKERR_OK = 0, /**< Operation successful */
|
||||||
CKERR_INVALIDPARAMETER = -1, /**< One of the parameter passed to the function was invalid */
|
CKERR_INVALIDPARAMETER = -1, /**< One of the parameter passed to the function was invalid */
|
||||||
@ -195,14 +215,16 @@ namespace LibCmo::CK2 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Per Class Unique Identifier.
|
* @brief Unique class identifier.
|
||||||
@remark
|
* @remarks
|
||||||
+ Each class derived from the CKObject class has a unique class ID.
|
* \li Each class derived from the ObjImpls::CKObject class has a unique class ID.
|
||||||
+ This ID can be accessed through each instance of these classes, with the
|
* \li This ID can be accessed through each instance of these classes, with the ObjImpls::CKObject::GetClassID() method.
|
||||||
CKObject::GetClassID method.
|
* \li This class ID is used internally for various matching operations, like matching behaviors on objects, etc..
|
||||||
+ This class ID is used internally for various matching operations, like matching behaviors on
|
* \li Identifiers listed in there is CK2 builtin class identifier list.
|
||||||
objects, etc..
|
* In original Virtools SDK, user can use plugin mechanism to register more class identifier in runtime.
|
||||||
@see CKObject::GetClassID, CKIsChildClassOf, Class Identifiers
|
* Virtools only guarateen that identifiers listed in there must correspond with its real meaning.
|
||||||
|
* However, there is no guarateen that IDs not listed in there will be the same when Virtools engine quit and initialized back again.
|
||||||
|
* @see ObjImpls::CKObject::GetClassID(), CKIsChildClassOf()
|
||||||
*/
|
*/
|
||||||
enum class CK_CLASSID : CKINT {
|
enum class CK_CLASSID : CKINT {
|
||||||
CKCID_OBJECT = 1,
|
CKCID_OBJECT = 1,
|
||||||
@ -289,8 +311,10 @@ namespace LibCmo::CK2 {
|
|||||||
#define PRIiCLASSID PRIiCKINT
|
#define PRIiCLASSID PRIiCKINT
|
||||||
|
|
||||||
// ========== Class List ==========
|
// ========== Class List ==========
|
||||||
|
// We declare these classes in there to make sure that
|
||||||
|
// following code can refer their pointer type safely.
|
||||||
|
|
||||||
// Objects and derivated classes
|
// Objects and derivated classes
|
||||||
|
|
||||||
namespace ObjImpls {
|
namespace ObjImpls {
|
||||||
class CKObject;
|
class CKObject;
|
||||||
class CKInterfaceObjectManager;
|
class CKInterfaceObjectManager;
|
||||||
@ -345,7 +369,7 @@ namespace LibCmo::CK2 {
|
|||||||
class CKGrid;
|
class CKGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- Misc
|
// Misc
|
||||||
class CKBehaviorPrototype;
|
class CKBehaviorPrototype;
|
||||||
class CKMessage;
|
class CKMessage;
|
||||||
class CK2dCurvePoint;
|
class CK2dCurvePoint;
|
||||||
@ -362,7 +386,7 @@ namespace LibCmo::CK2 {
|
|||||||
class CKFileExtension;
|
class CKFileExtension;
|
||||||
class CKVertexBuffer;
|
class CKVertexBuffer;
|
||||||
|
|
||||||
//--- Managers
|
// Managers
|
||||||
namespace MgrImpls {
|
namespace MgrImpls {
|
||||||
class CKBaseManager;
|
class CKBaseManager;
|
||||||
class CKObjectManager;
|
class CKObjectManager;
|
||||||
@ -379,13 +403,14 @@ namespace LibCmo::CK2 {
|
|||||||
class CKPluginManager;
|
class CKPluginManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Data Handlers
|
||||||
namespace DataHandlers {
|
namespace DataHandlers {
|
||||||
class CKBitmapHandler;
|
class CKBitmapHandler;
|
||||||
class CKMovieHandler;
|
class CKMovieHandler;
|
||||||
class CKSoundHandler;
|
class CKSoundHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--- Important classes
|
// Important classes (rewritten hugely)
|
||||||
class CKContext;
|
class CKContext;
|
||||||
class CKStateChunk;
|
class CKStateChunk;
|
||||||
class CKFileReader;
|
class CKFileReader;
|
||||||
@ -393,32 +418,34 @@ namespace LibCmo::CK2 {
|
|||||||
class CKFileVisitor;
|
class CKFileVisitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Global Unique Identifier Struture.
|
* @brief Global unique identifier struture.
|
||||||
@remark
|
* @remarks
|
||||||
+ Guids are used to uniquely identify plugins,operation types, parameter types and behavior prototypes.
|
* \li Guids are used to uniquely identify plugins, operation types, parameter types and behavior prototypes.
|
||||||
+ Its defined as
|
* \li Comparison operators are defined so CKGUID can be compared with ==, != , <, > operators.
|
||||||
```
|
* \li It's defined as following code
|
||||||
typedef struct CKGUID {
|
* \code
|
||||||
union {
|
* typedef struct CKGUID {
|
||||||
struct { CKDWORD d1,d2; };
|
* union {
|
||||||
CKDWORD d[2];
|
* struct { CKDWORD d1,d2; };
|
||||||
};
|
* CKDWORD d[2];
|
||||||
};
|
* };
|
||||||
```
|
* };
|
||||||
+ Comparison operators are defined so CKGUIDS can be compared with
|
* \endcode
|
||||||
==, != , <, > operators.
|
|
||||||
|
|
||||||
@see Pre-Registred Parameter Types, ParameterOperation Types
|
|
||||||
*/
|
*/
|
||||||
struct CKGUID {
|
struct CKGUID {
|
||||||
CKDWORD d1, d2;
|
CKDWORD d1, d2;
|
||||||
|
|
||||||
constexpr CKGUID(CKDWORD gd1 = 0, CKDWORD gd2 = 0) : d1(gd1), d2(gd2) {}
|
constexpr CKGUID(CKDWORD gd1 = 0, CKDWORD gd2 = 0) : d1(gd1), d2(gd2) {}
|
||||||
CKGUID(const CKGUID& rhs) : d1(rhs.d1), d2(rhs.d2) {}
|
CKGUID(const CKGUID& rhs) : d1(rhs.d1), d2(rhs.d2) {}
|
||||||
|
CKGUID(CKGUID&& rhs) : d1(rhs.d1), d2(rhs.d2) {}
|
||||||
CKGUID& operator=(const CKGUID& rhs) {
|
CKGUID& operator=(const CKGUID& rhs) {
|
||||||
this->d1 = rhs.d1;
|
this->d1 = rhs.d1;
|
||||||
this->d2 = rhs.d2;
|
this->d2 = rhs.d2;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
CKGUID& operator=(CKGUID&& rhs) {
|
||||||
|
this->d1 = rhs.d1;
|
||||||
|
this->d2 = rhs.d2;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "CKBitmapHandler.hpp"
|
#include "CKBitmapHandler.hpp"
|
||||||
#include "stb_image.h"
|
#include <stb_image.h>
|
||||||
#include "stb_image_write.h"
|
#include <stb_image_write.h>
|
||||||
|
|
||||||
namespace LibCmo::CK2::DataHandlers {
|
namespace LibCmo::CK2::DataHandlers {
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
|
|
||||||
static bool StbReadFile(CKSTRING u8filename, VxMath::VxImageDescEx* read_image) {
|
static bool StbReadFile(CKSTRING u8filename, VxMath::VxImageDescEx* read_image) {
|
||||||
if (u8filename == nullptr || read_image == nullptr) return false;
|
if (u8filename == nullptr || read_image == nullptr) return false;
|
||||||
FILE* fs = EncodingHelper::U8FOpen(u8filename, "rb");
|
FILE* fs = YYCC::IOHelper::UTF8FOpen(u8filename, u8"rb");
|
||||||
if (fs == nullptr) return false;
|
if (fs == nullptr) return false;
|
||||||
|
|
||||||
// read data
|
// read data
|
||||||
@ -210,7 +210,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
static bool StbSaveFile(CKSTRING u8filename, const VxMath::VxImageDescEx* write_image, bool save_alpha, SaveOperation oper) {
|
static bool StbSaveFile(CKSTRING u8filename, const VxMath::VxImageDescEx* write_image, bool save_alpha, SaveOperation oper) {
|
||||||
if (u8filename == nullptr || write_image == nullptr) return false;
|
if (u8filename == nullptr || write_image == nullptr) return false;
|
||||||
if (!write_image->IsValid()) return false;
|
if (!write_image->IsValid()) return false;
|
||||||
FILE* fs = EncodingHelper::U8FOpen(u8filename, "wb");
|
FILE* fs = YYCC::IOHelper::UTF8FOpen(u8filename, u8"wb");
|
||||||
if (fs == nullptr) return false;
|
if (fs == nullptr) return false;
|
||||||
|
|
||||||
// allocate buffer and convert data from ARGB to RGBA or RGB
|
// allocate buffer and convert data from ARGB to RGBA or RGB
|
||||||
@ -285,7 +285,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
|
|
||||||
#pragma region CKBitmapBMPHandler
|
#pragma region CKBitmapBMPHandler
|
||||||
|
|
||||||
static const CKBitmapProperties g_BMPProperties(CKGUID(0xBCA97223u, 0x48578BCAu), "Bmp");
|
static const CKBitmapProperties g_BMPProperties(CKGUID(0xBCA97223u, 0x48578BCAu), u8"Bmp");
|
||||||
|
|
||||||
CKBitmapBMPHandler::CKBitmapBMPHandler() :
|
CKBitmapBMPHandler::CKBitmapBMPHandler() :
|
||||||
CKBitmapHandler() {}
|
CKBitmapHandler() {}
|
||||||
@ -330,7 +330,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
|
|
||||||
#pragma region CKBitmapTGAHandler
|
#pragma region CKBitmapTGAHandler
|
||||||
|
|
||||||
static const CKBitmapProperties g_TGAProperties(CKGUID(0x585C7216u, 0x33302657u), "Tga");
|
static const CKBitmapProperties g_TGAProperties(CKGUID(0x585C7216u, 0x33302657u), u8"Tga");
|
||||||
|
|
||||||
CKBitmapTGAHandler::CKBitmapTGAHandler() :
|
CKBitmapTGAHandler::CKBitmapTGAHandler() :
|
||||||
CKBitmapHandler() {}
|
CKBitmapHandler() {}
|
||||||
@ -372,7 +372,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
#pragma region CKBitmapJPGHandler
|
#pragma region CKBitmapJPGHandler
|
||||||
|
|
||||||
// MARK: this GUID is gotten from Virtools 3.5 Plugins.
|
// MARK: this GUID is gotten from Virtools 3.5 Plugins.
|
||||||
static const CKBitmapProperties g_JPGProperties(CKGUID(0x4AE51AC4u, 0x04587D76u), "jpg");
|
static const CKBitmapProperties g_JPGProperties(CKGUID(0x4AE51AC4u, 0x04587D76u), u8"jpg");
|
||||||
// MARK: this quality is gotten from default value of virtools.
|
// MARK: this quality is gotten from default value of virtools.
|
||||||
constexpr int g_JPGDefaultQuality = 75;
|
constexpr int g_JPGDefaultQuality = 75;
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
#pragma region CKBitmapPNGHandler
|
#pragma region CKBitmapPNGHandler
|
||||||
|
|
||||||
// MARK: this GUID is gotten from Virtools 3.5 Plugins.
|
// MARK: this GUID is gotten from Virtools 3.5 Plugins.
|
||||||
static const CKBitmapProperties g_PNGProperties(CKGUID(0x02D45C7Bu, 0x4AAC16ECu), "png");
|
static const CKBitmapProperties g_PNGProperties(CKGUID(0x02D45C7Bu, 0x4AAC16ECu), u8"png");
|
||||||
// MARK: this is compress level gotten from default value of virtools.
|
// MARK: this is compress level gotten from default value of virtools.
|
||||||
constexpr int g_PNGDefaultCompressLevel = 3;
|
constexpr int g_PNGDefaultCompressLevel = 3;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
public:
|
public:
|
||||||
CKBitmapHandler() {}
|
CKBitmapHandler() {}
|
||||||
virtual ~CKBitmapHandler() {}
|
virtual ~CKBitmapHandler() {}
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKBitmapHandler);
|
YYCC_DEL_CLS_COPY_MOVE(CKBitmapHandler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief General CKBitmapHandler getter.
|
* @brief General CKBitmapHandler getter.
|
||||||
@ -102,7 +102,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
public:
|
public:
|
||||||
CKBitmapBMPHandler();
|
CKBitmapBMPHandler();
|
||||||
virtual ~CKBitmapBMPHandler();
|
virtual ~CKBitmapBMPHandler();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKBitmapBMPHandler);
|
YYCC_DEL_CLS_COPY_MOVE(CKBitmapBMPHandler);
|
||||||
|
|
||||||
static const CKBitmapProperties& GetBitmapDefaultProperties();
|
static const CKBitmapProperties& GetBitmapDefaultProperties();
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
public:
|
public:
|
||||||
CKBitmapTGAHandler();
|
CKBitmapTGAHandler();
|
||||||
virtual ~CKBitmapTGAHandler();
|
virtual ~CKBitmapTGAHandler();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKBitmapTGAHandler);
|
YYCC_DEL_CLS_COPY_MOVE(CKBitmapTGAHandler);
|
||||||
|
|
||||||
static const CKBitmapProperties& GetBitmapDefaultProperties();
|
static const CKBitmapProperties& GetBitmapDefaultProperties();
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
public:
|
public:
|
||||||
CKBitmapJPGHandler();
|
CKBitmapJPGHandler();
|
||||||
virtual ~CKBitmapJPGHandler();
|
virtual ~CKBitmapJPGHandler();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKBitmapJPGHandler);
|
YYCC_DEL_CLS_COPY_MOVE(CKBitmapJPGHandler);
|
||||||
|
|
||||||
static const CKBitmapProperties& GetBitmapDefaultProperties();
|
static const CKBitmapProperties& GetBitmapDefaultProperties();
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ namespace LibCmo::CK2::DataHandlers {
|
|||||||
public:
|
public:
|
||||||
CKBitmapPNGHandler();
|
CKBitmapPNGHandler();
|
||||||
virtual ~CKBitmapPNGHandler();
|
virtual ~CKBitmapPNGHandler();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKBitmapPNGHandler);
|
YYCC_DEL_CLS_COPY_MOVE(CKBitmapPNGHandler);
|
||||||
|
|
||||||
static const CKBitmapProperties& GetBitmapDefaultProperties();
|
static const CKBitmapProperties& GetBitmapDefaultProperties();
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
CKBaseManager virtual functions implementations help
|
CKBaseManager virtual functions implementations help
|
||||||
@ -40,7 +40,7 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
XContainer::NSXString::FromCKSTRING(m_ManagerName, name);
|
XContainer::NSXString::FromCKSTRING(m_ManagerName, name);
|
||||||
}
|
}
|
||||||
virtual ~CKBaseManager() {}
|
virtual ~CKBaseManager() {}
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKBaseManager);
|
YYCC_DEL_CLS_COPY_MOVE(CKBaseManager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Acces to Manager GUID
|
@brief Acces to Manager GUID
|
||||||
@ -90,7 +90,7 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
data for your manager.
|
data for your manager.
|
||||||
@see CKStateChunk, LoadData
|
@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.
|
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.
|
+ During a load operation, each manager is automatically called if there was a chunk saved in the file with SaveData.
|
||||||
@see CKStateChunk, 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;
|
return CKERROR::CKERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
CKMANAGER_FUNC_OnSequenceToBeDeleted for this function to get called.
|
CKMANAGER_FUNC_OnSequenceToBeDeleted for this function to get called.
|
||||||
@see Main Virtools Events, CKContext::DestroyObjects, SequenceDeleted
|
@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.
|
@brief Called after objects have been deleted.
|
||||||
@return CK_OK if successful or an error code otherwise.
|
@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.
|
CKMANAGER_FUNC_OnSequenceDeleted for this function to get called.
|
||||||
@see Main Virtools Events, CKContext::DestroyObjects, SequenceToBeDeleted
|
@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:
|
protected:
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
namespace LibCmo::CK2::MgrImpls {
|
namespace LibCmo::CK2::MgrImpls {
|
||||||
|
|
||||||
CKObjectManager::CKObjectManager(CKContext* ctx) :
|
CKObjectManager::CKObjectManager(CKContext* ctx) :
|
||||||
CKBaseManager(ctx, OBJECT_MANAGER_GUID, "Object Manager"),
|
CKBaseManager(ctx, OBJECT_MANAGER_GUID, u8"Object Manager"),
|
||||||
m_ObjectsList(), m_ReturnedObjectOffsets(), m_ObjectCount(0),
|
m_ObjectsList(), m_ReturnedObjectOffsets(), m_ObjectCount(0),
|
||||||
m_GroupGlobalIndex(), m_SceneGlobalIndex(),
|
m_GroupGlobalIndex(), m_SceneGlobalIndex(),
|
||||||
m_ObjectsListByClass(CKGetClassCount()) {}
|
m_ObjectsListByClass(CKGetClassCount()) {}
|
||||||
@ -20,6 +20,7 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
|
|
||||||
// get description first
|
// get description first
|
||||||
const CKClassDesc* desc = CKGetClassDesc(cls);
|
const CKClassDesc* desc = CKGetClassDesc(cls);
|
||||||
|
// if no description, return directly to reject creating object.
|
||||||
if (desc == nullptr) return nullptr;
|
if (desc == nullptr) return nullptr;
|
||||||
|
|
||||||
// allocate a CK_ID first
|
// allocate a CK_ID first
|
||||||
@ -60,13 +61,10 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
|
|
||||||
void CKObjectManager::InternalDestroy(ObjImpls::CKObject* obj) {
|
void CKObjectManager::InternalDestroy(ObjImpls::CKObject* obj) {
|
||||||
// find desc by classid
|
// find desc by classid
|
||||||
// if really we can not find it, we only can delete it directly.
|
|
||||||
const CKClassDesc* desc = CKGetClassDesc(obj->GetClassID());
|
const CKClassDesc* desc = CKGetClassDesc(obj->GetClassID());
|
||||||
if (desc == nullptr) {
|
// a create CKObject instance definitely can find corresponding desc.
|
||||||
delete obj;
|
// if not, throw exception.
|
||||||
return;
|
if (desc == nullptr) throw LogicException("Invalid CK_CLASSID");
|
||||||
}
|
|
||||||
|
|
||||||
// free it
|
// free it
|
||||||
desc->ReleaseFct(m_Context, obj);
|
desc->ReleaseFct(m_Context, obj);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "CKBaseManager.hpp"
|
#include "CKBaseManager.hpp"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
public:
|
public:
|
||||||
CKObjectManager(CKContext* ctx);
|
CKObjectManager(CKContext* ctx);
|
||||||
virtual ~CKObjectManager();
|
virtual ~CKObjectManager();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKObjectManager);
|
YYCC_DEL_CLS_COPY_MOVE(CKObjectManager);
|
||||||
|
|
||||||
// ========== Objects Management ==========
|
// ========== Objects Management ==========
|
||||||
|
|
||||||
|
@ -2,20 +2,16 @@
|
|||||||
|
|
||||||
namespace LibCmo::CK2::MgrImpls {
|
namespace LibCmo::CK2::MgrImpls {
|
||||||
|
|
||||||
#if defined(LIBCMO_OS_WIN32)
|
static constexpr char8_t g_UniqueFolder[] = u8"LibCmo";
|
||||||
static wchar_t g_UniqueFolder[] = L"LibCmo";
|
|
||||||
#else
|
|
||||||
static char g_UniqueFolder[] = "LibCmo";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CKPathManager::CKPathManager(CKContext* ctx) :
|
CKPathManager::CKPathManager(CKContext* ctx) :
|
||||||
CKBaseManager(ctx, PATH_MANAGER_GUID, "Path Manager"),
|
CKBaseManager(ctx, PATH_MANAGER_GUID, u8"Path Manager"),
|
||||||
m_TempFolder(), m_ExtraPathes() {
|
m_TempFolder(), m_ExtraPathes() {
|
||||||
// preset for temp folder
|
// preset for temp folder
|
||||||
// todo: add current CKContext pointer as the part of temp path.
|
// todo: add current CKContext pointer as the part of temp path.
|
||||||
// thus multiple CKContext can work.
|
// thus multiple CKContext can work.
|
||||||
m_TempFolder = std::filesystem::temp_directory_path();
|
m_TempFolder = std::filesystem::temp_directory_path();
|
||||||
m_TempFolder /= g_UniqueFolder;
|
m_TempFolder /= std::filesystem::path(g_UniqueFolder);
|
||||||
std::filesystem::create_directories(m_TempFolder);
|
std::filesystem::create_directories(m_TempFolder);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -24,8 +20,7 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
bool CKPathManager::SetTempFolder(CKSTRING u8_temp) {
|
bool CKPathManager::SetTempFolder(CKSTRING u8_temp) {
|
||||||
if (u8_temp == nullptr) return false;
|
if (u8_temp == nullptr) return false;
|
||||||
|
|
||||||
std::filesystem::path cache;
|
std::filesystem::path cache(u8_temp);
|
||||||
EncodingHelper::U8PathToStdPath(cache, u8_temp);
|
|
||||||
if (std::filesystem::is_directory(cache)) {
|
if (std::filesystem::is_directory(cache)) {
|
||||||
m_TempFolder = cache;
|
m_TempFolder = cache;
|
||||||
return true;
|
return true;
|
||||||
@ -35,28 +30,22 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
XContainer::XString CKPathManager::GetTempFolder() {
|
XContainer::XString CKPathManager::GetTempFolder() {
|
||||||
XContainer::XString result;
|
return this->m_TempFolder.u8string();
|
||||||
EncodingHelper::StdPathToU8Path(result, this->m_TempFolder);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XContainer::XString CKPathManager::GetTempFilePath(CKSTRING u8_filename) {
|
XContainer::XString CKPathManager::GetTempFilePath(CKSTRING u8_filename) {
|
||||||
if (u8_filename == nullptr) return XContainer::XString();
|
if (u8_filename == nullptr) return XContainer::XString();
|
||||||
|
|
||||||
std::filesystem::path stdfilename;
|
std::filesystem::path stdfilename(u8_filename);
|
||||||
EncodingHelper::U8PathToStdPath(stdfilename, u8_filename);
|
|
||||||
auto realfile = this->m_TempFolder / stdfilename;
|
auto realfile = this->m_TempFolder / stdfilename;
|
||||||
|
|
||||||
XContainer::XString result;
|
return realfile.u8string();
|
||||||
EncodingHelper::StdPathToU8Path(result, realfile);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKPathManager::AddPath(CKSTRING u8path) {
|
bool CKPathManager::AddPath(CKSTRING u8path) {
|
||||||
if (u8path == nullptr) return false;
|
if (u8path == nullptr) return false;
|
||||||
|
|
||||||
std::filesystem::path newpath;
|
std::filesystem::path newpath(u8path);
|
||||||
EncodingHelper::U8PathToStdPath(newpath, u8path);
|
|
||||||
if (std::filesystem::is_directory(newpath)) {
|
if (std::filesystem::is_directory(newpath)) {
|
||||||
m_ExtraPathes.emplace_back(std::move(newpath));
|
m_ExtraPathes.emplace_back(std::move(newpath));
|
||||||
return true;
|
return true;
|
||||||
@ -70,8 +59,7 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CKPathManager::ResolveFileName(XContainer::XString& u8_filename) {
|
bool CKPathManager::ResolveFileName(XContainer::XString& u8_filename) {
|
||||||
std::filesystem::path filepath;
|
std::filesystem::path filepath(u8_filename);
|
||||||
EncodingHelper::U8PathToStdPath(filepath, u8_filename.c_str());
|
|
||||||
|
|
||||||
// if it is absolute path, return it directly
|
// if it is absolute path, return it directly
|
||||||
if (filepath.is_absolute()) {
|
if (filepath.is_absolute()) {
|
||||||
@ -81,7 +69,7 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
// test in temp folder
|
// test in temp folder
|
||||||
auto tempfile = m_TempFolder / filepath;
|
auto tempfile = m_TempFolder / filepath;
|
||||||
if (std::filesystem::is_regular_file(tempfile)) {
|
if (std::filesystem::is_regular_file(tempfile)) {
|
||||||
EncodingHelper::StdPathToU8Path(u8_filename, tempfile);
|
u8_filename = tempfile.u8string();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +78,7 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
auto combinedpath = extrapath / filepath;
|
auto combinedpath = extrapath / filepath;
|
||||||
if (std::filesystem::is_regular_file(combinedpath)) {
|
if (std::filesystem::is_regular_file(combinedpath)) {
|
||||||
// this is correct
|
// this is correct
|
||||||
EncodingHelper::StdPathToU8Path(u8_filename, combinedpath);
|
u8_filename = combinedpath.u8string();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,19 +88,17 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CKPathManager::GetFileName(XContainer::XString& u8path) {
|
void CKPathManager::GetFileName(XContainer::XString& u8path) {
|
||||||
std::filesystem::path filepath;
|
std::filesystem::path filepath(u8path);
|
||||||
EncodingHelper::U8PathToStdPath(filepath, u8path.c_str());
|
|
||||||
|
|
||||||
auto result = filepath.filename();
|
auto result = filepath.filename();
|
||||||
EncodingHelper::StdPathToU8Path(u8path, result);
|
u8path = result.u8string();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKPathManager::GetExtension(XContainer::XString& u8path) {
|
void CKPathManager::GetExtension(XContainer::XString& u8path) {
|
||||||
std::filesystem::path filepath;
|
std::filesystem::path filepath(u8path);
|
||||||
EncodingHelper::U8PathToStdPath(filepath, u8path.c_str());
|
|
||||||
|
|
||||||
auto result = filepath.extension();
|
auto result = filepath.extension();
|
||||||
EncodingHelper::StdPathToU8Path(u8path, result);
|
u8path = result.u8string();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "CKBaseManager.hpp"
|
#include "CKBaseManager.hpp"
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ namespace LibCmo::CK2::MgrImpls {
|
|||||||
public:
|
public:
|
||||||
CKPathManager(CKContext* ctx);
|
CKPathManager(CKContext* ctx);
|
||||||
virtual ~CKPathManager();
|
virtual ~CKPathManager();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKPathManager);
|
YYCC_DEL_CLS_COPY_MOVE(CKPathManager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the temp folder of current context.
|
* @brief Set the temp folder of current context.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "CKRenderObject.hpp"
|
#include "CKRenderObject.hpp"
|
||||||
|
|
||||||
namespace LibCmo::CK2::ObjImpls {
|
namespace LibCmo::CK2::ObjImpls {
|
||||||
@ -9,7 +9,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
public:
|
public:
|
||||||
CK3dEntity(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
CK3dEntity(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||||
virtual ~CK3dEntity();
|
virtual ~CK3dEntity();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CK3dEntity);
|
YYCC_DEL_CLS_COPY_MOVE(CK3dEntity);
|
||||||
|
|
||||||
virtual CK_CLASSID GetClassID(void) override {
|
virtual CK_CLASSID GetClassID(void) override {
|
||||||
return CK_CLASSID::CKCID_3DENTITY;
|
return CK_CLASSID::CKCID_3DENTITY;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "CK3dEntity.hpp"
|
#include "CK3dEntity.hpp"
|
||||||
|
|
||||||
namespace LibCmo::CK2::ObjImpls {
|
namespace LibCmo::CK2::ObjImpls {
|
||||||
@ -11,7 +11,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
CK3dEntity(ctx, ckid, name)
|
CK3dEntity(ctx, ckid, name)
|
||||||
{}
|
{}
|
||||||
virtual ~CK3dObject() {}
|
virtual ~CK3dObject() {}
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CK3dObject);
|
YYCC_DEL_CLS_COPY_MOVE(CK3dObject);
|
||||||
|
|
||||||
virtual CK_CLASSID GetClassID(void) override {
|
virtual CK_CLASSID GetClassID(void) override {
|
||||||
return CK_CLASSID::CKCID_3DOBJECT;
|
return CK_CLASSID::CKCID_3DOBJECT;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "CKSceneObject.hpp"
|
#include "CKSceneObject.hpp"
|
||||||
|
|
||||||
namespace LibCmo::CK2::ObjImpls {
|
namespace LibCmo::CK2::ObjImpls {
|
||||||
@ -9,7 +9,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
public:
|
public:
|
||||||
CKBeObject(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
CKBeObject(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||||
virtual ~CKBeObject();
|
virtual ~CKBeObject();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKBeObject);
|
YYCC_DEL_CLS_COPY_MOVE(CKBeObject);
|
||||||
|
|
||||||
virtual CK_CLASSID GetClassID(void) override {
|
virtual CK_CLASSID GetClassID(void) override {
|
||||||
return CK_CLASSID::CKCID_BEOBJECT;
|
return CK_CLASSID::CKCID_BEOBJECT;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "CKBeObject.hpp"
|
#include "CKBeObject.hpp"
|
||||||
|
|
||||||
namespace LibCmo::CK2::ObjImpls {
|
namespace LibCmo::CK2::ObjImpls {
|
||||||
@ -9,7 +9,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
public:
|
public:
|
||||||
CKGroup(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
CKGroup(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||||
virtual ~CKGroup();
|
virtual ~CKGroup();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKGroup);
|
YYCC_DEL_CLS_COPY_MOVE(CKGroup);
|
||||||
|
|
||||||
virtual CK_CLASSID GetClassID(void) override {
|
virtual CK_CLASSID GetClassID(void) override {
|
||||||
return CK_CLASSID::CKCID_GROUP;
|
return CK_CLASSID::CKCID_GROUP;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "CKBeObject.hpp"
|
#include "CKBeObject.hpp"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
public:
|
public:
|
||||||
CKMaterial(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
CKMaterial(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||||
virtual ~CKMaterial();
|
virtual ~CKMaterial();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKMaterial);
|
YYCC_DEL_CLS_COPY_MOVE(CKMaterial);
|
||||||
|
|
||||||
virtual CK_CLASSID GetClassID(void) override {
|
virtual CK_CLASSID GetClassID(void) override {
|
||||||
return CK_CLASSID::CKCID_MATERIAL;
|
return CK_CLASSID::CKCID_MATERIAL;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "CKBeObject.hpp"
|
#include "CKBeObject.hpp"
|
||||||
|
|
||||||
namespace LibCmo::CK2::ObjImpls {
|
namespace LibCmo::CK2::ObjImpls {
|
||||||
@ -19,7 +19,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
public:
|
public:
|
||||||
CKMesh(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
CKMesh(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||||
virtual ~CKMesh();
|
virtual ~CKMesh();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKMesh);
|
YYCC_DEL_CLS_COPY_MOVE(CKMesh);
|
||||||
|
|
||||||
virtual CK_CLASSID GetClassID(void) override {
|
virtual CK_CLASSID GetClassID(void) override {
|
||||||
return CK_CLASSID::CKCID_MESH;
|
return CK_CLASSID::CKCID_MESH;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
CKObject virtual functions implementations help
|
CKObject virtual functions implementations help
|
||||||
@ -40,7 +40,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
public:
|
public:
|
||||||
CKObject(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
CKObject(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||||
virtual ~CKObject();
|
virtual ~CKObject();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKObject);
|
YYCC_DEL_CLS_COPY_MOVE(CKObject);
|
||||||
|
|
||||||
CK_ID GetID(void) const;
|
CK_ID GetID(void) const;
|
||||||
CKSTRING GetName(void) const;
|
CKSTRING GetName(void) const;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "CKBeObject.hpp"
|
#include "CKBeObject.hpp"
|
||||||
|
|
||||||
namespace LibCmo::CK2::ObjImpls {
|
namespace LibCmo::CK2::ObjImpls {
|
||||||
@ -11,7 +11,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
CKBeObject(ctx, ckid, name)
|
CKBeObject(ctx, ckid, name)
|
||||||
{}
|
{}
|
||||||
virtual ~CKRenderObject() {}
|
virtual ~CKRenderObject() {}
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKRenderObject);
|
YYCC_DEL_CLS_COPY_MOVE(CKRenderObject);
|
||||||
|
|
||||||
virtual CK_CLASSID GetClassID(void) override {
|
virtual CK_CLASSID GetClassID(void) override {
|
||||||
return CK_CLASSID::CKCID_RENDEROBJECT;
|
return CK_CLASSID::CKCID_RENDEROBJECT;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "CKObject.hpp"
|
#include "CKObject.hpp"
|
||||||
|
|
||||||
namespace LibCmo::CK2::ObjImpls {
|
namespace LibCmo::CK2::ObjImpls {
|
||||||
@ -11,7 +11,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
CKObject(ctx, ckid, name),
|
CKObject(ctx, ckid, name),
|
||||||
m_Scenes() {}
|
m_Scenes() {}
|
||||||
virtual ~CKSceneObject() {}
|
virtual ~CKSceneObject() {}
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKSceneObject);
|
YYCC_DEL_CLS_COPY_MOVE(CKSceneObject);
|
||||||
|
|
||||||
virtual CK_CLASSID GetClassID(void) override {
|
virtual CK_CLASSID GetClassID(void) override {
|
||||||
return CK_CLASSID::CKCID_SCENEOBJECT;
|
return CK_CLASSID::CKCID_SCENEOBJECT;
|
||||||
|
@ -15,6 +15,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
* All pointers should translate to DWORD(32 bit) for platform independent.
|
* All pointers should translate to DWORD(32 bit) for platform independent.
|
||||||
* Otherwise this struct may be corrupted in x64 platform because pointer is QWORD in x64.
|
* Otherwise this struct may be corrupted in x64 platform because pointer is QWORD in x64.
|
||||||
*/
|
*/
|
||||||
|
#pragma pack(4)
|
||||||
struct FakeBitmapProperties {
|
struct FakeBitmapProperties {
|
||||||
CKINT m_Size;
|
CKINT m_Size;
|
||||||
struct {
|
struct {
|
||||||
@ -23,7 +24,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
}m_ReaderGuid;
|
}m_ReaderGuid;
|
||||||
struct {
|
struct {
|
||||||
// fake CKFileExtension
|
// fake CKFileExtension
|
||||||
CKCHAR m_Data[4];
|
char m_Data[4];
|
||||||
}m_Ext;
|
}m_Ext;
|
||||||
struct {
|
struct {
|
||||||
// fake VxImageDescEx
|
// fake VxImageDescEx
|
||||||
@ -60,6 +61,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
}m_Format;
|
}m_Format;
|
||||||
/*void**/CKPTR m_Data;
|
/*void**/CKPTR m_Data;
|
||||||
};
|
};
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
CKTexture::CKTexture(CKContext* ctx, CK_ID ckid, CKSTRING name) :
|
CKTexture::CKTexture(CKContext* ctx, CK_ID ckid, CKSTRING name) :
|
||||||
CKBeObject(ctx, ckid, name),
|
CKBeObject(ctx, ckid, name),
|
||||||
@ -184,10 +186,13 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
// setup ext and guid
|
// setup ext and guid
|
||||||
props.m_ReaderGuid.d1 = realprops.m_ReaderGuid.d1;
|
props.m_ReaderGuid.d1 = realprops.m_ReaderGuid.d1;
|
||||||
props.m_ReaderGuid.d2 = realprops.m_ReaderGuid.d2;
|
props.m_ReaderGuid.d2 = realprops.m_ReaderGuid.d2;
|
||||||
|
std::string ext;
|
||||||
|
if (!m_Context->GetOrdinaryString(realprops.m_Ext.GetExt(), ext))
|
||||||
|
m_Context->OutputToConsole(u8"Fail to get ordinary string for the extension of bitmap properties when saving CKTexture. Some textures may be saved with blank extension.");
|
||||||
std::memcpy(
|
std::memcpy(
|
||||||
props.m_Ext.m_Data,
|
props.m_Ext.m_Data,
|
||||||
realprops.m_Ext.GetExt(),
|
ext.c_str(),
|
||||||
std::min(CKSizeof(props.m_Ext.m_Data), realprops.m_Ext.GetSize())
|
std::min(CKSizeof(props.m_Ext.m_Data) - CKDWORD_C(1), static_cast<CKDWORD>(ext.size()))
|
||||||
);
|
);
|
||||||
|
|
||||||
// write fake one
|
// write fake one
|
||||||
@ -308,9 +313,15 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
if (buf != nullptr) {
|
if (buf != nullptr) {
|
||||||
FakeBitmapProperties* props = static_cast<FakeBitmapProperties*>(buf.get());
|
FakeBitmapProperties* props = static_cast<FakeBitmapProperties*>(buf.get());
|
||||||
|
|
||||||
|
// get utf8 extension
|
||||||
|
XContainer::XString ext;
|
||||||
|
if (!m_Context->GetUTF8String(props->m_Ext.m_Data, ext))
|
||||||
|
m_Context->OutputToConsole(u8"Fail to get UTF8 extension when loading CKTexture. Some textures may have blank extension in bitmap properties.");
|
||||||
|
|
||||||
|
// get my bitmap prop
|
||||||
CKBitmapProperties myprops(
|
CKBitmapProperties myprops(
|
||||||
CKGUID(props->m_ReaderGuid.d1, props->m_ReaderGuid.d2),
|
CKGUID(props->m_ReaderGuid.d1, props->m_ReaderGuid.d2),
|
||||||
props->m_Ext.m_Data
|
ext.c_str()
|
||||||
);
|
);
|
||||||
m_ImageHost.SetSaveFormat(myprops);
|
m_ImageHost.SetSaveFormat(myprops);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../VTAll.hpp"
|
#include "../../VTInternal.hpp"
|
||||||
#include "../CKBitmapData.hpp"
|
#include "../CKBitmapData.hpp"
|
||||||
#include "CKBeObject.hpp"
|
#include "CKBeObject.hpp"
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ namespace LibCmo::CK2::ObjImpls {
|
|||||||
public:
|
public:
|
||||||
CKTexture(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
CKTexture(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
||||||
virtual ~CKTexture();
|
virtual ~CKTexture();
|
||||||
LIBCMO_DISABLE_COPY_MOVE(CKTexture);
|
YYCC_DEL_CLS_COPY_MOVE(CKTexture);
|
||||||
|
|
||||||
virtual CK_CLASSID GetClassID(void) override {
|
virtual CK_CLASSID GetClassID(void) override {
|
||||||
return CK_CLASSID::CKCID_TEXTURE;
|
return CK_CLASSID::CKCID_TEXTURE;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user