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


C++ idTypeDef类代码示例

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


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

示例1:

/*
============
idScriptObject::GetVariable
============
*/
byte *idScriptObject::GetVariable( const char *name, etype_t etype ) const
{
	int				i;
	int				pos;
	const idTypeDef	*t;
	const idTypeDef	*parm;
	
	if( type == &type_object )
	{
		return NULL;
	}
	
	t = type;
	do
	{
		if( t->SuperClass() != &type_object )
		{
			pos = t->SuperClass()->Size();
		}
		else
		{
			pos = 0;
		}
		for( i = 0; i < t->NumParameters(); i++ )
		{
			parm = t->GetParmType( i );
			if( !strcmp( t->GetParmName( i ), name ) )
			{
				if( etype != parm->FieldType()->Type() )
				{
					return NULL;
				}
				return &data[ pos ];
			}
			
			if( parm->FieldType()->Inherits( &type_object ) )
			{
				pos += type_object.Size();
			}
			else
			{
				pos += parm->FieldType()->Size();
			}
		}
		t = t->SuperClass();
	}
	while( t && ( t != &type_object ) );
	
	return NULL;
}
开发者ID:revelator,项目名称:MHDoom,代码行数:55,代码来源:Script_Program.cpp

示例2: idCompileError

/*
================
idTypeDef::AddField

Adds a new field to an object type.
================
*/
void idTypeDef::AddField( idTypeDef *fieldtype, const char *name ) {
	if ( type != ev_object ) {
		throw idCompileError( "idTypeDef::AddField : tried to add field to non-object type" );
	}

	parmTypes.Append( fieldtype );
	idStr &parmName = parmNames.Alloc();
	parmName = name;

	if ( fieldtype->FieldType()->Inherits( &type_object ) ) {
		size += type_object.Size();
	} else {
		size += fieldtype->FieldType()->Size();
	}
}
开发者ID:RobertBeckebans,项目名称:fhDOOM,代码行数:22,代码来源:Script_Program.cpp

示例3: idVarDef

/*
============
idProgram::AllocDef
============
*/
idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scope, bool constant )
{
	idVarDef	*def;
	idStr		element;
	idVarDef	*def_x;
	idVarDef	*def_y;
	idVarDef	*def_z;
	
	// allocate a new def
	def = new idVarDef( type );
	def->scope		= scope;
	def->numUsers	= 1;
	def->num		= varDefs.Append( def );
	
	// add the def to the list with defs with this name and set the name pointer
	AddDefToNameList( def, name );
	
	if( ( type->Type() == ev_vector ) || ( ( type->Type() == ev_field ) && ( type->FieldType()->Type() == ev_vector ) ) )
	{
		//
		// vector
		//
		if( !strcmp( name, RESULT_STRING ) )
		{
			// <RESULT> vector defs don't need the _x, _y and _z components
			assert( scope->Type() == ev_function );
			def->value.stackOffset	= scope->value.functionPtr->locals;
			def->initialized		= idVarDef::stackVariable;
			scope->value.functionPtr->locals += type->Size();
		}
		else if( scope->TypeDef()->Inherits( &type_object ) )
		{
			idTypeDef	newtype( ev_field, NULL, "float field", 0, &type_float );
			idTypeDef	*type = GetType( newtype, true );
			
			// set the value to the variable's position in the object
			def->value.ptrOffset = scope->TypeDef()->Size();
			
			// make automatic defs for the vectors elements
			// origin can be accessed as origin_x, origin_y, and origin_z
			sprintf( element, "%s_x", def->Name() );
			def_x = AllocDef( type, element, scope, constant );
			
			sprintf( element, "%s_y", def->Name() );
			def_y = AllocDef( type, element, scope, constant );
			def_y->value.ptrOffset = def_x->value.ptrOffset + type_float.Size();
			
			sprintf( element, "%s_z", def->Name() );
			def_z = AllocDef( type, element, scope, constant );
			def_z->value.ptrOffset = def_y->value.ptrOffset + type_float.Size();
		}
		else
		{
			// make automatic defs for the vectors elements
			// origin can be accessed as origin_x, origin_y, and origin_z
			sprintf( element, "%s_x", def->Name() );
			def_x = AllocDef( &type_float, element, scope, constant );
			
			sprintf( element, "%s_y", def->Name() );
			def_y = AllocDef( &type_float, element, scope, constant );
			
			sprintf( element, "%s_z", def->Name() );
			def_z = AllocDef( &type_float, element, scope, constant );
			
			// point the vector def to the x coordinate
			def->value			= def_x->value;
			def->initialized	= def_x->initialized;
		}
	}
	else if( scope->TypeDef()->Inherits( &type_object ) )
	{
		//
		// object variable
		//
		// set the value to the variable's position in the object
		def->value.ptrOffset = scope->TypeDef()->Size();
	}
	else if( scope->Type() == ev_function )
	{
		//
		// stack variable
		//
		// since we don't know how many local variables there are,
		// we have to have them go backwards on the stack
		def->value.stackOffset	= scope->value.functionPtr->locals;
		def->initialized		= idVarDef::stackVariable;
		
		if( type->Inherits( &type_object ) )
		{
			// objects only have their entity number on the stack, not the entire object
			scope->value.functionPtr->locals += type_object.Size();
		}
		else
		{
			scope->value.functionPtr->locals += type->Size();
//.........这里部分代码省略.........
开发者ID:revelator,项目名称:MHDoom,代码行数:101,代码来源:Script_Program.cpp


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