mirror of https://github.com/lukechilds/node.git
Browse Source
As per discussion in abi-stable-node: https://github.com/nodejs/abi-stable-node/issues/256, take a refactor to napi_addon_register_func such that the result from the register function is assigned to the module exports property. By making this change, native module can be agnostic about which type of module the environment supports. PR-URL: https://github.com/nodejs/node/pull/15088 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Hitesh Kanwathirtha <digitalinfinity@gmail.com>canary-base
committed by
Michael Dawson
37 changed files with 322 additions and 272 deletions
@ -1,7 +1,9 @@ |
|||
#include "myobject.h" |
|||
#include "../common.h" |
|||
|
|||
void Init(napi_env env, napi_value exports, napi_value module, void* priv) { |
|||
napi_value Init(napi_env env, napi_value exports) { |
|||
MyObject::Init(env, exports); |
|||
return exports; |
|||
} |
|||
|
|||
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) |
|||
|
@ -1,12 +1,10 @@ |
|||
#include <node_api.h> |
|||
#include "../common.h" |
|||
|
|||
void Init(napi_env env, napi_value exports, napi_value module, void* context) { |
|||
napi_value Init(napi_env env, napi_value exports) { |
|||
napi_value external; |
|||
NAPI_CALL_RETURN_VOID(env, |
|||
napi_create_external(env, env, NULL, NULL, &external)); |
|||
NAPI_CALL_RETURN_VOID(env, |
|||
napi_set_named_property(env, module, "exports", external)); |
|||
NAPI_CALL(env, napi_create_external(env, env, NULL, NULL, &external)); |
|||
return external; |
|||
} |
|||
|
|||
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) |
|||
|
Loading…
Reference in new issue