Hi. I'm very new to v8 - and I love it!
I want to create a system in which the "user" can load scripts, each
script should have an own context.
Also, they should be able to create "instances" (if they exist in
JavaScript so far) through wrapper functions.
Pseudo code should be:
var myVar = Variables.create("blah");
myVar.set("x");
My current implementation looks like this:
Handle<Value> CVariables::v8_Create(const Arguments &args)
{
// TODO: Check arguments
String::AsciiValue ascName(args[0]);
// Create the instance for the variable
CVariable *pVariable = pVariables->Create(*ascName);
if (!pVariable)
{
// TODO: Throw Exception
return Null();
}
// Create the JS "instance" for the Variable object
Handle<Function> Constructor = pVariables->m_Variable->GetFunction();
Handle<Object> Instance = Constructor->NewInstance();
Instance->SetInternalField(0,
Local<Value>(External::New(pVariable)));
return Instance;
}
This works well, I can call it. But the problem is, that it seems that
pVariable won't get deallocated. Is it possible to automaticly
deallocate when the GC of v8 deallocates the "instance" of the
Variable object?
Thanks for any help :)
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users