diff --git a/Makefile b/Makefile index b1c267ed55..47eb7288ad 100644 --- a/Makefile +++ b/Makefile @@ -1423,6 +1423,7 @@ FORMAT_CPP_FILES += $(LINT_CPP_FILES) # C source codes. FORMAT_CPP_FILES += $(wildcard \ benchmark/napi/*/*.c \ + test/js-native-api/*.h \ test/js-native-api/*/*.c \ test/js-native-api/*/*.h \ test/node-api/*/*.c \ diff --git a/test/js-native-api/2_function_arguments/2_function_arguments.c b/test/js-native-api/2_function_arguments/2_function_arguments.c index 2f7a196f65..123d9116b3 100644 --- a/test/js-native-api/2_function_arguments/2_function_arguments.c +++ b/test/js-native-api/2_function_arguments/2_function_arguments.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" static napi_value Add(napi_env env, napi_callback_info info) { size_t argc = 2; diff --git a/test/js-native-api/2_function_arguments/binding.gyp b/test/js-native-api/2_function_arguments/binding.gyp index 7e35a4c9d6..77836418d4 100644 --- a/test/js-native-api/2_function_arguments/binding.gyp +++ b/test/js-native-api/2_function_arguments/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "2_function_arguments", "sources": [ - "../entry_point.c", "2_function_arguments.c" ] } diff --git a/test/js-native-api/3_callbacks/3_callbacks.c b/test/js-native-api/3_callbacks/3_callbacks.c index 3be18daff1..44bd245574 100644 --- a/test/js-native-api/3_callbacks/3_callbacks.c +++ b/test/js-native-api/3_callbacks/3_callbacks.c @@ -1,6 +1,7 @@ #include -#include "../common.h" #include +#include "../common.h" +#include "../entry_point.h" static napi_value RunCallback(napi_env env, napi_callback_info info) { size_t argc = 2; diff --git a/test/js-native-api/3_callbacks/binding.gyp b/test/js-native-api/3_callbacks/binding.gyp index 3cc662c407..0b3e2eb96c 100644 --- a/test/js-native-api/3_callbacks/binding.gyp +++ b/test/js-native-api/3_callbacks/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "3_callbacks", "sources": [ - "../entry_point.c", "3_callbacks.c" ] } diff --git a/test/js-native-api/4_object_factory/4_object_factory.c b/test/js-native-api/4_object_factory/4_object_factory.c index 5b06517744..8fd6090f22 100644 --- a/test/js-native-api/4_object_factory/4_object_factory.c +++ b/test/js-native-api/4_object_factory/4_object_factory.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" static napi_value CreateObject(napi_env env, napi_callback_info info) { size_t argc = 1; diff --git a/test/js-native-api/4_object_factory/binding.gyp b/test/js-native-api/4_object_factory/binding.gyp index 6cb3a9fa68..c1f2aca149 100644 --- a/test/js-native-api/4_object_factory/binding.gyp +++ b/test/js-native-api/4_object_factory/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "4_object_factory", "sources": [ - "../entry_point.c", "4_object_factory.c" ] } diff --git a/test/js-native-api/5_function_factory/5_function_factory.c b/test/js-native-api/5_function_factory/5_function_factory.c index 679f09fee9..8c2bdac5bd 100644 --- a/test/js-native-api/5_function_factory/5_function_factory.c +++ b/test/js-native-api/5_function_factory/5_function_factory.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" static napi_value MyFunction(napi_env env, napi_callback_info info) { napi_value str; diff --git a/test/js-native-api/5_function_factory/binding.gyp b/test/js-native-api/5_function_factory/binding.gyp index c621c29f18..183332d344 100644 --- a/test/js-native-api/5_function_factory/binding.gyp +++ b/test/js-native-api/5_function_factory/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "5_function_factory", "sources": [ - "../entry_point.c", "5_function_factory.c" ] } diff --git a/test/js-native-api/6_object_wrap/6_object_wrap.cc b/test/js-native-api/6_object_wrap/6_object_wrap.cc index 7ebe711a6d..49b1241fb3 100644 --- a/test/js-native-api/6_object_wrap/6_object_wrap.cc +++ b/test/js-native-api/6_object_wrap/6_object_wrap.cc @@ -1,4 +1,5 @@ #include "../common.h" +#include "../entry_point.h" #include "assert.h" #include "myobject.h" diff --git a/test/js-native-api/6_object_wrap/binding.gyp b/test/js-native-api/6_object_wrap/binding.gyp index 2807d6a157..44c9c3f837 100644 --- a/test/js-native-api/6_object_wrap/binding.gyp +++ b/test/js-native-api/6_object_wrap/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "6_object_wrap", "sources": [ - "../entry_point.c", "6_object_wrap.cc" ] } diff --git a/test/js-native-api/7_factory_wrap/7_factory_wrap.cc b/test/js-native-api/7_factory_wrap/7_factory_wrap.cc index b1dbd8eee4..5fb7a6670d 100644 --- a/test/js-native-api/7_factory_wrap/7_factory_wrap.cc +++ b/test/js-native-api/7_factory_wrap/7_factory_wrap.cc @@ -1,6 +1,7 @@ #include -#include "myobject.h" #include "../common.h" +#include "../entry_point.h" +#include "myobject.h" napi_value CreateObject(napi_env env, napi_callback_info info) { size_t argc = 1; diff --git a/test/js-native-api/7_factory_wrap/binding.gyp b/test/js-native-api/7_factory_wrap/binding.gyp index f9096674a7..bb7c8aab18 100644 --- a/test/js-native-api/7_factory_wrap/binding.gyp +++ b/test/js-native-api/7_factory_wrap/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "7_factory_wrap", "sources": [ - "../entry_point.c", "7_factory_wrap.cc", "myobject.cc" ] diff --git a/test/js-native-api/8_passing_wrapped/8_passing_wrapped.cc b/test/js-native-api/8_passing_wrapped/8_passing_wrapped.cc index 5b3b790958..1a3e6d1072 100644 --- a/test/js-native-api/8_passing_wrapped/8_passing_wrapped.cc +++ b/test/js-native-api/8_passing_wrapped/8_passing_wrapped.cc @@ -1,6 +1,7 @@ #include -#include "myobject.h" #include "../common.h" +#include "../entry_point.h" +#include "myobject.h" extern size_t finalize_count; diff --git a/test/js-native-api/8_passing_wrapped/binding.gyp b/test/js-native-api/8_passing_wrapped/binding.gyp index f85cc4cc97..206d106e52 100644 --- a/test/js-native-api/8_passing_wrapped/binding.gyp +++ b/test/js-native-api/8_passing_wrapped/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "8_passing_wrapped", "sources": [ - "../entry_point.c", "8_passing_wrapped.cc", "myobject.cc" ] diff --git a/test/js-native-api/common-inl.h b/test/js-native-api/common-inl.h new file mode 100644 index 0000000000..d4db4a3e58 --- /dev/null +++ b/test/js-native-api/common-inl.h @@ -0,0 +1,56 @@ +#ifndef JS_NATIVE_API_COMMON_INL_H_ +#define JS_NATIVE_API_COMMON_INL_H_ + +#include +#include "common.h" + +#include + +inline void add_returned_status(napi_env env, + const char* key, + napi_value object, + char* expected_message, + napi_status expected_status, + napi_status actual_status) { + char napi_message_string[100] = ""; + napi_value prop_value; + + if (actual_status != expected_status) { + snprintf(napi_message_string, + sizeof(napi_message_string), + "Invalid status [%d]", + actual_status); + } + + NODE_API_CALL_RETURN_VOID( + env, + napi_create_string_utf8( + env, + (actual_status == expected_status ? expected_message + : napi_message_string), + NAPI_AUTO_LENGTH, + &prop_value)); + NODE_API_CALL_RETURN_VOID( + env, napi_set_named_property(env, object, key, prop_value)); +} + +inline void add_last_status(napi_env env, + const char* key, + napi_value return_value) { + napi_value prop_value; + const napi_extended_error_info* p_last_error; + NODE_API_CALL_RETURN_VOID(env, napi_get_last_error_info(env, &p_last_error)); + + NODE_API_CALL_RETURN_VOID( + env, + napi_create_string_utf8( + env, + (p_last_error->error_message == NULL ? "napi_ok" + : p_last_error->error_message), + NAPI_AUTO_LENGTH, + &prop_value)); + NODE_API_CALL_RETURN_VOID( + env, napi_set_named_property(env, return_value, key, prop_value)); +} + +#endif // JS_NATIVE_API_COMMON_INL_H_ diff --git a/test/js-native-api/common.c b/test/js-native-api/common.c deleted file mode 100644 index 865d2064bd..0000000000 --- a/test/js-native-api/common.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include "common.h" - -#include - -void add_returned_status(napi_env env, - const char* key, - napi_value object, - char* expected_message, - napi_status expected_status, - napi_status actual_status) { - - char napi_message_string[100] = ""; - napi_value prop_value; - - if (actual_status != expected_status) { - snprintf(napi_message_string, sizeof(napi_message_string), - "Invalid status [%d]", actual_status); - } - - NODE_API_CALL_RETURN_VOID(env, - napi_create_string_utf8( - env, - (actual_status == expected_status ? - expected_message : - napi_message_string), - NAPI_AUTO_LENGTH, - &prop_value)); - NODE_API_CALL_RETURN_VOID(env, - napi_set_named_property(env, object, key, prop_value)); -} - -void add_last_status(napi_env env, const char* key, napi_value return_value) { - napi_value prop_value; - const napi_extended_error_info* p_last_error; - NODE_API_CALL_RETURN_VOID(env, - napi_get_last_error_info(env, &p_last_error)); - - NODE_API_CALL_RETURN_VOID(env, - napi_create_string_utf8(env, - (p_last_error->error_message == NULL ? - "napi_ok" : - p_last_error->error_message), - NAPI_AUTO_LENGTH, - &prop_value)); - NODE_API_CALL_RETURN_VOID(env, - napi_set_named_property(env, return_value, key, prop_value)); -} diff --git a/test/js-native-api/common.h b/test/js-native-api/common.h index 25b26fb091..fc6f4cb6c2 100644 --- a/test/js-native-api/common.h +++ b/test/js-native-api/common.h @@ -1,3 +1,6 @@ +#ifndef JS_NATIVE_API_COMMON_H_ +#define JS_NATIVE_API_COMMON_H_ + #include // Empty value so that macros here are able to return NULL or void @@ -76,11 +79,17 @@ #define DECLARE_NODE_API_PROPERTY_VALUE(name, value) \ { (name), NULL, NULL, NULL, NULL, (value), napi_default, NULL } -void add_returned_status(napi_env env, - const char* key, - napi_value object, - char* expected_message, - napi_status expected_status, - napi_status actual_status); +static inline void add_returned_status(napi_env env, + const char* key, + napi_value object, + char* expected_message, + napi_status expected_status, + napi_status actual_status); -void add_last_status(napi_env env, const char* key, napi_value return_value); +static inline void add_last_status(napi_env env, + const char* key, + napi_value return_value); + +#include "common-inl.h" + +#endif // JS_NATIVE_API_COMMON_H_ diff --git a/test/js-native-api/entry_point.c b/test/js-native-api/entry_point.h similarity index 55% rename from test/js-native-api/entry_point.c rename to test/js-native-api/entry_point.h index 6b7b50a38c..5ba5aaffa6 100644 --- a/test/js-native-api/entry_point.c +++ b/test/js-native-api/entry_point.h @@ -1,3 +1,6 @@ +#ifndef JS_NATIVE_API_ENTRY_POINT_H_ +#define JS_NATIVE_API_ENTRY_POINT_H_ + #include EXTERN_C_START @@ -5,3 +8,5 @@ napi_value Init(napi_env env, napi_value exports); EXTERN_C_END NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) + +#endif // JS_NATIVE_API_ENTRY_POINT_H_ diff --git a/test/js-native-api/test_array/binding.gyp b/test/js-native-api/test_array/binding.gyp index feb6bd37d8..ba19b16e39 100644 --- a/test/js-native-api/test_array/binding.gyp +++ b/test/js-native-api/test_array/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_array", "sources": [ - "../entry_point.c", "test_array.c" ] } diff --git a/test/js-native-api/test_array/test_array.c b/test/js-native-api/test_array/test_array.c index 846755a97b..a4515025fc 100644 --- a/test/js-native-api/test_array/test_array.c +++ b/test/js-native-api/test_array/test_array.c @@ -1,6 +1,7 @@ #include #include #include "../common.h" +#include "../entry_point.h" static napi_value TestGetElement(napi_env env, napi_callback_info info) { size_t argc = 2; diff --git a/test/js-native-api/test_bigint/binding.gyp b/test/js-native-api/test_bigint/binding.gyp index 84db32bf3e..6ef04b4394 100644 --- a/test/js-native-api/test_bigint/binding.gyp +++ b/test/js-native-api/test_bigint/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_bigint", "sources": [ - "../entry_point.c", "test_bigint.c" ] } diff --git a/test/js-native-api/test_bigint/test_bigint.c b/test/js-native-api/test_bigint/test_bigint.c index c63c2f7fe2..2c61e0b217 100644 --- a/test/js-native-api/test_bigint/test_bigint.c +++ b/test/js-native-api/test_bigint/test_bigint.c @@ -1,8 +1,9 @@ -#include #include -#include #include +#include +#include #include "../common.h" +#include "../entry_point.h" static napi_value IsLossless(napi_env env, napi_callback_info info) { size_t argc = 2; diff --git a/test/js-native-api/test_cannot_run_js/binding.gyp b/test/js-native-api/test_cannot_run_js/binding.gyp index 210417b47b..0b827ff34d 100644 --- a/test/js-native-api/test_cannot_run_js/binding.gyp +++ b/test/js-native-api/test_cannot_run_js/binding.gyp @@ -1,32 +1,18 @@ { "targets": [ - { - "target_name": "copy_entry_point", - "type": "none", - "copies": [ - { - "destination": ".", - "files": [ "../entry_point.c" ] - } - ] - }, { "target_name": "test_cannot_run_js", "sources": [ - "entry_point.c", "test_cannot_run_js.c" ], "defines": [ "NAPI_EXPERIMENTAL" ], - "dependencies": [ "copy_entry_point" ], }, { "target_name": "test_pending_exception", "sources": [ - "entry_point.c", "test_cannot_run_js.c" ], "defines": [ "NAPI_VERSION=8" ], - "dependencies": [ "copy_entry_point" ], } ] } diff --git a/test/js-native-api/test_cannot_run_js/test_cannot_run_js.c b/test/js-native-api/test_cannot_run_js/test_cannot_run_js.c index 6f2a6e71b8..2cd25823c9 100644 --- a/test/js-native-api/test_cannot_run_js/test_cannot_run_js.c +++ b/test/js-native-api/test_cannot_run_js/test_cannot_run_js.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" #include "stdlib.h" static void Finalize(napi_env env, void* data, void* hint) { diff --git a/test/js-native-api/test_constructor/binding.gyp b/test/js-native-api/test_constructor/binding.gyp index 019114f646..d796a9dbf1 100644 --- a/test/js-native-api/test_constructor/binding.gyp +++ b/test/js-native-api/test_constructor/binding.gyp @@ -3,8 +3,6 @@ { "target_name": "test_constructor", "sources": [ - "../common.c", - "../entry_point.c", "test_constructor.c", "test_null.c", ] diff --git a/test/js-native-api/test_constructor/test_constructor.c b/test/js-native-api/test_constructor/test_constructor.c index 92b0398551..c706170bac 100644 --- a/test/js-native-api/test_constructor/test_constructor.c +++ b/test/js-native-api/test_constructor/test_constructor.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" #include "test_null.h" static double value_ = 1; diff --git a/test/js-native-api/test_conversions/binding.gyp b/test/js-native-api/test_conversions/binding.gyp index f1640c6638..c286c3fd02 100644 --- a/test/js-native-api/test_conversions/binding.gyp +++ b/test/js-native-api/test_conversions/binding.gyp @@ -3,8 +3,6 @@ { "target_name": "test_conversions", "sources": [ - "../entry_point.c", - "../common.c", "test_conversions.c", "test_null.c", ] diff --git a/test/js-native-api/test_conversions/test_conversions.c b/test/js-native-api/test_conversions/test_conversions.c index 500962d514..89b93ef011 100644 --- a/test/js-native-api/test_conversions/test_conversions.c +++ b/test/js-native-api/test_conversions/test_conversions.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" #include "test_null.h" static napi_value AsBool(napi_env env, napi_callback_info info) { diff --git a/test/js-native-api/test_dataview/binding.gyp b/test/js-native-api/test_dataview/binding.gyp index b8d641f5c0..6423539081 100644 --- a/test/js-native-api/test_dataview/binding.gyp +++ b/test/js-native-api/test_dataview/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_dataview", "sources": [ - "../entry_point.c", "test_dataview.c" ] } diff --git a/test/js-native-api/test_dataview/test_dataview.c b/test/js-native-api/test_dataview/test_dataview.c index c614a79818..9f62b734c6 100644 --- a/test/js-native-api/test_dataview/test_dataview.c +++ b/test/js-native-api/test_dataview/test_dataview.c @@ -1,6 +1,7 @@ #include #include #include "../common.h" +#include "../entry_point.h" static napi_value CreateDataView(napi_env env, napi_callback_info info) { size_t argc = 3; diff --git a/test/js-native-api/test_date/binding.gyp b/test/js-native-api/test_date/binding.gyp index a65a4e1387..6039d122c7 100644 --- a/test/js-native-api/test_date/binding.gyp +++ b/test/js-native-api/test_date/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_date", "sources": [ - "../entry_point.c", "test_date.c" ] } diff --git a/test/js-native-api/test_date/test_date.c b/test/js-native-api/test_date/test_date.c index d5e9c778a9..ef87d6da35 100644 --- a/test/js-native-api/test_date/test_date.c +++ b/test/js-native-api/test_date/test_date.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" static napi_value createDate(napi_env env, napi_callback_info info) { size_t argc = 1; diff --git a/test/js-native-api/test_error/binding.gyp b/test/js-native-api/test_error/binding.gyp index 617ececb89..46382427fe 100644 --- a/test/js-native-api/test_error/binding.gyp +++ b/test/js-native-api/test_error/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_error", "sources": [ - "../entry_point.c", "test_error.c" ] } diff --git a/test/js-native-api/test_error/test_error.c b/test/js-native-api/test_error/test_error.c index 43e98921ef..f34798263d 100644 --- a/test/js-native-api/test_error/test_error.c +++ b/test/js-native-api/test_error/test_error.c @@ -1,6 +1,7 @@ #define NAPI_VERSION 9 #include #include "../common.h" +#include "../entry_point.h" static napi_value checkError(napi_env env, napi_callback_info info) { size_t argc = 1; diff --git a/test/js-native-api/test_exception/binding.gyp b/test/js-native-api/test_exception/binding.gyp index 4844346a13..e98a564a10 100644 --- a/test/js-native-api/test_exception/binding.gyp +++ b/test/js-native-api/test_exception/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_exception", "sources": [ - "../entry_point.c", "test_exception.c" ] } diff --git a/test/js-native-api/test_exception/test_exception.c b/test/js-native-api/test_exception/test_exception.c index 053f048466..84b991961a 100644 --- a/test/js-native-api/test_exception/test_exception.c +++ b/test/js-native-api/test_exception/test_exception.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" static bool exceptionWasPending = false; static int num = 0x23432; diff --git a/test/js-native-api/test_function/binding.gyp b/test/js-native-api/test_function/binding.gyp index df70facefc..7ea9400c35 100644 --- a/test/js-native-api/test_function/binding.gyp +++ b/test/js-native-api/test_function/binding.gyp @@ -3,8 +3,6 @@ { "target_name": "test_function", "sources": [ - "../common.c", - "../entry_point.c", "test_function.c" ] } diff --git a/test/js-native-api/test_function/test_function.c b/test/js-native-api/test_function/test_function.c index 107727872a..02a2988dc3 100644 --- a/test/js-native-api/test_function/test_function.c +++ b/test/js-native-api/test_function/test_function.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" static napi_value TestCreateFunctionParameters(napi_env env, napi_callback_info info) { diff --git a/test/js-native-api/test_general/binding.gyp b/test/js-native-api/test_general/binding.gyp index 6a766dc5e4..577a506f7f 100644 --- a/test/js-native-api/test_general/binding.gyp +++ b/test/js-native-api/test_general/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_general", "sources": [ - "../entry_point.c", "test_general.c" ] } diff --git a/test/js-native-api/test_general/test_general.c b/test/js-native-api/test_general/test_general.c index b474ab442c..0cd1c54ee1 100644 --- a/test/js-native-api/test_general/test_general.c +++ b/test/js-native-api/test_general/test_general.c @@ -3,11 +3,12 @@ // not related to any of the other tests // defined in the file #define NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED +#include +#include #include #include -#include -#include #include "../common.h" +#include "../entry_point.h" static napi_value testStrictEquals(napi_env env, napi_callback_info info) { size_t argc = 2; diff --git a/test/js-native-api/test_handle_scope/binding.gyp b/test/js-native-api/test_handle_scope/binding.gyp index 842bd5af74..7959c47cb9 100644 --- a/test/js-native-api/test_handle_scope/binding.gyp +++ b/test/js-native-api/test_handle_scope/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_handle_scope", "sources": [ - "../entry_point.c", "test_handle_scope.c" ] } diff --git a/test/js-native-api/test_handle_scope/test_handle_scope.c b/test/js-native-api/test_handle_scope/test_handle_scope.c index 681cc04c4f..832ce545d1 100644 --- a/test/js-native-api/test_handle_scope/test_handle_scope.c +++ b/test/js-native-api/test_handle_scope/test_handle_scope.c @@ -1,6 +1,7 @@ #include -#include "../common.h" #include +#include "../common.h" +#include "../entry_point.h" // these tests validate the handle scope functions in the normal // flow. Forcing gc behavior to fully validate they are doing diff --git a/test/js-native-api/test_instance_data/binding.gyp b/test/js-native-api/test_instance_data/binding.gyp index 5b2d4ff328..0d55905e9e 100644 --- a/test/js-native-api/test_instance_data/binding.gyp +++ b/test/js-native-api/test_instance_data/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_instance_data", "sources": [ - "../entry_point.c", "test_instance_data.c" ] } diff --git a/test/js-native-api/test_instance_data/test_instance_data.c b/test/js-native-api/test_instance_data/test_instance_data.c index 95d41ed5f6..5e33ddd75d 100644 --- a/test/js-native-api/test_instance_data/test_instance_data.c +++ b/test/js-native-api/test_instance_data/test_instance_data.c @@ -1,7 +1,8 @@ +#include #include #include -#include #include "../common.h" +#include "../entry_point.h" typedef struct { size_t value; diff --git a/test/js-native-api/test_new_target/binding.gyp b/test/js-native-api/test_new_target/binding.gyp index f9cc6e8375..1afe797d14 100644 --- a/test/js-native-api/test_new_target/binding.gyp +++ b/test/js-native-api/test_new_target/binding.gyp @@ -4,7 +4,6 @@ 'target_name': 'test_new_target', 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], 'sources': [ - '../entry_point.c', 'test_new_target.c' ] } diff --git a/test/js-native-api/test_new_target/test_new_target.c b/test/js-native-api/test_new_target/test_new_target.c index d3fe5b0d2d..4e2be97419 100644 --- a/test/js-native-api/test_new_target/test_new_target.c +++ b/test/js-native-api/test_new_target/test_new_target.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" static napi_value BaseClass(napi_env env, napi_callback_info info) { napi_value newTargetArg; diff --git a/test/js-native-api/test_number/binding.gyp b/test/js-native-api/test_number/binding.gyp index fa65304ba5..c0a4cb62d9 100644 --- a/test/js-native-api/test_number/binding.gyp +++ b/test/js-native-api/test_number/binding.gyp @@ -3,8 +3,6 @@ { "target_name": "test_number", "sources": [ - "../common.c", - "../entry_point.c", "test_number.c", "test_null.c", ] diff --git a/test/js-native-api/test_number/test_number.c b/test/js-native-api/test_number/test_number.c index c8d4733f58..b8169451e6 100644 --- a/test/js-native-api/test_number/test_number.c +++ b/test/js-native-api/test_number/test_number.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" #include "test_null.h" static napi_value Test(napi_env env, napi_callback_info info) { diff --git a/test/js-native-api/test_object/binding.gyp b/test/js-native-api/test_object/binding.gyp index e681f98f73..b81f502584 100644 --- a/test/js-native-api/test_object/binding.gyp +++ b/test/js-native-api/test_object/binding.gyp @@ -3,8 +3,6 @@ { "target_name": "test_object", "sources": [ - "../common.c", - "../entry_point.c", "test_null.c", "test_object.c" ] diff --git a/test/js-native-api/test_object/test_object.c b/test/js-native-api/test_object/test_object.c index eb5aa2071e..eddf805187 100644 --- a/test/js-native-api/test_object/test_object.c +++ b/test/js-native-api/test_object/test_object.c @@ -1,6 +1,7 @@ #include -#include "../common.h" #include +#include "../common.h" +#include "../entry_point.h" #include "test_null.h" static int test_value = 3; diff --git a/test/js-native-api/test_promise/binding.gyp b/test/js-native-api/test_promise/binding.gyp index fd777daf5e..de2802f860 100644 --- a/test/js-native-api/test_promise/binding.gyp +++ b/test/js-native-api/test_promise/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_promise", "sources": [ - "../entry_point.c", "test_promise.c" ] } diff --git a/test/js-native-api/test_promise/test_promise.c b/test/js-native-api/test_promise/test_promise.c index 488ecea785..eef4813aa6 100644 --- a/test/js-native-api/test_promise/test_promise.c +++ b/test/js-native-api/test_promise/test_promise.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" napi_deferred deferred = NULL; diff --git a/test/js-native-api/test_properties/binding.gyp b/test/js-native-api/test_properties/binding.gyp index adb6dd5ea1..ee38504eea 100644 --- a/test/js-native-api/test_properties/binding.gyp +++ b/test/js-native-api/test_properties/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_properties", "sources": [ - "../entry_point.c", "test_properties.c" ] } diff --git a/test/js-native-api/test_properties/test_properties.c b/test/js-native-api/test_properties/test_properties.c index d822d3628d..567dd8c3a4 100644 --- a/test/js-native-api/test_properties/test_properties.c +++ b/test/js-native-api/test_properties/test_properties.c @@ -1,6 +1,7 @@ #define NAPI_VERSION 9 #include #include "../common.h" +#include "../entry_point.h" static double value_ = 1; diff --git a/test/js-native-api/test_reference/binding.gyp b/test/js-native-api/test_reference/binding.gyp index 518fd21c37..d894002891 100644 --- a/test/js-native-api/test_reference/binding.gyp +++ b/test/js-native-api/test_reference/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_reference", "sources": [ - "../entry_point.c", "test_reference.c" ] } diff --git a/test/js-native-api/test_reference/test_reference.c b/test/js-native-api/test_reference/test_reference.c index c17f27021b..82c1f17d9d 100644 --- a/test/js-native-api/test_reference/test_reference.c +++ b/test/js-native-api/test_reference/test_reference.c @@ -1,8 +1,9 @@ #define NAPI_VERSION 9 -#include #include #include +#include #include "../common.h" +#include "../entry_point.h" static int test_value = 1; static int finalize_count = 0; @@ -51,40 +52,44 @@ static napi_value CreateExternal(napi_env env, napi_callback_info info) { } static napi_value CreateSymbol(napi_env env, napi_callback_info info) { - - size_t argc = 1; - napi_value args[1]; - - NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL,NULL)); - NODE_API_ASSERT(env, argc == 1, "Expect one argument only (symbol description)"); - - napi_value result_symbol; - - NODE_API_CALL(env, napi_create_symbol(env, args[0], &result_symbol)); - return result_symbol; + size_t argc = 1; + napi_value args[1]; + + NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); + NODE_API_ASSERT( + env, argc == 1, "Expect one argument only (symbol description)"); + + napi_value result_symbol; + + NODE_API_CALL(env, napi_create_symbol(env, args[0], &result_symbol)); + return result_symbol; } static napi_value CreateSymbolFor(napi_env env, napi_callback_info info) { - - size_t argc = 1; - napi_value args[1]; - - char description[256]; - size_t description_length; - - NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL,NULL)); - NODE_API_ASSERT(env, argc == 1, "Expect one argument only (symbol description)"); + size_t argc = 1; + napi_value args[1]; - NODE_API_CALL(env, napi_get_value_string_utf8(env, args[0], description, sizeof(description), &description_length)); - NODE_API_ASSERT(env, description_length <= 255, "Cannot accommodate descriptions longer than 255 bytes"); - - napi_value result_symbol; - - NODE_API_CALL(env, node_api_symbol_for(env, - description, - description_length, - &result_symbol)); - return result_symbol; + char description[256]; + size_t description_length; + + NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); + NODE_API_ASSERT( + env, argc == 1, "Expect one argument only (symbol description)"); + + NODE_API_CALL( + env, + napi_get_value_string_utf8( + env, args[0], description, sizeof(description), &description_length)); + NODE_API_ASSERT(env, + description_length <= 255, + "Cannot accommodate descriptions longer than 255 bytes"); + + napi_value result_symbol; + + NODE_API_CALL(env, + node_api_symbol_for( + env, description, description_length, &result_symbol)); + return result_symbol; } static napi_value CreateSymbolForEmptyString(napi_env env, napi_callback_info info) { diff --git a/test/js-native-api/test_reference_double_free/binding.gyp b/test/js-native-api/test_reference_double_free/binding.gyp index 864846765d..2d906dadae 100644 --- a/test/js-native-api/test_reference_double_free/binding.gyp +++ b/test/js-native-api/test_reference_double_free/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_reference_double_free", "sources": [ - "../entry_point.c", "test_reference_double_free.c" ] } diff --git a/test/js-native-api/test_reference_double_free/test_reference_double_free.c b/test/js-native-api/test_reference_double_free/test_reference_double_free.c index f491d237fd..0e0f91caf9 100644 --- a/test/js-native-api/test_reference_double_free/test_reference_double_free.c +++ b/test/js-native-api/test_reference_double_free/test_reference_double_free.c @@ -1,6 +1,7 @@ -#include #include +#include #include "../common.h" +#include "../entry_point.h" static size_t g_call_count = 0; diff --git a/test/js-native-api/test_string/binding.gyp b/test/js-native-api/test_string/binding.gyp index c2f55857d4..63fec1ae3b 100644 --- a/test/js-native-api/test_string/binding.gyp +++ b/test/js-native-api/test_string/binding.gyp @@ -3,10 +3,8 @@ { "target_name": "test_string", "sources": [ - "../entry_point.c", "test_string.c", "test_null.c", - "../common.c", ] } ] diff --git a/test/js-native-api/test_string/test_string.c b/test/js-native-api/test_string/test_string.c index e4b79fe50f..b2046e3b87 100644 --- a/test/js-native-api/test_string/test_string.c +++ b/test/js-native-api/test_string/test_string.c @@ -4,6 +4,7 @@ #define NAPI_EXPERIMENTAL #include #include "../common.h" +#include "../entry_point.h" #include "test_null.h" enum length_type { actual_length, auto_length }; diff --git a/test/js-native-api/test_symbol/binding.gyp b/test/js-native-api/test_symbol/binding.gyp index 254531dfa9..c44a78d042 100644 --- a/test/js-native-api/test_symbol/binding.gyp +++ b/test/js-native-api/test_symbol/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_symbol", "sources": [ - "../entry_point.c", "test_symbol.c" ] } diff --git a/test/js-native-api/test_symbol/test_symbol.c b/test/js-native-api/test_symbol/test_symbol.c index a87b275c93..b14658298d 100644 --- a/test/js-native-api/test_symbol/test_symbol.c +++ b/test/js-native-api/test_symbol/test_symbol.c @@ -1,5 +1,6 @@ #include #include "../common.h" +#include "../entry_point.h" static napi_value New(napi_env env, napi_callback_info info) { size_t argc = 1; diff --git a/test/js-native-api/test_typedarray/binding.gyp b/test/js-native-api/test_typedarray/binding.gyp index 0caf90049c..d708d2d249 100644 --- a/test/js-native-api/test_typedarray/binding.gyp +++ b/test/js-native-api/test_typedarray/binding.gyp @@ -3,7 +3,6 @@ { "target_name": "test_typedarray", "sources": [ - "../entry_point.c", "test_typedarray.c" ] } diff --git a/test/js-native-api/test_typedarray/test_typedarray.c b/test/js-native-api/test_typedarray/test_typedarray.c index 9a2031d256..240d024691 100644 --- a/test/js-native-api/test_typedarray/test_typedarray.c +++ b/test/js-native-api/test_typedarray/test_typedarray.c @@ -1,7 +1,8 @@ #include -#include #include +#include #include "../common.h" +#include "../entry_point.h" static napi_value Multiply(napi_env env, napi_callback_info info) { size_t argc = 2;