dbertoni    2003/08/03 23:35:34

  Modified:    c/src/xalanc/XSLT ElemApplyTemplates.cpp
                        ElemCallTemplate.cpp StylesheetExecutionContext.cpp
                        StylesheetExecutionContext.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
                        VariablesStack.cpp VariablesStack.hpp
  Log:
  More params cleanup.
  
  Revision  Changes    Path
  1.3       +1 -2      xml-xalan/c/src/xalanc/XSLT/ElemApplyTemplates.cpp
  
  Index: ElemApplyTemplates.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemApplyTemplates.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ElemApplyTemplates.cpp    2 Aug 2003 01:07:48 -0000       1.2
  +++ ElemApplyTemplates.cpp    4 Aug 2003 06:35:33 -0000       1.3
  @@ -219,10 +219,9 @@
        // Push the params & stack frame, but then execute the select
        // expression inside transformSelectedChildren, which must be
        // executed in the stack frame before the new stack frame.
  -     StylesheetExecutionContext::ParamsPushPop       thePushPop(
  +     const StylesheetExecutionContext::ParamsPushPop         thePushPop(
                        executionContext,
                        *this,
  -                     this,
                        savedStackFrameIndex);
   
        const XalanQName* const         currentMode = 
executionContext.getCurrentMode();
  
  
  
  1.3       +2 -3      xml-xalan/c/src/xalanc/XSLT/ElemCallTemplate.cpp
  
  Index: ElemCallTemplate.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/ElemCallTemplate.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ElemCallTemplate.cpp      2 Aug 2003 01:07:48 -0000       1.2
  +++ ElemCallTemplate.cpp      4 Aug 2003 06:35:33 -0000       1.3
  @@ -155,10 +155,9 @@
   
        assert(m_template != 0);
   
  -     StylesheetExecutionContext::ParamsPushPop       thePushPop(
  +     const StylesheetExecutionContext::ParamsPushPop         thePushPop(
                                executionContext,
  -                             *this,                  
  -                             m_template);
  +                             *this);
   
        m_template->execute(executionContext);
   }
  
  
  
  1.3       +3 -10     
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContext.cpp
  
  Index: StylesheetExecutionContext.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContext.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StylesheetExecutionContext.cpp    2 Aug 2003 01:07:48 -0000       1.2
  +++ StylesheetExecutionContext.cpp    4 Aug 2003 06:35:33 -0000       1.3
  @@ -86,30 +86,23 @@
   
   StylesheetExecutionContext::ParamsPushPop::doPush(
                        const ElemTemplateElement&              
xslCallTemplateElement,
  -                     const ElemTemplateElement*              targetTemplate,
                        int                                                     
        savedStackFrameIndex)
   {
        if (xslCallTemplateElement.hasParams() == true)
        {
                
getExecutionContext().setCurrentStackFrameIndex(savedStackFrameIndex);
   
  -             getExecutionContext().pushParams(
  -                                     xslCallTemplateElement,
  -                                     targetTemplate);
  +             getExecutionContext().pushParams(xslCallTemplateElement);
        }
   }
   
   
   
  -StylesheetExecutionContext::ParamsPushPop::doPush(
  -                     const ElemTemplateElement&              
xslCallTemplateElement,
  -                     const ElemTemplateElement*              targetTemplate)
  +StylesheetExecutionContext::ParamsPushPop::doPush(const ElemTemplateElement& 
xslCallTemplateElement)
   {
        if (xslCallTemplateElement.hasParams() == true)
        {
  -             getExecutionContext().pushParams(
  -                                     xslCallTemplateElement,
  -                                     targetTemplate);
  +             getExecutionContext().pushParams(xslCallTemplateElement);
        }
   }
   
  
  
  
  1.6       +4 -15     
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContext.hpp
  
  Index: StylesheetExecutionContext.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContext.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StylesheetExecutionContext.hpp    2 Aug 2003 01:07:48 -0000       1.5
  +++ StylesheetExecutionContext.hpp    4 Aug 2003 06:35:33 -0000       1.6
  @@ -892,12 +892,9 @@
         * Also, push default arguments on the stack.
         *
         * @param xslCallTemplateElement "call-template" element
  -      * @param targetTemplate         target template
         */
        virtual void
  -     pushParams(
  -                     const ElemTemplateElement&      xslCallTemplateElement,
  -                     const ElemTemplateElement*      targetTemplate) = 0;
  +     pushParams(const ElemTemplateElement&   xslCallTemplateElement) = 0;
   
        /**
         * Given a name, return a string representing the value, but don't look 
in
  @@ -1014,25 +1011,20 @@
   
                ParamsPushPop(
                                StylesheetExecutionContext&             
executionContext,
  -                             const ElemTemplateElement&              
xslCallTemplateElement,
  -                             const ElemTemplateElement*              
targetTemplate) :
  +                             const ElemTemplateElement&              
xslCallTemplateElement) :
                        PushAndPopContextMarker(executionContext)
                {
  -                     doPush(
  -                             xslCallTemplateElement,
  -                             targetTemplate);
  +                     doPush(xslCallTemplateElement);
                }
   
                ParamsPushPop(
                                StylesheetExecutionContext&             
executionContext,
                                const ElemTemplateElement&              
xslCallTemplateElement,
  -                             const ElemTemplateElement*              
targetTemplate,
                                int&                                            
        savedStackFrameIndex) :
                        PushAndPopContextMarker(executionContext, 
savedStackFrameIndex)
                {
                        doPush(
                                xslCallTemplateElement,
  -                             targetTemplate,
                                savedStackFrameIndex);
                }
   
  @@ -1044,12 +1036,9 @@
   
                doPush(
                        const ElemTemplateElement&              
xslCallTemplateElement,
  -                     const ElemTemplateElement*              targetTemplate,
                        int                                                     
        stackFrameIndex);
   
  -             doPush(
  -                     const ElemTemplateElement&              
xslCallTemplateElement,
  -                     const ElemTemplateElement*              targetTemplate);
  +             doPush(const ElemTemplateElement&       xslCallTemplateElement);
        };
   
        /**
  
  
  
  1.7       +3 -9      
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StylesheetExecutionContextDefault.cpp     2 Aug 2003 01:07:48 -0000       
1.6
  +++ StylesheetExecutionContextDefault.cpp     4 Aug 2003 06:35:33 -0000       
1.7
  @@ -785,9 +785,7 @@
   
   
   void
  -StylesheetExecutionContextDefault::pushParams(
  -                     const ElemTemplateElement&      xslCallTemplateElement,
  -                     const ElemTemplateElement*      targetTemplate)
  +StylesheetExecutionContextDefault::pushParams(const ElemTemplateElement&     
xslCallTemplateElement)
   {
        // We have a params vector that we reuse, but occasionally, a
        // param will result in recursive execution, so we'll use a
  @@ -807,9 +805,7 @@
   
                getParams(xslCallTemplateElement, m_paramsVector);
   
  -             m_variablesStack.pushParams(
  -                                     m_paramsVector,
  -                                     targetTemplate);
  +             m_variablesStack.pushParams(m_paramsVector);
        }
        else
        {
  @@ -817,9 +813,7 @@
   
                getParams(xslCallTemplateElement, tempParams);
   
  -             m_variablesStack.pushParams(
  -                                     tempParams,
  -                                     targetTemplate);
  +             m_variablesStack.pushParams(tempParams);
        }
   }
   
  
  
  
  1.6       +1 -3      
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StylesheetExecutionContextDefault.hpp     2 Aug 2003 01:07:48 -0000       
1.5
  +++ StylesheetExecutionContextDefault.hpp     4 Aug 2003 06:35:33 -0000       
1.6
  @@ -497,9 +497,7 @@
        clearTopLevelParams();
   
        virtual void
  -     pushParams(
  -                     const ElemTemplateElement&      xslCallTemplateElement,
  -                     const ElemTemplateElement*      targetTemplate);
  +     pushParams(const ElemTemplateElement&   xslCallTemplateElement);
   
        virtual const XObjectPtr
        getParamVariable(const XalanQName&      theName);
  
  
  
  1.3       +30 -76    xml-xalan/c/src/xalanc/XSLT/VariablesStack.cpp
  
  Index: VariablesStack.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/VariablesStack.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- VariablesStack.cpp        2 Aug 2003 01:07:48 -0000       1.2
  +++ VariablesStack.cpp        4 Aug 2003 06:35:33 -0000       1.3
  @@ -150,92 +150,31 @@
   void
   VariablesStack::popContextMarker()
   {
  -     const VariableStackStackType::size_type         nElems = m_stack.size();
  +     VariableStackStackType::iterator        i = m_stack.end();
   
  -     VariableStackStackType::size_type i = nElems;
  -
  -     for(; i > 0; --i)
  +     for(; ;)
        {
  -             assert(i >= m_stack.size());
  +             assert(i != m_stack.begin());
   
  -             const StackEntry&                       theEntry = m_stack[i - 
1];
  +             const StackEntry&                       theEntry = *--i;
                assert(theEntry == back());
   
                const StackEntry::eType         type = theEntry.getType();
                assert(type < StackEntry::eNextValue && type >= 0);
   
  -#if !defined(NDEBUG)
  -             const ElemTemplateElement* const        theElement =
  -                     theEntry.getElement();
  -#endif
  -
                pop();
   
                if (type == StackEntry::eContextMarker)
                {
                        break;
                }
  -#if !defined(NDEBUG)
  -             else if (type == StackEntry::eElementFrameMarker)
  -             {
  -                     if (m_elementFrameStack.empty() == true)
  -                     {
  -                             throw InvalidStackContextException();
  -                     }
  -
  -                     const ElemTemplateElement* const        theStackBack =
  -                             m_elementFrameStack.back();
  -
  -                     m_elementFrameStack.pop_back();
  -
  -                     if (theElement != theStackBack)
  -                     {
  -                             throw InvalidStackContextException();
  -                     }
  -             }
  -#endif
        }
   
  -     assert(m_stack.size() == i - 1);
  -
  -     m_currentStackFrameIndex = i - 1;
  +     m_currentStackFrameIndex = m_stack.size();
   }
   
   
   
  -class CommitPushElementFrame
  -{
  -public:
  -
  -     CommitPushElementFrame(
  -                     VariablesStack&                                         
                theVariableStack,
  -                     const ElemTemplateElement*                              
        targetTemplate) :
  -             m_variableStack(&theVariableStack)
  -     {
  -             theVariableStack.pushElementFrame(targetTemplate);
  -     }
  -
  -     ~CommitPushElementFrame()
  -     {
  -             if (m_variableStack != 0)
  -             {
  -                     m_variableStack->popElementFrame();
  -             }
  -     }
  -
  -     void
  -     commit()
  -     {
  -             m_variableStack = 0;
  -     }
  -
  -private:
  -
  -     VariablesStack*                                         m_variableStack;
  -};
  -
  -
  -
   void
   VariablesStack::push(const StackEntry&       theEntry)
   {
  @@ -294,20 +233,35 @@
   
   
   
  +VariablesStack::CommitPushParams::CommitPushParams(VariablesStack&   
theVariablesStack) :
  +     m_variablesStack(&theVariablesStack),
  +     m_stackSize(theVariablesStack.getStackSize())
  +{
  +}
  +
  +
  +
  +VariablesStack::CommitPushParams::~CommitPushParams()
  +{
  +     if (m_variablesStack != 0)
  +     {
  +             while(m_variablesStack->getStackSize() > m_stackSize)
  +             {
  +                     m_variablesStack->pop();
  +             }
  +     }
  +}
  +
  +
  +
   void
  -VariablesStack::pushParams(
  -                     const ParamsVectorType&         theParams,
  -                     const ElemTemplateElement*      targetTemplate)
  +VariablesStack::pushParams(const ParamsVectorType&   theParams)
   {
  -     // This object will push an element marker, and pop it
  +     // This object will push the params and pop them
        // if we don't call it's commit() member function.  So
        // if an exception is thrown while transferring the
  -     // parameters, the element marker will be popped.
  -     // This keeps the stack in a consistent state.
  -     // It will also delete things left in the temp stack
  -     // as well.
  -     CommitPushElementFrame          thePusher(*this,
  -                                                                             
  targetTemplate);
  +     // parameters, the stack stays in a consistent state.
  +     CommitPushParams        thePusher(*this);
   
        XALAN_USING_STD(for_each)
   
  
  
  
  1.3       +32 -4     xml-xalan/c/src/xalanc/XSLT/VariablesStack.hpp
  
  Index: VariablesStack.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/VariablesStack.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- VariablesStack.hpp        2 Aug 2003 01:07:48 -0000       1.2
  +++ VariablesStack.hpp        4 Aug 2003 06:35:33 -0000       1.3
  @@ -193,12 +193,9 @@
         * popContextMarker() when you are done with the arguments.
         *
         * @param theParam The vector containing the parameters.
  -      * @param targetTemplate target template for the parameters
         */
        void
  -     pushParams(
  -                     const ParamsVectorType&         theParams,
  -                     const ElemTemplateElement*      targetTemplate);
  +     pushParams(const ParamsVectorType&      theParams);
   
        /**
         * Given a name, return a string representing the value, but don't look
  @@ -513,9 +510,40 @@
        typedef std::vector<StackEntry>         VariableStackStackType;
   #endif
   
  +     typedef VariableStackStackType::size_type       size_type;
  +
  +     size_type
  +     getStackSize() const
  +     {
  +             return m_stack.size();
  +     }
  +
        enum { eDefaultStackSize = 100 };
   
   private:
  +
  +     class CommitPushParams
  +     {
  +     public:
  +
  +             CommitPushParams(VariablesStack&        theVariablesStack);
  +
  +             ~CommitPushParams();
  +
  +             void
  +             commit()
  +             {
  +                     m_variablesStack = 0;
  +             }
  +
  +     private:
  +
  +             VariablesStack*         m_variablesStack;
  +
  +             size_type                       m_stackSize;
  +     };
  +
  +     friend class CommitPushParams;
   
        /**
         * Check to see if an element frame for the particular element has 
already
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to