문제

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