3030#include " env.h"
3131#include " env-inl.h"
3232#include " string_bytes.h"
33+ #include " util.h"
34+ #include " util-inl.h"
3335#include " v8.h"
3436
3537#include < errno.h>
@@ -761,8 +763,7 @@ void SecureContext::GetTicketKeys(const FunctionCallbackInfo<Value>& args) {
761763#if !defined(OPENSSL_NO_TLSEXT) && defined(SSL_CTX_get_tlsext_ticket_keys)
762764 HandleScope handle_scope (args.GetIsolate ());
763765
764- SecureContext* wrap;
765- NODE_UNWRAP (args.This (), SecureContext, wrap);
766+ SecureContext* wrap = UnwrapObject<SecureContext>(args.This ());
766767
767768 Local<Object> buff = Buffer::New (wrap->env (), 48 );
768769 if (SSL_CTX_get_tlsext_ticket_keys (wrap->ctx_ ,
@@ -786,8 +787,7 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo<Value>& args) {
786787 return ThrowTypeError (" Bad argument" );
787788 }
788789
789- SecureContext* wrap;
790- NODE_UNWRAP (args.This (), SecureContext, wrap);
790+ SecureContext* wrap = UnwrapObject<SecureContext>(args.This ());
791791
792792 if (SSL_CTX_set_tlsext_ticket_keys (wrap->ctx_ ,
793793 Buffer::Data (args[0 ]),
@@ -915,8 +915,7 @@ void SSLWrap<Base>::GetPeerCertificate(
915915 const FunctionCallbackInfo<Value>& args) {
916916 HandleScope scope (node_isolate);
917917
918- Base* w = NULL ;
919- NODE_UNWRAP (args.This (), Base, w);
918+ Base* w = UnwrapObject<Base>(args.This ());
920919 Environment* env = w->env ();
921920
922921 Local<Object> info = Object::New ();
@@ -1050,8 +1049,7 @@ template <class Base>
10501049void SSLWrap<Base>::GetSession(const FunctionCallbackInfo<Value>& args) {
10511050 HandleScope scope (node_isolate);
10521051
1053- Base* w = NULL ;
1054- NODE_UNWRAP (args.This (), Base, w);
1052+ Base* w = UnwrapObject<Base>(args.This ());
10551053
10561054 SSL_SESSION* sess = SSL_get_session (w->ssl_ );
10571055 if (sess == NULL )
@@ -1072,8 +1070,7 @@ template <class Base>
10721070void SSLWrap<Base>::SetSession(const FunctionCallbackInfo<Value>& args) {
10731071 HandleScope scope (node_isolate);
10741072
1075- Base* w = NULL ;
1076- NODE_UNWRAP (args.This (), Base, w);
1073+ Base* w = UnwrapObject<Base>(args.This ());
10771074
10781075 if (args.Length () < 1 ||
10791076 (!args[0 ]->IsString () && !Buffer::HasInstance (args[0 ]))) {
@@ -1111,8 +1108,7 @@ template <class Base>
11111108void SSLWrap<Base>::LoadSession(const FunctionCallbackInfo<Value>& args) {
11121109 HandleScope scope (node_isolate);
11131110
1114- Base* w = NULL ;
1115- NODE_UNWRAP (args.This (), Base, w);
1111+ Base* w = UnwrapObject<Base>(args.This ());
11161112 Environment* env = w->env ();
11171113
11181114 if (args.Length () >= 1 && Buffer::HasInstance (args[0 ])) {
@@ -1144,8 +1140,7 @@ void SSLWrap<Base>::LoadSession(const FunctionCallbackInfo<Value>& args) {
11441140template <class Base >
11451141void SSLWrap<Base>::IsSessionReused(const FunctionCallbackInfo<Value>& args) {
11461142 HandleScope scope (node_isolate);
1147- Base* w = NULL ;
1148- NODE_UNWRAP (args.This (), Base, w);
1143+ Base* w = UnwrapObject<Base>(args.This ());
11491144 bool yes = SSL_session_reused (w->ssl_ );
11501145 args.GetReturnValue ().Set (yes);
11511146}
@@ -1154,8 +1149,7 @@ void SSLWrap<Base>::IsSessionReused(const FunctionCallbackInfo<Value>& args) {
11541149template <class Base >
11551150void SSLWrap<Base>::ReceivedShutdown(const FunctionCallbackInfo<Value>& args) {
11561151 HandleScope scope (node_isolate);
1157- Base* w = NULL ;
1158- NODE_UNWRAP (args.This (), Base, w);
1152+ Base* w = UnwrapObject<Base>(args.This ());
11591153 bool yes = SSL_get_shutdown (w->ssl_ ) == SSL_RECEIVED_SHUTDOWN;
11601154 args.GetReturnValue ().Set (yes);
11611155}
@@ -1164,8 +1158,7 @@ void SSLWrap<Base>::ReceivedShutdown(const FunctionCallbackInfo<Value>& args) {
11641158template <class Base >
11651159void SSLWrap<Base>::EndParser(const FunctionCallbackInfo<Value>& args) {
11661160 HandleScope scope (node_isolate);
1167- Base* w = NULL ;
1168- NODE_UNWRAP (args.This (), Base, w);
1161+ Base* w = UnwrapObject<Base>(args.This ());
11691162 w->hello_parser_ .End ();
11701163}
11711164
@@ -1174,8 +1167,7 @@ template <class Base>
11741167void SSLWrap<Base>::Renegotiate(const FunctionCallbackInfo<Value>& args) {
11751168 HandleScope scope (node_isolate);
11761169
1177- Base* w = NULL ;
1178- NODE_UNWRAP (args.This (), Base, w);
1170+ Base* w = UnwrapObject<Base>(args.This ());
11791171
11801172 ClearErrorOnReturn clear_error_on_return;
11811173 (void ) &clear_error_on_return; // Silence unused variable warning.
@@ -1188,8 +1180,7 @@ void SSLWrap<Base>::Renegotiate(const FunctionCallbackInfo<Value>& args) {
11881180template <class Base >
11891181void SSLWrap<Base>::IsInitFinished(const FunctionCallbackInfo<Value>& args) {
11901182 HandleScope scope (node_isolate);
1191- Base* w = NULL ;
1192- NODE_UNWRAP (args.This (), Base, w);
1183+ Base* w = UnwrapObject<Base>(args.This ());
11931184 bool yes = SSL_is_init_finished (w->ssl_ );
11941185 args.GetReturnValue ().Set (yes);
11951186}
@@ -1200,8 +1191,7 @@ template <class Base>
12001191void SSLWrap<Base>::VerifyError(const FunctionCallbackInfo<Value>& args) {
12011192 HandleScope scope (node_isolate);
12021193
1203- Base* w = NULL ;
1204- NODE_UNWRAP (args.This (), Base, w);
1194+ Base* w = UnwrapObject<Base>(args.This ());
12051195
12061196 // XXX(indutny) Do this check in JS land?
12071197 X509* peer_cert = SSL_get_peer_certificate (w->ssl_ );
@@ -1267,8 +1257,7 @@ template <class Base>
12671257void SSLWrap<Base>::GetCurrentCipher(const FunctionCallbackInfo<Value>& args) {
12681258 HandleScope scope (node_isolate);
12691259
1270- Base* w = NULL ;
1271- NODE_UNWRAP (args.This (), Base, w);
1260+ Base* w = UnwrapObject<Base>(args.This ());
12721261 Environment* env = w->env ();
12731262
12741263 OPENSSL_CONST SSL_CIPHER* c = SSL_get_current_cipher (w->ssl_ );
@@ -1363,8 +1352,7 @@ void SSLWrap<Base>::GetNegotiatedProto(
13631352 const FunctionCallbackInfo<Value>& args) {
13641353 HandleScope scope (node_isolate);
13651354
1366- Base* w = NULL ;
1367- NODE_UNWRAP (args.This (), Base, w);
1355+ Base* w = UnwrapObject<Base>(args.This ());
13681356
13691357 if (w->is_client ()) {
13701358 if (w->selected_npn_proto_ .IsEmpty () == false ) {
@@ -1390,8 +1378,7 @@ template <class Base>
13901378void SSLWrap<Base>::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
13911379 HandleScope scope (node_isolate);
13921380
1393- Base* w = NULL ;
1394- NODE_UNWRAP (args.This (), Base, w);
1381+ Base* w = UnwrapObject<Base>(args.This ());
13951382
13961383 if (args.Length () < 1 || !Buffer::HasInstance (args[0 ]))
13971384 return ThrowTypeError (" Must give a Buffer as first argument" );
0 commit comments