diff --git a/Makefile b/Makefile index b1c267ed552..47eb7288ad3 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 2f7a196f65c..123d9116b35 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 7e35a4c9d6d..77836418d47 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 3be18daff1d..44bd2455749 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 3cc662c4076..0b3e2eb96cd 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 5b06517744d..8fd6090f22a 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 6cb3a9fa68b..c1f2aca1498 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 679f09fee9e..8c2bdac5bd5 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 c621c29f185..183332d3441 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 7ebe711a6dc..49b1241fb38 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 2807d6a1572..44c9c3f837b 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 b1dbd8eee49..5fb7a6670d7 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 f9096674a70..bb7c8aab182 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 5b3b7909582..1a3e6d10720 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 f85cc4cc97a..206d106e52c 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 00000000000..d4db4a3e58b --- /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 865d2064bde..00000000000 --- 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 25b26fb0913..fc6f4cb6c2e 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 6b7b50a38c9..5ba5aaffa62 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 feb6bd37d88..ba19b16e397 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 846755a97b7..a4515025fc2 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 84db32bf3ea..6ef04b4394a 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 c63c2f7fe29..2c61e0b217e 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 210417b47b1..0b827ff34d1 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 6f2a6e71b8d..2cd25823c92 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 019114f6465..d796a9dbf1c 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 92b03985513..c706170bac4 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 f1640c6638e..c286c3fd029 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 500962d5144..89b93ef0112 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 b8d641f5c0f..64235390812 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 c614a79818c..9f62b734c6a 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 a65a4e13872..6039d122c76 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 d5e9c778a9c..ef87d6da350 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 617ececb89f..46382427fe6 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 43e98921efa..f34798263db 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 4844346a139..e98a564a10f 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 053f048466d..84b991961ae 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 df70facefc0..7ea9400c351 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 107727872a0..02a2988dc3e 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 6a766dc5e40..577a506f7fa 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 b474ab442cb..0cd1c54ee14 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 842bd5af744..7959c47cb90 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 681cc04c4f4..832ce545d1f 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 5b2d4ff328b..0d55905e9e7 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 95d41ed5f64..5e33ddd75d4 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 f9cc6e83758..1afe797d140 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 d3fe5b0d2d9..4e2be97419c 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 fa65304ba54..c0a4cb62d98 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 c8d4733f580..b8169451e62 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 e681f98f73a..b81f5025846 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 eb5aa2071e3..eddf8051875 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 fd777daf5e0..de2802f8607 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 488ecea7853..eef4813aa63 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 adb6dd5ea15..ee38504eea7 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 d822d3628d8..567dd8c3a44 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 518fd21c37c..d8940028915 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 c17f27021b4..82c1f17d9dc 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 864846765d0..2d906dadae6 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 f491d237fde..0e0f91caf98 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 c2f55857d41..63fec1ae3b5 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 e4b79fe50f0..b2046e3b873 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 254531dfa92..c44a78d042f 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 a87b275c938..b14658298d5 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 0caf90049ca..d708d2d2493 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 9a2031d2566..240d024691e 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;