1 : #include "nsGkAtoms.h"
2 : #include "txXSLTFunctions.h"
3 : #include "txExecutionState.h"
4 :
5 : /*
6 : Implementation of XSLT 1.0 extension function: current
7 : */
8 :
9 : /**
10 : * Creates a new current function call
11 : **/
12 0 : CurrentFunctionCall::CurrentFunctionCall()
13 : {
14 0 : }
15 :
16 : /*
17 : * Evaluates this Expr
18 : *
19 : * @return NodeSet containing the context node used for the complete
20 : * Expr or Pattern.
21 : */
22 : nsresult
23 0 : CurrentFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
24 : {
25 0 : *aResult = nsnull;
26 :
27 0 : if (!requireParams(0, 0, aContext))
28 0 : return NS_ERROR_XPATH_BAD_ARGUMENT_COUNT;
29 :
30 : txExecutionState* es =
31 0 : static_cast<txExecutionState*>(aContext->getPrivateContext());
32 0 : if (!es) {
33 : NS_ERROR(
34 0 : "called xslt extension function \"current\" with wrong context");
35 0 : return NS_ERROR_UNEXPECTED;
36 : }
37 0 : return aContext->recycler()->getNodeSet(
38 0 : es->getEvalContext()->getContextNode(), aResult);
39 : }
40 :
41 : Expr::ResultType
42 0 : CurrentFunctionCall::getReturnType()
43 : {
44 0 : return NODESET_RESULT;
45 : }
46 :
47 : bool
48 0 : CurrentFunctionCall::isSensitiveTo(ContextSensitivity aContext)
49 : {
50 0 : return !!(aContext & PRIVATE_CONTEXT);
51 : }
52 :
53 : #ifdef TX_TO_STRING
54 : nsresult
55 0 : CurrentFunctionCall::getNameAtom(nsIAtom** aAtom)
56 : {
57 0 : *aAtom = nsGkAtoms::current;
58 0 : NS_ADDREF(*aAtom);
59 0 : return NS_OK;
60 : }
61 : #endif
|