Thank you for your help.
There are two scenarios I need to address for any given type (for
instance, Point):
First, it should be possible to create the object from within
JavaScript, for instance: "var x = new Point(1, 5);"
Second, it should be possible to create the object from within C++,
and pass it to JavaScript.
Currently, my procedure is to create a single FunctionTemplate (say
pointTemplate). This template's InstanceTemplate has properties like x
and y. The function's callback is a C++ function which generates a new
object (for instance, it might be named Create_Point).
To allow creating objects from JavaScript, I add the function to the
global scope.
To wrap an object from C++, I call pointTemplate->GetFunction()-
>NewInstance().
The problem occurs when I call NewInstance. This causes the actual
function to be called, causing a new C++ Point to be created. I do not
want a new C++ point; instead, I want to wrap an existing one.
The only workaround I can think of is changing pointTemplate from a
FunctionTemplate to an ObjectTemplate, and creating an entirely
separate FunctionTemplate for use as a JavaScript constructor.
Thank you,
Alex