Revision: 19740
Author:   [email protected]
Date:     Mon Mar 10 08:18:57 2014 UTC
Log: Allow Object::InternalFieldCount and Object::GetAlignedPointerFromInternalField to be called from Persistent classes

[email protected]

BUG=

Review URL: https://codereview.chromium.org/177343002
http://code.google.com/p/v8/source/detail?r=19740

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/test/cctest/test-api.cc

=======================================
--- /branches/bleeding_edge/include/v8.h        Fri Mar  7 09:10:18 2014 UTC
+++ /branches/bleeding_edge/include/v8.h        Mon Mar 10 08:18:57 2014 UTC
@@ -576,6 +576,7 @@
   template<class F> friend class UniquePersistent;
   template<class F> friend class PersistentBase;
   template<class F> friend class ReturnValue;
+  friend class Object;

   explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
   PersistentBase(PersistentBase& other); // NOLINT
@@ -2165,6 +2166,12 @@

   /** Gets the number of internal fields for this Object. */
   int InternalFieldCount();
+
+  /** Same as above, but works for Persistents */
+  V8_INLINE static int InternalFieldCount(
+      const PersistentBase<Object>& object) {
+    return object.val_->InternalFieldCount();
+  }

   /** Gets the value from an internal field. */
   V8_INLINE Local<Value> GetInternalField(int index);
@@ -2178,6 +2185,12 @@
    * leads to undefined behavior.
    */
   V8_INLINE void* GetAlignedPointerFromInternalField(int index);
+
+  /** Same as above, but works for Persistents */
+  V8_INLINE static void* GetAlignedPointerFromInternalField(
+      const PersistentBase<Object>& object, int index) {
+    return object.val_->GetAlignedPointerFromInternalField(index);
+  }

   /**
* Sets a 2-byte-aligned native pointer in an internal field. To retrieve such
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Fri Mar 7 08:43:54 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-api.cc Mon Mar 10 08:18:57 2014 UTC
@@ -2634,6 +2634,10 @@

   void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1));
   CheckAlignedPointerInInternalField(obj, huge);
+
+  v8::UniquePersistent<v8::Object> persistent(isolate, obj);
+  CHECK_EQ(1, Object::InternalFieldCount(persistent));
+ CHECK_EQ(huge, Object::GetAlignedPointerFromInternalField(persistent, 0));
 }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" 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