Re: Create a new native object with a constructor
Braden McDaniel <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 2016-06-20 at 08:43 -0400, Josh Matthews wrote:
> On 2016-06-20 7:06 AM, Braden McDaniel wrote:
> > On a related note, the JS_InitClass documentation includes this:
> >
> > If you provide a constructor for the class, then you should
> > also
> > pass an object to parent_proto. JS_InitClass uses parent_proto
> > to
> > build a prototype object for the class. The prototype object
> > inherits properties and methods from the parent_proto object
> > you
> > provide.
> >
> > I gather, then, that passing null for parent_proto is insufficient
> > even
> > if the parent is Object? Is there some convenient way to get the
> > proto
> > for Object in order to pass it here?
>
> You're looking for JS_GetObjectPrototype.
Is it? That requires that I have an Object. The global object is
handy enough; but is that what I want?
I think I want what, in JavaScript, this would give me:
new Object().__proto__
So, I guess I'm asking if there's a way for me to get to that via the
SpiderMonkey API without actually instantiating a JavaScript Object.
--
Braden McDaniel <[email protected]>
_______________________________________________
dev-tech-js-engine mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine