Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Commit fabac78

Browse files
committed
Use nan helpers to set exports
Fixes compilation errors when built on Node.js master with V8 7.4. `NAN_EXPORT()` requires the function name exported to JavaScript land and the exported C++ method to match. Change the exported C++ methods to begin with a lower case character to preserve the existing casing of the name exported to JavaScript. PR-URL: #125 Fixes: #116 Reviewed-By: Sam Roberts <[email protected]>
1 parent 0e87572 commit fabac78

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

src/module.cc

+15-22
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extern std::string commandline_string;
4747
* External JavaScript API for triggering a report
4848
*
4949
******************************************************************************/
50-
NAN_METHOD(TriggerReport) {
50+
NAN_METHOD(triggerReport) {
5151
Nan::HandleScope scope;
5252
v8::Isolate* isolate = info.GetIsolate();
5353
char filename[NR_MAXNAME + 1] = "";
@@ -81,7 +81,7 @@ NAN_METHOD(TriggerReport) {
8181
* External JavaScript API for returning a report
8282
*
8383
******************************************************************************/
84-
NAN_METHOD(GetReport) {
84+
NAN_METHOD(getReport) {
8585
Nan::HandleScope scope;
8686
v8::Isolate* isolate = info.GetIsolate();
8787
std::ostringstream out;
@@ -100,7 +100,7 @@ NAN_METHOD(GetReport) {
100100
* External JavaScript APIs for node-report configuration
101101
*
102102
******************************************************************************/
103-
NAN_METHOD(SetEvents) {
103+
NAN_METHOD(setEvents) {
104104
Nan::Utf8String parameter(info[0]);
105105
v8::Isolate* isolate = info.GetIsolate();
106106
unsigned int previous_events = nodereport_events; // save previous settings
@@ -132,7 +132,7 @@ NAN_METHOD(SetEvents) {
132132
}
133133
#endif
134134
}
135-
NAN_METHOD(SetSignal) {
135+
NAN_METHOD(setSignal) {
136136
#ifndef _WIN32
137137
Nan::Utf8String parameter(info[0]);
138138
unsigned int previous_signal = nodereport_signal; // save previous setting
@@ -145,15 +145,15 @@ NAN_METHOD(SetSignal) {
145145
}
146146
#endif
147147
}
148-
NAN_METHOD(SetFileName) {
148+
NAN_METHOD(setFileName) {
149149
Nan::Utf8String parameter(info[0]);
150150
ProcessNodeReportFileName(*parameter);
151151
}
152-
NAN_METHOD(SetDirectory) {
152+
NAN_METHOD(setDirectory) {
153153
Nan::Utf8String parameter(info[0]);
154154
ProcessNodeReportDirectory(*parameter);
155155
}
156-
NAN_METHOD(SetVerbose) {
156+
NAN_METHOD(setVerbose) {
157157
Nan::Utf8String parameter(info[0]);
158158
nodereport_verbose = ProcessNodeReportVerboseSwitch(*parameter);
159159
}
@@ -375,7 +375,7 @@ static void SetupSignalHandler() {
375375
* Native module initializer function, called when the module is require'd
376376
*
377377
******************************************************************************/
378-
void Initialize(v8::Local<v8::Object> exports) {
378+
NAN_MODULE_INIT(Initialize) {
379379
v8::Isolate* isolate = Isolate::GetCurrent();
380380
node_isolate = isolate;
381381

@@ -426,20 +426,13 @@ void Initialize(v8::Local<v8::Object> exports) {
426426
}
427427
#endif
428428

429-
exports->Set(Nan::New("triggerReport").ToLocalChecked(),
430-
Nan::New<v8::FunctionTemplate>(TriggerReport)->GetFunction());
431-
exports->Set(Nan::New("getReport").ToLocalChecked(),
432-
Nan::New<v8::FunctionTemplate>(GetReport)->GetFunction());
433-
exports->Set(Nan::New("setEvents").ToLocalChecked(),
434-
Nan::New<v8::FunctionTemplate>(SetEvents)->GetFunction());
435-
exports->Set(Nan::New("setSignal").ToLocalChecked(),
436-
Nan::New<v8::FunctionTemplate>(SetSignal)->GetFunction());
437-
exports->Set(Nan::New("setFileName").ToLocalChecked(),
438-
Nan::New<v8::FunctionTemplate>(SetFileName)->GetFunction());
439-
exports->Set(Nan::New("setDirectory").ToLocalChecked(),
440-
Nan::New<v8::FunctionTemplate>(SetDirectory)->GetFunction());
441-
exports->Set(Nan::New("setVerbose").ToLocalChecked(),
442-
Nan::New<v8::FunctionTemplate>(SetVerbose)->GetFunction());
429+
NAN_EXPORT(target, triggerReport);
430+
NAN_EXPORT(target, getReport);
431+
NAN_EXPORT(target, setEvents);
432+
NAN_EXPORT(target, setSignal);
433+
NAN_EXPORT(target, setFileName);
434+
NAN_EXPORT(target, setDirectory);
435+
NAN_EXPORT(target, setVerbose);
443436

444437
if (nodereport_verbose) {
445438
#ifdef _WIN32

0 commit comments

Comments
 (0)