XPCOMGC/GCObject Inheritance: Difference between revisions
< XPCOMGC
Jump to navigation
Jump to search
(Initial cut at GCObject inheritance) |
(s/GCObject/GCFinalizedObject/) |
||
| Line 39: | Line 39: | ||
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" | 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 | == Part III: rewrite the classes of list B to inherit from GCFinalizedObject == | ||
For each class in list B, make the class a subclass of | 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 | 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 | ||
Latest revision as of 14:34, 1 October 2007
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