LuaState::LuaState(bool initStandardLibrary, bool multithreaded) { m_state = lua_open(); m_ownState = true; lua_setusergcfunction(m_state, LuaPlusGCFunction); SetupStateEx(); GetHeadObject()->m_prev = NULL; GetHeadObject()->m_next = GetTailObject(); GetTailObject()->m_prev = GetHeadObject(); GetTailObject()->m_next = NULL; #ifdef LUA_MTSUPPORT if (multithreaded) { #ifdef WIN32 // What about clean up? CRITICAL_SECTION* cs = new CRITICAL_SECTION; ::InitializeCriticalSection(cs); lua_setlockfunctions(m_state, LSLock, LSUnlock, cs); #endif WIN32 } #endif LUA_MTSUPPORT Init(initStandardLibrary); }
void LuaState_UserStateOpen(lua_State* L) { #if LUAPLUS_EXTENSIONS lua_setusergcfunction(L, LuaPlusGCFunction); #endif /* LUAPLUS_EXTENSIONS */ lua_atpanic(L, FatalError); }
LuaState::LuaState(bool initStandardLibrary, bool multithreaded) { m_state = lua_newstate(luaHelper_defaultAlloc, luaHelper_ud); m_ownState = true; lua_setusergcfunction(m_state, LuaPlusGCFunction); //jj luaX_setnewthreadhandler( newthread_handler ); //jj luaX_setfreethreadhandler( freethread_handler ); SetupStateEx(); GetHeadObject()->m_prev = NULL; GetHeadObject()->m_next = (LuaObject*)GetTailObject(); GetTailObject()->m_prev = (LuaObject*)GetHeadObject(); GetTailObject()->m_next = NULL; #ifdef LUA_MTSUPPORT if (multithreaded) { /*#ifdef WIN32 // What about clean up? CRITICAL_SECTION* cs = new CRITICAL_SECTION; ::InitializeCriticalSection(cs); lua_setlockfunctions(m_state, LSLock, LSUnlock, cs); #endif // WIN32*/ } #endif // LUA_MTSUPPORT // luastateopen_thread(m_state); Init(initStandardLibrary); }