After following the example in the V8 embedder's guide for "Accessing Dynamic Variables," I have successfully adjusted the code to compile with the newest version. However, the example only demonstrates how to define accessors for a Class. If I want to use JavaScript to modify an existing instance of Point
, how can I accomplish that?
Specifically, consider this scenario:
C++:
Point* p=...
p->x=10;
....
//At this point, I am stuck
....
Handle<Script> handleScript=Local<Script>::New(isolate, ...);
handleScript->Run();
//now p->x should be 5
JavaScript:
p.x=5;
EDIT: It appears the simplest solution may involve something like: (continuing from the example)
context->Global()->Set(String::NewFromUtf8(isolate, "p"), obj);
If there is a more efficient method available, I would love to learn about it.