Browse Source

src: replace Holder() with This()

Switch to always use args.This() to retrieve object instance.
v0.11.1-release
Trevor Norris 12 years ago
committed by Ben Noordhuis
parent
commit
0a4ebc3d2c
  1. 6
      src/fs_event_wrap.cc
  2. 2
      src/handle_wrap.cc
  3. 6
      src/handle_wrap.h
  4. 28
      src/node_crypto.cc
  5. 2
      src/node_crypto.h
  6. 6
      src/node_internals.h
  7. 6
      src/node_script.cc
  8. 6
      src/node_stat_watcher.cc

6
src/fs_event_wrap.cc

@ -171,9 +171,9 @@ Handle<Value> FSEventWrap::Close(const Arguments& args) {
// Unwrap manually here. The UNWRAP() macro asserts that wrap != NULL. // Unwrap manually here. The UNWRAP() macro asserts that wrap != NULL.
// That usually indicates an error but not here: double closes are possible // That usually indicates an error but not here: double closes are possible
// and legal, HandleWrap::Close() deals with them the same way. // and legal, HandleWrap::Close() deals with them the same way.
assert(!args.Holder().IsEmpty()); assert(!args.This().IsEmpty());
assert(args.Holder()->InternalFieldCount() > 0); assert(args.This()->InternalFieldCount() > 0);
void* ptr = args.Holder()->GetAlignedPointerFromInternalField(0); void* ptr = args.This()->GetAlignedPointerFromInternalField(0);
FSEventWrap* wrap = static_cast<FSEventWrap*>(ptr); FSEventWrap* wrap = static_cast<FSEventWrap*>(ptr);
if (wrap == NULL || wrap->initialized_ == false) { if (wrap == NULL || wrap->initialized_ == false) {

2
src/handle_wrap.cc

@ -84,7 +84,7 @@ Handle<Value> HandleWrap::Close(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
HandleWrap *wrap = static_cast<HandleWrap*>( HandleWrap *wrap = static_cast<HandleWrap*>(
args.Holder()->GetAlignedPointerFromInternalField(0)); args.This()->GetAlignedPointerFromInternalField(0));
// guard against uninitialized handle or double close // guard against uninitialized handle or double close
if (wrap == NULL || wrap->handle__ == NULL) { if (wrap == NULL || wrap->handle__ == NULL) {

6
src/handle_wrap.h

@ -47,10 +47,10 @@ namespace node {
// taken care of. // taken care of.
#define UNWRAP_NO_ABORT(type) \ #define UNWRAP_NO_ABORT(type) \
assert(!args.Holder().IsEmpty()); \ assert(!args.This().IsEmpty()); \
assert(args.Holder()->InternalFieldCount() > 0); \ assert(args.This()->InternalFieldCount() > 0); \
type* wrap = static_cast<type*>( \ type* wrap = static_cast<type*>( \
args.Holder()->GetAlignedPointerFromInternalField(0)); args.This()->GetAlignedPointerFromInternalField(0));
class HandleWrap { class HandleWrap {
public: public:

28
src/node_crypto.cc

@ -170,7 +170,7 @@ void SecureContext::Initialize(Handle<Object> target) {
Handle<Value> SecureContext::New(const Arguments& args) { Handle<Value> SecureContext::New(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *p = new SecureContext(); SecureContext *p = new SecureContext();
p->Wrap(args.Holder()); p->Wrap(args.This());
return args.This(); return args.This();
} }
@ -178,7 +178,7 @@ Handle<Value> SecureContext::New(const Arguments& args) {
Handle<Value> SecureContext::Init(const Arguments& args) { Handle<Value> SecureContext::Init(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
OPENSSL_CONST SSL_METHOD *method = SSLv23_method(); OPENSSL_CONST SSL_METHOD *method = SSLv23_method();
@ -342,7 +342,7 @@ static X509* LoadX509 (Handle<Value> v) {
Handle<Value> SecureContext::SetKey(const Arguments& args) { Handle<Value> SecureContext::SetKey(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
unsigned int len = args.Length(); unsigned int len = args.Length();
if (len != 1 && len != 2) { if (len != 1 && len != 2) {
@ -447,7 +447,7 @@ end:
Handle<Value> SecureContext::SetCert(const Arguments& args) { Handle<Value> SecureContext::SetCert(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
if (args.Length() != 1) { if (args.Length() != 1) {
return ThrowException(Exception::TypeError( return ThrowException(Exception::TypeError(
@ -478,7 +478,7 @@ Handle<Value> SecureContext::AddCACert(const Arguments& args) {
bool newCAStore = false; bool newCAStore = false;
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
if (args.Length() != 1) { if (args.Length() != 1) {
return ThrowException(Exception::TypeError(String::New("Bad parameter"))); return ThrowException(Exception::TypeError(String::New("Bad parameter")));
@ -508,7 +508,7 @@ Handle<Value> SecureContext::AddCACert(const Arguments& args) {
Handle<Value> SecureContext::AddCRL(const Arguments& args) { Handle<Value> SecureContext::AddCRL(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
if (args.Length() != 1) { if (args.Length() != 1) {
return ThrowException(Exception::TypeError(String::New("Bad parameter"))); return ThrowException(Exception::TypeError(String::New("Bad parameter")));
@ -540,7 +540,7 @@ Handle<Value> SecureContext::AddCRL(const Arguments& args) {
Handle<Value> SecureContext::AddRootCerts(const Arguments& args) { Handle<Value> SecureContext::AddRootCerts(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
assert(sc->ca_store_ == NULL); assert(sc->ca_store_ == NULL);
@ -579,7 +579,7 @@ Handle<Value> SecureContext::AddRootCerts(const Arguments& args) {
Handle<Value> SecureContext::SetCiphers(const Arguments& args) { Handle<Value> SecureContext::SetCiphers(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
if (args.Length() != 1 || !args[0]->IsString()) { if (args.Length() != 1 || !args[0]->IsString()) {
return ThrowException(Exception::TypeError(String::New("Bad parameter"))); return ThrowException(Exception::TypeError(String::New("Bad parameter")));
@ -594,7 +594,7 @@ Handle<Value> SecureContext::SetCiphers(const Arguments& args) {
Handle<Value> SecureContext::SetOptions(const Arguments& args) { Handle<Value> SecureContext::SetOptions(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
if (args.Length() != 1 || !args[0]->IntegerValue()) { if (args.Length() != 1 || !args[0]->IntegerValue()) {
return ThrowException(Exception::TypeError(String::New("Bad parameter"))); return ThrowException(Exception::TypeError(String::New("Bad parameter")));
@ -608,7 +608,7 @@ Handle<Value> SecureContext::SetOptions(const Arguments& args) {
Handle<Value> SecureContext::SetSessionIdContext(const Arguments& args) { Handle<Value> SecureContext::SetSessionIdContext(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
if (args.Length() != 1 || !args[0]->IsString()) { if (args.Length() != 1 || !args[0]->IsString()) {
return ThrowException(Exception::TypeError(String::New("Bad parameter"))); return ThrowException(Exception::TypeError(String::New("Bad parameter")));
@ -640,7 +640,7 @@ Handle<Value> SecureContext::SetSessionIdContext(const Arguments& args) {
Handle<Value> SecureContext::SetSessionTimeout(const Arguments& args) { Handle<Value> SecureContext::SetSessionTimeout(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
if (args.Length() != 1 || !args[0]->IsInt32()) { if (args.Length() != 1 || !args[0]->IsInt32()) {
return ThrowTypeError("Bad parameter"); return ThrowTypeError("Bad parameter");
@ -654,7 +654,7 @@ Handle<Value> SecureContext::SetSessionTimeout(const Arguments& args) {
Handle<Value> SecureContext::Close(const Arguments& args) { Handle<Value> SecureContext::Close(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
sc->FreeCTXMem(); sc->FreeCTXMem();
return False(node_isolate); return False(node_isolate);
} }
@ -671,7 +671,7 @@ Handle<Value> SecureContext::LoadPKCS12(const Arguments& args) {
char* pass = NULL; char* pass = NULL;
bool ret = false; bool ret = false;
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder()); SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.This());
if (args.Length() < 1) { if (args.Length() < 1) {
return ThrowException(Exception::TypeError( return ThrowException(Exception::TypeError(
@ -1213,7 +1213,7 @@ Handle<Value> Connection::New(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
Connection *p = new Connection(); Connection *p = new Connection();
p->Wrap(args.Holder()); p->Wrap(args.This());
if (args.Length() < 1 || !args[0]->IsObject()) { if (args.Length() < 1 || !args[0]->IsObject()) {
return ThrowException(Exception::Error(String::New( return ThrowException(Exception::Error(String::New(

2
src/node_crypto.h

@ -225,7 +225,7 @@ class Connection : ObjectWrap {
void SetShutdownFlags(); void SetShutdownFlags();
static Connection* Unwrap(const v8::Arguments& args) { static Connection* Unwrap(const v8::Arguments& args) {
Connection* ss = ObjectWrap::Unwrap<Connection>(args.Holder()); Connection* ss = ObjectWrap::Unwrap<Connection>(args.This());
ss->ClearError(); ss->ClearError();
return ss; return ss;
} }

6
src/node_internals.h

@ -96,10 +96,10 @@ inline static v8::Handle<v8::Value> ThrowRangeError(const char* errmsg) {
} }
#define UNWRAP(type) \ #define UNWRAP(type) \
assert(!args.Holder().IsEmpty()); \ assert(!args.This().IsEmpty()); \
assert(args.Holder()->InternalFieldCount() > 0); \ assert(args.This()->InternalFieldCount() > 0); \
type* wrap = static_cast<type*>( \ type* wrap = static_cast<type*>( \
args.Holder()->GetAlignedPointerFromInternalField(0)); \ args.This()->GetAlignedPointerFromInternalField(0)); \
if (!wrap) { \ if (!wrap) { \
fprintf(stderr, #type ": Aborting due to unwrap failure at %s:%d\n", \ fprintf(stderr, #type ": Aborting due to unwrap failure at %s:%d\n", \
__FILE__, __LINE__); \ __FILE__, __LINE__); \

6
src/node_script.cc

@ -240,7 +240,7 @@ Handle<Value> WrappedScript::New(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
WrappedScript *t = new WrappedScript(); WrappedScript *t = new WrappedScript();
t->Wrap(args.Holder()); t->Wrap(args.This());
return return
WrappedScript::EvalMachine<compileCode, thisContext, wrapExternal>(args); WrappedScript::EvalMachine<compileCode, thisContext, wrapExternal>(args);
@ -401,7 +401,7 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args) {
return try_catch.ReThrow(); return try_catch.ReThrow();
} }
} else { } else {
WrappedScript *n_script = ObjectWrap::Unwrap<WrappedScript>(args.Holder()); WrappedScript *n_script = ObjectWrap::Unwrap<WrappedScript>(args.This());
if (!n_script) { if (!n_script) {
return ThrowException(Exception::Error( return ThrowException(Exception::Error(
String::New("Must be called as a method of Script."))); String::New("Must be called as a method of Script.")));
@ -422,7 +422,7 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args) {
return try_catch.ReThrow(); return try_catch.ReThrow();
} }
} else { } else {
WrappedScript *n_script = ObjectWrap::Unwrap<WrappedScript>(args.Holder()); WrappedScript *n_script = ObjectWrap::Unwrap<WrappedScript>(args.This());
if (!n_script) { if (!n_script) {
return ThrowException(Exception::Error( return ThrowException(Exception::Error(
String::New("Must be called as a method of Script."))); String::New("Must be called as a method of Script.")));

6
src/node_stat_watcher.cc

@ -94,7 +94,7 @@ Handle<Value> StatWatcher::New(const Arguments& args) {
assert(args.IsConstructCall()); assert(args.IsConstructCall());
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
StatWatcher* s = new StatWatcher(); StatWatcher* s = new StatWatcher();
s->Wrap(args.Holder()); s->Wrap(args.This());
return args.This(); return args.This();
} }
@ -103,7 +103,7 @@ Handle<Value> StatWatcher::Start(const Arguments& args) {
assert(args.Length() == 3); assert(args.Length() == 3);
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.Holder()); StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.This());
String::Utf8Value path(args[0]); String::Utf8Value path(args[0]);
const bool persistent = args[1]->BooleanValue(); const bool persistent = args[1]->BooleanValue();
const uint32_t interval = args[2]->Uint32Value(); const uint32_t interval = args[2]->Uint32Value();
@ -118,7 +118,7 @@ Handle<Value> StatWatcher::Start(const Arguments& args) {
Handle<Value> StatWatcher::Stop(const Arguments& args) { Handle<Value> StatWatcher::Stop(const Arguments& args) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.Holder()); StatWatcher* wrap = ObjectWrap::Unwrap<StatWatcher>(args.This());
if (onstop_sym.IsEmpty()) { if (onstop_sym.IsEmpty()) {
onstop_sym = NODE_PSYMBOL("onstop"); onstop_sym = NODE_PSYMBOL("onstop");
} }

Loading…
Cancel
Save