diff options
author | Trevor Norris <trev.norris@gmail.com> | 2013-10-29 13:09:52 -0700 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2013-10-29 15:09:44 -0700 |
commit | f2e3be53bc33fc9269c248cec4ac26d6ec9054f7 (patch) | |
tree | 544ee459002a8fc1c8f3dccb2ff2025959fdd82b /src | |
parent | 60a3e695cb6ff09f81de4195368535fdb11e2da9 (diff) | |
download | node-new-f2e3be53bc33fc9269c248cec4ac26d6ec9054f7.tar.gz |
src: don't use class specific Unwrap methods
Instead use the template functions in util.h.
Diffstat (limited to 'src')
-rw-r--r-- | src/node_crypto.cc | 22 | ||||
-rw-r--r-- | src/node_crypto.h | 6 | ||||
-rw-r--r-- | src/node_wrap.h | 8 | ||||
-rw-r--r-- | src/pipe_wrap.cc | 5 | ||||
-rw-r--r-- | src/pipe_wrap.h | 1 | ||||
-rw-r--r-- | src/process_wrap.cc | 2 | ||||
-rw-r--r-- | src/tcp_wrap.cc | 5 | ||||
-rw-r--r-- | src/tcp_wrap.h | 1 | ||||
-rw-r--r-- | src/tty_wrap.cc | 5 | ||||
-rw-r--r-- | src/tty_wrap.h | 1 | ||||
-rw-r--r-- | src/udp_wrap.cc | 5 | ||||
-rw-r--r-- | src/udp_wrap.h | 1 |
12 files changed, 17 insertions, 45 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index af00b70563..5d059846a0 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<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1832,7 +1832,7 @@ void Connection::EncIn(const FunctionCallbackInfo<Value>& args) { void Connection::ClearOut(const FunctionCallbackInfo<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1886,7 +1886,7 @@ void Connection::ClearOut(const FunctionCallbackInfo<Value>& args) { void Connection::ClearPending(const FunctionCallbackInfo<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(args.This()); int bytes_pending = BIO_pending(conn->bio_read_); args.GetReturnValue().Set(bytes_pending); } @@ -1894,7 +1894,7 @@ void Connection::ClearPending(const FunctionCallbackInfo<Value>& args) { void Connection::EncPending(const FunctionCallbackInfo<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(args.This()); int bytes_pending = BIO_pending(conn->bio_write_); args.GetReturnValue().Set(bytes_pending); } @@ -1903,7 +1903,7 @@ void Connection::EncPending(const FunctionCallbackInfo<Value>& args) { void Connection::EncOut(const FunctionCallbackInfo<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1934,7 +1934,7 @@ void Connection::EncOut(const FunctionCallbackInfo<Value>& args) { void Connection::ClearIn(const FunctionCallbackInfo<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1989,7 +1989,7 @@ void Connection::ClearIn(const FunctionCallbackInfo<Value>& args) { void Connection::Start(const FunctionCallbackInfo<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(args.This()); int rv = 0; if (!SSL_is_init_finished(conn->ssl_)) { @@ -2014,7 +2014,7 @@ void Connection::Start(const FunctionCallbackInfo<Value>& args) { void Connection::Shutdown(const FunctionCallbackInfo<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(args.This()); if (conn->ssl_ == NULL) { return args.GetReturnValue().Set(false); @@ -2030,7 +2030,7 @@ void Connection::Shutdown(const FunctionCallbackInfo<Value>& args) { void Connection::Close(const FunctionCallbackInfo<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(args.This()); if (conn->ssl_ != NULL) { SSL_free(conn->ssl_); @@ -2043,7 +2043,7 @@ void Connection::Close(const FunctionCallbackInfo<Value>& args) { void Connection::GetServername(const FunctionCallbackInfo<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(args.This()); if (conn->is_server() && !conn->servername_.IsEmpty()) { args.GetReturnValue().Set(conn->servername_); @@ -2056,7 +2056,7 @@ void Connection::GetServername(const FunctionCallbackInfo<Value>& args) { void Connection::SetSNICallback(const FunctionCallbackInfo<Value>& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args.This()); + Connection* conn = UnwrapObject<Connection>(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 414261effe..90483b7dbf 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -274,12 +274,6 @@ class Connection : public SSLWrap<Connection>, public WeakObject { void ClearError(); void SetShutdownFlags(); - static Connection* Unwrap(v8::Local<v8::Object> object) { - Connection* conn = UnwrapObject<Connection>(object); - conn->ClearError(); - return conn; - } - Connection(Environment* env, v8::Local<v8::Object> wrap, SecureContext* sc, diff --git a/src/node_wrap.h b/src/node_wrap.h index 0f56f6ddf7..798d94334b 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<TCPWrap>(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<TTYWrap>(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<PipeWrap>(obj); \ BODY \ } \ } while (0) diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 4b195fda4a..5e8fc5ea9b 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -69,11 +69,6 @@ Local<Object> PipeWrap::Instantiate(Environment* env) { } -PipeWrap* PipeWrap::Unwrap(Local<Object> obj) { - return UnwrapObject<PipeWrap>(obj); -} - - void PipeWrap::Initialize(Handle<Object> target, Handle<Value> unused, Handle<Context> context) { diff --git a/src/pipe_wrap.h b/src/pipe_wrap.h index 89330fc724..92492c42b7 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<v8::Object> Instantiate(Environment* env); - static PipeWrap* Unwrap(v8::Local<v8::Object> obj); static void Initialize(v8::Handle<v8::Object> target, v8::Handle<v8::Value> unused, v8::Handle<v8::Context> context); diff --git a/src/process_wrap.cc b/src/process_wrap.cc index 0a4029c185..2ed3d8f301 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -110,7 +110,7 @@ class ProcessWrap : public HandleWrap { Local<Object> handle = stdio->Get(handle_key).As<Object>(); options->stdio[i].data.stream = reinterpret_cast<uv_stream_t*>( - PipeWrap::Unwrap(handle)->UVHandle()); + UnwrapObject<PipeWrap>(handle)->UVHandle()); } else if (type->Equals(FIXED_ONE_BYTE_STRING(node_isolate, "wrap"))) { Local<String> handle_key = FIXED_ONE_BYTE_STRING(node_isolate, "handle"); diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index b719fbe912..b903ae17d2 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -121,11 +121,6 @@ void TCPWrap::Initialize(Handle<Object> target, } -TCPWrap* TCPWrap::Unwrap(Local<Object> obj) { - return UnwrapObject<TCPWrap>(obj); -} - - uv_tcp_t* TCPWrap::UVHandle() { return &handle_; } diff --git a/src/tcp_wrap.h b/src/tcp_wrap.h index b1fa4c7f8f..c9981f572d 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<v8::Object> Instantiate(Environment* env); - static TCPWrap* Unwrap(v8::Local<v8::Object> obj); static void Initialize(v8::Handle<v8::Object> target, v8::Handle<v8::Value> unused, v8::Handle<v8::Context> context); diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc index bf94309cda..f97ea8a885 100644 --- a/src/tty_wrap.cc +++ b/src/tty_wrap.cc @@ -90,11 +90,6 @@ void TTYWrap::Initialize(Handle<Object> target, } -TTYWrap* TTYWrap::Unwrap(Local<Object> obj) { - return UnwrapObject<TTYWrap>(obj); -} - - uv_tty_t* TTYWrap::UVHandle() { return &handle_; } diff --git a/src/tty_wrap.h b/src/tty_wrap.h index 4c69b4c88a..91abfeb414 100644 --- a/src/tty_wrap.h +++ b/src/tty_wrap.h @@ -33,7 +33,6 @@ class TTYWrap : public StreamWrap { static void Initialize(v8::Handle<v8::Object> target, v8::Handle<v8::Value> unused, v8::Handle<v8::Context> context); - static TTYWrap* Unwrap(v8::Local<v8::Object> obj); uv_tty_t* UVHandle(); diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 0d72ffe0b5..53d8820e74 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<Object> obj) { - return UnwrapObject<UDPWrap>(obj); -} - - Local<Object> 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 b9aa566be2..ab0d6fa8e6 100644 --- a/src/udp_wrap.h +++ b/src/udp_wrap.h @@ -52,7 +52,6 @@ class UDPWrap: public HandleWrap { const v8::FunctionCallbackInfo<v8::Value>& args); static void SetBroadcast(const v8::FunctionCallbackInfo<v8::Value>& args); static void SetTTL(const v8::FunctionCallbackInfo<v8::Value>& args); - static UDPWrap* Unwrap(v8::Local<v8::Object> obj); static v8::Local<v8::Object> Instantiate(Environment* env); uv_udp_t* UVHandle(); |