Reviewers: Sven Panne,
Message:
ptal
Description:
Allow Object::InternalFieldCount and
Object::GetAlignedPointerFromInternalField
to be called from Persistent classes
[email protected]
BUG=
Please review this at https://codereview.chromium.org/177343002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+17, -0 lines):
M include/v8.h
M test/cctest/test-api.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
dd8f2685bc37115638f5332ddbefd42a79c16cea..0ad85c51dc84637b2603bc47774b9f5634e62700
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -576,6 +576,7 @@ template <class T> class PersistentBase {
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
@@ -2185,6 +2186,12 @@ class V8_EXPORT Object : public Value {
/** 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);
@@ -2198,6 +2205,12 @@ class V8_EXPORT Object : public Value {
*/
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
* a field, GetAlignedPointerFromInternalField must be used, everything
else
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
c5c932b7516cc70738ad918a9311dabe1e985427..e454a4f04594df2c7ca64035e7b566218ee3fded
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -2634,6 +2634,10 @@ THREADED_TEST(InternalFieldsAlignedPointers) {
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/groups/opt_out.