Browse Source

src: upgrade after v8 api change

The prototype of v8::Persistent<T>::MakeWeak() has changed. Update the
code in src/ to follow suit.
v0.11.3-release
Ben Noordhuis 12 years ago
parent
commit
393d33e7ea
  1. 13
      src/node_object_wrap.h
  2. 15
      src/v8_typed_array.cc

13
src/node_object_wrap.h

@ -115,14 +115,13 @@ class NODE_EXTERN ObjectWrap {
private: private:
static void WeakCallback(v8::Isolate* isolate, static void WeakCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value> value, v8::Persistent<v8::Object>* pobj,
void* data) { ObjectWrap* wrap) {
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
ObjectWrap *obj = static_cast<ObjectWrap*>(data); assert(wrap->refs_ == 0);
assert(value == obj->handle_); assert(*pobj == wrap->handle_);
assert(!obj->refs_); assert((*pobj).IsNearDeath(isolate));
assert(value.IsNearDeath(isolate)); delete wrap;
delete obj;
} }
}; };

15
src/v8_typed_array.cc

@ -69,10 +69,11 @@ class ArrayBuffer {
} }
private: private:
static void WeakCallback(v8::Isolate* env, static void WeakCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value> value, v8::Persistent<v8::Object>* pobj,
void* data) { void* data) {
v8::Object* obj = v8::Object::Cast(*value); v8::HandleScope handle_scope(isolate);
v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(*pobj);
void* ptr = obj->GetIndexedPropertiesExternalArrayData(); void* ptr = obj->GetIndexedPropertiesExternalArrayData();
int element_size = v8_typed_array::SizeOfArrayElementForType( int element_size = v8_typed_array::SizeOfArrayElementForType(
@ -82,8 +83,8 @@ class ArrayBuffer {
node::node_isolate->AdjustAmountOfExternalAllocatedMemory(-size); node::node_isolate->AdjustAmountOfExternalAllocatedMemory(-size);
value.ClearWeak(env); (*pobj).ClearWeak(isolate);
value.Dispose(env); (*pobj).Dispose(isolate);
free(ptr); free(ptr);
} }
@ -128,7 +129,9 @@ class ArrayBuffer {
v8::Persistent<v8::Object> persistent = v8::Persistent<v8::Object> persistent =
v8::Persistent<v8::Object>::New(node::node_isolate, args.This()); v8::Persistent<v8::Object>::New(node::node_isolate, args.This());
persistent.MakeWeak(node::node_isolate, NULL, &ArrayBuffer::WeakCallback); persistent.MakeWeak(node::node_isolate,
static_cast<void*>(NULL),
&ArrayBuffer::WeakCallback);
return args.This(); return args.This();
} }

Loading…
Cancel
Save