There isn't a whole lot of documentation on v8, and I couldn't figure
out the answer to this. So maybe the mailing list can help.
Usually if you are writing a function in C[++] that deals with
transient javascript values you do something like this:
Local<Object> func1 () {
HandleScope scope;
Local<Object> foo = Object::New();
//some stuff goes here
return scope.Close(foo);
}
Declaring the scope prevents the object from being allocated in the
global JS scope (if I understand correctly) and using
HandleScope::Close will allow that value to be marshalled out of that
scope for use elsewhere so that it doesn't get garbage collected when
the variable "scope" goes out of scope (the scope goes out of scope?
Man, that is confusing!)
My question is this: if I'm writing an axillary function (let's say a
small inline function) that I am always intending to call from another
function that has already declared a scope, do I need to declare
another scope within the aux. function? Example:
Local<Object> func2 () {
Local<Object> foo = Object::New();
//do some stuff
return foo;
}
Local<Object> func1 () {
HandleScope scope;
return scope.Close( func2() );
}
Should func2 define its own HandleScope and then close it before it
returns? Or will everything work out OK in this case? Or is there
altogether some other thing I should be doing?
Thanks,
Jeremy
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users