Deprecating SpiderMonkey Rooting Typedefs

75 views
Skip to first unread message

Bobby Holley

unread,
May 27, 2022, 1:45:18 PM5/27/22
to dev-pl...@mozilla.org
Hi Folks,

We've long had two ways to specify SpiderMonkey rooting types in C++: via the canonical definition (e.g., JS::Handle<JSObject*>) and the a set of shortcut typedefs defined in TypeDecls.h (e.g., JS::HandleObject).

Thus far we have relied on a loose cultural understanding of when and where to use each variant, but this approach inevitably creates distracting consistency problems, and is thus something we're moving away from. As the C++ style owner, I would like to resolve this specific issue with consistent guidance.

I've spoken with a number of engineers, and the conversations lean in favor of eliminating the typedefs, because:
* They don't improve understandability or flexibility, and sometimes hinder them.
* Consistency around typedef availability and naming for more complex and esoteric types is an ongoing headache.
* Needing a separate header to access the typedefs is occasionally cumbersome.
* We don't shortcut other commonly-used handles like RefPtr and already_AddRefed.

I do think the typedefs improve readability to some degree, but that those benefits are outweighed by the simplicity and consistency advantages of eliminating them.

Please let me know if there are important considerations that appear to have been overlooked. Absent further discussion I plan to update the style guide next week, and we can proceed with eliminating the typedefs from the code as time permits.

Thanks,
Bobby
Message has been deleted
Message has been deleted

Bobby Holley

unread,
Jun 1, 2022, 7:08:41 PM6/1/22
to dev-pl...@mozilla.org
I've submitted a patch in bug 1772234 to update the style guide.
Reply all
Reply to author
Forward
0 new messages