On Fri, May 8, 2015 at 2:57 AM, Francisco Tolmasky <[email protected]> wrote:
> So I can test if something is a built in prototype as so:
>
> if (thing->IsArray() &&
> thing->GetPrototype()->ToObject()->GetPrototype()->IsNull())
>   // yes.
>
> But, thing->IsObject() breaks down with this test, which would theoretically
> look like this:
>
> if (thing->IsObject() && thing->GetPrototype()->IsNull())
>   // yes.
>
> Since Object.create(null) will also pass this test. Is there something else
> I could do to determine if this is a Object.prototype? (I can't compare
> because the objects may be coming from different contexts).

The best I can come up with is to look up Object on the global object
with context->Global()->Get(...), then check if its .prototype
property StrictEquals |thing|.

It's not 100% foolproof because someone can override the built-in with
`Object = {}`.  You could look it up when creating the context and
keep a reference in a v8::Persistent.

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to