On Wed, Oct 8, 2014 at 10:02 PM, Jane Chen <[email protected]> wrote:
> I was able to get instanceof returning true following your tips.  Thanks.
> But it seems to me this design assumes that there is only a singleton
> Function we are operating on as I'm always interacting with This, which is
> the function returned from FunctionTemplate.GetFunction().
>
> If I want to dynamically create embedded objects from FunctionTemplates, is
> there a way to keep them "instanceof" of a certain class?

`o instanceof F` is more or less equivalent to recursively checking if
`o.__proto__.constructor === F`.  That is, you can make objects pass
the instanceof test by making their constructors inherit from one
another.  For example:

  function A() {}
  function B() {}
  B.prototype = Object.create(A.prototype);
  (new B) instanceof A;  // true

You can accomplish the same thing with the C++ API in a number of
ways.  In your case, just FunctionTemplate::Inherit() might be enough.

-- 
-- 
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