Hi, it's simple. I want my JS script to new/create object of my type.
Let's say Point:
class Point {
public:
int x, y;
};
I know how to "bind" an existing c++ object to JS and so script can
modify that object's content. But I want JS to hold the object or a
"reference" of it.
I'm not sure how the "construct Point function" should be written.
I tried this:
Handle<Value> Point_func(const Arguments & args) {
Point* p = new Point();
args.This()->SetInternalField(0, External::New(p));
return Undefined;
}
In the setter function I can get the object pointer. But how/when can
I free the object??
Or should I provide a JS function to new my Point and c++ keeps the
ownership of it, while JS side just keep a reference of it?
Can anyone help me? Do you have more documentation?
Many thanks~
Kenji
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---