Skip to content

Commit f2e3be5

Browse files
committed
src: don't use class specific Unwrap methods
Instead use the template functions in util.h.
1 parent 60a3e69 commit f2e3be5

12 files changed

Lines changed: 17 additions & 45 deletions

src/node_crypto.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,7 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) {
17821782
void Connection::EncIn(const FunctionCallbackInfo<Value>& args) {
17831783
HandleScope scope(node_isolate);
17841784

1785-
Connection* conn = Connection::Unwrap(args.This());
1785+
Connection* conn = UnwrapObject<Connection>(args.This());
17861786

17871787
if (args.Length() < 3) {
17881788
return ThrowTypeError("Takes 3 parameters");
@@ -1832,7 +1832,7 @@ void Connection::EncIn(const FunctionCallbackInfo<Value>& args) {
18321832
void Connection::ClearOut(const FunctionCallbackInfo<Value>& args) {
18331833
HandleScope scope(node_isolate);
18341834

1835-
Connection* conn = Connection::Unwrap(args.This());
1835+
Connection* conn = UnwrapObject<Connection>(args.This());
18361836

18371837
if (args.Length() < 3) {
18381838
return ThrowTypeError("Takes 3 parameters");
@@ -1886,15 +1886,15 @@ void Connection::ClearOut(const FunctionCallbackInfo<Value>& args) {
18861886

18871887
void Connection::ClearPending(const FunctionCallbackInfo<Value>& args) {
18881888
HandleScope scope(node_isolate);
1889-
Connection* conn = Connection::Unwrap(args.This());
1889+
Connection* conn = UnwrapObject<Connection>(args.This());
18901890
int bytes_pending = BIO_pending(conn->bio_read_);
18911891
args.GetReturnValue().Set(bytes_pending);
18921892
}
18931893

18941894

18951895
void Connection::EncPending(const FunctionCallbackInfo<Value>& args) {
18961896
HandleScope scope(node_isolate);
1897-
Connection* conn = Connection::Unwrap(args.This());
1897+
Connection* conn = UnwrapObject<Connection>(args.This());
18981898
int bytes_pending = BIO_pending(conn->bio_write_);
18991899
args.GetReturnValue().Set(bytes_pending);
19001900
}
@@ -1903,7 +1903,7 @@ void Connection::EncPending(const FunctionCallbackInfo<Value>& args) {
19031903
void Connection::EncOut(const FunctionCallbackInfo<Value>& args) {
19041904
HandleScope scope(node_isolate);
19051905

1906-
Connection* conn = Connection::Unwrap(args.This());
1906+
Connection* conn = UnwrapObject<Connection>(args.This());
19071907

19081908
if (args.Length() < 3) {
19091909
return ThrowTypeError("Takes 3 parameters");
@@ -1934,7 +1934,7 @@ void Connection::EncOut(const FunctionCallbackInfo<Value>& args) {
19341934
void Connection::ClearIn(const FunctionCallbackInfo<Value>& args) {
19351935
HandleScope scope(node_isolate);
19361936

1937-
Connection* conn = Connection::Unwrap(args.This());
1937+
Connection* conn = UnwrapObject<Connection>(args.This());
19381938

19391939
if (args.Length() < 3) {
19401940
return ThrowTypeError("Takes 3 parameters");
@@ -1989,7 +1989,7 @@ void Connection::ClearIn(const FunctionCallbackInfo<Value>& args) {
19891989
void Connection::Start(const FunctionCallbackInfo<Value>& args) {
19901990
HandleScope scope(node_isolate);
19911991

1992-
Connection* conn = Connection::Unwrap(args.This());
1992+
Connection* conn = UnwrapObject<Connection>(args.This());
19931993

19941994
int rv = 0;
19951995
if (!SSL_is_init_finished(conn->ssl_)) {
@@ -2014,7 +2014,7 @@ void Connection::Start(const FunctionCallbackInfo<Value>& args) {
20142014
void Connection::Shutdown(const FunctionCallbackInfo<Value>& args) {
20152015
HandleScope scope(node_isolate);
20162016

2017-
Connection* conn = Connection::Unwrap(args.This());
2017+
Connection* conn = UnwrapObject<Connection>(args.This());
20182018

20192019
if (conn->ssl_ == NULL) {
20202020
return args.GetReturnValue().Set(false);
@@ -2030,7 +2030,7 @@ void Connection::Shutdown(const FunctionCallbackInfo<Value>& args) {
20302030
void Connection::Close(const FunctionCallbackInfo<Value>& args) {
20312031
HandleScope scope(node_isolate);
20322032

2033-
Connection* conn = Connection::Unwrap(args.This());
2033+
Connection* conn = UnwrapObject<Connection>(args.This());
20342034

20352035
if (conn->ssl_ != NULL) {
20362036
SSL_free(conn->ssl_);
@@ -2043,7 +2043,7 @@ void Connection::Close(const FunctionCallbackInfo<Value>& args) {
20432043
void Connection::GetServername(const FunctionCallbackInfo<Value>& args) {
20442044
HandleScope scope(node_isolate);
20452045

2046-
Connection* conn = Connection::Unwrap(args.This());
2046+
Connection* conn = UnwrapObject<Connection>(args.This());
20472047

20482048
if (conn->is_server() && !conn->servername_.IsEmpty()) {
20492049
args.GetReturnValue().Set(conn->servername_);
@@ -2056,7 +2056,7 @@ void Connection::GetServername(const FunctionCallbackInfo<Value>& args) {
20562056
void Connection::SetSNICallback(const FunctionCallbackInfo<Value>& args) {
20572057
HandleScope scope(node_isolate);
20582058

2059-
Connection* conn = Connection::Unwrap(args.This());
2059+
Connection* conn = UnwrapObject<Connection>(args.This());
20602060

20612061
if (args.Length() < 1 || !args[0]->IsFunction()) {
20622062
return ThrowError("Must give a Function as first argument");

src/node_crypto.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,6 @@ class Connection : public SSLWrap<Connection>, public WeakObject {
274274
void ClearError();
275275
void SetShutdownFlags();
276276

277-
static Connection* Unwrap(v8::Local<v8::Object> object) {
278-
Connection* conn = UnwrapObject<Connection>(object);
279-
conn->ClearError();
280-
return conn;
281-
}
282-
283277
Connection(Environment* env,
284278
v8::Local<v8::Object> wrap,
285279
SecureContext* sc,

src/node_wrap.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "tcp_wrap.h"
2929
#include "tty_wrap.h"
3030
#include "udp_wrap.h"
31+
#include "util.h"
32+
#include "util-inl.h"
3133
#include "uv.h"
3234
#include "v8.h"
3335

@@ -37,15 +39,15 @@ namespace node {
3739
do { \
3840
if (env->tcp_constructor_template().IsEmpty() == false && \
3941
env->tcp_constructor_template()->HasInstance(obj)) { \
40-
TCPWrap* const wrap = TCPWrap::Unwrap(obj); \
42+
TCPWrap* const wrap = UnwrapObject<TCPWrap>(obj); \
4143
BODY \
4244
} else if (env->tty_constructor_template().IsEmpty() == false && \
4345
env->tty_constructor_template()->HasInstance(obj)) { \
44-
TTYWrap* const wrap = TTYWrap::Unwrap(obj); \
46+
TTYWrap* const wrap = UnwrapObject<TTYWrap>(obj); \
4547
BODY \
4648
} else if (env->pipe_constructor_template().IsEmpty() == false && \
4749
env->pipe_constructor_template()->HasInstance(obj)) { \
48-
PipeWrap* const wrap = PipeWrap::Unwrap(obj); \
50+
PipeWrap* const wrap = UnwrapObject<PipeWrap>(obj); \
4951
BODY \
5052
} \
5153
} while (0)

src/pipe_wrap.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ Local<Object> PipeWrap::Instantiate(Environment* env) {
6969
}
7070

7171

72-
PipeWrap* PipeWrap::Unwrap(Local<Object> obj) {
73-
return UnwrapObject<PipeWrap>(obj);
74-
}
75-
76-
7772
void PipeWrap::Initialize(Handle<Object> target,
7873
Handle<Value> unused,
7974
Handle<Context> context) {

src/pipe_wrap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class PipeWrap : public StreamWrap {
3232
uv_pipe_t* UVHandle();
3333

3434
static v8::Local<v8::Object> Instantiate(Environment* env);
35-
static PipeWrap* Unwrap(v8::Local<v8::Object> obj);
3635
static void Initialize(v8::Handle<v8::Object> target,
3736
v8::Handle<v8::Value> unused,
3837
v8::Handle<v8::Context> context);

src/process_wrap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class ProcessWrap : public HandleWrap {
110110
Local<Object> handle = stdio->Get(handle_key).As<Object>();
111111
options->stdio[i].data.stream =
112112
reinterpret_cast<uv_stream_t*>(
113-
PipeWrap::Unwrap(handle)->UVHandle());
113+
UnwrapObject<PipeWrap>(handle)->UVHandle());
114114
} else if (type->Equals(FIXED_ONE_BYTE_STRING(node_isolate, "wrap"))) {
115115
Local<String> handle_key =
116116
FIXED_ONE_BYTE_STRING(node_isolate, "handle");

src/tcp_wrap.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ void TCPWrap::Initialize(Handle<Object> target,
121121
}
122122

123123

124-
TCPWrap* TCPWrap::Unwrap(Local<Object> obj) {
125-
return UnwrapObject<TCPWrap>(obj);
126-
}
127-
128-
129124
uv_tcp_t* TCPWrap::UVHandle() {
130125
return &handle_;
131126
}

src/tcp_wrap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace node {
3030
class TCPWrap : public StreamWrap {
3131
public:
3232
static v8::Local<v8::Object> Instantiate(Environment* env);
33-
static TCPWrap* Unwrap(v8::Local<v8::Object> obj);
3433
static void Initialize(v8::Handle<v8::Object> target,
3534
v8::Handle<v8::Value> unused,
3635
v8::Handle<v8::Context> context);

src/tty_wrap.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ void TTYWrap::Initialize(Handle<Object> target,
9090
}
9191

9292

93-
TTYWrap* TTYWrap::Unwrap(Local<Object> obj) {
94-
return UnwrapObject<TTYWrap>(obj);
95-
}
96-
97-
9893
uv_tty_t* TTYWrap::UVHandle() {
9994
return &handle_;
10095
}

src/tty_wrap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class TTYWrap : public StreamWrap {
3333
static void Initialize(v8::Handle<v8::Object> target,
3434
v8::Handle<v8::Value> unused,
3535
v8::Handle<v8::Context> context);
36-
static TTYWrap* Unwrap(v8::Local<v8::Object> obj);
3736

3837
uv_tty_t* UVHandle();
3938

0 commit comments

Comments
 (0)