[fix] fix some bugs

- fix decorator throw a error when a attribute was connected to a pIn
- fix CKCID_PARAMETERVARIABLE support
This commit is contained in:
yyc12345 2020-06-26 23:36:03 +08:00
parent 9cd2f93b8b
commit cd562ede42
9 changed files with 259 additions and 98 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
*.db
*.db-journal
# User-specific files
*.rsuser

View File

@ -9,6 +9,14 @@
<Configuration>VT35</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="VT4|Win32">
<Configuration>VT4</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="VT4|x64">
<Configuration>VT4</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="VT5|Win32">
<Configuration>VT5</Configuration>
<Platform>Win32</Platform>
@ -37,9 +45,18 @@
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VT4|Win32'" Label="Configuration">
<PlatformToolset>v142</PlatformToolset>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='VT5|x64'">
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VT4|x64'" Label="Configuration">
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
@ -51,17 +68,27 @@
<LinkIncremental>true</LinkIncremental>
<IntDir>Temp\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VT4|Win32'">
<OutDir>E:\Virtools\Virtools Dev 4.0\InterfacePlugins\</OutDir>
<LinkIncremental>true</LinkIncremental>
<IntDir>Temp\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VT5|Win32'">
<ClCompile>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VT4|Win32'">
<ClCompile>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VT5|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>D:\CppLib\SQLite\sqlite-amalgamation-3310100;E:\Virtools\Virtools Dev 5.0\Sdk\Includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;VX_MEM_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;VIRTOOLS_5;VX_MEM_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
</ClCompile>
<Link>
@ -76,15 +103,43 @@
<ModuleDefinitionFile>SuperScriptMaterializer.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VT4|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>D:\CppLib\SQLite\sqlite-amalgamation-3310100;E:\Virtools\Virtools Dev 4.0\Sdk\Includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;VIRTOOLS_4;VX_MEM_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
</ClCompile>
<Link>
<OutputFile>E:\Virtools\Virtools Dev 4.0\InterfacePlugins\$(ProjectName).dll</OutputFile>
</Link>
<Link>
<AdditionalLibraryDirectories>D:\CppLib\SQLite\sqlite-dll-win32-x86-3310100;E:\Virtools\Virtools Dev 4.0\Sdk\Lib\Win32\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib;sqlite3.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>E:\Virtools\Virtools Dev 4.0\InterfacePlugins\$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<ModuleDefinitionFile>SuperScriptMaterializer.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VT5|x64'">
<Link>
<ModuleDefinitionFile>SuperScriptMaterializer.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VT4|x64'">
<Link>
<ModuleDefinitionFile>SuperScriptMaterializer.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VT35|Win32'">
<Link>
<ModuleDefinitionFile>SuperScriptMaterializer.def</ModuleDefinitionFile>
</Link>
<ClCompile>
<PreprocessorDefinitions>VIRTOOLS_35;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VT35|x64'">
<Link>

View File

@ -12,8 +12,9 @@ void dbScriptDataStructHelper::init(CKParameterManager* paramManager) {
_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_pLocalData = new db_pLocalData();
_db_pData = new db_pData();
_db_pOper = new db_pOper();
_db_eLink = new db_eLink();
@ -32,9 +33,10 @@ void dbScriptDataStructHelper::dispose() {
delete _db_bIn;
delete _db_bOut;
delete _db_bLink;
delete _db_pLocalData;
delete _db_pData;
delete _db_pLink;
delete _db_pLocal;
delete _db_pAttr;
delete _db_pOper;
delete _db_eLink;
@ -71,7 +73,7 @@ void dbEnvDataStructHelper::dispose() {
void database::open(const char* file) {
db = NULL;
stmtCache = new std::vector<sqlite3_stmt*>(13, NULL);
stmtCache = new std::vector<sqlite3_stmt*>(15, NULL);
//open db
int result;
@ -97,6 +99,8 @@ void database::close() {
}
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;
@ -142,7 +146,7 @@ BOOL scriptDatabase::init() {
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pLocalData([field] TEXT, [data] TEXT, [belong_to] INTEGER);",
"CREATE TABLE pData([field] TEXT, [data] TEXT, [belong_to] INTEGER);",
NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
@ -157,6 +161,10 @@ BOOL scriptDatabase::init() {
"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;
result = sqlite3_exec(db, "commit;", NULL, NULL, NULL);
if (result != SQLITE_OK) return FALSE;
@ -188,8 +196,10 @@ BOOL scriptDatabase::finalJob() {
sqlite3_exec(db, "CREATE INDEX [quick_where9] ON pLink ([belong_to])", NULL, NULL, NULL);
sqlite3_exec(db, "CREATE INDEX [quick_where10] ON bLink ([belong_to])", NULL, NULL, NULL);
sqlite3_exec(db, "CREATE INDEX [quick_where11] ON elink ([belong_to])", NULL, NULL, NULL);
sqlite3_exec(db, "CREATE INDEX [quick_where12] ON pAttr ([thisobj])", NULL, NULL, NULL);
sqlite3_exec(db, "commit;", NULL, NULL, NULL);
delete pAttrUniqueEnsurance;
return TRUE;
}
@ -422,11 +432,11 @@ void scriptDatabase::write_pLink(db_pLink* data) {
sqlite3_step(stmt);
}
void scriptDatabase::write_pLocalData(db_pLocalData* data) {
void scriptDatabase::write_pData(db_pData* data) {
if (db == NULL) return;
sqlite3_stmt* stmt = NULL;
tryGetStmt(10, "INSERT INTO pLocalData VALUES (?, ?, ?)");
tryGetStmt(10, "INSERT INTO pData VALUES (?, ?, ?)");
sqlite3_reset(stmt);
sqlite3_bind_text(stmt, 1, data->field.c_str(), -1, SQLITE_TRANSIENT);
@ -464,6 +474,26 @@ void scriptDatabase::write_eLink(db_eLink* data) {
sqlite3_step(stmt);
}
BOOL scriptDatabase::write_pAttr(db_pAttr* data) {
if (db == NULL) return TRUE;
if (pAttrUniqueEnsurance->find(data->thisobj) != pAttrUniqueEnsurance->end())
return FALSE; //existing item. skip it to make sure unique
pAttrUniqueEnsurance->insert(data->thisobj); //add this item
sqlite3_stmt* stmt = NULL;
tryGetStmt(13, "INSERT INTO pAttr 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_text(stmt, 3, data->type.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 4, data->type_guid.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_step(stmt);
return TRUE;
}
void envDatabase::write_envOp(db_envOp* data) {
if (db == NULL) return;

View File

@ -5,6 +5,7 @@
#include "stdafx.h"
#include <string>
#include <vector>
#include <set>
#define STRINGCACHE_SIZE 25565
@ -16,8 +17,9 @@ enum bLinkInputOutputType {
enum pLinkInputOutputType {
pLinkInputOutputType_PIN,
pLinkInputOutputType_POUT,
pLinkInputOutputType_PLOCAL, //when using pLocal, omit [index] and [input_is_bb]
pLinkInputOutputType_PTARGET //when using pTarget, omit [index] and [input_is_bb]
pLinkInputOutputType_PLOCAL, //when using pLocal, omit [index] and [input_is_bb], [input_index] set -1
pLinkInputOutputType_PTARGET, //when using pTarget, omit [index] and [input_is_bb], [input_index] set -1
pLinkInputOutputType_PATTR //when using pAttr, omit [index] and [input_is_bb], [input_index] set -1
};
#pragma region data struct define
@ -106,11 +108,18 @@ typedef struct {
EXPAND_CK_ID belong_to;
}db_pLocal;
typedef struct {
EXPAND_CK_ID thisobj;
std::string name;
std::string type;
std::string type_guid;
}db_pAttr;
typedef struct {
std::string field;
std::string data;
EXPAND_CK_ID belong_to;
}db_pLocalData;
}db_pData;
typedef struct {
EXPAND_CK_ID input;
@ -226,8 +235,9 @@ class dbScriptDataStructHelper {
db_bOut* _db_bOut;
db_bLink* _db_bLink;
db_pLocal* _db_pLocal;
db_pAttr* _db_pAttr;
db_pLink* _db_pLink;
db_pLocalData* _db_pLocalData;
db_pData* _db_pData;
db_pOper* _db_pOper;
db_eLink* _db_eLink;
};
@ -271,13 +281,16 @@ class scriptDatabase : public database {
void write_bLink(db_bLink* data);
void write_pLocal(db_pLocal* data);
void write_pLink(db_pLink* data);
void write_pLocalData(db_pLocalData* 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);
protected:
BOOL init();
BOOL finalJob();
std::set<EXPAND_CK_ID>* pAttrUniqueEnsurance;
};
class envDatabase : public database {

View File

@ -4,10 +4,11 @@
#define changeSuffix(a) prefix[endIndex]='\0';strcat(prefix,a)
#define copyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache;
#define safeStringCopy(storage,str) storage=(str)?(str):"";
#pragma region inline func
inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget) {
void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget) {
//WARNING: i only choose one between [DirectSource] and [SharedSource] bucause i don't find any pIn both have these two field
CKParameter* directSource = NULL;
CKObject* ds_Owner = NULL;
@ -15,26 +16,45 @@ inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, scriptDa
CKBehavior* ss_Owner = NULL;
if (directSource = cache->GetDirectSource()) {
helper->_db_pLink->input = directSource->GetID();
if (directSource->GetClassID() == CKCID_PARAMETERLOCAL) {
if (directSource->GetClassID() == CKCID_PARAMETERLOCAL || directSource->GetClassID() == CKCID_PARAMETERVARIABLE) {
//pLocal
helper->_db_pLink->input_obj = directSource->GetID();
helper->_db_pLink->input_type = pLinkInputOutputType_PLOCAL;
helper->_db_pLink->input_is_bb = FALSE;
helper->_db_pLink->input_index = -1;
} else {
//pOut
//WARNING: when GetClassID() return CKDataArray there are untested code
//pParam from bb pOut / pOper pOut / object Attribute / CKDataArray
ds_Owner = directSource->GetOwner();
switch (ds_Owner->GetClassID()) {
case CKCID_BEHAVIOR:
helper->_db_pLink->input_obj = ds_Owner->GetID();
helper->_db_pLink->input_type = pLinkInputOutputType_POUT;
//WARNING: untested doe to GetClassID() may have chance to return Attributes or CKDataArray accoring to document
if (helper->_db_pLink->input_is_bb = (ds_Owner->GetClassID() != CKCID_PARAMETEROPERATION)) {
//bb
helper->_db_pLink->input_is_bb = TRUE;
helper->_db_pLink->input_index = ((CKBehavior*)ds_Owner)->GetOutputParameterPosition((CKParameterOut*)directSource);
} else {
//pOper
break;
case CKCID_PARAMETEROPERATION:
helper->_db_pLink->input_obj = ds_Owner->GetID();
helper->_db_pLink->input_type = pLinkInputOutputType_POUT;
helper->_db_pLink->input_is_bb = FALSE;
helper->_db_pLink->input_index = 0;
break;
case CKCID_DATAARRAY:
// dataarray, see as virtual bb pLocal shortcut
helper->_db_pLink->input_obj = directSource->GetID();
helper->_db_pLink->input_type = pLinkInputOutputType_PATTR;
helper->_db_pLink->input_is_bb = FALSE;
helper->_db_pLink->input_index = -1;
proc_pAttr(ctx, db, helper, directSource);
break;
default:
//normal object, see as virtual bb pLocal shortcut
helper->_db_pLink->input_obj = directSource->GetID();
helper->_db_pLink->input_type = pLinkInputOutputType_PATTR;
helper->_db_pLink->input_is_bb = FALSE;
helper->_db_pLink->input_index = -1;
proc_pAttr(ctx, db, helper, directSource);
break;
}
}
}
@ -72,7 +92,7 @@ inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, scriptDa
}
}
inline void proc_pTarget(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents) {
void proc_pTarget(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents) {
helper->_db_pTarget->thisobj = cache->GetID();
helper->_db_pTarget->name = cache->GetName();
helper->_db_pTarget->type = helper->_parameterManager->ParameterTypeToName(cache->GetType());
@ -99,7 +119,7 @@ inline void proc_pTarget(CKContext* ctx, CKParameterIn* cache, scriptDatabase* d
generate_pLink_in_pIn(ctx, cache, db, helper, parents, grandparents, -1, TRUE, TRUE);
}
inline void proc_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
void proc_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
helper->_db_pIn->thisobj = cache->GetID();
helper->_db_pIn->index = index;
helper->_db_pIn->name = cache->GetName();
@ -130,7 +150,7 @@ inline void proc_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, d
}
inline void proc_pOut(CKContext* ctx, CKParameterOut* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
void proc_pOut(CKContext* ctx, CKParameterOut* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
helper->_db_pOut->thisobj = cache->GetID();
helper->_db_pOut->index = index;
helper->_db_pOut->name = cache->GetName();
@ -191,7 +211,7 @@ inline void proc_pOut(CKContext* ctx, CKParameterOut* cache, scriptDatabase* db,
}
}
inline void proc_bIn(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
void proc_bIn(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
helper->_db_bIn->thisobj = cache->GetID();
helper->_db_bIn->index = index;
helper->_db_bIn->name = cache->GetName();
@ -200,7 +220,7 @@ inline void proc_bIn(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStruct
db->write_bIn(helper->_db_bIn);
}
inline void proc_bOut(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
void proc_bOut(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
helper->_db_bOut->thisobj = cache->GetID();
helper->_db_bOut->index = index;
helper->_db_bOut->name = cache->GetName();
@ -209,7 +229,7 @@ inline void proc_bOut(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStruc
db->write_bOut(helper->_db_bOut);
}
inline void proc_bLink(CKBehaviorLink* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
void proc_bLink(CKBehaviorLink* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
CKBehaviorIO* io = cache->GetInBehaviorIO();
CKBehavior* beh = io->GetOwner();
helper->_db_bLink->input = io->GetID();
@ -229,7 +249,7 @@ inline void proc_bLink(CKBehaviorLink* cache, scriptDatabase* db, dbScriptDataSt
db->write_bLink(helper->_db_bLink);
}
inline void proc_pLocal(CKParameterLocal* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting) {
void proc_pLocal(CKParameterLocal* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting) {
helper->_db_pLocal->thisobj = cache->GetID();
helper->_db_pLocal->name = cache->GetName() ? cache->GetName() : "";
CKParameterType vaildTypeChecker = cache->GetType();
@ -242,10 +262,10 @@ inline void proc_pLocal(CKParameterLocal* cache, scriptDatabase* db, dbScriptDat
db->write_pLocal(helper->_db_pLocal);
//export plocal metadata
IteratepLocalData(cache, db, helper, cache->GetID());
DigParameterData(cache, db, helper, cache->GetID());
}
inline void proc_pOper(CKContext* ctx, CKParameterOperation* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
void proc_pOper(CKContext* ctx, CKParameterOperation* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
helper->_db_pOper->thisobj = cache->GetID();
helper->_db_pOper->op = helper->_parameterManager->OperationGuidToName(cache->GetOperationGuid());
copyGuid(cache->GetOperationGuid(), helper->_db_pOper->op_guid);
@ -259,24 +279,41 @@ inline void proc_pOper(CKContext* ctx, CKParameterOperation* cache, scriptDataba
proc_pOut(ctx, cache->GetOutParameter(), db, helper, cache->GetID(), parents, 0, FALSE);
}
void proc_pAttr(CKContext* ctx, scriptDatabase* db, dbScriptDataStructHelper* helper, CKParameter* cache) {
//write self first to detect conflict
helper->_db_pAttr->thisobj = cache->GetID();
safeStringCopy(helper->_db_pAttr->name, cache->GetName());
CKParameterType vaildTypeChecker = cache->GetType();
if (vaildTypeChecker != -1) helper->_db_pAttr->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
else helper->_db_pAttr->type = "!!UNKNOW TYPE!!"; //unknow type
copyGuid(cache->GetGUID(), helper->_db_pAttr->type_guid);
if (!db->write_pAttr(helper->_db_pAttr))
return;
//not duplicated, continue write property
CKObject* host = cache->GetOwner();
helper_pDataExport("attr.host_id", (long)host->GetID(), db, helper, cache->GetID());
helper_pDataExport("attr.host_name", host->GetName(), db, helper, cache->GetID());
}
//============================helper for pLocal data export
inline void helper_pLocalDataExport(const char* field, const char* data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
helper->_db_pLocalData->field = field;
helper->_db_pLocalData->data = data;
helper->_db_pLocalData->belong_to = parents;
void helper_pDataExport(const char* field, const char* data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
helper->_db_pData->field = field;
helper->_db_pData->data = data;
helper->_db_pData->belong_to = parents;
db->write_pLocalData(helper->_db_pLocalData);
db->write_pData(helper->_db_pData);
}
inline void helper_pLocalDataExport(const char* field, float data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
void helper_pDataExport(const char* field, float data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
char str[32];
sprintf(str, "%f", data);
helper_pLocalDataExport(field, str, db, helper, parents);
helper_pDataExport(field, str, db, helper, parents);
}
inline void helper_pLocalDataExport(const char* field, long data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
void helper_pDataExport(const char* field, long data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
char str[32];
ltoa(data, str, 10);
helper_pLocalDataExport(field, str, db, helper, parents);
helper_pDataExport(field, str, db, helper, parents);
}
@ -363,7 +400,7 @@ void IterateBehavior(CKContext* ctx, CKBehavior* bhv, scriptDatabase* db, dbScri
IterateBehavior(ctx, bhv->GetSubBehavior(i), db, helper, bhv->GetID());
}
void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
void DigParameterData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
CKGUID t = p->GetGUID();
BOOL unknowType = FALSE;
@ -372,15 +409,15 @@ void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStru
//nothing
if (t == CKPGUID_NONE) return;
if (p->GetParameterClassID() && p->GetValueObject(false)) {
helper_pLocalDataExport("id", (long)p->GetValueObject(false)->GetID(), db, helper, parents);
helper_pLocalDataExport("name", p->GetValueObject(false)->GetName(), db, helper, parents);
helper_pLocalDataExport("type", p->GetValueObject(false)->GetClassNameA(), db, helper, parents);
helper_pDataExport("id", (long)p->GetValueObject(false)->GetID(), db, helper, parents);
helper_pDataExport("name", p->GetValueObject(false)->GetName(), db, helper, parents);
helper_pDataExport("type", p->GetValueObject(false)->GetClassNameA(), db, helper, parents);
return;
}
//float
if (t == CKPGUID_FLOAT || t == CKPGUID_ANGLE || t == CKPGUID_PERCENTAGE || t == CKPGUID_TIME
|| t == CKPGUID_FLOATSLIDER) {
helper_pLocalDataExport("float-data", *(float*)(p->GetReadDataPtr(false)), db, helper, parents);
helper_pDataExport("float-data", *(float*)(p->GetReadDataPtr(false)), db, helper, parents);
return;
}
//int
@ -391,22 +428,22 @@ void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStru
|| t == CKPGUID_LIGHTTYPE || t == CKPGUID_SPRITEALIGN || t == CKPGUID_DIRECTION || t == CKPGUID_LAYERTYPE
|| t == CKPGUID_COMPOPERATOR || t == CKPGUID_BINARYOPERATOR || t == CKPGUID_SETOPERATOR
|| t == CKPGUID_OBSTACLEPRECISION || t == CKPGUID_OBSTACLEPRECISIONBEH) {
helper_pLocalDataExport("int-data", (long)(*(int*)(p->GetReadDataPtr(false))), db, helper, parents);
helper_pDataExport("int-data", (long)(*(int*)(p->GetReadDataPtr(false))), db, helper, parents);
return;
}
if (t == CKPGUID_VECTOR) {
VxVector vec;
memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec));
helper_pLocalDataExport("vector.x", vec.x, db, helper, parents);
helper_pLocalDataExport("vector.y", vec.y, db, helper, parents);
helper_pLocalDataExport("vector.z", vec.z, db, helper, parents);
helper_pDataExport("vector.x", vec.x, db, helper, parents);
helper_pDataExport("vector.y", vec.y, db, helper, parents);
helper_pDataExport("vector.z", vec.z, db, helper, parents);
return;
}
if (t == CKPGUID_2DVECTOR) {
Vx2DVector vec;
memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec));
helper_pLocalDataExport("2dvector.x", vec.x, db, helper, parents);
helper_pLocalDataExport("2dvector.y", vec.y, db, helper, parents);
helper_pDataExport("2dvector.x", vec.x, db, helper, parents);
helper_pDataExport("2dvector.y", vec.y, db, helper, parents);
return;
}
if (t == CKPGUID_MATRIX) {
@ -417,7 +454,7 @@ void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStru
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
sprintf(position, "matrix[%d][%d]", i, j);
helper_pLocalDataExport(position, mat[i][j], db, helper, parents);
helper_pDataExport(position, mat[i][j], db, helper, parents);
}
}
return;
@ -425,10 +462,10 @@ void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStru
if (t == CKPGUID_COLOR) {
VxColor col;
memcpy(&col, p->GetReadDataPtr(false), sizeof(col));
helper_pLocalDataExport("color.r", col.r, db, helper, parents);
helper_pLocalDataExport("color.g", col.g, db, helper, parents);
helper_pLocalDataExport("color.b", col.b, db, helper, parents);
helper_pLocalDataExport("color.a", col.a, db, helper, parents);
helper_pDataExport("color.r", col.r, db, helper, parents);
helper_pDataExport("color.g", col.g, db, helper, parents);
helper_pDataExport("color.b", col.b, db, helper, parents);
helper_pDataExport("color.a", col.a, db, helper, parents);
return;
}
if (t == CKPGUID_2DCURVE) {
@ -441,27 +478,27 @@ void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStru
endIndex = strlen(prefix);
changeSuffix(".pos.x");
helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetPosition().x, db, helper, parents);
helper_pDataExport(prefix, c->GetControlPoint(i)->GetPosition().x, db, helper, parents);
changeSuffix(".pos.y");
helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetPosition().y, db, helper, parents);
helper_pDataExport(prefix, c->GetControlPoint(i)->GetPosition().y, db, helper, parents);
changeSuffix(".islinear");
helper_pLocalDataExport(prefix, (long)c->GetControlPoint(i)->IsLinear(), db, helper, parents);
helper_pDataExport(prefix, (long)c->GetControlPoint(i)->IsLinear(), db, helper, parents);
if (c->GetControlPoint(i)->IsTCB()) {
changeSuffix(".bias");
helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetBias(), db, helper, parents);
helper_pDataExport(prefix, c->GetControlPoint(i)->GetBias(), db, helper, parents);
changeSuffix(".continuity");
helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetContinuity(), db, helper, parents);
helper_pDataExport(prefix, c->GetControlPoint(i)->GetContinuity(), db, helper, parents);
changeSuffix(".tension");
helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetTension(), db, helper, parents);
helper_pDataExport(prefix, c->GetControlPoint(i)->GetTension(), db, helper, parents);
} else {
changeSuffix(".intangent.x");
helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetInTangent().x, db, helper, parents);
helper_pDataExport(prefix, c->GetControlPoint(i)->GetInTangent().x, db, helper, parents);
changeSuffix(".intangent.y");
helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetInTangent().y, db, helper, parents);
helper_pDataExport(prefix, c->GetControlPoint(i)->GetInTangent().y, db, helper, parents);
changeSuffix(".outtangent.x");
helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetOutTangent().x, db, helper, parents);
helper_pDataExport(prefix, c->GetControlPoint(i)->GetOutTangent().x, db, helper, parents);
changeSuffix(".outtangent.y");
helper_pLocalDataExport(prefix, c->GetControlPoint(i)->GetOutTangent().y, db, helper, parents);
helper_pDataExport(prefix, c->GetControlPoint(i)->GetOutTangent().y, db, helper, parents);
}
}
return;
@ -470,11 +507,11 @@ void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStru
char* cptr = (char*)p->GetReadDataPtr(false);
int cc = p->GetDataSize();
helper->_db_pLocalData->data.clear();
helper->_db_pLocalData->data.insert(0, cptr, 0, cc);
helper->_db_pLocalData->field = "str";
helper->_db_pLocalData->belong_to = p->GetID();
db->write_pLocalData(helper->_db_pLocalData);
helper->_db_pData->data.clear();
helper->_db_pData->data.insert(0, cptr, 0, cc);
helper->_db_pData->field = "str";
helper->_db_pData->belong_to = p->GetID();
db->write_pData(helper->_db_pData);
return;
}
@ -489,24 +526,24 @@ void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStru
rcc = cc = p->GetDataSize();
if (rcc > 1024) rcc = 1024;
helper->_db_pLocalData->data.clear();
helper->_db_pData->data.clear();
for (int i = 0; i < rcc; i++) {
sprintf(temp, "0x%02X", cptr[i]);
helper->_db_pLocalData->data += temp;
helper->_db_pData->data += temp;
if (i != rcc - 1)
helper->_db_pLocalData->data += ", ";
helper->_db_pData->data += ", ";
}
if (rcc == cc)
helper->_db_pLocalData->field = "dump.data";
helper->_db_pData->field = "dump.data";
else
helper->_db_pLocalData->field = "dump.partial_data";
helper->_db_pLocalData->belong_to = p->GetID();
db->write_pLocalData(helper->_db_pLocalData);
helper->_db_pData->field = "dump.partial_data";
helper->_db_pData->belong_to = p->GetID();
db->write_pData(helper->_db_pData);
//dump data length
helper_pLocalDataExport("dump.length", (long)cc, db, helper, parents);
helper_pDataExport("dump.length", (long)cc, db, helper, parents);
return;
}
}

View File

@ -4,22 +4,23 @@
#include "stdafx.h"
#include "database.h"
inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget);
inline void proc_pTarget(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents);
inline void proc_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
inline void proc_pOut(CKContext* ctx, CKParameterOut* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
inline void proc_bIn(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index);
inline void proc_bOut(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index);
inline void proc_bLink(CKBehaviorLink* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
inline void proc_pLocal(CKParameterLocal* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting);
inline void proc_pOper(CKContext* ctx, CKParameterOperation* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget);
void proc_pTarget(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents);
void proc_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
void proc_pOut(CKContext* ctx, CKParameterOut* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
void proc_bIn(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index);
void proc_bOut(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index);
void proc_bLink(CKBehaviorLink* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void proc_pLocal(CKParameterLocal* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting);
void proc_pOper(CKContext* ctx, CKParameterOperation* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void proc_pAttr(CKContext* ctx, scriptDatabase* db, dbScriptDataStructHelper* helper, CKParameter* cache);
inline void helper_pLocalDataExport(const char* field, long data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
inline void helper_pLocalDataExport(const char* field, float data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
inline void helper_pLocalDataExport(const char* field, const char* data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void helper_pDataExport(const char* field, long data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void helper_pDataExport(const char* field, float data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void helper_pDataExport(const char* field, const char* data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void IterateBehavior(CKContext* ctx, CKBehavior* bhv, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void IterateScript(CKContext* ctx, scriptDatabase* db, dbScriptDataStructHelper* helper);
void IteratepLocalData(CKParameterLocal* pl, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void DigParameterData(CKParameterLocal* pl, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
#endif

View File

@ -25,6 +25,7 @@ class dbPLinkInputOutputType(object):
POUT = 1
PLOCAL = 2
PTARGET = 3
PATTR = 4
class dbBLinkInputOutputType(object):
INPUT = 0
@ -41,6 +42,7 @@ class LocalUsageType(object):
PIN = 0
POUT = 1
PLOCAL = 2
PATTR = 3
class JsonCustomEncoder(json.JSONEncoder):
def default(self, field):

View File

@ -434,6 +434,18 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
else:
cache = localUsageCounter[i[0]]
cache.count+=1
cache.lastUse = i[6]
cache.lastDirection = 0
cache.lastIndex = i[9]
elif (i[3] == dcv.dbPLinkInputOutputType.PATTR): # for attribute using
if i[2] not in createdShortcut:
cache = dcv.LocalUsageItem(0, True, dcv.LocalUsageType.PATTR)
localUsageCounter[i[2]] = cache
createdShortcut.add(i[2])
else:
cache = localUsageCounter[i[2]]
cache.count+=1
cache.lastUse = i[6]
cache.lastDirection = 0
@ -500,6 +512,8 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
tableName = 'pIn'
elif (cache.internal_type == dcv.LocalUsageType.POUT):
tableName = 'pOut'
elif (cache.internal_type == dcv.LocalUsageType.PATTR):
tableName = 'pAttr'
else:
tableName = 'pLocal'
exCur.execute("SELECT [name], [type] FROM {} WHERE [thisobj] == ?".format(tableName), (i,))
@ -598,7 +612,11 @@ def buildLink(exDb, deDb, target, currentGraphBlockCell, graphPIO):
(x1, y1) = computLinkPTerminal(i[2], 0, i[5], currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -1, i[0], i[1], i[2], i[6], 0, 0, i[5], i[9], x1, y1, x2, y2))
elif (i[3] == dcv.dbPLinkInputOutputType.PATTR):
(x1, y1) = computLinkPTerminal(i[0], 0, -1, currentGraphBlockCell)
(x2, y2) = computLinkPTerminal(i[6], 0, i[9], currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -1, i[0], i[1], i[2], i[6], 0, 0, -1, i[9], x1, y1, x2, y2))
else:
if i[2] in blockSet: # process protencial pOut(shortcut) (because plocal input/input_obj
# output/output_obj is same, so don't need add for them)
@ -653,6 +671,6 @@ def buildInfo(exDb, deDb):
deCur = deDb.cursor()
# export local data (including proto bb internal data)
exCur.execute("SELECT * FROM pLocalData;")
exCur.execute("SELECT * FROM pData;")
for i in exCur.fetchall():
deCur.execute("INSERT INTO info VALUES (?, ?, ?)", (i[2], i[0], i[1]))

View File

@ -11,6 +11,10 @@
<OutputPath>.</OutputPath>
<Name>SuperScriptViewer</Name>
<RootNamespace>SuperScriptViewer</RootNamespace>
<LaunchProvider>Standard Python launcher</LaunchProvider>
<CommandLineArguments>
</CommandLineArguments>
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>