koffi 2.3.4 → 2.3.6-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -2
- package/doc/changelog.md +4 -0
- package/doc/index.rst +1 -2
- package/doc/types.md +3 -3
- package/package.json +5 -5
- package/src/cnoke/cnoke.js +40 -834
- package/src/cnoke/package.json +1 -0
- package/src/cnoke/src/builder.js +447 -0
- package/src/cnoke/src/index.js +20 -0
- package/src/cnoke/src/tools.js +401 -0
- package/src/core/libcc/libcc.cc +2 -2
- package/src/koffi/build/2.3.6-beta.1/koffi_darwin_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_darwin_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_freebsd_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_freebsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_freebsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_linux_arm32hf/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_linux_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_linux_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_linux_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_openbsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_openbsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.exp +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.lib +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_arm64/koffi.pdb +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.exp +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.lib +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_ia32/koffi.pdb +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.exp +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.lib +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.1/koffi_win32_x64/koffi.pdb +0 -0
- package/src/koffi/src/abi_arm32.cc +43 -14
- package/src/koffi/src/abi_arm64.cc +95 -21
- package/src/koffi/src/abi_riscv64.cc +125 -64
- package/src/koffi/src/abi_x64_sysv.cc +38 -20
- package/src/koffi/src/abi_x64_win.cc +11 -5
- package/src/koffi/src/abi_x86.cc +14 -7
- package/src/koffi/src/call.cc +114 -44
- package/src/koffi/src/call.hh +6 -4
- package/src/koffi/src/ffi.cc +172 -147
- package/src/koffi/src/ffi.hh +18 -10
- package/src/koffi/src/index.d.ts +28 -7
- package/src/koffi/src/index.js +23 -4
- package/src/koffi/src/util.cc +261 -69
- package/src/koffi/src/util.hh +34 -8
- package/vendor/node-addon-api/CHANGELOG.md +122 -9
- package/vendor/node-addon-api/CONTRIBUTING.md +10 -10
- package/vendor/node-addon-api/README.md +36 -12
- package/vendor/node-addon-api/benchmark/function_args.cc +95 -62
- package/vendor/node-addon-api/benchmark/function_args.js +6 -6
- package/vendor/node-addon-api/benchmark/index.js +1 -1
- package/vendor/node-addon-api/benchmark/property_descriptor.cc +27 -34
- package/vendor/node-addon-api/benchmark/property_descriptor.js +5 -4
- package/vendor/node-addon-api/doc/async_operations.md +1 -1
- package/vendor/node-addon-api/doc/async_worker_variants.md +23 -2
- package/vendor/node-addon-api/doc/cmake-js.md +1 -1
- package/vendor/node-addon-api/doc/error_handling.md +3 -3
- package/vendor/node-addon-api/doc/external.md +7 -0
- package/vendor/node-addon-api/doc/handle_scope.md +14 -0
- package/vendor/node-addon-api/doc/hierarchy.md +1 -1
- package/vendor/node-addon-api/doc/object.md +27 -0
- package/vendor/node-addon-api/index.js +3 -3
- package/vendor/node-addon-api/napi-inl.deprecated.h +121 -127
- package/vendor/node-addon-api/napi-inl.h +1178 -1144
- package/vendor/node-addon-api/napi.h +2786 -2675
- package/vendor/node-addon-api/package.json +42 -1
- package/vendor/node-addon-api/test/addon.cc +8 -6
- package/vendor/node-addon-api/test/addon_build/index.js +9 -9
- package/vendor/node-addon-api/test/addon_build/tpl/addon.cc +2 -1
- package/vendor/node-addon-api/test/addon_build/tpl/index.js +4 -4
- package/vendor/node-addon-api/test/addon_data.cc +12 -13
- package/vendor/node-addon-api/test/array_buffer.js +3 -2
- package/vendor/node-addon-api/test/async_progress_queue_worker.cc +13 -3
- package/vendor/node-addon-api/test/async_progress_queue_worker.js +5 -5
- package/vendor/node-addon-api/test/async_progress_worker.cc +65 -9
- package/vendor/node-addon-api/test/async_progress_worker.js +14 -9
- package/vendor/node-addon-api/test/async_worker.cc +236 -3
- package/vendor/node-addon-api/test/async_worker.js +122 -37
- package/vendor/node-addon-api/test/async_worker_nocallback.js +9 -3
- package/vendor/node-addon-api/test/async_worker_persistent.js +2 -2
- package/vendor/node-addon-api/test/basic_types/array.js +3 -4
- package/vendor/node-addon-api/test/basic_types/boolean.cc +4 -2
- package/vendor/node-addon-api/test/basic_types/boolean.js +1 -2
- package/vendor/node-addon-api/test/basic_types/number.cc +12 -6
- package/vendor/node-addon-api/test/basic_types/number.js +19 -18
- package/vendor/node-addon-api/test/basic_types/value.cc +52 -1
- package/vendor/node-addon-api/test/basic_types/value.js +44 -21
- package/vendor/node-addon-api/test/bigint.cc +2 -1
- package/vendor/node-addon-api/test/binding.cc +11 -5
- package/vendor/node-addon-api/test/binding.gyp +3 -1
- package/vendor/node-addon-api/test/buffer.cc +46 -38
- package/vendor/node-addon-api/test/buffer.js +12 -12
- package/vendor/node-addon-api/test/callbackInfo.cc +27 -0
- package/vendor/node-addon-api/test/callbackInfo.js +9 -0
- package/vendor/node-addon-api/test/callbackscope.cc +19 -2
- package/vendor/node-addon-api/test/callbackscope.js +20 -20
- package/vendor/node-addon-api/test/common/index.js +37 -4
- package/vendor/node-addon-api/test/dataview/dataview.js +5 -5
- package/vendor/node-addon-api/test/dataview/dataview_read_write.js +14 -12
- package/vendor/node-addon-api/test/date.cc +2 -1
- package/vendor/node-addon-api/test/date.js +2 -2
- package/vendor/node-addon-api/test/env_cleanup.cc +12 -0
- package/vendor/node-addon-api/test/env_cleanup.js +38 -39
- package/vendor/node-addon-api/test/error.cc +6 -5
- package/vendor/node-addon-api/test/error_terminating_environment.js +64 -60
- package/vendor/node-addon-api/test/external.cc +36 -32
- package/vendor/node-addon-api/test/external.js +43 -46
- package/vendor/node-addon-api/test/function.cc +58 -44
- package/vendor/node-addon-api/test/function.js +4 -0
- package/vendor/node-addon-api/test/function_reference.cc +15 -13
- package/vendor/node-addon-api/test/globalObject/global_object_delete_property.js +50 -53
- package/vendor/node-addon-api/test/globalObject/global_object_get_property.js +33 -34
- package/vendor/node-addon-api/test/globalObject/global_object_has_own_property.js +38 -40
- package/vendor/node-addon-api/test/globalObject/global_object_set_property.js +47 -49
- package/vendor/node-addon-api/test/handlescope.cc +29 -3
- package/vendor/node-addon-api/test/handlescope.js +5 -3
- package/vendor/node-addon-api/test/index.js +1 -5
- package/vendor/node-addon-api/test/maybe/check.cc +49 -3
- package/vendor/node-addon-api/test/maybe/index.js +19 -7
- package/vendor/node-addon-api/test/memory_management.cc +9 -8
- package/vendor/node-addon-api/test/memory_management.js +2 -2
- package/vendor/node-addon-api/test/movable_callbacks.js +2 -2
- package/vendor/node-addon-api/test/name.js +3 -3
- package/vendor/node-addon-api/test/napi_child.js +2 -2
- package/vendor/node-addon-api/test/object/delete_property.js +7 -7
- package/vendor/node-addon-api/test/object/finalizer.cc +13 -12
- package/vendor/node-addon-api/test/object/finalizer.js +2 -2
- package/vendor/node-addon-api/test/object/get_property.js +6 -6
- package/vendor/node-addon-api/test/object/has_own_property.js +3 -3
- package/vendor/node-addon-api/test/object/has_property.js +4 -4
- package/vendor/node-addon-api/test/object/object.cc +191 -111
- package/vendor/node-addon-api/test/object/object.js +53 -52
- package/vendor/node-addon-api/test/object/object_deprecated.cc +24 -20
- package/vendor/node-addon-api/test/object/object_deprecated.js +3 -8
- package/vendor/node-addon-api/test/object/object_freeze_seal.js +54 -54
- package/vendor/node-addon-api/test/object/object_type_tag.cc +39 -0
- package/vendor/node-addon-api/test/object/object_type_tag.js +55 -0
- package/vendor/node-addon-api/test/object/subscript_operator.js +2 -2
- package/vendor/node-addon-api/test/object_reference.js +100 -100
- package/vendor/node-addon-api/test/objectwrap.cc +41 -34
- package/vendor/node-addon-api/test/objectwrap.js +23 -19
- package/vendor/node-addon-api/test/objectwrap_constructor_exception.cc +5 -5
- package/vendor/node-addon-api/test/objectwrap_constructor_exception.js +1 -1
- package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.cc +7 -7
- package/vendor/node-addon-api/test/objectwrap_multiple_inheritance.js +1 -1
- package/vendor/node-addon-api/test/objectwrap_removewrap.js +24 -32
- package/vendor/node-addon-api/test/objectwrap_worker_thread.js +5 -4
- package/vendor/node-addon-api/test/promise.cc +7 -0
- package/vendor/node-addon-api/test/promise.js +3 -1
- package/vendor/node-addon-api/test/reference.cc +1 -1
- package/vendor/node-addon-api/test/reference.js +2 -2
- package/vendor/node-addon-api/test/run_script.cc +1 -1
- package/vendor/node-addon-api/test/symbol.js +59 -66
- package/vendor/node-addon-api/test/testUtil.js +6 -6
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.cc +64 -29
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function.js +71 -34
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.cc +111 -19
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ctx.js +2 -1
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.cc +36 -26
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_existing_tsfn.js +5 -5
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.cc +3 -2
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_ptr.js +1 -1
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.cc +47 -32
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_sum.js +3 -3
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.cc +22 -9
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_unref.js +76 -31
- package/vendor/node-addon-api/test/thunking_manual.cc +61 -74
- package/vendor/node-addon-api/test/thunking_manual.js +6 -7
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.cc +20 -20
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function.js +19 -19
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.cc +57 -5
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ctx.js +2 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_existing_tsfn.js +5 -5
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.cc +5 -1
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_ptr.js +4 -3
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_sum.js +3 -3
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.cc +14 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_unref.js +76 -31
- package/vendor/node-addon-api/test/typedarray-bigint.js +2 -2
- package/vendor/node-addon-api/test/typedarray.cc +263 -70
- package/vendor/node-addon-api/test/typedarray.js +44 -10
- package/vendor/node-addon-api/test/version_management.cc +16 -15
- package/vendor/node-addon-api/test/version_management.js +18 -20
- package/vendor/node-addon-api/tools/check-napi.js +13 -14
- package/vendor/node-addon-api/tools/conversion.js +161 -169
- package/vendor/node-addon-api/tools/eslint-format.js +9 -1
- package/vendor/node-addon-api/unit-test/README.md +4 -4
- package/src/koffi/build/2.3.4/koffi_darwin_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_darwin_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_freebsd_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_freebsd_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_freebsd_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_linux_arm32hf.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_linux_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_linux_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_linux_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_openbsd_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_openbsd_x64.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_win32_arm64.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_win32_ia32.tar.gz +0 -0
- package/src/koffi/build/2.3.4/koffi_win32_x64.tar.gz +0 -0
|
@@ -7,7 +7,8 @@ Napi::Value StaticGetter(const Napi::CallbackInfo& /*info*/) {
|
|
|
7
7
|
return MaybeUnwrap(testStaticContextRef.Value().Get("value"));
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
void StaticSetter(const Napi::CallbackInfo& /*info*/,
|
|
10
|
+
void StaticSetter(const Napi::CallbackInfo& /*info*/,
|
|
11
|
+
const Napi::Value& value) {
|
|
11
12
|
testStaticContextRef.Value().Set("value", value);
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -22,11 +23,9 @@ Napi::Value TestStaticMethodInternal(const Napi::CallbackInfo& info) {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
class Test : public Napi::ObjectWrap<Test> {
|
|
25
|
-
public:
|
|
26
|
-
Test(const Napi::CallbackInfo& info) :
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if(info.Length() > 0) {
|
|
26
|
+
public:
|
|
27
|
+
Test(const Napi::CallbackInfo& info) : Napi::ObjectWrap<Test>(info) {
|
|
28
|
+
if (info.Length() > 0) {
|
|
30
29
|
finalizeCb_ = Napi::Persistent(info[0].As<Napi::Function>());
|
|
31
30
|
}
|
|
32
31
|
// Create an own instance property.
|
|
@@ -35,20 +34,19 @@ public:
|
|
|
35
34
|
info.This().As<Napi::Object>(),
|
|
36
35
|
"ownProperty",
|
|
37
36
|
OwnPropertyGetter,
|
|
38
|
-
napi_enumerable,
|
|
37
|
+
napi_enumerable,
|
|
38
|
+
this));
|
|
39
39
|
|
|
40
40
|
// Create an own instance property with a templated function.
|
|
41
41
|
info.This().As<Napi::Object>().DefineProperty(
|
|
42
|
-
Napi::PropertyDescriptor::Accessor<OwnPropertyGetter>(
|
|
43
|
-
|
|
42
|
+
Napi::PropertyDescriptor::Accessor<OwnPropertyGetter>(
|
|
43
|
+
"ownPropertyT", napi_enumerable, this));
|
|
44
44
|
|
|
45
45
|
bufref_ = Napi::Persistent(Napi::Buffer<uint8_t>::New(
|
|
46
46
|
Env(),
|
|
47
47
|
static_cast<uint8_t*>(malloc(1)),
|
|
48
48
|
1,
|
|
49
|
-
[](Napi::Env, uint8_t* bufaddr) {
|
|
50
|
-
free(bufaddr);
|
|
51
|
-
}));
|
|
49
|
+
[](Napi::Env, uint8_t* bufaddr) { free(bufaddr); }));
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
static Napi::Value OwnPropertyGetter(const Napi::CallbackInfo& info) {
|
|
@@ -88,16 +86,16 @@ public:
|
|
|
88
86
|
.Call(array, {}));
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
void TestVoidMethodT(const Napi::CallbackInfo
|
|
89
|
+
void TestVoidMethodT(const Napi::CallbackInfo& info) {
|
|
92
90
|
value_ = MaybeUnwrap(info[0].ToString());
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
Napi::Value TestMethodT(const Napi::CallbackInfo
|
|
96
|
-
|
|
93
|
+
Napi::Value TestMethodT(const Napi::CallbackInfo& info) {
|
|
94
|
+
return Napi::String::New(info.Env(), value_);
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
static Napi::Value TestStaticMethodT(const Napi::CallbackInfo& info) {
|
|
100
|
-
|
|
98
|
+
return Napi::String::New(info.Env(), s_staticMethodText);
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
static void TestStaticVoidMethodT(const Napi::CallbackInfo& info) {
|
|
@@ -105,20 +103,31 @@ public:
|
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
static void Initialize(Napi::Env env, Napi::Object exports) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
Napi::Symbol kTestStaticAccessorInternal =
|
|
111
|
-
|
|
112
|
-
Napi::Symbol
|
|
113
|
-
|
|
114
|
-
Napi::Symbol
|
|
115
|
-
|
|
116
|
-
Napi::Symbol
|
|
117
|
-
|
|
118
|
-
Napi::Symbol
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
Napi::Symbol
|
|
106
|
+
Napi::Symbol kTestStaticValueInternal =
|
|
107
|
+
Napi::Symbol::New(env, "kTestStaticValueInternal");
|
|
108
|
+
Napi::Symbol kTestStaticAccessorInternal =
|
|
109
|
+
Napi::Symbol::New(env, "kTestStaticAccessorInternal");
|
|
110
|
+
Napi::Symbol kTestStaticAccessorTInternal =
|
|
111
|
+
Napi::Symbol::New(env, "kTestStaticAccessorTInternal");
|
|
112
|
+
Napi::Symbol kTestStaticMethodInternal =
|
|
113
|
+
Napi::Symbol::New(env, "kTestStaticMethodInternal");
|
|
114
|
+
Napi::Symbol kTestStaticMethodTInternal =
|
|
115
|
+
Napi::Symbol::New(env, "kTestStaticMethodTInternal");
|
|
116
|
+
Napi::Symbol kTestStaticVoidMethodTInternal =
|
|
117
|
+
Napi::Symbol::New(env, "kTestStaticVoidMethodTInternal");
|
|
118
|
+
|
|
119
|
+
Napi::Symbol kTestValueInternal =
|
|
120
|
+
Napi::Symbol::New(env, "kTestValueInternal");
|
|
121
|
+
Napi::Symbol kTestAccessorInternal =
|
|
122
|
+
Napi::Symbol::New(env, "kTestAccessorInternal");
|
|
123
|
+
Napi::Symbol kTestAccessorTInternal =
|
|
124
|
+
Napi::Symbol::New(env, "kTestAccessorTInternal");
|
|
125
|
+
Napi::Symbol kTestMethodInternal =
|
|
126
|
+
Napi::Symbol::New(env, "kTestMethodInternal");
|
|
127
|
+
Napi::Symbol kTestMethodTInternal =
|
|
128
|
+
Napi::Symbol::New(env, "kTestMethodTInternal");
|
|
129
|
+
Napi::Symbol kTestVoidMethodTInternal =
|
|
130
|
+
Napi::Symbol::New(env, "kTestVoidMethodTInternal");
|
|
122
131
|
|
|
123
132
|
exports.Set(
|
|
124
133
|
"Test",
|
|
@@ -237,17 +246,15 @@ public:
|
|
|
237
246
|
}
|
|
238
247
|
|
|
239
248
|
void Finalize(Napi::Env env) {
|
|
240
|
-
|
|
241
|
-
if(finalizeCb_.IsEmpty()) {
|
|
249
|
+
if (finalizeCb_.IsEmpty()) {
|
|
242
250
|
return;
|
|
243
251
|
}
|
|
244
252
|
|
|
245
253
|
finalizeCb_.Call(env.Global(), {Napi::Boolean::New(env, true)});
|
|
246
254
|
finalizeCb_.Unref();
|
|
247
|
-
|
|
248
255
|
}
|
|
249
256
|
|
|
250
|
-
private:
|
|
257
|
+
private:
|
|
251
258
|
std::string value_;
|
|
252
259
|
Napi::FunctionReference finalizeCb_;
|
|
253
260
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-lone-blocks */
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
const assert = require('assert');
|
|
@@ -5,7 +6,7 @@ const testUtil = require('./testUtil');
|
|
|
5
6
|
|
|
6
7
|
module.exports = require('./common').runTest(test);
|
|
7
8
|
|
|
8
|
-
async function test(binding) {
|
|
9
|
+
async function test (binding) {
|
|
9
10
|
const Test = binding.objectwrap.Test;
|
|
10
11
|
|
|
11
12
|
const testValue = (obj, clazz) => {
|
|
@@ -28,6 +29,7 @@ async function test(binding) {
|
|
|
28
29
|
// read write-only
|
|
29
30
|
{
|
|
30
31
|
let error;
|
|
32
|
+
// eslint-disable-next-line no-unused-vars
|
|
31
33
|
try { const read = obj.testSetter; } catch (e) { error = e; }
|
|
32
34
|
// no error
|
|
33
35
|
assert.strictEqual(error, undefined);
|
|
@@ -107,19 +109,19 @@ async function test(binding) {
|
|
|
107
109
|
// for..in: object and prototype
|
|
108
110
|
{
|
|
109
111
|
const keys = [];
|
|
110
|
-
for (
|
|
112
|
+
for (const key in obj) {
|
|
111
113
|
keys.push(key);
|
|
112
114
|
}
|
|
113
115
|
|
|
114
|
-
assert(keys.length
|
|
116
|
+
assert(keys.length === 6);
|
|
115
117
|
// on prototype
|
|
116
|
-
assert(keys.includes(
|
|
117
|
-
assert(keys.includes(
|
|
118
|
-
assert(keys.includes(
|
|
119
|
-
assert(keys.includes(
|
|
118
|
+
assert(keys.includes('testGetSet'));
|
|
119
|
+
assert(keys.includes('testGetter'));
|
|
120
|
+
assert(keys.includes('testValue'));
|
|
121
|
+
assert(keys.includes('testMethod'));
|
|
120
122
|
// on object only
|
|
121
|
-
assert(keys.includes(
|
|
122
|
-
assert(keys.includes(
|
|
123
|
+
assert(keys.includes('ownProperty'));
|
|
124
|
+
assert(keys.includes('ownPropertyT'));
|
|
123
125
|
}
|
|
124
126
|
};
|
|
125
127
|
|
|
@@ -135,7 +137,7 @@ async function test(binding) {
|
|
|
135
137
|
obj.testSetter = 'iterator';
|
|
136
138
|
const values = [];
|
|
137
139
|
|
|
138
|
-
for (
|
|
140
|
+
for (const item of obj) {
|
|
139
141
|
values.push(item);
|
|
140
142
|
}
|
|
141
143
|
|
|
@@ -146,7 +148,7 @@ async function test(binding) {
|
|
|
146
148
|
const testStaticValue = (clazz) => {
|
|
147
149
|
assert.strictEqual(clazz.testStaticValue, 'value');
|
|
148
150
|
assert.strictEqual(clazz[clazz.kTestStaticValueInternal], 5);
|
|
149
|
-
}
|
|
151
|
+
};
|
|
150
152
|
|
|
151
153
|
const testStaticAccessor = (clazz) => {
|
|
152
154
|
// read-only, write-only
|
|
@@ -165,6 +167,7 @@ async function test(binding) {
|
|
|
165
167
|
// read write-only
|
|
166
168
|
{
|
|
167
169
|
let error;
|
|
170
|
+
// eslint-disable-next-line no-unused-vars
|
|
168
171
|
try { const read = clazz.testStaticSetter; } catch (e) { error = e; }
|
|
169
172
|
// no error
|
|
170
173
|
assert.strictEqual(error, undefined);
|
|
@@ -227,7 +230,7 @@ async function test(binding) {
|
|
|
227
230
|
// for..in
|
|
228
231
|
{
|
|
229
232
|
const keys = [];
|
|
230
|
-
for (
|
|
233
|
+
for (const key in clazz) {
|
|
231
234
|
keys.push(key);
|
|
232
235
|
}
|
|
233
236
|
|
|
@@ -240,21 +243,22 @@ async function test(binding) {
|
|
|
240
243
|
}
|
|
241
244
|
};
|
|
242
245
|
|
|
243
|
-
async function testFinalize(clazz) {
|
|
246
|
+
async function testFinalize (clazz) {
|
|
244
247
|
let finalizeCalled = false;
|
|
245
248
|
await testUtil.runGCTests([
|
|
246
249
|
'test finalize',
|
|
247
250
|
() => {
|
|
248
|
-
const finalizeCb = function(called) {
|
|
251
|
+
const finalizeCb = function (called) {
|
|
249
252
|
finalizeCalled = called;
|
|
250
253
|
};
|
|
251
254
|
|
|
252
|
-
//Scope Test instance so that it can be gc'd.
|
|
255
|
+
// Scope Test instance so that it can be gc'd.
|
|
256
|
+
// eslint-disable-next-line no-new
|
|
253
257
|
(() => { new Test(finalizeCb); })();
|
|
254
258
|
},
|
|
255
259
|
() => assert.strictEqual(finalizeCalled, true)
|
|
256
260
|
]);
|
|
257
|
-
}
|
|
261
|
+
}
|
|
258
262
|
|
|
259
263
|
const testObj = (obj, clazz) => {
|
|
260
264
|
testValue(obj, clazz);
|
|
@@ -264,16 +268,16 @@ async function test(binding) {
|
|
|
264
268
|
testEnumerables(obj, clazz);
|
|
265
269
|
|
|
266
270
|
testConventions(obj, clazz);
|
|
267
|
-
}
|
|
271
|
+
};
|
|
268
272
|
|
|
269
|
-
async function testClass(clazz) {
|
|
273
|
+
async function testClass (clazz) {
|
|
270
274
|
testStaticValue(clazz);
|
|
271
275
|
testStaticAccessor(clazz);
|
|
272
276
|
testStaticMethod(clazz);
|
|
273
277
|
|
|
274
278
|
testStaticEnumerables(clazz);
|
|
275
279
|
await testFinalize(clazz);
|
|
276
|
-
}
|
|
280
|
+
}
|
|
277
281
|
|
|
278
282
|
// `Test` is needed for accessing exposed symbols
|
|
279
283
|
testObj(new Test(), Test);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#include <napi.h>
|
|
2
2
|
|
|
3
|
-
class ConstructorExceptionTest
|
|
4
|
-
|
|
5
|
-
public:
|
|
6
|
-
ConstructorExceptionTest(const Napi::CallbackInfo& info)
|
|
7
|
-
|
|
3
|
+
class ConstructorExceptionTest
|
|
4
|
+
: public Napi::ObjectWrap<ConstructorExceptionTest> {
|
|
5
|
+
public:
|
|
6
|
+
ConstructorExceptionTest(const Napi::CallbackInfo& info)
|
|
7
|
+
: Napi::ObjectWrap<ConstructorExceptionTest>(info) {
|
|
8
8
|
Napi::Error error = Napi::Error::New(info.Env(), "an exception");
|
|
9
9
|
#ifdef NAPI_DISABLE_CPP_EXCEPTIONS
|
|
10
10
|
error.ThrowAsJavaScriptException();
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
#include <napi.h>
|
|
2
2
|
|
|
3
3
|
class TestMIBase {
|
|
4
|
-
public:
|
|
4
|
+
public:
|
|
5
5
|
TestMIBase() : test(0) {}
|
|
6
6
|
virtual void dummy() {}
|
|
7
7
|
uint32_t test;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
class TestMI : public TestMIBase, public Napi::ObjectWrap<TestMI> {
|
|
11
|
-
public:
|
|
12
|
-
TestMI(const Napi::CallbackInfo& info) :
|
|
13
|
-
Napi::ObjectWrap<TestMI>(info) {}
|
|
11
|
+
public:
|
|
12
|
+
TestMI(const Napi::CallbackInfo& info) : Napi::ObjectWrap<TestMI>(info) {}
|
|
14
13
|
|
|
15
14
|
Napi::Value GetTest(const Napi::CallbackInfo& info) {
|
|
16
15
|
return Napi::Number::New(info.Env(), test);
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
static void Initialize(Napi::Env env, Napi::Object exports) {
|
|
20
|
-
exports.Set(
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
exports.Set(
|
|
20
|
+
"TestMI",
|
|
21
|
+
DefineClass(
|
|
22
|
+
env, "TestMI", {InstanceAccessor<&TestMI::GetTest>("test")}));
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -2,39 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
if (process.argv[2] === 'child') {
|
|
4
4
|
// Create a single wrapped instance then exit.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const assert = require('assert');
|
|
9
|
-
const
|
|
10
|
-
const testUtil = require('./testUtil');
|
|
11
|
-
|
|
12
|
-
module.exports = require('./common').runTestWithBindingPath(test);
|
|
5
|
+
// eslint-disable-next-line no-new
|
|
6
|
+
new (require(process.argv[3]).objectwrap.Test)();
|
|
7
|
+
} else {
|
|
8
|
+
const assert = require('assert');
|
|
9
|
+
const testUtil = require('./testUtil');
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
return testUtil.runGCTests([
|
|
16
|
-
'objectwrap removewrap test',
|
|
17
|
-
() => {
|
|
18
|
-
const binding = require(bindingName);
|
|
19
|
-
const Test = binding.objectwrap_removewrap.Test;
|
|
20
|
-
const getDtorCalled = binding.objectwrap_removewrap.getDtorCalled;
|
|
11
|
+
module.exports = require('./common').runTestWithBindingPath(test);
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
() => {}
|
|
30
|
-
]);
|
|
13
|
+
function test (bindingName) {
|
|
14
|
+
return testUtil.runGCTests([
|
|
15
|
+
'objectwrap removewrap test',
|
|
16
|
+
() => {
|
|
17
|
+
const binding = require(bindingName);
|
|
18
|
+
const Test = binding.objectwrap_removewrap.Test;
|
|
19
|
+
const getDtorCalled = binding.objectwrap_removewrap.getDtorCalled;
|
|
31
20
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
assert.strictEqual(getDtorCalled(), 0);
|
|
22
|
+
assert.throws(() => {
|
|
23
|
+
// eslint-disable-next-line no-new
|
|
24
|
+
new Test();
|
|
25
|
+
});
|
|
26
|
+
assert.strictEqual(getDtorCalled(), 1);
|
|
27
|
+
},
|
|
28
|
+
// Test that gc does not crash.
|
|
29
|
+
() => {}
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
40
32
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const { Worker, isMainThread
|
|
3
|
+
const { Worker, isMainThread } = require('worker_threads');
|
|
4
|
+
const { runTestWithBuildType, whichBuildType } = require('./common');
|
|
4
5
|
|
|
5
|
-
module.exports =
|
|
6
|
+
module.exports = runTestWithBuildType(test);
|
|
6
7
|
|
|
7
|
-
async function test(
|
|
8
|
+
async function test () {
|
|
8
9
|
if (isMainThread) {
|
|
9
|
-
const buildType =
|
|
10
|
+
const buildType = await whichBuildType();
|
|
10
11
|
const worker = new Worker(__filename, { workerData: buildType });
|
|
11
12
|
return new Promise((resolve, reject) => {
|
|
12
13
|
worker.on('exit', () => {
|
|
@@ -18,12 +18,19 @@ Value RejectPromise(const CallbackInfo& info) {
|
|
|
18
18
|
return deferred.Promise();
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
Value PromiseReturnsCorrectEnv(const CallbackInfo& info) {
|
|
22
|
+
auto deferred = Promise::Deferred::New(info.Env());
|
|
23
|
+
return Boolean::New(info.Env(), deferred.Env() == info.Env());
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
Object InitPromise(Env env) {
|
|
22
27
|
Object exports = Object::New(env);
|
|
23
28
|
|
|
24
29
|
exports["isPromise"] = Function::New(env, IsPromise);
|
|
25
30
|
exports["resolvePromise"] = Function::New(env, ResolvePromise);
|
|
26
31
|
exports["rejectPromise"] = Function::New(env, RejectPromise);
|
|
32
|
+
exports["promiseReturnsCorrectEnv"] =
|
|
33
|
+
Function::New(env, PromiseReturnsCorrectEnv);
|
|
27
34
|
|
|
28
35
|
return exports;
|
|
29
36
|
}
|
|
@@ -5,7 +5,7 @@ const common = require('./common');
|
|
|
5
5
|
|
|
6
6
|
module.exports = common.runTest(test);
|
|
7
7
|
|
|
8
|
-
async function test(binding) {
|
|
8
|
+
async function test (binding) {
|
|
9
9
|
assert.strictEqual(binding.promise.isPromise({}), false);
|
|
10
10
|
|
|
11
11
|
const resolving = binding.promise.resolvePromise('resolved');
|
|
@@ -15,4 +15,6 @@ async function test(binding) {
|
|
|
15
15
|
const rejecting = binding.promise.rejectPromise('error');
|
|
16
16
|
await assert.strictEqual(binding.promise.isPromise(rejecting), true);
|
|
17
17
|
rejecting.then(common.mustNotCall()).catch(common.mustCall());
|
|
18
|
+
|
|
19
|
+
assert(binding.promise.promiseReturnsCorrectEnv());
|
|
18
20
|
}
|
|
@@ -5,10 +5,10 @@ const testUtil = require('./testUtil');
|
|
|
5
5
|
|
|
6
6
|
module.exports = require('./common').runTest(test);
|
|
7
7
|
|
|
8
|
-
function test(binding) {
|
|
8
|
+
function test (binding) {
|
|
9
9
|
return testUtil.runGCTests([
|
|
10
10
|
'test reference',
|
|
11
11
|
() => binding.reference.createWeakArray(),
|
|
12
12
|
() => assert.strictEqual(true, binding.reference.accessWeakArrayEmpty())
|
|
13
13
|
]);
|
|
14
|
-
}
|
|
14
|
+
}
|
|
@@ -1,73 +1,66 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const buildType = process.config.target_defaults.default_configuration;
|
|
4
3
|
const assert = require('assert');
|
|
5
4
|
|
|
6
5
|
module.exports = require('./common').runTest(test);
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
assert(binding.symbol.createNewSymbolWithNoArgs() === undefined);
|
|
69
|
-
|
|
70
|
-
assert(binding.symbol.testNullSymbolCanBeCreated() === binding.symbol.testNullSymbolCanBeCreated());
|
|
71
|
-
assert(binding.symbol.testUndefinedSymbolCanBeCreated() === binding.symbol.testUndefinedSymbolCanBeCreated());
|
|
72
|
-
assert(binding.symbol.testUndefinedSymbolCanBeCreated() !== binding.symbol.testNullSymbolCanBeCreated());
|
|
7
|
+
function test (binding) {
|
|
8
|
+
const majorNodeVersion = process.versions.node.split('.')[0];
|
|
9
|
+
|
|
10
|
+
const wellKnownSymbolFunctions = ['asyncIterator', 'hasInstance', 'isConcatSpreadable', 'iterator', 'match', 'replace', 'search', 'split', 'species', 'toPrimitive', 'toStringTag', 'unscopables'];
|
|
11
|
+
if (majorNodeVersion >= 12) {
|
|
12
|
+
wellKnownSymbolFunctions.push('matchAll');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function assertCanCreateSymbol (symbol) {
|
|
16
|
+
assert(binding.symbol.createNewSymbolWithCppStr(symbol) !== null);
|
|
17
|
+
assert(binding.symbol.createNewSymbolWithCStr(symbol) !== null);
|
|
18
|
+
assert(binding.symbol.createNewSymbolWithNapi(symbol) !== null);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function assertSymbolAreUnique (symbol) {
|
|
22
|
+
const symbolOne = binding.symbol.createNewSymbolWithCppStr(symbol);
|
|
23
|
+
const symbolTwo = binding.symbol.createNewSymbolWithCppStr(symbol);
|
|
24
|
+
|
|
25
|
+
assert(symbolOne !== symbolTwo);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function assertSymbolIsWellknown (symbol) {
|
|
29
|
+
const symbOne = binding.symbol.getWellKnownSymbol(symbol);
|
|
30
|
+
const symbTwo = binding.symbol.getWellKnownSymbol(symbol);
|
|
31
|
+
assert(symbOne && symbTwo);
|
|
32
|
+
assert(symbOne === symbTwo);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function assertSymbolIsNotWellknown (symbol) {
|
|
36
|
+
const symbolTest = binding.symbol.getWellKnownSymbol(symbol);
|
|
37
|
+
assert(symbolTest === undefined);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function assertCanCreateOrFetchGlobalSymbols (symbol, fetchFunction) {
|
|
41
|
+
const symbOne = fetchFunction(symbol);
|
|
42
|
+
const symbTwo = fetchFunction(symbol);
|
|
43
|
+
assert(symbOne && symbTwo);
|
|
44
|
+
assert(symbOne === symbTwo);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
assertCanCreateSymbol('testing');
|
|
48
|
+
assertSymbolAreUnique('symbol');
|
|
49
|
+
assertSymbolIsNotWellknown('testing');
|
|
50
|
+
|
|
51
|
+
for (const wellknownProperty of wellKnownSymbolFunctions) {
|
|
52
|
+
assertSymbolIsWellknown(wellknownProperty);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
assertCanCreateOrFetchGlobalSymbols('data', binding.symbol.getSymbolFromGlobalRegistry);
|
|
56
|
+
assertCanCreateOrFetchGlobalSymbols('CppKey', binding.symbol.getSymbolFromGlobalRegistryWithCppKey);
|
|
57
|
+
assertCanCreateOrFetchGlobalSymbols('CKey', binding.symbol.getSymbolFromGlobalRegistryWithCKey);
|
|
58
|
+
|
|
59
|
+
assert(binding.symbol.createNewSymbolWithNoArgs() === undefined);
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line no-self-compare
|
|
62
|
+
assert(binding.symbol.testNullSymbolCanBeCreated() === binding.symbol.testNullSymbolCanBeCreated());
|
|
63
|
+
// eslint-disable-next-line no-self-compare
|
|
64
|
+
assert(binding.symbol.testUndefinedSymbolCanBeCreated() === binding.symbol.testUndefinedSymbolCanBeCreated());
|
|
65
|
+
assert(binding.symbol.testUndefinedSymbolCanBeCreated() !== binding.symbol.testNullSymbolCanBeCreated());
|
|
73
66
|
}
|