Due to complaints about the classic stylings of my initial header name, you now 
need to include mozilla/HoldDropJSObjects.h rather than 
nsCycleCollectionHoldDrop.h for these templates.

----- Original Message -----
> In bug 883920, I converted these two macros into more contemporary templates.
> 
> What was
>   NS_HOLD_JS_OBJECTS(this, nsFoo);
> or
>   nsContentUtils::HoldJSObjects(this,
>   NS_CYCLE_COLLECTION_PARTICIPANT(nsFoo));
> can now just be
>   mozilla::HoldJSObjects(this);
> 
> 
> What was
>   NS_DROP_JS_OBJECTS(this, nsFoo);
> or
>   nsContentUtils::DropJSObjects(this);
> can now just be
>   mozilla::DropJSObjects(this);
> 
> 
> Both cases, nsISupports and otherwise, are now handled with a template.
> 
> In addition to being more convenient, these new templates are safer, because
> in the nsISupports case they do automatically whatever QIing is needed in
> certain uncommon cases.
> 
> The header for these new templates is nsCycleCollectionHoldDrop.h.
> nsContentUtils.h no longer has these functions.
> 
> HoldJSObjects adds the cycle collected argument to a hash table.  These
> objects are traced during GC and CC to look for JS pointers.  DropJSObjects
> removes the object from the table, so you don't want to call it until you
> know that it isn't holding onto anything.
> 
> Generally speaking, you want to do a Hold in the constructor, or at least
> when you store something into a raw JS pointer your C++ object is holding.
> It is a good idea to not call DropJSObjects until the destructor, to avoid
> various weird cases which can lead to critical security problems.  It is
> okay to Hold an object multiple times, or Drop it if it hasn't be held, so
> play it safe.
> 
> Find me on IRC (:mccr8) or email me if you have any questions about these
> changes, or anything else about tracing of C++ objects.
> 
> 
> Andrew
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
> 
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to