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/XPath XPath.cpp XPath.hpp XPathExpression.cpp XPathExpression.hpp XPathProcessorImpl.cpp XPathProcessorImpl.hpp
Date Fri, 03 Jan 2003 08:04:25 GMT
dbertoni    2003/01/03 00:04:25

  Modified:    c/src/XPath XPath.cpp XPath.hpp XPathExpression.cpp
                        XPathExpression.hpp XPathProcessorImpl.cpp
                        XPathProcessorImpl.hpp
  Log:
  New code to "inline" more XPath functions.
  
  Revision  Changes    Path
  1.85      +560 -94   xml-xalan/c/src/XPath/XPath.cpp
  
  Index: XPath.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.cpp,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- XPath.cpp	2 Jan 2003 17:39:08 -0000	1.84
  +++ XPath.cpp	3 Jan 2003 08:04:24 -0000	1.85
  @@ -153,6 +153,8 @@
   			const PrefixResolver&	prefixResolver,
   			XPathExecutionContext&	executionContext) const
   {
  +	assert(context != 0);
  +
   	// Push and pop the PrefixResolver...
   	XPathExecutionContext::PrefixResolverSetAndRestore	theResolverSetAndRestore(
   									executionContext,
  @@ -175,6 +177,8 @@
   			XPathExecutionContext&	executionContext,
   			bool&					result) const
   {
  +	assert(context != 0);
  +
   	// Push and pop the PrefixResolver...
   	XPathExecutionContext::PrefixResolverSetAndRestore	theResolverSetAndRestore(
   									executionContext,
  @@ -197,6 +201,8 @@
   			XPathExecutionContext&	executionContext,
   			double&					result) const
   {
  +	assert(context != 0);
  +
   	// Push and pop the PrefixResolver...
   	XPathExecutionContext::PrefixResolverSetAndRestore	theResolverSetAndRestore(
   									executionContext,
  @@ -219,6 +225,8 @@
   			XPathExecutionContext&	executionContext,
   			XalanDOMString&			result) const
   {
  +	assert(context != 0);
  +
   	// Push and pop the PrefixResolver...
   	XPathExecutionContext::PrefixResolverSetAndRestore	theResolverSetAndRestore(
   									executionContext,
  @@ -242,6 +250,8 @@
   			FormatterListener&		formatterListener,
   			MemberFunctionPtr		function) const
   {
  +	assert(context != 0);
  +
   	// Push and pop the PrefixResolver...
   	XPathExecutionContext::PrefixResolverSetAndRestore	theResolverSetAndRestore(
   									executionContext,
  @@ -264,6 +274,9 @@
   			XPathExecutionContext&	executionContext,
   			MutableNodeRefList&		result) const
   {
  +	assert(context != 0);
  +	assert(result.empty() == true);
  +
   	// Push and pop the PrefixResolver...
   	XPathExecutionContext::PrefixResolverSetAndRestore	theResolverSetAndRestore(
   									executionContext,
  @@ -367,10 +380,6 @@
   		return numberlit(opPos, executionContext);
   		break;
   
  -	case XPathExpression::eOP_ARGUMENT:
  -		return arg(context, opPos, executionContext);
  -		break;
  -
   	case XPathExpression::eOP_EXTFUNCTION:
   		return runExtFunction(context, opPos, executionContext);
   		break;
  @@ -384,17 +393,77 @@
   		break;
   
   	case XPathExpression::eOP_FUNCTION_POSITION:
  -		return functionPositionGeneric(context, executionContext);
  +		return executionContext.getXObjectFactory().createNumber(functionPosition(context, executionContext));
   		break;
   
   	case XPathExpression::eOP_FUNCTION_LAST:
  -		return functionLastGeneric(executionContext);
  +		return executionContext.getXObjectFactory().createNumber(functionLast(executionContext));
   		break;
   
   	case XPathExpression::eOP_FUNCTION_COUNT:
  -		return functionCountGeneric(context, opPos, executionContext);
  +		return executionContext.getXObjectFactory().createNumber(functionCount(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NOT:
  +		return executionContext.getXObjectFactory().createBoolean(functionNot(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_TRUE:
  +		return executionContext.getXObjectFactory().createBoolean(true);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_FALSE:
  +		return executionContext.getXObjectFactory().createBoolean(false);
   		break;
   
  +	case XPathExpression::eOP_FUNCTION_BOOLEAN:
  +		return executionContext.getXObjectFactory().createBoolean(functionBoolean(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NAME_0:
  +		return executionContext.getXObjectFactory().createStringReference(functionName(context));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NAME_1:
  +		return executionContext.getXObjectFactory().createStringReference(functionName(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_0:
  +		return executionContext.getXObjectFactory().createStringReference(functionLocalName(context));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_1:
  +		return executionContext.getXObjectFactory().createStringReference(functionLocalName(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_FLOOR:
  +		return executionContext.getXObjectFactory().createNumber(functionFloor(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_CEILING:
  +		return executionContext.getXObjectFactory().createNumber(functionCeiling(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_ROUND:
  +		return executionContext.getXObjectFactory().createNumber(functionRound(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NUMBER_0:
  +		return executionContext.getXObjectFactory().createNumber(functionNumber(context, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NUMBER_1:
  +		return executionContext.getXObjectFactory().createNumber(functionNumber(context, opPos, executionContext));
  +		break;
  +
  +//	case XPathExpression::eOP_FUNCTION_STRING_0:
  +//		return functionString(context);
  +//		break;
  +
  +//	case XPathExpression::eOP_FUNCTION_STRING_1:
  +//		return functionString(context, opPos, executionContext);
  +//		break;
  +
   	default:
   		unknownOpCodeError(context, executionContext, opPos);
   		break;
  @@ -475,11 +544,11 @@
   		break;
   
   	case XPathExpression::eOP_UNION:
  -		result = Union(context, opPos, executionContext)->boolean();
  +		Union(context, opPos, executionContext, result);
   		break;
   
   	case XPathExpression::eOP_LITERAL:
  -		result = literal(opPos, executionContext)->boolean();
  +		literal(opPos, result);
   		break;
   
   	case XPathExpression::eOP_VARIABLE:
  @@ -487,15 +556,11 @@
   		break;
   
   	case XPathExpression::eOP_GROUP:
  -		result = group(context, opPos, executionContext)->boolean();
  +		group(context, opPos, executionContext, result);
   		break;
   
   	case XPathExpression::eOP_NUMBERLIT:
  -		result = XObject::boolean(numberlit(opPos));
  -		break;
  -
  -	case XPathExpression::eOP_ARGUMENT:
  -		result = arg(context, opPos, executionContext)->boolean();
  +		numberlit(opPos, result);
   		break;
   
   	case XPathExpression::eOP_EXTFUNCTION:
  @@ -507,7 +572,7 @@
   		break;
   
   	case XPathExpression::eOP_LOCATIONPATH:
  -		result = locationPath(context, opPos, executionContext)->boolean();
  +		locationPath(context, opPos, executionContext, result);
   		break;
   
   	case XPathExpression::eOP_FUNCTION_POSITION:
  @@ -522,6 +587,58 @@
   		result = XObject::boolean(functionCount(context, opPos, executionContext));
   		break;
   
  +	case XPathExpression::eOP_FUNCTION_NOT:
  +		result = functionNot(context, opPos, executionContext);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_TRUE:
  +		result = true;
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_FALSE:
  +		result = false;
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_BOOLEAN:
  +		result = functionBoolean(context, opPos, executionContext);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NAME_0:
  +		result = XObject::boolean(functionName(context));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NAME_1:
  +		result = XObject::boolean(functionName(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_0:
  +		result = XObject::boolean(functionLocalName(context));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_1:
  +		result = XObject::boolean(functionLocalName(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_FLOOR:
  +		result = XObject::boolean(functionFloor(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_CEILING:
  +		result = XObject::boolean(functionCeiling(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_ROUND:
  +		result = XObject::boolean(functionRound(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NUMBER_0:
  +		result = XObject::boolean(functionNumber(context, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NUMBER_1:
  +		result = XObject::boolean(functionNumber(context, opPos, executionContext));
  +		break;
  +
   	default:
   		unknownOpCodeError(context, executionContext, opPos);
   		break;
  @@ -600,11 +717,11 @@
   		break;
   
   	case XPathExpression::eOP_UNION:
  -		result = Union(context, opPos, executionContext)->num();
  +		Union(context, opPos, executionContext, result);
   		break;
   
   	case XPathExpression::eOP_LITERAL:
  -		result = literal(opPos, executionContext)->num();
  +		literal(opPos, result);
   		break;
   
   	case XPathExpression::eOP_VARIABLE:
  @@ -612,17 +729,13 @@
   		break;
   
   	case XPathExpression::eOP_GROUP:
  -		result = group(context, opPos, executionContext)->num();
  +		group(context, opPos, executionContext, result);
   		break;
   
   	case XPathExpression::eOP_NUMBERLIT:
   		result = numberlit(opPos);
   		break;
   
  -	case XPathExpression::eOP_ARGUMENT:
  -		result = arg(context, opPos, executionContext)->num();
  -		break;
  -
   	case XPathExpression::eOP_EXTFUNCTION:
   		result = runExtFunction(context, opPos, executionContext)->num();
   		break;
  @@ -632,7 +745,7 @@
   		break;
   
   	case XPathExpression::eOP_LOCATIONPATH:
  -		result = locationPath(context, opPos, executionContext)->num();
  +		locationPath(context, opPos, executionContext, result);
   		break;
   
   	case XPathExpression::eOP_FUNCTION_POSITION:
  @@ -647,6 +760,58 @@
   		result = functionCount(context, opPos, executionContext);
   		break;
   
  +	case XPathExpression::eOP_FUNCTION_NOT:
  +		result = XObject::number(functionNot(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_TRUE:
  +		result = XObject::number(true);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_FALSE:
  +		result = XObject::number(false);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_BOOLEAN:
  +		result = XObject::number(functionBoolean(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NAME_0:
  +		result = XObject::number(functionName(context));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NAME_1:
  +		result = XObject::number(functionName(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_0:
  +		result = XObject::number(functionLocalName(context));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_1:
  +		result = XObject::number(functionLocalName(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_FLOOR:
  +		result = functionFloor(context, opPos, executionContext);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_CEILING:
  +		result = functionCeiling(context, opPos, executionContext);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_ROUND:
  +		result = functionRound(context, opPos, executionContext);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NUMBER_0:
  +		result = functionNumber(context, executionContext);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NUMBER_1:
  +		result = functionNumber(context, opPos, executionContext);
  +		break;
  +
   	default:
   		unknownOpCodeError(context, executionContext, opPos);
   		break;
  @@ -725,7 +890,7 @@
   		break;
   
   	case XPathExpression::eOP_UNION:
  -		Union(context, opPos, executionContext)->str(result);
  +		Union(context, opPos, executionContext, result);
   		break;
   
   	case XPathExpression::eOP_LITERAL:
  @@ -737,17 +902,13 @@
   		break;
   
   	case XPathExpression::eOP_GROUP:
  -		group(context, opPos, executionContext)->str(result);
  +		group(context, opPos, executionContext, result);
   		break;
   
   	case XPathExpression::eOP_NUMBERLIT:
   		numberlit(opPos, result);
   		break;
   
  -	case XPathExpression::eOP_ARGUMENT:
  -		arg(context, opPos, executionContext)->str(result);
  -		break;
  -
   	case XPathExpression::eOP_EXTFUNCTION:
   		runExtFunction(context, opPos, executionContext)->str(result);
   		break;
  @@ -757,7 +918,7 @@
   		break;
   
   	case XPathExpression::eOP_LOCATIONPATH:
  -		locationPath(context, opPos, executionContext)->str(result);
  +		locationPath(context, opPos, executionContext, result);
   		break;
   
   	case XPathExpression::eOP_FUNCTION_POSITION:
  @@ -772,6 +933,58 @@
   		XObject::string(functionCount(context, opPos, executionContext), result);
   		break;
   
  +	case XPathExpression::eOP_FUNCTION_NOT:
  +		XObject::string(functionNot(context, opPos, executionContext), result);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_TRUE:
  +		XObject::string(true, result);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_FALSE:
  +		XObject::string(false, result);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_BOOLEAN:
  +		XObject::string(functionBoolean(context, opPos, executionContext), result);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NAME_0:
  +		result.append(functionName(context));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NAME_1:
  +		result.append(functionName(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_0:
  +		result.append(functionLocalName(context));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_1:
  +		result.append(functionLocalName(context, opPos, executionContext));
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_FLOOR:
  +		XObject::string(functionFloor(context, opPos, executionContext), result);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_CEILING:
  +		XObject::string(functionCeiling(context, opPos, executionContext), result);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_ROUND:
  +		XObject::string(functionRound(context, opPos, executionContext), result);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NUMBER_0:
  +		XObject::string(functionNumber(context, executionContext), result);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NUMBER_1:
  +		XObject::string(functionNumber(context, opPos, executionContext), result);
  +		break;
  +
   	default:
   		unknownOpCodeError(context, executionContext, opPos);
   		break;
  @@ -780,6 +993,17 @@
   
   
   
  +inline void
  +stringToCharacters(
  +			const XalanDOMString&		str,
  +			FormatterListener&			formatterListener,
  +			XPath::MemberFunctionPtr	function)
  +{
  +	(formatterListener.*function)(str.c_str(), str.length());
  +}
  +
  +
  +
   void
   XPath::executeMore(
   			XalanNode* 				context,
  @@ -875,7 +1099,7 @@
   		break;
   
   	case XPathExpression::eOP_UNION:
  -		Union(context, opPos, executionContext)->str(formatterListener, function);
  +		Union(context, opPos, executionContext, formatterListener, function);
   		break;
   
   	case XPathExpression::eOP_LITERAL:
  @@ -887,17 +1111,13 @@
   		break;
   
   	case XPathExpression::eOP_GROUP:
  -		group(context, opPos, executionContext)->str(formatterListener, function);
  +		group(context, opPos, executionContext, formatterListener, function);
   		break;
   
   	case XPathExpression::eOP_NUMBERLIT:
   		numberlit(opPos, formatterListener, function);
   		break;
   
  -	case XPathExpression::eOP_ARGUMENT:
  -		arg(context, opPos, executionContext)->str(formatterListener, function);
  -		break;
  -
   	case XPathExpression::eOP_EXTFUNCTION:
   		runExtFunction(context, opPos, executionContext)->str(formatterListener, function);
   		break;
  @@ -922,6 +1142,58 @@
   		XObject::string(functionCount(context, opPos, executionContext), formatterListener, function);
   		break;
   
  +	case XPathExpression::eOP_FUNCTION_NOT:
  +		XObject::string(functionNot(context, opPos, executionContext), formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_TRUE:
  +		XObject::string(true, formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_FALSE:
  +		XObject::string(false, formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_BOOLEAN:
  +		XObject::string(functionBoolean(context, opPos, executionContext), formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NAME_0:
  +		stringToCharacters(functionName(context), formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NAME_1:
  +		stringToCharacters(functionName(context, opPos, executionContext), formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_0:
  +		stringToCharacters(functionLocalName(context), formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_1:
  +		stringToCharacters(functionLocalName(context, opPos, executionContext), formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_FLOOR:
  +		XObject::string(functionFloor(context, opPos, executionContext), formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_CEILING:
  +		XObject::string(functionCeiling(context, opPos, executionContext), formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_ROUND:
  +		XObject::string(functionRound(context, opPos, executionContext), formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NUMBER_0:
  +		XObject::string(functionNumber(context, executionContext), formatterListener, function);
  +		break;
  +
  +	case XPathExpression::eOP_FUNCTION_NUMBER_1:
  +		XObject::string(functionNumber(context, opPos, executionContext), formatterListener, function);
  +		break;
  +
   	default:
   		unknownOpCodeError(context, executionContext, opPos);
   		break;
  @@ -964,6 +1236,25 @@
   	case XPathExpression::eOP_FUNCTION_POSITION:
   	case XPathExpression::eOP_FUNCTION_LAST:
   	case XPathExpression::eOP_FUNCTION_COUNT:
  +	case XPathExpression::eOP_FUNCTION_NOT:
  +	case XPathExpression::eOP_FUNCTION_TRUE:
  +	case XPathExpression::eOP_FUNCTION_FALSE:
  +	case XPathExpression::eOP_FUNCTION_BOOLEAN:
  +	case XPathExpression::eOP_FUNCTION_NAME_0:
  +	case XPathExpression::eOP_FUNCTION_NAME_1:
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_0:
  +	case XPathExpression::eOP_FUNCTION_LOCALNAME_1:
  +	case XPathExpression::eOP_FUNCTION_FLOOR:
  +	case XPathExpression::eOP_FUNCTION_CEILING:
  +	case XPathExpression::eOP_FUNCTION_ROUND:
  +	case XPathExpression::eOP_FUNCTION_NUMBER_0:
  +	case XPathExpression::eOP_FUNCTION_NUMBER_1:
  +	case XPathExpression::eOP_FUNCTION_STRING_0:
  +	case XPathExpression::eOP_FUNCTION_STRING_1:
  +	case XPathExpression::eOP_FUNCTION_STRINGLENGTH_0:
  +	case XPathExpression::eOP_FUNCTION_STRINGLENGTH_1:
  +	case XPathExpression::eOP_FUNCTION_NAMESPACEURI_0:
  +	case XPathExpression::eOP_FUNCTION_NAMESPACEURI_1:
   		notNodeSetError(context, executionContext);
   		break;
   
  @@ -979,10 +1270,6 @@
   		group(context, opPos, executionContext, result);
   		break;
   
  -	case XPathExpression::eOP_ARGUMENT:
  -		theXObject = arg(context, opPos, executionContext, result);
  -		break;
  -
   	case XPathExpression::eOP_EXTFUNCTION:
   		theXObject = runExtFunction(context, opPos, executionContext);
   		break;
  @@ -1724,6 +2011,79 @@
   			XalanNode*				context,
   			int						opPos,
   			XPathExecutionContext&	executionContext,
  +			bool&					result) const
  +{
  +	typedef XPathExecutionContext::BorrowReturnMutableNodeRefList	BorrowReturnMutableNodeRefList;
  +
  +	BorrowReturnMutableNodeRefList	resultNodeList(executionContext);
  +
  +	Union(context, opPos, executionContext, *resultNodeList);
  +
  +	result = XObject::boolean(*resultNodeList);
  +}
  +
  +
  +
  +void
  +XPath::Union(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			double&					result) const
  +{
  +	typedef XPathExecutionContext::BorrowReturnMutableNodeRefList	BorrowReturnMutableNodeRefList;
  +
  +	BorrowReturnMutableNodeRefList	resultNodeList(executionContext);
  +
  +	Union(context, opPos, executionContext, *resultNodeList);
  +
  +	result = XObject::number(executionContext, *resultNodeList);
  +}
  +
  +
  +
  +void
  +XPath::Union(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			XalanDOMString&			result) const
  +{
  +	typedef XPathExecutionContext::BorrowReturnMutableNodeRefList	BorrowReturnMutableNodeRefList;
  +
  +	BorrowReturnMutableNodeRefList	resultNodeList(executionContext);
  +
  +	Union(context, opPos, executionContext, *resultNodeList);
  +
  +	XObject::string(*resultNodeList, result);
  +}
  +
  +
  +
  +void
  +XPath::Union(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			FormatterListener&		formatterListener,
  +			MemberFunctionPtr		function) const
  +{
  +	typedef XPathExecutionContext::BorrowReturnMutableNodeRefList	BorrowReturnMutableNodeRefList;
  +
  +	BorrowReturnMutableNodeRefList	resultNodeList(executionContext);
  +
  +	Union(context, opPos, executionContext, *resultNodeList);
  +
  +	XObject::string(*resultNodeList, formatterListener, function);
  +}
  +
  +
  +
  +void
  +XPath::Union(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
   			MutableNodeRefList&		result) const
   {
   	assert(result.empty() == true);
  @@ -1783,6 +2143,36 @@
   
   void
   XPath::literal(
  +			int		opPos,
  +			bool&	theResult) const
  +{
  +	assert(m_expression.m_opMap.size() > unsigned(opPos + 2));
  +	assert(m_expression.m_tokenQueue.size() > unsigned(m_expression.m_opMap[opPos + 2]));
  +
  +	const XToken&	theLiteral = m_expression.m_tokenQueue[m_expression.m_opMap[opPos + 2]];
  +
  +	theResult = theLiteral.boolean();
  +}
  +
  +
  +
  +void
  +XPath::literal(
  +			int			opPos,
  +			double&		theResult) const
  +{
  +	assert(m_expression.m_opMap.size() > unsigned(opPos + 2));
  +	assert(m_expression.m_tokenQueue.size() > unsigned(m_expression.m_opMap[opPos + 2]));
  +
  +	const XToken&	theLiteral = m_expression.m_tokenQueue[m_expression.m_opMap[opPos + 2]];
  +
  +	theResult = theLiteral.num();
  +}
  +
  +
  +
  +void
  +XPath::literal(
   			int					opPos,
   			XalanDOMString&		theString) const
   {
  @@ -1863,6 +2253,21 @@
   
   void
   XPath::numberlit(
  +			int		opPos,
  +			bool&	theResult) const
  +{
  +	assert(m_expression.m_opMap.size() > unsigned(opPos + 3));
  +	assert(m_expression.m_tokenQueue.size() > unsigned(m_expression.m_opMap[opPos + 3]));
  +
  +	const XToken&	theLiteral = m_expression.m_tokenQueue[m_expression.m_opMap[opPos + 3]];
  +
  +	theResult = theLiteral.boolean();
  +}
  +
  +
  +
  +void
  +XPath::numberlit(
   			int					opPos,
   			XalanDOMString&		theString) const
   {
  @@ -1916,7 +2321,7 @@
   			XalanNode*				context,
   			int						opPos,
   			XPathExecutionContext&	executionContext,
  -			double&					theResult) const
  +			bool&					theResult) const
   {
   	assert(context != 0);
   
  @@ -1926,14 +2331,27 @@
   
   	locationPath(context, opPos, executionContext, *mnl.get());
   
  -	// $$$ ToDo: Reduce this to a call on XObject...
  -	XPathExecutionContext::GetAndReleaseCachedString	theGuard(executionContext);
  +	theResult = XObject::boolean(*mnl.get());
  +}
   
  -	XalanDOMString&		theString = theGuard.get();
   
  -	XObject::string(*mnl.get(), theString);
   
  -	theResult = XObject::number(theString);
  +void
  +XPath::locationPath(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			double&					theResult) const
  +{
  +	assert(context != 0);
  +
  +	typedef XPathExecutionContext::BorrowReturnMutableNodeRefList	BorrowReturnMutableNodeRefList;
  +
  +	BorrowReturnMutableNodeRefList	mnl(executionContext);
  +
  +	locationPath(context, opPos, executionContext, *mnl.get());
  +
  +	theResult = XObject::number(executionContext, *mnl.get());
   }
   
   
  @@ -1985,6 +2403,8 @@
   			int						opPos,
   			XPathExecutionContext&	executionContext) const
   {
  +	assert(context != 0);
  +
   	const int	endExtFunc = opPos + m_expression.m_opMap[opPos + 1] - 1;
   
   	opPos += 2;
  @@ -2021,6 +2441,8 @@
   			int						opPos,
   			XPathExecutionContext&	executionContext) const
   {
  +	assert(context != 0);
  +
   	const int	endFunc = opPos + m_expression.m_opMap[opPos + 1] - 1;
   
   	opPos += 2;
  @@ -2107,82 +2529,122 @@
   
   
   double
  -XPath::functionPosition(
  +XPath::functionCount(
   			XalanNode*				context,
  +			int						opPos,
   			XPathExecutionContext&	executionContext) const
   {
  -	if (context == 0)
  +	assert(context != 0);
  +
  +	typedef XPathExecutionContext::BorrowReturnMutableNodeRefList	BorrowReturnMutableNodeRefList;
  +
  +	BorrowReturnMutableNodeRefList	result(executionContext);
  +
  +	const XObjectPtr	nodesetResult(executeMore(context, opPos + 2, executionContext, *result));
  +
  +	if (nodesetResult.null() == false)
   	{
  -		executionContext.error(
  -				"The position() function requires a non-null context node!",
  -				context,
  -				m_locator);
  +		return nodesetResult->nodeset().getLength();
  +	}
  +	else
  +	{
  +		return result->getLength();
   	}
   
  -	return executionContext.getContextNodeListPosition(*context);
  +	return executionContext.getContextNodeListLength();
   }
   
   
   
  -const XObjectPtr
  -XPath::functionPositionGeneric(
  +const XalanDOMString&
  +XPath::functionName(
   			XalanNode*				context,
  +			int						opPos,
   			XPathExecutionContext&	executionContext) const
   {
  -	return executionContext.getXObjectFactory().createNumber(functionPosition(context, executionContext));
  -}
  +	assert(context != 0);
   
  +	typedef XPathExecutionContext::BorrowReturnMutableNodeRefList	BorrowReturnMutableNodeRefList;
   
  +	BorrowReturnMutableNodeRefList	result(executionContext);
   
  -double
  -XPath::functionLast(XPathExecutionContext&	executionContext) const
  -{
  -	return executionContext.getContextNodeListLength();
  -}
  +	const XObjectPtr	nodesetResult(executeMore(context, opPos + 2, executionContext, *result));
   
  +	const NodeRefListBase* const	theNodeList = nodesetResult.null() == false ?
  +			&nodesetResult->nodeset() : &*result;
  +	assert(theNodeList != 0);
   
  +	if (theNodeList->getLength() == 0)
  +	{
  +		return s_emptyString;
  +	}
  +	else
  +	{
  +		assert(theNodeList->item(0) != 0);
   
  -const XObjectPtr
  -XPath::functionLastGeneric(XPathExecutionContext&	executionContext) const
  -{
  -	return executionContext.getXObjectFactory().createNumber(functionLast(executionContext));
  +		return functionName(theNodeList->item(0));
  +	}
   }
   
   
   
  -double
  -XPath::functionCount(
  -			XalanNode*				context,
  -			int						opPos,
  -			XPathExecutionContext&	executionContext) const
  +const XalanDOMString&
  +XPath::functionLocalName(XalanNode*		context) const
   {
  -	typedef XPathExecutionContext::BorrowReturnMutableNodeRefList	BorrowReturnMutableNodeRefList;
  +	assert(context != 0);
   
  -	BorrowReturnMutableNodeRefList	result(executionContext);
  +	const XalanDOMString*		theResult = &s_emptyString;
   
  -	const XObjectPtr	nodesetResult(executeMore(context, opPos + 2, executionContext, *result));
  +	const XalanNode::NodeType	theType = context->getNodeType();
   
  -	if (nodesetResult.null() == false)
  +	if(theType == XalanNode::ELEMENT_NODE ||
  +	   theType == XalanNode::PROCESSING_INSTRUCTION_NODE)
   	{
  -		return nodesetResult->nodeset().getLength();
  +		theResult = &DOMServices::getLocalNameOfNode(*context);
   	}
  -	else
  +	else if (theType == XalanNode::ATTRIBUTE_NODE)
   	{
  -		return result->getLength();
  +		const XalanDOMString&	theLocalName = DOMServices::getLocalNameOfNode(*context);
  +
  +		if (theLocalName != DOMServices::s_XMLNamespace)
  +		{
  +			theResult = &theLocalName;
  +		}
   	}
   
  -	return executionContext.getContextNodeListLength();
  +	return *theResult;
   }
   
   
   
  -const XObjectPtr
  -XPath::functionCountGeneric(
  +const XalanDOMString&
  +XPath::functionLocalName(
   			XalanNode*				context,
   			int						opPos,
   			XPathExecutionContext&	executionContext) const
   {
  -	return executionContext.getXObjectFactory().createNumber(functionCount(context, opPos, executionContext));
  +	assert(context != 0);
  +
  +	typedef XPathExecutionContext::BorrowReturnMutableNodeRefList	BorrowReturnMutableNodeRefList;
  +
  +	BorrowReturnMutableNodeRefList	result(executionContext);
  +
  +	const XObjectPtr	nodesetResult(executeMore(context, opPos + 2, executionContext, *result));
  +
  +	const NodeRefListBase* const	theNodeList = nodesetResult.null() == false ?
  +			&nodesetResult->nodeset() : &*result;
  +	assert(theNodeList != 0);
  +
  +	if (theNodeList->getLength() == 0)
  +	{
  +		return s_emptyString;
  +	}
  +	else
  +	{
  +		assert(theNodeList->item(0) != 0);
  +
  +		return functionLocalName(theNodeList->item(0));
  +	}
   }
   
   
  @@ -2341,15 +2803,17 @@
   
   						queryResults.setDocumentOrder();
   					}
  -					else if (mnl->getReverseDocumentOrder() == true)
  -					{
  -						mnl->reverseAssign(queryResults);
  -					}
  +//					else if (mnl->getReverseDocumentOrder() == true)
  +//					{
  +//						queryResults.swap(*mnl);
  +//
  +//						queryResults.reverse();
  +//					}
   					else
   					{
   						assert(mnl->getDocumentOrder() == true);
   
  -						queryResults = *mnl;
  +						queryResults.swap(*mnl);
   					}
   				}
   			}
  @@ -2363,13 +2827,15 @@
   		}
   		else if (subQueryResults->getReverseDocumentOrder() == true)
   		{
  -			subQueryResults->reverseAssign(queryResults);
  +			queryResults.swap(*subQueryResults);
  +
  +			queryResults.reverse();
   		}
   		else
   		{
   			assert(subQueryResults->getDocumentOrder() == true);
   
  -			queryResults = *subQueryResults;
  +			queryResults.swap(*subQueryResults);
   		}
   	}
   }
  @@ -2425,12 +2891,12 @@
   
   	assert(context != 0);
   
  -	int					argLen = 0;
  +	int				argLen = 0;
   
  -	eMatchScore	score = eMatchScoreNone;
  +	eMatchScore		score = eMatchScoreNone;
   
  -	const int	startOpPos = opPos;
  -	const int	stepType = currentExpression.getOpCodeMapValue(opPos);
  +	const int		startOpPos = opPos;
  +	const int		stepType = currentExpression.getOpCodeMapValue(opPos);
   
   	switch(stepType)
   	{
  
  
  
  1.39      +404 -89   xml-xalan/c/src/XPath/XPath.hpp
  
  Index: XPath.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.hpp,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- XPath.hpp	2 Jan 2003 17:47:35 -0000	1.38
  +++ XPath.hpp	3 Jan 2003 08:04:24 -0000	1.39
  @@ -212,7 +212,7 @@
   	/**
   	 * Execute the XPath from the provided context.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param executionContext current execution context
   	 * @return smart-pointer to result XObject
  @@ -226,7 +226,7 @@
   	/**
   	 * Execute the XPath from the provided context.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param executionContext current execution context
   	 * @param result           the boolean result
  @@ -241,7 +241,7 @@
   	/**
   	 * Execute the XPath from the provided context.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param executionContext current execution context
   	 * @param result           the numeric result
  @@ -257,7 +257,7 @@
   	 * Execute the XPath from the provided context.  The
   	 * result is appended to the supplied string.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param executionContext current execution context
   	 * @param result           the string result
  @@ -274,7 +274,7 @@
   	/**
   	 * Execute the XPath from the provided context.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param executionContext current execution context
   	 * @param formatterListener the FormatterListener instance to receive the result
  @@ -301,7 +301,7 @@
   	 * will be empty, and the result will be in the XObject
   	 * instance returned.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param executionContext current execution context
   	 * @param result           the node-set result
  @@ -317,7 +317,7 @@
   	/**
   	 * Execute the XPath from the provided context.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param contextNodeList  node list for current context
   	 * @param executionContext current execution context
  @@ -341,7 +341,7 @@
   	/**
   	 * Execute the XPath from the provided context.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param contextNodeList  node list for current context
   	 * @param executionContext current execution context
  @@ -366,7 +366,7 @@
   	/**
   	 * Execute the XPath from the provided context.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param contextNodeList  node list for current context
   	 * @param executionContext current execution context
  @@ -392,7 +392,7 @@
   	 * Execute the XPath from the provided context.  The
   	 * result is appended to the supplied string.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param contextNodeList  node list for current context
   	 * @param executionContext current execution context
  @@ -417,7 +417,7 @@
   	/**
   	 * Execute the XPath from the provided context.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param contextNodeList  node list for current context
   	 * @param executionContext current execution context
  @@ -454,7 +454,7 @@
   	 * will be empty, and the result will be in the XObject
   	 * instance returned.
   	 *
  -	 * @param context          current source tree context node
  +	 * @param context          current source tree context node, which must not be 0
   	 * @param prefixResolver   prefix resolver to use
   	 * @param contextNodeList  node list for current context
   	 * @param executionContext current execution context
  @@ -478,9 +478,10 @@
   	}
   
   	/**
  -	 * Execute the XPath from the provided context.  The
  -	 * prefix resolver must already be set in the
  -	 * execution context.
  +	 * Execute the XPath from the provided context.
  +	 *
  +	 * The prefix resolver and current node must already
  +	 * be set execution context, and must not be 0.
   	 *
   	 * @param executionContext current execution context
   	 * @return smart-pointer to result XObject
  @@ -488,15 +489,17 @@
   	const XObjectPtr
   	execute(XPathExecutionContext&	executionContext) const
   	{
  +		assert(executionContext.getCurrentNode() != 0);
   		assert(executionContext.getPrefixResolver() != 0);
   
   		return executeMore(executionContext.getCurrentNode(), 0, executionContext);
   	}
   
   	/**
  -	 * Execute the XPath from the provided context.  The
  -	 * prefix resolver must already be set in the
  -	 * execution context.
  +	 * Execute the XPath from the provided context.
  +	 *
  +	 * The prefix resolver and current node must already
  +	 * be set execution context, and must not be 0.
   	 *
   	 * @param executionContext current execution context
   	 * @param result           the boolean result
  @@ -506,14 +509,16 @@
   			XPathExecutionContext&	executionContext,
   			bool&					result) const
   	{
  +		assert(executionContext.getCurrentNode() != 0);
   		assert(executionContext.getPrefixResolver() != 0);
   
   		executeMore(executionContext.getCurrentNode(), 0, executionContext, result);
   	}
   
   	/**
  -	 * Execute the XPath from the provided context.  The
  -	 * prefix resolver must already be set in the
  +	 * Execute the XPath from the provided context.
  +	 *
  +	 * The prefix resolver must already be set in the
   	 * execution context.
   	 *
   	 * @param executionContext current execution context
  @@ -524,16 +529,18 @@
   			XPathExecutionContext&	executionContext,
   			double&					result) const
   	{
  +		assert(executionContext.getCurrentNode() != 0);
   		assert(executionContext.getPrefixResolver() != 0);
   
   		executeMore(executionContext.getCurrentNode(), 0, executionContext, result);
   	}
   
   	/**
  -	 * Execute the XPath from the provided context.  The
  -	 * prefix resolver must already be set in the
  -	 * execution context.  The result is appended to the
  -	 * supplied string.
  +	 * Execute the XPath from the provided context. The
  +	 * result is appended to the supplied string.
  +	 *
  +	 * The prefix resolver and current node must already
  +	 * be set execution context, and must not be 0.
   	 *
   	 * @param executionContext current execution context
   	 * @param result           the string result
  @@ -543,15 +550,17 @@
   			XPathExecutionContext&	executionContext,
   			XalanDOMString&			result) const
   	{
  +		assert(executionContext.getCurrentNode() != 0);
   		assert(executionContext.getPrefixResolver() != 0);
   
   		executeMore(executionContext.getCurrentNode(), 0, executionContext, result);
   	}
   
   	/**
  -	 * Execute the XPath from the provided context.  The
  -	 * prefix resolver must already be set in the
  -	 * execution context.
  +	 * Execute the XPath from the provided context.
  +	 * 
  +	 * The prefix resolver and current node must already
  +	 * be set execution context, and must not be 0.
   	 *
   	 * @param executionContext current execution context
   	 * @param formatterListener the FormatterListener instance to receive the result
  @@ -563,6 +572,7 @@
   			FormatterListener&		formatterListener,
   			MemberFunctionPtr		function) const
   	{
  +		assert(executionContext.getCurrentNode() != 0);
   		assert(executionContext.getPrefixResolver() != 0);
   
   		executeMore(executionContext.getCurrentNode(), 0, executionContext, formatterListener, function);
  @@ -581,8 +591,8 @@
   	 * will be empty, and the result will be in the XObject
   	 * instance returned.
   	 * 
  -	 * The prefix resolver must already be set in the
  -	 * execution context.
  +	 * The prefix resolver and current node must already
  +	 * be set execution context, and must not be 0.
   	 *
   	 * @param executionContext current execution context
   	 * @return the node-set result, if the result was not returned in the parameter
  @@ -592,6 +602,7 @@
   			XPathExecutionContext&	executionContext,
   			MutableNodeRefList&		result) const
   	{
  +		assert(executionContext.getCurrentNode() != 0);
   		assert(executionContext.getPrefixResolver() != 0);
   
   		return executeMore(executionContext.getCurrentNode(), 0, executionContext, result);
  @@ -866,10 +877,7 @@
   			XalanNode*				context,
   			int						opPos,
   			XPathExecutionContext&	executionContext,
  -			MutableNodeRefList&		theResult) const
  -	{
  -		step(executionContext, context, opPos + 2, theResult);
  -	}
  +			bool&					theResult) const;
   
   	/**
   	 * Execute a location path.
  @@ -877,7 +885,7 @@
   	 * @param context          current source tree context node
   	 * @param opPos            current position in the m_opMap array
   	 * @param executionContext current execution context
  -	 * @param theResult	       the result as a number
  +	 * @param theResult	       the result as a node list
   	 */
   	void
   	locationPath(
  @@ -887,13 +895,12 @@
   			double&					theResult) const;
   
   	/**
  -	 * Execute a location path.  The result is appended to the
  -	 * supplied string.
  +	 * Execute a location path.
   	 *
   	 * @param context          current source tree context node
   	 * @param opPos            current position in the m_opMap array
   	 * @param executionContext current execution context
  -	 * @param theResult	       the string
  +	 * @param theResult	       the result as a node list
   	 */
   	void
   	locationPath(
  @@ -920,6 +927,24 @@
   			MemberFunctionPtr		function) const;
   
   	/**
  +	 * Execute a location path.
  +	 *
  +	 * @param context          current source tree context node
  +	 * @param opPos            current position in the m_opMap array
  +	 * @param executionContext current execution context
  +	 * @param theResult	       the result as a node list
  +	 */
  +	void
  +	locationPath(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			MutableNodeRefList&		theResult) const
  +	{
  +		step(executionContext, context, opPos + 2, theResult);
  +	}
  +
  +	/**
   	 * Execute the XPath from the provided context.
   	 *
   	 * @param context          current source tree context node
  @@ -1317,6 +1342,68 @@
   
   	/**
   	 * Computes the union of its operands which must be node-sets.
  +	 *
  +	 * @param context The current source tree context node.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @result the result of the union of node-set operands.
  +	 */
  +	void
  +	Union(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			bool&					result) const;
  +
  +	/**
  +	 * Computes the union of its operands which must be node-sets.
  +	 *
  +	 * @param context The current source tree context node.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @result the result of the union of node-set operands.
  +	 */
  +	void
  +	Union(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			double&					result) const;
  +
  +	/**
  +	 * Computes the union of its operands which must be node-sets.
  +	 *
  +	 * @param context The current source tree context node.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @result the result of the union of node-set operands.
  +	 */
  +	void
  +	Union(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			XalanDOMString&			result) const;
  +
  +	/**
  +	 * Computes the union of its operands which must be node-sets.
  +	 *
  +	 * @param context The current source tree context node.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @param formatterListener the FormatterListener instance to receive the result
  +	 * @param function A pointer to the member function of FormatterListener to call
  +	 */
  +	void
  +	Union(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			FormatterListener&		formatterListener,
  +			MemberFunctionPtr		function) const;
  +
  +	/**
  +	 * Computes the union of its operands which must be node-sets.
   	 * @param context The current source tree context node.
   	 * @param opPos The current position in the m_opMap array.
   	 * @param executionContext current execution context
  @@ -1341,6 +1428,28 @@
   			XPathExecutionContext&	executionContext) const;
     
   	/**
  +	 * Get a literal value as a boolean.
  +	 *
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param theResult The value.
  +	 */
  +	void
  +	literal(
  +			int		opPos,
  +			bool&	theResult) const;
  +
  +	/**
  +	 * Get a literal value as a number.
  +	 *
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param theResult The value.
  +	 */
  +	void
  +	literal(
  +			int			opPos,
  +			double&		theResult) const;
  +
  +	/**
   	 * Get a literal value.  The value is appended to the
   	 * supplied string.
   	 *
  @@ -1403,6 +1512,77 @@
   			XalanNode*				context,
   			int						opPos,
   			XPathExecutionContext&	executionContext,
  +			bool&					theResult) const
  +	{
  +		executeMore(context, opPos + 2, executionContext, theResult);
  +	}
  +
  +	/**
  +	 * Execute an expression as a group.
  +	 * @param context The current source tree context node.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @param theResult The result of the execution
  +	 */
  +	void
  +	group(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			double&					theResult) const
  +	{
  +		executeMore(context, opPos + 2, executionContext, theResult);
  +	}
  +
  +	/**
  +	 * Execute an expression as a group.
  +	 * @param context The current source tree context node.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @param theResult The result of the execution
  +	 */
  +	void
  +	group(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			XalanDOMString&			theResult) const
  +	{
  +		executeMore(context, opPos + 2, executionContext, theResult);
  +	}
  +
  +	/**
  +	 * Execute an expression as a group.
  +	 *
  +	 * @param context The current source tree context node.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @param formatterListener the FormatterListener instance to receive the result
  +	 * @param function A pointer to the member function of FormatterListener to call
  +	 */
  +	void
  +	group(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
  +			FormatterListener&		formatterListener,
  +			MemberFunctionPtr		function) const
  +	{
  +		executeMore(context, opPos + 2, executionContext, formatterListener, function);
  +	}
  +
  +	/**
  +	 * Execute an expression as a group.
  +	 * @param context The current source tree context node.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @param theResult The result of the execution
  +	 */
  +	void
  +	group(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext,
   			MutableNodeRefList&		theResult) const
   	{
   		executeMore(context, opPos + 2, executionContext, theResult);
  @@ -1427,6 +1607,17 @@
   			XPathExecutionContext&	executionContext) const;
   
   	/**
  +	 * Get a literal value as a boolean.
  +	 *
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param theResult The string.
  +	 */
  +	void
  +	numberlit(
  +			int		opPos,
  +			bool&	theResult) const;
  +
  +	/**
   	 * Get a literal value.  The value is appended to the
   	 * supplied string.
   	 *
  @@ -1452,41 +1643,6 @@
   			MemberFunctionPtr	function) const;
   
   	/**
  -	 * Execute a function argument.
  -	 *
  -	 * @param context The current source tree context node.
  -	 * @param opPos The current position in the m_opMap array.
  -	 * @param executionContext current execution context
  -	 * @return the result of the argument expression.
  -	 */
  -	const XObjectPtr
  -	arg(
  -			XalanNode*				context,
  -			int						opPos,
  -			XPathExecutionContext&	executionContext) const
  -	{
  -		return executeMore(context, opPos + 2, executionContext);
  -	}
  -
  -	/**
  -	 * Execute a function argument.
  -	 * @param context The current source tree context node.
  -	 * @param opPos The current position in the m_opMap array.
  -	 * @param executionContext current execution context
  -	 * @param the result of the argument expression.
  -	 * @result the result of the argument expression.
  -	 */
  -	const XObjectPtr
  -	arg(
  -			XalanNode*				context,
  -			int						opPos,
  -			XPathExecutionContext&	executionContext,
  -			MutableNodeRefList&		result) const
  -	{
  -		return executeMore(context, opPos + 2, executionContext, result);
  -	}
  -
  -	/**
   	 * Setup for and run an extension function.
   	 * @param context The current source tree context node.
   	 * @param opPos The current position in the m_opMap array.
  @@ -1559,68 +1715,227 @@
   	/**
   	 * Handle the built-in function "position".
   	 *
  -	 * @param context The current source tree context node.
  +	 * @param context The current source tree context node, which must not be 0.
   	 * @param executionContext current execution context
   	 * @return the result of the function.
   	 */
   	double
   	functionPosition(
   			XalanNode*				context,
  -			XPathExecutionContext&	executionContext) const;
  +			XPathExecutionContext&	executionContext) const
  +	{
  +		assert(context != 0);
  +
  +		return executionContext.getContextNodeListPosition(*context);
  +	}
   
   	/**
  -	 * Handle the built-in function "position".
  +	 * Handle the built-in function "last".
  +	 *
  +	 * @param executionContext current execution context
  +	 * @return the result of the function.
  +	 */
  +	double
  +	functionLast(XPathExecutionContext&		executionContext) const
  +	{
  +		return executionContext.getContextNodeListLength();
  +	}
  +
  +	/**
  +	 * Handle the built-in function "count".
   	 *
   	 * @param context The current source tree context node.
  +	 * @param opPos The current position in the m_opMap array.
   	 * @param executionContext current execution context
   	 * @return the result of the function.
   	 */
  -	const XObjectPtr
  -	functionPositionGeneric(
  +	double
  +	functionCount(
   			XalanNode*				context,
  +			int						opPos,
   			XPathExecutionContext&	executionContext) const;
   
   	/**
  -	 * Handle the built-in function "last".
  +	 * Handle the built-in function "not".
   	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @param opPos The current position in the m_opMap array.
   	 * @param executionContext current execution context
   	 * @return the result of the function.
   	 */
  -	double
  -	functionLast(XPathExecutionContext&		executionContext) const;
  +	bool
  +	functionNot(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext) const
  +	{
  +		assert(context != 0);
  +
  +		return !functionBoolean(context, opPos, executionContext);
  +	}
   
   	/**
  -	 * Handle the built-in function "last".
  +	 * Handle the built-in function "boolean".
   	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @param opPos The current position in the m_opMap array.
   	 * @param executionContext current execution context
   	 * @return the result of the function.
   	 */
  -	const XObjectPtr
  -	functionLastGeneric(XPathExecutionContext&	executionContext) const;
  +	bool
  +	functionBoolean(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext) const
  +	{
  +		assert(context != 0);
  +
  +		bool	result;
  +
  +		executeMore(context, opPos + 2, executionContext, result);
  +
  +		return result;
  +	}
   
   	/**
  -	 * Handle the built-in function "count".
  +	 * Handle the built-in function "name".
   	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @return the result of the function.
  +	 */
  +	const XalanDOMString&
  +	functionName(XalanNode*		context) const
  +	{
  +		assert(context != 0);
  +
  +		return DOMServices::getNameOfNode(*context);
  +	}
  +
  +	/**
  +	 * Handle the built-in function "name".
  +	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @param opPos The current position in the m_opMap array.
   	 * @param executionContext current execution context
   	 * @return the result of the function.
   	 */
  -	double
  -	functionCount(
  +	const XalanDOMString&
  +	functionName(
   			XalanNode*				context,
   			int						opPos,
   			XPathExecutionContext&	executionContext) const;
   
   	/**
  -	 * Handle the built-in function "count".
  +	 * Handle the built-in function "local-name".
  +	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @return the result of the function.
  +	 */
  +	const XalanDOMString&
  +	functionLocalName(XalanNode*	context) const;
  +
  +	/**
  +	 * Handle the built-in function "local-name".
   	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @param opPos The current position in the m_opMap array.
   	 * @param executionContext current execution context
   	 * @return the result of the function.
   	 */
  -	const XObjectPtr
  -	functionCountGeneric(
  +	const XalanDOMString&
  +	functionLocalName(
   			XalanNode*				context,
   			int						opPos,
   			XPathExecutionContext&	executionContext) const;
  +
  +	/**
  +	 * Handle the built-in function "number".
  +	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @param executionContext current execution context
  +	 * @return the result of the function.
  +	 */
  +	double
  +	functionNumber(
  +			XalanNode*				context,
  +			XPathExecutionContext&	executionContext) const
  +	{
  +		assert(context != 0);
  +
  +		return XObject::number(executionContext, *context);
  +	}
  +
  +	/**
  +	 * Handle the built-in function "number".
  +	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @return the result of the function.
  +	 */
  +	double
  +	functionNumber(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext) const
  +	{
  +		double	result;
  +
  +		executeMore(context, opPos + 2, executionContext, result);
  +
  +		return result;
  +	}
  +
  +	/**
  +	 * Handle the built-in function "floor".
  +	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @return the result of the function.
  +	 */
  +	double
  +	functionFloor(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext) const
  +	{
  +		return DoubleSupport::floor(functionNumber(context, opPos, executionContext));
  +	}
  +
  +	/**
  +	 * Handle the built-in function "ceiling".
  +	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @return the result of the function.
  +	 */
  +	double
  +	functionCeiling(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext) const
  +	{
  +		return DoubleSupport::ceiling(functionNumber(context, opPos, executionContext));
  +	}
  +
  +	/**
  +	 * Handle the built-in function "round".
  +	 *
  +	 * @param context The current source tree context node, which must not be 0.
  +	 * @param opPos The current position in the m_opMap array.
  +	 * @param executionContext current execution context
  +	 * @return the result of the function.
  +	 */
  +	double
  +	functionRound(
  +			XalanNode*				context,
  +			int						opPos,
  +			XPathExecutionContext&	executionContext) const
  +	{
  +		return DoubleSupport::round(functionNumber(context, opPos, executionContext));
  +	}
   
   	/**
   	 * Get a numeric operand for an expression.
  
  
  
  1.43      +19 -0     xml-xalan/c/src/XPath/XPathExpression.cpp
  
  Index: XPathExpression.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.cpp,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- XPathExpression.cpp	2 Jan 2003 17:39:09 -0000	1.42
  +++ XPathExpression.cpp	3 Jan 2003 08:04:24 -0000	1.43
  @@ -172,6 +172,25 @@
   	XPathExpression::s_opCodeMapLengthIndex + 1,
   	XPathExpression::s_opCodeMapLengthIndex + 1,
   	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
  +	XPathExpression::s_opCodeMapLengthIndex + 1,
   	XPathExpression::s_opCodeMapLengthIndex + 1
   };
   
  
  
  
  1.33      +21 -48    xml-xalan/c/src/XPath/XPathExpression.hpp
  
  Index: XPathExpression.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.hpp,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- XPathExpression.hpp	2 Jan 2003 17:39:09 -0000	1.32
  +++ XPathExpression.hpp	3 Jan 2003 08:04:24 -0000	1.33
  @@ -578,58 +578,31 @@
   		eOP_PREDICATE_WITH_POSITION = 55,
     
   		/**
  -		 * [OP_FUNCTION_POSITION]
  -		 * [length]
  -		 * [FUNC_ID]
  -		 * [arg count]
  -		 *  {OP_ARGUMENT}*
  -		 * [ENDOP]
  -		 * 
  -		 * returns: 
  -		 *  XNodeSet
  -		 *  XNumber
  -		 *  XString
  -		 *  XBoolean
  -		 *  XRTree
  -		 *  XObject
  +		 * These are values for intrinsic functions which
  +		 * have been compiled directly into the op map.
   		 */
   		eOP_FUNCTION_POSITION = 56,
  -
  -		/**
  -		 * [OP_FUNCTION_POSITION]
  -		 * [length]
  -		 * [FUNC_ID]
  -		 * [arg count]
  -		 *  {OP_ARGUMENT}*
  -		 * [ENDOP]
  -		 * 
  -		 * returns: 
  -		 *  XNodeSet
  -		 *  XNumber
  -		 *  XString
  -		 *  XBoolean
  -		 *  XRTree
  -		 *  XObject
  -		 */
   		eOP_FUNCTION_LAST = 57,
  -
  -		/**
  -		 * [OP_FUNCTION_POSITION]
  -		 * [length]
  -		 * [FUNC_ID]
  -		 * [arg count]
  -		 *  {OP_ARGUMENT}*
  -		 * [ENDOP]
  -		 * 
  -		 * returns: 
  -		 *  XNodeSet
  -		 *  XNumber
  -		 *  XString
  -		 *  XBoolean
  -		 *  XRTree
  -		 *  XObject
  -		 */
   		eOP_FUNCTION_COUNT = 58,
  +		eOP_FUNCTION_NOT = 59,
  +		eOP_FUNCTION_TRUE = 60,
  +		eOP_FUNCTION_FALSE = 61,
  +		eOP_FUNCTION_BOOLEAN = 62,
  +		eOP_FUNCTION_NAME_0 = 63,
  +		eOP_FUNCTION_NAME_1 = 64,
  +		eOP_FUNCTION_LOCALNAME_0 = 65,
  +		eOP_FUNCTION_LOCALNAME_1 = 66,
  +		eOP_FUNCTION_FLOOR = 67,
  +		eOP_FUNCTION_CEILING = 68,
  +		eOP_FUNCTION_ROUND = 69,
  +		eOP_FUNCTION_NUMBER_0 = 70,
  +		eOP_FUNCTION_NUMBER_1 = 71,
  +		eOP_FUNCTION_STRING_0 = 72,
  +		eOP_FUNCTION_STRING_1 = 73,
  +		eOP_FUNCTION_STRINGLENGTH_0 = 74,
  +		eOP_FUNCTION_STRINGLENGTH_1 = 75,
  +		eOP_FUNCTION_NAMESPACEURI_0 = 76,
  +		eOP_FUNCTION_NAMESPACEURI_1 = 77,
   
   		// Always add _before_ this one and update
   		// s_opCodeLengthArray.
  
  
  
  1.67      +390 -50   xml-xalan/c/src/XPath/XPathProcessorImpl.cpp
  
  Index: XPathProcessorImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.cpp,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- XPathProcessorImpl.cpp	2 Jan 2003 17:39:09 -0000	1.66
  +++ XPathProcessorImpl.cpp	3 Jan 2003 08:04:24 -0000	1.67
  @@ -883,9 +883,7 @@
   
   
   void
  -XPathProcessorImpl::error(
  -			const XalanDOMString&	msg,
  -			XalanNode*				/* sourceNode */) const
  +XPathProcessorImpl::error(const XalanDOMString&		msg) const
   {
   	const XPathConstructionContext::GetAndReleaseCachedString	theGuard(*m_constructionContext);
   
  @@ -919,33 +917,7 @@
   
   			thePrintWriter.print(theCurrentPattern);
   
  -			thePrintWriter.print("'");
  -
  -			if (m_locator != 0)
  -			{
  -				const XalanDOMChar* const	theSystemID =
  -					m_locator->getSystemId();
  -
  -				thePrintWriter.print("(");
  -
  -				if (theSystemID == 0)
  -				{
  -					thePrintWriter.print("Unknown URI");
  -				}
  -				else
  -				{
  -					thePrintWriter.print(theSystemID);
  -				}
  -
  -				thePrintWriter.print(", ");
  -				thePrintWriter.print(m_locator->getLineNumber());
  -				thePrintWriter.print(", ");
  -				thePrintWriter.print(m_locator->getColumnNumber());
  -
  -				thePrintWriter.print(")");
  -			}
  -
  -			thePrintWriter.println();
  +			thePrintWriter.println("'");
   		}
   
   		// Back up one token, since we've consumed one...
  @@ -982,11 +954,9 @@
   
   
   void
  -XPathProcessorImpl::error(
  -			const char*		msg,
  -			XalanNode*		sourceNode) const
  +XPathProcessorImpl::error(const char*	msg) const
   {
  -	error(TranscodeFromLocalCodePage(msg), sourceNode);
  +	error(TranscodeFromLocalCodePage(msg));
   }
   
   
  @@ -1535,10 +1505,6 @@
   {
   	assert(m_expression != 0);
   
  -	const int	opPos = m_expression->opCodeMapLength();
  -
  -	m_expression->appendOpCode(XPathExpression::eOP_ARGUMENT);
  -
   	if (m_requireLiterals == false ||
   		isCurrentLiteral() == true)
   	{
  @@ -1548,9 +1514,6 @@
   	{
   		error(TranscodeFromLocalCodePage("A literal argument is required."));
   	}
  -
  -	m_expression->updateOpCodeLength(XPathExpression::eOP_ARGUMENT,
  -									 opPos);
   }
   
   
  @@ -1657,6 +1620,58 @@
   			FunctionCount();
   			break;
   
  +		case XPathExpression::eOP_FUNCTION_NOT:
  +			FunctionNot();
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_TRUE:
  +			FunctionTrue();
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_FALSE:
  +			FunctionFalse();
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_BOOLEAN:
  +			FunctionBoolean();
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_NAME_0:
  +			FunctionName(opPos);
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_LOCALNAME_0:
  +			FunctionLocalName(opPos);
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_NUMBER_0:
  +			FunctionNumber(opPos);
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_FLOOR:
  +			FunctionFloor();
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_CEILING:
  +			FunctionCeiling();
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_ROUND:
  +			FunctionRound();
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_STRING_0:
  +			FunctionString(opPos);
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_STRINGLENGTH_0:
  +			FunctionStringLength(opPos);
  +			break;
  +
  +		case XPathExpression::eOP_FUNCTION_NAMESPACEURI_0:
  +			FunctionNamespaceURI(opPos);
  +			break;
  +
   		default:
   			{
   				// The position must be at least zero, since
  @@ -1775,6 +1790,313 @@
   
   
   void
  +XPathProcessorImpl::FunctionNot()
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_NOT);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 1)
  +	{
  +		error("The not() function takes one arguments");
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionTrue()
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_TRUE);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 0)
  +	{
  +		error("The true() function does not accept any arguments");
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionFalse()
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_FALSE);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 0)
  +	{
  +		error("The false() function does not accept any arguments");
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionBoolean()
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_BOOLEAN);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 1)
  +	{
  +		error("The boolean() function takes one arguments");
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionName(int	opPos)
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_NAME_0);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 0)
  +	{
  +		if (argCount == 1)
  +		{
  +			m_expression->replaceOpCode(
  +				opPos,
  +				XPathExpression::eOP_FUNCTION_NAME_0,
  +				XPathExpression::eOP_FUNCTION_NAME_1);
  +		}
  +		else
  +		{
  +			error("The name() function takes zero or one argument(s)");
  +		}
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionLocalName(int	opPos)
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_LOCALNAME_0);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 0)
  +	{
  +		if (argCount == 1)
  +		{
  +			m_expression->replaceOpCode(
  +				opPos,
  +				XPathExpression::eOP_FUNCTION_LOCALNAME_0,
  +				XPathExpression::eOP_FUNCTION_LOCALNAME_1);
  +		}
  +		else
  +		{
  +			error("The locale-name() function takes zero or one argument(s)");
  +		}
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionNumber(int	opPos)
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_NUMBER_0);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 0)
  +	{
  +		if (argCount == 1)
  +		{
  +			m_expression->replaceOpCode(
  +				opPos,
  +				XPathExpression::eOP_FUNCTION_NUMBER_0,
  +				XPathExpression::eOP_FUNCTION_NUMBER_1);
  +		}
  +		else
  +		{
  +			error("The number() function takes zero or one argument(s)");
  +		}
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionFloor()
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_FLOOR);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 1)
  +	{
  +		error("The floor() function accepts one argument");
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionCeiling()
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_CEILING);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 1)
  +	{
  +		error("The ceiling() function accepts one argument");
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionRound()
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_ROUND);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 1)
  +	{
  +		error("The round() function accepts one argument");
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionString(int	opPos)
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_STRING_0);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 0)
  +	{
  +		if (argCount == 1)
  +		{
  +			m_expression->replaceOpCode(
  +				opPos,
  +				XPathExpression::eOP_FUNCTION_STRING_0,
  +				XPathExpression::eOP_FUNCTION_STRING_1);
  +		}
  +		else
  +		{
  +			error("The string() function takes zero or one argument(s)");
  +		}
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionStringLength(int	opPos)
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_STRINGLENGTH_0);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 0)
  +	{
  +		if (argCount == 1)
  +		{
  +			m_expression->replaceOpCode(
  +				opPos,
  +				XPathExpression::eOP_FUNCTION_STRINGLENGTH_0,
  +				XPathExpression::eOP_FUNCTION_STRINGLENGTH_1);
  +		}
  +		else
  +		{
  +			error("The string-length() function takes zero or one argument(s)");
  +		}
  +	}
  +}
  +
  +
  +
  +void
  +XPathProcessorImpl::FunctionNamespaceURI(int	opPos)
  +{
  +	m_expression->appendOpCode(XPathExpression::eOP_FUNCTION_NAMESPACEURI_0);
  +
  +	// Consume the name...
  +	nextToken();
  +
  +	// Get the arguments, and the argument count...
  +	const int	argCount = FunctionCallArguments();
  +
  +	if (argCount != 0)
  +	{
  +		if (argCount == 1)
  +		{
  +			m_expression->replaceOpCode(
  +				opPos,
  +				XPathExpression::eOP_FUNCTION_NAMESPACEURI_0,
  +				XPathExpression::eOP_FUNCTION_NAMESPACEURI_1);
  +		}
  +		else
  +		{
  +			error("The namespace-uri() function takes zero or one argument(s)");
  +		}
  +	}
  +}
  +
  +
  +
  +void
   XPathProcessorImpl::LocationPath()
   {
   	const int	opPos = m_expression->opCodeMapLength();
  @@ -1783,20 +2105,23 @@
   
   	if(tokenIs(XalanUnicode::charSolidus) == true)
   	{
  -		const int	newOpPos = m_expression->opCodeMapLength();
  +		nextToken();
   
  -		// Tell how long the step is without the predicate
  -		const XPathExpression::OpCodeMapValueVectorType		theArgs(1, 4);
  +		const int	newOpPos = m_expression->opCodeMapLength();
   
  -		m_expression->appendOpCode(XPathExpression::eFROM_ROOT,
  -								   theArgs);
  +//		if (tokenIs(XalanUnicode::charSolidus) == false)
  +		{
  +			// Tell how long the step is without the predicate
  +			const XPathExpression::OpCodeMapValueVectorType		theArgs(1, 4);
   
  -		m_expression->appendOpCode(XPathExpression::eNODETYPE_ROOT);
  +			m_expression->appendOpCode(XPathExpression::eFROM_ROOT,
  +									   theArgs);
   
  -		// Tell how long the entire step is.
  -		m_expression->updateOpCodeLength(newOpPos);
  +			m_expression->appendOpCode(XPathExpression::eNODETYPE_ROOT);
   
  -		nextToken();
  +			// Tell how long the entire step is.
  +			m_expression->updateOpCodeLength(newOpPos);
  +		}
   	}
   
   	if(length(m_token) != 0)
  @@ -1856,6 +2181,11 @@
   	{
   		nextToken();
   
  +		if(tokenIs(XalanUnicode::charLeftSquareBracket) == true)
  +		{
  +			error("'..[predicate]' or '.[predicate]' is illegal syntax.  Use 'self::node()[predicate]' instead.");
  +		}
  +
   		// Tell how long the step is without the predicate
   		const XPathExpression::OpCodeMapValueVectorType		theArgs(1, 4);
   
  @@ -2984,12 +3314,22 @@
   
   const XPathProcessorImpl::TableEntry	XPathProcessorImpl::s_functionTable[] =
   {
  +	{ XPathFunctionTable::s_not, XPathExpression::eOP_FUNCTION_NOT },
   	{ XPathProcessorImpl::s_lastString, XPathExpression::eOP_FUNCTION_LAST },
  +	{ XPathFunctionTable::s_name, XPathExpression::eOP_FUNCTION_NAME_0 },
   	{ XPathProcessorImpl::s_nodeString, XPathExpression::eNODETYPE_NODE },
   	{ XPathProcessorImpl::s_textString, XPathExpression::eNODETYPE_TEXT },
  +	{ XPathFunctionTable::s_true, XPathExpression::eOP_FUNCTION_TRUE },
   	{ XPathFunctionTable::s_count, XPathExpression::eOP_FUNCTION_COUNT  },
  +	{ XPathFunctionTable::s_false, XPathExpression::eOP_FUNCTION_FALSE },
  +	{ XPathFunctionTable::s_floor, XPathExpression::eOP_FUNCTION_FLOOR },
  +	{ XPathFunctionTable::s_round, XPathExpression::eOP_FUNCTION_ROUND },
  +	{ XPathFunctionTable::s_number, XPathExpression::eOP_FUNCTION_NUMBER_0 },
  +	{ XPathFunctionTable::s_boolean, XPathExpression::eOP_FUNCTION_BOOLEAN },
  +	{ XPathFunctionTable::s_ceiling, XPathExpression::eOP_FUNCTION_CEILING },
   	{ XPathProcessorImpl::s_commentString, XPathExpression::eNODETYPE_COMMENT },
   	{ XPathProcessorImpl::s_positionString, XPathExpression::eOP_FUNCTION_POSITION },
  +	{ XPathFunctionTable::s_localName, XPathExpression::eOP_FUNCTION_LOCALNAME_0 },
   	{ XPathProcessorImpl::s_piString, XPathExpression::eNODETYPE_PI },
   };
   
  
  
  
  1.30      +42 -7     xml-xalan/c/src/XPath/XPathProcessorImpl.hpp
  
  Index: XPathProcessorImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.hpp,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- XPathProcessorImpl.hpp	2 Jan 2003 17:39:09 -0000	1.29
  +++ XPathProcessorImpl.hpp	3 Jan 2003 08:04:24 -0000	1.30
  @@ -303,7 +303,7 @@
   	lookbehind( 
   			char	c,
   			int		n) const;
  - 
  +
   	/**
   	 * look behind the current token in order to 
   	 * see if there is a useable token.
  @@ -377,17 +377,13 @@
   	 * Throw an exception using the provided message text.
   	 */
   	void
  -	error(
  -			const XalanDOMString&	msg,
  -			XalanNode*				sourceNode = 0) const;
  +	error(const XalanDOMString&		msg) const;
   
   	/**
   	 * Throw an exception using the provided message text.
   	 */
   	void
  -	error(
  -			const char*		msg,
  -			XalanNode*		sourceNode = 0) const;
  +	error(const char*	msg) const;
   
   	/**
   	 * Given a string, return the corresponding token.
  @@ -590,6 +586,45 @@
   
   	void
   	FunctionCount();
  +
  +	void
  +	FunctionNot();
  +
  +	void
  +	FunctionTrue();
  +
  +	void
  +	FunctionFalse();
  +
  +	void
  +	FunctionBoolean();
  +
  +	void
  +	FunctionName(int	opPos);
  +
  +	void
  +	FunctionLocalName(int	opPos);
  +
  +	void
  +	FunctionNumber(int	opPos);
  +
  +	void
  +	FunctionFloor();
  +
  +	void
  +	FunctionCeiling();
  +
  +	void
  +	FunctionRound();
  +
  +	void
  +	FunctionString(int	opPos);
  +
  +	void
  +	FunctionStringLength(int	opPos);
  +
  +	void
  +	FunctionNamespaceURI(int	opPos);
   
   	/**
   	 * --------------------------------------------------------------------------------
  
  
  

---------------------------------------------------------------------
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