• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ USLuaState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中USLuaState的典型用法代码示例。如果您正苦于以下问题:C++ USLuaState类的具体用法?C++ USLuaState怎么用?C++ USLuaState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: Affirm

//----------------------------------------------------------------//
uintptr USLuaSerializer::Affirm ( USLuaState& state, int idx ) {

	// if we're an object, affirm as such...
	if ( state.IsType ( idx, LUA_TUSERDATA )) {
		return this->Affirm ( state.GetLuaObject < USLuaObject >( -1 ));
	}

	// bail if we're not a table
	if ( !state.IsType ( idx, LUA_TTABLE )) return 0;

	// get the table's address
	uintptr tableID = ( uintptr )lua_topointer ( state, idx );
	
	// bail if the table's already been added
	if ( this->mTableMap.contains ( tableID )) return tableID;

	// add the ref now to avoid cycles
	this->mTableMap [ tableID ].SetStrongRef ( state, idx );

	// follow the table's refs to make sure everything gets added
	u32 itr = state.PushTableItr ( idx );
	while ( state.TableItrNext ( itr )) {
		this->Affirm ( state, -1 );
	}
	
	return tableID;
}
开发者ID:,项目名称:,代码行数:28,代码来源:


示例2: WriteTableInitializer

//----------------------------------------------------------------//
u32 USLuaSerializer::WriteTableInitializer ( USStream& stream, USLuaState& state, int idx, cc8* prefix ) {

	u32 count = 0;
	u32 itr = state.PushTableItr ( idx );
	while ( state.TableItrNext ( itr )) {
		
		switch ( lua_type ( state, -2 )) {
		
			case LUA_TSTRING: {
				stream.Print ( "\t%s [ \"%s\" ] = ", prefix, lua_tostring ( state, -2 ));
				break;
			}
			case LUA_TNUMBER: {
				stream.Print ( "\t%s [ %s ]\t= ", prefix, lua_tostring ( state, -2 ));
				break;
			}
		};
		
		switch ( lua_type ( state, -1 )) {
			
			case LUA_TBOOLEAN: {
				int value = lua_toboolean ( state, -1 );
				cc8* str = ( value ) ? "true": "false";
				stream.Print ( "%s\n", str );
				break;
			}
			case LUA_TTABLE: {
				uintptr tableID = ( uintptr )lua_topointer ( state, -1 );
				if ( this->mTableMap.contains ( tableID )) {
					stream.Print ( "objects [ 0x%08X ]\n", tableID );
				}
				break;
			}
			case LUA_TSTRING: {
				STLString str = _escapeString ( lua_tostring ( state, -1 ));
				stream.Print ( "\"%s\"\n", str.c_str ());
				break;
			}
			case LUA_TNUMBER: {
				stream.Print ( "%s\n", lua_tostring ( state, -1 ));
				break;
			}
			case LUA_TUSERDATA: {
				USLuaObject* object = state.GetLuaObject < USLuaObject >( -1 );
				u32 instanceID = this->GetID ( object );
				stream.Print ( "objects [ 0x%08X ]\n", instanceID );
				break;
			}
			case LUA_TLIGHTUSERDATA: {
				stream.Print ( "%p,\n", lua_touserdata ( state, -1 ));
				break;
			}
		};
		
		++count;
	}
	
	return count;
}
开发者ID:,项目名称:,代码行数:60,代码来源:


示例3: RegisterLuaClass

//----------------------------------------------------------------//
void MOAIVertexFormat::RegisterLuaClass ( USLuaState& state ) {
	
	state.SetField ( -1, "GL_BYTE", ( u32 )GL_BYTE );
	//state.SetField ( -1, "GL_FIXED", ( u32 )GL_FIXED );
	state.SetField ( -1, "GL_FLOAT", ( u32 )GL_FLOAT );
	state.SetField ( -1, "GL_SHORT", ( u32 )GL_SHORT );
	state.SetField ( -1, "GL_UNSIGNED_BYTE", ( u32 )GL_UNSIGNED_BYTE );
	state.SetField ( -1, "GL_UNSIGNED_SHORT", ( u32 )GL_UNSIGNED_SHORT );
}
开发者ID:,项目名称:,代码行数:10,代码来源:


示例4: state

/**	@name	areaForRect
	@text	Returns the area for the specified rectangle.

	@in		number x1
	@in		number y1
	@in		number x2
	@in		number y2
	@out	number area			The calculated area.
*/
int MOAICpShape::_areaForRect ( lua_State* L ) {
	USLuaState state ( L );
	if ( !state.CheckParams ( 1, "NNNN" )) return 0;

	USMetaRect < cpFloat > rect = state.GetRect < cpFloat >( 1 );
	rect.Bless ();
	
	lua_pushnumber ( L, rect.Area ());
	return 1;
}
开发者ID:,项目名称:,代码行数:19,代码来源:


示例5: passing

/**	@name	setFrameSize
	@text	Sets the amount of time it takes for one frame to pass.  This in effect can be used to set the FPS limit of the application by passing (1 / FPS).

	@in		number size			The frame size (how long in seconds it takes for one frame to be rendered).
	@out	nil
*/
int MOAISim::_setFrameSize ( lua_State* L ) {

	USLuaState state ( L );
	if ( !state.CheckParams ( 1, "N" )) return 0;
	
	MOAISim& device = MOAISim::Get ();
	device.mStep = state.GetValue < double >( 1, device.mStep );
	
	return 0;
}
开发者ID:mobilehub,项目名称:moai-beta,代码行数:16,代码来源:MOAISim.cpp


示例6: state

/**	@name	getScale
	@text	Returns the default size of this font for use with the MOAITextbox:setTextSize function.

	@in		MOAIFont self
	@out	number size				The default point size of the font.
*/
int MOAIFont::_getScale ( lua_State* L ) {

	USLuaState state ( L );
	if ( !state.CheckParams ( 1, "U" )) return 0;
	
	MOAIFont* self = state.GetLuaObject < MOAIFont >( 1 );
	if ( !self ) return 0;
	
	lua_pushnumber ( state, self->GetScale ());
	return 1;
}
开发者ID:mobilehub,项目名称:moai-beta,代码行数:17,代码来源:MOAIFont.cpp


示例7: state

/**	@name	timeToFrames
	@text	Converts the number of time passed in seconds to frames.

	@in		number time			The number of seconds.
	@out	number frames		The equivilant number of frames for the specified number of seconds.
*/
int MOAISim::_timeToFrames ( lua_State* L ) {

	USLuaState state ( L );
	if ( !state.CheckParams ( 1, "N" )) return 0;
	
	float time = state.GetValue < float >( 1, 0.0f );
	
	MOAISim& device = MOAISim::Get ();
	lua_pushnumber ( state, time / device.mStep );
	
	return 0;
}
开发者ID:mobilehub,项目名称:moai-beta,代码行数:18,代码来源:MOAISim.cpp


示例8: components

/**	@name	areaForCircle
	@text	Returns the area for a polygon.
	
	@in		table vertices Array containg vertex coordinate components ( t[1] = x0, t[2] = y0, t[3] = x1, t[4] = y1... )
	@out	number area
*/ 
int MOAICpShape::_areaForPolygon ( lua_State* L ) {
	USLuaState state ( L );
	if ( !state.CheckParams ( 1, "T" )) return 0;

	cpVect verts [ MAX_POLY_VERTS ];
	int numVerts = MOAICpShape::LoadVerts ( state, 1, verts, MAX_POLY_VERTS );
			
	if ( numVerts && cpPolyValidate ( verts, numVerts )) {
		cpFloat area = cpAreaForPoly ( numVerts, verts );
		area = area < 0 ? -area : area;
		lua_pushnumber ( L, area );
		return 1;
	}
	return 0;
}
开发者ID:,项目名称:,代码行数:21,代码来源:


示例9: userdata

/**	@name	serializeToString
	@text	Serializes the specified table or userdata to a string.  Useful for sending data to a remote server.

	@in		MOAISerializer self
	@opt	table data				The table data to serialize.
	@opt	userdata data			The userdata (object) to serialize.  You must provide either a table or userdata, but not both.
	@out	string serialized		The serialized string.
*/
int MOAISerializer::_serializeToString ( lua_State* L ) {

	USLuaState state ( L );
	if ( !state.CheckParams ( 1, "U" )) return 0;
	if ( !( state.IsType ( 1, LUA_TTABLE ) || state.IsType ( 1, LUA_TUSERDATA ))) return 0;

	USLuaSerializer serializer;
	serializer.Affirm ( state, 1 );
	serializer.AddLuaReturn ( state, 1 );
	STLString result = serializer.SerializeToString ();

	lua_pushstring ( state, result );

	return 1;
}
开发者ID:mobilehub,项目名称:moai-beta,代码行数:23,代码来源:MOAISerializer.cpp


示例10: PushListenerAndSelf

//----------------------------------------------------------------//
bool MOAIEventSource::PushListenerAndSelf ( u32 eventID, USLuaState& state ) {

	if ( this->mListenerTable ) {
	
		this->mListenerTable.PushRef ( state );
		if ( state.GetFieldWithType ( -1, eventID, LUA_TFUNCTION )) {
			
			lua_replace ( state, -2 );
			this->PushLuaUserdata ( state );
			return true;
		}
		state.Pop ( 1 );
	}
	return false;
}
开发者ID:,项目名称:,代码行数:16,代码来源:


示例11:

//----------------------------------------------------------------//
void MOAIGfxQuad2D::RegisterLuaClass ( USLuaState& state ) {

	this->MOAIDeck2D::RegisterLuaClass ( state );
	
	state.SetField ( -1, "FILTER_POINT", ( u32 )GL_NEAREST );
	state.SetField ( -1, "FILTER_BILERP", ( u32 )GL_LINEAR );
}
开发者ID:mobilehub,项目名称:moai-beta,代码行数:8,代码来源:MOAIGfxQuad2D.cpp


示例12: SetRefField

//----------------------------------------------------------------//
void USLuaSerializer::SetRefField ( USLuaState& state, int idx, cc8* name, USLuaObject* object ) {

	if ( state.IsType ( idx, LUA_TTABLE )) {
		
		this->PushRef ( state, object );
		lua_setfield ( state, -2, name );
	}
}
开发者ID:,项目名称:,代码行数:9,代码来源:


示例13: size

/**	@name	setStyle
	@text	Sets the particulars of a given debug line style.
	
	@in		number styleID		See MOAIDebugLines class documentation for a list of styles.
	@opt	number size			Pen size (in pixels) for the style. Default value is 1.
	@opt	number r			Red component of line color. Default value is 1.
	@opt	number g			Green component of line color. Default value is 1.
	@opt	number b			Blue component of line color. Default value is 1.
	@opt	number a			Alpha component of line color. Default value is 1.
	@out	nil
*/
int MOAIDebugLines::_setStyle ( lua_State* L ) {
	
	USLuaState state ( L );
	if ( !state.CheckParams ( 1, "N" )) return 0;
	
	u32 styleID		= state.GetValue < u32 >( 1, 0 );
	u32 size		= state.GetValue < u32 >( 2, 1 );
	float r			= state.GetValue < float >( 3, 1.0f );
	float g			= state.GetValue < float >( 4, 1.0f );
	float b			= state.GetValue < float >( 5, 1.0f );
	float a			= state.GetValue < float >( 6, 1.0f );
	
	u32 color = USColor::PackRGBA ( r, g, b, a );
	
	MOAIDebugLines::Get ().SetStyle ( styleID, size, color );
	
	return 0;
}
开发者ID:,项目名称:,代码行数:29,代码来源:


示例14: AffirmListenerTable

//----------------------------------------------------------------//
void MOAIEventSource::AffirmListenerTable ( USLuaState& state ) {

	if ( !mListenerTable ) {
	
		lua_newtable ( state );
		this->mListenerTable.SetRef ( state, -1, false );
		state.Pop ( 1 );
	}
}
开发者ID:,项目名称:,代码行数:10,代码来源:


示例15: off

/**	@name	setClearColor
	@text	At the start of each frame the device will by default automatically render a background color.  Using this function you can set the background color that is drawn each frame.  If you specify no arguments to this function, then automatic redraw of the background color will be turned off (i.e. the previous render will be used as the background).

	@opt	number red			The red value of the color.
	@opt	number green		The green value of the color.
	@opt	number blue			The blue value of the color.
	@opt	number alpha		The alpha value of the color.
	@out	nil
*/
int MOAISim::_setClearColor ( lua_State* L ) {

	USLuaState state ( L );
	MOAISim& sim = MOAISim::Get ();
	
	if ( state.GetTop () == 0 ) {
		sim.mClearFlags &= ~GL_COLOR_BUFFER_BIT;
	}
	else {
		float r = state.GetValue < float >( 1, 0.0f );
		float g = state.GetValue < float >( 2, 0.0f );
		float b = state.GetValue < float >( 3, 0.0f );
		float a = state.GetValue < float >( 4, 1.0f );
		
		sim.mClearColor = USColor::PackRGBA ( r, g, b, a );
		sim.mClearFlags |= GL_COLOR_BUFFER_BIT;
	}
	return 0;
}
开发者ID:mobilehub,项目名称:moai-beta,代码行数:28,代码来源:MOAISim.cpp


示例16: SetRef

//----------------------------------------------------------------//
void USLuaRef::SetRef ( USLuaState& state, int idx, bool weak ) {

	this->Clear ();
	this->mWeak = weak;

	int top = state.GetTop ();

	if ( lua_isnil ( state, idx ) == false ) {

		USLuaRuntime& luaRuntime = USLuaRuntime::Get ();

		if ( weak ) {
			this->mRef = luaRuntime.mWeakRefTable.Ref ( state, idx );
		}
		else {
			this->mRef = luaRuntime.mStrongRefTable.Ref ( state, idx );	
		}
		
		this->mOwnsRef = true;
	}
	
	assert ( top == state.GetTop ());
}
开发者ID:,项目名称:,代码行数:24,代码来源:


示例17: Ref

//----------------------------------------------------------------//
int USLuaRefTable::Ref ( USLuaState& 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:,项目名称:,代码行数:17,代码来源:


示例18: WriteTable

//----------------------------------------------------------------//
u32 USLuaSerializer::WriteTable ( USStream& stream, USLuaState& state, int idx, u32 tab ) {

	STLString indent;
	
	for ( u32 i = 0; i < tab; ++i ) {
		indent.append ( "\t" );
	}
	
	u32 count = 0;
	u32 itr = state.PushTableItr ( idx );
	while ( state.TableItrNext ( itr )) {
		
		if ( count == 0 ) {
			stream.Print ( "\n" );
		}
		
		switch ( lua_type ( state, -2 )) {
		
			case LUA_TSTRING: {
				stream.Print ( "%s[ \"%s\" ] = ", indent.c_str (), lua_tostring ( state, -2 ));
				break;
			}
			case LUA_TNUMBER: {
				stream.Print ( "%s[ %s ]\t= ", indent.c_str (), lua_tostring ( state, -2 ));
				break;
			}
		};
		
		switch ( lua_type ( state, -1 )) {
			
			case LUA_TBOOLEAN: {
				int value = lua_toboolean ( state, -1 );
				cc8* str = ( value ) ? "true": "false";
				stream.Print ( "%s,\n", str );
				break;
			}
			case LUA_TTABLE: {
				
				uintptr tableID = ( uintptr )lua_topointer ( state, -1 );
				if ( this->mTableMap.contains ( tableID )) {
					stream.Print ( "objects [ 0x%08X ],\n", tableID );
				}
				else {
					stream.Print ( "{" );
					if ( this->WriteTable ( stream, state, -1, tab + 1 )) {
						stream.Print ( "%s},\n", indent.c_str ());
					}
					else {
						stream.Print ( "},\n" );
					}
				}
				break;
			}
			case LUA_TSTRING: {
				STLString str = _escapeString ( lua_tostring ( state, -1 ));
				stream.Print ( "\"%s\",\n", str.c_str ());
				break;
			}
			case LUA_TNUMBER: {
				stream.Print ( "%s,\n", lua_tostring ( state, -1 ));
				break;
			}
			case LUA_TLIGHTUSERDATA: {
				stream.Print ( "%p,\n", lua_touserdata ( state, -1 ));
				break;
			}
		};
		
		++count;
	}
	
	return count;
}
开发者ID:,项目名称:,代码行数:74,代码来源:



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ USMatrix4x4类代码示例发布时间:2022-05-31
下一篇:
C++ USER类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap