Do some refactor works

* Move CKParameter digger into shared_export
* Update database for new database file
* Rename some name for more readable experience
This commit is contained in:
yyc12345 2021-09-26 15:10:49 +08:00
parent 60930da54c
commit 73a2c9f14a
11 changed files with 554 additions and 715 deletions

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -20,7 +21,7 @@
<PlatformToolset>v100</PlatformToolset>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
@ -28,7 +29,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -108,18 +109,22 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="database.h" />
<ClInclude Include="data_export.h" />
<ClInclude Include="env_export.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="script_export.h" />
<ClInclude Include="shared_export.h" />
<ClInclude Include="virtools_compatible.h" />
<ClInclude Include="vt_menu.h" />
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="database.cpp" />
<ClCompile Include="data_export.cpp" />
<ClCompile Include="env_export.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="script_export.cpp" />
<ClCompile Include="shared_export.cpp" />
<ClCompile Include="virtools_compatible.cpp" />
<ClCompile Include="vt_menu.cpp" />
<ClCompile Include="vt_player.cpp" />

View File

@ -33,240 +33,15 @@
<ClInclude Include="vt_menu.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CK2dEntity.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CK3dEntity.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKAll.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKAttributeManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKBaseManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKBehavior.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKBehaviorIO.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKBehaviorManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKBehaviorPrototype.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKBeObject.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKBitmapData.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKCamera.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKCollisionManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKContext.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKDataArray.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKDef.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKdefines2.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKDependencies.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKEnums.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKError.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKGlobals.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKGroup.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKInputManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKLevel.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKLight.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKMaterial.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKMesh.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKMessage.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKMessageManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKObject.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKObjectArray.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKObjectDeclaration.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKParameter.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKParameterIn.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKParameterManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKParameterOperation.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKPathManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKPluginManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKRenderContext.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKRenderManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKRenderObject.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKScene.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKSceneObject.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKSound.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKSoundManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKSprite.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKSprite3D.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKSpriteText.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKStateObject.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKTexture.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKTimeManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\CKTypes.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\Vx2dVector.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxAllocator.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxColor.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxFrustum.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxMath.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxMathDefines.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxMatrix.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxMutex.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxPlane.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxQuaternion.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxRay.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxRect.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxSphere.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\VxVector.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XArray.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XBitArray.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XClassArray.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XHashFun.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XHashTable.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XObjectArray.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XSArray.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XSHashTable.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XSmartPtr.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XString.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="D:\BallanceModLoader\virtools\XUtil.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="virtools_compatible.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="shared_export.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="data_export.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="database.cpp">
@ -287,156 +62,15 @@
<ClCompile Include="vt_player.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CK2dEntity.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CK3dEntity.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKAttributeManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKBaseManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKBehavior.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKBehaviorIO.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKBehaviorManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKBehaviorPrototype.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKBeObject.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKBitmapData.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKCamera.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKCollisionManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKContext.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKDataArray.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKGlobals.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKGroup.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKInputManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKLevel.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKLight.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKMaterial.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKMesh.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKMessage.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKMessageManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKObject.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKObjectArray.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKObjectDeclaration.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKParameter.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKParameterIn.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKParameterManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKParameterOperation.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKPathManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKPluginManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKRenderContext.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKRenderManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKRenderObject.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKScene.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKSceneObject.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKSound.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKSoundManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKSprite.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKSprite3D.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKSpriteText.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKStateObject.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKTexture.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\CKTimeManager.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\VxMath.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\VxMatrix.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\VxQuaternion.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="D:\BallanceModLoader\virtools\XString.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="virtools_compatible.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="shared_export.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="data_export.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="SuperScriptMaterializer.def">

View File

@ -0,0 +1,2 @@
#include "data_export.h"

View File

@ -0,0 +1,9 @@
#if !defined(_YYCDLL_DATA_EXPORT_H__IMPORTED_)
#define _YYCDLL_DATA_EXPORT_H__IMPORTED_
#include "stdafx.h"
#include "database.h"
void DigCKObjectData(CKObject* cko, scriptDatabase* db, db_shared_dictData* helper, EXPAND_CK_ID parents);
#endif

View File

@ -3,20 +3,20 @@
#pragma region helper
void dbScriptDataStructHelper::init(CKParameterManager* paramManager) {
_dbCKBehavior = new dbCKBehavior();
_dbCKScript = new dbCKScript();
_db_pTarget = new db_pTarget();
_db_pIn = new db_pIn();
_db_pOut = new db_pOut();
_db_bIn = new db_bIn();
_db_bOut = new db_bOut();
_db_bLink = new db_bLink();
_db_pLocal = new db_pLocal();
_db_pAttr = new db_pAttr();
_db_pLink = new db_pLink();
_db_pData = new db_pData();
_db_pOper = new db_pOper();
_db_eLink = new db_eLink();
_db_behavior = new db_script_behavior();
_db_script = new db_script_script();
_db_pTarget = new db_script_pTarget();
_db_pIn = new db_script_pIn();
_db_pOut = new db_script_pOut();
_db_bIn = new db_script_bIn();
_db_bOut = new db_script_bOut();
_db_bLink = new db_script_bLink();
_db_pLocal = new db_script_pLocal();
_db_pAttr = new db_script_pAttr();
_db_pLink = new db_script_pLink();
_db_pData = new db_script_pData();
_db_pOper = new db_script_pOper();
_db_eLink = new db_script_eLink();
_parameterManager = paramManager;
_stringCache = (char*)malloc(STRINGCACHE_SIZE * sizeof(char));
@ -25,8 +25,8 @@ void dbScriptDataStructHelper::init(CKParameterManager* paramManager) {
}
void dbScriptDataStructHelper::dispose() {
delete _dbCKBehavior;
delete _dbCKScript;
delete _db_behavior;
delete _db_script;
delete _db_pTarget;
delete _db_pIn;
delete _db_pOut;
@ -44,13 +44,36 @@ void dbScriptDataStructHelper::dispose() {
free(_stringCache);
}
void dbDataDataStructHelper::init(CKParameterManager* paramManager) {
_db_obj = new db_data_obj();
_db_objHeader = new db_data_objHeader();
_db_objBody = new db_data_objBody();
_db_objParam = new db_data_objParam();
_db_msg = new db_data_msg();
_parameterManager = paramManager;
_stringCache = (char*)malloc(STRINGCACHE_SIZE * sizeof(char));
if (_stringCache == NULL)
throw new std::bad_alloc();
}
void dbDataDataStructHelper::dispose() {
delete _db_obj;
delete _db_objHeader;
delete _db_objBody;
delete _db_objParam;
delete _db_msg;
_parameterManager = NULL;
free(_stringCache);
}
void dbEnvDataStructHelper::init() {
_db_envOp = new db_envOp;
_db_envParam = new db_envParam;
_db_envMsg = new db_envMsg;
_db_envAttr = new db_envAttr;
_db_envPlugin = new db_envPlugin;
_db_envVariable = new db_envVariable;
_db_op = new db_env_op();
_db_param = new db_env_param();
_db_attr = new db_env_attr();
_db_plugin = new db_env_plugin();
_db_variable = new db_env_variable();
_stringCache = (char*)malloc(STRINGCACHE_SIZE * sizeof(char));
if (_stringCache == NULL)
@ -58,12 +81,11 @@ void dbEnvDataStructHelper::init() {
}
void dbEnvDataStructHelper::dispose() {
delete _db_envOp;
delete _db_envParam;
delete _db_envMsg;
delete _db_envAttr;
delete _db_envPlugin;
delete _db_envVariable;
delete _db_op;
delete _db_param;
delete _db_attr;
delete _db_plugin;
delete _db_variable;
free(_stringCache);
}
@ -75,15 +97,23 @@ void dbEnvDataStructHelper::dispose() {
void database::open(const char* file) {
db = NULL;
stmtCache = new std::vector<sqlite3_stmt*>(14, NULL); // TODO: sync with tryGetStmt's count
stmtCache = new std::vector<sqlite3_stmt*>();
//open db
int result;
result = sqlite3_open(file, &db);
if (result != SQLITE_OK) goto fail;
// disable synchronous
result = sqlite3_exec(db, "PRAGMA synchronous = OFF;", NULL, NULL, NULL);
if (result != SQLITE_OK) goto fail;
// do some custom init
if (!init()) goto fail;
//start job
sqlite3_exec(db, "begin;", NULL, NULL, NULL);
return;
fail:
db = NULL;
@ -92,6 +122,14 @@ fail:
void database::close() {
if (db == NULL) return;
//stop job
for (auto it = stmtCache->begin(); it != stmtCache->end(); it++) {
if (*it != NULL)
sqlite3_finalize(*it);
}
sqlite3_exec(db, "commit;", NULL, NULL, NULL);
// do some custom job
finalJob();
//release res
@ -100,91 +138,46 @@ void database::close() {
delete stmtCache;
}
sqlite3_stmt* database::safeStmt(size_t index) {
if (index >= stmtCache->size()) {
// need resize
stmtCache->resize(index + 1, NULL);
}
}
#define createTable(sql) result=sqlite3_exec(db,sql,NULL,NULL,NULL);if(result!=SQLITE_OK)return FALSE;
BOOL scriptDatabase::init() {
pAttrUniqueEnsurance = new std::set<EXPAND_CK_ID>();
int result;
result = sqlite3_exec(db, "PRAGMA synchronous = OFF;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
//init table
result = sqlite3_exec(db, "begin;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE script([thisobj] INTEGER, [name] TEXT, [index] INTEGER, [behavior] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE behavior([thisobj] INTEGER, [name] TEXT, [type] INTEGER, [proto_name] TEXT, [proto_guid] TEXT, [flags] INTEGER, [priority] INTEGER, [version] INTEGER, [pin_count] TEXT, [parent] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pTarget([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pIn([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pOut([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE bIn([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [belong_to] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE bOut([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [belong_to] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE bLink([input] INTEGER, [output] INTEGER, [delay] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_index] INETEGR, [belong_to] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pLocal([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [is_setting] INTEGER, [belong_to] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pData([field] TEXT, [data] TEXT, [belong_to] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pLink([input] INTEGER, [output] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_is_bb] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_is_bb] INTEGER, [output_index] INETEGR, [belong_to] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pOper([thisobj] INTEGER, [op] TEXT, [op_guid] TEXT, [belong_to] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE eLink([export_obj] INTEGER, [internal_obj] INTEGER, [is_in] INTEGER, [index] INTEGER, [belong_to] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pAttr([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
createTable("CREATE TABLE script([thisobj] INTEGER, [name] TEXT, [index] INTEGER, [behavior] INTEGER);");
createTable("CREATE TABLE behavior([thisobj] INTEGER, [name] TEXT, [type] INTEGER, [proto_name] TEXT, [proto_guid] TEXT, [flags] INTEGER, [priority] INTEGER, [version] INTEGER, [pin_count] TEXT, [parent] INTEGER);");
createTable("CREATE TABLE pTarget([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);");
createTable("CREATE TABLE pIn([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);");
createTable("CREATE TABLE pOut([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER);");
createTable("CREATE TABLE bIn([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [belong_to] INTEGER);");
createTable("CREATE TABLE bOut([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [belong_to] INTEGER);");
createTable("CREATE TABLE bLink([input] INTEGER, [output] INTEGER, [delay] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_index] INETEGR, [belong_to] INTEGER);");
createTable("CREATE TABLE pLocal([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [is_setting] INTEGER, [belong_to] INTEGER);");
createTable("CREATE TABLE pData([field] TEXT, [data] TEXT, [belong_to] INTEGER);");
createTable("CREATE TABLE pLink([input] INTEGER, [output] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_is_bb] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_is_bb] INTEGER, [output_index] INETEGR, [belong_to] INTEGER);");
createTable("CREATE TABLE pOper([thisobj] INTEGER, [op] TEXT, [op_guid] TEXT, [belong_to] INTEGER);");
createTable("CREATE TABLE eLink([export_obj] INTEGER, [internal_obj] INTEGER, [is_in] INTEGER, [index] INTEGER, [belong_to] INTEGER);");
createTable("CREATE TABLE pAttr([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT);");
result = sqlite3_exec(db, "commit;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
//start job
sqlite3_exec(db, "begin;", NULL, NULL, NULL);
return TRUE;
}
BOOL scriptDatabase::finalJob() {
//stop job
for (auto it = stmtCache->begin(); it != stmtCache->end(); it++) {
if (*it != NULL)
sqlite3_finalize(*it);
}
sqlite3_exec(db, "commit;", NULL, NULL, NULL);
//create index for quick select in following app
sqlite3_exec(db, "begin;", NULL, NULL, NULL);
sqlite3_exec(db, "CREATE INDEX [quick_where1] ON behavior ([parent])", NULL, NULL, NULL);
@ -205,70 +198,63 @@ BOOL scriptDatabase::finalJob() {
return TRUE;
}
BOOL envDatabase::init() {
stmtCache = new std::vector<sqlite3_stmt*>(6, NULL); // TODO: sync with tryGetStmt's count
BOOL dataDatabase::init() {
int result;
result = sqlite3_exec(db, "PRAGMA synchronous = OFF;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
//init table
result = sqlite3_exec(db, "begin;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE op([funcptr] INTEGER, [in1_guid] TEXT, [in2_guid] TEXT, [out_guid] TEXT, [op_guid] TEXT, [op_name] TEXT, [op_code] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE param([index] INTEGER, [guid] TEXT, [derived_from] TEXT, [type_name] TEXT, [default_size] INTEGER, [func_CreateDefault] INTEGER, [func_Delete] INTEGER, [func_SaveLoad] INTEGER, [func_Check] INTEGER, [func_Copy] INTEGER, [func_String] INTEGER, [func_UICreator] INTEGER, [creator_dll_index] INTEGER, [creator_plugin_index] INTEGER, [dw_param] INTEGER, [dw_flags] INTEGER, [cid] INTEGER, [saver_manager] TEXT);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE msg([index] INTEGER, [name] TEXT);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE attr([index] INTEGER, [name] TEXT, [category_index] INTEGER, [category_name] TEXT, [flags] INTEGER, [param_index] INTEGER, [compatible_classid] INTEGER, [default_value] TEXT);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE plugin([dll_index] INTEGER, [dll_name] TEXT, [plugin_index] INTEGER, [category] TEXT, [active] INTEGER, [needed_by_file] INTEGER, [guid] TEXT, [desc] TEXT, [author] TEXT, [summary] TEXT, [version] INTEGER, [func_init] INTEGER, [func_exit] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE [variable] ([name] TEXT, [description] TEXT, [flags] INTEGER, [type] INTEGER, [representation] TEXT, [data] TEXT);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
createTable("CREATE TABLE obj([thisObj] INTEGER, [name] TEXT, [type_classid] INTEGER, [type_guid] TEXT, [type_name] TEXT, [rows] INTEGER, [columns] INTEGER);");
createTable("CREATE TABLE objHeader([index] INTEGER, [name] TEXT, [type] INTEGER, [param_type] TEXT, [param_type_guid] TEXT, [belong_to] INTEGER);");
createTable("CREATE TABLE objBody([row] INTEGER, [column] INTEGER, [showcase] TEXT, [inner_object] INTEGER, [inner_param] INTEGER, [belong_to] INTEGER);");
createTable("CREATE TABLE objParam([field] TEXT, [data] TEXT, [belong_to] INTEGER);");
createTable("CREATE TABLE msg([index] INTEGER, [name] TEXT);");
result = sqlite3_exec(db, "commit;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
//start job
sqlite3_exec(db, "begin;", NULL, NULL, NULL);
return TRUE;
}
BOOL dataDatabase::finalJob() {
return TRUE;
}
BOOL envDatabase::init() {
int result;
//init table
result = sqlite3_exec(db, "begin;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
createTable("CREATE TABLE op([funcptr] INTEGER, [in1_guid] TEXT, [in2_guid] TEXT, [out_guid] TEXT, [op_guid] TEXT, [op_name] TEXT, [op_code] INTEGER);");
createTable("CREATE TABLE param([index] INTEGER, [guid] TEXT, [derived_from] TEXT, [type_name] TEXT, [default_size] INTEGER, [func_CreateDefault] INTEGER, [func_Delete] INTEGER, [func_SaveLoad] INTEGER, [func_Check] INTEGER, [func_Copy] INTEGER, [func_String] INTEGER, [func_UICreator] INTEGER, [creator_dll_index] INTEGER, [creator_plugin_index] INTEGER, [dw_param] INTEGER, [dw_flags] INTEGER, [cid] INTEGER, [saver_manager] TEXT);");
createTable("CREATE TABLE attr([index] INTEGER, [name] TEXT, [category_index] INTEGER, [category_name] TEXT, [flags] INTEGER, [param_index] INTEGER, [compatible_classid] INTEGER, [default_value] TEXT);");
createTable("CREATE TABLE plugin([dll_index] INTEGER, [dll_name] TEXT, [plugin_index] INTEGER, [category] TEXT, [active] INTEGER, [needed_by_file] INTEGER, [guid] TEXT, [desc] TEXT, [author] TEXT, [summary] TEXT, [version] INTEGER, [func_init] INTEGER, [func_exit] INTEGER);");
createTable("CREATE TABLE [variable] ([name] TEXT, [description] TEXT, [flags] INTEGER, [type] INTEGER, [representation] TEXT, [data] TEXT);");
result = sqlite3_exec(db, "commit;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
return TRUE;
}
BOOL envDatabase::finalJob() {
//stop job
for (auto it = stmtCache->begin(); it != stmtCache->end(); it++) {
if (*it != NULL)
sqlite3_finalize(*it);
}
sqlite3_exec(db, "commit;", NULL, NULL, NULL);
return TRUE;
}
#undef createTable
#pragma endregion
#pragma region write func
#define tryGetStmt(index,defaultStr) stmt=(*stmtCache)[index];if(stmt==NULL){sqlite3_prepare_v2(db,defaultStr,-1,&stmt,NULL);(*stmtCache)[index]=stmt;}
#define tryGetStmt(index,defaultStr) safeStmt(index);stmt=(*stmtCache)[index];if(stmt==NULL){sqlite3_prepare_v2(db,defaultStr,-1,&stmt,NULL);(*stmtCache)[index]=stmt;}
void scriptDatabase::write_CKBehavior(dbCKBehavior* data) {
void scriptDatabase::write_behavior(db_script_behavior* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -288,7 +274,7 @@ void scriptDatabase::write_CKBehavior(dbCKBehavior* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_CKScript(dbCKScript* data) {
void scriptDatabase::write_script(db_script_script* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -302,7 +288,7 @@ void scriptDatabase::write_CKScript(dbCKScript* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_pTarget(db_pTarget* data) {
void scriptDatabase::write_pTarget(db_script_pTarget* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -319,7 +305,7 @@ void scriptDatabase::write_pTarget(db_pTarget* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_pIn(db_pIn* data) {
void scriptDatabase::write_pIn(db_script_pIn* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -337,7 +323,7 @@ void scriptDatabase::write_pIn(db_pIn* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_pOut(db_pOut* data) {
void scriptDatabase::write_pOut(db_script_pOut* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -353,7 +339,7 @@ void scriptDatabase::write_pOut(db_pOut* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_bIn(db_bIn* data) {
void scriptDatabase::write_bIn(db_script_bIn* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -367,7 +353,7 @@ void scriptDatabase::write_bIn(db_bIn* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_bOut(db_bOut* data) {
void scriptDatabase::write_bOut(db_script_bOut* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -381,7 +367,7 @@ void scriptDatabase::write_bOut(db_bOut* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_bLink(db_bLink* data) {
void scriptDatabase::write_bLink(db_script_bLink* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -401,7 +387,7 @@ void scriptDatabase::write_bLink(db_bLink* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_pLocal(db_pLocal* data) {
void scriptDatabase::write_pLocal(db_script_pLocal* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -417,7 +403,7 @@ void scriptDatabase::write_pLocal(db_pLocal* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_pLink(db_pLink* data) {
void scriptDatabase::write_pLink(db_script_pLink* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -438,7 +424,7 @@ void scriptDatabase::write_pLink(db_pLink* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_pData(db_pData* data) {
void scriptDatabase::write_pData(db_script_pData* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -451,7 +437,7 @@ void scriptDatabase::write_pData(db_pData* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_pOper(db_pOper* data) {
void scriptDatabase::write_pOper(db_script_pOper* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -465,7 +451,7 @@ void scriptDatabase::write_pOper(db_pOper* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_eLink(db_eLink* data) {
void scriptDatabase::write_eLink(db_script_eLink* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -480,7 +466,7 @@ void scriptDatabase::write_eLink(db_eLink* data) {
sqlite3_step(stmt);
}
BOOL scriptDatabase::write_pAttr(db_pAttr* data) {
BOOL scriptDatabase::write_pAttr(db_script_pAttr* data) {
if (db == NULL) return TRUE;
if (pAttrUniqueEnsurance->find(data->thisobj) != pAttrUniqueEnsurance->end())
@ -500,7 +486,83 @@ BOOL scriptDatabase::write_pAttr(db_pAttr* data) {
return TRUE;
}
void envDatabase::write_envOp(db_envOp* data) {
void dataDatabase::write_obj(db_data_obj* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
tryGetStmt(0, "INSERT INTO objParam VALUES (?, ?, ?)");
sqlite3_reset(stmt);
sqlite3_bind_int(stmt, 1, data->thisobj);
sqlite3_bind_text(stmt, 2, data->name.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_int(stmt, 3, data->type_classid);
sqlite3_bind_text(stmt, 4, data->type_guid.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 5, data->type_name.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_int(stmt, 6, data->rows);
sqlite3_bind_int(stmt, 7, data->columns);
sqlite3_step(stmt);
}
void dataDatabase::write_objHeader(db_data_objHeader* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
tryGetStmt(1, "INSERT INTO objParam VALUES (?, ?, ?)");
sqlite3_reset(stmt);
sqlite3_bind_int(stmt, 1, data->index);
sqlite3_bind_text(stmt, 2, data->name.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_int(stmt, 3, data->type);
sqlite3_bind_text(stmt, 4, data->param_type.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 5, data->param_type_guid.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_int(stmt, 6, data->belong_to);
sqlite3_step(stmt);
}
void dataDatabase::write_objBody(db_data_objBody* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
tryGetStmt(2, "INSERT INTO objParam VALUES (?, ?, ?)");
sqlite3_reset(stmt);
sqlite3_bind_int(stmt, 1, data->row);
sqlite3_bind_int(stmt, 2, data->column);
sqlite3_bind_text(stmt, 3, data->showcase.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_int(stmt, 4, data->inner_object);
sqlite3_bind_int(stmt, 5, data->inner_param);
sqlite3_bind_int(stmt, 6, data->belong_to);
sqlite3_step(stmt);
}
void dataDatabase::write_objParam(db_data_objParam* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
tryGetStmt(3, "INSERT INTO objParam VALUES (?, ?, ?)");
sqlite3_reset(stmt);
sqlite3_bind_text(stmt, 1, data->field.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 2, data->data.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_int(stmt, 3, data->belong_to);
sqlite3_step(stmt);
}
void dataDatabase::write_msg(db_data_msg* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
tryGetStmt(4, "INSERT INTO msg VALUES (?, ?)");
sqlite3_reset(stmt);
sqlite3_bind_int(stmt, 1, data->index);
sqlite3_bind_text(stmt, 2, data->name.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_step(stmt);
}
void envDatabase::write_op(db_env_op* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -517,7 +579,7 @@ void envDatabase::write_envOp(db_envOp* data) {
sqlite3_step(stmt);
}
void envDatabase::write_envParam(db_envParam* data) {
void envDatabase::write_param(db_env_param* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
@ -545,23 +607,11 @@ void envDatabase::write_envParam(db_envParam* data) {
sqlite3_step(stmt);
}
void envDatabase::write_envMsg(db_envMsg* data) {
void envDatabase::write_attr(db_env_attr* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
tryGetStmt(2, "INSERT INTO msg VALUES (?, ?)");
sqlite3_reset(stmt);
sqlite3_bind_int(stmt, 1, data->index);
sqlite3_bind_text(stmt, 2, data->name.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_step(stmt);
}
void envDatabase::write_envAttr(db_envAttr* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
tryGetStmt(3, "INSERT INTO attr VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
tryGetStmt(2, "INSERT INTO attr VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
sqlite3_reset(stmt);
sqlite3_bind_int(stmt, 1, data->index);
@ -575,11 +625,11 @@ void envDatabase::write_envAttr(db_envAttr* data) {
sqlite3_step(stmt);
}
void envDatabase::write_envPlugin(db_envPlugin* data) {
void envDatabase::write_plugin(db_env_plugin* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
tryGetStmt(4, "INSERT INTO plugin VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
tryGetStmt(3, "INSERT INTO plugin VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
sqlite3_reset(stmt);
sqlite3_bind_int(stmt, 1, data->dll_index);
@ -598,12 +648,12 @@ void envDatabase::write_envPlugin(db_envPlugin* data) {
sqlite3_step(stmt);
}
void envDatabase::write_envVariable(db_envVariable* data) {
void envDatabase::write_variable(db_env_variable* data) {
if (db == NULL) return;
#if !defined(VIRTOOLS_21)
sqlite3_stmt* stmt = NULL;
tryGetStmt(5, "INSERT INTO [variable] VALUES (?, ?, ?, ?, ?, ?)");
tryGetStmt(4, "INSERT INTO [variable] VALUES (?, ?, ?, ?, ?, ?)");
sqlite3_reset(stmt);
sqlite3_bind_text(stmt, 1, data->name.c_str(), -1, SQLITE_TRANSIENT);

View File

@ -25,6 +25,8 @@ enum pLinkInputOutputType {
#pragma region data struct define
// =================== script db
typedef struct {
EXPAND_CK_ID thisobj;
std::string name;
@ -37,14 +39,14 @@ typedef struct {
//pTarget, pIn, pOut, bIn, bOut
std::string pin_count;
EXPAND_CK_ID parent;
}dbCKBehavior;
}db_script_behavior;
typedef struct {
EXPAND_CK_ID thisobj;
std::string host_name;
int index;
EXPAND_CK_ID behavior;
}dbCKScript;
}db_script_script;
typedef struct {
EXPAND_CK_ID thisobj;
@ -54,7 +56,7 @@ typedef struct {
EXPAND_CK_ID belong_to;
EXPAND_CK_ID direct_source;
EXPAND_CK_ID shared_source;
}db_pTarget;
}db_script_pTarget;
typedef struct {
EXPAND_CK_ID thisobj;
@ -65,7 +67,7 @@ typedef struct {
EXPAND_CK_ID belong_to;
EXPAND_CK_ID direct_source;
EXPAND_CK_ID shared_source;
}db_pIn;
}db_script_pIn;
typedef struct {
EXPAND_CK_ID thisobj;
@ -74,16 +76,16 @@ typedef struct {
std::string type;
std::string type_guid;
EXPAND_CK_ID belong_to;
}db_pOut;
}db_script_pOut;
typedef struct {
EXPAND_CK_ID thisobj;
int index;
std::string name;
EXPAND_CK_ID belong_to;
}db_bIO;
typedef db_bIO db_bIn;
typedef db_bIO db_bOut;
}db_shared_bIO;
typedef db_shared_bIO db_script_bIn;
typedef db_shared_bIO db_script_bOut;
typedef struct {
EXPAND_CK_ID input;
@ -98,7 +100,7 @@ typedef struct {
EXPAND_CK_ID output_obj;
bLinkInputOutputType output_type;
int output_index;
}db_bLink;
}db_script_bLink;
typedef struct {
EXPAND_CK_ID thisobj;
@ -107,20 +109,21 @@ typedef struct {
std::string type_guid;
BOOL is_setting;
EXPAND_CK_ID belong_to;
}db_pLocal;
}db_script_pLocal;
typedef struct {
EXPAND_CK_ID thisobj;
std::string name;
std::string type;
std::string type_guid;
}db_pAttr;
}db_script_pAttr;
typedef struct {
std::string field;
std::string data;
EXPAND_CK_ID belong_to;
}db_pData;
}db_shared_dictData;
typedef db_shared_dictData db_script_pData;
typedef struct {
EXPAND_CK_ID input;
@ -136,14 +139,14 @@ typedef struct {
pLinkInputOutputType output_type;
BOOL output_is_bb;
int output_index;
}db_pLink;
}db_script_pLink;
typedef struct {
EXPAND_CK_ID thisobj;
std::string op;
std::string op_guid;
EXPAND_CK_ID belong_to;
}db_pOper;
}db_script_pOper;
typedef struct {
EXPAND_CK_ID export_obj;
@ -151,9 +154,47 @@ typedef struct {
BOOL is_in;
int index;
EXPAND_CK_ID belong_to;
}db_eLink;
}db_script_eLink;
// =================== data db
typedef struct {
EXPAND_CK_ID thisobj;
std::string name;
CK_CLASSID type_classid;
std::string type_guid;
std::string type_name;
int rows;
int columns;
}db_data_obj;
typedef struct {
int index;
std::string name;
CK_ARRAYTYPE type;
std::string param_type;
std::string param_type_guid;
EXPAND_CK_ID belong_to;
}db_data_objHeader;
typedef struct {
int row;
int column;
std::string showcase;
EXPAND_CK_ID inner_object;
EXPAND_CK_ID inner_param;
EXPAND_CK_ID belong_to;
}db_data_objBody;
typedef db_shared_dictData db_data_objParam;
typedef struct {
CKMessageType index;
std::string name;
}db_data_msg;
// =================== env db
typedef struct {
CK_PARAMETEROPERATION funcPtr;
@ -163,7 +204,7 @@ typedef struct {
std::string op_guid;
std::string op_name;
CKOperationType op_code;
}db_envOp;
}db_env_op;
typedef struct {
CKParameterType index;
@ -184,12 +225,7 @@ typedef struct {
CKDWORD dw_flags;
CKDWORD cid;
std::string saver_manager;
}db_envParam;
typedef struct {
CKMessageType index;
std::string name;
}db_envMsg;
}db_env_param;
typedef struct {
CKAttributeType index;
@ -200,7 +236,7 @@ typedef struct {
CKParameterType param_index;
CK_CLASSID compatible_classid;
std::string default_value;
}db_envAttr;
}db_env_attr;
typedef struct {
int dll_index;
@ -216,7 +252,7 @@ typedef struct {
DWORD version;
CK_INITINSTANCEFCT func_init;
CK_EXITINSTANCEFCT func_exit;
}db_envPlugin;
}db_env_plugin;
typedef struct {
std::string name;
@ -225,7 +261,7 @@ typedef struct {
UNIVERSAL_VAR_TYPE type;
std::string representation;
std::string data;
}db_envVariable;
}db_env_variable;
#pragma endregion
@ -236,20 +272,35 @@ class dbScriptDataStructHelper {
char* _stringCache;
CKParameterManager* _parameterManager;
dbCKBehavior* _dbCKBehavior;
dbCKScript* _dbCKScript;
db_pTarget* _db_pTarget;
db_pIn* _db_pIn;
db_pOut* _db_pOut;
db_bIn* _db_bIn;
db_bOut* _db_bOut;
db_bLink* _db_bLink;
db_pLocal* _db_pLocal;
db_pAttr* _db_pAttr;
db_pLink* _db_pLink;
db_pData* _db_pData;
db_pOper* _db_pOper;
db_eLink* _db_eLink;
db_script_behavior* _db_behavior;
db_script_script* _db_script;
db_script_pTarget* _db_pTarget;
db_script_pIn* _db_pIn;
db_script_pOut* _db_pOut;
db_script_bIn* _db_bIn;
db_script_bOut* _db_bOut;
db_script_bLink* _db_bLink;
db_script_pLocal* _db_pLocal;
db_script_pAttr* _db_pAttr;
db_script_pLink* _db_pLink;
db_script_pData* _db_pData;
db_script_pOper* _db_pOper;
db_script_eLink* _db_eLink;
};
class dbDataDataStructHelper {
public:
void init(CKParameterManager* paramManager);
void dispose();
char* _stringCache;
CKParameterManager* _parameterManager;
db_data_obj* _db_obj;
db_data_objHeader* _db_objHeader;
db_data_objBody* _db_objBody;
db_data_objParam* _db_objParam;
db_data_msg* _db_msg;
};
class dbEnvDataStructHelper {
@ -258,12 +309,12 @@ class dbEnvDataStructHelper {
void dispose();
char* _stringCache;
db_envOp* _db_envOp;
db_envParam* _db_envParam;
db_envMsg* _db_envMsg;
db_envAttr* _db_envAttr;
db_envPlugin* _db_envPlugin;
db_envVariable* _db_envVariable;
db_env_op* _db_op;
db_env_param* _db_param;
//db_data_msg* _db_envMsg;
db_env_attr* _db_attr;
db_env_plugin* _db_plugin;
db_env_variable* _db_variable;
};
@ -273,6 +324,7 @@ class database {
void close();
protected:
sqlite3_stmt* safeStmt(size_t index);
virtual BOOL init() { return TRUE; }
virtual BOOL finalJob() { return TRUE; }
@ -282,20 +334,20 @@ class database {
class scriptDatabase : public database {
public:
void write_CKBehavior(dbCKBehavior* data);
void write_CKScript(dbCKScript* data);
void write_pTarget(db_pTarget* data);
void write_pIn(db_pIn* data);
void write_pOut(db_pOut* data);
void write_bIn(db_bIn* data);
void write_bOut(db_bOut* data);
void write_bLink(db_bLink* data);
void write_pLocal(db_pLocal* data);
void write_pLink(db_pLink* data);
void write_pData(db_pData* data);
void write_pOper(db_pOper* data);
void write_eLink(db_eLink* data);
BOOL write_pAttr(db_pAttr* data);
void write_behavior(db_script_behavior* data);
void write_script(db_script_script* data);
void write_pTarget(db_script_pTarget* data);
void write_pIn(db_script_pIn* data);
void write_pOut(db_script_pOut* data);
void write_bIn(db_script_bIn* data);
void write_bOut(db_script_bOut* data);
void write_bLink(db_script_bLink* data);
void write_pLocal(db_script_pLocal* data);
void write_pLink(db_script_pLink* data);
void write_pData(db_script_pData* data);
void write_pOper(db_script_pOper* data);
void write_eLink(db_script_eLink* data);
BOOL write_pAttr(db_script_pAttr* data);
protected:
BOOL init();
@ -304,14 +356,28 @@ class scriptDatabase : public database {
std::set<EXPAND_CK_ID>* pAttrUniqueEnsurance;
};
class dataDatabase : public database {
public:
void write_obj(db_data_obj* data);
void write_objHeader(db_data_objHeader* data);
void write_objBody(db_data_objBody* data);
void write_objParam(db_data_objParam* data);
void write_msg(db_data_msg* data);
protected:
BOOL init();
BOOL finalJob();
};
class envDatabase : public database {
public:
void write_envOp(db_envOp* data);
void write_envParam(db_envParam* data);
void write_envMsg(db_envMsg* data);
void write_envAttr(db_envAttr* data);
void write_envPlugin(db_envPlugin* data);
void write_envVariable(db_envVariable* data);
void write_op(db_env_op* data);
void write_param(db_env_param* data);
//void write_msg(db_data_msg* data);
void write_attr(db_env_attr* data);
void write_plugin(db_env_plugin* data);
void write_variable(db_env_variable* data);
protected:
BOOL init();

View File

@ -12,10 +12,10 @@ void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase
CKGUID _guid;
for (int i = 0; i < count; i++) {
//fill basic data
helper->_db_envOp->op_code = i;
helper->_db_op->op_code = i;
_guid = parameterManager->OperationCodeToGuid(i);
copyGuid(_guid,helper->_db_envOp->op_guid);
helper->_db_envOp->op_name = parameterManager->OperationCodeToName(i);
copyGuid(_guid,helper->_db_op->op_guid);
helper->_db_op->op_name = parameterManager->OperationCodeToName(i);
//allocate mem
cacheListCount = parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, NULL);
@ -27,12 +27,12 @@ void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase
parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, opList);
for (int j = 0; j < cacheListCount; j++) {
copyGuid(opList[j].P1Guid, helper->_db_envOp->in1_guid);
copyGuid(opList[j].P2Guid, helper->_db_envOp->in2_guid);
copyGuid(opList[j].ResGuid, helper->_db_envOp->out_guid);
helper->_db_envOp->funcPtr = opList[j].Fct;
copyGuid(opList[j].P1Guid, helper->_db_op->in1_guid);
copyGuid(opList[j].P2Guid, helper->_db_op->in2_guid);
copyGuid(opList[j].ResGuid, helper->_db_op->out_guid);
helper->_db_op->funcPtr = opList[j].Fct;
db->write_envOp(helper->_db_envOp);
db->write_op(helper->_db_op);
}
}
if (opList != NULL) free(opList);
@ -45,32 +45,32 @@ void IterateParameter(CKParameterManager* parameterManager, envDatabase* db, dbE
for (int i = 0; i < count; i++) {
desc = parameterManager->GetParameterTypeDescription(i);
helper->_db_envParam->index = desc->Index;
copyGuid(desc->Guid, helper->_db_envParam->guid);
copyGuid(desc->DerivedFrom, helper->_db_envParam->derived_from);
helper->_db_envParam->type_name = desc->TypeName.CStr();
helper->_db_envParam->default_size = desc->DefaultSize;
helper->_db_envParam->func_CreateDefault = desc->CreateDefaultFunction;
helper->_db_envParam->func_Delete = desc->DeleteFunction;
helper->_db_envParam->func_SaveLoad = desc->SaveLoadFunction;
helper->_db_envParam->func_Check = desc->CheckFunction;
helper->_db_envParam->func_Copy = desc->CopyFunction;
helper->_db_envParam->func_String = desc->StringFunction;
helper->_db_envParam->func_UICreator = desc->UICreatorFunction;
helper->_db_param->index = desc->Index;
copyGuid(desc->Guid, helper->_db_param->guid);
copyGuid(desc->DerivedFrom, helper->_db_param->derived_from);
helper->_db_param->type_name = desc->TypeName.CStr();
helper->_db_param->default_size = desc->DefaultSize;
helper->_db_param->func_CreateDefault = desc->CreateDefaultFunction;
helper->_db_param->func_Delete = desc->DeleteFunction;
helper->_db_param->func_SaveLoad = desc->SaveLoadFunction;
helper->_db_param->func_Check = desc->CheckFunction;
helper->_db_param->func_Copy = desc->CopyFunction;
helper->_db_param->func_String = desc->StringFunction;
helper->_db_param->func_UICreator = desc->UICreatorFunction;
CKPluginEntry* plgEntry = desc->CreatorDll;
if (plgEntry != NULL) {
helper->_db_envParam->creator_dll_index = plgEntry->m_PluginDllIndex;
helper->_db_envParam->creator_plugin_index = plgEntry->m_PositionInDll;
helper->_db_param->creator_dll_index = plgEntry->m_PluginDllIndex;
helper->_db_param->creator_plugin_index = plgEntry->m_PositionInDll;
} else {
helper->_db_envParam->creator_dll_index =-1;
helper->_db_envParam->creator_plugin_index =-1;
helper->_db_param->creator_dll_index =-1;
helper->_db_param->creator_plugin_index =-1;
}
helper->_db_envParam->dw_param = desc->dwParam;
helper->_db_envParam->dw_flags = desc->dwFlags;
helper->_db_envParam->cid = desc->Cid;
copyGuid(desc->Saver_Manager, helper->_db_envParam->saver_manager);
helper->_db_param->dw_param = desc->dwParam;
helper->_db_param->dw_flags = desc->dwFlags;
helper->_db_param->cid = desc->Cid;
copyGuid(desc->Saver_Manager, helper->_db_param->saver_manager);
db->write_envParam(helper->_db_envParam);
db->write_param(helper->_db_param);
}
}
@ -80,48 +80,48 @@ void IterateMessage(CKMessageManager* msgManager, envDatabase* db, dbEnvDataStru
helper->_db_envMsg->index = i;
helper->_db_envMsg->name = msgManager->GetMessageTypeName(i);
db->write_envMsg(helper->_db_envMsg);
db->write_msg(helper->_db_envMsg);
}
}
void IterateAttribute(CKAttributeManager* attrManager, envDatabase* db, dbEnvDataStructHelper* helper) {
int count = attrManager->GetAttributeCount();
for (int i = 0; i < count; i++) {
helper->_db_envAttr->index = i;
helper->_db_envAttr->name = attrManager->GetAttributeNameByType(i);
helper->_db_envAttr->category_index = attrManager->GetAttributeCategoryIndex(i);
helper->_db_envAttr->category_name = attrManager->GetAttributeCategory(i) != NULL ? attrManager->GetAttributeCategory(i) : "";
helper->_db_envAttr->flags = attrManager->GetAttributeFlags(i);
helper->_db_envAttr->param_index = attrManager->GetAttributeParameterType(i);
helper->_db_envAttr->compatible_classid = attrManager->GetAttributeCompatibleClassId(i);
helper->_db_envAttr->default_value = attrManager->GetAttributeDefaultValue(i) != NULL ? attrManager->GetAttributeDefaultValue(i) : "";
helper->_db_attr->index = i;
helper->_db_attr->name = attrManager->GetAttributeNameByType(i);
helper->_db_attr->category_index = attrManager->GetAttributeCategoryIndex(i);
helper->_db_attr->category_name = attrManager->GetAttributeCategory(i) != NULL ? attrManager->GetAttributeCategory(i) : "";
helper->_db_attr->flags = attrManager->GetAttributeFlags(i);
helper->_db_attr->param_index = attrManager->GetAttributeParameterType(i);
helper->_db_attr->compatible_classid = attrManager->GetAttributeCompatibleClassId(i);
helper->_db_attr->default_value = attrManager->GetAttributeDefaultValue(i) != NULL ? attrManager->GetAttributeDefaultValue(i) : "";
db->write_envAttr(helper->_db_envAttr);
db->write_attr(helper->_db_attr);
}
}
void IteratePlugin(CKPluginManager* plgManager, envDatabase* db, dbEnvDataStructHelper* helper) {
for (int i = 0; i <= 7; i++) {
int catCount = plgManager->GetPluginCount(i);
helper->_db_envPlugin->category = plgManager->GetCategoryName(i);
helper->_db_plugin->category = plgManager->GetCategoryName(i);
for (int j = 0; j < catCount; j++) {
CKPluginEntry* plgEntry = plgManager->GetPluginInfo(i, j);
helper->_db_envPlugin->dll_index = plgEntry->m_PluginDllIndex;
helper->_db_envPlugin->dll_name = plgManager->GetPluginDllInfo(plgEntry->m_PluginDllIndex)->m_DllFileName.CStr();
helper->_db_envPlugin->plugin_index = plgEntry->m_PositionInDll;
helper->_db_envPlugin->active = plgEntry->m_Active;
helper->_db_envPlugin->needed_by_file = plgEntry->m_NeededByFile;
helper->_db_plugin->dll_index = plgEntry->m_PluginDllIndex;
helper->_db_plugin->dll_name = plgManager->GetPluginDllInfo(plgEntry->m_PluginDllIndex)->m_DllFileName.CStr();
helper->_db_plugin->plugin_index = plgEntry->m_PositionInDll;
helper->_db_plugin->active = plgEntry->m_Active;
helper->_db_plugin->needed_by_file = plgEntry->m_NeededByFile;
CKPluginInfo* plgInfo = &(plgEntry->m_PluginInfo);
copyGuid(plgInfo->m_GUID, helper->_db_envPlugin->guid);
helper->_db_envPlugin->desc = plgInfo->m_Description.CStr();
helper->_db_envPlugin->author = plgInfo->m_Author.CStr();
helper->_db_envPlugin->summary = plgInfo->m_Summary.CStr();
helper->_db_envPlugin->version = plgInfo->m_Version;
helper->_db_envPlugin->func_init = plgInfo->m_InitInstanceFct;
helper->_db_envPlugin->func_exit = plgInfo->m_ExitInstanceFct;
copyGuid(plgInfo->m_GUID, helper->_db_plugin->guid);
helper->_db_plugin->desc = plgInfo->m_Description.CStr();
helper->_db_plugin->author = plgInfo->m_Author.CStr();
helper->_db_plugin->summary = plgInfo->m_Summary.CStr();
helper->_db_plugin->version = plgInfo->m_Version;
helper->_db_plugin->func_init = plgInfo->m_InitInstanceFct;
helper->_db_plugin->func_exit = plgInfo->m_ExitInstanceFct;
db->write_envPlugin(helper->_db_envPlugin);
db->write_plugin(helper->_db_plugin);
}
}
}
@ -133,15 +133,15 @@ void IterateVariable(CKVariableManager* varManager, envDatabase* db, dbEnvDataSt
XString dataCopyCache;
for (; !it.End(); it++) {
varobj = it.GetVariable();
helper->_db_envVariable->name = it.GetName();
safeStringCopy(helper->_db_envVariable->desciption, varobj->GetDescription());
helper->_db_envVariable->flags = varobj->GetFlags();
helper->_db_envVariable->type = varobj->GetType();
safeStringCopy(helper->_db_envVariable->representation, varobj->GetRepresentation());
helper->_db_variable->name = it.GetName();
safeStringCopy(helper->_db_variable->desciption, varobj->GetDescription());
helper->_db_variable->flags = varobj->GetFlags();
helper->_db_variable->type = varobj->GetType();
safeStringCopy(helper->_db_variable->representation, varobj->GetRepresentation());
varobj->GetStringValue(dataCopyCache);
helper->_db_envVariable->data = dataCopyCache.CStr();
helper->_db_variable->data = dataCopyCache.CStr();
db->write_envVariable(helper->_db_envVariable);
db->write_variable(helper->_db_variable);
}
}
#endif

View File

@ -1,5 +1,5 @@
#if !defined(_YYCDLL_HELP_EXPORT_H__IMPORTED_)
#define _YYCDLL_HELP_EXPORT_H__IMPORTED_
#if !defined(_YYCDLL_ENV_EXPORT_H__IMPORTED_)
#define _YYCDLL_ENV_EXPORT_H__IMPORTED_
#include "stdafx.h"
#include "database.h"

View File

@ -338,11 +338,11 @@ void IterateScript(CKContext* ctx, scriptDatabase* db, dbScriptDataStructHelper*
//write script table
beh = beobj->GetScript(j);
helper->_dbCKScript->thisobj = beobj->GetID();
helper->_dbCKScript->host_name = beobj->GetName();
helper->_dbCKScript->index = j;
helper->_dbCKScript->behavior = beh->GetID();
db->write_CKScript(helper->_dbCKScript);
helper->_db_script->thisobj = beobj->GetID();
helper->_db_script->host_name = beobj->GetName();
helper->_db_script->index = j;
helper->_db_script->behavior = beh->GetID();
db->write_script(helper->_db_script);
//iterate script
IterateBehavior(ctx, beh, db, helper, -1);
@ -352,23 +352,23 @@ void IterateScript(CKContext* ctx, scriptDatabase* db, dbScriptDataStructHelper*
void IterateBehavior(CKContext* ctx, CKBehavior* bhv, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
//write self data
helper->_dbCKBehavior->thisobj = bhv->GetID();
helper->_dbCKBehavior->name = bhv->GetName();
helper->_dbCKBehavior->type = bhv->GetType();
helper->_dbCKBehavior->proto_name = bhv->GetPrototypeName() ? bhv->GetPrototypeName() : "";
copyGuid(bhv->GetPrototypeGuid(), helper->_dbCKBehavior->proto_guid);
helper->_dbCKBehavior->flags = bhv->GetFlags();
helper->_dbCKBehavior->priority = bhv->GetPriority();
helper->_dbCKBehavior->version = bhv->GetVersion();
helper->_dbCKBehavior->parent = parents;
helper->_db_behavior->thisobj = bhv->GetID();
helper->_db_behavior->name = bhv->GetName();
helper->_db_behavior->type = bhv->GetType();
helper->_db_behavior->proto_name = bhv->GetPrototypeName() ? bhv->GetPrototypeName() : "";
copyGuid(bhv->GetPrototypeGuid(), helper->_db_behavior->proto_guid);
helper->_db_behavior->flags = bhv->GetFlags();
helper->_db_behavior->priority = bhv->GetPriority();
helper->_db_behavior->version = bhv->GetVersion();
helper->_db_behavior->parent = parents;
sprintf(helper->_stringCache, "%d,%d,%d,%d,%d",
(bhv->IsUsingTarget() ? 1 : 0),
bhv->GetInputParameterCount(),
bhv->GetOutputParameterCount(),
bhv->GetInputCount(),
bhv->GetOutputCount());
helper->_dbCKBehavior->pin_count = helper->_stringCache;
db->write_CKBehavior(helper->_dbCKBehavior);
helper->_db_behavior->pin_count = helper->_stringCache;
db->write_behavior(helper->_db_behavior);
//write target
if (bhv->IsUsingTarget())

View File

@ -0,0 +1,42 @@
#include "shared_export.h"
combined_database::combined_database() :
db_script(NULL),
helper_script(NULL),
db_data(NULL),
helper_data(NULL) {
;
}
db_shared_dictData* combined_database::get_struct() {
if (helper_script != NULL) return helper_script->_db_pData;
if (helper_data != NULL) return helper_data->_db_objParam;
return NULL;
}
char* combined_database::get_string_cache() {
if (helper_script != NULL) return helper_script->_stringCache;
if (helper_data != NULL) return helper_data->_stringCache;
return NULL;
}
void combined_database::write_dict(db_shared_dictData* data) {
if (db_script != NULL) db_script->write_pData(data);
if (db_data != NULL) db_data->write_objParam(data);
}
void DigParameterData(CKParameter* p, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
combined_database cdb;
cdb.db_script = db;
cdb.helper_script = helper;
DigParameterData(p, &cdb, parents);
}
void DigParameterData(CKParameter* p, dataDatabase* db, dbDataDataStructHelper* helper, EXPAND_CK_ID parents) {
combined_database cdb;
cdb.db_data = db;
cdb.helper_data = helper;
DigParameterData(p, &cdb, parents);
}

View File

@ -0,0 +1,31 @@
#if !defined(_YYCDLL_SHARED_EXPORT_H__IMPORTED_)
#define _YYCDLL_SHARED_EXPORT_H__IMPORTED_
#include "stdafx.h"
#include "database.h"
class combined_database {
public:
combined_database();
db_shared_dictData* get_struct();
char* get_string_cache();
void write_dict(db_shared_dictData* data);
scriptDatabase* db_script;
dbScriptDataStructHelper* helper_script;
dataDatabase* db_data;
dbDataDataStructHelper* helper_data;
};
#define copyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache;
#define safeStringCopy(storage,str) storage=(str)?(str):"";
void DigParameterData(CKParameter* p, combined_database* helper, EXPAND_CK_ID parents);
void DigParameterData(CKParameter* p, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void DigParameterData(CKParameter* p, dataDatabase* db, dbDataDataStructHelper* helper, EXPAND_CK_ID parents);
void helper_FillStruct(const char* field, long data, db_shared_dictData* helper);
void helper_FillStruct(const char* field, float data, db_shared_dictData* helper);
void helper_FillStruct(const char* field, const char* data, db_shared_dictData* helper);
#endif