How do you expose a C++ class in the V8 Javascript Engine so it can be created using new?
- by Steve Hanov
The official examples of exposing a Point class seem to assume that there will be a fixed number of instances of it in your program. It is not clear how new instances are allocated in the C++ code, when new is called in Javascript.
How would you expose a class that can have multiple instances? For example, an Image class:
var img1 = new Image( 640, 480 );
var img2 = new Image( 1024, 768 );
img1.clear( "red" );
img2.clear( "black" );