Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Types | Protected Attributes | Private Attributes
txStylesheetCompilerState Class Reference

#include <txStylesheetCompiler.h>

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

List of all members.

Public Member Functions

 txStylesheetCompilerState (txACompileObserver *aObserver)
 txStylesheetCompilerState
 ~txStylesheetCompilerState ()
nsresult init (const nsAString &aStylesheetURI, txStylesheet *aStylesheet, txListIterator *aInsertPosition)
PRBool handleEmbeddedSheet ()
void doneEmbedding ()
nsresult pushHandlerTable (txHandlerTable *aTable)
void popHandlerTable ()
nsresult pushSorter (txPushNewContext *aSorter)
void popSorter ()
nsresult pushChooseGotoList ()
void popChooseGotoList ()
nsresult pushObject (TxObject *aObject)
TxObjectpopObject ()
nsresult pushPtr (void *aPtr)
voidpopPtr ()
nsresult addToplevelItem (txToplevelItem *aItem)
nsresult openInstructionContainer (txInstructionContainer *aContainer)
void closeInstructionContainer ()
nsresult addInstruction (nsAutoPtr< txInstruction > aInstruction)
nsresult loadIncludedStylesheet (const nsAString &aURI)
nsresult loadImportedStylesheet (const nsAString &aURI, txStylesheet::ImportFrame *aFrame)
nsresult addGotoTarget (txInstruction **aTargetPointer)
nsresult addVariable (const txExpandedName &aName)
nsresult resolveNamespacePrefix (nsIAtom *aPrefix, PRInt32 &aID)
nsresult resolveFunctionCall (nsIAtom *aName, PRInt32 aID, FunctionCall *&aFunction)
PRBool caseInsensitiveNameTests ()
 Should nametests parsed in this context be case-sensitive.
PRBool fcp ()
 Should the stylesheet be parsed in forwards compatible parsing mode.
void SetErrorOffset (PRUint32 aOffset)

Public Attributes

nsRefPtr< txStylesheetmStylesheet
txHandlerTablemHandlerTable
nsAutoPtr< txElementContextmElementContext
txPushNewContextmSorter
nsAutoPtr< txListmChooseGotoList
PRPackedBool mDOE
PRPackedBool mSearchingForFallback

Protected Types

enum  { eNoEmbed, eNeedEmbed, eInEmbed, eHasEmbed }

Protected Attributes

nsRefPtr< txACompileObservermObserver
nsVoidArray mInScopeVariables
nsVoidArray mChildCompilerList
nsString mTarget
enum
txStylesheetCompilerState:: { ... }  
mEmbedStatus
nsString mStylesheetURI
PRPackedBool mIsTopCompiler
PRPackedBool mDoneWithThisStylesheet
txStack mObjectStack
txStack mOtherStack

Private Attributes

txInstruction ** mNextInstrPtr
txListIterator mToplevelIterator
nsVoidArray mGotoTargetPointers

Detailed Description

Definition at line 96 of file txStylesheetCompiler.h.


Member Enumeration Documentation

anonymous enum [protected]
Enumerator:
eNoEmbed 
eNeedEmbed 
eInEmbed 
eHasEmbed 

Definition at line 171 of file txStylesheetCompiler.h.


Constructor & Destructor Documentation

txStylesheetCompilerState

Definition at line 552 of file txStylesheetCompiler.cpp.

    : mHandlerTable(nsnull),
      mSorter(nsnull),
      mDOE(PR_FALSE),
      mSearchingForFallback(PR_FALSE),
      mObserver(aObserver),
      mEmbedStatus(eNoEmbed),
      mDoneWithThisStylesheet(PR_FALSE),
      mNextInstrPtr(nsnull),
      mToplevelIterator(nsnull)
{
    // Embedded stylesheets have another handler, which is set in
    // txStylesheetCompiler::init if the baseURI has a fragment identifier.
    mHandlerTable = gTxRootHandler;

}

Definition at line 621 of file txStylesheetCompiler.cpp.

{
    while (!mObjectStack.isEmpty()) {
        delete popObject();
    }
    
    PRInt32 i;
    for (i = mInScopeVariables.Count() - 1; i >= 0; --i) {
        delete NS_STATIC_CAST(txInScopeVariable*, mInScopeVariables[i]);
    }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 838 of file txStylesheetCompiler.cpp.

{
    if (!mGotoTargetPointers.AppendElement(aTargetPointer)) {
        return NS_ERROR_OUT_OF_MEMORY;
    }
    
    return NS_OK;
}

Here is the caller graph for this function:

Definition at line 742 of file txStylesheetCompiler.cpp.

{
    NS_PRECONDITION(mNextInstrPtr, "adding instruction outside container");

    txInstruction* newInstr = aInstruction;

    *mNextInstrPtr = aInstruction.forget();
    mNextInstrPtr = &newInstr->mNext;
    
    PRInt32 i, count = mGotoTargetPointers.Count();
    for (i = 0; i < count; ++i) {
        *NS_STATIC_CAST(txInstruction**, mGotoTargetPointers[i]) = newInstr;
    }
    mGotoTargetPointers.Clear();

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 719 of file txStylesheetCompiler.cpp.

{
    return mToplevelIterator.addBefore(aItem);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 848 of file txStylesheetCompiler.cpp.

{
    txInScopeVariable* var = new txInScopeVariable(aName);
    NS_ENSURE_TRUE(var, NS_ERROR_OUT_OF_MEMORY);

    if (!mInScopeVariables.AppendElement(var)) {
        delete var;
        return NS_ERROR_OUT_OF_MEMORY;
    }

    return NS_OK;
}

Here is the caller graph for this function:

Should nametests parsed in this context be case-sensitive.

Implements txIParseContext.

Definition at line 983 of file txStylesheetCompiler.cpp.

{
    return PR_FALSE;
}

Definition at line 734 of file txStylesheetCompiler.cpp.

{
    NS_ASSERTION(mGotoTargetPointers.Count() == 0,
                 "GotoTargets still exists, did you forget to add txReturn?");
    mNextInstrPtr = 0;
}

Here is the caller graph for this function:

Definition at line 110 of file txStylesheetCompiler.h.

Here is the caller graph for this function:

Should the stylesheet be parsed in forwards compatible parsing mode.

Definition at line 149 of file txStylesheetCompiler.h.

Here is the caller graph for this function:

Definition at line 106 of file txStylesheetCompiler.h.

    {
        return mEmbedStatus == eInEmbed;
    }

Here is the caller graph for this function:

nsresult txStylesheetCompilerState::init ( const nsAString &  aStylesheetURI,
txStylesheet aStylesheet,
txListIterator aInsertPosition 
)

Definition at line 570 of file txStylesheetCompiler.cpp.

{
    NS_ASSERTION(!aStylesheet || aInsertPosition,
                 "must provide insertposition if loading subsheet");
    mStylesheetURI = aStylesheetURI;
    // Check for fragment identifier of an embedded stylesheet.
    PRInt32 fragment = aStylesheetURI.FindChar('#') + 1;
    if (fragment > 0) {
        PRInt32 fragmentLength = aStylesheetURI.Length() - fragment;
        if (fragmentLength > 0) {
            // This is really an embedded stylesheet, not just a
            // "url#". We may want to unescape the fragment.
            mTarget = Substring(aStylesheetURI, (PRUint32)fragment,
                                fragmentLength);
            mEmbedStatus = eNeedEmbed;
            mHandlerTable = gTxEmbedHandler;
        }
    }
    nsresult rv = NS_OK;
    if (aStylesheet) {
        mStylesheet = aStylesheet;
        mToplevelIterator = *aInsertPosition;
        mIsTopCompiler = PR_FALSE;
    }
    else {
        mStylesheet = new txStylesheet;
        NS_ENSURE_TRUE(mStylesheet, NS_ERROR_OUT_OF_MEMORY);
        
        rv = mStylesheet->init();
        NS_ENSURE_SUCCESS(rv, rv);
        
        mToplevelIterator =
            txListIterator(&mStylesheet->mRootFrame->mToplevelItems);
        mToplevelIterator.next(); // go to the end of the list
        mIsTopCompiler = PR_TRUE;
    }
   
    mElementContext = new txElementContext(aStylesheetURI);
    NS_ENSURE_TRUE(mElementContext && mElementContext->mMappings,
                   NS_ERROR_OUT_OF_MEMORY);

    // Push the "old" txElementContext
    rv = pushObject(0);
    NS_ENSURE_SUCCESS(rv, rv);
    
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 805 of file txStylesheetCompiler.cpp.

{
    PR_LOG(txLog::xslt, PR_LOG_ALWAYS,
           ("CompilerState::loadImportedStylesheet: %s\n",
            NS_LossyConvertUCS2toASCII(aURI).get()));
    if (mStylesheetURI.Equals(aURI)) {
        return NS_ERROR_XSLT_LOAD_RECURSION;
    }
    NS_ENSURE_TRUE(mObserver, NS_ERROR_NOT_IMPLEMENTED);

    txListIterator iter(&aFrame->mToplevelItems);
    iter.next(); // go to the end of the list

    txACompileObserver* observer = NS_STATIC_CAST(txStylesheetCompiler*, this);

    nsRefPtr<txStylesheetCompiler> compiler =
        new txStylesheetCompiler(aURI, mStylesheet, &iter, observer);
    NS_ENSURE_TRUE(compiler, NS_ERROR_OUT_OF_MEMORY);

    if (!mChildCompilerList.AppendElement(compiler)) {
        return NS_ERROR_OUT_OF_MEMORY;
    }

    nsresult rv = mObserver->loadURI(aURI, mStylesheetURI, compiler);
    if (NS_FAILED(rv)) {
        mChildCompilerList.RemoveElement(compiler);
    }

    return rv;  
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 761 of file txStylesheetCompiler.cpp.

{
    PR_LOG(txLog::xslt, PR_LOG_ALWAYS,
           ("CompilerState::loadIncludedStylesheet: %s\n",
            NS_LossyConvertUCS2toASCII(aURI).get()));
    if (mStylesheetURI.Equals(aURI)) {
        return NS_ERROR_XSLT_LOAD_RECURSION;
    }
    NS_ENSURE_TRUE(mObserver, NS_ERROR_NOT_IMPLEMENTED);

    nsAutoPtr<txToplevelItem> item(new txDummyItem);
    NS_ENSURE_TRUE(item, NS_ERROR_OUT_OF_MEMORY);

    nsresult rv = mToplevelIterator.addBefore(item);
    NS_ENSURE_SUCCESS(rv, rv);
    
    item.forget();

    // step back to the dummy-item
    mToplevelIterator.previous();
    
    txACompileObserver* observer = NS_STATIC_CAST(txStylesheetCompiler*, this);

    nsRefPtr<txStylesheetCompiler> compiler =
        new txStylesheetCompiler(aURI, mStylesheet, &mToplevelIterator,
                                 observer);
    NS_ENSURE_TRUE(compiler, NS_ERROR_OUT_OF_MEMORY);

    // step forward before calling the observer in case of syncronous loading
    mToplevelIterator.next();

    if (!mChildCompilerList.AppendElement(compiler)) {
        return NS_ERROR_OUT_OF_MEMORY;
    }

    rv = mObserver->loadURI(aURI, mStylesheetURI, compiler);
    if (NS_FAILED(rv)) {
        mChildCompilerList.RemoveElement(compiler);
    }

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 725 of file txStylesheetCompiler.cpp.

{
    NS_PRECONDITION(!mNextInstrPtr, "can't nest instruction-containers");

    mNextInstrPtr = aContainer->mFirstInstruction.StartAssignment();
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 681 of file txStylesheetCompiler.cpp.

{
    // this will delete the old value
    mChooseGotoList = NS_STATIC_CAST(txList*, popObject());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 645 of file txStylesheetCompiler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 694 of file txStylesheetCompiler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 709 of file txStylesheetCompiler.cpp.

{
    void* value = mOtherStack.pop();
#ifdef TX_DEBUG_STACK
    PR_LOG(txLog::xslt, PR_LOG_DEBUG, ("popPtr: %d\n", value));
#endif
    return value;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 662 of file txStylesheetCompiler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 668 of file txStylesheetCompiler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 634 of file txStylesheetCompiler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 688 of file txStylesheetCompiler.cpp.

{
    return mObjectStack.push(aObject);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 700 of file txStylesheetCompiler.cpp.

{
#ifdef TX_DEBUG_STACK
    PR_LOG(txLog::xslt, PR_LOG_DEBUG, ("pushPtr: %d\n", aPtr));
#endif
    return mOtherStack.push(aPtr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 651 of file txStylesheetCompiler.cpp.

{
    nsresult rv = pushPtr(mSorter);
    NS_ENSURE_SUCCESS(rv, rv);

    mSorter = aSorter;

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txStylesheetCompilerState::resolveFunctionCall ( nsIAtom aName,
PRInt32  aID,
FunctionCall *&  aFunction 
) [virtual]

Implements txIParseContext.

Definition at line 911 of file txStylesheetCompiler.cpp.

{
    aFunction = nsnull;

    if (aID == kNameSpaceID_None) {
        if (aName == txXSLTAtoms::document) {
            aFunction = new DocumentFunctionCall(mElementContext->mBaseURI);
            NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
    
            return NS_OK;
        }
        if (aName == txXSLTAtoms::key) {
            aFunction = new txKeyFunctionCall(mElementContext->mMappings);
            NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
    
            return NS_OK;
        }
        if (aName == txXSLTAtoms::formatNumber) {
            aFunction = new txFormatNumberFunctionCall(mStylesheet,
                                                       mElementContext->mMappings);
            NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
    
            return NS_OK;
        }
        if (aName == txXSLTAtoms::current) {
            aFunction = new CurrentFunctionCall();
            NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
    
            return NS_OK;
        }
        if (aName == txXSLTAtoms::unparsedEntityUri) {
    
            return NS_ERROR_NOT_IMPLEMENTED;
        }
        if (aName == txXSLTAtoms::generateId) {
            aFunction = new GenerateIdFunctionCall();
            NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
    
            return NS_OK;
        }
        if (aName == txXSLTAtoms::systemProperty) {
            aFunction = new SystemPropertyFunctionCall(mElementContext->mMappings);
            NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
    
            return NS_OK;
        }
        if (aName == txXSLTAtoms::elementAvailable) {
            aFunction =
                new ElementAvailableFunctionCall(mElementContext->mMappings);
            NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
    
            return NS_OK;
        }
        if (aName == txXSLTAtoms::functionAvailable) {
            aFunction =
                new FunctionAvailableFunctionCall(mElementContext->mMappings);
            NS_ENSURE_TRUE(aFunction, NS_ERROR_OUT_OF_MEMORY);
    
            return NS_OK;
        }
        if (!fcp()) {
            return NS_ERROR_XPATH_UNKNOWN_FUNCTION;
        }
    }

    aFunction = new txErrorFunctionCall(aName, aID);

    return aFunction ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

Here is the call graph for this function:

Implements txIParseContext.

Definition at line 862 of file txStylesheetCompiler.cpp.

{
    NS_ASSERTION(aPrefix && aPrefix != txXMLAtoms::_empty,
                 "caller should handle default namespace ''");
    aID = mElementContext->mMappings->lookupNamespace(aPrefix);
    return (aID != kNameSpaceID_Unknown) ? NS_OK : NS_ERROR_FAILURE;
}

Implements txIParseContext.

Definition at line 989 of file txStylesheetCompiler.cpp.

{
    // XXX implement me
}

Member Data Documentation

Definition at line 168 of file txStylesheetCompiler.h.

Definition at line 161 of file txStylesheetCompiler.h.

Definition at line 162 of file txStylesheetCompiler.h.

Definition at line 180 of file txStylesheetCompiler.h.

Definition at line 159 of file txStylesheetCompiler.h.

enum { ... } txStylesheetCompilerState::mEmbedStatus [protected]

Definition at line 187 of file txStylesheetCompiler.h.

Definition at line 158 of file txStylesheetCompiler.h.

Definition at line 167 of file txStylesheetCompiler.h.

Definition at line 179 of file txStylesheetCompiler.h.

Definition at line 185 of file txStylesheetCompiler.h.

Definition at line 181 of file txStylesheetCompiler.h.

Definition at line 166 of file txStylesheetCompiler.h.

Definition at line 182 of file txStylesheetCompiler.h.

Definition at line 163 of file txStylesheetCompiler.h.

Definition at line 160 of file txStylesheetCompiler.h.

Definition at line 157 of file txStylesheetCompiler.h.

Definition at line 178 of file txStylesheetCompiler.h.

Definition at line 170 of file txStylesheetCompiler.h.

Definition at line 186 of file txStylesheetCompiler.h.


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