Gecko:DeCOMtamination Algorithm: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:
##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
##Remove xpcom initializer like NS_NewClass(..)
##Remove xpcom initializer like NS_NewClass(..)
##Remove nsIClass declaration
##Remove nsIClass declaration

Revision as of 22:16, 21 November 2006

  1. Select a candidate for DeCOMtamination (using Olmar or Oink)
    1. Find all classes that inherit from ISupports
    2. Filter out classes scriptable via XPConnect. How to detect them?
    3. Order them by the number of descendants.
    4. Select one with the least descendants
  2. Collapse the XPCom interface nsIClass class and the child nsClass that implements it
    1. To avoid header pollution, find out what member variables are declared in nsClass that do not have headers for in the nsIClass and can not use a forward declaration.
    2. Rewrite them to form foo var to nsAutoPtr<foo> var. And add initializers for them to the constructor
    3. Update code that uses var. Eg var.member becomes var->member, var passed in an argument by value/const reference becomes *var.
    4. Place nsClass members into nsIClass removing virtual unless there are derivatives of nsClass
      • replace macros like NS_IMETHOD with nsresult
    5. Remove xpcom initializer like NS_NewClass(..)
    6. Remove nsIClass declaration
  3. Rename nsIClass to nsClass
  4. Update all uses of nsClass
    1. nsComPtr<nsIClass> becomes nsRefPtr<nsClass>
      • Since QueryInterface no longer exists, need to call AddRef on instantiation
    2. nsCOMArray<nsIClass> becomes nsTArray<nsRefPtr<nsClass> >
    3. 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()