* gc类lua调用修正
This commit is contained in:
+22
-6
@@ -22,20 +22,36 @@ namespace dl
|
||||
lua_close(L);
|
||||
}
|
||||
|
||||
bool LuaScript::DoFile(std::string_view path_name)
|
||||
bool LuaScript::DoString(std::string_view str)
|
||||
{
|
||||
Buffer buf = File::GetBuffer(path_name);
|
||||
|
||||
int ret = luaL_loadbuffer(L, (const char*)buf.data(), buf.size(), path_name.data());
|
||||
int ret = luaL_loadstring(L, str.data());
|
||||
if (ret)
|
||||
{
|
||||
log_err("lua 执行(加载)失败:[{}]:{}", path_name, lua_tostring(L, -1));
|
||||
log_err("lua 解析失败[{}]:\n{}", lua_tostring(L, -1), str);
|
||||
return false;
|
||||
}
|
||||
ret = lua_pcall(L, 0, 0, 0);
|
||||
if (ret)
|
||||
{
|
||||
log_err("lua 执行失败:[{}]:{}", path_name, lua_tostring(L, -1));
|
||||
log_err("lua 执行失败[{}]:\n{}", lua_tostring(L, -1), str);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LuaScript::DoFile(std::string_view path_name)
|
||||
{
|
||||
Buffer buf = File::GetBuffer(path_name);
|
||||
int ret = luaL_loadbuffer(L, (const char*)buf.data(), buf.size(), path_name.data());
|
||||
if (ret)
|
||||
{
|
||||
log_err("lua 解析(加载)失败[{}]:{}", path_name, lua_tostring(L, -1));
|
||||
return false;
|
||||
}
|
||||
ret = lua_pcall(L, 0, 0, 0);
|
||||
if (ret)
|
||||
{
|
||||
log_err("lua 执行失败[{}]:{}", path_name, lua_tostring(L, -1));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user