XPCOMGC/GCObject Inheritance

From MozillaWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

We need to make sure that every object which is used as a COM object inherits only once from GCObject.

Part I: Figuring out which classes need GCObject love

Print a list "A" of all classes which meet the following conditions:

  • The class inherits (directly or indirectly) from nsISupports
  • The class constructor is called by a method that is not a subclass constructor, e.g.
class A : public nsIObserver
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIOBSERVER
private:
  nsCOMPtr<nsIFoo> mFoo;
};

class B : public A
{
public:
  NS_DECL_NSIOBSERVER
};

class C : public nsIFoo
{
public:
  NS_DECL_NSIFOO
};

int main()
{
  B b(); // Flag class B but not class A
  C* c = new C(); // Flag class C
}

Part II: subtract subclasses of list A

For each class in list "A", look to see if it a subclass of another class in list A. If so, remove it from the list. This is list "B"

Part III: rewrite the classes of list B to inherit from GCFinalizedObject

For each class in list B, make the class a subclass of GCFinalizedObject.

Note: if we can complete steps I and II with dehydra and get the start position of the class declarations, it may be easier to do this with a text-processing program than with pork