dbertoni    00/07/25 07:54:35

  Modified:    c/src/XSLT VariablesStack.cpp VariablesStack.hpp
  Log:
  Hold a pointer to QName instead of an instance in a stack entry.  Re-arranged 
data members to make things clearer.
  
  Revision  Changes    Path
  1.3       +34 -47    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- VariablesStack.cpp        2000/07/21 19:52:57     1.2
  +++ VariablesStack.cpp        2000/07/25 14:54:33     1.3
  @@ -280,6 +280,8 @@
        const void
        operator()(const VariablesStack::ParamsVectorType::value_type&  
theEntry)
        {
  +             assert(theEntry.first != 0);
  +
                
m_variablesStack.push(VariablesStack::StackEntry(theEntry.first, 
theEntry.second));
        }
   
  @@ -327,7 +329,7 @@
                pushElementFrame(e);
        }
   
  -     push(StackEntry(name, val));
  +     push(StackEntry(&name, val));
   }
   
   
  @@ -389,7 +391,9 @@
   
                if(theEntry.getType() == StackEntry::eVariable)
                {
  -                     if(theEntry.getName().equals(qname))
  +                     assert(theEntry.getName() != 0);
  +
  +                     if(theEntry.getName()->equals(qname))
                        {
                                theResult = &theEntry;
   
  @@ -411,7 +415,9 @@
   
                        if(theEntry.getType() == StackEntry::eVariable)
                        {
  -                             if(theEntry.getName().equals(qname))
  +                             assert(theEntry.getName() != 0);
  +
  +                             if(theEntry.getName()->equals(qname))
                                {
                                        theResult = &theEntry;
   
  @@ -494,51 +500,36 @@
   
   
   VariablesStack::StackEntry::StackEntry() :
  -     m_type(eContextMarker),
  -     m_qname(),
  -     m_variable(0)
  +     m_type(eContextMarker)
   {
   }
   
   
   
   VariablesStack::StackEntry::StackEntry(
  -             const QName&    name,
  +             const QName*    name,
                XObject*                val) :
  -     m_type(eVariable),
  -     m_qname(name),
  -     m_variable(val)
  +     m_type(eVariable)
   {
  +     variable.m_qname = name;
  +     variable.m_value = val;
   }
   
   
   
  -VariablesStack::StackEntry::StackEntry(const ElemTemplateElement*            
elem) :
  -     m_type(eElementFrameMarker),
  -     m_qname(),
  -     m_element(elem)
  +VariablesStack::StackEntry::StackEntry(const ElemTemplateElement*    elem) :
  +     m_type(eElementFrameMarker)
   {
  +     elementMarker.m_element = elem;
   }
   
   
   
   VariablesStack::StackEntry::StackEntry(const StackEntry&     theSource) :
  -     m_type(theSource.m_type),
  -     m_qname(theSource.m_qname),
  -     m_variable(0)
  +     m_type(theSource.m_type)
   {
  -     if (theSource.m_type == eVariable)
  -     {
  -             m_variable = theSource.m_variable;
  -     }
  -     else if (theSource.m_type == eElementFrameMarker)
  -     {
  -             m_element = theSource.m_element;
  -     }
  -     else
  -     {
  -             m_variable = 0;
  -     }
  +     // Use operator=() to do the work...
  +     *this = theSource;
   }
   
   
  @@ -552,23 +543,17 @@
   VariablesStack::StackEntry&
   VariablesStack::StackEntry::operator=(const StackEntry&              theRHS)
   {
  -     if (&theRHS != this)
  +     m_type = theRHS.m_type;
  +
  +     if (m_type == eVariable)
        {
  -             m_type = theRHS.m_type;
  -             m_qname = theRHS.m_qname;
  +             variable.m_qname = theRHS.variable.m_qname;
   
  -             if (m_type == eVariable)
  -             {
  -                     m_variable = theRHS.m_variable;
  -             }
  -             else if (m_type == eElementFrameMarker)
  -             {
  -                     m_element = theRHS.m_element;
  -             }
  -             else
  -             {
  -                     m_variable = 0;
  -             }
  +             variable.m_value = theRHS.variable.m_value;
  +     }
  +     else if (m_type == eElementFrameMarker)
  +     {
  +             elementMarker.m_element = theRHS.elementMarker.m_element;
        }
   
        return *this;
  @@ -576,6 +561,8 @@
   
   
   
  +// Equality for StackEntry instances is probably bogus,
  +// so it might be worthwhile to just get rid of this.
   bool
   VariablesStack::StackEntry::operator==(const StackEntry&     theRHS) const
   {
  @@ -592,15 +579,15 @@
                }
                else if (m_type == eVariable)
                {
  -                     if (m_qname == theRHS.m_qname &&
  -                             m_variable == theRHS.m_variable)
  +                     // We only need to compare the variable pointer..
  +                     if (variable.m_value == theRHS.variable.m_value)
                        {
                                fResult = true;
                        }
                }
                else if (m_type == eElementFrameMarker)
                {
  -                     if (m_element == theRHS.m_element)
  +                     if (elementMarker.m_element == 
theRHS.elementMarker.m_element)
                        {
                                fResult = true;
                        }
  
  
  
  1.2       +18 -12    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- VariablesStack.hpp        2000/07/21 19:46:11     1.1
  +++ VariablesStack.hpp        2000/07/25 14:54:33     1.2
  @@ -140,9 +140,9 @@
        popContextMarker();
   
   #if defined(XALAN_NO_NAMESPACES)
  -     typedef vector<pair<QName, XObject*> >                          
ParamsVectorType;
  +     typedef vector<pair<const QName*, XObject*> >                           
ParamsVectorType;
   #else
  -     typedef std::vector<std::pair<QName, XObject*> >        
ParamsVectorType;
  +     typedef std::vector<std::pair<const QName*, XObject*> >         
ParamsVectorType;
   #endif
   
        /**
  @@ -320,7 +320,7 @@
                 * Construct a variable.
                 */
                StackEntry(
  -                     const QName&    name,
  +                     const QName*    name,
                        XObject*                val);
   
                /**
  @@ -355,10 +355,10 @@
                 * 
                 * @return qualified name of object
                 */
  -             const QName&
  +             const QName*
                getName() const
                {
  -                     return m_qname;
  +                     return variable.m_qname;
                }
   
                /**
  @@ -369,7 +369,7 @@
                XObject*
                getVariable() const
                {
  -                     return m_variable;
  +                     return variable.m_value;
                }
   
                /**
  @@ -380,7 +380,7 @@
                const ElemTemplateElement*
                getElement() const
                {
  -                     return m_element;
  +                     return elementMarker.m_element;
                }
   
                StackEntry&
  @@ -394,13 +394,19 @@
                // Data members...
                eStackEntryType                         m_type;
   
  -             QName                                           m_qname;
  -
                union
                {
  -                     XObject*                                        
m_variable;
  -
  -                     const ElemTemplateElement*      m_element;
  +                     struct
  +                     {
  +                             const QName*                            m_qname;
  +
  +                             XObject*                                        
m_value;
  +                     } variable;
  +
  +                     struct
  +                     {
  +                             const ElemTemplateElement*      m_element;
  +                     } elementMarker;
                };
        };
   
  
  
  

Reply via email to