Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: src/api.h

Issue 15817014: remove most uses of raw handle constructors (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: stupid cast needed Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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); \
}
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698