Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Add signature to SET_PROTOTYPE_METHOD and use args.Holder() in methods. #7261

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/api/addons.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ prototype:
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);

MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.This());
MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.Holder());
obj->value_ += 1;

args.GetReturnValue().Set(Number::New(isolate, obj->value_));
Expand Down Expand Up @@ -539,7 +539,7 @@ The implementation is similar to the above in `myobject.cc`:
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);

MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.This());
MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.Holder());
obj->value_ += 1;

args.GetReturnValue().Set(Number::New(isolate, obj->value_));
Expand Down
4 changes: 2 additions & 2 deletions src/fs_event_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void FSEventWrap::Start(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());

FSEventWrap* wrap = Unwrap<FSEventWrap>(args.This());
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.Holder());

if (args.Length() < 1 || !args[0]->IsString()) {
return env->ThrowTypeError("Bad arguments");
Expand Down Expand Up @@ -189,7 +189,7 @@ void FSEventWrap::Close(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());

FSEventWrap* wrap = Unwrap<FSEventWrap>(args.This());
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.Holder());

if (wrap == NULL || wrap->initialized_ == false)
return;
Expand Down
6 changes: 3 additions & 3 deletions src/handle_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void HandleWrap::Ref(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());

HandleWrap* wrap = Unwrap<HandleWrap>(args.This());
HandleWrap* wrap = Unwrap<HandleWrap>(args.Holder());

if (wrap != NULL && wrap->handle__ != NULL) {
uv_ref(wrap->handle__);
Expand All @@ -60,7 +60,7 @@ void HandleWrap::Unref(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());

HandleWrap* wrap = Unwrap<HandleWrap>(args.This());
HandleWrap* wrap = Unwrap<HandleWrap>(args.Holder());

if (wrap != NULL && wrap->handle__ != NULL) {
uv_unref(wrap->handle__);
Expand All @@ -73,7 +73,7 @@ void HandleWrap::Close(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());

HandleWrap* wrap = Unwrap<HandleWrap>(args.This());
HandleWrap* wrap = Unwrap<HandleWrap>(args.Holder());

// guard against uninitialized handle or double close
if (wrap == NULL || wrap->handle__ == NULL)
Expand Down
5 changes: 3 additions & 2 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@ inline void NODE_SET_PROTOTYPE_METHOD(v8::Handle<v8::FunctionTemplate> recv,
v8::FunctionCallback callback) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate,
callback);
v8::Handle<v8::Signature> s = v8::Signature::New(isolate, recv);
v8::Local<v8::FunctionTemplate> t =
v8::FunctionTemplate::New(isolate, callback, v8::Handle<v8::Value>(), s);
recv->PrototypeTemplate()->Set(v8::String::NewFromUtf8(isolate, name),
t->GetFunction());
}
Expand Down
2 changes: 1 addition & 1 deletion src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ class ContextifyScript : public BaseObject {
}

ContextifyScript* wrapped_script =
Unwrap<ContextifyScript>(args.This());
Unwrap<ContextifyScript>(args.Holder());
Local<Script> script = PersistentToLocal(env->isolate(),
wrapped_script->script_);

Expand Down
Loading