Open gschwind opened 1 year ago
I always thought it was a peculiarity of
JSClass
that the instances and prototype had to have the same one.
It used to be that builtin prototype objects in JS had the same type as the instance (e.g. Array.prototype
is an array object in JS). The spec has been moving away from that and now generally prefers plain objects for prototypes.
JS_InitClass
still uses the JSClass
for both the proto and constructor name. It would probably make sense to change this API to default to using a plain object for the prototype.
I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1808171 to improve JS_InitClass
.
I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1808171 to improve
JS_InitClass
.
These changes have now landed, so with the next ESR release we can improve this more.
The current document does not explain the usage of JSClass clearly. This patch try to give more detail about the purpose of JSClass, how to use it, and it's internal constraint.
Note that I did this documentation based on my own investigation within the current spidermonkey code, thus I maybe wrong.