Gecko:DeCOMtamination Algorithm: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| (8 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This algorithm is being implemented in [[Squash]] | |||
#Collapse the XPCom interface nsIClass class and the child nsClass that implements it. | |||
##Header Inference. Not all member variables are defined in public headers, find out what member variables are declared in nsClass that are not defined in public headers and can not use a forward declaration. Some options: | |||
##* Move Non-internal members into the base class, declare functions that use internal members as virtual. This also requires a factory method in the base class to return the derived class. | |||
#Collapse the XPCom interface nsIClass class and the child nsClass that implements it | ##* Make headers public, try again? | ||
## | ##'''Adds overhead:''' Rewrite them to form foo var to nsAutoPtr<foo> var. And add initializers for them to the constructor | ||
##Rewrite them to form foo var to nsAutoPtr<foo> var. And add initializers for them to the constructor | ##'''Adds overhead:''' Update code that uses var. Eg var.member becomes var->member, var passed in an argument by value/const reference becomes *var. | ||
##Update code that uses var. Eg var.member becomes var->member, var passed in an argument by value/const reference becomes *var. | |||
##Place nsClass members into nsIClass removing virtual unless there are derivatives of nsClass | ##Place nsClass members into nsIClass removing virtual unless there are derivatives of nsClass | ||
##* replace macros like NS_IMETHOD with nsresult | |||
##* If possible change code to return through return values instead of returning nsresults and results in an out parameter. See [[Gecko:Interface Style Guide]] | |||
##Remove xpcom initializer like NS_NewClass(..) | ##Remove xpcom initializer like NS_NewClass(..) | ||
##Remove nsIClass declaration | ##Remove nsIClass declaration | ||
| Line 14: | Line 15: | ||
#Update all uses of nsClass | #Update all uses of nsClass | ||
## nsComPtr<nsIClass> becomes nsRefPtr<nsClass> | ## nsComPtr<nsIClass> becomes nsRefPtr<nsClass> | ||
##* Since QueryInterface no longer exists, need to call AddRef on instantiation | |||
## nsCOMArray<nsIClass> becomes nsTArray<nsRefPtr<nsClass> > | ## nsCOMArray<nsIClass> becomes nsTArray<nsRefPtr<nsClass> > | ||
## Instatiate nsClass directly: | ## Instatiate nsClass directly: | ||
Latest revision as of 02:14, 21 February 2007
This algorithm is being implemented in Squash
- Collapse the XPCom interface nsIClass class and the child nsClass that implements it.
- Header Inference. Not all member variables are defined in public headers, find out what member variables are declared in nsClass that are not defined in public headers and can not use a forward declaration. Some options:
- Move Non-internal members into the base class, declare functions that use internal members as virtual. This also requires a factory method in the base class to return the derived class.
- Make headers public, try again?
- Adds overhead: Rewrite them to form foo var to nsAutoPtr<foo> var. And add initializers for them to the constructor
- Adds overhead: Update code that uses var. Eg var.member becomes var->member, var passed in an argument by value/const reference becomes *var.
- Place nsClass members into nsIClass removing virtual unless there are derivatives of nsClass
- replace macros like NS_IMETHOD with nsresult
- If possible change code to return through return values instead of returning nsresults and results in an out parameter. See Gecko:Interface Style Guide
- Remove xpcom initializer like NS_NewClass(..)
- Remove nsIClass declaration
- Header Inference. Not all member variables are defined in public headers, find out what member variables are declared in nsClass that are not defined in public headers and can not use a forward declaration. Some options:
- Rename nsIClass to nsClass
- Update all uses of nsClass
- nsComPtr<nsIClass> becomes nsRefPtr<nsClass>
- Since QueryInterface no longer exists, need to call AddRef on instantiation
- nsCOMArray<nsIClass> becomes nsTArray<nsRefPtr<nsClass> >
- Instatiate nsClass directly:
- Change do_CreateInstance("@mozilla.org/...") to invoke the constructor directly : new nsClass();
- CallCreateInstance(kClassCID, &sClass) becomes sClass = new nsClass()
- nsresult rv = NS_NewClass(getter_AddRefs(var)) becomes var = new nsClass()
- nsComPtr<nsIClass> becomes nsRefPtr<nsClass>