I’d like an example of how to access and call Javascript object properties and methods from C++ using the v8 engine. The documentation shows how to access C++ objects and functions through javascript but not the other way around.
Here’s a simple object constructor and instance in JS:
function MyObj()
{
this.myArray = [];
this.myDouble = 0;
this.myFunction = function(arg1,arg2)
{ return (myDouble + arg1 + arg2); }
}
var globalObject = new myObj();
How would I access globalObject’s properties and methods? Also a somewhat related question — how can I populate the array (globalObject.myArray) from C++?
Regards,
Pris
I haven’t tested the examples below.
But I believe it gives an example of what you want.
As for how to modify the array I believe it would be using
References
CodeProject Using V8
Connecting C++ to Javascript bungeeconnect
Google V8 Shell Sample Code
Google V8 Header File
V8 Users Mailing List Can you populate a v8::Array from C++? Thread