bug 113611, XPath and XSLT contexts. fixes bugs 96410, 102293, 92106, 110266, 116534 and a bunch of other cases not filed. This mostly fixes namespaces and some really bad speed issues by fixing the time when namespaces are resolved, how default priorities are computed and how templates are matched.

HUGE PERFWIN :-)
r=peterv, sr=jst


git-svn-id: svn://10.0.0.236/trunk@122650 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
axel%pike.org
2002-06-04 05:00:31 +00:00
parent c4d9baabad
commit f1b78d408d
76 changed files with 3740 additions and 2683 deletions

View File

@@ -24,6 +24,7 @@
*/
#include "Expr.h"
#include "txIXPathContext.h"
/**
* This class represents a FunctionCall as defined by the XSL Working Draft
@@ -77,50 +78,22 @@ FunctionCall::~FunctionCall()
* Adds the given parameter to this FunctionCall's parameter list
* @param expr the Expr to add to this FunctionCall's parameter list
**/
void FunctionCall::addParam(Expr* expr)
nsresult FunctionCall::addParam(Expr* aExpr)
{
if (expr)
params.add(expr);
if (aExpr)
params.add(aExpr);
return NS_OK;
} //-- addParam
/**
* Returns the default priority of this Expr based on the given Node,
* context Node, and ContextState.
**/
double FunctionCall::getDefaultPriority(Node* node,
Node* context,
ContextState* cs)
{
return 0.5;
} //-- getDefaultPriority
/**
* Determines whether this Expr matches the given node within
* the given context
**/
MBool FunctionCall::matches(Node* node, Node* context, ContextState* cs)
{
MBool result = MB_FALSE;
ExprResult* exprResult = evaluate(node, cs);
if (exprResult->getResultType() == ExprResult::NODESET) {
NodeSet* nodes = (NodeSet*)exprResult;
result = (nodes->contains(node));
}
delete exprResult;
return result;
} //-- matches
/*
* Evaluates the given Expression and converts its result to a String.
* The value is appended to the given destination String
*/
void FunctionCall::evaluateToString(Expr* aExpr,
Node* aContext,
ContextState* aCs,
void FunctionCall::evaluateToString(Expr* aExpr, txIEvalContext* aContext,
String& aDest)
{
NS_ASSERTION(aExpr, "missing expression");
ExprResult* exprResult = aExpr->evaluate(aContext, aCs);
ExprResult* exprResult = aExpr->evaluate(aContext);
if (!exprResult)
return;
@@ -131,12 +104,10 @@ void FunctionCall::evaluateToString(Expr* aExpr,
/*
* Evaluates the given Expression and converts its result to a number.
*/
double FunctionCall::evaluateToNumber(Expr* aExpr,
Node* aContext,
ContextState* aCs)
double FunctionCall::evaluateToNumber(Expr* aExpr, txIEvalContext* aContext)
{
NS_ASSERTION(aExpr, "missing expression");
ExprResult* exprResult = aExpr->evaluate(aContext, aCs);
ExprResult* exprResult = aExpr->evaluate(aContext);
if (!exprResult)
return Double::NaN;
@@ -148,12 +119,10 @@ double FunctionCall::evaluateToNumber(Expr* aExpr,
/*
* Evaluates the given Expression and converts its result to a boolean.
*/
MBool FunctionCall::evaluateToBoolean(Expr* aExpr,
Node* aContext,
ContextState* aCs)
MBool FunctionCall::evaluateToBoolean(Expr* aExpr, txIEvalContext* aContext)
{
NS_ASSERTION(aExpr, "missing expression");
ExprResult* exprResult = aExpr->evaluate(aContext, aCs);
ExprResult* exprResult = aExpr->evaluate(aContext);
if (!exprResult)
return MB_FALSE;
@@ -166,18 +135,16 @@ MBool FunctionCall::evaluateToBoolean(Expr* aExpr,
* Evaluates the given Expression and converts its result to a NodeSet.
* If the result is not a NodeSet NULL is returned.
*/
NodeSet* FunctionCall::evaluateToNodeSet(Expr* aExpr,
Node* aContext,
ContextState* aCs)
NodeSet* FunctionCall::evaluateToNodeSet(Expr* aExpr, txIEvalContext* aContext)
{
NS_ASSERTION(aExpr, "Missing expression to evaluate");
ExprResult* exprResult = aExpr->evaluate(aContext, aCs);
ExprResult* exprResult = aExpr->evaluate(aContext);
if (!exprResult)
return 0;
if (exprResult->getResultType() != ExprResult::NODESET) {
String err("NodeSet expected as argument");
aCs->recieveError(err);
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
delete exprResult;
return 0;
}
@@ -190,13 +157,13 @@ NodeSet* FunctionCall::evaluateToNodeSet(Expr* aExpr,
**/
MBool FunctionCall::requireParams (int paramCountMin,
int paramCountMax,
ContextState* cs)
txIEvalContext* aContext)
{
int argc = params.getLength();
if ((argc < paramCountMin) || (argc > paramCountMax)) {
String err(INVALID_PARAM_COUNT);
toString(err);
cs->recieveError(err);
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
return MB_FALSE;
}
return MB_TRUE;
@@ -205,13 +172,13 @@ MBool FunctionCall::requireParams (int paramCountMin,
/**
* Called to check number of parameters
**/
MBool FunctionCall::requireParams(int paramCountMin, ContextState* cs)
MBool FunctionCall::requireParams(int paramCountMin, txIEvalContext* aContext)
{
int argc = params.getLength();
if (argc < paramCountMin) {
String err(INVALID_PARAM_COUNT);
toString(err);
cs->recieveError(err);
aContext->receiveError(err, NS_ERROR_XPATH_INVALID_ARG);
return MB_FALSE;
}
return MB_TRUE;