I have a function set up to return a wrapped C++ object when called as
new MyClass();
but I want to also be able to say
MyClass.do_something();
I know how to do what I want in pure javascript:
MyClass.prototype = { do_something: function(){}};
but how do I do the same in C++?
I'm aware of the InstanceTemplate() and PrototypeTemplate() methods on v8::FunctionTemplate, but those seem to only be used in the creation of the new object returned when new MyClass()
is called. How do I get at the actual function's prototype?
Thank you.
I saw this post, but am not sure if it's relevant: Add a function template to a global object prototype in v8
edit: I think what I want to do probably needs to use the FunctionTemplate::GetFunction() method, but that needs a context, and all I have at this point is an Isolate*, since I'm adding this "constructor function" to the isolate global template so it's present in all contexts created from the v8::Isolate.
Aucun commentaire:
Enregistrer un commentaire