add full env export and add icon for viewer

This commit is contained in:
yyc12345 2020-04-25 12:28:57 +08:00
parent d601cef30f
commit a5174e935a
12 changed files with 233 additions and 20 deletions

View File

@ -39,11 +39,17 @@ void dbScriptDataStructHelper::dispose() {
void dbEnvDataStructHelper::init() {
_db_envOp = new db_envOp;
_db_envParam = new db_envParam;
_db_envMsg = new db_envMsg;
_db_envAttr = new db_envAttr;
_db_envPlugin = new db_envPlugin;
}
void dbEnvDataStructHelper::dispose() {
delete _db_envOp;
delete _db_envParam;
delete _db_envMsg;
delete _db_envAttr;
delete _db_envPlugin;
}
#pragma endregion
@ -181,7 +187,19 @@ BOOL envDatabase::init() {
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE param([index] INTEGER, [guid] TEXT, [derived_from] TEXT, [type_name] TEXT, [default_size] INTEGER, [func_CreateDefault] INTEGER, [func_Delete] INTEGER, [func_SaveLoad] INTEGER, [func_Check] INTEGER, [func_Copy] INTEGER, [func_String] INTEGER, [func_UICreator] INTEGER, [creator_plugin_id] INTEGER, [dw_param] INTEGER, [dw_flags] INTEGER, [cid] INTEGER, [saver_manager] TEXT);",
"CREATE TABLE param([index] INTEGER, [guid] TEXT, [derived_from] TEXT, [type_name] TEXT, [default_size] INTEGER, [func_CreateDefault] INTEGER, [func_Delete] INTEGER, [func_SaveLoad] INTEGER, [func_Check] INTEGER, [func_Copy] INTEGER, [func_String] INTEGER, [func_UICreator] INTEGER, [creator_dll_index] INTEGER, [creator_plugin_index] INTEGER, [dw_param] INTEGER, [dw_flags] INTEGER, [cid] INTEGER, [saver_manager] TEXT);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE msg([index] INTEGER, [name] TEXT);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE attr([index] INTEGER, [name] TEXT, [category_index] INTEGER, [category_name] TEXT, [flags] INTEGER, [param_index] INTEGER, [compatible_classid] INTEGER, [default_value] TEXT);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE plugin([dll_index] INTEGER, [dll_name] TEXT, [plugin_index] INTEGER, [category] TEXT, [active] INTEGER, [needed_by_file] INTEGER, [guid] TEXT, [desc] TEXT, [author] TEXT, [summary] TEXT, [version] INTEGER, [func_init] INTEGER, [func_exit] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
@ -419,7 +437,7 @@ void envDatabase::write_envOp(db_envOp* data) {
void envDatabase::write_envParam(db_envParam* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO param VALUES (%d, '%d,%d', '%d,%d', '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%d,%d');",
sprintf(commandStr, "INSERT INTO param VALUES (%d, '%d,%d', '%d,%d', '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%d,%d');",
data->index,
data->guid[0],
data->guid[1],
@ -434,7 +452,8 @@ void envDatabase::write_envParam(db_envParam* data) {
data->func_Copy,
data->func_String,
data->func_UICreator,
data->creator_plugin_id,
data->creator_dll_index,
data->creator_plugin_index,
data->dw_param,
data->dw_flags,
data->cid,
@ -444,5 +463,53 @@ void envDatabase::write_envParam(db_envParam* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void envDatabase::write_envMsg(db_envMsg* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO msg VALUES (%d, '%s');",
data->index,
data->name);
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void envDatabase::write_envAttr(db_envAttr* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO attr VALUES (%d, '%s', %d, '%s', %d, %d, %d, '%s');",
data->index,
data->name,
data->category_index,
data->category_name,
data->flags,
data->param_index,
data->compatible_classid,
data->default_value);
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void envDatabase::write_envPlugin(db_envPlugin* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO plugin VALUES (%d, '%s', %d, '%s', %d, %d, '%d,%d', '%s', '%s', '%s', %d, %d, %d);",
data->dll_index,
data->dll_name,
data->plugin_index,
data->category,
data->active,
data->needed_by_file,
data->guid[0],
data->guid[1],
data->desc,
data->author,
data->summary,
data->version,
data->func_init,
data->func_exit);
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
#pragma endregion

View File

@ -4,8 +4,6 @@
#include <sqlite3.h>
#include "stdafx.h"
#pragma region data struct define
typedef long EXPAND_CK_ID;
enum bLinkInputOutputType {
bLinkInputOutputType_INPUT,
@ -18,6 +16,8 @@ enum pLinkInputOutputType {
pLinkInputOutputType_PTARGET //when using pTarget, omit [index] and [input_is_bb]
};
#pragma region data struct define
typedef struct {
EXPAND_CK_ID thisobj;
char name[1024];
@ -164,13 +164,46 @@ typedef struct {
CK_PARAMETERCOPYFUNCTION func_Copy;
CK_PARAMETERSTRINGFUNCTION func_String;
CK_PARAMETERUICREATORFUNCTION func_UICreator;
int creator_plugin_id;
int creator_dll_index;
int creator_plugin_index;
CKDWORD dw_param;
CKDWORD dw_flags;
CKDWORD cid;
CKDWORD saver_manager[2];
}db_envParam;
typedef struct {
CKMessageType index;
char name[1024];
}db_envMsg;
typedef struct {
CKAttributeType index;
char name[1024];
CKAttributeCategory category_index;
char category_name[1024];
CK_ATTRIBUT_FLAGS flags;
CKParameterType param_index;
CK_CLASSID compatible_classid;
char default_value[1024];
}db_envAttr;
typedef struct {
int dll_index;
char dll_name[1024];
int plugin_index;
char category[1024];
CKBOOL active;
CKBOOL needed_by_file;
CKDWORD guid[2];
char desc[1024];
char author[1024];
char summary[1024];
DWORD version;
CK_INITINSTANCEFCT func_init;
CK_EXITINSTANCEFCT func_exit;
}db_envPlugin;
#pragma endregion
class dbScriptDataStructHelper {
@ -201,6 +234,9 @@ class dbEnvDataStructHelper {
db_envOp* _db_envOp;
db_envParam* _db_envParam;
db_envMsg* _db_envMsg;
db_envAttr* _db_envAttr;
db_envPlugin* _db_envPlugin;
};
@ -243,6 +279,9 @@ class envDatabase : public database {
public:
void write_envOp(db_envOp* data);
void write_envParam(db_envParam* data);
void write_envMsg(db_envMsg* data);
void write_envAttr(db_envAttr* data);
void write_envPlugin(db_envPlugin* data);
protected:
BOOL init();

View File

@ -54,7 +54,14 @@ void IterateParameter(CKParameterManager* parameterManager, envDatabase* db, dbE
helper->_db_envParam->func_Copy = desc->CopyFunction;
helper->_db_envParam->func_String = desc->StringFunction;
helper->_db_envParam->func_UICreator = desc->UICreatorFunction;
helper->_db_envParam->creator_plugin_id = desc->CreatorDll != NULL ? desc->CreatorDll->m_PluginDllIndex : -1;
CKPluginEntry* plgEntry = desc->CreatorDll;
if (plgEntry != NULL) {
helper->_db_envParam->creator_dll_index = plgEntry->m_PluginDllIndex;
helper->_db_envParam->creator_plugin_index = plgEntry->m_PositionInDll;
} else {
helper->_db_envParam->creator_dll_index =-1;
helper->_db_envParam->creator_plugin_index =-1;
}
helper->_db_envParam->dw_param = desc->dwParam;
helper->_db_envParam->dw_flags = desc->dwFlags;
helper->_db_envParam->cid = desc->Cid;
@ -63,3 +70,55 @@ void IterateParameter(CKParameterManager* parameterManager, envDatabase* db, dbE
db->write_envParam(helper->_db_envParam);
}
}
void IterateMessage(CKMessageManager* msgManager, envDatabase* db, dbEnvDataStructHelper* helper) {
int count = msgManager->GetMessageTypeCount();
for (int i = 0; i < count; i++) {
helper->_db_envMsg->index = i;
strcpy(helper->_db_envMsg->name, msgManager->GetMessageTypeName(i));
db->write_envMsg(helper->_db_envMsg);
}
}
void IterateAttribute(CKAttributeManager* attrManager, envDatabase* db, dbEnvDataStructHelper* helper) {
int count = attrManager->GetAttributeCount();
for (int i = 0; i < count; i++) {
helper->_db_envAttr->index = i;
strcpy(helper->_db_envAttr->name, attrManager->GetAttributeNameByType(i));
helper->_db_envAttr->category_index = attrManager->GetAttributeCategoryIndex(i);
strcpy(helper->_db_envAttr->category_name, attrManager->GetAttributeCategory(i) != NULL ? attrManager->GetAttributeCategory(i) : "");
helper->_db_envAttr->flags = attrManager->GetAttributeFlags(i);
helper->_db_envAttr->param_index = attrManager->GetAttributeParameterType(i);
helper->_db_envAttr->compatible_classid = attrManager->GetAttributeCompatibleClassId(i);
strcpy(helper->_db_envAttr->default_value, attrManager->GetAttributeDefaultValue(i) != NULL ? attrManager->GetAttributeDefaultValue(i) : "");
db->write_envAttr(helper->_db_envAttr);
}
}
void IteratePlugin(CKPluginManager* plgManager, envDatabase* db, dbEnvDataStructHelper* helper) {
for (int i = 0; i <= 7; i++) {
int catCount = plgManager->GetPluginCount(i);
strcpy(helper->_db_envPlugin->category, plgManager->GetCategoryName(i));
for (int j = 0; j < catCount; j++) {
CKPluginEntry* plgEntry = plgManager->GetPluginInfo(i, j);
helper->_db_envPlugin->dll_index = plgEntry->m_PluginDllIndex;
strcpy(helper->_db_envPlugin->dll_name, plgManager->GetPluginDllInfo(plgEntry->m_PluginDllIndex)->m_DllFileName.CStr());
helper->_db_envPlugin->plugin_index = plgEntry->m_PositionInDll;
helper->_db_envPlugin->active = plgEntry->m_Active;
helper->_db_envPlugin->needed_by_file = plgEntry->m_NeededByFile;
CKPluginInfo* plgInfo = &(plgEntry->m_PluginInfo);
cp_guid(helper->_db_envPlugin->guid, plgInfo->m_GUID);
strcpy(helper->_db_envPlugin->desc, plgInfo->m_Description.CStr());
strcpy(helper->_db_envPlugin->author, plgInfo->m_Author.CStr());
strcpy(helper->_db_envPlugin->summary, plgInfo->m_Summary.CStr());
helper->_db_envPlugin->version = plgInfo->m_Version;
helper->_db_envPlugin->func_init = plgInfo->m_InitInstanceFct;
helper->_db_envPlugin->func_exit = plgInfo->m_ExitInstanceFct;
db->write_envPlugin(helper->_db_envPlugin);
}
}
}

View File

@ -8,5 +8,8 @@
void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper);
void IterateParameter(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper);
void IterateMessage(CKMessageManager* msgManager, envDatabase* db, dbEnvDataStructHelper* helper);
void IterateAttribute(CKAttributeManager* attrManager, envDatabase* db, dbEnvDataStructHelper* helper);
void IteratePlugin(CKPluginManager* plgManager, envDatabase* db, dbEnvDataStructHelper* helper);
#endif

View File

@ -115,6 +115,9 @@ void PluginMenuCallback(int commandID) {
//iterate parameter operation/param
IterateParameterOperation(ctx->GetParameterManager(), _db, _helper);
IterateParameter(ctx->GetParameterManager(), _db, _helper);
IterateMessage(ctx->GetMessageManager(), _db, _helper);
IterateAttribute(ctx->GetAttributeManager(), _db, _helper);
IteratePlugin(CKGetPluginManager(), _db, _helper);
//release all
_helper->dispose();

View File

@ -0,0 +1,7 @@
import locale
database_encoding = locale.getpreferredencoding()
export_db = "export.db"
decorated_db = "decorate.db"
env_db = "env.db"
force_regenerate = False

View File

@ -1,23 +1,25 @@
import sqlite3
import DecoratorConstValue as dcv
import json
import locale
import CustomConfig
def run():
exportDb = sqlite3.connect('export.db')
exportDb.text_factory = lambda x: x.decode(locale.getpreferredencoding())
decorateDb = sqlite3.connect('decorate.db')
exportDb = sqlite3.connect(CustomConfig.export_db)
exportDb.text_factory = lambda x: x.decode(CustomConfig.database_encoding)
decorateDb = sqlite3.connect(CustomConfig.decorated_db)
# init table
print('Init decorate.dll')
print('Init decorate database...')
initDecorateDb(decorateDb)
decorateDb.commit()
# decorate graph
print('Generating gragh list...')
graphList = []
decorateGraph(exportDb, decorateDb, graphList)
# decorate each graph
print('Generating graph...')
currentGraphBlockCell = {}
for i in graphList:
currentGraphBlockCell.clear()
@ -26,6 +28,7 @@ def run():
buildLink(exportDb, decorateDb, i, currentGraphBlockCell, graphPIO)
# export information
print('Generating info...')
buildInfo(exportDb, decorateDb)
# give up all change of eexport.db (because no change)

View File

@ -1,3 +1,5 @@
import CustomConfig
from flask import Flask
from flask import g
from flask import render_template
@ -17,7 +19,7 @@ app = Flask(__name__)
def get_db():
db = getattr(g, '_database', None)
if db is None:
db = g._database = sqlite3.connect('decorate.db')
db = g._database = sqlite3.connect(CustomConfig.decorated_db)
return db
@app.teardown_appcontext
@ -47,7 +49,7 @@ def helpHandle():
@app.route('/about', methods=['GET'])
def aboutHandle():
return render_template("about.html")
return render_template("about.html", static_icon = url_for('static', filename='icon.png'))
@app.route('/index', methods=['GET'])
def indexHandle():

View File

@ -1,15 +1,42 @@
import CustomConfig
import DecoratorCore
import ServerCore
import os
import sys
import getopt
# debug use
# os.remove('decorate.db')
try:
opts, args = getopt.getopt(sys.argv, "hi:o:e:f")
except getopt.GetoptError:
print('Wrong arguments!')
print('test.py -i <export.db> -o <decorated.db> -e <env.db> -f')
sys.exit(1)
for opt, arg in opts:
if opt == '-h':
print('test.py -i <export.db> -o <decorated.db> -e <env.db> -f')
sys.exit(0)
elif opt == '-i':
CustomConfig.export_db = arg
elif opt == '-o':
CustomConfig.decorated_db = arg
elif opt == '-e':
CustomConfig.env_db = arg
elif opt == '-f':
CustomConfig.force_regenerate = True
# process -f
if (CustomConfig.force_regenerate):
if os.path.isfile(CustomConfig.decorated_db):
os.remove(CustomConfig.decorated_db)
print('Super Script View')
if not os.path.isfile("decorate.db"):
if not os.path.isfile(CustomConfig.env_db):
print('No environment database. Fail to generate. Exit app.')
sys.exit(1)
if not os.path.isfile(CustomConfig.decorated_db):
print('No decorated database, generating it.')
if not os.path.isfile('export.db'):
if not os.path.isfile(CustomConfig.export_db):
print('No export.db. Fail to generate. Exit app.')
sys.exit(1)

View File

@ -21,6 +21,9 @@
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<ItemGroup>
<Compile Include="CustomConfig.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="DecoratorConstValue.py">
<SubType>Code</SubType>
</Compile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -7,10 +7,10 @@
</head>
<body>
<h1>Super Script Materializer</h1>
<h1><img src="{{ static_icon }}" width="64" height="64" style="margin: 0 10px 0 10px;"/>Super Script Materializer</h1>
<p>There are no secret script behind Virtools. Super Script Materializer will destroy all locks and show you the real code.<br />
But Super Script Materializer only show you code. It couldn't analyse the result and touch author's heart and intention. This is your work.<br />
This also is the meaning of this app's icon.</p>
So, let we crack all scripts and destroy close-source illusion.</p>
<br />
<p><a href="https://github.com/yyc12345/SuperScriptMaterializer">SuperScriptMaterializer</a>. All codes are under GPLv3.<br />
Web interface is powered by <a href="https://github.com/pallets/flask">Flask</a>.<br />