Personal tools

Gecko:DeCOMtamination Algorithm

From MozillaWiki

Jump to: navigation, search

This algorithm is being implemented in Squash

  1. Collapse the XPCom interface nsIClass class and the child nsClass that implements it.
    1. 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?
    2. Adds overhead: Rewrite them to form foo var to nsAutoPtr<foo> var. And add initializers for them to the constructor
    3. Adds overhead: 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
      • If possible change code to return through return values instead of returning nsresults and results in an out parameter. See Gecko:Interface Style Guide
    5. Remove xpcom initializer like NS_NewClass(..)
    6. Remove nsIClass declaration
  2. Rename nsIClass to nsClass
  3. 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()