Hi,

How can I change (and dispose) an object allocate with External::New ?
Assuming I have the following code:

    SessionBridge* session_ptr = new SessionBridge(session);
    //create a pointer to a class template
    Handle<FunctionTemplate> point_templ = FunctionTemplate::New(isolate);
    //assign the "SessionBridge" name to the new class template
    point_templ->SetClassName(v8::String::NewFromUtf8(isolate, 
"SessionBridge"));
    //access the class template
    Handle<ObjectTemplate> point_proto = point_templ->PrototypeTemplate();
    //associates the "method" string to the callback SessionRequest in the 
class template
    point_proto->Set(v8::String::NewFromUtf8(isolate, "request"), 
FunctionTemplate::New(isolate, SessionRequest));
    //associates the "method" string to the callback SessionLog in the 
class template
    point_proto->Set(v8::String::NewFromUtf8(isolate, "log"), 
FunctionTemplate::New(isolate, SessionLog));
    //access the instance pointer of our new class template
    Handle<ObjectTemplate> point_inst = point_templ->InstanceTemplate();
    //set the internal fields of the class as we have the SessionBridge 
class internally
    point_inst->SetInternalFieldCount(1);
    //get class template
    Handle<Function> point_ctor = point_templ->GetFunction();
    //get class instance
    Local<Object> js_session = point_ctor->NewInstance();
    //build the "bridge" between c++ and javascript by associating the 
'session_ptr' pointer to the first internal
    //field of the object
    js_session->SetInternalField(0, External::New(isolate,session_ptr));
    context->Global()->Set(v8::String::NewFromUtf8(isolate, "session"), 
js_session);


I want to replace the SessionBridge instance (line 1) disposing the 
previous one

    SessionBridge* session_ptr = new SessionBridge(session);
    Local<Object> global1 = isolate->GetCurrentContext()->Global();
    Local<Object> obj1 = 
Local<Object>::Cast(global1->Get(v8::String::NewFromUtf8(isolate, 
"session")));
    SessionBridge* session_ptr = new SessionBridge(session);
    obj1->SetInternalField(0, External::New(isolate,session_ptr));


Thanks
Fabio

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to