Back to index

lightning-sunbird  0.9+nobinonly
CurrentFunctionCall.cpp
Go to the documentation of this file.
00001 #include "txAtoms.h"
00002 #include "XSLTFunctions.h"
00003 #include "txExecutionState.h"
00004 
00005 /*
00006   Implementation of XSLT 1.0 extension function: current
00007 */
00008 
00012 CurrentFunctionCall::CurrentFunctionCall() 
00013 {
00014 }
00015 
00016 /*
00017  * Evaluates this Expr
00018  *
00019  * @return NodeSet containing the context node used for the complete
00020  * Expr or Pattern.
00021  */
00022 nsresult
00023 CurrentFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
00024 {
00025     *aResult = nsnull;
00026 
00027     if (!requireParams(0, 0, aContext))
00028         return NS_ERROR_XPATH_BAD_ARGUMENT_COUNT;
00029 
00030     txExecutionState* es = 
00031         NS_STATIC_CAST(txExecutionState*, aContext->getPrivateContext());
00032     if (!es) {
00033         NS_ASSERTION(0,
00034             "called xslt extension function \"current\" with wrong context");
00035         return NS_ERROR_UNEXPECTED;
00036     }
00037     return aContext->recycler()->getNodeSet(
00038           es->getEvalContext()->getContextNode(), aResult);
00039 }
00040 
00041 #ifdef TX_TO_STRING
00042 nsresult
00043 CurrentFunctionCall::getNameAtom(nsIAtom** aAtom)
00044 {
00045     *aAtom = txXSLTAtoms::current;
00046     NS_ADDREF(*aAtom);
00047     return NS_OK;
00048 }
00049 #endif