mirror of
https://gitcode.com/JianFeeeee/LuaCangjia_api.git
synced 2026-09-21 01:18:10 +00:00
更新:添加doString方法及对应的单元测试
This commit is contained in:
@ -209,6 +209,37 @@ int Lua_runner::run(const char *path,const char *arg)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int Lua_runner::dostring(const char *target)
|
||||
{
|
||||
if(target == NULL)
|
||||
{
|
||||
errno = NAPI_ERROR_FUNCS;
|
||||
return -1;
|
||||
}
|
||||
if(luaL_dostring(this->L,target) != LUA_OK)
|
||||
{
|
||||
errno = NAPI_ERROR_FUNCS;
|
||||
this->reslt = lua_tostring(this->L,-1);
|
||||
lua_pop(L,1);//错误出栈
|
||||
return -1;
|
||||
}
|
||||
if(lua_gettop(this->L) == 0) {
|
||||
errno = NAPI_SCRIPT_BAD_RET;
|
||||
this->reslt = "";
|
||||
return -1;
|
||||
}
|
||||
if(lua_isstring(this->L,-1)){
|
||||
this->reslt = lua_tostring(this->L,-1);
|
||||
lua_pop(L,1);
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
errno = NAPI_SCRIPT_BAD_RET;
|
||||
lua_pop(L,1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
//TODO 实现函数调用 achieve func call via file
|
||||
/*
|
||||
int Lua_runner::callfunction()
|
||||
|
||||
Reference in New Issue
Block a user