@@ -12,6 +12,7 @@ class ObjectWrap {
1212 refs_ = 0 ;
1313 }
1414
15+
1516 virtual ~ObjectWrap ( ) {
1617 if (!handle_.IsEmpty ()) {
1718 assert (handle_.IsNearDeath ());
@@ -21,28 +22,28 @@ class ObjectWrap {
2122 }
2223 }
2324
25+
2426 template <class T >
25- static inline T* Unwrap (v8::Handle<v8::Object> handle)
26- {
27+ static inline T* Unwrap (v8::Handle<v8::Object> handle) {
2728 assert (!handle.IsEmpty ());
2829 assert (handle->InternalFieldCount () > 0 );
2930 return static_cast <T*>(handle->GetPointerFromInternalField (0 ));
3031 }
3132
33+
3234 v8::Persistent<v8::Object> handle_; // ro
3335
3436 protected:
35- inline void Wrap (v8::Handle<v8::Object> handle)
36- {
37+ inline void Wrap (v8::Handle<v8::Object> handle) {
3738 assert (handle_.IsEmpty ());
3839 assert (handle->InternalFieldCount () > 0 );
3940 handle_ = v8::Persistent<v8::Object>::New (handle);
4041 handle_->SetPointerInInternalField (0 , this );
4142 MakeWeak ();
4243 }
4344
44- inline void MakeWeak ( void )
45- {
45+
46+ inline void MakeWeak ( void ) {
4647 handle_.MakeWeak (this , WeakCallback);
4748 }
4849
@@ -72,11 +73,12 @@ class ObjectWrap {
7273 if (--refs_ == 0 ) { MakeWeak (); }
7374 }
7475
76+
7577 int refs_; // ro
7678
79+
7780 private:
78- static void WeakCallback (v8::Persistent<v8::Value> value, void *data)
79- {
81+ static void WeakCallback (v8::Persistent<v8::Value> value, void *data) {
8082 ObjectWrap *obj = static_cast <ObjectWrap*>(data);
8183 assert (value == obj->handle_ );
8284 assert (!obj->refs_ );
0 commit comments