refactor doc_export.cpp (2/3)

This commit is contained in:
yyc12345 2022-08-05 21:33:12 +08:00
parent cd0aafab9f
commit 7865b651ea
10 changed files with 362 additions and 397 deletions

View File

@ -113,7 +113,6 @@
<ClInclude Include="env_export.h" /> <ClInclude Include="env_export.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="doc_export.hpp" /> <ClInclude Include="doc_export.hpp" />
<ClInclude Include="shared_export.h" />
<ClInclude Include="string_helper.hpp" /> <ClInclude Include="string_helper.hpp" />
<ClInclude Include="virtools_compatible.h" /> <ClInclude Include="virtools_compatible.h" />
<ClInclude Include="vt_menu.h" /> <ClInclude Include="vt_menu.h" />
@ -125,7 +124,6 @@
<ClCompile Include="env_export.cpp" /> <ClCompile Include="env_export.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="doc_export.cpp" /> <ClCompile Include="doc_export.cpp" />
<ClCompile Include="shared_export.cpp" />
<ClCompile Include="string_helper.cpp" /> <ClCompile Include="string_helper.cpp" />
<ClCompile Include="virtools_compatible.cpp" /> <ClCompile Include="virtools_compatible.cpp" />
<ClCompile Include="vt_menu.cpp" /> <ClCompile Include="vt_menu.cpp" />

View File

@ -36,9 +36,6 @@
<ClInclude Include="virtools_compatible.h"> <ClInclude Include="virtools_compatible.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="shared_export.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="data_export.h"> <ClInclude Include="data_export.h">
<Filter>头文件</Filter> <Filter>头文件</Filter>
</ClInclude> </ClInclude>
@ -68,9 +65,6 @@
<ClCompile Include="virtools_compatible.cpp"> <ClCompile Include="virtools_compatible.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="shared_export.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="data_export.cpp"> <ClCompile Include="data_export.cpp">
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>

View File

@ -20,9 +20,9 @@ namespace SSMaterializer {
enum pLinkInputOutputType { enum pLinkInputOutputType {
pLinkInputOutputType_PIN, pLinkInputOutputType_PIN,
pLinkInputOutputType_POUT, pLinkInputOutputType_POUT,
pLinkInputOutputType_PLOCAL, //when using pLocal, omit [index] and [input_is_bb], [input_index] set -1 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_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 pLinkInputOutputType_PATTR //when using pAttr, omit [index], and [input_is_bb] will become [input_is_dataarray]
}; };
// =================== doc mDb // =================== doc mDb

View File

@ -8,305 +8,403 @@
#undef GetClassName #undef GetClassName
#define changeSuffix(a) prefix[endIndex]='\0';strcat(prefix,a) #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):"";
namespace SSMaterializer { namespace SSMaterializer {
namespace DocumentExporter { namespace DocumentExporter {
#pragma region script #pragma region script
void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::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 * `Generate` mean that this function will analyse something to generate some objects which are not existed in original Virtools document.
* `Proc` meath that this function only just export something which is already existed in original Virtools document, or with slight modifications.
*/
/// <summary>
/// Generate pLink and eLink from pIn
/// </summary>
/// <param name="ctx"></param>
/// <param name="analysed_pin"></param>
/// <param name="mDb"></param>
/// <param name="parents"></param>
/// <param name="grandparents"></param>
/// <param name="pin_index"></param>
/// <param name="executedFromBB"></param>
/// <param name="isTarget"></param>
void Generate_pLink(CKContext* ctx, CKParameterIn* analysed_pin, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int pin_index, BOOL executedFromBB, BOOL isTarget) {
CKParameter* directSource = NULL; CKParameter* directSource = NULL;
CKObject* ds_Owner = NULL; CKObject* ds_Owner = NULL;
CKParameterIn* sharedSource = NULL; CKParameterIn* sharedSource = NULL;
CKBehavior* ss_Owner = NULL; CKBehavior* ss_Owner = NULL;
if (directSource = cache->GetDirectSource()) {
helper->_db_pLink->input = directSource->GetID(); // first, we analyse eLink
// check whether this is export parameter and write to database
// if the behavior graph where this pIn locate, also include this pIn, we can simply
// assume there is a eLink between them
if (((CKBehavior*)ctx->GetObject(grandparents))->GetInputParameterPosition(analysed_pin) != -1) {
mDb->mDbHelper.script_eLink.export_obj = analysed_pin->GetID();
mDb->mDbHelper.script_eLink.internal_obj = parents;
mDb->mDbHelper.script_eLink.is_in = TRUE;
mDb->mDbHelper.script_eLink.index = pin_index;
mDb->mDbHelper.script_eLink.parent = grandparents;
mDb->write_script_eLink(mDb->mDbHelper.script_eLink);
// if a eLink has been detected successfully, we returned immediately
// and do not analyse any pLink anymore.
return;
}
// start to analyse pLink
// first, analyse direct_src
if (directSource = analysed_pin->GetDirectSource()) {
mDb->mDbHelper.script_pLink.input = directSource->GetID();
// for almost pin, it is connected to a pLocal, so we use a if to test it first
if (directSource->GetClassID() == CKCID_PARAMETERLOCAL || directSource->GetClassID() == CKCID_PARAMETERVARIABLE) { if (directSource->GetClassID() == CKCID_PARAMETERLOCAL || directSource->GetClassID() == CKCID_PARAMETERVARIABLE) {
//pLocal //pLocal
helper->_db_pLink->input_obj = directSource->GetID(); mDb->mDbHelper.script_pLink.input_obj = directSource->GetID(); // the owner of pLocal is itself.
helper->_db_pLink->input_type = pLinkInputOutputType_PLOCAL; mDb->mDbHelper.script_pLink.input_type = DataStruct::pLinkInputOutputType_PLOCAL;
helper->_db_pLink->input_is_bb = FALSE; mDb->mDbHelper.script_pLink.input_is_bb = FALSE;
helper->_db_pLink->input_index = -1; mDb->mDbHelper.script_pLink.input_index = -1;
} else { } else {
//WARNING: when GetClassID() return CKDataArray there are untested code // according to Virtools SDK document, there are 4 possible value gotten by us:
//pParam from bb pOut / pOper pOut / object Attribute / CKDataArray // bb pOut / pOper pOut / CKObject Attribute / CKDataArray
// however, the last 2 returned values have NOT been tested perfectly.
ds_Owner = directSource->GetOwner(); ds_Owner = directSource->GetOwner();
switch (ds_Owner->GetClassID()) { switch (ds_Owner->GetClassID()) {
case CKCID_BEHAVIOR: case CKCID_BEHAVIOR:
helper->_db_pLink->input_obj = ds_Owner->GetID(); mDb->mDbHelper.script_pLink.input_obj = ds_Owner->GetID();
helper->_db_pLink->input_type = pLinkInputOutputType_POUT; mDb->mDbHelper.script_pLink.input_type = DataStruct::pLinkInputOutputType_POUT;
helper->_db_pLink->input_is_bb = TRUE; mDb->mDbHelper.script_pLink.input_is_bb = TRUE;
helper->_db_pLink->input_index = ((CKBehavior*)ds_Owner)->GetOutputParameterPosition((CKParameterOut*)directSource); mDb->mDbHelper.script_pLink.input_index = ((CKBehavior*)ds_Owner)->GetOutputParameterPosition((CKParameterOut*)directSource);
break; break;
case CKCID_PARAMETEROPERATION: case CKCID_PARAMETEROPERATION:
helper->_db_pLink->input_obj = ds_Owner->GetID(); mDb->mDbHelper.script_pLink.input_obj = ds_Owner->GetID();
helper->_db_pLink->input_type = pLinkInputOutputType_POUT; mDb->mDbHelper.script_pLink.input_type = DataStruct::pLinkInputOutputType_POUT;
helper->_db_pLink->input_is_bb = FALSE; mDb->mDbHelper.script_pLink.input_is_bb = FALSE;
helper->_db_pLink->input_index = 0; mDb->mDbHelper.script_pLink.input_index = 0; // pOper only have 1 pOut
break; break;
case CKCID_DATAARRAY: case CKCID_DATAARRAY:
// dataarray, see as virtual bb pLocal shortcut // CKDataArray, see as virtual bb pLocal shortcut
helper->_db_pLink->input_obj = directSource->GetID(); mDb->mDbHelper.script_pLink.input_obj = directSource->GetID();
helper->_db_pLink->input_type = pLinkInputOutputType_PATTR; mDb->mDbHelper.script_pLink.input_type = DataStruct::pLinkInputOutputType_PATTR;
helper->_db_pLink->input_is_bb = FALSE; mDb->mDbHelper.script_pLink.input_is_bb = FALSE; // omit
helper->_db_pLink->input_index = -1; mDb->mDbHelper.script_pLink.input_index = -1; // omit
proc_pAttr(ctx, mDb, helper, directSource); Proc_pAttr(ctx, mDb, directSource);
break; break;
default: default:
//normal object, see as virtual bb pLocal shortcut // CKObject, because CKDataArray also a CKObject, so we test it first.
helper->_db_pLink->input_obj = directSource->GetID(); // see as virtual bb pLocal shortcut
helper->_db_pLink->input_type = pLinkInputOutputType_PATTR; mDb->mDbHelper.script_pLink.input_obj = directSource->GetID();
helper->_db_pLink->input_is_bb = FALSE; mDb->mDbHelper.script_pLink.input_type = DataStruct::pLinkInputOutputType_PATTR;
helper->_db_pLink->input_index = -1; mDb->mDbHelper.script_pLink.input_is_bb = FALSE; // omit
proc_pAttr(ctx, mDb, helper, directSource); mDb->mDbHelper.script_pLink.input_index = -1; // omit
Proc_pAttr(ctx, mDb, directSource);
break; break;
} }
} }
} }
if (sharedSource = cache->GetSharedSource()) { // direct_src reflect the real source of current analysed pIn,
// however direct_src do not reflact export link
// so we need to analyse shared_src now.
//
// if this pIn has established some export relation, its shared_src must be filled.
// so we can detect it here. once its shared_src is not NULL
// we should consider export link here.
//
// we do not need to analyse any export link here, we just need to export some info
// to indicate this phenomeno.
if (sharedSource = analysed_pin->GetSharedSource()) {
//pIn from BB //pIn from BB
helper->_db_pLink->input = sharedSource->GetID(); mDb->mDbHelper.script_pLink.input = sharedSource->GetID();
ss_Owner = (CKBehavior*)sharedSource->GetOwner(); ss_Owner = (CKBehavior*)sharedSource->GetOwner();
helper->_db_pLink->input_obj = ss_Owner->GetID(); mDb->mDbHelper.script_pLink.input_obj = ss_Owner->GetID();
if (ss_Owner->IsUsingTarget() && (ss_Owner->GetTargetParameter() == sharedSource)) { if (ss_Owner->IsUsingTarget() && (ss_Owner->GetTargetParameter() == sharedSource)) {
//pTarget //pTarget
helper->_db_pLink->input_type = pLinkInputOutputType_PTARGET; mDb->mDbHelper.script_pLink.input_type = DataStruct::pLinkInputOutputType_PTARGET;
helper->_db_pLink->input_is_bb = TRUE; mDb->mDbHelper.script_pLink.input_is_bb = TRUE;
helper->_db_pLink->input_index = -1; mDb->mDbHelper.script_pLink.input_index = -1; // omit
} else { } else {
//pIn //pIn
helper->_db_pLink->input_type = pLinkInputOutputType_PIN; mDb->mDbHelper.script_pLink.input_type = DataStruct::pLinkInputOutputType_PIN;
helper->_db_pLink->input_is_bb = TRUE; mDb->mDbHelper.script_pLink.input_is_bb = TRUE;
helper->_db_pLink->input_index = ss_Owner->GetInputParameterPosition(sharedSource); mDb->mDbHelper.script_pLink.input_index = ss_Owner->GetInputParameterPosition(sharedSource);
} }
} }
// if the header of pLink has been analysed successfully,
// we can add tail info and push into database
if (sharedSource != NULL || directSource != NULL) { if (sharedSource != NULL || directSource != NULL) {
helper->_db_pLink->output = cache->GetID(); mDb->mDbHelper.script_pLink.output = analysed_pin->GetID();
helper->_db_pLink->output_obj = parents; mDb->mDbHelper.script_pLink.output_obj = parents;
helper->_db_pLink->output_type = isTarget ? pLinkInputOutputType_PTARGET : pLinkInputOutputType_PIN; mDb->mDbHelper.script_pLink.output_type = isTarget ? DataStruct::pLinkInputOutputType_PTARGET : DataStruct::pLinkInputOutputType_PIN;
helper->_db_pLink->output_is_bb = executedFromBB; mDb->mDbHelper.script_pLink.output_is_bb = executedFromBB;
helper->_db_pLink->output_index = index; mDb->mDbHelper.script_pLink.output_index = pin_index;
helper->_db_pLink->belong_to = grandparents; mDb->mDbHelper.script_pLink.parent = grandparents;
mDb->write_script_pLink(helper->_db_pLink); mDb->write_script_pLink(mDb->mDbHelper.script_pLink);
} }
} }
void proc_pTarget(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents) { void Generate_pLink(CKContext* ctx, CKParameterOut* analysed_pout, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int pout_index, BOOL executedFromBB) {
helper->_db_pTarget->thisobj = cache->GetID(); // check eLink first
helper->_db_pTarget->name = cache->GetName(); // check whether expoer parameter and write to database
helper->_db_pTarget->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); if (((CKBehavior*)ctx->GetObject(grandparents))->GetOutputParameterPosition(analysed_pout) != -1) {
copyGuid(cache->GetGUID(), helper->_db_pTarget->type_guid); mDb->mDbHelper.script_eLink.export_obj = analysed_pout->GetID();
helper->_db_pTarget->belong_to = parents; mDb->mDbHelper.script_eLink.internal_obj = parents;
helper->_db_pTarget->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1; mDb->mDbHelper.script_eLink.is_in = FALSE;
helper->_db_pTarget->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1; mDb->mDbHelper.script_eLink.index = pout_index;
mDb->mDbHelper.script_eLink.parent = grandparents;
mDb->write_script_pTarget(helper->_db_pTarget); mDb->write_script_eLink(mDb->mDbHelper.script_eLink);
// if an eLink has been generated, skip following pLink generation
//judge whether expoer parameter and write SSMaterializerDatabase
if (((CKBehavior*)ctx->GetObject(grandparents))->GetInputParameterPosition(cache) != -1) {
helper->_db_eLink->export_obj = cache->GetID();
helper->_db_eLink->internal_obj = parents;
helper->_db_eLink->is_in = TRUE;
helper->_db_eLink->index = -1;
helper->_db_eLink->belong_to = grandparents;
mDb->write_script_eLink(helper->_db_eLink);
return; return;
} }
//=========try generate pLink // try generate pLink
generate_pLink_in_pIn(ctx, cache, mDb, helper, parents, grandparents, -1, TRUE, TRUE);
}
void proc_pIn(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::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();
CKParameterType vaildTypeChecker = cache->GetType();
if (vaildTypeChecker != -1) helper->_db_pIn->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
else helper->_db_pIn->type = "!!UNKNOW TYPE!!"; //unknow type
copyGuid(cache->GetGUID(), helper->_db_pIn->type_guid);
helper->_db_pIn->belong_to = parents;
helper->_db_pIn->direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
helper->_db_pIn->shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
mDb->write_script_pIn(helper->_db_pIn);
//judge whether expoer parameter and write SSMaterializerDatabase
if (((CKBehavior*)ctx->GetObject(grandparents))->GetInputParameterPosition(cache) != -1) {
helper->_db_eLink->export_obj = cache->GetID();
helper->_db_eLink->internal_obj = parents;
helper->_db_eLink->is_in = TRUE;
helper->_db_eLink->index = index;
helper->_db_eLink->belong_to = grandparents;
mDb->write_script_eLink(helper->_db_eLink);
return;
}
//=========try generate pLink
generate_pLink_in_pIn(ctx, cache, mDb, helper, parents, grandparents, index, executedFromBB, FALSE);
}
void proc_pOut(CKContext* ctx, CKParameterOut* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::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();
CKParameterType vaildTypeChecker = cache->GetType();
if (vaildTypeChecker != -1) helper->_db_pOut->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
else helper->_db_pOut->type = "!!UNKNOW TYPE!!"; //unknow type
copyGuid(cache->GetGUID(), helper->_db_pOut->type_guid);
helper->_db_pOut->belong_to = parents;
mDb->write_script_pOut(helper->_db_pOut);
//judge whether expoer parameter and write SSMaterializerDatabase
if (((CKBehavior*)ctx->GetObject(grandparents))->GetOutputParameterPosition(cache) != -1) {
helper->_db_eLink->export_obj = cache->GetID();
helper->_db_eLink->internal_obj = parents;
helper->_db_eLink->is_in = FALSE;
helper->_db_eLink->index = index;
helper->_db_eLink->belong_to = grandparents;
mDb->write_script_eLink(helper->_db_eLink);
return;
}
//=========try generate pLink
CKParameter* cache_Dest = NULL; CKParameter* cache_Dest = NULL;
CKObject* cache_DestOwner = NULL; CKObject* cache_DestOwner = NULL;
for (int j = 0, jCount = cache->GetDestinationCount(); j < jCount; j++) { for (int j = 0, jCount = analysed_pout->GetDestinationCount(); j < jCount; j++) {
cache_Dest = cache->GetDestination(j); cache_Dest = analysed_pout->GetDestination(j);
helper->_db_pLink->input = cache->GetID(); mDb->mDbHelper.script_pLink.input = analysed_pout->GetID();
helper->_db_pLink->input_obj = parents; mDb->mDbHelper.script_pLink.input_obj = parents;
helper->_db_pLink->input_type = pLinkInputOutputType_POUT; mDb->mDbHelper.script_pLink.input_type = DataStruct::pLinkInputOutputType_POUT;
helper->_db_pLink->input_is_bb = executedFromBB; mDb->mDbHelper.script_pLink.input_is_bb = executedFromBB;
helper->_db_pLink->input_index = index; mDb->mDbHelper.script_pLink.input_index = pout_index;
helper->_db_pLink->output = cache_Dest->GetID(); mDb->mDbHelper.script_pLink.output = cache_Dest->GetID();
if (cache_Dest->GetClassID() == CKCID_PARAMETERLOCAL) { if (cache_Dest->GetClassID() == CKCID_PARAMETERLOCAL) {
//pLocal //pLocal
helper->_db_pLink->output_obj = cache_Dest->GetID(); mDb->mDbHelper.script_pLink.output_obj = cache_Dest->GetID();
helper->_db_pLink->output_type = pLinkInputOutputType_PLOCAL; mDb->mDbHelper.script_pLink.output_type = DataStruct::pLinkInputOutputType_PLOCAL;
helper->_db_pLink->output_is_bb = FALSE; mDb->mDbHelper.script_pLink.output_is_bb = FALSE; // omit
helper->_db_pLink->output_index = -1; mDb->mDbHelper.script_pLink.output_index = -1; // omit
} else { } else {
//pOut, it must belong to a BB //pOut, it must belong to a graph BB (pOut can not be shared, and prototype bb or pOper do not have link-able pOut).
cache_DestOwner = cache_Dest->GetOwner(); cache_DestOwner = cache_Dest->GetOwner();
helper->_db_pLink->output_obj = cache_DestOwner->GetID(); switch (cache_DestOwner->GetClassID()) {
helper->_db_pLink->output_type = pLinkInputOutputType_POUT; case CKCID_BEHAVIOR:
helper->_db_pLink->output_is_bb = TRUE; mDb->mDbHelper.script_pLink.output_obj = cache_DestOwner->GetID();
helper->_db_pLink->output_index = ((CKBehavior*)cache_DestOwner)->GetOutputParameterPosition((CKParameterOut*)cache_Dest); mDb->mDbHelper.script_pLink.output_type = DataStruct::pLinkInputOutputType_POUT;
mDb->mDbHelper.script_pLink.output_is_bb = TRUE;
mDb->mDbHelper.script_pLink.output_index = ((CKBehavior*)cache_DestOwner)->GetOutputParameterPosition((CKParameterOut*)cache_Dest);
break;
case CKCID_DATAARRAY:
// CKDataArray, see as virtual bb pLocal shortcut
mDb->mDbHelper.script_pLink.output_obj = cache_Dest->GetID();
mDb->mDbHelper.script_pLink.output_type = DataStruct::pLinkInputOutputType_PATTR;
mDb->mDbHelper.script_pLink.input_is_bb = FALSE; // omit
mDb->mDbHelper.script_pLink.input_index = -1; // omit
Proc_pAttr(ctx, mDb, cache_Dest);
break;
default:
// CKObject, because CKDataArray also a CKObject, so we test it first.
// see as virtual bb pLocal shortcut
mDb->mDbHelper.script_pLink.output_obj = cache_Dest->GetID();
mDb->mDbHelper.script_pLink.output_type = DataStruct::pLinkInputOutputType_PATTR;
mDb->mDbHelper.script_pLink.input_is_bb = FALSE; // omit
mDb->mDbHelper.script_pLink.input_index = -1; // omit
Proc_pAttr(ctx, mDb, cache_Dest);
break;
}
} }
helper->_db_pLink->belong_to = grandparents; mDb->mDbHelper.script_pLink.parent = grandparents;
mDb->write_script_pLink(helper->_db_pLink); mDb->write_script_pLink(mDb->mDbHelper.script_pLink);
} }
} }
void proc_bIn(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index) { void Proc_pTarget(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents) {
helper->_db_bIn->thisobj = cache->GetID(); mDb->mDbHelper.script_pTarget.thisobj = cache->GetID();
helper->_db_bIn->index = index; mDb->mDbHelper.script_pTarget.name = cache->GetName();
helper->_db_bIn->name = cache->GetName(); CopyCKParamTypeStr(mDb->mDbHelper.script_pTarget.type, cache->GetType(), mDb->mDbHelper.param_manager);
helper->_db_bIn->belong_to = parents; CopyGuid(mDb->mDbHelper.script_pTarget.type_guid, cache->GetGUID());
mDb->mDbHelper.script_pTarget.parent = parents;
mDb->mDbHelper.script_pTarget.direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
mDb->mDbHelper.script_pTarget.shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
mDb->write_script_bIn(helper->_db_bIn); mDb->write_script_pTarget(mDb->mDbHelper.script_pTarget);
// try generate pLink and eLink
Generate_pLink(ctx, cache, mDb, parents, grandparents, -1, TRUE, TRUE);
} }
void proc_bOut(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index) { void Proc_pIn(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
helper->_db_bOut->thisobj = cache->GetID(); mDb->mDbHelper.script_pIn.thisobj = cache->GetID();
helper->_db_bOut->index = index; mDb->mDbHelper.script_pIn.index = index;
helper->_db_bOut->name = cache->GetName(); mDb->mDbHelper.script_pIn.name = cache->GetName();
helper->_db_bOut->belong_to = parents; CopyCKParamTypeStr(mDb->mDbHelper.script_pIn.type, cache->GetType(), mDb->mDbHelper.param_manager);
CopyGuid(mDb->mDbHelper.script_pIn.type_guid, cache->GetGUID());
mDb->mDbHelper.script_pIn.parent = parents;
mDb->mDbHelper.script_pIn.direct_source = cache->GetDirectSource() ? cache->GetDirectSource()->GetID() : -1;
mDb->mDbHelper.script_pIn.shared_source = cache->GetSharedSource() ? cache->GetSharedSource()->GetID() : -1;
mDb->write_script_pIn(mDb->mDbHelper.script_pIn);
// try generate pLink and eLink
Generate_pLink(ctx, cache, mDb, parents, grandparents, index, executedFromBB, FALSE);
mDb->write_script_bOut(helper->_db_bOut);
} }
void proc_bLink(CKBehaviorLink* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) { void Proc_pOut(CKContext* ctx, CKParameterOut* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
mDb->mDbHelper.script_pOut.thisobj = cache->GetID();
mDb->mDbHelper.script_pOut.index = index;
mDb->mDbHelper.script_pOut.name = cache->GetName();
CopyCKParamTypeStr(mDb->mDbHelper.script_pOut.type, cache->GetType(), mDb->mDbHelper.param_manager);
CopyGuid(mDb->mDbHelper.script_pOut.type_guid, cache->GetGUID());
mDb->mDbHelper.script_pOut.parent = parents;
mDb->write_script_pOut(mDb->mDbHelper.script_pOut);
// try generate pLink and eLink
Generate_pLink(ctx, cache, mDb, parents, grandparents, index, executedFromBB);
}
void Proc_bIn(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index) {
mDb->mDbHelper.script_bIn.thisobj = cache->GetID();
mDb->mDbHelper.script_bIn.index = index;
mDb->mDbHelper.script_bIn.name = cache->GetName();
mDb->mDbHelper.script_bIn.parent = parents;
mDb->write_script_bIn(mDb->mDbHelper.script_bIn);
}
void Proc_bOut(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index) {
mDb->mDbHelper.script_bOut.thisobj = cache->GetID();
mDb->mDbHelper.script_bOut.index = index;
mDb->mDbHelper.script_bOut.name = cache->GetName();
mDb->mDbHelper.script_bOut.parent = parents;
mDb->write_script_bOut(mDb->mDbHelper.script_bOut);
}
void Proc_bLink(CKBehaviorLink* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
CKBehaviorIO* io = cache->GetInBehaviorIO(); CKBehaviorIO* io = cache->GetInBehaviorIO();
CKBehavior* beh = io->GetOwner(); CKBehavior* beh = io->GetOwner();
helper->_db_bLink->input = io->GetID(); mDb->mDbHelper.script_bLink.input = io->GetID();
helper->_db_bLink->input_obj = beh->GetID(); mDb->mDbHelper.script_bLink.input_obj = beh->GetID();
helper->_db_bLink->input_type = (io->GetType() == CK_BEHAVIORIO_IN ? bLinkInputOutputType_INPUT : bLinkInputOutputType_OUTPUT); mDb->mDbHelper.script_bLink.input_type = (io->GetType() == CK_BEHAVIORIO_IN ? bLinkInputOutputType_INPUT : bLinkInputOutputType_OUTPUT);
helper->_db_bLink->input_index = (io->GetType() == CK_BEHAVIORIO_IN ? io->GetOwner()->GetInputPosition(io) : io->GetOwner()->GetOutputPosition(io)); mDb->mDbHelper.script_bLink.input_index = (io->GetType() == CK_BEHAVIORIO_IN ? io->GetOwner()->GetInputPosition(io) : io->GetOwner()->GetOutputPosition(io));
io = cache->GetOutBehaviorIO(); io = cache->GetOutBehaviorIO();
beh = io->GetOwner(); beh = io->GetOwner();
helper->_db_bLink->output = io->GetID(); mDb->mDbHelper.script_bLink.output = io->GetID();
helper->_db_bLink->output_obj = beh->GetID(); mDb->mDbHelper.script_bLink.output_obj = beh->GetID();
helper->_db_bLink->output_type = (io->GetType() == CK_BEHAVIORIO_IN ? bLinkInputOutputType_INPUT : bLinkInputOutputType_OUTPUT); mDb->mDbHelper.script_bLink.output_type = (io->GetType() == CK_BEHAVIORIO_IN ? bLinkInputOutputType_INPUT : bLinkInputOutputType_OUTPUT);
helper->_db_bLink->output_index = (io->GetType() == CK_BEHAVIORIO_IN ? io->GetOwner()->GetInputPosition(io) : io->GetOwner()->GetOutputPosition(io)); mDb->mDbHelper.script_bLink.output_index = (io->GetType() == CK_BEHAVIORIO_IN ? io->GetOwner()->GetInputPosition(io) : io->GetOwner()->GetOutputPosition(io));
helper->_db_bLink->delay = cache->GetActivationDelay(); mDb->mDbHelper.script_bLink.delay = cache->GetActivationDelay();
helper->_db_bLink->belong_to = parents; mDb->mDbHelper.script_bLink.belong_to = parents;
mDb->write_script_bLink(helper->_db_bLink); mDb->write_script_bLink(mDb->mDbHelper.script_bLink);
} }
void proc_pLocal(CKParameterLocal* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, BOOL is_setting) { void Proc_pLocal(CKParameterLocal* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, BOOL is_setting) {
helper->_db_pLocal->thisobj = cache->GetID(); mDb->mDbHelper.script_pLocal.thisobj = cache->GetID();
helper->_db_pLocal->name = cache->GetName() ? cache->GetName() : ""; mDb->mDbHelper.script_pLocal.name = cache->GetName() ? cache->GetName() : "";
CKParameterType vaildTypeChecker = cache->GetType(); CKParameterType vaildTypeChecker = cache->GetType();
if (vaildTypeChecker != -1) helper->_db_pLocal->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types if (vaildTypeChecker != -1) mDb->mDbHelper.script_pLocal.type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
else helper->_db_pLocal->type = "!!UNKNOW TYPE!!"; //unknow type else mDb->mDbHelper.script_pLocal.type = "!!UNKNOW TYPE!!"; //unknow type
copyGuid(cache->GetGUID(), helper->_db_pLocal->type_guid); CopyGuid(cache->GetGUID(), mDb->mDbHelper.script_pLocal.type_guid);
helper->_db_pLocal->is_setting = is_setting; mDb->mDbHelper.script_pLocal.is_setting = is_setting;
helper->_db_pLocal->belong_to = parents; mDb->mDbHelper.script_pLocal.belong_to = parents;
mDb->write_script_pLocal(helper->_db_pLocal); mDb->write_script_pLocal(mDb->mDbHelper.script_pLocal);
//export plocal metadata //export plocal metadata
DigParameterData(cache, mDb, helper, cache->GetID()); DigParameterData(cache, mDb, cache->GetID());
} }
void proc_pOper(CKContext* ctx, CKParameterOperation* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) { void Proc_pOper(CKContext* ctx, CKParameterOperation* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
helper->_db_pOper->thisobj = cache->GetID(); mDb->mDbHelper.script_pOper.thisobj = cache->GetID();
helper->_db_pOper->op = helper->_parameterManager->OperationGuidToName(cache->GetOperationGuid()); mDb->mDbHelper.script_pOper.op = helper->_parameterManager->OperationGuidToName(cache->GetOperationGuid());
copyGuid(cache->GetOperationGuid(), helper->_db_pOper->op_guid); CopyGuid(cache->GetOperationGuid(), mDb->mDbHelper.script_pOper.op_guid);
helper->_db_pOper->belong_to = parents; mDb->mDbHelper.script_pOper.belong_to = parents;
mDb->write_script_pOper(helper->_db_pOper); mDb->write_script_pOper(mDb->mDbHelper.script_pOper);
//export 2 input param and 1 output param //export 2 input param and 1 output param
proc_pIn(ctx, cache->GetInParameter1(), mDb, helper, cache->GetID(), parents, 0, FALSE); Proc_pIn(ctx, cache->GetInParameter1(), mDb, cache->GetID(), parents, 0, FALSE);
proc_pIn(ctx, cache->GetInParameter2(), mDb, helper, cache->GetID(), parents, 1, FALSE); Proc_pIn(ctx, cache->GetInParameter2(), mDb, cache->GetID(), parents, 1, FALSE);
proc_pOut(ctx, cache->GetOutParameter(), mDb, helper, cache->GetID(), parents, 0, FALSE); Proc_pOut(ctx, cache->GetOutParameter(), mDb, cache->GetID(), parents, 0, FALSE);
} }
void proc_pAttr(CKContext* ctx, Database::DocumentDatabase* mDb, CKParameter* cache) { void Proc_pAttr(CKContext* ctx, Database::DocumentDatabase* mDb, CKParameter* cache) {
//write self first to detect conflict //write self first to detect conflict
helper->_db_pAttr->thisobj = cache->GetID(); mDb->mDbHelper.script_pAttr.thisobj = cache->GetID();
safeStringCopy(helper->_db_pAttr->name, cache->GetName()); CopyCKString(mDb->mDbHelper.script_pAttr.name, cache->GetName());
CKParameterType vaildTypeChecker = cache->GetType(); CKParameterType vaildTypeChecker = cache->GetType();
if (vaildTypeChecker != -1) helper->_db_pAttr->type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types if (vaildTypeChecker != -1) mDb->mDbHelper.script_pAttr.type = helper->_parameterManager->ParameterTypeToName(cache->GetType()); //known types
else helper->_db_pAttr->type = "!!UNKNOW TYPE!!"; //unknow type else mDb->mDbHelper.script_pAttr.type = "!!UNKNOW TYPE!!"; //unknow type
copyGuid(cache->GetGUID(), helper->_db_pAttr->type_guid); CopyGuid(cache->GetGUID(), mDb->mDbHelper.script_pAttr.type_guid);
BOOL already_exist = FALSE; BOOL already_exist = FALSE;
mDb->write_script_pAttr(helper->_db_pAttr, &already_exist); mDb->write_script_pAttr(mDb->mDbHelper.script_pAttr, &already_exist);
if (!already_exist) { if (!already_exist) {
//not duplicated, continue write property //not duplicated, continue write property
CKObject* host = cache->GetOwner(); CKObject* host = cache->GetOwner();
DataDictWritter("attr.host_id", (long)host->GetID(), mDb, helper, cache->GetID()); DataDictWritter("attr.host_id", (long)host->GetID(), mDb, cache->GetID());
DataDictWritter("attr.host_name", host->GetName(), mDb, helper, cache->GetID()); DataDictWritter("attr.host_name", host->GetName(), mDb, cache->GetID());
} }
} }
void Proc_Behavior(CKContext* ctx, CKBehavior* bhv, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
//write self data
mDb->mDbHelper.script_behavior.thisobj = bhv->GetID();
mDb->mDbHelper.script_behavior.name = bhv->GetName();
mDb->mDbHelper.script_behavior.type = bhv->GetType();
mDb->mDbHelper.script_behavior.proto_name = bhv->GetPrototypeName() ? bhv->GetPrototypeName() : "";
CopyGuid(bhv->GetPrototypeGuid(), mDb->mDbHelper.script_behavior.proto_guid);
mDb->mDbHelper.script_behavior.flags = bhv->GetFlags();
mDb->mDbHelper.script_behavior.priority = bhv->GetPriority();
mDb->mDbHelper.script_behavior.version = bhv->GetVersion();
mDb->mDbHelper.script_behavior.parent = parents;
sprintf(helper->_stringCache, "%d,%d,%d,%d,%d",
(bhv->IsUsingTarget() ? 1 : 0),
bhv->GetInputParameterCount(),
bhv->GetOutputParameterCount(),
bhv->GetInputCount(),
bhv->GetOutputCount());
mDb->mDbHelper.script_behavior.pin_count = helper->_stringCache;
mDb->write_script_behavior(mDb->mDbHelper.script_behavior);
//write target
if (bhv->IsUsingTarget())
Proc_pTarget(ctx, bhv->GetTargetParameter(), mDb, bhv->GetID(), parents);
int count = 0, i = 0;
//pIn
for (i = 0, count = bhv->GetInputParameterCount(); i < count; i++)
Proc_pIn(ctx, bhv->GetInputParameter(i), mDb, bhv->GetID(), parents, i, TRUE);
//pOut
for (i = 0, count = bhv->GetOutputParameterCount(); i < count; i++)
Proc_pOut(ctx, bhv->GetOutputParameter(i), mDb, bhv->GetID(), parents, i, TRUE);
//bIn
for (i = 0, count = bhv->GetInputCount(); i < count; i++)
Proc_bIn(bhv->GetInput(i), mDb, bhv->GetID(), i);
//bOut
for (i = 0, count = bhv->GetOutputCount(); i < count; i++)
Proc_bOut(bhv->GetOutput(i), mDb, bhv->GetID(), i);
//bLink
for (i = 0, count = bhv->GetSubBehaviorLinkCount(); i < count; i++)
Proc_bLink(bhv->GetSubBehaviorLink(i), mDb, bhv->GetID());
//pLocal
for (i = 0, count = bhv->GetLocalParameterCount(); i < count; i++)
Proc_pLocal(bhv->GetLocalParameter(i), mDb, bhv->GetID(),
bhv->IsLocalParameterSetting(i));
//pOper
for (i = 0, count = bhv->GetParameterOperationCount(); i < count; i++)
Proc_pOper(ctx, bhv->GetParameterOperation(i), mDb, bhv->GetID());
//iterate sub bb
for (i = 0, count = bhv->GetSubBehaviorCount(); i < count; i++)
Proc_Behavior(ctx, bhv->GetSubBehavior(i), mDb, bhv->GetID());
}
void IterateScript(CKContext* ctx, Database::DocumentDatabase* mDb) { void IterateScript(CKContext* ctx, Database::DocumentDatabase* mDb) {
CKBeObject* beobj = NULL; CKBeObject* beobj = NULL;
@ -321,71 +419,18 @@ namespace SSMaterializer {
//write script table //write script table
beh = beobj->GetScript(j); beh = beobj->GetScript(j);
helper->_db_script->thisobj = beobj->GetID(); mDb->mDbHelper.script.thisobj = beobj->GetID();
helper->_db_script->host_name = beobj->GetName(); mDb->mDbHelper.script.host_name = beobj->GetName();
helper->_db_script->index = j; mDb->mDbHelper.script.index = j;
helper->_db_script->behavior = beh->GetID(); mDb->mDbHelper.script.behavior = beh->GetID();
mDb->write_script(helper->_db_script); mDb->write_script(mDb->mDbHelper.script);
//iterate script //iterate script
IterateBehavior(ctx, beh, mDb, helper, -1); Proc_Behavior(ctx, beh, mDb, -1);
} }
} }
} }
void IterateBehavior(CKContext* ctx, CKBehavior* bhv, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) {
//write self data
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->_db_behavior->pin_count = helper->_stringCache;
mDb->write_script_behavior(helper->_db_behavior);
//write target
if (bhv->IsUsingTarget())
proc_pTarget(ctx, bhv->GetTargetParameter(), mDb, helper, bhv->GetID(), parents);
int count = 0, i = 0;
//pIn
for (i = 0, count = bhv->GetInputParameterCount(); i < count; i++)
proc_pIn(ctx, bhv->GetInputParameter(i), mDb, helper, bhv->GetID(), parents, i, TRUE);
//pOut
for (i = 0, count = bhv->GetOutputParameterCount(); i < count; i++)
proc_pOut(ctx, bhv->GetOutputParameter(i), mDb, helper, bhv->GetID(), parents, i, TRUE);
//bIn
for (i = 0, count = bhv->GetInputCount(); i < count; i++)
proc_bIn(bhv->GetInput(i), mDb, helper, bhv->GetID(), i);
//bOut
for (i = 0, count = bhv->GetOutputCount(); i < count; i++)
proc_bOut(bhv->GetOutput(i), mDb, helper, bhv->GetID(), i);
//bLink
for (i = 0, count = bhv->GetSubBehaviorLinkCount(); i < count; i++)
proc_bLink(bhv->GetSubBehaviorLink(i), mDb, helper, bhv->GetID());
//pLocal
for (i = 0, count = bhv->GetLocalParameterCount(); i < count; i++)
proc_pLocal(bhv->GetLocalParameter(i), mDb, helper, bhv->GetID(),
bhv->IsLocalParameterSetting(i));
//pOper
for (i = 0, count = bhv->GetParameterOperationCount(); i < count; i++)
proc_pOper(ctx, bhv->GetParameterOperation(i), mDb, helper, bhv->GetID());
//iterate sub bb
for (i = 0, count = bhv->GetSubBehaviorCount(); i < count; i++)
IterateBehavior(ctx, bhv->GetSubBehavior(i), mDb, helper, bhv->GetID());
}
#pragma endregion #pragma endregion
#pragma region array #pragma region array
@ -403,12 +448,12 @@ namespace SSMaterializer {
//nothing //nothing
if (t == CKPGUID_NONE) return; if (t == CKPGUID_NONE) return;
if (p->GetParameterClassID() && p->GetValueObject(false)) { if (p->GetParameterClassID() && p->GetValueObject(false)) {
DataDictWritter("id", (long)p->GetValueObject(false)->GetID(), mDb, helper, parents); DataDictWritter("id", (long)p->GetValueObject(false)->GetID(), mDb, parents);
DataDictWritter("name", p->GetValueObject(false)->GetName(), mDb, helper, parents); DataDictWritter("name", p->GetValueObject(false)->GetName(), mDb, parents);
CK_CLASSID none_classid = p->GetValueObject(false)->GetClassID(); CK_CLASSID none_classid = p->GetValueObject(false)->GetClassID();
CKParameterType none_type = helper->_parameterManager->ClassIDToType(none_classid); CKParameterType none_type = helper->_parameterManager->ClassIDToType(none_classid);
DataDictWritter("type", helper->_parameterManager->ParameterTypeToName(none_type), mDb, helper, parents); DataDictWritter("type", helper->_parameterManager->ParameterTypeToName(none_type), mDb, parents);
return; return;
} }
//float //float
@ -417,7 +462,7 @@ namespace SSMaterializer {
|| t == CKPGUID_FLOATSLIDER || t == CKPGUID_FLOATSLIDER
#endif #endif
) { ) {
DataDictWritter("float-data", *(float*)(p->GetReadDataPtr(false)), mDb, helper, parents); DataDictWritter("float-data", *(float*)(p->GetReadDataPtr(false)), mDb, parents);
return; return;
} }
//int //int
@ -428,22 +473,22 @@ namespace SSMaterializer {
|| t == CKPGUID_LIGHTTYPE || t == CKPGUID_SPRITEALIGN || t == CKPGUID_DIRECTION || t == CKPGUID_LAYERTYPE || t == CKPGUID_LIGHTTYPE || t == CKPGUID_SPRITEALIGN || t == CKPGUID_DIRECTION || t == CKPGUID_LAYERTYPE
|| t == CKPGUID_COMPOPERATOR || t == CKPGUID_BINARYOPERATOR || t == CKPGUID_SETOPERATOR || t == CKPGUID_COMPOPERATOR || t == CKPGUID_BINARYOPERATOR || t == CKPGUID_SETOPERATOR
|| t == CKPGUID_OBSTACLEPRECISION || t == CKPGUID_OBSTACLEPRECISIONBEH) { || t == CKPGUID_OBSTACLEPRECISION || t == CKPGUID_OBSTACLEPRECISIONBEH) {
DataDictWritter("int-data", (long)(*(int*)(p->GetReadDataPtr(false))), mDb, helper, parents); DataDictWritter("int-data", (long)(*(int*)(p->GetReadDataPtr(false))), mDb, parents);
return; return;
} }
if (t == CKPGUID_VECTOR) { if (t == CKPGUID_VECTOR) {
VxVector vec; VxVector vec;
memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec)); memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec));
DataDictWritter("vector.x", vec.x, mDb, helper, parents); DataDictWritter("vector.x", vec.x, mDb, parents);
DataDictWritter("vector.y", vec.y, mDb, helper, parents); DataDictWritter("vector.y", vec.y, mDb, parents);
DataDictWritter("vector.z", vec.z, mDb, helper, parents); DataDictWritter("vector.z", vec.z, mDb, parents);
return; return;
} }
if (t == CKPGUID_2DVECTOR) { if (t == CKPGUID_2DVECTOR) {
Vx2DVector vec; Vx2DVector vec;
memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec)); memcpy(&vec, p->GetReadDataPtr(false), sizeof(vec));
DataDictWritter("2dvector.x", vec.x, mDb, helper, parents); DataDictWritter("2dvector.x", vec.x, mDb, parents);
DataDictWritter("2dvector.y", vec.y, mDb, helper, parents); DataDictWritter("2dvector.y", vec.y, mDb, parents);
return; return;
} }
if (t == CKPGUID_MATRIX) { if (t == CKPGUID_MATRIX) {
@ -454,7 +499,7 @@ namespace SSMaterializer {
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) { for (int j = 0; j < 4; ++j) {
sprintf(position, "matrix[%d][%d]", i, j); sprintf(position, "matrix[%d][%d]", i, j);
DataDictWritter(position, mat[i][j], mDb, helper, parents); DataDictWritter(position, mat[i][j], mDb, parents);
} }
} }
return; return;
@ -462,10 +507,10 @@ namespace SSMaterializer {
if (t == CKPGUID_COLOR) { if (t == CKPGUID_COLOR) {
VxColor col; VxColor col;
memcpy(&col, p->GetReadDataPtr(false), sizeof(col)); memcpy(&col, p->GetReadDataPtr(false), sizeof(col));
DataDictWritter("color.r", col.r, mDb, helper, parents); DataDictWritter("color.r", col.r, mDb, parents);
DataDictWritter("color.g", col.g, mDb, helper, parents); DataDictWritter("color.g", col.g, mDb, parents);
DataDictWritter("color.b", col.b, mDb, helper, parents); DataDictWritter("color.b", col.b, mDb, parents);
DataDictWritter("color.a", col.a, mDb, helper, parents); DataDictWritter("color.a", col.a, mDb, parents);
return; return;
} }
if (t == CKPGUID_2DCURVE) { if (t == CKPGUID_2DCURVE) {
@ -479,27 +524,27 @@ namespace SSMaterializer {
endIndex = strlen(prefix); endIndex = strlen(prefix);
changeSuffix(".pos.x"); changeSuffix(".pos.x");
DataDictWritter(prefix, c->GetControlPoint(i)->GetPosition().x, mDb, helper, parents); DataDictWritter(prefix, c->GetControlPoint(i)->GetPosition().x, mDb, parents);
changeSuffix(".pos.y"); changeSuffix(".pos.y");
DataDictWritter(prefix, c->GetControlPoint(i)->GetPosition().y, mDb, helper, parents); DataDictWritter(prefix, c->GetControlPoint(i)->GetPosition().y, mDb, parents);
changeSuffix(".islinear"); changeSuffix(".islinear");
DataDictWritter(prefix, (long)c->GetControlPoint(i)->IsLinear(), mDb, helper, parents); DataDictWritter(prefix, (long)c->GetControlPoint(i)->IsLinear(), mDb, parents);
if (c->GetControlPoint(i)->IsTCB()) { if (c->GetControlPoint(i)->IsTCB()) {
changeSuffix(".bias"); changeSuffix(".bias");
DataDictWritter(prefix, c->GetControlPoint(i)->GetBias(), mDb, helper, parents); DataDictWritter(prefix, c->GetControlPoint(i)->GetBias(), mDb, parents);
changeSuffix(".continuity"); changeSuffix(".continuity");
DataDictWritter(prefix, c->GetControlPoint(i)->GetContinuity(), mDb, helper, parents); DataDictWritter(prefix, c->GetControlPoint(i)->GetContinuity(), mDb, parents);
changeSuffix(".tension"); changeSuffix(".tension");
DataDictWritter(prefix, c->GetControlPoint(i)->GetTension(), mDb, helper, parents); DataDictWritter(prefix, c->GetControlPoint(i)->GetTension(), mDb, parents);
} else { } else {
changeSuffix(".intangent.x"); changeSuffix(".intangent.x");
DataDictWritter(prefix, c->GetControlPoint(i)->GetInTangent().x, mDb, helper, parents); DataDictWritter(prefix, c->GetControlPoint(i)->GetInTangent().x, mDb, parents);
changeSuffix(".intangent.y"); changeSuffix(".intangent.y");
DataDictWritter(prefix, c->GetControlPoint(i)->GetInTangent().y, mDb, helper, parents); DataDictWritter(prefix, c->GetControlPoint(i)->GetInTangent().y, mDb, parents);
changeSuffix(".outtangent.x"); changeSuffix(".outtangent.x");
DataDictWritter(prefix, c->GetControlPoint(i)->GetOutTangent().x, mDb, helper, parents); DataDictWritter(prefix, c->GetControlPoint(i)->GetOutTangent().x, mDb, parents);
changeSuffix(".outtangent.y"); changeSuffix(".outtangent.y");
DataDictWritter(prefix, c->GetControlPoint(i)->GetOutTangent().y, mDb, helper, parents); DataDictWritter(prefix, c->GetControlPoint(i)->GetOutTangent().y, mDb, parents);
} }
} }
return; return;
@ -548,7 +593,7 @@ namespace SSMaterializer {
mDb->write_pData(helper->_db_pData); mDb->write_pData(helper->_db_pData);
//dump data length //dump data length
DataDictWritter("dump.length", (long)cc, mDb, helper, parents); DataDictWritter("dump.length", (long)cc, mDb, parents);
return; return;
} }
} }

View File

@ -6,19 +6,20 @@
namespace SSMaterializer { namespace SSMaterializer {
namespace DocumentExporter { namespace DocumentExporter {
void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget); void Generate_pLink(CKContext* ctx, CKParameterIn* analysed_pin, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int pin_index, BOOL executedFromBB, BOOL isTarget);
void proc_pTarget(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents); void Generate_pLink(CKContext* ctx, CKParameterOut* analysed_pout, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int pout_index, BOOL executedFromBB);
void proc_pIn(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB); void Proc_pTarget(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents);
void proc_pOut(CKContext* ctx, CKParameterOut* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB); void Proc_pIn(CKContext* ctx, CKParameterIn* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
void proc_bIn(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index); void Proc_pOut(CKContext* ctx, CKParameterOut* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, DataStruct::EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
void proc_bOut(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index); void Proc_bIn(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index);
void proc_bLink(CKBehaviorLink* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); void Proc_bOut(CKBehaviorIO* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, int index);
void proc_pLocal(CKParameterLocal* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, BOOL is_setting); void Proc_bLink(CKBehaviorLink* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents);
void proc_pOper(CKContext* ctx, CKParameterOperation* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); void Proc_pLocal(CKParameterLocal* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents, BOOL is_setting);
void proc_pAttr(CKContext* ctx, Database::DocumentDatabase* mDb, CKParameter* cache); void Proc_pOper(CKContext* ctx, CKParameterOperation* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents);
void Proc_pAttr(CKContext* ctx, Database::DocumentDatabase* mDb, CKParameter* cache);
void IterateBehavior(CKContext* ctx, CKBehavior* bhv, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); void Proc_Behavior(CKContext* ctx, CKBehavior* bhv, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents);
void IterateScript(CKContext* ctx, Database::DocumentDatabase* mDb); void IterateScript(CKContext* ctx, Database::DocumentDatabase* mDb);
void IterateArray(CKContext* ctx, Database::DocumentDatabase* mDb); void IterateArray(CKContext* ctx, Database::DocumentDatabase* mDb);

View File

@ -2,8 +2,8 @@
//disable shit tip //disable shit tip
#pragma warning(disable:26812) #pragma warning(disable:26812)
#define copyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache; #define CopyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache;
#define safeStringCopy(storage,str) storage=(str)?(str):""; #define CopyCKString(storage,str) storage=(str)?(str):"";
void IterateParameterOperation(CKParameterManager* parameterManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper) { void IterateParameterOperation(CKParameterManager* parameterManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper) {
int count = parameterManager->GetParameterOperationCount(); int count = parameterManager->GetParameterOperationCount();
@ -14,7 +14,7 @@ void IterateParameterOperation(CKParameterManager* parameterManager, Environment
//fill basic data //fill basic data
helper->_db_op->op_code = i; helper->_db_op->op_code = i;
_guid = parameterManager->OperationCodeToGuid(i); _guid = parameterManager->OperationCodeToGuid(i);
copyGuid(_guid,helper->_db_op->op_guid); CopyGuid(_guid,helper->_db_op->op_guid);
helper->_db_op->op_name = parameterManager->OperationCodeToName(i); helper->_db_op->op_name = parameterManager->OperationCodeToName(i);
//allocate mem //allocate mem
@ -27,9 +27,9 @@ void IterateParameterOperation(CKParameterManager* parameterManager, Environment
parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, opList); parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, opList);
for (int j = 0; j < cacheListCount; j++) { for (int j = 0; j < cacheListCount; j++) {
copyGuid(opList[j].P1Guid, helper->_db_op->in1_guid); CopyGuid(opList[j].P1Guid, helper->_db_op->in1_guid);
copyGuid(opList[j].P2Guid, helper->_db_op->in2_guid); CopyGuid(opList[j].P2Guid, helper->_db_op->in2_guid);
copyGuid(opList[j].ResGuid, helper->_db_op->out_guid); CopyGuid(opList[j].ResGuid, helper->_db_op->out_guid);
helper->_db_op->funcPtr = opList[j].Fct; helper->_db_op->funcPtr = opList[j].Fct;
mDb->write_op(helper->_db_op); mDb->write_op(helper->_db_op);
@ -46,8 +46,8 @@ void IterateParameter(CKParameterManager* parameterManager, EnvironmentDatabase*
desc = parameterManager->GetParameterTypeDescription(i); desc = parameterManager->GetParameterTypeDescription(i);
helper->_db_param->index = desc->Index; helper->_db_param->index = desc->Index;
copyGuid(desc->Guid, helper->_db_param->guid); CopyGuid(desc->Guid, helper->_db_param->guid);
copyGuid(desc->DerivedFrom, helper->_db_param->derived_from); CopyGuid(desc->DerivedFrom, helper->_db_param->derived_from);
helper->_db_param->type_name = desc->TypeName.CStr(); helper->_db_param->type_name = desc->TypeName.CStr();
helper->_db_param->default_size = desc->DefaultSize; helper->_db_param->default_size = desc->DefaultSize;
helper->_db_param->func_CreateDefault = desc->CreateDefaultFunction; helper->_db_param->func_CreateDefault = desc->CreateDefaultFunction;
@ -68,7 +68,7 @@ void IterateParameter(CKParameterManager* parameterManager, EnvironmentDatabase*
helper->_db_param->dw_param = desc->dwParam; helper->_db_param->dw_param = desc->dwParam;
helper->_db_param->dw_flags = desc->dwFlags; helper->_db_param->dw_flags = desc->dwFlags;
helper->_db_param->cid = desc->Cid; helper->_db_param->cid = desc->Cid;
copyGuid(desc->Saver_Manager, helper->_db_param->saver_manager); CopyGuid(desc->Saver_Manager, helper->_db_param->saver_manager);
mDb->write_param(helper->_db_param); mDb->write_param(helper->_db_param);
} }
@ -113,7 +113,7 @@ void IteratePlugin(CKPluginManager* plgManager, EnvironmentDatabase* mDb, dbEnvD
helper->_db_plugin->active = plgEntry->m_Active; helper->_db_plugin->active = plgEntry->m_Active;
helper->_db_plugin->needed_by_file = plgEntry->m_NeededByFile; helper->_db_plugin->needed_by_file = plgEntry->m_NeededByFile;
CKPluginInfo* plgInfo = &(plgEntry->m_PluginInfo); CKPluginInfo* plgInfo = &(plgEntry->m_PluginInfo);
copyGuid(plgInfo->m_GUID, helper->_db_plugin->guid); CopyGuid(plgInfo->m_GUID, helper->_db_plugin->guid);
helper->_db_plugin->desc = plgInfo->m_Description.CStr(); helper->_db_plugin->desc = plgInfo->m_Description.CStr();
helper->_db_plugin->author = plgInfo->m_Author.CStr(); helper->_db_plugin->author = plgInfo->m_Author.CStr();
helper->_db_plugin->summary = plgInfo->m_Summary.CStr(); helper->_db_plugin->summary = plgInfo->m_Summary.CStr();
@ -134,10 +134,10 @@ void IterateVariable(CKVariableManager* varManager, EnvironmentDatabase* mDb, db
for (; !it.End(); it++) { for (; !it.End(); it++) {
varobj = it.GetVariable(); varobj = it.GetVariable();
helper->_db_variable->name = it.GetName(); helper->_db_variable->name = it.GetName();
safeStringCopy(helper->_db_variable->desciption, varobj->GetDescription()); CopyCKString(helper->_db_variable->desciption, varobj->GetDescription());
helper->_db_variable->flags = varobj->GetFlags(); helper->_db_variable->flags = varobj->GetFlags();
helper->_db_variable->type = varobj->GetType(); helper->_db_variable->type = varobj->GetType();
safeStringCopy(helper->_db_variable->representation, varobj->GetRepresentation()); CopyCKString(helper->_db_variable->representation, varobj->GetRepresentation());
varobj->GetStringValue(dataCopyCache); varobj->GetStringValue(dataCopyCache);
helper->_db_variable->data = dataCopyCache.CStr(); helper->_db_variable->data = dataCopyCache.CStr();

View File

@ -1,42 +0,0 @@
#include "shared_export.h"
combined_database::combined_database() :
db_script(NULL),
helper_script(NULL),
db_data(NULL),
helper_data(NULL) {
;
}
dbdoc_data* 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(dbdoc_data* data) {
if (db_script != NULL) db_script->write_pData(data);
if (db_data != NULL) db_data->write_objParam(data);
}
void DigParameterData(CKParameter* p, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents) {
combined_database cdb;
cdb.db_script = mDb;
cdb.helper_script = helper;
DigParameterData(p, &cdb, parents);
}
void DigParameterData(CKParameter* p, dataDatabase* mDb, dbDataDataStructHelper* helper, EXPAND_CK_ID parents) {
combined_database cdb;
cdb.db_data = mDb;
cdb.helper_data = helper;
DigParameterData(p, &cdb, parents);
}

View File

@ -1,31 +0,0 @@
#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();
dbdoc_data* get_struct();
char* get_string_cache();
void write_dict(dbdoc_data* data);
DocumentDatabase* db_script;
dbDocDataStructHelper* 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, DocumentDatabase* mDb, dbDocDataStructHelper* helper, EXPAND_CK_ID parents);
void DigParameterData(CKParameter* p, dataDatabase* mDb, dbDataDataStructHelper* helper, EXPAND_CK_ID parents);
void helper_FillStruct(const char* field, long data, dbdoc_data* helper);
void helper_FillStruct(const char* field, float data, dbdoc_data* helper);
void helper_FillStruct(const char* field, const char* data, dbdoc_data* helper);
#endif

View File

@ -23,9 +23,5 @@ namespace SSMaterializer {
} }
} }
void CopyGUID(std::string& strl, CKGUID& guid) {
StdstringPrintf(strl, "0x%08x, 0x%08x", guid.d1, guid.d2);
}
} }
} }

View File

@ -3,12 +3,16 @@
#include "stdafx.h" #include "stdafx.h"
#include <string> #include <string>
#define CopyGuid(str, guid) SSMaterializer::Utils::StdstringPrintf((str), "0x%08x, 0x%08x", (guid).d1, (guid).d2);
#define CopyCKString(storage, str) storage = (str) ? (str) : "";
#define CopyCKParamTypeStr(strl, ckpt, pm) if ((ckpt) != -1) (strl) = (pm)->ParameterTypeToName(ckpt);\
else (strl) = "!!UNKNOW TYPE!!";
namespace SSMaterializer { namespace SSMaterializer {
namespace Utils { namespace Utils {
void StdstringPrintf(std::string& strl, const char* format, ...); void StdstringPrintf(std::string& strl, const char* format, ...);
void StdstringVPrintf(std::string& strl, const char* format, va_list argptr); void StdstringVPrintf(std::string& strl, const char* format, va_list argptr);
void CopyGUID(std::string& strl, CKGUID& guid);
} }
} }