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


C++ CVariable::toInt方法代码示例

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


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

示例1: CilPredicater

bool CArrayObject::CilPredicater( const CVariable& elem1,
									const CVariable& elem2 )
{
	assert( g_ridPredicater != RID_NULL );
	assert( g_pVm != NULL );
	
	//Invoke predicater
	CVariable vars[ 3 ];
	vars[ 1 ] = elem1;
	vars[ 2 ] = elem2;
	
	CVariable* pResult = g_pVm->invokeMethod( g_ridPredicater,
												3,
												vars );
	bool bReturn = (pResult->toInt() < 0);
	delete( pResult );
	
	return bReturn;
}
开发者ID:hak,项目名称:criscript,代码行数:19,代码来源:cilBuiltinArrayObject.cpp

示例2: anyAccessor

/***************************************************************************
 *      anyAccessor
 ***************************************************************************/
CVariable* CArrayObject::anyAccessor(CCilVm* const pVm,
										CVmObject* const pObject, 
										const wstring* const pName,
										CVariable* const pVar,
										const bool bSet )
{
	assert( pObject != NULL );
	if( bSet )
	{
		//Getter implementation
		return NULL;
	}
	else
	{
		pObject->setProperty( *pName, *pVar );

		//Setter implementation
		int32_t iLength = 0;

		//Check existing length
		CVariable* pCurrentLengthVar = pObject->lookupProperty( STRING_PROPERTY_INTERNAL_LENGTH );

		if( pCurrentLengthVar != NULL  )
		{
			iLength = pCurrentLengthVar->toInt();
		}

		int32_t iGivenIndex = _wtoi( pName->data() ) + 1;
		
		if( iGivenIndex > iLength )
		{
			CVariable var( iGivenIndex, OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) ); 
			pObject->setProperty( STRING_PROPERTY_INTERNAL_LENGTH, var );
		}
		return NULL;
	}
}
开发者ID:hak,项目名称:criscript,代码行数:40,代码来源:cilBuiltinArrayObject.cpp

示例3: lengthAccessor

/***************************************************************************
 *      lengthAccessor
 *      array object helper
 ***************************************************************************/
CVariable* CArrayObject::lengthAccessor(CCilVm* const pVm,
										CVmObject* const pObject,
										const wstring* const pName,
										CVariable* const pVar,
										const bool bSet )
{
	assert( pObject != NULL );
	if( bSet )
	{
		//Getter implementation
		return pObject->lookupProperty( STRING_PROPERTY_INTERNAL_LENGTH );
	}
	else
	{
		//Setter implementation
		int32_t iLength = 0;

		//Check existing length
		CVariable* pCurrentLengthVar = pObject->lookupProperty( STRING_PROPERTY_INTERNAL_LENGTH );

		if( pCurrentLengthVar != NULL  )
		{
			iLength = pCurrentLengthVar->toInt();
		}

		int32_t iGivenIndex = pVar->toInt();

		//Just expanding the array, nothing to do
		CVariable var( iGivenIndex,
					  OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) );
		pObject->setProperty( STRING_PROPERTY_INTERNAL_LENGTH, var );

		if( iGivenIndex < iLength )
		{
			//Reducing an array size, need to eliminate some entries
			int32_t iNumToEliminate = iLength - iGivenIndex;

			hash_map< wstring, CVariable >::iterator itStart =
										pObject->getPropertyMap().begin();
			hash_map< wstring, CVariable >::iterator itEnd =
										pObject->getPropertyMap().end();
			while( itStart != itEnd && iNumToEliminate )
			{
				if( itStart->second.iOperandFlag && OPERAND_FLAG_DONTENUM )
				{
					itStart++;
					continue;
				}
				if( CheckArrayIndex( itStart->first ) )
				{
					const wstring& String = itStart->first;
					itStart ++;
					if( _wtoi( String.data() ) >= iGivenIndex )
					{
						pObject->removeProperty( String );
						iNumToEliminate--;
					}
				}
				else
					itStart++;
			}
		}
		return NULL;
	}
}
开发者ID:hak,项目名称:criscript,代码行数:69,代码来源:cilBuiltinArrayObject.cpp


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