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); } }
ICCItem *CCodeChain::EvalLiteralStruct (CEvalContext *pCtx, ICCItem *pItem) // EvalLiteralStruct // // Evalues the values in a structure and returns a structure // (or an error). { int i; CCSymbolTable *pTable = dynamic_cast<CCSymbolTable *>(pItem); if (pTable == NULL) return CreateError(CONSTLIT("Not a structure"), pItem); ICCItem *pNew = CreateSymbolTable(); if (pNew->IsError()) return pNew; CCSymbolTable *pNewTable = dynamic_cast<CCSymbolTable *>(pNew); // Loop over all key/value pairs for (i = 0; i < pTable->GetCount(); i++) { CString sKey = pTable->GetKey(i); ICCItem *pValue = pTable->GetElement(i); ICCItem *pNewKey = CreateString(sKey); ICCItem *pNewValue = (pValue ? Eval(pCtx, pValue) : CreateNil()); ICCItem *pResult = pNewTable->AddEntry(this, pNewKey, pNewValue); pNewKey->Discard(this); pNewValue->Discard(this); if (pResult->IsError()) { pNewTable->Discard(this); return pResult; } pResult->Discard(this); } // Done return pNewTable; }