I found this helper method in a tutorial 
<http://www.equals-forty-two.com/templates/post.html> a couple of days ago. 

It reinterpret casts a v8::Persistent to a v8::Local, with the intended use 
of calling V8 API functions that require a local handle to a context, 
without actually having to create a new v8::Local each time:

template <class TypeName>
inline v8::Local<TypeName> ToLocal(const v8::Persistent<TypeName>& 
persistent)
{
  return 
*reinterpret_cast<v8::Local<TypeName>*>(const_cast<v8::Persistent<TypeName>*>(&persistent));
}

I'm new to V8, so I find myself wondering if it's safe or not. Or if it can 
be safe in some cases.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/18ea3fe8-b9eb-4ec4-ac7b-c5bc0d1bdb7an%40googlegroups.com.

Reply via email to