Browse Source

bindings: update to new v8 apis

GetPointerFromInternalField() is deprecated now, we should use
GetAlignedPointerFromInternalField().
v0.9.6-release
Fedor Indutny 12 years ago
parent
commit
5e57bcc3ce
  1. 2
      src/fs_event_wrap.cc
  2. 10
      src/handle_wrap.cc
  3. 4
      src/node_internals.h
  4. 4
      src/node_object_wrap.h
  5. 4
      src/pipe_wrap.cc
  6. 6
      src/stream_wrap.cc
  7. 6
      src/tcp_wrap.cc
  8. 2
      src/tty_wrap.cc
  9. 2
      src/udp_wrap.cc
  10. 10
      src/v8_typed_array.cc

2
src/fs_event_wrap.cc

@ -171,7 +171,7 @@ Handle<Value> FSEventWrap::Close(const Arguments& args) {
// and legal, HandleWrap::Close() deals with them the same way.
assert(!args.Holder().IsEmpty());
assert(args.Holder()->InternalFieldCount() > 0);
void* ptr = args.Holder()->GetPointerFromInternalField(0);
void* ptr = args.Holder()->GetAlignedPointerFromInternalField(0);
FSEventWrap* wrap = static_cast<FSEventWrap*>(ptr);
if (wrap == NULL || wrap->initialized_ == false) return Undefined();

10
src/handle_wrap.cc

@ -26,8 +26,8 @@
#define UNWRAP_NO_ABORT(type) \
assert(!args.Holder().IsEmpty()); \
assert(args.Holder()->InternalFieldCount() > 0); \
type* wrap = \
static_cast<type*>(args.Holder()->GetPointerFromInternalField(0));
type* wrap = static_cast<type*>( \
args.Holder()->GetAlignedPointerFromInternalField(0));
namespace node {
@ -88,7 +88,7 @@ Handle<Value> HandleWrap::Close(const Arguments& args) {
HandleScope scope;
HandleWrap *wrap = static_cast<HandleWrap*>(
args.Holder()->GetPointerFromInternalField(0));
args.Holder()->GetAlignedPointerFromInternalField(0));
// guard against uninitialized handle or double close
if (wrap && wrap->handle__) {
@ -112,7 +112,7 @@ HandleWrap::HandleWrap(Handle<Object> object, uv_handle_t* h) {
assert(object_.IsEmpty());
assert(object->InternalFieldCount() > 0);
object_ = v8::Persistent<v8::Object>::New(object);
object_->SetPointerInInternalField(0, this);
object_->SetAlignedPointerInInternalField(0, this);
ngx_queue_insert_tail(&handle_wrap_queue, &handle_wrap_queue_);
}
@ -138,7 +138,7 @@ void HandleWrap::OnClose(uv_handle_t* handle) {
// But the handle pointer should be gone.
assert(wrap->handle__ == NULL);
wrap->object_->SetPointerInInternalField(0, NULL);
wrap->object_->SetAlignedPointerInInternalField(0, NULL);
wrap->object_.Dispose();
wrap->object_.Clear();

4
src/node_internals.h

@ -86,8 +86,8 @@ inline static v8::Handle<v8::Value> ThrowRangeError(const char* errmsg) {
#define UNWRAP(type) \
assert(!args.Holder().IsEmpty()); \
assert(args.Holder()->InternalFieldCount() > 0); \
type* wrap = \
static_cast<type*>(args.Holder()->GetPointerFromInternalField(0)); \
type* wrap = static_cast<type*>( \
args.Holder()->GetAlignedPointerFromInternalField(0)); \
if (!wrap) { \
fprintf(stderr, #type ": Aborting due to unwrap failure at %s:%d\n", \
__FILE__, __LINE__); \

4
src/node_object_wrap.h

@ -59,7 +59,7 @@ class NODE_EXTERN ObjectWrap {
static inline T* Unwrap (v8::Handle<v8::Object> handle) {
assert(!handle.IsEmpty());
assert(handle->InternalFieldCount() > 0);
return static_cast<T*>(handle->GetPointerFromInternalField(0));
return static_cast<T*>(handle->GetAlignedPointerFromInternalField(0));
}
@ -70,7 +70,7 @@ class NODE_EXTERN ObjectWrap {
assert(handle_.IsEmpty());
assert(handle->InternalFieldCount() > 0);
handle_ = v8::Persistent<v8::Object>::New(handle);
handle_->SetPointerInInternalField(0, this);
handle_->SetAlignedPointerInInternalField(0, this);
MakeWeak();
}

4
src/pipe_wrap.cc

@ -68,7 +68,7 @@ Local<Object> PipeWrap::Instantiate() {
PipeWrap* PipeWrap::Unwrap(Local<Object> obj) {
assert(!obj.IsEmpty());
assert(obj->InternalFieldCount() > 0);
return static_cast<PipeWrap*>(obj->GetPointerFromInternalField(0));
return static_cast<PipeWrap*>(obj->GetAlignedPointerFromInternalField(0));
}
@ -204,7 +204,7 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
// Unwrap the client javascript object.
assert(client_obj->InternalFieldCount() > 0);
PipeWrap* client_wrap =
static_cast<PipeWrap*>(client_obj->GetPointerFromInternalField(0));
static_cast<PipeWrap*>(client_obj->GetAlignedPointerFromInternalField(0));
if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return;

6
src/stream_wrap.cc

@ -220,8 +220,8 @@ void StreamWrap::OnReadCommon(uv_stream_t* handle, ssize_t nread,
if (!pending_obj.IsEmpty()) {
assert(pending_obj->InternalFieldCount() > 0);
StreamWrap* pending_wrap =
static_cast<StreamWrap*>(pending_obj->GetPointerFromInternalField(0));
StreamWrap* pending_wrap = static_cast<StreamWrap*>(
pending_obj->GetAlignedPointerFromInternalField(0));
if (uv_accept(handle, pending_wrap->GetStream())) abort();
argv[3] = pending_obj;
argc++;
@ -408,7 +408,7 @@ Handle<Value> StreamWrap::WriteStringImpl(const Arguments& args) {
Local<Object> send_stream_obj = args[1]->ToObject();
assert(send_stream_obj->InternalFieldCount() > 0);
StreamWrap* send_stream_wrap = static_cast<StreamWrap*>(
send_stream_obj->GetPointerFromInternalField(0));
send_stream_obj->GetAlignedPointerFromInternalField(0));
send_stream = send_stream_wrap->GetStream();
}

6
src/tcp_wrap.cc

@ -120,7 +120,7 @@ void TCPWrap::Initialize(Handle<Object> target) {
TCPWrap* TCPWrap::Unwrap(Local<Object> obj) {
assert(!obj.IsEmpty());
assert(obj->InternalFieldCount() > 0);
return static_cast<TCPWrap*>(obj->GetPointerFromInternalField(0));
return static_cast<TCPWrap*>(obj->GetAlignedPointerFromInternalField(0));
}
@ -316,8 +316,8 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
// Unwrap the client javascript object.
assert(client_obj->InternalFieldCount() > 0);
TCPWrap* client_wrap =
static_cast<TCPWrap*>(client_obj->GetPointerFromInternalField(0));
TCPWrap* client_wrap = static_cast<TCPWrap*>(
client_obj->GetAlignedPointerFromInternalField(0));
if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return;

2
src/tty_wrap.cc

@ -78,7 +78,7 @@ void TTYWrap::Initialize(Handle<Object> target) {
TTYWrap* TTYWrap::Unwrap(Local<Object> obj) {
assert(!obj.IsEmpty());
assert(obj->InternalFieldCount() > 0);
return static_cast<TTYWrap*>(obj->GetPointerFromInternalField(0));
return static_cast<TTYWrap*>(obj->GetAlignedPointerFromInternalField(0));
}

2
src/udp_wrap.cc

@ -388,7 +388,7 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
UDPWrap* UDPWrap::Unwrap(Local<Object> obj) {
assert(!obj.IsEmpty());
assert(obj->InternalFieldCount() > 0);
return static_cast<UDPWrap*>(obj->GetPointerFromInternalField(0));
return static_cast<UDPWrap*>(obj->GetAlignedPointerFromInternalField(0));
}

10
src/v8_typed_array.cc

@ -106,7 +106,7 @@ class ArrayBuffer {
if (!buf)
return ThrowError("Unable to allocate ArrayBuffer.");
args.This()->SetPointerInInternalField(0, buf);
args.This()->SetAlignedPointerInInternalField(0, buf);
args.This()->Set(v8::String::New("byteLength"),
v8::Integer::NewFromUnsigned(num_bytes),
@ -157,8 +157,8 @@ class ArrayBuffer {
if (buffer.IsEmpty()) return v8::Undefined(); // constructor failed
void* src = args.This()->GetPointerFromInternalField(0);
void* dest = buffer->GetPointerFromInternalField(0);
void* src = args.This()->GetAlignedPointerFromInternalField(0);
void* dest = buffer->GetAlignedPointerFromInternalField(0);
memcpy(dest, static_cast<char*>(src) + begin, slice_length);
return buffer;
@ -274,7 +274,7 @@ class TypedArray {
GetFunction()->NewInstance(1, argv);
if (buffer.IsEmpty()) return v8::Undefined(); // constructor failed
void* buf = buffer->GetPointerFromInternalField(0);
void* buf = buffer->GetAlignedPointerFromInternalField(0);
args.This()->SetIndexedPropertiesToExternalArrayData(
buf, TEAType, length);
// TODO(deanm): check for failure.
@ -303,7 +303,7 @@ class TypedArray {
GetFunction()->NewInstance(1, argv);
if (buffer.IsEmpty()) return v8::Undefined(); // constructor failed
void* buf = buffer->GetPointerFromInternalField(0);
void* buf = buffer->GetAlignedPointerFromInternalField(0);
args.This()->SetIndexedPropertiesToExternalArrayData(
buf, TEAType, length);
// TODO(deanm): check for failure.

Loading…
Cancel
Save