From: Trevor Norris Date: Tue, 29 Oct 2013 20:09:52 +0000 (-0700) Subject: src: don't use class specific Unwrap methods X-Git-Tag: v0.11.8~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f2e3be53bc33fc9269c248cec4ac26d6ec9054f7;p=platform%2Fupstream%2Fnodejs.git src: don't use class specific Unwrap methods Instead use the template functions in util.h. --- diff --git a/src/node_crypto.cc b/src/node_crypto.cc index af00b70..5d05984 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1782,7 +1782,7 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) { void Connection::EncIn(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1832,7 +1832,7 @@ void Connection::EncIn(const FunctionCallbackInfo& args) { void Connection::ClearOut(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1886,7 +1886,7 @@ void Connection::ClearOut(const FunctionCallbackInfo& args) { void Connection::ClearPending(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); int bytes_pending = BIO_pending(conn->bio_read_); args.GetReturnValue().Set(bytes_pending); } @@ -1894,7 +1894,7 @@ void Connection::ClearPending(const FunctionCallbackInfo& args) { void Connection::EncPending(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); int bytes_pending = BIO_pending(conn->bio_write_); args.GetReturnValue().Set(bytes_pending); } @@ -1903,7 +1903,7 @@ void Connection::EncPending(const FunctionCallbackInfo& args) { void Connection::EncOut(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1934,7 +1934,7 @@ void Connection::EncOut(const FunctionCallbackInfo& args) { void Connection::ClearIn(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1989,7 +1989,7 @@ void Connection::ClearIn(const FunctionCallbackInfo& args) { void Connection::Start(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); int rv = 0; if (!SSL_is_init_finished(conn->ssl_)) { @@ -2014,7 +2014,7 @@ void Connection::Start(const FunctionCallbackInfo& args) { void Connection::Shutdown(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); if (conn->ssl_ == NULL) { return args.GetReturnValue().Set(false); @@ -2030,7 +2030,7 @@ void Connection::Shutdown(const FunctionCallbackInfo& args) { void Connection::Close(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); if (conn->ssl_ != NULL) { SSL_free(conn->ssl_); @@ -2043,7 +2043,7 @@ void Connection::Close(const FunctionCallbackInfo& args) { void Connection::GetServername(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); if (conn->is_server() && !conn->servername_.IsEmpty()) { args.GetReturnValue().Set(conn->servername_); @@ -2056,7 +2056,7 @@ void Connection::GetServername(const FunctionCallbackInfo& args) { void Connection::SetSNICallback(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject(args.This()); if (args.Length() < 1 || !args[0]->IsFunction()) { return ThrowError("Must give a Function as first argument"); diff --git a/src/node_crypto.h b/src/node_crypto.h index 414261e..90483b7 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -274,12 +274,6 @@ class Connection : public SSLWrap, public WeakObject { void ClearError(); void SetShutdownFlags(); - static Connection* Unwrap(v8::Local object) { - Connection* conn = UnwrapObject(object); - conn->ClearError(); - return conn; - } - Connection(Environment* env, v8::Local wrap, SecureContext* sc, diff --git a/src/node_wrap.h b/src/node_wrap.h index 0f56f6d..798d943 100644 --- a/src/node_wrap.h +++ b/src/node_wrap.h @@ -28,6 +28,8 @@ #include "tcp_wrap.h" #include "tty_wrap.h" #include "udp_wrap.h" +#include "util.h" +#include "util-inl.h" #include "uv.h" #include "v8.h" @@ -37,15 +39,15 @@ namespace node { do { \ if (env->tcp_constructor_template().IsEmpty() == false && \ env->tcp_constructor_template()->HasInstance(obj)) { \ - TCPWrap* const wrap = TCPWrap::Unwrap(obj); \ + TCPWrap* const wrap = UnwrapObject(obj); \ BODY \ } else if (env->tty_constructor_template().IsEmpty() == false && \ env->tty_constructor_template()->HasInstance(obj)) { \ - TTYWrap* const wrap = TTYWrap::Unwrap(obj); \ + TTYWrap* const wrap = UnwrapObject(obj); \ BODY \ } else if (env->pipe_constructor_template().IsEmpty() == false && \ env->pipe_constructor_template()->HasInstance(obj)) { \ - PipeWrap* const wrap = PipeWrap::Unwrap(obj); \ + PipeWrap* const wrap = UnwrapObject(obj); \ BODY \ } \ } while (0) diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 4b195fd..5e8fc5e 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -69,11 +69,6 @@ Local PipeWrap::Instantiate(Environment* env) { } -PipeWrap* PipeWrap::Unwrap(Local obj) { - return UnwrapObject(obj); -} - - void PipeWrap::Initialize(Handle target, Handle unused, Handle context) { diff --git a/src/pipe_wrap.h b/src/pipe_wrap.h index 89330fc..92492c4 100644 --- a/src/pipe_wrap.h +++ b/src/pipe_wrap.h @@ -32,7 +32,6 @@ class PipeWrap : public StreamWrap { uv_pipe_t* UVHandle(); static v8::Local Instantiate(Environment* env); - static PipeWrap* Unwrap(v8::Local obj); static void Initialize(v8::Handle target, v8::Handle unused, v8::Handle context); diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 0a4029c..2ed3d8f 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -110,7 +110,7 @@ class ProcessWrap : public HandleWrap { Local handle = stdio->Get(handle_key).As(); options->stdio[i].data.stream = reinterpret_cast( - PipeWrap::Unwrap(handle)->UVHandle()); + UnwrapObject(handle)->UVHandle()); } else if (type->Equals(FIXED_ONE_BYTE_STRING(node_isolate, "wrap"))) { Local handle_key = FIXED_ONE_BYTE_STRING(node_isolate, "handle"); diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index b719fbe..b903ae1 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -121,11 +121,6 @@ void TCPWrap::Initialize(Handle target, } -TCPWrap* TCPWrap::Unwrap(Local obj) { - return UnwrapObject(obj); -} - - uv_tcp_t* TCPWrap::UVHandle() { return &handle_; } diff --git a/src/tcp_wrap.h b/src/tcp_wrap.h index b1fa4c7..c9981f5 100644 --- a/src/tcp_wrap.h +++ b/src/tcp_wrap.h @@ -30,7 +30,6 @@ namespace node { class TCPWrap : public StreamWrap { public: static v8::Local Instantiate(Environment* env); - static TCPWrap* Unwrap(v8::Local obj); static void Initialize(v8::Handle target, v8::Handle unused, v8::Handle context); diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index bf94309..f97ea8a 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -90,11 +90,6 @@ void TTYWrap::Initialize(Handle target, } -TTYWrap* TTYWrap::Unwrap(Local obj) { - return UnwrapObject(obj); -} - - uv_tty_t* TTYWrap::UVHandle() { return &handle_; } diff --git a/src/tty_wrap.h b/src/tty_wrap.h index 4c69b4c..91abfeb 100644 --- a/src/tty_wrap.h +++ b/src/tty_wrap.h @@ -33,7 +33,6 @@ class TTYWrap : public StreamWrap { static void Initialize(v8::Handle target, v8::Handle unused, v8::Handle context); - static TTYWrap* Unwrap(v8::Local obj); uv_tty_t* UVHandle(); diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 0d72ffe..53d8820 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -427,11 +427,6 @@ void UDPWrap::OnRecv(uv_udp_t* handle, } -UDPWrap* UDPWrap::Unwrap(Local obj) { - return UnwrapObject(obj); -} - - Local UDPWrap::Instantiate(Environment* env) { // If this assert fires then Initialize hasn't been called yet. assert(env->udp_constructor_function().IsEmpty() == false); diff --git a/src/udp_wrap.h b/src/udp_wrap.h index b9aa566..ab0d6fa 100644 --- a/src/udp_wrap.h +++ b/src/udp_wrap.h @@ -52,7 +52,6 @@ class UDPWrap: public HandleWrap { const v8::FunctionCallbackInfo& args); static void SetBroadcast(const v8::FunctionCallbackInfo& args); static void SetTTL(const v8::FunctionCallbackInfo& args); - static UDPWrap* Unwrap(v8::Local obj); static v8::Local Instantiate(Environment* env); uv_udp_t* UVHandle();