Skip to content

Commit

Permalink
Fix compilation on outdated versions due to Handle removal
Browse files Browse the repository at this point in the history
Fixes #562
  • Loading branch information
kkoopa committed Apr 27, 2016
1 parent d1d4600 commit f8b7c87
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -1850,6 +1850,41 @@ NAN_INLINE void SetInstanceTemplate(
SetTemplate(templ->InstanceTemplate(), name, value, attributes);
}

#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
NAN_INLINE void SetMethod(
v8::Handle<v8::Object> recv
, const char *name
, FunctionCallback callback) {
HandleScope scope;
v8::Local<v8::Function> fn = GetFunction(New<v8::FunctionTemplate>(
callback)).ToLocalChecked();
v8::Local<v8::String> fn_name = New(name).ToLocalChecked();
fn->SetName(fn_name);
recv->Set(fn_name, fn);
}

NAN_INLINE void SetMethod(
v8::Handle<v8::FunctionTemplate> templ
, const char *name
, FunctionCallback callback) {
HandleScope scope;
v8::Local<v8::FunctionTemplate> t = New<v8::FunctionTemplate>(callback);
v8::Local<v8::String> fn_name = New(name).ToLocalChecked();
t->SetClassName(fn_name);
templ->Set(fn_name, t);
}

NAN_INLINE void SetMethod(
v8::Handle<v8::ObjectTemplate> templ
, const char *name
, FunctionCallback callback) {
HandleScope scope;
v8::Local<v8::FunctionTemplate> t = New<v8::FunctionTemplate>(callback);
v8::Local<v8::String> fn_name = New(name).ToLocalChecked();
t->SetClassName(fn_name);
templ->Set(fn_name, t);
}
#else
NAN_INLINE void SetMethod(
v8::Local<v8::Object> recv
, const char *name
Expand Down Expand Up @@ -1883,6 +1918,7 @@ NAN_INLINE void SetMethod(
t->SetClassName(fn_name);
templ->Set(fn_name, t);
}
#endif

NAN_INLINE void SetPrototypeMethod(
v8::Local<v8::FunctionTemplate> recv
Expand Down

0 comments on commit f8b7c87

Please sign in to comment.