//----------------------------------------------------------------// void MOAIEnvironment::SetValue ( cc8* key ) { MOAIScopedLuaState state = MOAILuaRuntime::Get ().State (); this->PushLuaClassTable ( state ); state.ClearField ( -1, key ); state.Pop ( 1 ); }
//----------------------------------------------------------------// MOAILuaObject::~MOAILuaObject () { if ( MOAILuaRuntime::IsValid ()) { MOAILuaRuntime::Get ().DeregisterObject ( *this ); // TODO: change from both patrick's fork and the community branch; double check if (( !this->mCollected ) && this->mUserdata ) { MOAIScopedLuaState state = MOAILuaRuntime::Get ().State (); // clear out the gc this->mUserdata.PushRef ( state ); u32 top = state.GetTop (); bool isUserdata = state.IsType ( top, LUA_TUSERDATA ); MOAILuaRuntime::Get ().PurgeUserdata ( state, -1 ); top = state.GetTop (); isUserdata = state.IsType ( top, LUA_TUSERDATA ); if ( lua_getmetatable ( state, -1 )) { lua_pushnil ( state ); lua_setfield ( state, -2, "__gc" ); state.Pop ( 1 ); } top = state.GetTop (); isUserdata = state.IsType ( top, LUA_TUSERDATA ); // and the ref table lua_pushnil ( state ); lua_setmetatable ( state, -2 ); } } }