I already wrap all kinds of classes to V8, but maybe I phrased my question wrong. What I want to do is create the definition in script so I do not have to manage C++ objects for classes that are not bigger than a couple utility methods, and let V8 manage the objects. Like with the Point example I think it is a bit of overkill to wrap an object that has 2 fields and maybe one function. I already do this for a couple of utility classes I have that are written in JS, but I was seeing if there was a way to get at the function prototype of the class from JS to be able to create an instance of the function and push it to script.
On Apr 2, 10:44 am, Alex Iskander <[email protected]> wrote: > The way you do it is by making the constructor a C++ function. A bit > of reference on how to do this is in the following places: > The v8 embedder's guide > > The example files in the v8 source tree > > My own article which covers some of the techniques to wrap v8 > objects:http://create.tpsitulsa.com/blog/2009/01/29/v8-objects/ > > Also, as far as I know there is no way to intercept operators. > > Hope that helps, > > Alex > > Sent from Alex's iPhone > > On Apr 2, 2009, at 10:26 AM, MJ <[email protected]> wrote: > > > > > This is kind of a 2 part question. > > > 1) Are you able to get a class created in script in C++ and create an > > object of that type in C++ and then push it back to script? Like can > > you get the function from the engine and get the instance template > > from it and create a new instance. > > > function MyClass() > > { > > } > > > And then in C++ get MyClass and create an instance of it? > > > 2) Also, is it possible to override or intercept operators? --~--~---------~--~----~------------~-------~--~----~ v8-users mailing list [email protected] http://groups.google.com/group/v8-users -~----------~----~----~----~------~----~------~--~---
