xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbert...@apache.org
Subject cvs commit: xml-xalan/c/src/xalanc/XPath XPath.cpp XPath.hpp
Date Mon, 12 Apr 2004 00:37:06 GMT
dbertoni    2004/04/11 17:37:06

  Modified:    c/src/xalanc/XPath XPath.cpp XPath.hpp
  Log:
  Moved initialization code from constructor to discrete function.
  
  Revision  Changes    Path
  1.16      +60 -44    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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- XPath.cpp	6 Apr 2004 00:15:27 -0000	1.15
  +++ XPath.cpp	12 Apr 2004 00:37:06 -0000	1.16
  @@ -4952,15 +4952,60 @@
   	m_testFunction(&NodeTester::testDefault),
       m_testFunction2(&NodeTester::testDefault2)
   {
  +	const eMatchScore	theScore =
  +		initialize(
  +			theConstructionContext,
  +			theNameTest,
  +			thePrefixResolver,
  +			theLocator);
  +
  +	if (theMatchScore != 0)
  +	{
  +		*theMatchScore = theScore;
  +	}
  +}
  +    
  +
  +
  +XPath::NodeTester::NodeTester(
  +            const XalanDOMString&   theNamespaceURI,
  +            const XalanDOMString&   theLocalName,
  +            eMatchScore*            theMatchScore) :
  +	m_executionContext(0),
  +	m_targetNamespace(0),
  +	m_targetLocalName(0),
  +	m_testFunction(&NodeTester::testDefault),
  +    m_testFunction2(0)
  +{
  +	const eMatchScore	theScore =
  +		initialize(theNamespaceURI, theLocalName);
  +
  +	if (theMatchScore != 0)
  +	{
  +		*theMatchScore = theScore;
  +	}
  +}
  +
  +
  +
  +XPath::eMatchScore
  +XPath::NodeTester::initialize(
  +            XPathConstructionContext&	theConstructionContext,
  +            const XalanDOMString&       theNameTest,
  +            const PrefixResolver&       thePrefixResolver,
  +            const LocatorType*          theLocator)
  +{
   	const XalanDOMString::size_type     theLength =
                   length(theNameTest);
   
       if (theLength == 1 && theNameTest[0] == XPath::PSEUDONAME_ANY[0])
       {
  -		initialize(s_emptyString, s_emptyString, theMatchScore);
  +		return initialize(s_emptyString, s_emptyString);
       }
       else
       {
  +		eMatchScore		theResult = eMatchScoreNone;
  +
           const XalanDOMString::size_type     theIndex =
                   indexOf(theNameTest, XalanUnicode::charColon);
   
  @@ -4978,10 +5023,9 @@
               }
               else
               {
  -                initialize(
  +                theResult = initialize(
   					s_emptyString,
  -					theConstructionContext.getPooledString(theNameTest),
  -                    theMatchScore);
  +					theConstructionContext.getPooledString(theNameTest));
               }
           }
           else
  @@ -5021,10 +5065,9 @@
                            theNameTest[theIndex + 1] == XPath::PSEUDONAME_ANY[0])
                   {
                       // It's of the form "NCName:*"
  -					initialize(
  +					theResult = initialize(
                           theConstructionContext.getPooledString(*theNamespaceURI),
  -                        s_emptyString,
  -                        theMatchScore);
  +                        s_emptyString);
                   }
                   else
                   {
  @@ -5042,39 +5085,24 @@
                       else
                       {
                           // It's of the form "NCName:NCName"
  -						initialize(
  +						theResult = initialize(
                               theConstructionContext.getPooledString(*theNamespaceURI),
  -                            theConstructionContext.getPooledString(theScratchString),
  -                            theMatchScore);
  +                            theConstructionContext.getPooledString(theScratchString));
                       }
                   }
               }
           }
  -    }
  -}
  -    
  -
   
  -XPath::NodeTester::NodeTester(
  -            const XalanDOMString&   theNamespaceURI,
  -            const XalanDOMString&   theLocalName,
  -            eMatchScore*            theMatchScore) :
  -	m_executionContext(0),
  -	m_targetNamespace(0),
  -	m_targetLocalName(0),
  -	m_testFunction(&NodeTester::testDefault),
  -    m_testFunction2(0)
  -{
  -	initialize(theNamespaceURI, theLocalName, theMatchScore);
  +		return theResult;
  +    }
   }
   
   
   
  -void
  +XPath::eMatchScore
   XPath::NodeTester::initialize(
               const XalanDOMString&   theNamespaceURI,
  -            const XalanDOMString&   theLocalName,
  -            eMatchScore*            theMatchScore)
  +            const XalanDOMString&   theLocalName)
   {
       if (theNamespaceURI.empty() == false)
       {
  @@ -5084,10 +5112,7 @@
           {
               m_testFunction2 = &NodeTester::testElementNamespaceOnly2;
   
  -			if (theMatchScore != 0)
  -			{
  -				*theMatchScore = eMatchScoreNSWild;
  -			}
  +			return eMatchScoreNSWild;
           }
           else
           {
  @@ -5095,10 +5120,7 @@
   
   			m_targetLocalName = &theLocalName;
   
  -			if (theMatchScore != 0)
  -			{
  -				*theMatchScore = eMatchScoreQName;
  -			}
  +			return eMatchScoreQName;
           }
       }
       else if (theLocalName.empty() == false)
  @@ -5107,19 +5129,13 @@
   
           m_targetLocalName = &theLocalName;
   
  -		if (theMatchScore != 0)
  -		{
  -			*theMatchScore = eMatchScoreQName;
  -		}
  +		return eMatchScoreQName;
       }
       else
       {
           m_testFunction2 = &NodeTester::testElementTotallyWild2;
   
  -		if (theMatchScore != 0)
  -		{
  -			*theMatchScore = eMatchScoreNodeTest;
  -		}
  +		return eMatchScoreNodeTest;
       }
   }
   
  
  
  
  1.10      +12 -4     xml-xalan/c/src/xalanc/XPath/XPath.hpp
  
  Index: XPath.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPath.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XPath.hpp	6 Apr 2004 00:15:27 -0000	1.9
  +++ XPath.hpp	12 Apr 2004 00:37:06 -0000	1.10
  @@ -1083,13 +1083,21 @@
   			return *this;
   		}
   
  -	private:
  +	protected:
  +
  +		eMatchScore
  +		initialize(
  +            XPathConstructionContext&	theConstructionContext,
  +            const XalanDOMString&       theNameTest,
  +            const PrefixResolver&       thePrefixResolver,
  +            const LocatorType*          theLocator);
   
  -		void
  +		eMatchScore
   		initialize(
               const XalanDOMString&   theNamespaceURI,
  -            const XalanDOMString&   theLocalName,
  -            eMatchScore*            theMatchScore = 0);
  +            const XalanDOMString&   theLocalName);
  +
  +	private:
   
   
   		typedef eMatchScore (NodeTester::*TestFunctionPtr)(const XalanNode&, XalanNode::NodeType)
const;
  
  
  

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


Mime
View raw message