You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2003/08/02 03:06:52 UTC

cvs commit: xml-xalan/c/src/xalanc/XPath XPath.cpp XPathExecutionContext.hpp XPathExecutionContextDefault.cpp XPathExecutionContextDefault.hpp

dbertoni    2003/08/01 18:06:52

  Modified:    c/src/xalanc/XPath XPath.cpp XPathExecutionContext.hpp
                        XPathExecutionContextDefault.cpp
                        XPathExecutionContextDefault.hpp
  Log:
  Implement current node as a stack within the execution context.  This will help implement preventing stack overflow and takes stress off the processor stack.
  
  Revision  Changes    Path
  1.4       +6 -6      xml-xalan/c/src/xalanc/XPath/XPath.cpp
  
  Index: XPath.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPath.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XPath.cpp	30 Jul 2003 15:45:26 -0000	1.3
  +++ XPath.cpp	2 Aug 2003 01:06:51 -0000	1.4
  @@ -160,7 +160,7 @@
   									&prefixResolver);
   
   	// Push and pop the current node...
  -	XPathExecutionContext::CurrentNodeSetAndRestore		theNodeSetAndRestore(
  +	XPathExecutionContext::CurrentNodePushAndPop		theNodePushAndPop(
   									executionContext,
   									context);
   
  @@ -184,7 +184,7 @@
   									&prefixResolver);
   
   	// Push and pop the current node...
  -	XPathExecutionContext::CurrentNodeSetAndRestore		theNodeSetAndRestore(
  +	XPathExecutionContext::CurrentNodePushAndPop		theNodePushAndPop(
   									executionContext,
   									context);
   
  @@ -208,7 +208,7 @@
   									&prefixResolver);
   
   	// Push and pop the current node...
  -	XPathExecutionContext::CurrentNodeSetAndRestore		theNodeSetAndRestore(
  +	XPathExecutionContext::CurrentNodePushAndPop		theNodePushAndPop(
   									executionContext,
   									context);
   
  @@ -232,7 +232,7 @@
   									&prefixResolver);
   
   	// Push and pop the current node...
  -	XPathExecutionContext::CurrentNodeSetAndRestore		theNodeSetAndRestore(
  +	XPathExecutionContext::CurrentNodePushAndPop		theNodePushAndPop(
   									executionContext,
   									context);
   
  @@ -257,7 +257,7 @@
   									&prefixResolver);
   
   	// Push and pop the current node...
  -	XPathExecutionContext::CurrentNodeSetAndRestore		theNodeSetAndRestore(
  +	XPathExecutionContext::CurrentNodePushAndPop		theNodePushAndPop(
   									executionContext,
   									context);
   
  @@ -282,7 +282,7 @@
   									&prefixResolver);
   
   	// Push and pop the current node...
  -	XPathExecutionContext::CurrentNodeSetAndRestore		theNodeSetAndRestore(
  +	XPathExecutionContext::CurrentNodePushAndPop		theNodePushAndPop(
   									executionContext,
   									context);
   
  
  
  
  1.2       +13 -21    xml-xalan/c/src/xalanc/XPath/XPathExecutionContext.hpp
  
  Index: XPathExecutionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathExecutionContext.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XPathExecutionContext.hpp	29 Jun 2003 03:58:00 -0000	1.1
  +++ XPathExecutionContext.hpp	2 Aug 2003 01:06:52 -0000	1.2
  @@ -146,42 +146,34 @@
   	 * @param theCurrentNode new current node
   	 */
   	virtual void
  -	setCurrentNode(XalanNode*	theCurrentNode) = 0;
  +	pushCurrentNode(XalanNode*	theCurrentNode) = 0;
   
  -	class CurrentNodeSetAndRestore
  +	/**
  +	 * Reset the node currently being executed.
  +	 */
  +	virtual void
  +	popCurrentNode() = 0;
  +
  +	class CurrentNodePushAndPop
   	{
   	public:
   
  -		CurrentNodeSetAndRestore(
  +		CurrentNodePushAndPop(
   				XPathExecutionContext&	theExecutionContext,
   				XalanNode*				theNewNode) :
  -			m_executionContext(theExecutionContext),
  -			m_savedNode(theExecutionContext.getCurrentNode())
  +			m_executionContext(theExecutionContext)
   		{
  -			theExecutionContext.setCurrentNode(theNewNode);
  -		}
  -
  -		CurrentNodeSetAndRestore(
  -				XPathExecutionContext&	theExecutionContext,
  -				XalanNode*				theOldNode,
  -				XalanNode*				theNewNode) :
  -			m_executionContext(theExecutionContext),
  -			m_savedNode(theOldNode)
  -		{
  -			assert(theExecutionContext.getCurrentNode() == theOldNode);
  -
  -			theExecutionContext.setCurrentNode(theNewNode);
  +			theExecutionContext.pushCurrentNode(theNewNode);
   		}
   
  -		~CurrentNodeSetAndRestore()
  +		~CurrentNodePushAndPop()
   		{
  -			m_executionContext.setCurrentNode(m_savedNode);
  +			m_executionContext.popCurrentNode();
   		}
   
   	private:
   
   		XPathExecutionContext&	m_executionContext;
  -		XalanNode* const		m_savedNode;
   	};
   
   	/**
  
  
  
  1.2       +17 -6     xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.cpp
  
  Index: XPathExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XPathExecutionContextDefault.cpp	29 Jun 2003 03:58:00 -0000	1.1
  +++ XPathExecutionContextDefault.cpp	2 Aug 2003 01:06:52 -0000	1.2
  @@ -104,7 +104,7 @@
   	XPathExecutionContext(&theXObjectFactory),
   	m_xpathEnvSupport(&theXPathEnvSupport),
   	m_domSupport(&theDOMSupport),
  -	m_currentNode(theCurrentNode),
  +	m_currentNodeStack(),
   	m_contextNodeList(theContextNodeList == 0 ? &s_dummyList : theContextNodeList),
   	m_prefixResolver(thePrefixResolver),
   	m_throwFoundIndex(false),
  @@ -113,6 +113,7 @@
   	m_cachedPosition(),
   	m_scratchQName()
   {
  +	m_currentNodeStack.push_back(theCurrentNode);
   }
   
   
  @@ -124,7 +125,7 @@
   	XPathExecutionContext(),
   	m_xpathEnvSupport(0),
   	m_domSupport(0),
  -	m_currentNode(theCurrentNode),
  +	m_currentNodeStack(),
   	m_contextNodeList(theContextNodeList == 0 ? &s_dummyList : theContextNodeList),
   	m_prefixResolver(thePrefixResolver),
   	m_throwFoundIndex(false),
  @@ -133,6 +134,7 @@
   	m_cachedPosition(),
   	m_scratchQName()
   {
  +	m_currentNodeStack.push_back(theCurrentNode);
   }
   
   
  @@ -163,7 +165,8 @@
   		m_xobjectFactory->reset();
   	}
   
  -	m_currentNode = 0;
  +	m_currentNodeStack.clear();
  +
   	m_contextNodeList = &s_dummyList;
   	m_prefixResolver = 0;
   	m_throwFoundIndex = false;
  @@ -180,15 +183,23 @@
   XalanNode*
   XPathExecutionContextDefault::getCurrentNode() const
   {
  -	return m_currentNode;
  +	return m_currentNodeStack.back();
  +}
  +
  +
  +
  +void
  +XPathExecutionContextDefault::pushCurrentNode(XalanNode*	theCurrentNode)
  +{
  +	m_currentNodeStack.push_back(theCurrentNode);
   }
   
   
   
   void
  -XPathExecutionContextDefault::setCurrentNode(XalanNode*		theCurrentNode)
  +XPathExecutionContextDefault::popCurrentNode()
   {
  -	m_currentNode = theCurrentNode;
  +	m_currentNodeStack.pop_back();
   }
   
   
  
  
  
  1.2       +11 -2     xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.hpp
  
  Index: XPathExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XPathExecutionContextDefault.hpp	29 Jun 2003 03:58:00 -0000	1.1
  +++ XPathExecutionContextDefault.hpp	2 Aug 2003 01:06:52 -0000	1.2
  @@ -112,6 +112,12 @@
   {
   public:
   
  +#if defined(XALAN_NO_STD_NAMESPACE)
  +	typedef deque<XalanNode*>			CurrentNodeStackType;
  +#else
  +	typedef std::deque<XalanNode*>		CurrentNodeStackType;
  +#endif
  +
   	/**
   	 * Construct an XPathExecutionContextDefault object
   	 *
  @@ -217,7 +223,10 @@
   	getCurrentNode() const;
   
   	virtual void
  -	setCurrentNode(XalanNode*		theCurrentNode);
  +	pushCurrentNode(XalanNode*		theCurrentNode);
  +
  +	virtual void
  +	popCurrentNode();
   
   	virtual bool
   	isNodeAfter(
  @@ -408,7 +417,7 @@
   
   	DOMSupport*								m_domSupport;
   
  -	XalanNode*								m_currentNode;
  +	CurrentNodeStackType					m_currentNodeStack;
   
   	const NodeRefListBase*					m_contextNodeList;
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org