Browse Source

src: shorten Object{Wrap,Unwrap}

Going back to the original names of Wrap/Unwrap now that most all the
class members that duplicate the name and functionality have been
removed.
v0.11.8-release
Trevor Norris 12 years ago
parent
commit
613d76ef6a
  1. 4
      src/fs_event_wrap.cc
  2. 8
      src/handle_wrap.cc
  3. 14
      src/node_contextify.cc
  4. 134
      src/node_crypto.cc
  5. 8
      src/node_http_parser.cc
  6. 4
      src/node_stat_watcher.cc
  7. 6
      src/node_wrap.h
  8. 10
      src/node_zlib.cc
  9. 12
      src/pipe_wrap.cc
  10. 6
      src/process_wrap.cc
  11. 4
      src/signal_wrap.cc
  12. 18
      src/stream_wrap.cc
  13. 24
      src/tcp_wrap.cc
  14. 10
      src/timer_wrap.cc
  15. 20
      src/tls_wrap.cc
  16. 4
      src/tty_wrap.cc
  17. 16
      src/udp_wrap.cc
  18. 4
      src/util-inl.h
  19. 4
      src/util.h
  20. 2
      src/weak-object-inl.h

4
src/fs_event_wrap.cc

@ -100,7 +100,7 @@ void FSEventWrap::New(const FunctionCallbackInfo<Value>& args) {
void FSEventWrap::Start(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
FSEventWrap* wrap = UnwrapObject<FSEventWrap>(args.This());
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.This());
if (args.Length() < 1 || !args[0]->IsString()) {
return ThrowTypeError("Bad arguments");
@ -179,7 +179,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
void FSEventWrap::Close(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
FSEventWrap* wrap = UnwrapObject<FSEventWrap>(args.This());
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.This());
if (wrap == NULL || wrap->initialized_ == false)
return;

8
src/handle_wrap.cc

@ -44,7 +44,7 @@ extern QUEUE handle_wrap_queue;
void HandleWrap::Ref(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
HandleWrap* wrap = UnwrapObject<HandleWrap>(args.This());
HandleWrap* wrap = Unwrap<HandleWrap>(args.This());
if (wrap != NULL && wrap->handle__ != NULL) {
uv_ref(wrap->handle__);
@ -56,7 +56,7 @@ void HandleWrap::Ref(const FunctionCallbackInfo<Value>& args) {
void HandleWrap::Unref(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
HandleWrap* wrap = UnwrapObject<HandleWrap>(args.This());
HandleWrap* wrap = Unwrap<HandleWrap>(args.This());
if (wrap != NULL && wrap->handle__ != NULL) {
uv_unref(wrap->handle__);
@ -68,7 +68,7 @@ void HandleWrap::Unref(const FunctionCallbackInfo<Value>& args) {
void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
HandleWrap* wrap = UnwrapObject<HandleWrap>(args.This());
HandleWrap* wrap = Unwrap<HandleWrap>(args.This());
// guard against uninitialized handle or double close
if (wrap == NULL || wrap->handle__ == NULL)
@ -95,7 +95,7 @@ HandleWrap::HandleWrap(Environment* env,
handle__->data = this;
HandleScope scope(node_isolate);
persistent().Reset(node_isolate, object);
WrapObject<HandleWrap>(object, this);
Wrap<HandleWrap>(object, this);
QUEUE_INSERT_TAIL(&handle_wrap_queue, &handle_wrap_queue_);
}

14
src/node_contextify.cc

@ -180,7 +180,7 @@ class ContextifyContext {
HandleScope scope(node_isolate);
Local<Object> wrapper =
env->script_data_constructor_function()->NewInstance();
WrapObject<ContextifyContext>(wrapper, this);
Wrap<ContextifyContext>(wrapper, this);
return scope.Close(wrapper);
}
@ -300,7 +300,7 @@ class ContextifyContext {
HandleScope scope(node_isolate);
ContextifyContext* ctx =
UnwrapObject<ContextifyContext>(args.Data().As<Object>());
Unwrap<ContextifyContext>(args.Data().As<Object>());
Local<Object> sandbox = PersistentToLocal(node_isolate, ctx->sandbox_);
Local<Value> rv = sandbox->GetRealNamedProperty(property);
@ -324,7 +324,7 @@ class ContextifyContext {
HandleScope scope(node_isolate);
ContextifyContext* ctx =
UnwrapObject<ContextifyContext>(args.Data().As<Object>());
Unwrap<ContextifyContext>(args.Data().As<Object>());
PersistentToLocal(node_isolate, ctx->sandbox_)->Set(property, value);
}
@ -336,7 +336,7 @@ class ContextifyContext {
HandleScope scope(node_isolate);
ContextifyContext* ctx =
UnwrapObject<ContextifyContext>(args.Data().As<Object>());
Unwrap<ContextifyContext>(args.Data().As<Object>());
Local<Object> sandbox = PersistentToLocal(node_isolate, ctx->sandbox_);
Local<Object> proxy_global = PersistentToLocal(node_isolate,
@ -357,7 +357,7 @@ class ContextifyContext {
HandleScope scope(node_isolate);
ContextifyContext* ctx =
UnwrapObject<ContextifyContext>(args.Data().As<Object>());
Unwrap<ContextifyContext>(args.Data().As<Object>());
bool success = PersistentToLocal(node_isolate,
ctx->sandbox_)->Delete(property);
@ -374,7 +374,7 @@ class ContextifyContext {
HandleScope scope(node_isolate);
ContextifyContext* ctx =
UnwrapObject<ContextifyContext>(args.Data().As<Object>());
Unwrap<ContextifyContext>(args.Data().As<Object>());
Local<Object> sandbox = PersistentToLocal(node_isolate, ctx->sandbox_);
args.GetReturnValue().Set(sandbox->GetPropertyNames());
@ -575,7 +575,7 @@ class ContextifyScript : public WeakObject {
}
ContextifyScript* wrapped_script =
UnwrapObject<ContextifyScript>(args.This());
Unwrap<ContextifyScript>(args.This());
Local<Script> script = PersistentToLocal(node_isolate,
wrapped_script->script_);

134
src/node_crypto.cc

@ -245,7 +245,7 @@ void SecureContext::New(const FunctionCallbackInfo<Value>& args) {
void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
OPENSSL_CONST SSL_METHOD *method = SSLv23_method();
@ -371,7 +371,7 @@ static X509* LoadX509(Handle<Value> v) {
void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
unsigned int len = args.Length();
if (len != 1 && len != 2) {
@ -477,7 +477,7 @@ int SSL_CTX_use_certificate_chain(SSL_CTX *ctx, BIO *in) {
void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
if (args.Length() != 1) {
return ThrowTypeError("Bad parameter");
@ -505,7 +505,7 @@ void SecureContext::AddCACert(const FunctionCallbackInfo<Value>& args) {
bool newCAStore = false;
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
if (args.Length() != 1) {
return ThrowTypeError("Bad parameter");
@ -534,7 +534,7 @@ void SecureContext::AddCACert(const FunctionCallbackInfo<Value>& args) {
void SecureContext::AddCRL(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
if (args.Length() != 1) {
return ThrowTypeError("Bad parameter");
@ -566,7 +566,7 @@ void SecureContext::AddCRL(const FunctionCallbackInfo<Value>& args) {
void SecureContext::AddRootCerts(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
assert(sc->ca_store_ == NULL);
@ -603,7 +603,7 @@ void SecureContext::AddRootCerts(const FunctionCallbackInfo<Value>& args) {
void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
if (args.Length() != 1 || !args[0]->IsString()) {
return ThrowTypeError("Bad parameter");
@ -617,7 +617,7 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
void SecureContext::SetOptions(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
if (args.Length() != 1 || !args[0]->IntegerValue()) {
return ThrowTypeError("Bad parameter");
@ -631,7 +631,7 @@ void SecureContext::SetSessionIdContext(
const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
if (args.Length() != 1 || !args[0]->IsString()) {
return ThrowTypeError("Bad parameter");
@ -668,7 +668,7 @@ void SecureContext::SetSessionIdContext(
void SecureContext::SetSessionTimeout(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
if (args.Length() != 1 || !args[0]->IsInt32()) {
return ThrowTypeError("Bad parameter");
@ -681,7 +681,7 @@ void SecureContext::SetSessionTimeout(const FunctionCallbackInfo<Value>& args) {
void SecureContext::Close(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
sc->FreeCTXMem();
}
@ -698,7 +698,7 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
char* pass = NULL;
bool ret = false;
SecureContext* sc = UnwrapObject<SecureContext>(args.This());
SecureContext* sc = Unwrap<SecureContext>(args.This());
if (args.Length() < 1) {
return ThrowTypeError("Bad parameter");
@ -763,7 +763,7 @@ void SecureContext::GetTicketKeys(const FunctionCallbackInfo<Value>& args) {
#if !defined(OPENSSL_NO_TLSEXT) && defined(SSL_CTX_get_tlsext_ticket_keys)
HandleScope handle_scope(args.GetIsolate());
SecureContext* wrap = UnwrapObject<SecureContext>(args.This());
SecureContext* wrap = Unwrap<SecureContext>(args.This());
Local<Object> buff = Buffer::New(wrap->env(), 48);
if (SSL_CTX_get_tlsext_ticket_keys(wrap->ctx_,
@ -787,7 +787,7 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo<Value>& args) {
return ThrowTypeError("Bad argument");
}
SecureContext* wrap = UnwrapObject<SecureContext>(args.This());
SecureContext* wrap = Unwrap<SecureContext>(args.This());
if (SSL_CTX_set_tlsext_ticket_keys(wrap->ctx_,
Buffer::Data(args[0]),
@ -915,7 +915,7 @@ void SSLWrap<Base>::GetPeerCertificate(
const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
Environment* env = w->env();
Local<Object> info = Object::New();
@ -1049,7 +1049,7 @@ template <class Base>
void SSLWrap<Base>::GetSession(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
SSL_SESSION* sess = SSL_get_session(w->ssl_);
if (sess == NULL)
@ -1070,7 +1070,7 @@ template <class Base>
void SSLWrap<Base>::SetSession(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
if (args.Length() < 1 ||
(!args[0]->IsString() && !Buffer::HasInstance(args[0]))) {
@ -1108,7 +1108,7 @@ template <class Base>
void SSLWrap<Base>::LoadSession(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
Environment* env = w->env();
if (args.Length() >= 1 && Buffer::HasInstance(args[0])) {
@ -1140,7 +1140,7 @@ void SSLWrap<Base>::LoadSession(const FunctionCallbackInfo<Value>& args) {
template <class Base>
void SSLWrap<Base>::IsSessionReused(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
bool yes = SSL_session_reused(w->ssl_);
args.GetReturnValue().Set(yes);
}
@ -1149,7 +1149,7 @@ void SSLWrap<Base>::IsSessionReused(const FunctionCallbackInfo<Value>& args) {
template <class Base>
void SSLWrap<Base>::ReceivedShutdown(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
bool yes = SSL_get_shutdown(w->ssl_) == SSL_RECEIVED_SHUTDOWN;
args.GetReturnValue().Set(yes);
}
@ -1158,7 +1158,7 @@ void SSLWrap<Base>::ReceivedShutdown(const FunctionCallbackInfo<Value>& args) {
template <class Base>
void SSLWrap<Base>::EndParser(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
w->hello_parser_.End();
}
@ -1167,7 +1167,7 @@ template <class Base>
void SSLWrap<Base>::Renegotiate(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
ClearErrorOnReturn clear_error_on_return;
(void) &clear_error_on_return; // Silence unused variable warning.
@ -1180,7 +1180,7 @@ void SSLWrap<Base>::Renegotiate(const FunctionCallbackInfo<Value>& args) {
template <class Base>
void SSLWrap<Base>::IsInitFinished(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
bool yes = SSL_is_init_finished(w->ssl_);
args.GetReturnValue().Set(yes);
}
@ -1191,7 +1191,7 @@ template <class Base>
void SSLWrap<Base>::VerifyError(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
// XXX(indutny) Do this check in JS land?
X509* peer_cert = SSL_get_peer_certificate(w->ssl_);
@ -1257,7 +1257,7 @@ template <class Base>
void SSLWrap<Base>::GetCurrentCipher(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
Environment* env = w->env();
OPENSSL_CONST SSL_CIPHER* c = SSL_get_current_cipher(w->ssl_);
@ -1352,7 +1352,7 @@ void SSLWrap<Base>::GetNegotiatedProto(
const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
if (w->is_client()) {
if (w->selected_npn_proto_.IsEmpty() == false) {
@ -1378,7 +1378,7 @@ template <class Base>
void SSLWrap<Base>::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Base* w = UnwrapObject<Base>(args.This());
Base* w = Unwrap<Base>(args.This());
if (args.Length() < 1 || !Buffer::HasInstance(args[0]))
return ThrowTypeError("Must give a Buffer as first argument");
@ -1654,7 +1654,7 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) {
env->secure_context_constructor_template();
if (secure_context_constructor_template->HasInstance(ret)) {
conn->sniContext_.Reset(node_isolate, ret);
SecureContext* sc = UnwrapObject<SecureContext>(ret.As<Object>());
SecureContext* sc = Unwrap<SecureContext>(ret.As<Object>());
SSL_set_SSL_CTX(s, sc->ctx_);
} else {
return SSL_TLSEXT_ERR_NOACK;
@ -1673,7 +1673,7 @@ void Connection::New(const FunctionCallbackInfo<Value>& args) {
return ThrowError("First argument must be a crypto module Credentials");
}
SecureContext* sc = UnwrapObject<SecureContext>(args[0]->ToObject());
SecureContext* sc = Unwrap<SecureContext>(args[0]->ToObject());
Environment* env = sc->env();
bool is_server = args[1]->BooleanValue();
@ -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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<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 = UnwrapObject<Connection>(args.This());
Connection* conn = Unwrap<Connection>(args.This());
if (args.Length() < 1 || !args[0]->IsFunction()) {
return ThrowError("Must give a Function as first argument");
@ -2135,7 +2135,7 @@ void CipherBase::Init(const char* cipher_type,
void CipherBase::Init(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
CipherBase* cipher = UnwrapObject<CipherBase>(args.This());
CipherBase* cipher = Unwrap<CipherBase>(args.This());
if (args.Length() < 2 ||
!(args[0]->IsString() && Buffer::HasInstance(args[1]))) {
@ -2187,7 +2187,7 @@ void CipherBase::InitIv(const char* cipher_type,
void CipherBase::InitIv(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
CipherBase* cipher = UnwrapObject<CipherBase>(args.This());
CipherBase* cipher = Unwrap<CipherBase>(args.This());
if (args.Length() < 3 || !args[0]->IsString()) {
return ThrowError("Must give cipher-type, key, and iv as argument");
@ -2225,7 +2225,7 @@ void CipherBase::Update(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope handle_scope(args.GetIsolate());
CipherBase* cipher = UnwrapObject<CipherBase>(args.This());
CipherBase* cipher = Unwrap<CipherBase>(args.This());
ASSERT_IS_STRING_OR_BUFFER(args[0]);
@ -2272,7 +2272,7 @@ bool CipherBase::SetAutoPadding(bool auto_padding) {
void CipherBase::SetAutoPadding(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
CipherBase* cipher = UnwrapObject<CipherBase>(args.This());
CipherBase* cipher = Unwrap<CipherBase>(args.This());
cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue());
}
@ -2294,7 +2294,7 @@ void CipherBase::Final(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope handle_scope(args.GetIsolate());
CipherBase* cipher = UnwrapObject<CipherBase>(args.This());
CipherBase* cipher = Unwrap<CipherBase>(args.This());
unsigned char* out_value = NULL;
int out_len = -1;
@ -2354,7 +2354,7 @@ void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) {
void Hmac::HmacInit(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Hmac* hmac = UnwrapObject<Hmac>(args.This());
Hmac* hmac = Unwrap<Hmac>(args.This());
if (args.Length() < 2 || !args[0]->IsString()) {
return ThrowError("Must give hashtype string, key as arguments");
@ -2380,7 +2380,7 @@ bool Hmac::HmacUpdate(const char* data, int len) {
void Hmac::HmacUpdate(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Hmac* hmac = UnwrapObject<Hmac>(args.This());
Hmac* hmac = Unwrap<Hmac>(args.This());
ASSERT_IS_STRING_OR_BUFFER(args[0]);
@ -2422,7 +2422,7 @@ bool Hmac::HmacDigest(unsigned char** md_value, unsigned int* md_len) {
void Hmac::HmacDigest(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Hmac* hmac = UnwrapObject<Hmac>(args.This());
Hmac* hmac = Unwrap<Hmac>(args.This());
enum encoding encoding = BUFFER;
if (args.Length() >= 1) {
@ -2496,7 +2496,7 @@ bool Hash::HashUpdate(const char* data, int len) {
void Hash::HashUpdate(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Hash* hash = UnwrapObject<Hash>(args.This());
Hash* hash = Unwrap<Hash>(args.This());
ASSERT_IS_STRING_OR_BUFFER(args[0]);
@ -2527,7 +2527,7 @@ void Hash::HashUpdate(const FunctionCallbackInfo<Value>& args) {
void Hash::HashDigest(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Hash* hash = UnwrapObject<Hash>(args.This());
Hash* hash = Unwrap<Hash>(args.This());
if (!hash->initialised_) {
return ThrowError("Not initialized");
@ -2586,7 +2586,7 @@ void Sign::SignInit(const char* sign_type) {
void Sign::SignInit(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Sign* sign = UnwrapObject<Sign>(args.This());
Sign* sign = Unwrap<Sign>(args.This());
if (args.Length() == 0 || !args[0]->IsString()) {
return ThrowError("Must give signtype string as argument");
@ -2608,7 +2608,7 @@ bool Sign::SignUpdate(const char* data, int len) {
void Sign::SignUpdate(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Sign* sign = UnwrapObject<Sign>(args.This());
Sign* sign = Unwrap<Sign>(args.This());
ASSERT_IS_STRING_OR_BUFFER(args[0]);
@ -2694,7 +2694,7 @@ bool Sign::SignFinal(const char* key_pem,
void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Sign* sign = UnwrapObject<Sign>(args.This());
Sign* sign = Unwrap<Sign>(args.This());
unsigned char* md_value;
unsigned int md_len;
@ -2768,7 +2768,7 @@ void Verify::VerifyInit(const char* verify_type) {
void Verify::VerifyInit(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Verify* verify = UnwrapObject<Verify>(args.This());
Verify* verify = Unwrap<Verify>(args.This());
if (args.Length() == 0 || !args[0]->IsString()) {
return ThrowError("Must give verifytype string as argument");
@ -2790,7 +2790,7 @@ bool Verify::VerifyUpdate(const char* data, int len) {
void Verify::VerifyUpdate(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Verify* verify = UnwrapObject<Verify>(args.This());
Verify* verify = Unwrap<Verify>(args.This());
ASSERT_IS_STRING_OR_BUFFER(args[0]);
@ -2903,7 +2903,7 @@ bool Verify::VerifyFinal(const char* key_pem,
void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Verify* verify = UnwrapObject<Verify>(args.This());
Verify* verify = Unwrap<Verify>(args.This());
ASSERT_IS_BUFFER(args[0]);
char* kbuf = Buffer::Data(args[0]);
@ -3056,7 +3056,7 @@ void DiffieHellman::New(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::GenerateKeys(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
DiffieHellman* diffieHellman = UnwrapObject<DiffieHellman>(args.This());
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.This());
if (!diffieHellman->initialised_) {
return ThrowError("Not initialized");
@ -3079,7 +3079,7 @@ void DiffieHellman::GenerateKeys(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::GetPrime(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
DiffieHellman* diffieHellman = UnwrapObject<DiffieHellman>(args.This());
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.This());
if (!diffieHellman->initialised_) {
return ThrowError("Not initialized");
@ -3097,7 +3097,7 @@ void DiffieHellman::GetPrime(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::GetGenerator(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
DiffieHellman* diffieHellman = UnwrapObject<DiffieHellman>(args.This());
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.This());
if (!diffieHellman->initialised_) {
return ThrowError("Not initialized");
@ -3115,7 +3115,7 @@ void DiffieHellman::GetGenerator(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::GetPublicKey(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
DiffieHellman* diffieHellman = UnwrapObject<DiffieHellman>(args.This());
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.This());
if (!diffieHellman->initialised_) {
return ThrowError("Not initialized");
@ -3138,7 +3138,7 @@ void DiffieHellman::GetPublicKey(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
DiffieHellman* diffieHellman = UnwrapObject<DiffieHellman>(args.This());
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.This());
if (!diffieHellman->initialised_) {
return ThrowError("Not initialized");
@ -3161,7 +3161,7 @@ void DiffieHellman::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
DiffieHellman* diffieHellman = UnwrapObject<DiffieHellman>(args.This());
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.This());
if (!diffieHellman->initialised_) {
return ThrowError("Not initialized");
@ -3232,7 +3232,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::SetPublicKey(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
DiffieHellman* diffieHellman = UnwrapObject<DiffieHellman>(args.This());
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.This());
if (!diffieHellman->initialised_) {
return ThrowError("Not initialized");
@ -3252,7 +3252,7 @@ void DiffieHellman::SetPublicKey(const FunctionCallbackInfo<Value>& args) {
void DiffieHellman::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
DiffieHellman* diffieHellman = UnwrapObject<DiffieHellman>(args.This());
DiffieHellman* diffieHellman = Unwrap<DiffieHellman>(args.This());
if (!diffieHellman->initialised_) {
return ThrowError("Not initialized");
@ -3697,7 +3697,7 @@ bool Certificate::VerifySpkac(const char* data, unsigned int len) {
void Certificate::VerifySpkac(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Certificate* certificate = UnwrapObject<Certificate>(args.This());
Certificate* certificate = Unwrap<Certificate>(args.This());
bool i = false;
if (args.Length() < 1)
@ -3762,7 +3762,7 @@ const char* Certificate::ExportPublicKey(const char* data, int len) {
void Certificate::ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Certificate* certificate = UnwrapObject<Certificate>(args.This());
Certificate* certificate = Unwrap<Certificate>(args.This());
if (args.Length() < 1)
return ThrowTypeError("Missing argument");
@ -3805,7 +3805,7 @@ const char* Certificate::ExportChallenge(const char* data, int len) {
void Certificate::ExportChallenge(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Certificate* crt = UnwrapObject<Certificate>(args.This());
Certificate* crt = Unwrap<Certificate>(args.This());
if (args.Length() < 1)
return ThrowTypeError("Missing argument");

8
src/node_http_parser.cc

@ -364,7 +364,7 @@ class Parser : public WeakObject {
static void Execute(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Parser* parser = UnwrapObject<Parser>(args.This());
Parser* parser = Unwrap<Parser>(args.This());
assert(parser->current_buffer_.IsEmpty());
assert(parser->current_buffer_len_ == 0);
assert(parser->current_buffer_data_ == NULL);
@ -419,7 +419,7 @@ class Parser : public WeakObject {
static void Finish(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
Parser* parser = UnwrapObject<Parser>(args.This());
Parser* parser = Unwrap<Parser>(args.This());
assert(parser->current_buffer_.IsEmpty());
parser->got_exception_ = false;
@ -453,7 +453,7 @@ class Parser : public WeakObject {
static_cast<http_parser_type>(args[0]->Int32Value());
assert(type == HTTP_REQUEST || type == HTTP_RESPONSE);
Parser* parser = UnwrapObject<Parser>(args.This());
Parser* parser = Unwrap<Parser>(args.This());
// Should always be called from the same context.
assert(env == parser->env());
parser->Init(type);
@ -464,7 +464,7 @@ class Parser : public WeakObject {
static void Pause(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope handle_scope(args.GetIsolate());
Parser* parser = UnwrapObject<Parser>(args.This());
Parser* parser = Unwrap<Parser>(args.This());
// Should always be called from the same context.
assert(env == parser->env());
http_parser_pause(&parser->parser_, should_pause);

4
src/node_stat_watcher.cc

@ -114,7 +114,7 @@ void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) {
assert(args.Length() == 3);
HandleScope scope(node_isolate);
StatWatcher* wrap = UnwrapObject<StatWatcher>(args.This());
StatWatcher* wrap = Unwrap<StatWatcher>(args.This());
String::Utf8Value path(args[0]);
const bool persistent = args[1]->BooleanValue();
const uint32_t interval = args[2]->Uint32Value();
@ -127,7 +127,7 @@ void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) {
void StatWatcher::Stop(const FunctionCallbackInfo<Value>& args) {
StatWatcher* wrap = UnwrapObject<StatWatcher>(args.This());
StatWatcher* wrap = Unwrap<StatWatcher>(args.This());
Environment* env = wrap->env();
Context::Scope context_scope(env->context());
HandleScope handle_scope(env->isolate());

6
src/node_wrap.h

@ -39,15 +39,15 @@ namespace node {
do { \
if (env->tcp_constructor_template().IsEmpty() == false && \
env->tcp_constructor_template()->HasInstance(obj)) { \
TCPWrap* const wrap = UnwrapObject<TCPWrap>(obj); \
TCPWrap* const wrap = Unwrap<TCPWrap>(obj); \
BODY \
} else if (env->tty_constructor_template().IsEmpty() == false && \
env->tty_constructor_template()->HasInstance(obj)) { \
TTYWrap* const wrap = UnwrapObject<TTYWrap>(obj); \
TTYWrap* const wrap = Unwrap<TTYWrap>(obj); \
BODY \
} else if (env->pipe_constructor_template().IsEmpty() == false && \
env->pipe_constructor_template()->HasInstance(obj)) { \
PipeWrap* const wrap = UnwrapObject<PipeWrap>(obj); \
PipeWrap* const wrap = Unwrap<PipeWrap>(obj); \
BODY \
} \
} while (0)

10
src/node_zlib.cc

@ -124,7 +124,7 @@ class ZCtx : public WeakObject {
static void Close(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
ZCtx* ctx = UnwrapObject<ZCtx>(args.This());
ZCtx* ctx = Unwrap<ZCtx>(args.This());
ctx->Close();
}
@ -134,7 +134,7 @@ class ZCtx : public WeakObject {
HandleScope scope(node_isolate);
assert(args.Length() == 7);
ZCtx* ctx = UnwrapObject<ZCtx>(args.This());
ZCtx* ctx = Unwrap<ZCtx>(args.This());
assert(ctx->init_done_ && "write before init");
assert(ctx->mode_ != NONE && "already finalized");
@ -343,7 +343,7 @@ class ZCtx : public WeakObject {
assert((args.Length() == 4 || args.Length() == 5) &&
"init(windowBits, level, memLevel, strategy, [dictionary])");
ZCtx* ctx = UnwrapObject<ZCtx>(args.This());
ZCtx* ctx = Unwrap<ZCtx>(args.This());
int windowBits = args[0]->Uint32Value();
assert((windowBits >= 8 && windowBits <= 15) && "invalid windowBits");
@ -382,7 +382,7 @@ class ZCtx : public WeakObject {
assert(args.Length() == 2 && "params(level, strategy)");
ZCtx* ctx = UnwrapObject<ZCtx>(args.This());
ZCtx* ctx = Unwrap<ZCtx>(args.This());
Params(ctx, args[0]->Int32Value(), args[1]->Int32Value());
}
@ -390,7 +390,7 @@ class ZCtx : public WeakObject {
static void Reset(const FunctionCallbackInfo<Value> &args) {
HandleScope scope(node_isolate);
ZCtx* ctx = UnwrapObject<ZCtx>(args.This());
ZCtx* ctx = Unwrap<ZCtx>(args.This());
Reset(ctx);
SetDictionary(ctx);

12
src/pipe_wrap.cc

@ -139,7 +139,7 @@ PipeWrap::PipeWrap(Environment* env, Handle<Object> object, bool ipc)
void PipeWrap::Bind(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
PipeWrap* wrap = UnwrapObject<PipeWrap>(args.This());
PipeWrap* wrap = Unwrap<PipeWrap>(args.This());
String::AsciiValue name(args[0]);
int err = uv_pipe_bind(&wrap->handle_, *name);
@ -151,7 +151,7 @@ void PipeWrap::Bind(const FunctionCallbackInfo<Value>& args) {
void PipeWrap::SetPendingInstances(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
PipeWrap* wrap = UnwrapObject<PipeWrap>(args.This());
PipeWrap* wrap = Unwrap<PipeWrap>(args.This());
int instances = args[0]->Int32Value();
@ -163,7 +163,7 @@ void PipeWrap::SetPendingInstances(const FunctionCallbackInfo<Value>& args) {
void PipeWrap::Listen(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
PipeWrap* wrap = UnwrapObject<PipeWrap>(args.This());
PipeWrap* wrap = Unwrap<PipeWrap>(args.This());
int backlog = args[0]->Int32Value();
int err = uv_listen(reinterpret_cast<uv_stream_t*>(&wrap->handle_),
@ -205,7 +205,7 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
env->pipe_constructor_template()->GetFunction()->NewInstance();
// Unwrap the client javascript object.
PipeWrap* wrap = UnwrapObject<PipeWrap>(client_obj);
PipeWrap* wrap = Unwrap<PipeWrap>(client_obj);
uv_stream_t* client_handle = reinterpret_cast<uv_stream_t*>(&wrap->handle_);
if (uv_accept(handle, client_handle))
return;
@ -264,7 +264,7 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
void PipeWrap::Open(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
PipeWrap* wrap = UnwrapObject<PipeWrap>(args.This());
PipeWrap* wrap = Unwrap<PipeWrap>(args.This());
int fd = args[0]->Int32Value();
@ -279,7 +279,7 @@ void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(args.GetIsolate());
PipeWrap* wrap = UnwrapObject<PipeWrap>(args.This());
PipeWrap* wrap = Unwrap<PipeWrap>(args.This());
assert(args[0]->IsObject());
assert(args[1]->IsString());

6
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*>(
UnwrapObject<PipeWrap>(handle)->UVHandle());
Unwrap<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");
@ -133,7 +133,7 @@ class ProcessWrap : public HandleWrap {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope handle_scope(args.GetIsolate());
ProcessWrap* wrap = UnwrapObject<ProcessWrap>(args.This());
ProcessWrap* wrap = Unwrap<ProcessWrap>(args.This());
Local<Object> js_options = args[0]->ToObject();
@ -261,7 +261,7 @@ class ProcessWrap : public HandleWrap {
static void Kill(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
ProcessWrap* wrap = UnwrapObject<ProcessWrap>(args.This());
ProcessWrap* wrap = Unwrap<ProcessWrap>(args.This());
int signal = args[0]->Int32Value();
int err = uv_process_kill(&wrap->process_, signal);

4
src/signal_wrap.cc

@ -80,7 +80,7 @@ class SignalWrap : public HandleWrap {
static void Start(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SignalWrap* wrap = UnwrapObject<SignalWrap>(args.This());
SignalWrap* wrap = Unwrap<SignalWrap>(args.This());
int signum = args[0]->Int32Value();
int err = uv_signal_start(&wrap->handle_, OnSignal, signum);
@ -89,7 +89,7 @@ class SignalWrap : public HandleWrap {
static void Stop(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
SignalWrap* wrap = UnwrapObject<SignalWrap>(args.This());
SignalWrap* wrap = Unwrap<SignalWrap>(args.This());
int err = uv_signal_stop(&wrap->handle_);
args.GetReturnValue().Set(err);

18
src/stream_wrap.cc

@ -66,7 +66,7 @@ StreamWrap::StreamWrap(Environment* env,
void StreamWrap::GetFD(Local<String>, const PropertyCallbackInfo<Value>& args) {
#if !defined(_WIN32)
HandleScope scope(node_isolate);
StreamWrap* wrap = UnwrapObject<StreamWrap>(args.This());
StreamWrap* wrap = Unwrap<StreamWrap>(args.This());
int fd = -1;
if (wrap != NULL && wrap->stream() != NULL) {
fd = wrap->stream()->io_watcher.fd;
@ -87,7 +87,7 @@ void StreamWrap::UpdateWriteQueueSize() {
void StreamWrap::ReadStart(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
StreamWrap* wrap = UnwrapObject<StreamWrap>(args.This());
StreamWrap* wrap = Unwrap<StreamWrap>(args.This());
int err;
if (wrap->is_named_pipe_ipc()) {
@ -103,7 +103,7 @@ void StreamWrap::ReadStart(const FunctionCallbackInfo<Value>& args) {
void StreamWrap::ReadStop(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
StreamWrap* wrap = UnwrapObject<StreamWrap>(args.This());
StreamWrap* wrap = Unwrap<StreamWrap>(args.This());
int err = uv_read_stop(wrap->stream());
args.GetReturnValue().Set(err);
@ -129,7 +129,7 @@ static Local<Object> AcceptHandle(Environment* env, uv_stream_t* pipe) {
if (wrap_obj.IsEmpty())
return Local<Object>();
WrapType* wrap = UnwrapObject<WrapType>(wrap_obj);
WrapType* wrap = Unwrap<WrapType>(wrap_obj);
handle = wrap->UVHandle();
if (uv_accept(pipe, reinterpret_cast<uv_stream_t*>(handle)))
@ -193,7 +193,7 @@ void StreamWrap::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope handle_scope(args.GetIsolate());
StreamWrap* wrap = UnwrapObject<StreamWrap>(args.This());
StreamWrap* wrap = Unwrap<StreamWrap>(args.This());
assert(args[0]->IsObject());
assert(Buffer::HasInstance(args[1]));
@ -233,7 +233,7 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
HandleScope handle_scope(args.GetIsolate());
int err;
StreamWrap* wrap = UnwrapObject<StreamWrap>(args.This());
StreamWrap* wrap = Unwrap<StreamWrap>(args.This());
assert(args[0]->IsObject());
assert(args[1]->IsString());
@ -283,7 +283,7 @@ void StreamWrap::WriteStringImpl(const FunctionCallbackInfo<Value>& args) {
if (args[2]->IsObject()) {
Local<Object> send_handle_obj = args[2].As<Object>();
HandleWrap* wrap = UnwrapObject<HandleWrap>(send_handle_obj);
HandleWrap* wrap = Unwrap<HandleWrap>(send_handle_obj);
send_handle = wrap->GetHandle();
// Reference StreamWrap instance to prevent it from being garbage
// collected before `AfterWrite` is called.
@ -316,7 +316,7 @@ void StreamWrap::Writev(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope handle_scope(args.GetIsolate());
StreamWrap* wrap = UnwrapObject<StreamWrap>(args.This());
StreamWrap* wrap = Unwrap<StreamWrap>(args.This());
assert(args[0]->IsObject());
assert(args[1]->IsArray());
@ -466,7 +466,7 @@ void StreamWrap::Shutdown(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope handle_scope(args.GetIsolate());
StreamWrap* wrap = UnwrapObject<StreamWrap>(args.This());
StreamWrap* wrap = Unwrap<StreamWrap>(args.This());
assert(args[0]->IsObject());
Local<Object> req_wrap_obj = args[0].As<Object>();

24
src/tcp_wrap.cc

@ -157,7 +157,7 @@ void TCPWrap::GetSockName(const FunctionCallbackInfo<Value>& args) {
HandleScope handle_scope(args.GetIsolate());
struct sockaddr_storage address;
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
assert(args[0]->IsObject());
Local<Object> out = args[0].As<Object>();
@ -180,7 +180,7 @@ void TCPWrap::GetPeerName(const FunctionCallbackInfo<Value>& args) {
HandleScope handle_scope(args.GetIsolate());
struct sockaddr_storage address;
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
assert(args[0]->IsObject());
Local<Object> out = args[0].As<Object>();
@ -201,7 +201,7 @@ void TCPWrap::GetPeerName(const FunctionCallbackInfo<Value>& args) {
void TCPWrap::SetNoDelay(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
int enable = static_cast<int>(args[0]->BooleanValue());
int err = uv_tcp_nodelay(&wrap->handle_, enable);
@ -212,7 +212,7 @@ void TCPWrap::SetNoDelay(const FunctionCallbackInfo<Value>& args) {
void TCPWrap::SetKeepAlive(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
int enable = args[0]->Int32Value();
unsigned int delay = args[1]->Uint32Value();
@ -226,7 +226,7 @@ void TCPWrap::SetKeepAlive(const FunctionCallbackInfo<Value>& args) {
void TCPWrap::SetSimultaneousAccepts(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
bool enable = args[0]->BooleanValue();
int err = uv_tcp_simultaneous_accepts(&wrap->handle_, enable);
@ -237,7 +237,7 @@ void TCPWrap::SetSimultaneousAccepts(const FunctionCallbackInfo<Value>& args) {
void TCPWrap::Open(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
int fd = args[0]->IntegerValue();
uv_tcp_open(&wrap->handle_, fd);
}
@ -246,7 +246,7 @@ void TCPWrap::Open(const FunctionCallbackInfo<Value>& args) {
void TCPWrap::Bind(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
String::AsciiValue ip_address(args[0]);
int port = args[1]->Int32Value();
@ -263,7 +263,7 @@ void TCPWrap::Bind(const FunctionCallbackInfo<Value>& args) {
void TCPWrap::Bind6(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
String::AsciiValue ip6_address(args[0]);
int port = args[1]->Int32Value();
@ -280,7 +280,7 @@ void TCPWrap::Bind6(const FunctionCallbackInfo<Value>& args) {
void TCPWrap::Listen(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
int backlog = args[0]->Int32Value();
int err = uv_listen(reinterpret_cast<uv_stream_t*>(&wrap->handle_),
@ -312,7 +312,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
Local<Object> client_obj = Instantiate(env);
// Unwrap the client javascript object.
TCPWrap* wrap = UnwrapObject<TCPWrap>(client_obj);
TCPWrap* wrap = Unwrap<TCPWrap>(client_obj);
uv_stream_t* client_handle = reinterpret_cast<uv_stream_t*>(&wrap->handle_);
if (uv_accept(handle, client_handle))
return;
@ -364,7 +364,7 @@ void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope handle_scope(args.GetIsolate());
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
assert(args[0]->IsObject());
assert(args[1]->IsString());
@ -396,7 +396,7 @@ void TCPWrap::Connect6(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope handle_scope(args.GetIsolate());
TCPWrap* wrap = UnwrapObject<TCPWrap>(args.This());
TCPWrap* wrap = Unwrap<TCPWrap>(args.This());
assert(args[0]->IsObject());
assert(args[1]->IsString());

10
src/timer_wrap.cc

@ -91,7 +91,7 @@ class TimerWrap : public HandleWrap {
static void Start(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TimerWrap* wrap = UnwrapObject<TimerWrap>(args.This());
TimerWrap* wrap = Unwrap<TimerWrap>(args.This());
int64_t timeout = args[0]->IntegerValue();
int64_t repeat = args[1]->IntegerValue();
@ -101,7 +101,7 @@ class TimerWrap : public HandleWrap {
static void Stop(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TimerWrap* wrap = UnwrapObject<TimerWrap>(args.This());
TimerWrap* wrap = Unwrap<TimerWrap>(args.This());
int err = uv_timer_stop(&wrap->handle_);
args.GetReturnValue().Set(err);
@ -109,7 +109,7 @@ class TimerWrap : public HandleWrap {
static void Again(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TimerWrap* wrap = UnwrapObject<TimerWrap>(args.This());
TimerWrap* wrap = Unwrap<TimerWrap>(args.This());
int err = uv_timer_again(&wrap->handle_);
args.GetReturnValue().Set(err);
@ -117,7 +117,7 @@ class TimerWrap : public HandleWrap {
static void SetRepeat(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TimerWrap* wrap = UnwrapObject<TimerWrap>(args.This());
TimerWrap* wrap = Unwrap<TimerWrap>(args.This());
int64_t repeat = args[0]->IntegerValue();
uv_timer_set_repeat(&wrap->handle_, repeat);
@ -126,7 +126,7 @@ class TimerWrap : public HandleWrap {
static void GetRepeat(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TimerWrap* wrap = UnwrapObject<TimerWrap>(args.This());
TimerWrap* wrap = Unwrap<TimerWrap>(args.This());
int64_t repeat = uv_timer_get_repeat(&wrap->handle_);
args.GetReturnValue().Set(static_cast<double>(repeat));

20
src/tls_wrap.cc

@ -60,7 +60,7 @@ TLSCallbacks::TLSCallbacks(Environment* env,
Kind kind,
Handle<Object> sc,
StreamWrapCallbacks* old)
: SSLWrap<TLSCallbacks>(env, UnwrapObject<SecureContext>(sc), kind),
: SSLWrap<TLSCallbacks>(env, Unwrap<SecureContext>(sc), kind),
StreamWrapCallbacks(old),
enc_in_(NULL),
enc_out_(NULL),
@ -72,12 +72,12 @@ TLSCallbacks::TLSCallbacks(Environment* env,
shutdown_(false) {
// Persist SecureContext
sc_ = UnwrapObject<SecureContext>(sc);
sc_ = Unwrap<SecureContext>(sc);
sc_handle_.Reset(node_isolate, sc);
Local<Object> object = env->tls_wrap_constructor_function()->NewInstance();
persistent().Reset(node_isolate, object);
WrapObject<TLSCallbacks>(object, this);
node::Wrap<TLSCallbacks>(object, this);
// Initialize queue for clearIn writes
QUEUE_INIT(&write_item_queue_);
@ -212,7 +212,7 @@ void TLSCallbacks::Wrap(const FunctionCallbackInfo<Value>& args) {
void TLSCallbacks::Start(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TLSCallbacks* wrap = UnwrapObject<TLSCallbacks>(args.This());
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.This());
if (wrap->started_)
return ThrowError("Already started.");
@ -583,7 +583,7 @@ int TLSCallbacks::DoShutdown(ShutdownWrap* req_wrap, uv_shutdown_cb cb) {
void TLSCallbacks::SetVerifyMode(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TLSCallbacks* wrap = UnwrapObject<TLSCallbacks>(args.This());
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.This());
if (args.Length() < 2 || !args[0]->IsBoolean() || !args[1]->IsBoolean())
return ThrowTypeError("Bad arguments, expected two booleans");
@ -614,7 +614,7 @@ void TLSCallbacks::EnableSessionCallbacks(
const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TLSCallbacks* wrap = UnwrapObject<TLSCallbacks>(args.This());
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.This());
wrap->enable_session_callbacks();
EnableHelloParser(args);
@ -624,7 +624,7 @@ void TLSCallbacks::EnableSessionCallbacks(
void TLSCallbacks::EnableHelloParser(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TLSCallbacks* wrap = UnwrapObject<TLSCallbacks>(args.This());
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.This());
wrap->hello_parser_.Start(SSLWrap<TLSCallbacks>::OnClientHello,
OnClientHelloParseEnd,
@ -642,7 +642,7 @@ void TLSCallbacks::OnClientHelloParseEnd(void* arg) {
void TLSCallbacks::GetServername(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TLSCallbacks* wrap = UnwrapObject<TLSCallbacks>(args.This());
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.This());
const char* servername = SSL_get_servername(wrap->ssl_,
TLSEXT_NAMETYPE_host_name);
@ -657,7 +657,7 @@ void TLSCallbacks::GetServername(const FunctionCallbackInfo<Value>& args) {
void TLSCallbacks::SetServername(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TLSCallbacks* wrap = UnwrapObject<TLSCallbacks>(args.This());
TLSCallbacks* wrap = Unwrap<TLSCallbacks>(args.This());
if (args.Length() < 1 || !args[0]->IsString())
return ThrowTypeError("First argument should be a string");
@ -694,7 +694,7 @@ int TLSCallbacks::SelectSNIContextCallback(SSL* s, int* ad, void* arg) {
p->sni_context_.Dispose();
p->sni_context_.Reset(node_isolate, ctx);
SecureContext* sc = UnwrapObject<SecureContext>(ctx.As<Object>());
SecureContext* sc = Unwrap<SecureContext>(ctx.As<Object>());
SSL_set_SSL_CTX(s, sc->ctx_);
}

4
src/tty_wrap.cc

@ -130,7 +130,7 @@ void TTYWrap::IsTTY(const FunctionCallbackInfo<Value>& args) {
void TTYWrap::GetWindowSize(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TTYWrap* wrap = UnwrapObject<TTYWrap>(args.This());
TTYWrap* wrap = Unwrap<TTYWrap>(args.This());
assert(args[0]->IsArray());
int width, height;
@ -149,7 +149,7 @@ void TTYWrap::GetWindowSize(const FunctionCallbackInfo<Value>& args) {
void TTYWrap::SetRawMode(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
TTYWrap* wrap = UnwrapObject<TTYWrap>(args.This());
TTYWrap* wrap = Unwrap<TTYWrap>(args.This());
int err = uv_tty_set_mode(&wrap->handle_, args[0]->IsTrue());
args.GetReturnValue().Set(err);

16
src/udp_wrap.cc

@ -135,7 +135,7 @@ void UDPWrap::New(const FunctionCallbackInfo<Value>& args) {
void UDPWrap::GetFD(Local<String>, const PropertyCallbackInfo<Value>& args) {
#if !defined(_WIN32)
HandleScope scope(node_isolate);
UDPWrap* wrap = UnwrapObject<UDPWrap>(args.This());
UDPWrap* wrap = Unwrap<UDPWrap>(args.This());
int fd = (wrap == NULL) ? -1 : wrap->handle_.io_watcher.fd;
args.GetReturnValue().Set(fd);
#endif
@ -145,7 +145,7 @@ void UDPWrap::GetFD(Local<String>, const PropertyCallbackInfo<Value>& args) {
void UDPWrap::DoBind(const FunctionCallbackInfo<Value>& args, int family) {
HandleScope scope(node_isolate);
UDPWrap* wrap = UnwrapObject<UDPWrap>(args.This());
UDPWrap* wrap = Unwrap<UDPWrap>(args.This());
// bind(ip, port, flags)
assert(args.Length() == 3);
@ -191,7 +191,7 @@ void UDPWrap::Bind6(const FunctionCallbackInfo<Value>& args) {
#define X(name, fn) \
void UDPWrap::name(const FunctionCallbackInfo<Value>& args) { \
HandleScope scope(node_isolate); \
UDPWrap* wrap = UnwrapObject<UDPWrap>(args.This()); \
UDPWrap* wrap = Unwrap<UDPWrap>(args.This()); \
assert(args.Length() == 1); \
int flag = args[0]->Int32Value(); \
int err = fn(&wrap->handle_, flag); \
@ -209,7 +209,7 @@ X(SetMulticastLoopback, uv_udp_set_multicast_loop)
void UDPWrap::SetMembership(const FunctionCallbackInfo<Value>& args,
uv_membership membership) {
HandleScope scope(node_isolate);
UDPWrap* wrap = UnwrapObject<UDPWrap>(args.This());
UDPWrap* wrap = Unwrap<UDPWrap>(args.This());
assert(args.Length() == 2);
@ -243,7 +243,7 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope handle_scope(args.GetIsolate());
UDPWrap* wrap = UnwrapObject<UDPWrap>(args.This());
UDPWrap* wrap = Unwrap<UDPWrap>(args.This());
// send(req, buffer, offset, length, port, address)
assert(args[0]->IsObject());
@ -313,7 +313,7 @@ void UDPWrap::Send6(const FunctionCallbackInfo<Value>& args) {
void UDPWrap::RecvStart(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
UDPWrap* wrap = UnwrapObject<UDPWrap>(args.This());
UDPWrap* wrap = Unwrap<UDPWrap>(args.This());
int err = uv_udp_recv_start(&wrap->handle_, OnAlloc, OnRecv);
// UV_EALREADY means that the socket is already bound but that's okay
@ -325,7 +325,7 @@ void UDPWrap::RecvStart(const FunctionCallbackInfo<Value>& args) {
void UDPWrap::RecvStop(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(node_isolate);
UDPWrap* wrap = UnwrapObject<UDPWrap>(args.This());
UDPWrap* wrap = Unwrap<UDPWrap>(args.This());
int r = uv_udp_recv_stop(&wrap->handle_);
args.GetReturnValue().Set(r);
@ -337,7 +337,7 @@ void UDPWrap::GetSockName(const FunctionCallbackInfo<Value>& args) {
HandleScope handle_scope(args.GetIsolate());
struct sockaddr_storage address;
UDPWrap* wrap = UnwrapObject<UDPWrap>(args.This());
UDPWrap* wrap = Unwrap<UDPWrap>(args.This());
assert(args[0]->IsObject());
Local<Object> obj = args[0].As<Object>();

4
src/util-inl.h

@ -81,14 +81,14 @@ inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
}
template <typename TypeName>
void WrapObject(v8::Local<v8::Object> object, TypeName* pointer) {
void Wrap(v8::Local<v8::Object> object, TypeName* pointer) {
assert(!object.IsEmpty());
assert(object->InternalFieldCount() > 0);
object->SetAlignedPointerInInternalField(0, pointer);
}
template <typename TypeName>
TypeName* UnwrapObject(v8::Local<v8::Object> object) {
TypeName* Unwrap(v8::Local<v8::Object> object) {
assert(!object.IsEmpty());
assert(object->InternalFieldCount() > 0);
void* pointer = object->GetAlignedPointerFromInternalField(0);

4
src/util.h

@ -77,10 +77,10 @@ inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
const unsigned char* data,
int length = -1);
inline static void WrapObject(v8::Local<v8::Object> object, void* pointer);
inline void Wrap(v8::Local<v8::Object> object, void* pointer);
template <typename TypeName>
inline static TypeName* UnwrapObject(v8::Local<v8::Object> object);
inline TypeName* Unwrap(v8::Local<v8::Object> object);
} // namespace node

2
src/weak-object-inl.h

@ -33,7 +33,7 @@ WeakObject::WeakObject(v8::Isolate* isolate, v8::Local<v8::Object> object)
weak_object_.MarkIndependent();
// The pointer is resolved as void*.
WrapObject<WeakObject>(object, this);
Wrap<WeakObject>(object, this);
MakeWeak();
}

Loading…
Cancel
Save