Index: build/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/build/Makefile.in,v
retrieving revision 1.61
diff -u -3 -r1.61 Makefile.in
--- build/Makefile.in 17 Jan 2003 12:40:47 -0000 1.61
+++ build/Makefile.in 20 Jan 2003 11:52:58 -0000
@@ -58,7 +58,6 @@
../source/base/Map.$(OBJ_SUFFIX) \
../source/base/NamedMap.$(OBJ_SUFFIX) \
../source/base/SimpleErrorObserver.$(OBJ_SUFFIX) \
- ../source/base/Stack.$(OBJ_SUFFIX) \
../source/base/Tokenizer.$(OBJ_SUFFIX) \
../source/base/txAtoms.$(OBJ_SUFFIX) \
../source/base/txExpandedNameMap.$(OBJ_SUFFIX) \
Index: macbuild/transformiix.xml
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/macbuild/transformiix.xml,v
retrieving revision 1.20
diff -u -3 -r1.20 transformiix.xml
--- macbuild/transformiix.xml 17 Jan 2003 12:44:20 -0000 1.20
+++ macbuild/transformiix.xml 20 Jan 2003 11:53:09 -0000
@@ -1099,13 +1099,6 @@
Name
- Stack.cpp
- MacOS
- Text
-
-
-
- Name
XMLUtils.cpp
MacOS
Text
@@ -1646,11 +1639,6 @@
Name
- Stack.cpp
- MacOS
-
-
- Name
XMLUtils.cpp
MacOS
@@ -2971,13 +2959,6 @@
Name
- Stack.cpp
- MacOS
- Text
-
-
-
- Name
XMLUtils.cpp
MacOS
Text
@@ -3534,11 +3515,6 @@
Name
- Stack.cpp
- MacOS
-
-
- Name
XMLUtils.cpp
MacOS
@@ -3947,12 +3923,6 @@
transformiixDebug.shlb
Name
SimpleErrorObserver.cpp
- MacOS
-
-
- transformiixDebug.shlb
- Name
- Stack.cpp
MacOS
Index: source/base/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/source/base/Makefile.in,v
retrieving revision 1.25
diff -u -3 -r1.25 Makefile.in
--- source/base/Makefile.in 17 Jan 2003 12:40:38 -0000 1.25
+++ source/base/Makefile.in 20 Jan 2003 11:53:09 -0000
@@ -47,7 +47,6 @@
Map.cpp \
NamedMap.cpp \
SimpleErrorObserver.cpp \
- Stack.cpp \
Tokenizer.cpp \
txAtoms.cpp \
txExpandedNameMap.cpp \
Index: source/base/txStack.h
===================================================================
RCS file: source/base/txStack.h
diff -N source/base/txStack.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ source/base/txStack.h 20 Jan 2003 11:53:09 -0000
@@ -0,0 +1,149 @@
+//* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * 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 mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2002
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Peter Van der Beken (original author)
+ *
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef txStack_h___
+#define txStack_h___
+
+#include "nsVoidArray.h"
+
+class txStack : private nsVoidArray
+{
+public:
+ /**
+ * Returns the specified object from the top of this stack,
+ * without removing it from the stack.
+ *
+ * @return a pointer to the object that is the top of this stack.
+ */
+ void* peek()
+ {
+ return ElementAt(Count() - 1);
+ }
+
+ /**
+ * Adds the specified object to the top of this stack.
+ *
+ * @param obj a pointer to the object that is to be added to the
+ * top of this stack.
+ */
+ nsresult push(void* aObject)
+ {
+ return AppendElement(aObject);
+ }
+
+ /**
+ * Removes and returns the specified object from the top of this
+ * stack.
+ *
+ * @return a pointer to the object that was the top of this stack.
+ */
+ void* pop()
+ {
+ PRInt32 count = Count() - 1;
+ void* object = ElementAt(count);
+ RemoveElementAt(count);
+ return object;
+ }
+
+ /**
+ * Returns true if there are no objects in the stack.
+ *
+ * @return true if there are no objects in the stack.
+ */
+ PRBool isEmpty()
+ {
+ return (Count() > 0);
+ }
+
+ /**
+ * Returns the number of elements in the Stack.
+ *
+ * @return the number of elements in the Stack.
+ */
+ PRInt32 size()
+ {
+ return Count();
+ }
+
+private:
+ friend class txStackIterator;
+};
+
+class txStackIterator
+{
+public:
+ /**
+ * Creates an iterator for the given stack.
+ *
+ * @param aStack the stack to create an iterator for.
+ */
+ txStackIterator(txStack* aStack) : mStack(aStack),
+ mCounter(0)
+ {
+ }
+
+ /**
+ * Returns true if there is more objects on the stack.
+ *
+ * @return .
+ */
+ PRBool hasNext()
+ {
+ return (mCounter < mStack->Count());
+ }
+
+ /**
+ * Returns the next object pointer from the stack.
+ *
+ * @return .
+ */
+ void* next()
+ {
+ if (mCounter == mStack->Count()) {
+ return nsnull;
+ }
+ return mStack->ElementAt(mCounter++);
+ }
+
+private:
+ txStack* mStack;
+ PRUint32 mCounter;
+};
+
+#endif /* txStack_h___ */
Index: source/main/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/source/main/Makefile.in,v
retrieving revision 1.30
diff -u -3 -r1.30 Makefile.in
--- source/main/Makefile.in 17 Jan 2003 12:40:42 -0000 1.30
+++ source/main/Makefile.in 20 Jan 2003 11:53:09 -0000
@@ -45,7 +45,6 @@
../base/Map.$(OBJ_SUFFIX) \
../base/NamedMap.$(OBJ_SUFFIX) \
../base/SimpleErrorObserver.$(OBJ_SUFFIX) \
- ../base/Stack.$(OBJ_SUFFIX) \
../base/Tokenizer.$(OBJ_SUFFIX) \
../base/txAtoms.$(OBJ_SUFFIX) \
../base/txExpandedNameMap.$(OBJ_SUFFIX) \
Index: source/xpath/ExprParser.cpp
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/source/xpath/ExprParser.cpp,v
retrieving revision 1.31
diff -u -3 -r1.31 ExprParser.cpp
--- source/xpath/ExprParser.cpp 19 Jan 2003 23:17:01 -0000 1.31
+++ source/xpath/ExprParser.cpp 20 Jan 2003 11:53:10 -0000
@@ -41,7 +41,7 @@
#include "ExprParser.h"
#include "ExprLexer.h"
#include "FunctionLib.h"
-#include "Stack.h"
+#include "txStack.h"
#include "txAtoms.h"
#include "txIXPathContext.h"
#include "txStringUtils.h"
@@ -235,8 +235,8 @@
Expr* expr = 0;
- Stack exprs;
- Stack ops;
+ txStack exprs;
+ txStack ops;
while (!done) {
@@ -280,7 +280,7 @@
case Token::MULTIPLY_OP:
case Token::SUBTRACTION_OP:
{
- while (!exprs.empty() &&
+ while (!exprs.isEmpty() &&
precedenceLevel(tok->type)
<= precedenceLevel(((Token*)ops.peek())->type)) {
expr = createBinaryExpr((Expr*)exprs.pop(),
@@ -300,13 +300,13 @@
// make sure expr != 0
if (!expr) {
- while (!exprs.empty()) {
+ while (!exprs.isEmpty()) {
delete (Expr*)exprs.pop();
}
return 0;
}
- while (!exprs.empty()) {
+ while (!exprs.isEmpty()) {
expr = createBinaryExpr((Expr*)exprs.pop(), expr, (Token*)ops.pop());
}
Index: source/xslt/ProcessorState.cpp
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/source/xslt/ProcessorState.cpp,v
retrieving revision 1.77
diff -u -3 -r1.77 ProcessorState.cpp
--- source/xslt/ProcessorState.cpp 19 Jan 2003 23:17:06 -0000 1.77
+++ source/xslt/ProcessorState.cpp 20 Jan 2003 11:53:12 -0000
@@ -47,6 +47,74 @@
#include "txVariableMap.h"
#include "XSLTProcessor.h"
+
+DHASH_WRAPPER(txLoadedDocumentsBase, txLoadedDocumentEntry, nsAString&)
+
+txLoadedDocumentsHash::txLoadedDocumentsHash(Document* aSourceDocument,
+ Document* aStyleDocument)
+ : mSourceDocument(aSourceDocument),
+ mStyleDocument(aStyleDocument)
+{
+ PRBool isLive = Init(8);
+ if (!isLive) {
+ mHashTable.ops = nsnull;
+ return;
+ }
+
+ if (mSourceDocument) {
+ Add(mSourceDocument);
+ }
+ if (mStyleDocument) {
+ Add(mStyleDocument);
+ }
+}
+
+txLoadedDocumentsHash::~txLoadedDocumentsHash()
+{
+ if (!mHashTable.ops) {
+ return;
+ }
+
+ nsAutoString baseURI;
+ if (mSourceDocument) {
+ mSourceDocument->getBaseURI(baseURI);
+ Remove(baseURI);
+ }
+ if (mStyleDocument) {
+ mStyleDocument->getBaseURI(baseURI);
+ Remove(baseURI);
+ }
+}
+
+void txLoadedDocumentsHash::Add(Document* aDocument)
+{
+ if (!mHashTable.ops) {
+ return;
+ }
+
+ nsAutoString baseURI;
+ mSourceDocument->getBaseURI(baseURI);
+ txLoadedDocumentEntry* entry = AddEntry(baseURI);
+ if (entry) {
+ entry->mDocument = aDocument;
+ }
+}
+
+Document* txLoadedDocumentsHash::Get(const nsAString& aURI)
+{
+ if (!mHashTable.ops) {
+ return nsnull;
+ }
+
+ txLoadedDocumentEntry* entry = GetEntry(aURI);
+ if (entry) {
+ return entry->mDocument;
+ }
+
+ return nsnull;
+}
+
+
/**
* Creates a new ProcessorState for the given XSL document
**/
@@ -55,13 +123,12 @@
: mOutputHandler(0),
mResultHandler(0),
mOutputHandlerFactory(0),
+ mLoadedDocuments(aSourceDocument, aXslDocument),
mXslKeys(MB_TRUE),
mDecimalFormats(MB_TRUE),
mEvalContext(0),
mLocalVariables(0),
mGlobalVariableValues(MB_TRUE),
- mSourceDocument(aSourceDocument),
- xslDocument(aXslDocument),
mRTFDocument(0)
{
NS_ASSERTION(aSourceDocument, "missing source document");
@@ -73,21 +140,6 @@
mExprHashes[ValueAttr].setOwnership(Map::eOwnsItems);
mPatternHashes[CountAttr].setOwnership(Map::eOwnsItems);
mPatternHashes[FromAttr].setOwnership(Map::eOwnsItems);
-
- // determine xslt properties
- if (mSourceDocument) {
- nsAutoString baseURI;
- mSourceDocument->getBaseURI(baseURI);
- loadedDocuments.put(baseURI, mSourceDocument);
- }
- if (xslDocument) {
- nsAutoString baseURI;
- xslDocument->getBaseURI(baseURI);
- loadedDocuments.put(baseURI, xslDocument);
- }
-
- // Make sure all loaded documents get deleted
- loadedDocuments.setObjectDeletion(MB_TRUE);
}
/**
@@ -100,19 +152,6 @@
while (iter.hasNext())
delete (ImportFrame*)iter.next();
- // Make sure that xslDocument and mSourceDocument aren't deleted along with
- // the rest of the documents in the loadedDocuments hash
- if (xslDocument) {
- nsAutoString baseURI;
- xslDocument->getBaseURI(baseURI);
- loadedDocuments.remove(baseURI);
- }
- if (mSourceDocument) {
- nsAutoString baseURI;
- mSourceDocument->getBaseURI(baseURI);
- loadedDocuments.remove(baseURI);
- }
-
// in module the outputhandler is refcounted
#ifdef TX_EXE
delete mOutputHandler;
@@ -385,14 +424,16 @@
NS_LossyConvertUCS2toASCII(frag).get()));
// try to get already loaded document
- Document* xmlDoc = (Document*)loadedDocuments.get(docUrl);
+ Document* xmlDoc = mLoadedDocuments.Get(docUrl);
if (!xmlDoc) {
// open URI
nsAutoString errMsg;
XMLParser xmlParser;
- xmlDoc = xmlParser.getDocumentFromURI(docUrl, xslDocument, errMsg);
+ xmlDoc = xmlParser.getDocumentFromURI(docUrl,
+ mLoadedDocuments.mStyleDocument,
+ errMsg);
if (!xmlDoc) {
receiveError(NS_LITERAL_STRING("Couldn't load document '") +
@@ -401,7 +442,7 @@
return NULL;
}
// add to list of documents
- loadedDocuments.put(docUrl, xmlDoc);
+ mLoadedDocuments.Add(xmlDoc);
}
// return element with supplied id if supplied
@@ -667,8 +708,9 @@
Document* ProcessorState::getStylesheetDocument()
{
- NS_ASSERTION(xslDocument, "missing stylesheet document");
- return xslDocument;
+ NS_ASSERTION(mLoadedDocuments.mStyleDocument,
+ "missing stylesheet document");
+ return mLoadedDocuments.mStyleDocument;
}
/*
@@ -1023,7 +1065,7 @@
// Set up the state we have at the beginning of the transformation
txVariableMap *oldVars = mLocalVariables;
mLocalVariables = 0;
- txSingleNodeContext evalContext(mSourceDocument, this);
+ txSingleNodeContext evalContext(mLoadedDocuments.mSourceDocument, this);
txIEvalContext* priorEC = setEvalContext(&evalContext);
// Compute the variable value
globVar->mFlags = GlobalVariableValue::evaluating;
Index: source/xslt/ProcessorState.h
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/source/xslt/ProcessorState.h,v
retrieving revision 1.42
diff -u -3 -r1.42 ProcessorState.h
--- source/xslt/ProcessorState.h 18 Jan 2003 00:37:07 -0000 1.42
+++ source/xslt/ProcessorState.h 20 Jan 2003 11:53:13 -0000
@@ -29,9 +29,7 @@
#define TRANSFRMX_PROCESSORSTATE_H
#include "NodeSet.h"
-#include "Stack.h"
#include "ErrorObserver.h"
-#include "NamedMap.h"
#include "txPatternParser.h"
#include "Expr.h"
#include "txOutputFormat.h"
@@ -42,10 +40,39 @@
#include "XSLTFunctions.h"
#include "txError.h"
#include "nsVoidArray.h"
+#include "nsDoubleHashtable.h"
class txVariableMap;
class txXSLKey;
+class txLoadedDocumentEntry : public PLDHashStringEntry {
+public:
+ txLoadedDocumentEntry(const void* aKey) : PLDHashStringEntry(aKey)
+ {
+ }
+ ~txLoadedDocumentEntry()
+ {
+ delete mDocument;
+ }
+ Document* mDocument;
+};
+
+DECL_DHASH_WRAPPER(txLoadedDocumentsBase, txLoadedDocumentEntry, nsAString&)
+
+class txLoadedDocumentsHash : public txLoadedDocumentsBase
+{
+public:
+ txLoadedDocumentsHash(Document* aSourceDocument, Document* aStyleDocument);
+ ~txLoadedDocumentsHash();
+ void Add(Document* aDocument);
+ Document* Get(const nsAString& aURI);
+
+private:
+ friend class ProcessorState;
+ Document* mSourceDocument;
+ Document* mStyleDocument;
+};
+
/**
* Class used for keeping the current state of the XSL Processor
*/
@@ -418,7 +445,7 @@
* The set of loaded documents. This includes both document() loaded
* documents and xsl:include/xsl:import'ed documents.
*/
- NamedMap loadedDocuments;
+ txLoadedDocumentsHash mLoadedDocuments;
/**
* The set of all available keys
@@ -467,9 +494,6 @@
*/
txExpandedNameMap mGlobalVariableValues;
- Document* mSourceDocument;
- Document* xslDocument;
-
/**
* Document used to create RTFs
*/
Index: source/xslt/XSLTProcessor.cpp
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.cpp,v
retrieving revision 1.128
diff -u -3 -r1.128 XSLTProcessor.cpp
--- source/xslt/XSLTProcessor.cpp 19 Jan 2003 23:17:06 -0000 1.128
+++ source/xslt/XSLTProcessor.cpp 20 Jan 2003 11:53:15 -0000
@@ -48,6 +48,7 @@
#include "txNodeSetContext.h"
#include "txNodeSorter.h"
#include "txRtfHandler.h"
+#include "txStack.h"
#include "txStringUtils.h"
#include "txTextHandler.h"
#include "txURIUtils.h"
@@ -866,7 +867,7 @@
void
txXSLTProcessor::processAttributeSets(Element* aElement,
ProcessorState* aPs,
- Stack* aRecursionStack)
+ txStack* aRecursionStack)
{
nsresult rv = NS_OK;
nsAutoString names;
@@ -915,7 +916,7 @@
aRecursionStack->pop();
}
else {
- Stack recursionStack;
+ txStack recursionStack;
recursionStack.push(&name);
processAttributeSets(parent, aPs, &recursionStack);
recursionStack.pop();
Index: source/xslt/XSLTProcessor.h
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/source/xslt/XSLTProcessor.h,v
retrieving revision 1.47
diff -u -3 -r1.47 XSLTProcessor.h
--- source/xslt/XSLTProcessor.h 17 Jan 2003 12:49:20 -0000 1.47
+++ source/xslt/XSLTProcessor.h 20 Jan 2003 11:53:15 -0000
@@ -30,6 +30,8 @@
#include "ProcessorState.h"
+class txStack;
+
class txIGlobalParameter : public TxObject
{
public:
@@ -123,7 +125,7 @@
* including themselves, even indirectly
*/
static void processAttributeSets(Element* aElement, ProcessorState* aPs,
- Stack* aRecursionStack = 0);
+ txStack* aRecursionStack = 0);
/**
* Processes the children of the specified element using the given
Index: source/xslt/txHTMLOutput.h
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/source/xslt/txHTMLOutput.h,v
retrieving revision 1.4
diff -u -3 -r1.4 txHTMLOutput.h
--- source/xslt/txHTMLOutput.h 17 Jan 2003 12:44:46 -0000 1.4
+++ source/xslt/txHTMLOutput.h 20 Jan 2003 11:53:13 -0000
@@ -40,7 +40,7 @@
#define TRANSFRMX_HTML_OUTPUT_H
#include "txXMLOutput.h"
-#include "Stack.h"
+#include "txStack.h"
class txHTMLOutput : public txXMLOutput
{
@@ -109,7 +109,7 @@
MBool isShorthandElement(const nsAString& aName);
MBool isShorthandAttribute(const nsAString& aLocalName);
- Stack mCurrentElements;
+ txStack mCurrentElements;
};
#endif
Index: source/xslt/txXMLOutput.h
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/source/xslt/txXMLOutput.h,v
retrieving revision 1.6
diff -u -3 -r1.6 txXMLOutput.h
--- source/xslt/txXMLOutput.h 18 Jan 2003 00:37:08 -0000 1.6
+++ source/xslt/txXMLOutput.h 20 Jan 2003 11:53:13 -0000
@@ -42,7 +42,7 @@
#include "txXMLEventHandler.h"
#include "dom.h"
#include "List.h"
-#include "Stack.h"
+#include "txStack.h"
#include "txOutputFormat.h"
#include "XMLUtils.h"
@@ -197,7 +197,7 @@
MBool mInCDATASection;
PRUint32 mIndentLevel;
txList mAttributes;
- Stack mCDATASections;
+ txStack mCDATASections;
private:
PRUnichar mBuffer[4];
Index: source/xslt/functions/txKeyFunctionCall.cpp
===================================================================
RCS file: /cvsroot/mozilla/extensions/transformiix/source/xslt/functions/txKeyFunctionCall.cpp,v
retrieving revision 1.16
diff -u -3 -r1.16 txKeyFunctionCall.cpp
--- source/xslt/functions/txKeyFunctionCall.cpp 19 Jan 2003 23:17:11 -0000 1.16
+++ source/xslt/functions/txKeyFunctionCall.cpp 20 Jan 2003 11:53:11 -0000
@@ -19,6 +19,7 @@
*/
#include "ProcessorState.h"
+#include "NamedMap.h"
#include "txAtoms.h"
#include "txSingleNodeContext.h"
#include "XMLDOMUtils.h"