diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index bad634ddaf14b9..0518cd3b7ce002 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -17,7 +17,8 @@ inline AsyncWrap::AsyncWrap(Environment* env, v8::Handle object, ProviderType provider, AsyncWrap* parent) - : BaseObject(env, object), bits_(static_cast(provider) << 1) { + : BaseObject(env, object, provider), + bits_(static_cast(provider) << 1) { // Check user controlled flag to see if the init callback should run. if (!env->using_asyncwrap()) return; diff --git a/src/base-object-inl.h b/src/base-object-inl.h index db0daa1e82f559..2b36ddcf3fba9f 100644 --- a/src/base-object-inl.h +++ b/src/base-object-inl.h @@ -10,10 +10,15 @@ namespace node { -inline BaseObject::BaseObject(Environment* env, v8::Local handle) +inline BaseObject::BaseObject(Environment* env, + v8::Local handle, + const uint16_t p_id) : handle_(env->isolate(), handle), env_(env) { CHECK_EQ(false, handle.IsEmpty()); + // Shift value 8 bits over to try avoiding conflict with anything else. + if (p_id != 0) + handle_.SetWrapperClassId(p_id << 8); } diff --git a/src/base-object.h b/src/base-object.h index 5a7b95827e8f11..c2b30fae1ac6de 100644 --- a/src/base-object.h +++ b/src/base-object.h @@ -9,7 +9,9 @@ class Environment; class BaseObject { public: - BaseObject(Environment* env, v8::Local handle); + BaseObject(Environment* env, + v8::Local handle, + const uint16_t p_id = 0); virtual ~BaseObject(); // Returns the wrapped object. Returns an empty handle when