peterv%netscape.com f21892e8db Landing TX_BRIDGE_1_1_BRANCH.
Rewrite pretty much all variable and parameter handling. Makes global and local variables be handled differently. Global variables are no longer part of the variables stack, and are lazily evaluated. Fixes bugs 117658, 92929 and some unfiled bugs and fixes remaining parts of bugs 83651 and 96802. Patch by sicking, r=Pike sr=bz.

Fix for bug 156464: fix rounding problems in module, allow patterns without any '0's in the integer part and fix problems with grouping for standalone. Patch by sicking, r=Pike sr=bz.

Fix for bug 157340 (Probable bugs in extensions/transformiix/source/base/txMozillaString.h). Patch by peterv, r=Pike, sr=bz.

Fix for bug 146967 (Clean up Transformiix strings). Patch by peterv, r=sicking, sr=jst.

Fix for bug 156464 (Remove static strings from Transformiix). Patch by peterv, r=Pike, sr=jst.


git-svn-id: svn://10.0.0.236/trunk@126495 18797224-902f-48f8-a5cc-f745e15eee43
2002-08-06 12:28:27 +00:00

96 lines
2.8 KiB
C++

/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is TransforMiiX XSLT processor.
*
* The Initial Developer of the Original Code is The MITRE Corporation.
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
*
* Portions created by Keith Visco as a Non MITRE employee,
* (C) 1999 Keith Visco. All Rights Reserved.
*
* Contributor(s):
* Keith Visco, kvisco@ziplink.net
* -- original author.
*
*/
#include "Expr.h"
#include "txAtoms.h"
#include "txIXPathContext.h"
//-------------------/
//- VariableRefExpr -/
//-------------------/
/**
* Creates a VariableRefExpr with the given variable name
**/
VariableRefExpr::VariableRefExpr(txAtom* aPrefix, txAtom* aLocalName,
PRInt32 aNSID)
: mPrefix(aPrefix), mLocalName(aLocalName), mNamespace(aNSID)
{
NS_ASSERTION(mLocalName, "VariableRefExpr without local name?");
if (mPrefix == txXMLAtoms::_empty)
mPrefix = 0;
TX_IF_ADDREF_ATOM(mPrefix);
TX_IF_ADDREF_ATOM(mLocalName);
}
/*
* Release the local name atom
*/
VariableRefExpr::~VariableRefExpr()
{
TX_IF_RELEASE_ATOM(mPrefix);
TX_IF_RELEASE_ATOM(mLocalName);
}
/**
* Evaluates this Expr based on the given context node and processor state
* @param context the context node for evaluation of this Expr
* @param ps the ContextState containing the stack information needed
* for evaluation
* @return the result of the evaluation
**/
ExprResult* VariableRefExpr::evaluate(txIEvalContext* aContext)
{
ExprResult* exprResult = 0;
nsresult rv = aContext->getVariable(mNamespace, mLocalName, exprResult);
if (NS_FAILED(rv)) {
// XXX report error, undefined variable
return new StringResult("error");
}
return exprResult->clone();
}
/**
* Returns the String representation of this Expr.
* @param dest the String to use when creating the String
* representation. The String representation will be appended to
* any data in the destination String, to allow cascading calls to
* other #toString() methods for Expressions.
* @return the String representation of this Expr.
**/
void VariableRefExpr::toString(String& aDest)
{
aDest.append('$');
if (mPrefix) {
String prefix;
TX_GET_ATOM_STRING(mPrefix, prefix);
aDest.append(prefix);
aDest.append(':');
}
String lname;
TX_GET_ATOM_STRING(mLocalName, lname);
aDest.append(lname);
} //-- toString