src: don't use class specific Unwrap methods
authorTrevor Norris <trev.norris@gmail.com>
Tue, 29 Oct 2013 20:09:52 +0000 (13:09 -0700)
committerTrevor Norris <trev.norris@gmail.com>
Tue, 29 Oct 2013 22:09:44 +0000 (15:09 -0700)
Instead use the template functions in util.h.

12 files changed:
src/node_crypto.cc
src/node_crypto.h
src/node_wrap.h
src/pipe_wrap.cc
src/pipe_wrap.h
src/process_wrap.cc
src/tcp_wrap.cc
src/tcp_wrap.h
src/tty_wrap.cc
src/tty_wrap.h
src/udp_wrap.cc
src/udp_wrap.h

index af00b70..5d05984 100644 (file)
@@ -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");
index 414261e..90483b7 100644 (file)
@@ -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,
index 0f56f6d..798d943 100644 (file)
@@ -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)
index 4b195fd..5e8fc5e 100644 (file)
@@ -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) {
index 89330fc..92492c4 100644 (file)
@@ -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);
index 0a4029c..2ed3d8f 100644 (file)
@@ -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");
index b719fbe..b903ae1 100644 (file)
@@ -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_;
 }
index b1fa4c7..c9981f5 100644 (file)
@@ -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);
index bf94309..f97ea8a 100644 (file)
@@ -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_;
 }
index 4c69b4c..91abfeb 100644 (file)
@@ -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();
 
index 0d72ffe..53d8820 100644 (file)
@@ -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);
index b9aa566..ab0d6fa 100644 (file)
@@ -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();