--------------------- PatchSet 98 Date: 2002/11/01 02:01:13 Author: rbcollins Branch: esi Tag: (none) Log: render fully c++ Members: src/ESI.cc:1.1.2.7->1.1.2.8 Index: squid3/src/ESI.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESI.cc,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- squid3/src/ESI.cc 1 Nov 2002 01:55:07 -0000 1.1.2.7 +++ squid3/src/ESI.cc 1 Nov 2002 02:01:13 -0000 1.1.2.8 @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.1.2.7 2002/11/01 01:55:07 rbcollins Exp $ + * $Id: ESI.cc,v 1.1.2.8 2002/11/01 02:01:13 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -160,15 +160,12 @@ typedef struct _esiElementType esiElementType; -typedef void esiRender (void *, esiSegment *); /* render into the segment list */ class esiElement; -#define RENDER(foo, bar) foo->Vptr->render(foo, bar) typedef int esiAddElement (void *, esiElement *); /* add a child to an element */ #define ADDELEMENT(foo, bar) foo->Vptr->add(foo,bar) typedef esiProcessResult_t esiProcessSelf (void *, int); /* process thisNode element */ #define PROCESS(foo, bar) foo->Vptr->process(foo, bar) struct _esiElementType { - esiRender *render; esiAddElement *add; esiProcessSelf *process; }; @@ -180,8 +177,6 @@ /* some core operators */ -static esiRender esiRenderSelf; - /* the methods for each type */ static esiAddElement esiAddFail; static esiProcessSelf esiProcessComplete; @@ -201,7 +196,6 @@ static esiProcessSelf esiTryProcess; static esiAddElement esiChooseAdd; -static esiRender esiChooseRender; static esiProcessSelf esiChooseProcess; /* the types we have */ @@ -219,19 +213,19 @@ ESI_ELEMENT_OTHERWISE } esiElementType_t; -static esiElementType _esiComment = {esiRenderSelf,esiAddFail,esiProcessComplete}; -static esiElementType _esiLiteral = {esiRenderSelf,esiAddFail,esiLiteralProcess}; -static esiElementType _esiSequence = {esiRenderSelf,esiSequenceAdd,esiSequenceProcess}; -static esiElementType _esiInclude = {esiRenderSelf, esiAddFail, esiIncludeProcess}; -static esiElementType _esiRemove = {esiRenderSelf, esiRemoveAdd, esiProcessComplete}; -static esiElementType _esiTry = {esiRenderSelf, esiTryAdd, esiTryProcess}; +static esiElementType _esiComment = {esiAddFail,esiProcessComplete}; +static esiElementType _esiLiteral = {esiAddFail,esiLiteralProcess}; +static esiElementType _esiSequence = {esiSequenceAdd,esiSequenceProcess}; +static esiElementType _esiInclude = {esiAddFail, esiIncludeProcess}; +static esiElementType _esiRemove = {esiRemoveAdd, esiProcessComplete}; +static esiElementType _esiTry = {esiTryAdd, esiTryProcess}; /* esiAttempt, esiExcept, esiVar, esiWhen and esiOtherwise are 'Sequences' */ -static esiElementType _esiAttempt = {esiRenderSelf,esiSequenceAdd,esiSequenceProcess}; -static esiElementType _esiExcept = {esiRenderSelf,esiSequenceAdd,esiSequenceProcess}; -static esiElementType _esiVar = {esiRenderSelf,esiSequenceAdd,esiSequenceProcess}; -static esiElementType _esiChoose = {esiChooseRender, esiChooseAdd, esiChooseProcess}; -static esiElementType _esiWhen = {esiRenderSelf,esiSequenceAdd,esiSequenceProcess}; -static esiElementType _esiOtherwise= {esiRenderSelf,esiSequenceAdd,esiSequenceProcess}; +static esiElementType _esiAttempt = {esiSequenceAdd,esiSequenceProcess}; +static esiElementType _esiExcept = {esiSequenceAdd,esiSequenceProcess}; +static esiElementType _esiVar = {esiSequenceAdd,esiSequenceProcess}; +static esiElementType _esiChoose = {esiChooseAdd, esiChooseProcess}; +static esiElementType _esiWhen = {esiSequenceAdd,esiSequenceProcess}; +static esiElementType _esiOtherwise= {esiSequenceAdd,esiSequenceProcess}; /* esiComment */ @@ -513,7 +507,7 @@ if (!context->outbound) context->outbound = context->outboundtail = cbdataAlloc (esiSegment); if (!context->flags.error) - RENDER (context->tree, context->outboundtail); + context->tree->render(context->outboundtail); /* TODO: fixup thisNode outboundtail dross a little */ while (context->outboundtail->next) context->outboundtail = context->outboundtail->next; @@ -1895,7 +1889,7 @@ assert (output->next == NULL); debug (86,5)("esiSequenceRender: rendering %d elements\n", processedcount); for (i = 0; i < processedcount; ++i) { - RENDER (elements[i], output); + elements[i]->render(output); /* FIXME: pass a esiSegment ** ? */ while (output->next) output = output->next; @@ -2315,9 +2309,9 @@ assert (except); debug (86, 5)("esiTryRender: Rendering Try %p\n", this); if (flags.attemptok) { - RENDER (attempt, output); + attempt->render(output); } else if (flags.exceptok) { - RENDER (except, output); + except->render(output); } else debug (86,5)("esiTryRender: Neither except nor attempt succeeded?!?\n"); } @@ -3048,12 +3042,6 @@ } void -esiChooseRender (void *data, esiSegment *output) -{ - ((esiChoose *)data)->render(output); -} - -void esiChoose::render(esiSegment *output) { /* append all processed elements, and trim processed and rendered elements */ @@ -3061,10 +3049,9 @@ assert (elementcount || otherwise); debug (86,5)("esiChooseRender: rendering\n"); if (chosenelement >= 0) - RENDER (elements[chosenelement], output); - else if (otherwise) { - RENDER (otherwise, output); - } + elements[chosenelement]->render(output); + else if (otherwise) + otherwise->render(output); } int