From efdd73c8e4d7ad78cb497accc3be41e606a17f7c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 13 Sep 2010 11:40:04 -0700 Subject: [PATCH] Fix style in node_object_wrap.h --- src/node_object_wrap.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/node_object_wrap.h b/src/node_object_wrap.h index 3002e6175..8eafd891c 100644 --- a/src/node_object_wrap.h +++ b/src/node_object_wrap.h @@ -12,6 +12,7 @@ class ObjectWrap { refs_ = 0; } + virtual ~ObjectWrap ( ) { if (!handle_.IsEmpty()) { assert(handle_.IsNearDeath()); @@ -21,19 +22,19 @@ class ObjectWrap { } } + template - static inline T* Unwrap (v8::Handle handle) - { + static inline T* Unwrap (v8::Handle handle) { assert(!handle.IsEmpty()); assert(handle->InternalFieldCount() > 0); return static_cast(handle->GetPointerFromInternalField(0)); } + v8::Persistent handle_; // ro protected: - inline void Wrap (v8::Handle handle) - { + inline void Wrap (v8::Handle handle) { assert(handle_.IsEmpty()); assert(handle->InternalFieldCount() > 0); handle_ = v8::Persistent::New(handle); @@ -41,8 +42,8 @@ class ObjectWrap { MakeWeak(); } - inline void MakeWeak (void) - { + + inline void MakeWeak (void) { handle_.MakeWeak(this, WeakCallback); } @@ -72,11 +73,12 @@ class ObjectWrap { if (--refs_ == 0) { MakeWeak(); } } + int refs_; // ro + private: - static void WeakCallback (v8::Persistent value, void *data) - { + static void WeakCallback (v8::Persistent value, void *data) { ObjectWrap *obj = static_cast(data); assert(value == obj->handle_); assert(!obj->refs_);