示例#1
0
//----------------------------------------------------------------//
void MOAIEnvironment::SetValue ( lua_State* L ) {

	MOAILuaState state ( L );

	int top = state.GetTop ();

	this->PushLuaClassTable ( state );
		
	state.CopyToTop ( -3 ); // key
	state.CopyToTop ( -3 ); // value
	
	lua_settable ( state, -3 );
	state.Pop ( 1 );
	
	if ( this->PushListener ( EVENT_VALUE_CHANGED, state )) {
	
		state.CopyToTop ( -3 ); // key
		state.CopyToTop ( -3 ); // value
		
		state.DebugCall ( 2, 0 );
	}
	
	top = state.GetTop ();
}
示例#2
0
//----------------------------------------------------------------//
void MOAILuaObject::SetLocal ( MOAILuaState& state, int idx, MOAILuaLocal& ref ) {

	idx = state.AbsIndex ( idx );

	assert ( this->mInstanceTable );

	this->mInstanceTable.PushRef ( state );
	
	if ( ref ) {
		luaL_unref ( state, -1, ref.mRef );
		ref.mRef = LUA_NOREF;
	}
	
	state.CopyToTop ( idx );
	ref.mRef = luaL_ref ( state, -2 );
	
	lua_pop ( state, 1 );
}