dbertoni    01/02/03 21:43:36

  Modified:    c/src/XSLT VariablesStack.cpp VariablesStack.hpp
  Log:
  Fixed bug with xsl:with-param with no matching xsl:param in the called 
template.  Fixes variable26.
  
  Revision  Changes    Path
  1.12      +87 -16    xml-xalan/c/src/XSLT/VariablesStack.cpp
  
  Index: VariablesStack.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/VariablesStack.cpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- VariablesStack.cpp        2001/01/26 23:01:51     1.11
  +++ VariablesStack.cpp        2001/02/04 05:43:35     1.12
  @@ -145,10 +145,10 @@
   
        for(int i = (nElems - 1); i >= 0 && m_stack.empty() == false; --i)
        {
  -             const StackEntry&       theEntry = m_stack[i];
  +             const StackEntry&                       theEntry = m_stack[i];
                assert(theEntry == back());
   
  -             const StackEntry::eStackEntryType       type = 
theEntry.getType();
  +             const StackEntry::eType         type = theEntry.getType();
                assert(type < StackEntry::eNextValue && type >= 0);
   
                pop();
  @@ -244,13 +244,13 @@
   
        if (theEntry.m_value.null() == false)
        {
  -             
m_variablesStack.push(VariablesStack::StackEntry(theEntry.m_qname, 
theEntry.m_value));
  +             
m_variablesStack.push(VariablesStack::StackEntry(theEntry.m_qname, 
theEntry.m_value, true));
        }
        else
        {
                assert(theEntry.m_variable != 0);
   
  -             
m_variablesStack.push(VariablesStack::StackEntry(theEntry.m_qname, 
theEntry.m_variable));
  +             
m_variablesStack.push(VariablesStack::StackEntry(theEntry.m_qname, 
theEntry.m_variable, true));
        }
   }
   
  @@ -322,6 +322,31 @@
   
   
   void
  +VariablesStack::resetParams()
  +{
  +     const unsigned int      nElems = getCurrentStackFrameIndex();
  +
  +     // There is guaranteed to be a context marker at
  +     // the bottom of the stack, so i should stop at
  +     // 1.
  +     for(unsigned int i = nElems - 1; i > 0; --i)
  +     {
  +             StackEntry&             theEntry = m_stack[i];
  +
  +             if(theEntry.getType() == StackEntry::eContextMarker)
  +             {
  +                     break;
  +             }
  +             else
  +             {
  +                     theEntry.deactivate();
  +             }
  +     }
  +}
  +
  +
  +
  +void
   VariablesStack::markGlobalStackFrame()
   {
        m_globalStackFrameIndex = m_stack.size();
  @@ -362,11 +387,12 @@
   VariablesStack::findXObject(
                        const QName&                                    name,
                        StylesheetExecutionContext&             
executionContext,
  +                     bool                                                    
fIsParam,
                        bool                                                    
fSearchGlobalSpace,
                        bool&                                                   
fNameFound)
   {
        StackEntry* const       theEntry =
  -             findEntry(name, fSearchGlobalSpace);
  +             findEntry(name, fIsParam, fSearchGlobalSpace);
   
        if (theEntry == 0)
        {
  @@ -378,7 +404,9 @@
        {
                fNameFound = true;
   
  -             assert(theEntry->getType() == StackEntry::eVariable);
  +             assert(theEntry->getType() == StackEntry::eVariable ||
  +                        theEntry->getType() == StackEntry::eParam ||
  +                        theEntry->getType() == StackEntry::eActiveParam);
   
                const XObjectPtr&       theValue = theEntry->getValue();
   
  @@ -403,6 +431,7 @@
                                assert(theNewValue.null() == false);
   
                                theEntry->setValue(theNewValue);
  +                             theEntry->activate();
                        }
   
                        return theNewValue;
  @@ -415,6 +444,7 @@
   VariablesStack::StackEntry*
   VariablesStack::findEntry(
                        const QName&    qname,
  +                     bool                    fIsParam,
                        bool                    fSearchGlobalSpace)
   {
        StackEntry*             theResult = 0;
  @@ -428,9 +458,12 @@
                // 1.
                for(unsigned int i = nElems - 1; i > 0; --i)
                {
  -                     StackEntry&             theEntry = m_stack[i];
  +                     StackEntry&                                     
theEntry = m_stack[i];
   
  -                     if(theEntry.getType() == StackEntry::eVariable)
  +                     const StackEntry::eType         theType = 
theEntry.getType();
  +
  +                     if(theType == StackEntry::eVariable ||
  +                        theType == StackEntry::eActiveParam)
                        {
                                assert(theEntry.getName() != 0);
   
  @@ -441,6 +474,20 @@
                                        break;
                                }
                        }
  +                     else if (theType == StackEntry::eParam)
  +                     {
  +                             if (fIsParam == true)
  +                             {
  +                                     if(theEntry.getName()->equals(qname))
  +                                     {
  +                                             theEntry.activate();
  +
  +                                             theResult = &theEntry;
  +
  +                                             break;
  +                                     }
  +                             }
  +                     }
                        else if(theEntry.getType() == 
StackEntry::eContextMarker)
                        {
                                break;
  @@ -448,7 +495,7 @@
                }
        }
   
  -     if(0 == theResult && true == fSearchGlobalSpace && 
m_globalStackFrameIndex > 1)
  +     if(0 == theResult && fIsParam == false && true == fSearchGlobalSpace && 
m_globalStackFrameIndex > 1)
        {
                // Look in the global space
                for(unsigned int i = m_globalStackFrameIndex - 1; i > 0; i--)
  @@ -552,9 +599,10 @@
   
   
   VariablesStack::StackEntry::StackEntry(
  -             const QName*            name,
  -             const XObjectPtr&       val) :
  -     m_type(eVariable),
  +                     const QName*            name,
  +                     const XObjectPtr&       val,
  +                     bool                            isParam) :
  +     m_type(isParam == true ? eParam : eVariable),
        m_qname(name),
        m_value(val),
        m_variable(0),
  @@ -566,8 +614,9 @@
   
   VariablesStack::StackEntry::StackEntry(
                        const QName*                    name,
  -                     const ElemVariable*             var) :
  -     m_type(eVariable),
  +                     const ElemVariable*             var,
  +                     bool                                    isParam) :
  +     m_type(isParam == true ? eParam : eVariable),
        m_qname(name),
        m_value(),
        m_variable(var),
  @@ -612,7 +661,7 @@
   {
        m_type = theRHS.m_type;
   
  -     if (m_type == eVariable)
  +     if (m_type == eVariable || m_type == eParam || m_type == eActiveParam)
        {
                m_qname = theRHS.m_qname;
   
  @@ -654,7 +703,7 @@
                                fResult = true;
                        }
                }
  -             else if (m_type == eVariable)
  +             else if (m_type == eVariable || m_type == eParam || m_type == 
eActiveParam)
                {
                        // We only need to compare the variable related 
members...
                        if (m_value == theRHS.m_value ||
  @@ -677,6 +726,28 @@
        }
   
        return fResult;
  +}
  +
  +
  +
  +void
  +VariablesStack::StackEntry::activate()
  +{
  +     if (m_type == eParam)
  +     {
  +             m_type = eActiveParam;
  +     }
  +}
  +
  +
  +
  +void
  +VariablesStack::StackEntry::deactivate()
  +{
  +     if (m_type == eActiveParam)
  +     {
  +             m_type = eParam;
  +     }
   }
   
   
  
  
  
  1.9       +28 -10    xml-xalan/c/src/XSLT/VariablesStack.hpp
  
  Index: VariablesStack.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/VariablesStack.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- VariablesStack.hpp        2001/01/16 02:38:12     1.8
  +++ VariablesStack.hpp        2001/02/04 05:43:35     1.9
  @@ -208,7 +208,7 @@
                        StylesheetExecutionContext&             
executionContext,
                        bool&                                                   
fNameFound)
        {
  -             return findXObject(qname, executionContext, false, fNameFound);
  +             return findXObject(qname, executionContext, true, false, 
fNameFound);
        }
   
        /**
  @@ -226,7 +226,7 @@
                        StylesheetExecutionContext&             
executionContext,
                        bool&                                                   
fNameFound)
        {
  -             return findXObject(qname, executionContext, true, fNameFound);
  +             return findXObject(qname, executionContext, false, true, 
fNameFound);
        }
   
        /**
  @@ -266,6 +266,12 @@
        start();
   
        /**
  +      * Reset all params in the current stack frame.
  +      */
  +     void
  +     resetParams();
  +
  +     /**
         * Mark the top of the global stack frame.
         */
        void
  @@ -383,10 +389,12 @@
                 * Enumeration for types of stack entries, one of context 
state, context
                 * marker, element marker, or argument.
                 */
  -             enum eStackEntryType { eContextMarker,
  -                                                        eVariable,
  -                                                        eElementFrameMarker,
  -                                                        eNextValue };
  +             enum eType { eContextMarker,
  +                                 eVariable,
  +                                     eParam,
  +                                     eActiveParam,
  +                                     eElementFrameMarker,
  +                                     eNextValue };
   
                /**
                 * Construct a context marker.
  @@ -399,14 +407,16 @@
                 */
                StackEntry(
                        const QName*            name,
  -                     const XObjectPtr&       val);
  +                     const XObjectPtr&       val,
  +                     bool                            isParam = false);
   
                /**
                 * Construct a variable that has not been evaluated yet.
                 */
                StackEntry(
                        const QName*                    name,
  -                     const ElemVariable*             var);
  +                     const ElemVariable*             var,
  +                     bool                                    isParam = 
false);
   
                /**
                 * Construct an element frame marker.
  @@ -429,7 +439,7 @@
                 * 
                 * @return enumeration value for type
                 */
  -             eStackEntryType
  +             eType
                getType() const
                {
                        return m_type;
  @@ -479,6 +489,12 @@
                        return m_variable;
                }
   
  +             void
  +             activate();
  +
  +             void
  +             deactivate();
  +
                /**
                 * Retrieve the ElemTemplateElem where frame begins.  Valid 
only for element frame markers
                 *
  @@ -499,7 +515,7 @@
        private:
   
                // Data members...
  -             eStackEntryType                         m_type;
  +             eType                                           m_type;
   
                const QName*                            m_qname;
   
  @@ -523,12 +539,14 @@
        findXObject(
                        const QName&                                    name,
                        StylesheetExecutionContext&             
executionContext,
  +                     bool                                                    
fIsParam,
                        bool                                                    
fSearchGlobalSpace,
                        bool&                                                   
fNameFound);
   
        StackEntry*
        findEntry(
                        const QName&    name,
  +                     bool                    fIsParam,
                        bool                    fSearchGlobalSpace);
   
   
  
  
  

Reply via email to