Example #1
0
ALERROR CExtension::ExecuteGlobals (SDesignLoadCtx &Ctx)

//	ExecuteGlobals
//
//	Execute the globals

	{
	DEBUG_TRY

	int i;
	CCodeChainCtx CCCtx;

	//	Add a hook so that all lambda expressions defined in this global block
	//	are wrapped with something that sets the extension UNID to the context.

	if (m_iType != extBase)
		CCCtx.SetGlobalDefineWrapper(this);

	//	Run the code (which will likely define a bunch of functions)

	for (i = 0; i < m_Globals.GetCount(); i++)
		{
		ICCItem *pResult = CCCtx.Run(m_Globals[i].pCode);
		if (pResult->IsError())
			{
			Ctx.sError = strPatternSubst(CONSTLIT("%s globals: %s"), m_Globals[i].sFilespec, pResult->GetStringValue());
			return ERR_FAIL;
			}

		CCCtx.Discard(pResult);
		}

	//	Done

	return NOERROR;

	DEBUG_CATCH
	}