enhance something

This commit is contained in:
yyc12345 2020-04-03 16:10:53 +08:00
parent af516ff3bf
commit 820e87f2bc
3 changed files with 50 additions and 10 deletions

View File

@ -58,7 +58,7 @@ void database::open(const char* file) {
NULL, NULL, &errmsg); NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail; if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db, result = sqlite3_exec(db,
"CREATE TABLE behavior('thisobj' INTEGER, 'name' TEXT, 'type' INTEGER, 'proto_name' TEXT, 'proto_guid' TEXT, 'flags' INTEGER, 'priority' INTEGER, 'version' INTEGER, 'parent' INTEGER);", "CREATE TABLE behavior('thisobj' INTEGER, 'name' TEXT, 'type' INTEGER, 'proto_name' TEXT, 'proto_guid' TEXT, 'flags' INTEGER, 'priority' INTEGER, 'version' INTEGER, 'pin_count' TEXT, 'parent' INTEGER);",
NULL, NULL, &errmsg); NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail; if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db, result = sqlite3_exec(db,
@ -133,7 +133,7 @@ void database::close() {
void database::write_CKBehavior(dbCKBehavior* data) { void database::write_CKBehavior(dbCKBehavior* data) {
if (db == NULL) return; if (db == NULL) return;
sprintf(commandStr, "INSERT INTO behavior VALUES (%d, '%s', %d, '%s', '%d, %d', %d, %d, %d, %d);", sprintf(commandStr, "INSERT INTO behavior VALUES (%d, '%s', %d, '%s', '%d, %d', %d, %d, %d, '%s', %d);",
data->thisobj, data->thisobj,
data->name, data->name,
data->type, data->type,
@ -143,6 +143,7 @@ void database::write_CKBehavior(dbCKBehavior* data) {
data->flags, data->flags,
data->priority, data->priority,
data->version, data->version,
data->pin_count,
data->parent); data->parent);
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg); sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);

View File

@ -17,6 +17,8 @@ typedef struct dbCKBehavior {
CK_BEHAVIOR_FLAGS flags; CK_BEHAVIOR_FLAGS flags;
int priority; int priority;
CKDWORD version; CKDWORD version;
//pTarget, pIn, pOut, bIn, bOut
char pin_count[128];
EXPAND_CK_ID parent; EXPAND_CK_ID parent;
}; };

View File

@ -186,6 +186,12 @@ void IterateBehavior(CKBehavior* bhv, database* db, dbDataStructHelper* helper,
helper->_dbCKBehavior->priority = bhv->GetPriority(); helper->_dbCKBehavior->priority = bhv->GetPriority();
helper->_dbCKBehavior->version = bhv->GetVersion(); helper->_dbCKBehavior->version = bhv->GetVersion();
helper->_dbCKBehavior->parent = parents; helper->_dbCKBehavior->parent = parents;
sprintf(helper->_dbCKBehavior->pin_count, "%d, %d, %d, %d, %d",
(bhv->IsUsingTarget() ? 1 : 0),
bhv->GetInputParameterCount(),
bhv->GetOutputParameterCount(),
bhv->GetInputCount(),
bhv->GetOutputCount());
db->write_CKBehavior(helper->_dbCKBehavior); db->write_CKBehavior(helper->_dbCKBehavior);
//write target //write target
@ -324,20 +330,51 @@ void IteratepLocalData(CKParameterLocal* p, database* db, dbDataStructHelper* he
} }
return; return;
} }
if (t == CKPGUID_STRING) {
unknowType = TRUE;
//if it gets here, we have no idea what it really is. so simply dump it.
//buffer-like
if (unknowType || t == CKPGUID_VOIDBUF || t == CKPGUID_STRING || t == CKPGUID_SHADER || t == CKPGUID_TECHNIQUE || t == CKPGUID_PASS) {
char* cptr = (char*)p->GetReadDataPtr(false); char* cptr = (char*)p->GetReadDataPtr(false);
int cc = p->GetDataSize(); int cc = p->GetDataSize();
for (int i = 0; i < cc; i++) for (int i = 0; i < cc; i++)
helper->_db_pLocalData->data[i] = cptr[i]; helper->_db_pLocalData->data[i] = cptr[i];
helper->_db_pLocalData->data[cc] = '\0'; helper->_db_pLocalData->data[cc] = '\0';
strcpy(helper->_db_pLocalData->field, "dump-data"); strcpy(helper->_db_pLocalData->field, "str");
helper->_db_pLocalData->belong_to = p->GetID();
db->write_pLocalData(helper->_db_pLocalData);
return;
}
unknowType = TRUE;
//if it gets here, we have no idea what it really is. so simply dump it.
//buffer-like
if (unknowType || t == CKPGUID_VOIDBUF || t == CKPGUID_SHADER || t == CKPGUID_TECHNIQUE || t == CKPGUID_PASS) {
//dump data
unsigned char* cptr = (unsigned char*)p->GetReadDataPtr(false);
char temp[4];
int cc = 0, rcc = 0, pos = 0;
rcc = cc = p->GetDataSize();
if (rcc > 200) rcc = 200;
for (int i = 0; i < rcc; i++) {
sprintf(temp, "%02X", cptr[i]);
helper->_db_pLocalData->data[pos++] = '0';
helper->_db_pLocalData->data[pos++] = 'x';
helper->_db_pLocalData->data[pos++] = temp[0];
helper->_db_pLocalData->data[pos++] = temp[1];
helper->_db_pLocalData->data[pos++] = ',';
}
if (pos)
helper->_db_pLocalData->data[--pos] = '\0';
else
helper->_db_pLocalData->data[0] = '\0';
if (rcc == cc)
strcpy(helper->_db_pLocalData->field, "dump.data");
else
strcpy(helper->_db_pLocalData->field, "dump.partial_data");
helper->_db_pLocalData->belong_to = p->GetID(); helper->_db_pLocalData->belong_to = p->GetID();
db->write_pLocalData(helper->_db_pLocalData); db->write_pLocalData(helper->_db_pLocalData);
//dump data length
helper_pLocalDataExport("dump.length", (long)cc, db, helper, parents);
return; return;
} }
} }