Hi all,

I'm using ObjectTemplate to create JS empty objects that are simple 
wrappers of a c++ object
(in the JS code they are just used as "handles" to pass the objects around 
in the script).

I was just wondering if there is any issue or penalty to use a new 
ObjectTemplate every time (see code below)
or if I should store the ObjectTemplate in a persistent handle and reuse it.

Thank you,
Ricky

v8::Handle<v8::Object> WrapNativeElem(NativeElem* elem)
   {
      Isolate* isolate = Isolate::GetCurrent();
      EscapableHandleScope handle_scope(isolate);

      // create an empty object
      v8::Handle<v8::ObjectTemplate> elem_templ = v8::ObjectTemplate::New();
      elem_templ->SetInternalFieldCount(1);
      v8::Local<v8::Object> wrapper = elem_templ->NewInstance();
      
      // set the game state as internal field and return the wrapper
      wrapper->SetInternalField(0, External::New(Isolate::GetCurrent(), elem
));
      return handle_scope.Escape(wrapper);
   }


-- 
-- 
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