Skip to content
Prev Previous commit
Next Next commit
Change the local casual macro to a more formal one.
  • Loading branch information
kenny-y committed Jul 4, 2018
commit 645f38e87553a43b5f56f692f7afc58c5b2654eb
40 changes: 20 additions & 20 deletions benchmark/napi/function_args/napi_binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,39 +189,39 @@ static napi_value CallWithArguments(napi_env env, napi_callback_info info) {
}


#define EXPORT_FUNC(name, func) \
#define EXPORT_FUNC(env, exports, name, func) \
do { \
napi_value func ## _v; \
status = napi_create_function(env, \
name, \
napi_status status; \
napi_value js_func; \
status = napi_create_function((env), \
(name), \
NAPI_AUTO_LENGTH, \
func, \
(func), \
NULL, \
&func ## _v); \
&js_func); \
assert(status == napi_ok); \
status = napi_set_named_property(env, exports, name, func ## _v); \
status = napi_set_named_property((env), \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Align arguments as with the previous call.

(exports), (name), js_func); \
assert(status == napi_ok); \
} while (0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The trailing backslashes must be aligned to the column of the outermost trailing backslash.



NAPI_MODULE_INIT() {
napi_status status;

EXPORT_FUNC("callWithString", CallWithString);
EXPORT_FUNC("callWithLongString", CallWithString);
EXPORT_FUNC(env, exports, "callWithString", CallWithString);
EXPORT_FUNC(env, exports, "callWithLongString", CallWithString);

EXPORT_FUNC("callWithArray", CallWithArray);
EXPORT_FUNC("callWithLargeArray", CallWithArray);
EXPORT_FUNC("callWithHugeArray", CallWithArray);
EXPORT_FUNC(env, exports, "callWithArray", CallWithArray);
EXPORT_FUNC(env, exports, "callWithLargeArray", CallWithArray);
EXPORT_FUNC(env, exports, "callWithHugeArray", CallWithArray);

EXPORT_FUNC("callWithNumber", CallWithNumber);
EXPORT_FUNC(env, exports, "callWithNumber", CallWithNumber);

EXPORT_FUNC("callWithObject", CallWithObject);
EXPORT_FUNC("callWithTypedarray", CallWithTypedarray);
EXPORT_FUNC(env, exports, "callWithObject", CallWithObject);
EXPORT_FUNC(env, exports, "callWithTypedarray", CallWithTypedarray);

EXPORT_FUNC("callWith10Numbers", CallWithArguments);
EXPORT_FUNC("callWith100Numbers", CallWithArguments);
EXPORT_FUNC("callWith1000Numbers", CallWithArguments);
EXPORT_FUNC(env, exports, "callWith10Numbers", CallWithArguments);
EXPORT_FUNC(env, exports, "callWith100Numbers", CallWithArguments);
EXPORT_FUNC(env, exports, "callWith1000Numbers", CallWithArguments);

return exports;
}