This commit is contained in:
lenheart
2024-09-15 13:08:42 +08:00
parent 977fdf7ccf
commit b90bde86e0
26 changed files with 948 additions and 210 deletions

View File

@@ -187,8 +187,7 @@ static SQInteger SqReloadScript(HSQUIRRELVM v)
void InitSquirrel()
{
std::lock_guard<std::recursive_mutex>
lock(SqMtx);
// std::lock_guard<std::recursive_mutex> lock(SqMtx);
v = sq_open(4096); // 创建虚拟机其栈的初始大小为1024
@@ -228,17 +227,6 @@ void InitSquirrel()
ReqSquirrelScript(v);
}
// 执行虚拟机Main函数
SQInteger top = sq_gettop(v); // saves the stack size before the call
sq_pushroottable(v); // pushes the global table
sq_pushstring(v, _SC("main"), -1);
if (SQ_SUCCEEDED(sq_get(v, -2)))
{ // gets the field 'foo' from the global table
sq_pushroottable(v); // push the 'this' (in this case is the global table)
sq_call(v, 1, SQFalse, SQTrue); // calls the function
}
sq_settop(v, top); // restores the original stack size
sq_pushroottable(v);
sq_pushstring(v, "sq_ReloadScript", -1);
sq_newclosure(v, SqReloadScript, 0); // create a new function