更新:添加doString方法及对应的单元测试

This commit is contained in:
2026-04-05 08:19:20 +08:00
parent 14526b8dc2
commit 8f1d409cf5
10 changed files with 337 additions and 146 deletions

View File

@ -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()