当前位置: 首页>>代码示例>>C++>>正文


C++ MOAILuaState::AbsIndex方法代码示例

本文整理汇总了C++中MOAILuaState::AbsIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ MOAILuaState::AbsIndex方法的具体用法?C++ MOAILuaState::AbsIndex怎么用?C++ MOAILuaState::AbsIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MOAILuaState的用法示例。


在下文中一共展示了MOAILuaState::AbsIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetInterfaceTable

//----------------------------------------------------------------//
void MOAILuaObject::SetInterfaceTable ( MOAILuaState& state, int idx ) {

	idx = state.AbsIndex ( idx );

	this->PushMemberTable ( state );
	
	// set the interface table as the member table's metatable
	lua_pushvalue ( state, idx );
	lua_setmetatable ( state, -2 );
	
	lua_pop ( state, 1 );
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例2: Ref

//----------------------------------------------------------------//
int MOAILuaRefTable::Ref ( MOAILuaState& state, int idx ) {

	assert ( this->mTableID != LUA_NOREF );

	idx = state.AbsIndex ( idx );
	int refID = this->ReserveRefID ();

	lua_rawgeti ( state, LUA_REGISTRYINDEX, this->mTableID );
	lua_pushnumber ( state, refID );
	lua_pushvalue ( state, idx );
	lua_settable ( state, -3 );
	
	lua_pop ( state, 1 );
	
	return refID;
}
开发者ID:AzureRodrigo,项目名称:moai-dev,代码行数:17,代码来源:MOAILuaRef.cpp

示例3: SetLocal

//----------------------------------------------------------------//
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 );
}
开发者ID:kengonakajima,项目名称:moai-dev,代码行数:19,代码来源:MOAILuaObject.cpp

示例4: SetMemberTable

//----------------------------------------------------------------//
void MOAILuaObject::SetMemberTable ( MOAILuaState& state, int idx ) {
	UNUSED ( state );
	UNUSED ( idx );

	// TODO: what if object is a singleton?
	assert ( !this->GetLuaClass ()->IsSingleton ()); // TODO: should actually set the member table, not just crash

	idx = state.AbsIndex ( idx );
	
	this->PushLuaUserdata ( state ); // userdata
	lua_getmetatable ( state, - 1 ); // ref table
	lua_getmetatable ( state, - 1 ); // member table
	lua_getmetatable ( state, - 1 ); // interface table

	lua_pushvalue ( state, idx );
	lua_replace ( state, -3 );
	
	this->MakeLuaBinding ( state );
	state.Pop ( 1 );
}
开发者ID:,项目名称:,代码行数:21,代码来源:

示例5: _dumpType

	//----------------------------------------------------------------//
	static void _dumpType ( lua_State* L, int idx, const char *name, bool verbose, TableSet& foundTables ) {

		MOAILuaState state ( L );

		const char *format = DUMP_FORMAT;

		idx = state.AbsIndex( idx );
		StkId tvalue = state->base + idx - 1;

		switch ( lua_type ( state, idx )) {

			case LUA_TBOOLEAN:

				ZLLog::Print ( format, tvalue, "bool", name );
				ZLLog::Print ( " = %s", lua_toboolean ( state, idx ) ? "true" : "false" );
				break;

			case LUA_TFUNCTION: {

				const char *funcType = iscfunction ( tvalue ) ? "C function" : "Lua function";

				ZLLog::Print ( format, clvalue ( tvalue ), funcType, name );
				break;
			}

			case LUA_TLIGHTUSERDATA:

				ZLLog::Print ( format, pvalue ( tvalue ), "pointer", name );
				break;

			case LUA_TNIL:

				ZLLog::Print ( format, tvalue, "nil", name );
				break;

			case LUA_TNONE:
				 // Intentionally do nothing--not even the line break.
				return;

			case LUA_TNUMBER:

				ZLLog::Print ( format, tvalue, "number", name );
				ZLLog::Print ( " = %f", lua_tonumber ( state, idx ));
				break;

			case LUA_TSTRING:

				ZLLog::Print ( format, rawtsvalue( tvalue ), "string", name );
				ZLLog::Print ( " = \"%s\"", lua_tostring ( state, idx ));
				break;

			case LUA_TTABLE: {

				struct Table* htable = hvalue( tvalue );

				if ( foundTables.contains ( htable )) {

					ZLLog::Print ( DUMP_FORMAT " (see above)", htable, "table", name );
					break;
				}
				else {

					foundTables.insert ( htable );

					ZLLog::Print ( format, htable, "table", name );

					if ( verbose ) {

						ZLLog::Print ( "\n" );
						lua_pushnil ( state );

						while ( lua_next ( state, idx ) ) {

							STLString elementName( name );
							elementName.append ( "." );
							elementName.append ( lua_tostring ( state, -2 ));
							_dumpType ( state, -1, elementName.c_str (), verbose, foundTables );
							lua_pop ( state, 1 );
						}
					}
				}
			}
				return; // suppress newline

			case LUA_TTHREAD:

				ZLLog::Print ( format, thvalue( tvalue ), "thread", name );
				break;

			case LUA_TUSERDATA:

				if ( lua_islightuserdata ( state, idx ) ) {
					
					ZLLog::Print ( format, lua_topointer ( state, idx ) , "light userdata", name );
				}
				else {

					ZLLog::Print ( format, lua_topointer( state, idx ), "userdata", name );

//.........这里部分代码省略.........
开发者ID:flimshaw,项目名称:moai-dev,代码行数:101,代码来源:MOAILuaRuntime.cpp


注:本文中的MOAILuaState::AbsIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。