Index: src/api.h |
diff --git a/src/api.h b/src/api.h |
index 3c141f7097cf2476b51e1108d99210d736ee37e7..e64e960ecff9e72db8d19118717e2cd6fbe98d01 100644 |
--- a/src/api.h |
+++ b/src/api.h |
@@ -273,13 +273,26 @@ class Utils { |
OPEN_HANDLE_LIST(DECLARE_OPEN_HANDLE) |
#undef DECLARE_OPEN_HANDLE |
-}; |
+ template<class From, class To> |
+ static inline Local<To> Convert(v8::internal::Handle<From> obj) { |
+ ASSERT(obj.is_null() || !obj->IsTheHole()); |
+ return Local<To>(reinterpret_cast<To*>(obj.location())); |
+ } |
-template <class T> |
-inline T* ToApi(v8::internal::Handle<v8::internal::Object> obj) { |
- return reinterpret_cast<T*>(obj.location()); |
-} |
+ template <class T> |
+ static inline v8::internal::Handle<v8::internal::Object> OpenPersistent( |
+ const v8::Persistent<T>& persistent) { |
+ return v8::internal::Handle<v8::internal::Object>( |
+ reinterpret_cast<v8::internal::Object**>(persistent.val_)); |
+ } |
+ |
+ template <class T> |
+ static inline v8::internal::Handle<v8::internal::Object> OpenPersistent( |
+ v8::Persistent<T>* persistent) { |
+ return OpenPersistent(*persistent); |
+ } |
+}; |
template <class T> |
@@ -293,31 +306,31 @@ v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom( |
} |
-class InternalHandleHelper { |
- public: |
- template<class From, class To> |
- static inline Local<To> Convert(v8::internal::Handle<From> obj) { |
- return Local<To>(reinterpret_cast<To*>(obj.location())); |
- } |
-}; |
+template <class T> |
+inline T* ToApi(v8::internal::Handle<v8::internal::Object> obj) { |
+ return reinterpret_cast<T*>(obj.location()); |
+} |
+ |
+template <class T> |
+inline v8::Local<T> ToApiHandle( |
+ v8::internal::Handle<v8::internal::Object> obj) { |
+ return Utils::Convert<v8::internal::Object, T>(obj); |
+} |
// Implementations of ToLocal |
#define MAKE_TO_LOCAL(Name, From, To) \ |
Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \ |
- ASSERT(obj.is_null() || !obj->IsTheHole()); \ |
- return InternalHandleHelper::Convert<v8::internal::From, v8::To>(obj); \ |
+ return Convert<v8::internal::From, v8::To>(obj); \ |
} |
#define MAKE_TO_LOCAL_TYPED_ARRAY(TypedArray, typeConst) \ |
Local<v8::TypedArray> Utils::ToLocal##TypedArray( \ |
v8::internal::Handle<v8::internal::JSTypedArray> obj) { \ |
- ASSERT(obj.is_null() || !obj->IsTheHole()); \ |
ASSERT(obj->type() == typeConst); \ |
- return InternalHandleHelper:: \ |
- Convert<v8::internal::JSTypedArray, v8::TypedArray>(obj); \ |
+ return Convert<v8::internal::JSTypedArray, v8::TypedArray>(obj); \ |
} |