Added and Fixed.

This commit is contained in:
Saturneic 2019-02-02 20:06:49 +08:00
parent 42943e292a
commit e0733eae26
4 changed files with 74 additions and 5 deletions

View File

@ -21,11 +21,16 @@
//计算模块入口函数类型 //计算模块入口函数类型
typedef int(*PCSFUNC)(void); typedef int(*PCSFUNC)(void);
struct farg_info {
string type;
int size = 1;
};
//计算模块类 //计算模块类
class CPart{ class CPart{
public: public:
// 参数格式信息列表 // 参数格式信息列表
vector<int> fargs_in, fargs_out; vector<farg_info> fargs_in, fargs_out;
// 输入参数与输出参数缓冲区 // 输入参数与输出参数缓冲区
vector<void *> args_in, args_out; vector<void *> args_in, args_out;
// 计算过程入口与出口管理类 // 计算过程入口与出口管理类
@ -45,12 +50,14 @@ public:
// 源文件名 // 源文件名
string src_name; string src_name;
// 唯一的构造函数 // 构造函数
CPart(string src_path,string lib_path,string src_name,string name,bool ffresh = true); CPart(string src_path,string lib_path,string src_name,string name,bool ffresh = true);
// 根据数据库信息构造
CPart(string func_name, sqlite3 *psql);
// 析构函数 // 析构函数
~CPart(); ~CPart();
// 设置输入输出参数格式信息列表 // 设置输入输出参数格式信息列表
void setArgsType(vector<int> fargs_in, vector<int> fargs_out); void setArgsType(vector<farg_info> fargs_in, vector<farg_info> fargs_out);
// 编译源文件 // 编译源文件
int BuildSo(void); int BuildSo(void);
// 获得动态链接库操作柄 // 获得动态链接库操作柄

View File

@ -74,6 +74,51 @@ CPart::CPart(string t_srcpath,string t_libpath,string t_srcname,string t_name,bo
} }
CPart::CPart(string func_name, sqlite3 *psql){
// 获得动态链接库名
string sql_quote = "SELECT libfiles.name FROM functions INNER JOIN libfiles ON libfiles.id = functions.libfile_id WHERE functions.name = ?1;";
sqlite3_stmt *psqlsmt;
const char *pzTail;
sqlite3_prepare(psql, sql_quote.data(), -1, &psqlsmt, &pzTail);
sqlite3_bind_text(psqlsmt, 1, func_name.data(), -1, SQLITE_TRANSIENT);
sqlite3_step(psqlsmt);
lib_name = (char *)sqlite3_column_text(psqlsmt, 0);
sqlite3_finalize(psqlsmt);
// 获得工程信息
sql_quote = "SELECT * FROM projfile;";
sqlite3_prepare(psql, sql_quote.data(), -1, &psqlsmt, &pzTail);
sqlite3_step(psqlsmt);
lib_path = (char *)sqlite3_column_text(psqlsmt, 3);
name = (char *)sqlite3_column_text(psqlsmt, 0);
sqlite3_finalize(psqlsmt);
// 获得相关操作柄
GetSoHandle();
// 记录形式参数
sql_quote = "SELECT * FROM fargs_"+func_name+" WHERE io = ?1;";
sqlite3_prepare(psql, sql_quote.data(), -1, &psqlsmt, &pzTail);
sqlite3_bind_int(psqlsmt, 1, 0);
int rtn = sqlite3_step(psqlsmt);
if(rtn != SQLITE_DONE)
do{
farg_info nfi;
nfi.type =(char *) sqlite3_column_text(psqlsmt, 1);
nfi.size =sqlite3_column_int(psqlsmt, 5);
fargs_in.push_back(nfi);
}while (sqlite3_step(psqlsmt) != SQLITE_DONE);
sqlite3_reset(psqlsmt);
sqlite3_clear_bindings(psqlsmt);
sqlite3_bind_int(psqlsmt, 1, 1);
if(rtn != SQLITE_DONE)
do{
farg_info nfi;
nfi.type =(char *) sqlite3_column_text(psqlsmt, 1);
nfi.size =sqlite3_column_int(psqlsmt, 5);
fargs_out.push_back(nfi);
}while (sqlite3_step(psqlsmt) != SQLITE_DONE);
sqlite3_finalize(psqlsmt);
}
/** /**
@ -125,7 +170,7 @@ CPart::~CPart(){
@param fargs_in @param fargs_in
@param fargs_out @param fargs_out
*/ */
void CPart::setArgsType(vector<int> fargs_in, vector<int> fargs_out){ void CPart::setArgsType(vector<farg_info> fargs_in, vector<farg_info> fargs_out){
this->fargs_in = fargs_in; this->fargs_in = fargs_in;
this->fargs_out = fargs_out; this->fargs_out = fargs_out;
} }

View File

@ -1173,10 +1173,26 @@ void Proj::UpdateProcess(void){
{"content","?3"} {"content","?3"}
}); });
for(auto lib : lib_index){ for(auto lib : lib_index){
sql_quote = "SELECT count(*) FROM libfiles WHERE name = ?1";
sqlite3_prepare(psql, sql_quote.data(), -1, &psqlsmt, &pzTail);
sqlite3_bind_text(psqlsmt, 1, lib.second.data(), -1, SQLITE_TRANSIENT);
int rtn = sqlite3_step(psqlsmt);
if(rtn == SQLITE_DONE || rtn == SQLITE_ROW){
int if_find = sqlite3_column_int(psqlsmt, 0);
sqlite3_finalize(psqlsmt);
if(if_find) continue;
}
else{
const char *error = sqlite3_errmsg(psql);
int errorcode = sqlite3_extended_errcode(psql);
printf("\033[31mSQL Error: [%d]%s\n\033[0m",errorcode,error);
throw error;
}
sqlite3_bind_int(psqlsmt2, 1, ++last_id); sqlite3_bind_int(psqlsmt2, 1, ++last_id);
sqlite3_bind_text(psqlsmt2, 2, lib.second.data(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(psqlsmt2, 2, lib.second.data(), -1, SQLITE_TRANSIENT);
// 添加动态链接库 // 添加动态链接库
int rtn = sqlite3_step(psqlsmt2); rtn = sqlite3_step(psqlsmt2);
if(rtn == SQLITE_DONE || rtn == SQLITE_ROW){ if(rtn == SQLITE_DONE || rtn == SQLITE_ROW){
} }

View File

@ -87,6 +87,7 @@ int update(string instruct, vector<string> &configs, vector<string> &lconfigs, v
nproj.UpdateProcess(); nproj.UpdateProcess();
} catch (const char *err_info) { } catch (const char *err_info) {
printf("\033[31mError: %s\n\033[0m",err_info); printf("\033[31mError: %s\n\033[0m",err_info);
return -1;
} }
printf("\033[32mSucceed.\n\033[0m"); printf("\033[32mSucceed.\n\033[0m");
return 0; return 0;