XPCOMGC/Stack Pointers

From MozillaWiki
< XPCOMGC
Revision as of 17:55, 10 September 2007 by Benjamin Smedberg (talk | contribs) (Initial spec)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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. Also remove use of getter_AddRefs with these objects.

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);
  }