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


C++ CBlock::Create方法代码示例

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


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

示例1: GetLoop

int CInterpreter::GetLoop( void )
{
	CBlock			block;

	block.Create( ID_LOOP );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if ( LookAhead( TK_CLOSED_PARENTHESIS ) )
	{
		//-1 denotes an infinite loop
		block.Write( TK_FLOAT, (float) -1);
	}
	else
	{
		if ( GetInteger( &block ) == false )
			return false;
	}

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("GetLoop : too many parameters");

	m_blockStream->WriteBlock( &block );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:27,代码来源:Interpreter.cpp

示例2: GetElse

int CInterpreter::GetElse( void )
{
	CBlock	block;

	block.Create( ID_ELSE );

	/*
	if ( Match( TK_OPEN_PARENTHESIS ) == false )
		return Error("syntax error : '(' not found");
	*/

	/*
	if ( GetAny( &block ) == false )
		return false;

	if ( GetEvaluator( &block ) == false )
		return false;

	if ( GetAny( &block ) == false )
		return false;
	*/

	/*
	if ( Match( TK_CLOSED_PARENTHESIS ) == false )
		return Error("sound : too many parameters");
	*/

	m_blockStream->WriteBlock( &block );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:31,代码来源:Interpreter.cpp

示例3: GetWait

int CInterpreter::GetWait( void )
{
	CBlock			block;

	block.Create( ID_WAIT );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if ( LookAhead( TK_STRING ) )
	{
		if ( GetString( &block ) == false )
			return false;
	}
	else
	{
		if ( GetFloat( &block ) == false )
			return false;
	}

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("wait : too many parameters");

	m_blockStream->WriteBlock( &block );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:27,代码来源:Interpreter.cpp

示例4: GetMove

int CInterpreter::GetMove( void )
{
	CBlock	block;

	block.Create( ID_MOVE );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if ( GetVector( &block ) == false )
		return false;

	//Angles are optional
	if ( LookAhead( TK_VECTOR_START ) || LookAhead( TK_IDENTIFIER ) )
	{
		if ( GetVector( &block ) == false )
			return false;
	}

	if ( GetFloat( &block ) == false )
		return false;

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("move : too many parameters");

	m_blockStream->WriteBlock( &block );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:29,代码来源:Interpreter.cpp

示例5: GetVariable

int CInterpreter::GetVariable( int type )
{
	const char	*varName;
	variable_t	*var;
	CToken		*token;

	//Get the variable's name
	token = m_tokenizer->GetToken( 0, 0 );
	varName = token->GetStringValue();

	//See if we already have a variable by this name
	var = FindVar( varName );

	//Variable names must be unique on creation
	if ( var )
		return Error( "\"%s\" : already exists\n", varName );

	//Add the variable
	AddVar( varName, type );

	//Insert the variable into the stream

	CBlock	block;

	block.Create( TYPE_VARIABLE );
	block.Write( TK_FLOAT, (float) type );
	block.Write( TK_STRING, varName );

	m_blockStream->WriteBlock( &block );

	token->Delete();

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:34,代码来源:Interpreter.cpp

示例6: GetDoWait

int CInterpreter::GetDoWait( void )
{
	CBlock	block;

	//Write out the "do" portion
	block.Create( ID_DO );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if ( GetString( &block ) == false )
		return false;

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("do : too many parameters");

	//Write out the accompanying "wait"
	char	*str = (char *) block.GetMemberData( 0 );

	CBlock	block2;

	block2.Create( ID_WAIT );

	block2.Write( TK_STRING, (char *) str );

	m_blockStream->WriteBlock( &block );
	m_blockStream->WriteBlock( &block2 );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:30,代码来源:Interpreter.cpp

示例7: GetAffect

int CInterpreter::GetAffect( void )
{
	CBlock			block;
	char			typeName[MAX_STRING_SIZE];
	int				type;

	block.Create( ID_AFFECT );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if ( GetString( &block ) == false )	
		return false;

	if (!LookAhead( TK_IDENTIFIER ))
		return Error("syntax error : identifier not found");

	if ( MatchGet() )
		return Error("syntax error : illegal use of \"get\"");

	if ( GetType( (char *) typeName ) == false )
		return false;

	type = FindSymbol( typeName, m_typeKeywords);

	switch ( type )
	{
	case TYPE_INSERT:
	case TYPE_FLUSH:
		
		block.Write( TK_FLOAT, (float) type );
		break;

	default:
		return Error("'%s': unknown affect type", typeName );
		break;

	}

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("affect : too many parameters");

	if (!LookAhead( TK_BLOCK_START ))
		return Error("syntax error : '{' not found");

	m_blockStream->WriteBlock( &block );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:49,代码来源:Interpreter.cpp

示例8: GetFlush

int CInterpreter::GetFlush( void )
{
	CBlock	block;

	block.Create( ID_FLUSH );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("flush : too many parameters");

	m_blockStream->WriteBlock( &block );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:16,代码来源:Interpreter.cpp

示例9: GetRemove

int CInterpreter::GetRemove( void )
{
	CBlock	block;

	block.Create( ID_REMOVE );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if ( GetString( &block ) == false )
		return false;

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("remove : too many parameters");

	m_blockStream->WriteBlock( &block );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:19,代码来源:Interpreter.cpp

示例10: GetWaitSignal

int CInterpreter::GetWaitSignal( void )
{
	CBlock			block;

	block.Create( ID_WAITSIGNAL );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if ( GetString( &block ) == false )
		return false;

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("waitsignal : too many parameters");

	m_blockStream->WriteBlock( &block );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:19,代码来源:Interpreter.cpp

示例11:

CBlock *CBlock::Duplicate( void )
{
	blockMember_v::iterator	mi;
	CBlock					*newblock;

	newblock = new CBlock;

	if ( newblock == NULL )
		return NULL;

	newblock->Create( m_id );

	//Duplicate entire block and return the cc
	for ( mi = m_members.begin(); mi != m_members.end(); mi++ )
	{
		newblock->AddMember( (*mi)->Duplicate() );
	}

	return newblock;
}
开发者ID:DavidZeise,项目名称:OpenJK,代码行数:20,代码来源:BlockStream.cpp

示例12: GetRem

// this is just so people can put comments in scripts in BehavEd and not have them lost as normal comments would be.
//
int CInterpreter::GetRem( void )
{	
	CBlock	block;

	block.Create( ID_REM );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	// optional string?

	if (Match( TK_CLOSED_PARENTHESIS ))
		return true;

	GetString( &block );	

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("rem : function only takes 1 optional parameter");

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:23,代码来源:Interpreter.cpp

示例13: GetDeclare

int CInterpreter::GetDeclare( void )
{
	CBlock	block;
	char	typeName[MAX_STRING_LENGTH];
	int		type;

	block.Create( ID_DECLARE );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if ( GetType( (char *) typeName ) == false )
		return false;

	type = FindSymbol( typeName, m_typeKeywords);

	switch ( type )
	{
	case TK_FLOAT:
	case TK_VECTOR:
	case TK_STRING:
		block.Write( TK_FLOAT, (float) type );
		break;

	default:
		return Error("unknown identifier %s", typeName );
		break;
	}

	if ( GetString( &block ) == false )
		return false;

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("declare : too many parameters");

	m_blockStream->WriteBlock( &block );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:39,代码来源:Interpreter.cpp

示例14: GetSound

int CInterpreter::GetSound( void )
{
	CBlock	block;

	block.Create( ID_SOUND );

	if (!Match( TK_OPEN_PARENTHESIS ))
		return Error("syntax error : '(' not found");

	if ( GetIdentifier( &block ) == false )
		return false;

	if ( GetString( &block ) == false )
		return false;

	if (!Match( TK_CLOSED_PARENTHESIS ))
		return Error("sound : too many parameters");

	m_blockStream->WriteBlock( &block );

	return true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:22,代码来源:Interpreter.cpp

示例15:


//.........这里部分代码省略.........
		case TK_FLOAT:
			token->Delete();
			m_iBadCBlockNumber = -m_iBadCBlockNumber;
			Error("syntax error : unexpected float");
			return m_iBadCBlockNumber;
			break;
		
		case TK_IDENTIFIER:
			m_iBadCBlockNumber++;
			if (!GetID( (char *) token->GetStringValue() ))
			{
				token->Delete();
				return m_iBadCBlockNumber;
			}
			token->Delete();
			break;
		
		case TK_BLOCK_START:
			token->Delete();
			if (parenthesisLevel)
			{
				m_iBadCBlockNumber = -m_iBadCBlockNumber;
				Error("syntax error : brace inside parenthesis");
				return m_iBadCBlockNumber;
			}

			blockLevel++;
			break;

		case TK_BLOCK_END:
			token->Delete();
			if (parenthesisLevel)
			{
				m_iBadCBlockNumber = -m_iBadCBlockNumber;
				Error("syntax error : brace inside parenthesis");
				return m_iBadCBlockNumber;
			}
			
			block.Create( ID_BLOCK_END );
			m_blockStream->WriteBlock( &block );
			block.Free();

			blockLevel--;
			break;

		case TK_OPEN_PARENTHESIS:
			token->Delete();
			blockLevel++;
			parenthesisLevel++;
			break;

		case TK_CLOSED_PARENTHESIS:
			token->Delete();
			blockLevel--;
			parenthesisLevel--;

			if (parenthesisLevel<0)
			{
				m_iBadCBlockNumber = -m_iBadCBlockNumber;
				Error("syntax error : closed parenthesis with no opening match");
				return m_iBadCBlockNumber;
			}
			break;

		case TK_VECTOR_START:
			token->Delete();
			m_iBadCBlockNumber = -m_iBadCBlockNumber;
			Error("syntax error : unexpected vector");
			return m_iBadCBlockNumber;
			break;

		case TK_VECTOR_END:
			token->Delete();
			m_iBadCBlockNumber = -m_iBadCBlockNumber;
			Error("syntax error : unexpected vector");
			return m_iBadCBlockNumber;
			break;
		}
	}

	if ( blockLevel )
	{
		m_iBadCBlockNumber = -m_iBadCBlockNumber;
		Error("error : open brace was not closed");
		return m_iBadCBlockNumber;
	}

	if ( parenthesisLevel )
	{
		m_iBadCBlockNumber = -m_iBadCBlockNumber;
		Error("error: open parenthesis");
		return m_iBadCBlockNumber;
	}

	//Release all the variable information, because it's already been written out
	FreeVars();

	m_iBadCBlockNumber = 0;
	return m_iBadCBlockNumber;	//true;
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:101,代码来源:Interpreter.cpp


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