From a90951e9ea70fa1b3836af4b925322919159100e Mon Sep 17 00:00:00 2001 From: Benjamin Byholm Date: Wed, 27 Apr 2016 17:12:47 +0300 Subject: [PATCH] Don't use deprecated v8::Template::Set() in SetMethod --- doc/methods.md | 9 ++++++--- nan.h | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/doc/methods.md b/doc/methods.md index 90aa46a3..0411a705 100644 --- a/doc/methods.md +++ b/doc/methods.md @@ -474,9 +474,12 @@ Sets a method with a given name directly on a JavaScript object where the method Signature: ```c++ -template void Nan::SetMethod(const T &recv, - const char *name, - Nan::FunctionCallback callback) +void Nan::SetMethod(v8::Local recv, + const char *name, + Nan::FunctionCallback callback) +void Nan::SetMethod(v8::Local templ, + const char *name, + Nan::FunctionCallback callback) ``` diff --git a/nan.h b/nan.h index 27476350..66fe434e 100644 --- a/nan.h +++ b/nan.h @@ -1850,9 +1850,8 @@ NAN_INLINE void SetInstanceTemplate( SetTemplate(templ->InstanceTemplate(), name, value, attributes); } -template NAN_INLINE void SetMethod( - const T &recv + v8::Local recv , const char *name , FunctionCallback callback) { HandleScope scope; @@ -1863,6 +1862,17 @@ NAN_INLINE void SetMethod( recv->Set(fn_name, fn); } +NAN_INLINE void SetMethod( + v8::Local templ + , const char *name + , FunctionCallback callback) { + HandleScope scope; + v8::Local t = New(callback); + v8::Local fn_name = New(name).ToLocalChecked(); + t->SetClassName(fn_name); + templ->Set(fn_name, t); +} + NAN_INLINE void SetPrototypeMethod( v8::Local recv , const char* name, FunctionCallback callback) {