gcobject-stuff
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
permissions -rw-r--r--
State as of now

This is a bunch of manual rewriting after the last set of automatic patchery. *Most* of this should have been taken care of by the automatic rewrite, but there are a couple hunks which are real fixes... in particular, a couple things need to inherit from XPCOMGCFinalizedObject or have overridden operator new/delete or other stuff. I want to record this and deal with the details later.

diff --git a/content/xslt/src/base/txExpandedNameMap.h b/content/xslt/src/base/txExpandedNameMap.h
--- a/content/xslt/src/base/txExpandedNameMap.h
+++ b/content/xslt/src/base/txExpandedNameMap.h
@@ -184,11 +184,6 @@ class txOwningExpandedNameMap : public t
 class txOwningExpandedNameMap : public txExpandedNameMap_base
 {
 public:
-    ~txOwningExpandedNameMap()
-    {
-        clear();
-    }
-
     nsresult add(const txExpandedName& aKey, E* aValue)
     {
         return addItem(aKey, (void*)aValue);
diff --git a/content/xslt/src/base/txList.cpp b/content/xslt/src/base/txList.cpp
--- a/content/xslt/src/base/txList.cpp
+++ b/content/xslt/src/base/txList.cpp
@@ -51,14 +51,6 @@ txList::txList() {
    lastItem   = 0;
    itemCount  = 0;
 } //-- txList;
-
-/**
- * txList destructor, cleans up ListItems, but will not delete the Object
- * references
-*/
-txList::~txList() {
-    clear();
-} //-- ~txList
 
 nsresult txList::insert(int index, void* objPtr)
 {
diff --git a/content/xslt/src/base/txList.h b/content/xslt/src/base/txList.h
--- a/content/xslt/src/base/txList.h
+++ b/content/xslt/src/base/txList.h
@@ -56,11 +56,6 @@ public:
     * Creates an empty txList
     **/
     txList();
-
-    /**
-     * txList destructor, object references will not be deleted.
-    **/
-    ~txList();
 
     /**
      * Returns the object located at the given index. This may
diff --git a/content/xslt/src/base/txNamespaceMap.h b/content/xslt/src/base/txNamespaceMap.h
--- a/content/xslt/src/base/txNamespaceMap.h
+++ b/content/xslt/src/base/txNamespaceMap.h
@@ -56,7 +56,7 @@ public:
 
 private:
     nsCOMArray<nsIAtom> mPrefixes;
-    nsTArray<PRInt32> mNamespaces;
+    nsTArray<PRInt32, GCAllocator> mNamespaces;
 };
 
 #endif //TRANSFRMX_TXNAMESPACEMAP_H
diff --git a/content/xslt/src/xpath/txIXPathContext.h b/content/xslt/src/xpath/txIXPathContext.h
--- a/content/xslt/src/xpath/txIXPathContext.h
+++ b/content/xslt/src/xpath/txIXPathContext.h
@@ -95,13 +95,9 @@ public:
  * When evaluating a XPath expression, |txIMatchContext|s are used
  * to transport the information from Step to Step.
  */
-class txIMatchContext
+class txIMatchContext : public XPCOMGCObject
 {
 public:
-    virtual ~txIMatchContext()
-    {
-    }
-
     /*
      * Return the ExprResult associated with the variable with the 
      * given namespace and local name.
diff --git a/content/xslt/src/xslt/txInstructions.h b/content/xslt/src/xslt/txInstructions.h
--- a/content/xslt/src/xslt/txInstructions.h
+++ b/content/xslt/src/xslt/txInstructions.h
@@ -56,11 +56,6 @@ public:
     txInstruction()
     {
         MOZ_COUNT_CTOR(txInstruction);
-    }
-
-    virtual ~txInstruction()
-    {
-        MOZ_COUNT_DTOR(txInstruction);
     }
 
     virtual nsresult execute(txExecutionState& aEs) = 0;
@@ -292,7 +287,7 @@ public:
                      nsAutoPtr<Expr> aDataTypeExpr, nsAutoPtr<Expr> aOrderExpr,
                      nsAutoPtr<Expr> aCaseOrderExpr);
 
-    struct SortKey {
+    struct SortKey : public XPCOMGCObject {
         SortKey(nsAutoPtr<Expr> aSelectExpr, nsAutoPtr<Expr> aLangExpr,
                 nsAutoPtr<Expr> aDataTypeExpr, nsAutoPtr<Expr> aOrderExpr,
                 nsAutoPtr<Expr> aCaseOrderExpr);
@@ -402,12 +397,19 @@ public:
     nsCOMPtr<nsIAtom> mPrefix;
 };
 
-class txText : public txInstruction
+class txText : public MMgc::GCFinalizable,
+               public txInstruction
 {
 public:
     txText(const nsAString& aStr, PRBool aDOE);
 
     TX_DECL_TXINSTRUCTION
+
+    static void* operator new(size_t size) NS_GCFINALIZEDALLOCATOR
+    {
+        return XPCOMGCFinalizedObject::operator new(size);
+    }
+    static void operator delete(void *obj);
 
     nsString mStr;
     PRBool mDOE;
diff --git a/content/xslt/src/xslt/txNodeSorter.h b/content/xslt/src/xslt/txNodeSorter.h
--- a/content/xslt/src/xslt/txNodeSorter.h
+++ b/content/xslt/src/xslt/txNodeSorter.h
@@ -75,7 +75,7 @@ private:
         TxObject** mSortValues;
         nsresult mRv;
     };
-    struct SortKey
+    struct SortKey : public XPCOMGCObject
     {
         Expr* mExpr;
         txXPathResultComparator* mComparator;
diff --git a/content/xslt/src/xslt/txStylesheet.cpp b/content/xslt/src/xslt/txStylesheet.cpp
--- a/content/xslt/src/xslt/txStylesheet.cpp
+++ b/content/xslt/src/xslt/txStylesheet.cpp
@@ -628,14 +628,6 @@ txStylesheet::addDecimalFormat(const txE
     return NS_OK;
 }
 
-txStylesheet::ImportFrame::~ImportFrame()
-{
-    txListIterator tlIter(&mToplevelItems);
-    while (tlIter.hasNext()) {
-        delete static_cast<txToplevelItem*>(tlIter.next());
-    }
-}
-
 txStylesheet::GlobalVariable::GlobalVariable(nsAutoPtr<Expr> aExpr,
                                              nsAutoPtr<txInstruction> aFirstInstruction,
                                              PRBool aIsParam)
diff --git a/content/xslt/src/xslt/txStylesheet.h b/content/xslt/src/xslt/txStylesheet.h
--- a/content/xslt/src/xslt/txStylesheet.h
+++ b/content/xslt/src/xslt/txStylesheet.h
@@ -110,13 +110,12 @@ public:
     /**
      * Contain information that is import precedence dependant.
      */
-    class ImportFrame {
+    class ImportFrame : public XPCOMGCObject {
     public:
         ImportFrame()
             : mFirstNotImported(nsnull)
         {
         }
-        ~ImportFrame();
 
         // List of toplevel items
         txList mToplevelItems;
diff --git a/content/xslt/src/xslt/txStylesheetCompiler.h b/content/xslt/src/xslt/txStylesheetCompiler.h
--- a/content/xslt/src/xslt/txStylesheetCompiler.h
+++ b/content/xslt/src/xslt/txStylesheetCompiler.h
@@ -195,7 +195,9 @@ struct txStylesheetAttr
     nsString mValue;
 };
 
-class txStylesheetCompiler : private txStylesheetCompilerState,
+class txStylesheetCompiler : public XPCOMGCFinalizedObject,
+                             public MMgc::GCFinalizable,
+                             private txStylesheetCompilerState,
                              public txACompileObserver
 {
 public:
@@ -248,7 +250,7 @@ private:
     nsresult mStatus;
 };
 
-class txInScopeVariable {
+class txInScopeVariable : public XPCOMGCObject {
 public:
     txInScopeVariable(const txExpandedName& aName) : mName(aName), mLevel(1)
     {
diff --git a/content/xslt/src/xslt/txToplevelItems.h b/content/xslt/src/xslt/txToplevelItems.h
--- a/content/xslt/src/xslt/txToplevelItems.h
+++ b/content/xslt/src/xslt/txToplevelItems.h
@@ -48,16 +48,12 @@ class txPattern;
 class txPattern;
 class Expr;
 
-class txToplevelItem
+class txToplevelItem : public XPCOMGCObject
 {
 public:
     txToplevelItem()
     {
         MOZ_COUNT_CTOR(txToplevelItem);
-    }
-    virtual ~txToplevelItem()
-    {
-        MOZ_COUNT_DTOR(txToplevelItem);
     }
 
     enum type {
@@ -108,10 +104,17 @@ public:
 };
 
 // xsl:output
-class txOutputItem : public txToplevelItem
+class txOutputItem : public MMgc::GCFinalizable,
+                     public txToplevelItem
 {
 public:
     TX_DECL_TOPLEVELITEM
+
+    static void* operator new(size_t size) NS_GCFINALIZEDALLOCATOR
+    {
+        return XPCOMGCFinalizedObject::operator new(size);
+    }
+    static void operator delete(void *obj);
 
     txOutputFormat mFormat;
 };
diff --git a/content/xslt/src/xslt/txXPathResultComparator.cpp b/content/xslt/src/xslt/txXPathResultComparator.cpp
--- a/content/xslt/src/xslt/txXPathResultComparator.cpp
+++ b/content/xslt/src/xslt/txXPathResultComparator.cpp
@@ -105,7 +105,7 @@ txResultStringComparator::createSortable
                                               txIEvalContext *aContext,
                                               txObject *&aResult)
 {
-    nsAutoPtr<StringValue> val(new StringValue);
+    StringValue *val(new StringValue);
     if (!val) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
@@ -131,7 +131,7 @@ txResultStringComparator::createSortable
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (nsCaseKey.IsEmpty()) {
-        aResult = val.forget();
+        aResult = val;
 
         return NS_OK;
     }
@@ -141,7 +141,7 @@ txResultStringComparator::createSortable
     NS_ENSURE_SUCCESS(rv, rv);
 #endif
 
-    aResult = val.forget();
+    aResult = val;
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xslt/txXPathResultComparator.h b/content/xslt/src/xslt/txXPathResultComparator.h
--- a/content/xslt/src/xslt/txXPathResultComparator.h
+++ b/content/xslt/src/xslt/txXPathResultComparator.h
@@ -53,13 +53,9 @@ class txIEvalContext;
 /*
  * Result comparators
  */
-class txXPathResultComparator
+class txXPathResultComparator : public XPCOMGCObject
 {
 public:
-    virtual ~txXPathResultComparator()
-    {
-    }
-
     /*
      * Compares two XPath results. Returns -1 if val1 < val2,
      * 1 if val1 > val2 and 0 if val1 == val2.
@@ -96,9 +92,17 @@ private:
 #endif
     int mSorting;
 
-    class StringValue : public TxObject
+    class StringValue
+        : public MMgc::GCFinalizable
+        , public TxObject
     {
     public:
+        static void* operator new(size_t size) NS_GCFINALIZEDALLOCATOR
+        {
+            return XPCOMGCFinalizedObject::operator new(size);
+        }
+        static void operator delete(void *obj);
+
 #ifdef TX_EXE
         nsString mStr;
 #else
diff --git a/content/xul/templates/src/nsRDFConInstanceTestNode.h b/content/xul/templates/src/nsRDFConInstanceTestNode.h
--- a/content/xul/templates/src/nsRDFConInstanceTestNode.h
+++ b/content/xul/templates/src/nsRDFConInstanceTestNode.h
@@ -86,8 +86,6 @@ public:
               mEmptyTest(aEmptyTest) {
             MOZ_COUNT_CTOR(nsRDFConInstanceTestNode::Element); }
 
-        virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConInstanceTestNode::Element); }
-
         static Element*
         Create(nsIRDFResource* aContainer,
                Test aContainerTest, Test aEmptyTest) {
diff --git a/content/xul/templates/src/nsRDFConMemberTestNode.h b/content/xul/templates/src/nsRDFConMemberTestNode.h
--- a/content/xul/templates/src/nsRDFConMemberTestNode.h
+++ b/content/xul/templates/src/nsRDFConMemberTestNode.h
@@ -79,8 +79,6 @@ public:
               mMember(aMember) {
             MOZ_COUNT_CTOR(nsRDFConMemberTestNode::Element); }
 
-        virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConMemberTestNode::Element); }
-
         static Element*
         Create(nsIRDFResource* aContainer, nsIRDFNode* aMember) {
             return new Element(aContainer, aMember);
diff --git a/content/xul/templates/src/nsRDFPropertyTestNode.h b/content/xul/templates/src/nsRDFPropertyTestNode.h
--- a/content/xul/templates/src/nsRDFPropertyTestNode.h
+++ b/content/xul/templates/src/nsRDFPropertyTestNode.h
@@ -100,8 +100,6 @@ public:
               mTarget(aTarget) {
             MOZ_COUNT_CTOR(nsRDFPropertyTestNode::Element); }
 
-        virtual ~Element() { MOZ_COUNT_DTOR(nsRDFPropertyTestNode::Element); }
-
         static Element*
         Create(nsIRDFResource* aSource,
                nsIRDFResource* aProperty,
diff --git a/content/xul/templates/src/nsRuleNetwork.cpp b/content/xul/templates/src/nsRuleNetwork.cpp
--- a/content/xul/templates/src/nsRuleNetwork.cpp
+++ b/content/xul/templates/src/nsRuleNetwork.cpp
@@ -428,11 +428,6 @@ ReteNodeSet::ReteNodeSet()
 {
 }
 
-ReteNodeSet::~ReteNodeSet()
-{
-    Clear();
-}
-
 nsresult
 ReteNodeSet::Add(ReteNode* aNode)
 {
diff --git a/content/xul/templates/src/nsRuleNetwork.h b/content/xul/templates/src/nsRuleNetwork.h
--- a/content/xul/templates/src/nsRuleNetwork.h
+++ b/content/xul/templates/src/nsRuleNetwork.h
@@ -117,13 +117,9 @@ public:
     friend class ConstIterator;
 
 protected:
-    class List {
+    class List : public XPCOMGCObject {
     public:
-        List() { MOZ_COUNT_CTOR(MemoryElementSet::List); }
-
-        ~List() {
-            MOZ_COUNT_DTOR(MemoryElementSet::List);
-            NS_IF_RELEASE(mNext); }
+        List() { }
 
         MemoryElement* mElement;
         List*          mNext;
@@ -435,8 +431,6 @@ public:
         mSupport  = aInstantiation.mSupport;
         return *this; }
 
-    ~Instantiation() { MOZ_COUNT_DTOR(Instantiation); }
-
     /**
      * Add the specified variable-to-value assignment to the instantiation's
      * set of assignments.
@@ -498,14 +492,13 @@ public:
     friend class nsXULTemplateResultSetRDF; // so it can get to the List
 
 protected:
-    class List {
+    class List : public XPCOMGCObject {
     public:
         Instantiation mInstantiation;
         List*         mNext;
         List*         mPrev;
 
-        List() { MOZ_COUNT_CTOR(InstantiationSet::List); }
-        ~List() { MOZ_COUNT_DTOR(InstantiationSet::List); }
+        List() { }
     };
 
     List mHead;
@@ -664,7 +657,6 @@ class ReteNodeSet
 {
 public:
     ReteNodeSet();
-    ~ReteNodeSet();
 
     nsresult Add(ReteNode* aNode);
     nsresult Clear();
diff --git a/content/xul/templates/src/nsXMLBinding.h b/content/xul/templates/src/nsXMLBinding.h
--- a/content/xul/templates/src/nsXMLBinding.h
+++ b/content/xul/templates/src/nsXMLBinding.h
@@ -50,7 +50,7 @@ class nsXMLBindingValues;
 /**
  * a <binding> description
  */
-struct nsXMLBinding {
+struct nsXMLBinding : public XPCOMGCObject {
   nsCOMPtr<nsIAtom> mVar;
   nsCOMPtr<nsIDOMXPathExpression> mExpr;
 
@@ -60,11 +60,6 @@ struct nsXMLBinding {
     : mVar(aVar), mExpr(aExpr), mNext(nsnull)
   {
     MOZ_COUNT_CTOR(nsXMLBinding);
-  }
-
-  ~nsXMLBinding()
-  {
-    MOZ_COUNT_DTOR(nsXMLBinding);
   }
 };
 
diff --git a/editor/libeditor/base/nsEditorCommands.h b/editor/libeditor/base/nsEditorCommands.h
--- a/editor/libeditor/base/nsEditorCommands.h
+++ b/editor/libeditor/base/nsEditorCommands.h
@@ -45,7 +45,9 @@
 // This is a virtual base class for commands registered with the editor controller.
 // Note that such commands can be shared by more than on editor instance, so
 // MUST be stateless. Any state must be stored via the refCon (an nsIEditor).
-class nsBaseEditorCommand : public nsIControllerCommand
+class nsBaseEditorCommand : public XPCOMGCFinalizedObject,
+                            public MMgc::GCFinalizable,
+                            public nsIControllerCommand
 {
 public:
 
diff --git a/editor/libeditor/html/nsHTMLCSSUtils.cpp b/editor/libeditor/html/nsHTMLCSSUtils.cpp
--- a/editor/libeditor/html/nsHTMLCSSUtils.cpp
+++ b/editor/libeditor/html/nsHTMLCSSUtils.cpp
@@ -300,10 +300,6 @@ const nsHTMLCSSUtils::CSSEquivTable hrAl
 
 nsHTMLCSSUtils::nsHTMLCSSUtils()
 : mIsCSSPrefChecked(PR_FALSE)
-{
-}
-
-nsHTMLCSSUtils::~nsHTMLCSSUtils()
 {
 }
 
diff --git a/editor/libeditor/html/nsHTMLCSSUtils.h b/editor/libeditor/html/nsHTMLCSSUtils.h
--- a/editor/libeditor/html/nsHTMLCSSUtils.h
+++ b/editor/libeditor/html/nsHTMLCSSUtils.h
@@ -58,11 +58,10 @@ typedef void (*nsProcessValueFunc)(const
                                    const char * aDefaultValueString,
                                    const char * aPrependString, const char* aAppendString);
 
-class nsHTMLCSSUtils
+class nsHTMLCSSUtils : public XPCOMGCObject
 {
 public:
   nsHTMLCSSUtils();
-  ~nsHTMLCSSUtils();
 
   enum nsCSSEditableProperty {
     eCSSEditableProperty_NONE=0,
diff --git a/editor/libeditor/html/nsWSRunObject.h b/editor/libeditor/html/nsWSRunObject.h
--- a/editor/libeditor/html/nsWSRunObject.h
+++ b/editor/libeditor/html/nsWSRunObject.h
@@ -207,7 +207,7 @@ class NS_STACK_CLASS nsWSRunObject
     // WSFragment represents a single run of ws (all leadingws, or all normalws,
     // or all trailingws, or all leading+trailingws).  Note that this single run may
     // still span multiple nodes.
-    struct WSFragment
+    struct WSFragment : public XPCOMGCObject
     {
       nsCOMPtr<nsIDOMNode> mStartNode;  // node where ws run starts
       nsCOMPtr<nsIDOMNode> mEndNode;    // node where ws run ends