Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Public Attributes | Private Attributes | Static Private Attributes
txExecutionState Class Reference

#include <txExecutionState.h>

Inheritance diagram for txExecutionState:
Inheritance graph
[legend]
Collaboration diagram for txExecutionState:
Collaboration graph
[legend]

List of all members.

Classes

struct  TemplateRule
 Struct holding information about a current template rule. More...

Public Member Functions

 txExecutionState (txStylesheet *aStylesheet, PRBool aDisableLoads)
 ~txExecutionState ()
nsresult init (const txXPathNode &aNode, txExpandedNameMap *aGlobalParams)
nsresult end (nsresult aResult)
nsresult pushEvalContext (txIEvalContext *aContext)
txIEvalContextpopEvalContext ()
nsresult pushString (const nsAString &aStr)
void popString (nsAString &aStr)
nsresult pushInt (PRInt32 aInt)
PRInt32 popInt ()
nsresult pushResultHandler (txAXMLEventHandler *aHandler)
txAXMLEventHandlerpopResultHandler ()
nsresult pushTemplateRule (txStylesheet::ImportFrame *aFrame, const txExpandedName &aMode, txVariableMap *aParams)
void popTemplateRule ()
nsresult pushParamMap (txVariableMap *aParams)
txVariableMappopParamMap ()
txIEvalContextgetEvalContext ()
txExpandedNameMapgetParamMap ()
const txXPathNoderetrieveDocument (const nsAString &aUri)
nsresult getKeyNodes (const txExpandedName &aKeyName, const txXPathNode &aDocument, const nsAString &aKeyValue, PRBool aIndexIfNotFound, txNodeSet **aResult)
TemplateRulegetCurrentTemplateRule ()
txInstructiongetNextInstruction ()
nsresult runTemplate (txInstruction *aInstruction)
nsresult runTemplate (txInstruction *aInstruction, txInstruction *aReturnTo)
void gotoInstruction (txInstruction *aNext)
void returnFromTemplate ()
nsresult bindVariable (const txExpandedName &aName, txAExprResult *aValue)
void removeVariable (const txExpandedName &aName)
virtual nsresult getVariable (PRInt32 aNamespace, nsIAtom *aLName, txAExprResult *&aResult)=0
virtual MBool isStripSpaceAllowed (const txXPathNode &aNode)=0
virtual voidgetPrivateContext ()=0
 Returns a pointer to the private context.
virtual txResultRecyclerrecycler ()=0
virtual void receiveError (const nsAString &aMsg, nsresult aRes)=0

Public Attributes

 TX_DECL_MATCH_CONTEXT
txAXMLEventHandlermOutputHandler
txAXMLEventHandlermResultHandler
txAOutputHandlerFactorymOutputHandlerFactory
nsAutoPtr< txVariableMapmTemplateParams
nsRefPtr< txStylesheetmStylesheet

Private Attributes

txStack mReturnStack
txStack mLocalVarsStack
txStack mEvalContextStack
txStack mIntStack
txStack mResultHandlerStack
txStack mParamStack
nsStringArray mStringStack
txInstructionmNextInstruction
txVariableMapmLocalVariables
txVariableMap mGlobalVariableValues
nsRefPtr< txAExprResultmGlobalVarPlaceholderValue
PRInt32 mRecursionDepth
TemplateRulemTemplateRules
PRInt32 mTemplateRulesBufferSize
PRInt32 mTemplateRuleCount
txIEvalContextmEvalContext
txIEvalContextmInitialEvalContext
txExpandedNameMapmGlobalParams
txLoadedDocumentsHash mLoadedDocuments
txKeyHash mKeyHash
nsRefPtr< txResultRecyclermRecycler
PRPackedBool mDisableLoads

Static Private Attributes

static const PRInt32 kMaxRecursionDepth = 20000

Detailed Description

Definition at line 92 of file txExecutionState.h.


Class Documentation

struct txExecutionState::TemplateRule

Struct holding information about a current template rule.

Definition at line 105 of file txExecutionState.h.

Collaboration diagram for txExecutionState::TemplateRule:
Class Members
ImportFrame * mFrame
nsIAtom * mModeLocalName
PRInt32 mModeNsId
txVariableMap * mParams

Constructor & Destructor Documentation

txExecutionState::txExecutionState ( txStylesheet aStylesheet,
PRBool  aDisableLoads 
)

Definition at line 105 of file txExecutionState.cpp.

{
    delete mResultHandler;
    delete mLocalVariables;
    delete mEvalContext;
//    delete mRTFDocument;

    PRInt32 i;
    for (i = 0; i < mTemplateRuleCount; ++i) {
        NS_IF_RELEASE(mTemplateRules[i].mModeLocalName);
    }
    delete [] mTemplateRules;
    
    txStackIterator varsIter(&mLocalVarsStack);
    while (varsIter.hasNext()) {
        delete (txVariableMap*)varsIter.next();
    }

    txStackIterator contextIter(&mEvalContextStack);
    while (contextIter.hasNext()) {
        txIEvalContext* context = (txIEvalContext*)contextIter.next();
        if (context != mInitialEvalContext) {
            delete context;
        }
    }

    txStackIterator handlerIter(&mResultHandlerStack);
    while (handlerIter.hasNext()) {
        delete (txAXMLEventHandler*)handlerIter.next();
    }

    txStackIterator paramIter(&mParamStack);
    while (paramIter.hasNext()) {
        delete (txExpandedNameMap*)paramIter.next();
    }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 567 of file txExecutionState.cpp.

Here is the call graph for this function:

Definition at line 204 of file txExecutionState.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 515 of file txExecutionState.cpp.

Definition at line 457 of file txExecutionState.cpp.

{
    return mEvalContext;
}
nsresult txExecutionState::getKeyNodes ( const txExpandedName aKeyName,
const txXPathNode aDocument,
const nsAString &  aKeyValue,
PRBool  aIndexIfNotFound,
txNodeSet **  aResult 
)

Definition at line 504 of file txExecutionState.cpp.

{
    return mKeyHash.getKeyNodes(aKeyName, aDocument, aKeyValue,
                                aIndexIfNotFound, *this, aResult);
}

Here is the call graph for this function:

Definition at line 521 of file txExecutionState.cpp.

{
    txInstruction* instr = mNextInstruction;
    if (instr) {
        mNextInstruction = instr->mNext;
    }
    
    return instr;
}

Here is the caller graph for this function:

virtual void* txIMatchContext::getPrivateContext ( ) [pure virtual, inherited]

Returns a pointer to the private context.

Implemented in txXSLTParamContext, and txSingleNodeContext.

Here is the caller graph for this function:

virtual nsresult txIMatchContext::getVariable ( PRInt32  aNamespace,
nsIAtom aLName,
txAExprResult *&  aResult 
) [pure virtual, inherited]

Implemented in txXSLTParamContext, and txSingleNodeContext.

Here is the caller graph for this function:

Definition at line 550 of file txExecutionState.cpp.

{
    mNextInstruction = aNext;
}

Definition at line 143 of file txExecutionState.cpp.

{
    nsresult rv = NS_OK;

    mGlobalParams = aGlobalParams;

    // Set up initial context
    mEvalContext = new txSingleNodeContext(aNode, this);
    NS_ENSURE_TRUE(mEvalContext, NS_ERROR_OUT_OF_MEMORY);

    mInitialEvalContext = mEvalContext;

    // Set up output and result-handler
    txAXMLEventHandler* handler = 0;
    rv = mOutputHandlerFactory->
        createHandlerWith(mStylesheet->getOutputFormat(), &handler);
    NS_ENSURE_SUCCESS(rv, rv);

    mOutputHandler = handler;
    mResultHandler = handler;
    mOutputHandler->startDocument();

    // Set up loaded-documents-hash
    nsAutoPtr<txXPathNode> document(txXPathNodeUtils::getOwnerDocument(aNode));
    NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);

    rv = mLoadedDocuments.init(document);
    NS_ENSURE_SUCCESS(rv, rv);

    // loaded-documents-hash owns this now
    document.forget();

    // Init members
    rv = mKeyHash.init();
    NS_ENSURE_SUCCESS(rv, rv);
    
    mRecycler = new txResultRecycler;
    NS_ENSURE_TRUE(mRecycler, NS_ERROR_OUT_OF_MEMORY);
    
    rv = mRecycler->init();
    NS_ENSURE_SUCCESS(rv, rv);
    
    // The actual value here doesn't really matter since noone should use this
    // value. But lets put something errorlike in just in case
    mGlobalVarPlaceholderValue = new StringResult(NS_LITERAL_STRING("Error"), nsnull);
    NS_ENSURE_TRUE(mGlobalVarPlaceholderValue, NS_ERROR_OUT_OF_MEMORY);

    // Initiate first instruction. This has to be done last since findTemplate
    // might use us.
    txStylesheet::ImportFrame* frame = 0;
    txExpandedName nullName;
    txInstruction* templ = mStylesheet->findTemplate(aNode, nullName,
                                                     this, nsnull, &frame);
    rv = pushTemplateRule(frame, nullName, nsnull);
    NS_ENSURE_SUCCESS(rv, rv);

    return runTemplate(templ);
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual MBool txIMatchContext::isStripSpaceAllowed ( const txXPathNode aNode) [pure virtual, inherited]

Implemented in txXSLTParamContext, and txSingleNodeContext.

Here is the caller graph for this function:

Definition at line 361 of file txExecutionState.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 395 of file txExecutionState.cpp.

{
    return NS_PTR_TO_INT32(mIntStack.pop());
}

Here is the call graph for this function:

Definition at line 596 of file txExecutionState.cpp.

{
    txVariableMap* oldParams = mTemplateParams.forget();
    mTemplateParams = (txVariableMap*)mParamStack.pop();

    return oldParams;
}

Here is the call graph for this function:

Definition at line 412 of file txExecutionState.cpp.

Here is the call graph for this function:

void txExecutionState::popString ( nsAString &  aStr)

Definition at line 380 of file txExecutionState.cpp.

{
    PRInt32 count = mStringStack.Count() - 1;
    NS_ASSERTION(count >= 0, "stack is empty");
    mStringStack.StringAt(count, aStr);
    mStringStack.RemoveStringAt(count);
}

Definition at line 449 of file txExecutionState.cpp.

{
    // decrement outside of RELEASE, that would decrement twice
    --mTemplateRuleCount;
    NS_IF_RELEASE(mTemplateRules[mTemplateRuleCount].mModeLocalName);
}

Here is the caller graph for this function:

Definition at line 350 of file txExecutionState.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 389 of file txExecutionState.cpp.

{
    return mIntStack.push(NS_INT32_TO_PTR(aInt));
}

Here is the call graph for this function:

Definition at line 584 of file txExecutionState.cpp.

Here is the call graph for this function:

Definition at line 401 of file txExecutionState.cpp.

Here is the call graph for this function:

Definition at line 370 of file txExecutionState.cpp.

{
    if (!mStringStack.AppendString(aStr)) {
        return NS_ERROR_OUT_OF_MEMORY;
    }
    
    return NS_OK;
}

Definition at line 421 of file txExecutionState.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void txIMatchContext::receiveError ( const nsAString &  aMsg,
nsresult  aRes 
) [pure virtual, inherited]

Implemented in txXSLTParamContext, and txSingleNodeContext.

Here is the caller graph for this function:

virtual txResultRecycler* txIMatchContext::recycler ( ) [pure virtual, inherited]

Implemented in txXSLTParamContext, and txSingleNodeContext.

Here is the caller graph for this function:

Definition at line 578 of file txExecutionState.cpp.

Here is the call graph for this function:

Definition at line 463 of file txExecutionState.cpp.

{
    NS_ASSERTION(aUri.FindChar(PRUnichar('#')) == kNotFound,
                 "Remove the fragment.");

    if (mDisableLoads) {
        return nsnull;
    }

    PR_LOG(txLog::xslt, PR_LOG_DEBUG,
           ("Retrieve Document %s", NS_LossyConvertUCS2toASCII(aUri).get()));

    // try to get already loaded document
    txLoadedDocumentEntry *entry = mLoadedDocuments.PutEntry(aUri);
    if (!entry) {
        return nsnull;
    }

    if (!entry->mDocument) {
        // open URI
        nsAutoString errMsg;
        // XXX we should get the loader from the actual node
        // triggering the load, but this will do for the time being
        nsresult rv;
        rv = txParseDocumentFromURI(aUri, *mLoadedDocuments.mSourceDocument,
                                    errMsg,
                                    getter_Transfers(entry->mDocument));

        if (NS_FAILED(rv) || !entry->mDocument) {
            mLoadedDocuments.RawRemoveEntry(entry);
            receiveError(NS_LITERAL_STRING("Couldn't load document '") +
                         aUri + NS_LITERAL_STRING("': ") + errMsg, rv);

            return nsnull;
        }
    }

    return entry->mDocument;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 556 of file txExecutionState.cpp.

{
    --mRecursionDepth;
    NS_ASSERTION(!mReturnStack.isEmpty() && !mLocalVarsStack.isEmpty(),
                 "return or variable stack is empty");
    delete mLocalVariables;
    mNextInstruction = (txInstruction*)mReturnStack.pop();
    mLocalVariables = (txVariableMap*)mLocalVarsStack.pop();
}

Here is the call graph for this function:

Definition at line 532 of file txExecutionState.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txExecutionState::runTemplate ( txInstruction aInstruction,
txInstruction aReturnTo 
)

Member Data Documentation

Definition at line 185 of file txExecutionState.h.

Definition at line 183 of file txExecutionState.h.

Definition at line 175 of file txExecutionState.h.

Definition at line 160 of file txExecutionState.h.

Definition at line 178 of file txExecutionState.h.

Definition at line 167 of file txExecutionState.h.

Definition at line 168 of file txExecutionState.h.

Definition at line 176 of file txExecutionState.h.

Definition at line 161 of file txExecutionState.h.

Definition at line 181 of file txExecutionState.h.

Definition at line 180 of file txExecutionState.h.

Definition at line 166 of file txExecutionState.h.

Definition at line 159 of file txExecutionState.h.

Definition at line 165 of file txExecutionState.h.

Definition at line 149 of file txExecutionState.h.

Definition at line 151 of file txExecutionState.h.

Definition at line 163 of file txExecutionState.h.

Definition at line 169 of file txExecutionState.h.

Definition at line 182 of file txExecutionState.h.

Definition at line 150 of file txExecutionState.h.

Definition at line 162 of file txExecutionState.h.

Definition at line 158 of file txExecutionState.h.

nsStringArray txExecutionState::mStringStack [private]

Definition at line 164 of file txExecutionState.h.

Definition at line 155 of file txExecutionState.h.

Definition at line 153 of file txExecutionState.h.

Definition at line 173 of file txExecutionState.h.

Definition at line 171 of file txExecutionState.h.

Definition at line 172 of file txExecutionState.h.

Definition at line 100 of file txExecutionState.h.


The documentation for this class was generated from the following files: