I've been following the V8 embedder's guide example "Accessing Dynamic Variables", and have managed to adjust the given code so that it compiles correctly with the latest version. However, the example shows only how to define accessors for a Class. If I'd like to use javascript to modify an existing Point instance, how do I pass that through?

For example, I imagine this scenario:

C++:

Point* p=...
p->x=10;
....
//This is where I'm completely stuck
.... 
Handle<Script> handleScript=Local<Script>::New(isolate, ...);
handleScript->Run();

//now p->x should be 5

javascript:

p.x=5;

EDIT: it seems the easiest way would be something like: (continuing from the example)

context->Global()->Set(String::NewFromUtf8(isolate, "p"), obj);

if there's a better way, I'd be happy to hear it.

有帮助吗?

解决方案

The easiest way would be: (continuing from the example)

context->Global()->Set(String::NewFromUtf8(isolate, "p"), obj);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top