koffi 2.3.17 → 2.3.18
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 +6 -0
- package/build/2.3.18/koffi_darwin_arm64/koffi.node +0 -0
- package/build/2.3.18/koffi_darwin_x64/koffi.node +0 -0
- package/build/{2.3.17 → 2.3.18}/koffi_freebsd_arm64/koffi.node +0 -0
- package/build/{2.3.17 → 2.3.18}/koffi_freebsd_ia32/koffi.node +0 -0
- package/build/{2.3.17 → 2.3.18}/koffi_freebsd_x64/koffi.node +0 -0
- package/build/{2.3.17 → 2.3.18}/koffi_linux_arm32hf/koffi.node +0 -0
- package/build/{2.3.17 → 2.3.18}/koffi_linux_arm64/koffi.node +0 -0
- package/build/2.3.18/koffi_linux_ia32/koffi.node +0 -0
- package/build/{2.3.17 → 2.3.18}/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/build/{2.3.17 → 2.3.18}/koffi_linux_x64/koffi.node +0 -0
- package/build/{2.3.17 → 2.3.18}/koffi_openbsd_ia32/koffi.node +0 -0
- package/build/{2.3.17 → 2.3.18}/koffi_openbsd_x64/koffi.node +0 -0
- package/build/2.3.18/koffi_win32_arm64/koffi.node +0 -0
- package/build/2.3.18/koffi_win32_ia32/koffi.node +0 -0
- package/build/2.3.18/koffi_win32_x64/koffi.node +0 -0
- package/package.json +2 -2
- package/src/koffi/src/call.cc +3 -0
- package/src/koffi/src/ffi.cc +3 -4
- package/src/koffi/src/ffi.hh +2 -0
- package/vendor/node-addon-api/CHANGELOG.md +41 -0
- package/vendor/node-addon-api/README.md +1 -1
- package/vendor/node-addon-api/doc/array_buffer.md +10 -0
- package/vendor/node-addon-api/doc/buffer.md +97 -0
- package/vendor/node-addon-api/doc/env.md +2 -2
- package/vendor/node-addon-api/doc/external.md +2 -2
- package/vendor/node-addon-api/doc/external_buffer.md +18 -0
- package/vendor/node-addon-api/doc/hierarchy.md +4 -2
- package/vendor/node-addon-api/doc/object.md +2 -29
- package/vendor/node-addon-api/doc/type_taggable.md +40 -0
- package/vendor/node-addon-api/doc/value.md +7 -1
- package/vendor/node-addon-api/napi-inl.h +317 -22
- package/vendor/node-addon-api/napi.h +84 -7
- package/vendor/node-addon-api/package.json +9 -1
- package/vendor/node-addon-api/test/async_progress_worker.cc +15 -3
- package/vendor/node-addon-api/test/binding.cc +4 -2
- package/vendor/node-addon-api/test/binding.gyp +11 -1
- package/vendor/node-addon-api/test/buffer.cc +13 -19
- package/vendor/node-addon-api/test/buffer.h +26 -0
- package/vendor/node-addon-api/test/buffer.js +82 -0
- package/vendor/node-addon-api/test/buffer_new_or_copy-inl.h +68 -0
- package/vendor/node-addon-api/test/buffer_no_external.cc +24 -0
- package/vendor/node-addon-api/test/error.cc +101 -0
- package/vendor/node-addon-api/test/error.js +15 -1
- package/vendor/node-addon-api/test/index.js +1 -1
- package/vendor/node-addon-api/test/object_reference.cc +220 -22
- package/vendor/node-addon-api/test/object_reference.js +83 -80
- package/vendor/node-addon-api/test/objectwrap.cc +23 -3
- package/vendor/node-addon-api/test/objectwrap.js +14 -2
- package/vendor/node-addon-api/test/reference.cc +55 -1
- package/vendor/node-addon-api/test/reference.js +7 -1
- package/vendor/node-addon-api/test/type_taggable.cc +66 -0
- package/vendor/node-addon-api/test/type_taggable.js +60 -0
- package/vendor/node-addon-api/test/value_type_cast.cc +60 -0
- package/vendor/node-addon-api/test/value_type_cast.js +106 -0
- package/vendor/node-addon-api/tools/eslint-format.js +2 -2
- package/build/2.3.17/koffi_darwin_arm64/koffi.node +0 -0
- package/build/2.3.17/koffi_darwin_x64/koffi.node +0 -0
- package/build/2.3.17/koffi_linux_ia32/koffi.node +0 -0
- package/build/2.3.17/koffi_win32_arm64/koffi.node +0 -0
- package/build/2.3.17/koffi_win32_ia32/koffi.node +0 -0
- package/build/2.3.17/koffi_win32_x64/koffi.node +0 -0
- package/vendor/node-addon-api/test/object/object_type_tag.cc +0 -39
- package/vendor/node-addon-api/test/object/object_type_tag.js +0 -55
- /package/build/{2.3.17 → 2.3.18}/koffi_win32_arm64/koffi.exp +0 -0
- /package/build/{2.3.17 → 2.3.18}/koffi_win32_arm64/koffi.lib +0 -0
- /package/build/{2.3.17 → 2.3.18}/koffi_win32_ia32/koffi.exp +0 -0
- /package/build/{2.3.17 → 2.3.18}/koffi_win32_ia32/koffi.lib +0 -0
- /package/build/{2.3.17 → 2.3.18}/koffi_win32_x64/koffi.exp +0 -0
- /package/build/{2.3.17 → 2.3.18}/koffi_win32_x64/koffi.lib +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const napiChild = require('./napi_child');
|
|
5
|
+
|
|
6
|
+
module.exports = require('./common').runTestWithBuildType(test);
|
|
7
|
+
|
|
8
|
+
function test (buildType) {
|
|
9
|
+
const binding = require(`./build/${buildType}/binding_type_check.node`);
|
|
10
|
+
const testTable = {
|
|
11
|
+
typeCastBoolean: {
|
|
12
|
+
positiveValues: [true, false],
|
|
13
|
+
negativeValues: [{}, [], 1, 1n, 'true', null, undefined]
|
|
14
|
+
},
|
|
15
|
+
typeCastNumber: {
|
|
16
|
+
positiveValues: [1, NaN],
|
|
17
|
+
negativeValues: [{}, [], true, 1n, '1', null, undefined]
|
|
18
|
+
},
|
|
19
|
+
typeCastBigInt: {
|
|
20
|
+
positiveValues: [1n],
|
|
21
|
+
negativeValues: [{}, [], true, 1, '1', null, undefined]
|
|
22
|
+
},
|
|
23
|
+
typeCastDate: {
|
|
24
|
+
positiveValues: [new Date()],
|
|
25
|
+
negativeValues: [{}, [], true, 1, 1n, '1', null, undefined]
|
|
26
|
+
},
|
|
27
|
+
typeCastString: {
|
|
28
|
+
positiveValues: ['', '1'],
|
|
29
|
+
negativeValues: [{}, [], true, 1, 1n, null, undefined]
|
|
30
|
+
},
|
|
31
|
+
typeCastSymbol: {
|
|
32
|
+
positiveValues: [Symbol('1')],
|
|
33
|
+
negativeValues: [{}, [], true, 1, 1n, '1', null, undefined]
|
|
34
|
+
},
|
|
35
|
+
typeCastObject: {
|
|
36
|
+
positiveValues: [{}, new Date(), []],
|
|
37
|
+
negativeValues: [true, 1, 1n, '1', null, undefined]
|
|
38
|
+
},
|
|
39
|
+
typeCastArray: {
|
|
40
|
+
positiveValues: [[1]],
|
|
41
|
+
negativeValues: [{}, true, 1, 1n, '1', null, undefined]
|
|
42
|
+
},
|
|
43
|
+
typeCastArrayBuffer: {
|
|
44
|
+
positiveValues: [new ArrayBuffer(0)],
|
|
45
|
+
negativeValues: [new Uint8Array(1), {}, [], null, undefined]
|
|
46
|
+
},
|
|
47
|
+
typeCastTypedArray: {
|
|
48
|
+
positiveValues: [new Uint8Array(0)],
|
|
49
|
+
negativeValues: [new ArrayBuffer(1), {}, [], null, undefined]
|
|
50
|
+
},
|
|
51
|
+
typeCastDataView: {
|
|
52
|
+
positiveValues: [new DataView(new ArrayBuffer(0))],
|
|
53
|
+
negativeValues: [new ArrayBuffer(1), null, undefined]
|
|
54
|
+
},
|
|
55
|
+
typeCastFunction: {
|
|
56
|
+
positiveValues: [() => {}],
|
|
57
|
+
negativeValues: [{}, null, undefined]
|
|
58
|
+
},
|
|
59
|
+
typeCastPromise: {
|
|
60
|
+
positiveValues: [Promise.resolve()],
|
|
61
|
+
// napi_is_promise distinguishes Promise and thenable.
|
|
62
|
+
negativeValues: [{ then: () => {} }, null, undefined]
|
|
63
|
+
},
|
|
64
|
+
typeCastBuffer: {
|
|
65
|
+
positiveValues: [Buffer.from('')],
|
|
66
|
+
// napi_is_buffer doesn't distinguish between Buffer and TypedArrays.
|
|
67
|
+
negativeValues: [new ArrayBuffer(1), null, undefined]
|
|
68
|
+
},
|
|
69
|
+
typeCastExternal: {
|
|
70
|
+
positiveValues: [binding.external],
|
|
71
|
+
negativeValues: [{}, null, undefined]
|
|
72
|
+
},
|
|
73
|
+
typeCastTypeArrayOfUint8: {
|
|
74
|
+
// TypedArrayOf<uint8_t>::CheckCast doesn't distinguish between Uint8ClampedArray and Uint8Array.
|
|
75
|
+
positiveValues: [new Uint8Array(0), new Uint8ClampedArray(0)],
|
|
76
|
+
negativeValues: [new Int8Array(1), null, undefined]
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
if (process.argv[2] === 'child') {
|
|
81
|
+
child(binding, testTable, process.argv[3], process.argv[4], parseInt(process.argv[5]));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
for (const [methodName, { positiveValues, negativeValues }] of Object.entries(testTable)) {
|
|
86
|
+
for (const idx of positiveValues.keys()) {
|
|
87
|
+
const { status } = napiChild.spawnSync(process.execPath, [__filename, 'child', methodName, 'positiveValues', idx]);
|
|
88
|
+
assert.strictEqual(status, 0, `${methodName} positive value ${idx} test failed`);
|
|
89
|
+
}
|
|
90
|
+
for (const idx of negativeValues.keys()) {
|
|
91
|
+
const { status, signal, stderr } = napiChild.spawnSync(process.execPath, [__filename, 'child', methodName, 'negativeValues', idx], {
|
|
92
|
+
encoding: 'utf8'
|
|
93
|
+
});
|
|
94
|
+
if (process.platform === 'win32') {
|
|
95
|
+
assert.strictEqual(status, 128 + 6 /* SIGABRT */, `${methodName} negative value ${idx} test failed`);
|
|
96
|
+
} else {
|
|
97
|
+
assert.strictEqual(signal, 'SIGABRT', `${methodName} negative value ${idx} test failed`);
|
|
98
|
+
}
|
|
99
|
+
assert.ok(stderr.match(/FATAL ERROR: .*::CheckCast.*/));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function child (binding, testTable, methodName, type, idx) {
|
|
105
|
+
binding[methodName](testTable[methodName][type][idx]);
|
|
106
|
+
}
|
|
@@ -23,7 +23,7 @@ function main (args) {
|
|
|
23
23
|
// Check js files that change on unstaged file
|
|
24
24
|
const fileUnStaged = spawn(
|
|
25
25
|
'git',
|
|
26
|
-
['diff', '--name-only', FORMAT_START, filesToCheck],
|
|
26
|
+
['diff', '--name-only', '--diff-filter=d', FORMAT_START, filesToCheck],
|
|
27
27
|
{
|
|
28
28
|
encoding: 'utf-8'
|
|
29
29
|
}
|
|
@@ -32,7 +32,7 @@ function main (args) {
|
|
|
32
32
|
// Check js files that change on staged file
|
|
33
33
|
const fileStaged = spawn(
|
|
34
34
|
'git',
|
|
35
|
-
['diff', '--name-only', '--cached', FORMAT_START, filesToCheck],
|
|
35
|
+
['diff', '--name-only', '--cached', '--diff-filter=d', FORMAT_START, filesToCheck],
|
|
36
36
|
{
|
|
37
37
|
encoding: 'utf-8'
|
|
38
38
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#include "napi.h"
|
|
2
|
-
|
|
3
|
-
#if (NAPI_VERSION > 7)
|
|
4
|
-
|
|
5
|
-
using namespace Napi;
|
|
6
|
-
|
|
7
|
-
static const napi_type_tag type_tags[5] = {
|
|
8
|
-
{0xdaf987b3cc62481a, 0xb745b0497f299531},
|
|
9
|
-
{0xbb7936c374084d9b, 0xa9548d0762eeedb9},
|
|
10
|
-
{0xa5ed9ce2e4c00c38, 0},
|
|
11
|
-
{0, 0},
|
|
12
|
-
{0xa5ed9ce2e4c00c38, 0xdaf987b3cc62481a},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
Value TypeTaggedInstance(const CallbackInfo& info) {
|
|
16
|
-
Object instance = Object::New(info.Env());
|
|
17
|
-
uint32_t type_index = info[0].As<Number>().Int32Value();
|
|
18
|
-
|
|
19
|
-
instance.TypeTag(&type_tags[type_index]);
|
|
20
|
-
|
|
21
|
-
return instance;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
Value CheckTypeTag(const CallbackInfo& info) {
|
|
25
|
-
uint32_t type_index = info[0].As<Number>().Int32Value();
|
|
26
|
-
Object instance = info[1].As<Object>();
|
|
27
|
-
|
|
28
|
-
return Boolean::New(info.Env(),
|
|
29
|
-
instance.CheckTypeTag(&type_tags[type_index]));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Object InitObjectTypeTag(Env env) {
|
|
33
|
-
Object exports = Object::New(env);
|
|
34
|
-
exports["checkTypeTag"] = Function::New(env, CheckTypeTag);
|
|
35
|
-
exports["typedTaggedInstance"] = Function::New(env, TypeTaggedInstance);
|
|
36
|
-
return exports;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
#endif
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const assert = require('assert');
|
|
4
|
-
|
|
5
|
-
module.exports = require('../common').runTest(test);
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line camelcase
|
|
8
|
-
function test ({ object_type_tag }) {
|
|
9
|
-
const obj1 = object_type_tag.typedTaggedInstance(0);
|
|
10
|
-
const obj2 = object_type_tag.typedTaggedInstance(1);
|
|
11
|
-
|
|
12
|
-
// Verify that type tags are correctly accepted.
|
|
13
|
-
assert.strictEqual(object_type_tag.checkTypeTag(0, obj1), true);
|
|
14
|
-
assert.strictEqual(object_type_tag.checkTypeTag(1, obj2), true);
|
|
15
|
-
|
|
16
|
-
// Verify that wrongly tagged objects are rejected.
|
|
17
|
-
assert.strictEqual(object_type_tag.checkTypeTag(0, obj2), false);
|
|
18
|
-
assert.strictEqual(object_type_tag.checkTypeTag(1, obj1), false);
|
|
19
|
-
|
|
20
|
-
// Verify that untagged objects are rejected.
|
|
21
|
-
assert.strictEqual(object_type_tag.checkTypeTag(0, {}), false);
|
|
22
|
-
assert.strictEqual(object_type_tag.checkTypeTag(1, {}), false);
|
|
23
|
-
|
|
24
|
-
// Node v14 and v16 have an issue checking type tags if the `upper` in
|
|
25
|
-
// `napi_type_tag` is 0, so these tests can only be performed on Node version
|
|
26
|
-
// >=18. See:
|
|
27
|
-
// - https://github.com/nodejs/node/issues/43786
|
|
28
|
-
// - https://github.com/nodejs/node/pull/43788
|
|
29
|
-
const nodeVersion = parseInt(process.versions.node.split('.')[0]);
|
|
30
|
-
if (nodeVersion < 18) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const obj3 = object_type_tag.typedTaggedInstance(2);
|
|
35
|
-
const obj4 = object_type_tag.typedTaggedInstance(3);
|
|
36
|
-
|
|
37
|
-
// Verify that untagged objects are rejected.
|
|
38
|
-
assert.strictEqual(object_type_tag.checkTypeTag(0, {}), false);
|
|
39
|
-
assert.strictEqual(object_type_tag.checkTypeTag(1, {}), false);
|
|
40
|
-
|
|
41
|
-
// Verify that type tags are correctly accepted.
|
|
42
|
-
assert.strictEqual(object_type_tag.checkTypeTag(0, obj1), true);
|
|
43
|
-
assert.strictEqual(object_type_tag.checkTypeTag(1, obj2), true);
|
|
44
|
-
assert.strictEqual(object_type_tag.checkTypeTag(2, obj3), true);
|
|
45
|
-
assert.strictEqual(object_type_tag.checkTypeTag(3, obj4), true);
|
|
46
|
-
|
|
47
|
-
// Verify that wrongly tagged objects are rejected.
|
|
48
|
-
assert.strictEqual(object_type_tag.checkTypeTag(0, obj2), false);
|
|
49
|
-
assert.strictEqual(object_type_tag.checkTypeTag(1, obj1), false);
|
|
50
|
-
assert.strictEqual(object_type_tag.checkTypeTag(0, obj3), false);
|
|
51
|
-
assert.strictEqual(object_type_tag.checkTypeTag(1, obj4), false);
|
|
52
|
-
assert.strictEqual(object_type_tag.checkTypeTag(2, obj4), false);
|
|
53
|
-
assert.strictEqual(object_type_tag.checkTypeTag(3, obj3), false);
|
|
54
|
-
assert.strictEqual(object_type_tag.checkTypeTag(4, obj3), false);
|
|
55
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|