lundi 4 juillet 2016

In the V8 Javascript Engine, how do you add a FunctionTemplate as an attribute of another FunctionTemplate with the C++ API?


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


Aucun commentaire:

Enregistrer un commentaire