Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n-api,test: make methods static #20243

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/addons-napi/1_hello_world/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../common.h"
#include <string.h>

napi_value Method(napi_env env, napi_callback_info info) {
static napi_value Method(napi_env env, napi_callback_info info) {
napi_value world;
const char* str = "world";
size_t str_len = strlen(str);
Expand Down
4 changes: 2 additions & 2 deletions test/addons-napi/2_function_arguments/binding.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <node_api.h>
#include "../common.h"

napi_value Add(napi_env env, napi_callback_info info) {
static napi_value Add(napi_env env, napi_callback_info info) {
size_t argc = 2;
napi_value args[2];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand Down Expand Up @@ -29,7 +29,7 @@ napi_value Add(napi_env env, napi_callback_info info) {
return sum;
}

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor desc = DECLARE_NAPI_PROPERTY("add", Add);
NAPI_CALL(env, napi_define_properties(env, exports, 1, &desc));
return exports;
Expand Down
6 changes: 3 additions & 3 deletions test/addons-napi/3_callbacks/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../common.h"
#include <string.h>

napi_value RunCallback(napi_env env, napi_callback_info info) {
static napi_value RunCallback(napi_env env, napi_callback_info info) {
size_t argc = 2;
napi_value args[2];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand Down Expand Up @@ -34,7 +34,7 @@ napi_value RunCallback(napi_env env, napi_callback_info info) {
return NULL;
}

napi_value RunCallbackWithRecv(napi_env env, napi_callback_info info) {
static napi_value RunCallbackWithRecv(napi_env env, napi_callback_info info) {
size_t argc = 2;
napi_value args[2];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -45,7 +45,7 @@ napi_value RunCallbackWithRecv(napi_env env, napi_callback_info info) {
return NULL;
}

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor desc[2] = {
DECLARE_NAPI_PROPERTY("RunCallback", RunCallback),
DECLARE_NAPI_PROPERTY("RunCallbackWithRecv", RunCallbackWithRecv),
Expand Down
4 changes: 2 additions & 2 deletions test/addons-napi/4_object_factory/binding.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <node_api.h>
#include "../common.h"

napi_value CreateObject(napi_env env, napi_callback_info info) {
static napi_value CreateObject(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -14,7 +14,7 @@ napi_value CreateObject(napi_env env, napi_callback_info info) {
return obj;
}

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
NAPI_CALL(env,
napi_create_function(env, "exports", -1, CreateObject, NULL, &exports));
return exports;
Expand Down
6 changes: 3 additions & 3 deletions test/addons-napi/5_function_factory/binding.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#include <node_api.h>
#include "../common.h"

napi_value MyFunction(napi_env env, napi_callback_info info) {
static napi_value MyFunction(napi_env env, napi_callback_info info) {
napi_value str;
NAPI_CALL(env, napi_create_string_utf8(env, "hello world", -1, &str));
return str;
}

napi_value CreateFunction(napi_env env, napi_callback_info info) {
static napi_value CreateFunction(napi_env env, napi_callback_info info) {
napi_value fn;
NAPI_CALL(env,
napi_create_function(env, "theFunction", -1, MyFunction, NULL, &fn));
return fn;
}

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
NAPI_CALL(env,
napi_create_function(env, "exports", -1, CreateFunction, NULL, &exports));
return exports;
Expand Down
12 changes: 6 additions & 6 deletions test/addons-napi/test_array/test_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <string.h>
#include "../common.h"

napi_value TestGetElement(napi_env env, napi_callback_info info) {
static napi_value TestGetElement(napi_env env, napi_callback_info info) {
size_t argc = 2;
napi_value args[2];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand Down Expand Up @@ -45,7 +45,7 @@ napi_value TestGetElement(napi_env env, napi_callback_info info) {
return ret;
}

napi_value TestHasElement(napi_env env, napi_callback_info info) {
static napi_value TestHasElement(napi_env env, napi_callback_info info) {
size_t argc = 2;
napi_value args[2];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand Down Expand Up @@ -84,7 +84,7 @@ napi_value TestHasElement(napi_env env, napi_callback_info info) {
return ret;
}

napi_value TestDeleteElement(napi_env env, napi_callback_info info) {
static napi_value TestDeleteElement(napi_env env, napi_callback_info info) {
size_t argc = 2;
napi_value args[2];

Expand Down Expand Up @@ -119,7 +119,7 @@ napi_value TestDeleteElement(napi_env env, napi_callback_info info) {
return ret;
}

napi_value New(napi_env env, napi_callback_info info) {
static napi_value New(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand Down Expand Up @@ -147,7 +147,7 @@ napi_value New(napi_env env, napi_callback_info info) {
return ret;
}

napi_value NewWithLength(napi_env env, napi_callback_info info) {
static napi_value NewWithLength(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -169,7 +169,7 @@ napi_value NewWithLength(napi_env env, napi_callback_info info) {
return ret;
}

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor descriptors[] = {
DECLARE_NAPI_PROPERTY("TestGetElement", TestGetElement),
DECLARE_NAPI_PROPERTY("TestHasElement", TestHasElement),
Expand Down
16 changes: 8 additions & 8 deletions test/addons-napi/test_buffer/test_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static void noopDeleter(napi_env env, void* data, void* finalize_hint) {
deleterCallCount++;
}

napi_value newBuffer(napi_env env, napi_callback_info info) {
static napi_value newBuffer(napi_env env, napi_callback_info info) {
napi_value theBuffer;
char* theCopy;
const unsigned int kBufferSize = sizeof(theText);
Expand All @@ -37,7 +37,7 @@ napi_value newBuffer(napi_env env, napi_callback_info info) {
return theBuffer;
}

napi_value newExternalBuffer(napi_env env, napi_callback_info info) {
static napi_value newExternalBuffer(napi_env env, napi_callback_info info) {
napi_value theBuffer;
char* theCopy = strdup(theText);
NAPI_ASSERT(env, theCopy, "Failed to copy static text for newExternalBuffer");
Expand All @@ -53,20 +53,20 @@ napi_value newExternalBuffer(napi_env env, napi_callback_info info) {
return theBuffer;
}

napi_value getDeleterCallCount(napi_env env, napi_callback_info info) {
static napi_value getDeleterCallCount(napi_env env, napi_callback_info info) {
napi_value callCount;
NAPI_CALL(env, napi_create_int32(env, deleterCallCount, &callCount));
return callCount;
}

napi_value copyBuffer(napi_env env, napi_callback_info info) {
static napi_value copyBuffer(napi_env env, napi_callback_info info) {
napi_value theBuffer;
NAPI_CALL(env, napi_create_buffer_copy(
env, sizeof(theText), theText, NULL, &theBuffer));
return theBuffer;
}

napi_value bufferHasInstance(napi_env env, napi_callback_info info) {
static napi_value bufferHasInstance(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -85,7 +85,7 @@ napi_value bufferHasInstance(napi_env env, napi_callback_info info) {
return returnValue;
}

napi_value bufferInfo(napi_env env, napi_callback_info info) {
static napi_value bufferInfo(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -106,7 +106,7 @@ napi_value bufferInfo(napi_env env, napi_callback_info info) {
return returnValue;
}

napi_value staticBuffer(napi_env env, napi_callback_info info) {
static napi_value staticBuffer(napi_env env, napi_callback_info info) {
napi_value theBuffer;
NAPI_CALL(
env,
Expand All @@ -119,7 +119,7 @@ napi_value staticBuffer(napi_env env, napi_callback_info info) {
return theBuffer;
}

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
napi_value theValue;

NAPI_CALL(env,
Expand Down
12 changes: 6 additions & 6 deletions test/addons-napi/test_constructor/test_constructor.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
static double value_ = 1;
static double static_value_ = 10;

napi_value GetValue(napi_env env, napi_callback_info info) {
static napi_value GetValue(napi_env env, napi_callback_info info) {
size_t argc = 0;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, NULL, NULL, NULL));

Expand All @@ -16,7 +16,7 @@ napi_value GetValue(napi_env env, napi_callback_info info) {
return number;
}

napi_value SetValue(napi_env env, napi_callback_info info) {
static napi_value SetValue(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -28,7 +28,7 @@ napi_value SetValue(napi_env env, napi_callback_info info) {
return NULL;
}

napi_value Echo(napi_env env, napi_callback_info info) {
static napi_value Echo(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -38,14 +38,14 @@ napi_value Echo(napi_env env, napi_callback_info info) {
return args[0];
}

napi_value New(napi_env env, napi_callback_info info) {
static napi_value New(napi_env env, napi_callback_info info) {
napi_value _this;
NAPI_CALL(env, napi_get_cb_info(env, info, NULL, NULL, &_this, NULL));

return _this;
}

napi_value GetStaticValue(napi_env env, napi_callback_info info) {
static napi_value GetStaticValue(napi_env env, napi_callback_info info) {
size_t argc = 0;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, NULL, NULL, NULL));

Expand All @@ -58,7 +58,7 @@ napi_value GetStaticValue(napi_env env, napi_callback_info info) {
}


napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
napi_value number;
NAPI_CALL(env, napi_create_double(env, value_, &number));

Expand Down
4 changes: 2 additions & 2 deletions test/addons-napi/test_constructor/test_constructor_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

napi_ref constructor_;

napi_value New(napi_env env, napi_callback_info info) {
static napi_value New(napi_env env, napi_callback_info info) {
napi_value _this;
NAPI_CALL(env, napi_get_cb_info(env, info, NULL, NULL, &_this, NULL));

return _this;
}

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
napi_value cons;
NAPI_CALL(env, napi_define_class(
env, "MyObject_Extra", 8, New, NULL, 0, NULL, &cons));
Expand Down
22 changes: 11 additions & 11 deletions test/addons-napi/test_conversions/test_conversions.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <node_api.h>
#include "../common.h"

napi_value AsBool(napi_env env, napi_callback_info info) {
static napi_value AsBool(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -15,7 +15,7 @@ napi_value AsBool(napi_env env, napi_callback_info info) {
return output;
}

napi_value AsInt32(napi_env env, napi_callback_info info) {
static napi_value AsInt32(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -29,7 +29,7 @@ napi_value AsInt32(napi_env env, napi_callback_info info) {
return output;
}

napi_value AsUInt32(napi_env env, napi_callback_info info) {
static napi_value AsUInt32(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -43,7 +43,7 @@ napi_value AsUInt32(napi_env env, napi_callback_info info) {
return output;
}

napi_value AsInt64(napi_env env, napi_callback_info info) {
static napi_value AsInt64(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -57,7 +57,7 @@ napi_value AsInt64(napi_env env, napi_callback_info info) {
return output;
}

napi_value AsDouble(napi_env env, napi_callback_info info) {
static napi_value AsDouble(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -71,7 +71,7 @@ napi_value AsDouble(napi_env env, napi_callback_info info) {
return output;
}

napi_value AsString(napi_env env, napi_callback_info info) {
static napi_value AsString(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -87,7 +87,7 @@ napi_value AsString(napi_env env, napi_callback_info info) {
return output;
}

napi_value ToBool(napi_env env, napi_callback_info info) {
static napi_value ToBool(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -98,7 +98,7 @@ napi_value ToBool(napi_env env, napi_callback_info info) {
return output;
}

napi_value ToNumber(napi_env env, napi_callback_info info) {
static napi_value ToNumber(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -109,7 +109,7 @@ napi_value ToNumber(napi_env env, napi_callback_info info) {
return output;
}

napi_value ToObject(napi_env env, napi_callback_info info) {
static napi_value ToObject(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -120,7 +120,7 @@ napi_value ToObject(napi_env env, napi_callback_info info) {
return output;
}

napi_value ToString(napi_env env, napi_callback_info info) {
static napi_value ToString(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
Expand All @@ -131,7 +131,7 @@ napi_value ToString(napi_env env, napi_callback_info info) {
return output;
}

napi_value Init(napi_env env, napi_value exports) {
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor descriptors[] = {
DECLARE_NAPI_PROPERTY("asBool", AsBool),
DECLARE_NAPI_PROPERTY("asInt32", AsInt32),
Expand Down
Loading