[webkit-dev] Coding style proposal - Consistent naming of protector Ref/RefPtrs (https://bugs.webkit.org/show_bug.cgi?id=157591)

Brady Eidson beidson at apple.com
Wed May 11 16:10:49 PDT 2016


It is a common pattern throughout the project to temporarily protect a RefCounted object with a Ref/RefPtr.

e.g.,
RefPtr<Node> protectedNode(node);

The naming for these protector variables is all over the map.
e.g.,

RefPtr<Element> protect(element);
RefPtr<Element> protector(this);
RefPtr<Node> self(node);
RefPtr<Widget> widgetRef(widget);

I’ve seen this come up in patch review a lot, most recently from Darin - (https://bugs.webkit.org/show_bug.cgi?id=157448#c16)

In reply (https://bugs.webkit.org/show_bug.cgi?id=157448#c17) I suggested that we should formalize a style guideline for this so it’s no longer a gray area.

I filed https://bugs.webkit.org/show_bug.cgi?id=157591 with a description of what I think the rule should be, including examples of both good and bad names.

I’ve already attached a patch to implement the check-webkit-style enforcement of the rule as well as update https://webkit.org/code-style-guidelines/ describing it.

If there are no objections here in the next ~day, assuming I get a review on the patch, I’ll be landing the new rule.

Thanks,
~Brady


More information about the webkit-dev mailing list