Howdy folks,
Thanks to the magic of C++11, we don’t need PassRef and PassRefPtr anymore, as
we can use rvalue references and move semantics to achieve churn-free ownership
transfers.
I’ve already removed PassRef entirely, and PassRefPtr will be next. Given how
widely it’s used in the codebase, I expect it will take some time.
Here’s the endgame I’m shooting for:
RefT is used for all ownership-sharing pointers known to be non-null. It
cannot be null.
RefPtrT is used for pointers that need a null state.
Return values that were previously PassRefT or PassRefPtrT will become
RefT or RefPtrT.
Arguments that were previously PassRefT or PassRefPtrT will become RefT
or RefPtrT.
You will need to WTF::move() when transferring ownership. This is different
from the PassRefPtr way, where ownership could be transferred without visual
indication at the call site.
To pass a local RefPtr to a function f(RefPtr) *without* transferring
ownership, use Ref/RefPtr::copyRef() to keep the local reference on the object.
Important note: After you’ve WTF::move()’d out of a Ref, it’s in an invalid
state and cannot be used again. I’m working on a solution to turn this into a
compile-time error.
Cheers,
Kling
PS. Once the kinks are ironed out, I’ll also be updating the RefPtr
documentation on webkit.org.
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev