本文整理汇总了C++中CCodeChain::CreateInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ CCodeChain::CreateInteger方法的具体用法?C++ CCodeChain::CreateInteger怎么用?C++ CCodeChain::CreateInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCodeChain
的用法示例。
在下文中一共展示了CCodeChain::CreateInteger方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CONSTLIT
ICCItem *fnCount (CEvalContext *pCtx, ICCItem *pArguments, DWORD dwData)
// fnCount
//
// Returns the number of elements in the list
//
// (count list)
{
CCodeChain *pCC = pCtx->pCC;
ICCItem *pArgs;
ICCItem *pResult;
ICCItem *pList;
// Evaluate the arguments and validate them
pArgs = pCC->EvaluateArgs(pCtx, pArguments, CONSTLIT("l"));
if (pArgs->IsError())
return pArgs;
// The first argument is the list
pList = pArgs->Head(pCC);
pResult = pCC->CreateInteger(pList->GetCount());
// Done
pArgs->Discard(pCC);
return pResult;
}
示例2:
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();
}
}
示例3: 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);
}
示例4: if
ICCItem *fnRandom (CEvalContext *pCtx, ICCItem *pArguments, DWORD dwData)
// fnRandom
//
// (random from to) -> number
// (random list) -> random item in list
{
CCodeChain *pCC = pCtx->pCC;
ICCItem *pArgs;
ICCItem *pResult;
// Evaluate the arguments and validate them
pArgs = pCC->EvaluateArgs(pCtx, pArguments, CONSTLIT("*"));
if (pArgs->IsError())
return pArgs;
// Do stuff based on parameters
if (pArgs->GetCount() == 2)
{
int iOp1 = pArgs->GetElement(0)->GetIntegerValue();
int iOp2 = pArgs->GetElement(1)->GetIntegerValue();
pArgs->Discard(pCC);
pResult = pCC->CreateInteger(mathRandom(iOp1, iOp2));
}
else if (pArgs->GetCount() == 1)
{
ICCItem *pList = pArgs->GetElement(0);
if (pList->IsNil())
pResult = pCC->CreateNil();
else if (pList->GetCount() == 0)
pResult = pCC->CreateNil();
else
pResult = pList->GetElement(mathRandom(0, pList->GetCount()-1))->Reference();
pArgs->Discard(pCC);
}
else
{
pResult = pCC->CreateNil();
pArgs->Discard(pCC);
}
// Done
return pResult;
}
示例5: 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);
}