本文整理汇总了C++中CCodeChainCtx::SaveAndDefineDataVar方法的典型用法代码示例。如果您正苦于以下问题:C++ CCodeChainCtx::SaveAndDefineDataVar方法的具体用法?C++ CCodeChainCtx::SaveAndDefineDataVar怎么用?C++ CCodeChainCtx::SaveAndDefineDataVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCodeChainCtx
的用法示例。
在下文中一共展示了CCodeChainCtx::SaveAndDefineDataVar方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ICCItem *CMission::FireOnReward (ICCItem *pData)
// FireOnReward
//
// Fire <OnReward>
//
// Callers are responsible for discarding the result, if not NULL.
{
SEventHandlerDesc Event;
if (FindEventHandler(EVENT_ON_REWARD, &Event))
{
CCodeChainCtx Ctx;
Ctx.SaveAndDefineSourceVar(this);
Ctx.SaveAndDefineDataVar(pData);
ICCItem *pResult = Ctx.Run(Event);
if (pResult->IsError())
{
ReportEventError(EVENT_ON_REWARD, pResult);
Ctx.Discard(pResult);
return NULL;
}
return pResult;
}
return NULL;
}
示例2: EvalBool
bool IDockScreenDisplay::EvalBool (const CString &sCode, bool *retbResult, CString *retsError)
// EvalBool
//
// Evaluates the given string
{
CCodeChainCtx Ctx;
Ctx.SetScreen(m_pDockScreen);
Ctx.SaveAndDefineSourceVar(m_pLocation);
Ctx.SaveAndDefineDataVar(m_pData);
char *pPos = sCode.GetPointer();
ICCItem *pExp = Ctx.Link(sCode, 1, NULL);
ICCItem *pResult = Ctx.Run(pExp); // LATER:Event
Ctx.Discard(pExp);
if (pResult->IsError())
{
*retsError = pResult->GetStringValue();
Ctx.Discard(pResult);
return false;
}
*retbResult = !pResult->IsNil();
Ctx.Discard(pResult);
return true;
}
示例3: InitPainterParameters
void CEffectCreator::InitPainterParameters (CCreatePainterCtx &Ctx, IEffectPainter *pPainter)
// InitPainterParameters
//
// Initialize painter parameters
{
SEventHandlerDesc Event;
if (FindEventHandlerEffectType(evtGetParameters, &Event))
{
CCodeChainCtx CCCtx;
CCCtx.SaveAndDefineDataVar(Ctx.GetData());
ICCItem *pResult = CCCtx.Run(Event);
if (pResult->IsError())
::kernelDebugLogMessage(CONSTLIT("EffectType %x GetParameters: %s"), GetUNID(), (LPSTR)pResult->GetStringValue());
else if (pResult->IsSymbolTable())
{
int i;
CCSymbolTable *pTable = (CCSymbolTable *)pResult;
for (i = 0; i < pTable->GetCount(); i++)
{
CString sParam = pTable->GetKey(i);
ICCItem *pValue = pTable->GetElement(i);
CEffectParamDesc Value;
if (pValue->IsNil())
Value.InitNull();
else if (pValue->IsInteger())
Value.InitInteger(pValue->GetIntegerValue());
else if (pValue->IsIdentifier())
{
CString sValue = pValue->GetStringValue();
char *pPos = sValue.GetASCIIZPointer();
// If this is a color, parse it
if (*pPos == '#')
Value.InitColor(::LoadRGBColor(sValue));
// Otherwise, a string
else
Value.InitString(sValue);
}
pPainter->SetParam(Ctx, sParam, Value);
}
}
else
::kernelDebugLogMessage(CONSTLIT("EffectType %x GetParameters: Expected struct result."), GetUNID());
CCCtx.Discard(pResult);
}
}
示例4: if
CSpaceObject *IDockScreenDisplay::EvalListSource (const CString &sString, CString *retsError)
// EvalListSource
//
// Returns the object from which we should display items
{
char *pPos = sString.GetPointer();
// See if we need to evaluate
if (*pPos == '=')
{
CCodeChainCtx Ctx;
Ctx.SetScreen(this);
Ctx.SaveAndDefineSourceVar(m_pLocation);
Ctx.SaveAndDefineDataVar(m_pData);
ICCItem *pExp = Ctx.Link(sString, 1, NULL);
ICCItem *pResult = Ctx.Run(pExp); // LATER:Event
Ctx.Discard(pExp);
if (pResult->IsError())
{
*retsError = pResult->GetStringValue();
Ctx.Discard(pResult);
return NULL;
}
// Convert to an object pointer
CSpaceObject *pSource;
if (strEquals(pResult->GetStringValue(), DATA_FROM_PLAYER))
pSource = m_pPlayer->GetShip();
else if (strEquals(pResult->GetStringValue(), DATA_FROM_STATION)
|| strEquals(pResult->GetStringValue(), DATA_FROM_SOURCE))
pSource = m_pLocation;
else
pSource = Ctx.AsSpaceObject(pResult);
Ctx.Discard(pResult);
return pSource;
}
// Otherwise, compare to constants
else if (strEquals(sString, DATA_FROM_PLAYER))
return m_pPlayer->GetShip();
else
return m_pLocation;
}
示例5: EvalString
bool IDockScreenDisplay::EvalString (const CString &sString, bool bPlain, ECodeChainEvents iEvent, CString *retsResult)
// EvalString
//
// Evaluates the given string.
{
CCodeChainCtx Ctx;
Ctx.SetEvent(iEvent);
Ctx.SetScreen(m_pDockScreen);
Ctx.SaveAndDefineSourceVar(m_pLocation);
Ctx.SaveAndDefineDataVar(m_pData);
return Ctx.RunEvalString(sString, bPlain, retsResult);
}
示例6: FireOnReward
void CMission::FireOnReward (ICCItem *pData)
// FireOnReward
//
// Fire <OnReward>
{
SEventHandlerDesc Event;
if (FindEventHandler(EVENT_ON_REWARD, &Event))
{
CCodeChainCtx Ctx;
Ctx.SaveAndDefineSourceVar(this);
Ctx.SaveAndDefineDataVar(pData);
ICCItem *pResult = Ctx.Run(Event);
if (pResult->IsError())
ReportEventError(EVENT_ON_REWARD, pResult);
Ctx.Discard(pResult);
}
}
示例7: FireOnStop
void CMission::FireOnStop (const CString &sReason, ICCItem *pData)
// FireOnStop
//
// Fire <OnCompleted>
{
SEventHandlerDesc Event;
if (FindEventHandler(EVENT_ON_COMPLETED, &Event))
{
CCodeChainCtx Ctx;
Ctx.SaveAndDefineSourceVar(this);
Ctx.SaveAndDefineDataVar(pData);
Ctx.DefineString(STR_A_REASON, sReason);
ICCItem *pResult = Ctx.Run(Event);
if (pResult->IsError())
ReportEventError(EVENT_ON_COMPLETED, pResult);
Ctx.Discard(pResult);
}
}
示例8: FireCustomEvent
void CMission::FireCustomEvent (const CString &sEvent, ICCItem *pData)
// FireCustomEvent
//
// Fires a custom timed event
{
SEventHandlerDesc Event;
if (FindEventHandler(sEvent, &Event))
{
CCodeChainCtx Ctx;
Ctx.SetEvent(eventDoEvent);
Ctx.SaveAndDefineSourceVar(this);
Ctx.SaveAndDefineDataVar(pData);
ICCItem *pResult = Ctx.Run(Event);
if (pResult->IsError())
ReportEventError(sEvent, pResult);
Ctx.Discard(pResult);
}
}
示例9: OnInitList
ALERROR CDockScreenCustomList::OnInitList (SInitCtx &Ctx, CString *retsError)
// OnInitList
//
// Initialize list
{
// Get the list element
CXMLElement *pListData = Ctx.pDesc->GetContentElementByTag(LIST_TAG);
if (pListData == NULL)
return ERR_FAIL;
// See if we define a custom row height
CString sRowHeight;
if (pListData->FindAttribute(ROW_HEIGHT_ATTRIB, &sRowHeight))
{
CString sResult;
if (!EvalString(sRowHeight, false, eventNone, &sResult))
{
*retsError = sResult;
return ERR_FAIL;
}
int cyRow = strToInt(sResult, -1);
if (cyRow > 0)
m_pItemListControl->SetRowHeight(cyRow);
}
// Get the list to show
CCodeChain &CC = g_pUniverse->GetCC();
ICCItem *pExp = CC.Link(pListData->GetContentText(0), 0, NULL);
// Evaluate the function
CCodeChainCtx CCCtx;
CCCtx.SetScreen(m_pDockScreen);
CCCtx.SaveAndDefineSourceVar(m_pLocation);
CCCtx.SaveAndDefineDataVar(m_pData);
ICCItem *pResult = CCCtx.Run(pExp); // LATER:Event
CCCtx.Discard(pExp);
if (pResult->IsError())
{
*retsError = pResult->GetStringValue();
return ERR_FAIL;
}
// Set this expression as the list
m_pItemListControl->SetList(CC, pResult);
CCCtx.Discard(pResult);
// Position the cursor on the next relevant item
SelectNextItem();
// Give the screen a chance to start at a different item (other
// than the first)
CString sInitialItemFunc = pListData->GetAttribute(INITIAL_ITEM_ATTRIB);
if (!sInitialItemFunc.IsBlank())
{
bool bMore = IsCurrentItemValid();
while (bMore)
{
bool bResult;
if (!EvalBool(sInitialItemFunc, &bResult, retsError))
return ERR_FAIL;
if (bResult)
break;
bMore = SelectNextItem();
}
}
return NOERROR;
}