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


C++ CCodeChain类代码示例

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


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

示例1:

ICCItem *fnMath (CEvalContext *pCtx, ICCItem *pArgs, DWORD dwData)

//	fnMath
//
//	Simple integer arithmetic
//
//	(sqrt int1)

	{
	CCodeChain *pCC = pCtx->pCC;

	//	Compute

	switch (dwData)
		{
		case FN_MATH_SQRT:
			{
			int iValue = pArgs->GetElement(0)->GetIntegerValue();
			if (iValue >= 0)
				return pCC->CreateInteger(mathSqrt(iValue));
			else
				return pCC->CreateError(CONSTLIT("Imaginary number"), pArgs->GetElement(0));
			}

		default:
			ASSERT(false);
			return pCC->CreateNil();
		}
	}
开发者ID:alanhorizon,项目名称:Transport,代码行数:29,代码来源:Functions.cpp

示例2: DefineGlobalWeaponType

void DefineGlobalWeaponType (CCodeChain &CC, const CString &sVar, CItemType *pWeaponType)
	{
	if (pWeaponType)
		CC.DefineGlobalInteger(sVar, pWeaponType->GetUNID());
	else
		CC.DefineGlobal(sVar, CC.CreateNil());
	}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:7,代码来源:CCUtil.cpp

示例3: CONSTLIT

ICCItem *fnAtmCreate (CEvalContext *pCtx, ICCItem *pArguments, DWORD dwData)

//	fnAtmCreate
//
//	Creates a new atom table
//
//	(atmAtomTable ((atom1 entry1) (atom2 entry2) ... (atomn entryn))) -> atmtable

	{
	CCodeChain *pCC = pCtx->pCC;
	ICCItem *pArgs;
	ICCItem *pAtomTable;
	ICCItem *pList;
	int i;

	//	Evaluate the argument

	pArgs = pCC->EvaluateArgs(pCtx, pArguments, CONSTLIT("l"));
	if (pArgs->IsError())
		return pArgs;

	//	Create the table

	pAtomTable = pCC->CreateAtomTable();
	if (pAtomTable->IsError())
		return pAtomTable;

	//	Add each entry

	pList = pArgs->Head(pCC);
	for (i = 0; i < pList->GetCount(); i++)
		{
		ICCItem *pPair = pList->GetElement(i);
		ICCItem *pResult;

		//	Make sure we have two elements

		if (pPair->GetCount() != 2)
			{
			pAtomTable->Discard(pCC);
			return pCC->CreateError(CONSTLIT("Invalid format for atom table entry:"), pPair);
			}

		//	Get the atom and the entry

		pResult = pAtomTable->AddEntry(pCC, pPair->GetElement(0), pPair->GetElement(1));
		if (pResult->IsError())
			{
			pAtomTable->Discard(pCC);
			return pResult;
			}

		pResult->Discard(pCC);
		}

	//	Done

	pArgs->Discard(pCC);
	return pAtomTable;
	}
开发者ID:alanhorizon,项目名称:Transport,代码行数:60,代码来源:Functions.cpp

示例4: SetStringValue

void CCSymbolTable::SetStringValue (CCodeChain &CC, const CString &sKey, const CString &sValue)

//	SetStringValue
//
//	Sets a string value

	{
	ICCItem *pKey = CC.CreateString(sKey);
	ICCItem *pValue = CC.CreateString(sValue);
	AddEntry(&CC, pKey, pValue);
	pKey->Discard(&CC);
	pValue->Discard(&CC);
	}
开发者ID:dogguts,项目名称:Transcendence,代码行数:13,代码来源:CCSymbolTable.cpp

示例5: SetIntegerValue

void CCSymbolTable::SetIntegerValue (CCodeChain &CC, const CString &sKey, int iValue)

//	SetIntegerValue
//
//	Sets an integer value

	{
	ICCItem *pKey = CC.CreateString(sKey);
	ICCItem *pValue = CC.CreateInteger(iValue);
	AddEntry(&CC, pKey, pValue);
	pKey->Discard(&CC);
	pValue->Discard(&CC);
	}
开发者ID:dogguts,项目名称:Transcendence,代码行数:13,代码来源:CCSymbolTable.cpp

示例6: strFind

ICCItem *fnStrFind (CEvalContext *pCtx, ICCItem *pArgs, DWORD dwData)

//	fnStrFind
//
//	Finds a string in some text

	{
	CCodeChain *pCC = pCtx->pCC;
	int iPos = strFind(pArgs->GetElement(0)->GetStringValue(), pArgs->GetElement(1)->GetStringValue());

	if (iPos == -1)
		return pCC->CreateNil();
	else
		return pCC->CreateInteger(iPos);
	}
开发者ID:alanhorizon,项目名称:Transport,代码行数:15,代码来源:Functions.cpp

示例7: DefineGlobalSpaceObject

void DefineGlobalSpaceObject (CCodeChain &CC, const CString &sVar, CSpaceObject *pObj)

//	DefineGlobalSpaceObject
//
//	Defines a global variable and assigns it the given space object. If pObj
//	is NULL then the variable is Nil.

	{
	if (pObj)
		CC.DefineGlobalInteger(sVar, (int)pObj);
	else
		{
		ICCItem *pValue = CC.CreateNil();
		CC.DefineGlobal(sVar, pValue);
		pValue->Discard(&CC);
		}
	}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:17,代码来源:CCUtil.cpp

示例8: DefineGlobalItem

void DefineGlobalItem (CCodeChain &CC, const CString &sVar, const CItem &Item)

//	DefineGlobalItem
//
//	Defines a global variable and assigns it the given item

	{
	ICCItem *pItem = CreateListFromItem(CC, Item);
	CC.DefineGlobal(sVar, pItem);
	pItem->Discard(&CC);
	}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:11,代码来源:CCUtil.cpp

示例9: DefineGlobalVector

void DefineGlobalVector (CCodeChain &CC, const CString &sVar, const CVector &vVector)

//	DefineGlobalVector
//
//	Defines a global variable and assigns it the given vector

	{
	ICCItem *pValue = CreateListFromVector(CC, vVector);
	CC.DefineGlobal(sVar, pValue);
	pValue->Discard(&CC);
	}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:11,代码来源:CCUtil.cpp

示例10: pageLibraryInit

ALERROR pageLibraryInit (CCodeChain &CC)
	{
	ALERROR error;
	int i;

	for (i = 0; i < EXTENSIONS_COUNT; i++)
		if (error = CC.RegisterPrimitive(&g_Extensions[i]))
			return error;

	return NOERROR;
	}
开发者ID:bmer,项目名称:Alchemy,代码行数:11,代码来源:pageLibrary.cpp

示例11: if

ICCItem *fnSeededRandom (CEvalContext *pCtx, ICCItem *pArgs, DWORD dwData)

//	fnSeededRandom
//
//	(seededRandom seed from to) -> number
//	(seededRandom seed list) -> random item in list

	{
	CCodeChain *pCC = pCtx->pCC;
	ICCItem *pResult;

	int iSeed = pArgs->GetElement(0)->GetIntegerValue();

	//	Do stuff based on parameters

	if (pArgs->GetCount() == 3)
		{
		int iOp1 = pArgs->GetElement(1)->GetIntegerValue();
		int iOp2 = pArgs->GetElement(2)->GetIntegerValue();

		pResult = pCC->CreateInteger(mathSeededRandom(iSeed, iOp1, iOp2));
		}
	else if (pArgs->GetCount() == 2)
		{
		ICCItem *pList = pArgs->GetElement(1);

		if (pList->IsNil())
			pResult = pCC->CreateNil();
		else if (pList->GetCount() == 0)
			pResult = pCC->CreateNil();
		else
			pResult = pList->GetElement(mathSeededRandom(iSeed, 0, pList->GetCount()-1))->Reference();
		}
	else
		pResult = pCC->CreateNil();

	//	Done

	return pResult;
	}
开发者ID:alanhorizon,项目名称:Transport,代码行数:40,代码来源:Functions.cpp

示例12: CreateDataFromItem

CString CreateDataFromItem (CCodeChain &CC, ICCItem *pItem)

//	CreateDataFromItem
//
//	Encodes the item in a string suitable for storage.
//	(Use Link to reverse).

	{
	//	Set quoted before we unlink
	//	Note: This might be a hack...it probably makes more sense to mark
	//	all function return values as 'quoted'

	bool bOldQuoted = (pItem->IsQuoted() ? true : false);
	pItem->SetQuoted();
	CString sData = CC.Unlink(pItem);
	if (!bOldQuoted)
		pItem->ClearQuoted();

	return sData;
	}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:20,代码来源:CCUtil.cpp


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