XPCOMGC/Stack Pointers

From MozillaWiki
< XPCOMGC
Revision as of 23:33, 10 October 2007 by Tglek (talk | contribs)
Jump to navigation Jump to search

Automatic rewriting spec for XPCOMGC:

Detect every instance of nsCOMPtr that is used as a stack variable, and rewrite it to be a raw pointer.

  • Remove use of getter_AddRefs with these objects.
  • Rewrite nsCOMPtr::swap()
  • Remove nsCOMPtr::get() for stack vars

e.g.

  nsFoo::Function(nsISupports* gah)
  {
-   nsCOMPtr<nsIBar> bar;
+   nsIBar* bar;
  
-   nsCOMPtr<nsIBaz> gahbaz = do_QueryInterface(gah);
+   nsIBaz* gahbaz = do_QueryInterface(gah);

-   nsresult rv = gahbaz->GetBar(getter_AddRefs(bar));
+   nsresult rv = gahbaz->GetBar(&bar);
  }