koffi 2.0.1 → 2.1.0-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/CMakeLists.txt +1 -8
- package/benchmark/atoi_koffi.js +12 -8
- package/benchmark/atoi_napi.js +12 -8
- package/benchmark/atoi_node_ffi.js +11 -10
- package/benchmark/raylib_cc.cc +12 -9
- package/benchmark/raylib_koffi.js +15 -13
- package/benchmark/raylib_node_ffi.js +15 -13
- package/benchmark/raylib_node_raylib.js +14 -11
- package/build/qemu/2.1.0-beta.1/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.0-beta.1/koffi_win32_x64.tar.gz +0 -0
- package/doc/changes.md +12 -8
- package/doc/dist/doctrees/changes.doctree +0 -0
- package/doc/dist/doctrees/environment.pickle +0 -0
- package/doc/dist/doctrees/functions.doctree +0 -0
- package/doc/dist/doctrees/index.doctree +0 -0
- package/doc/dist/doctrees/types.doctree +0 -0
- package/doc/dist/html/_sources/changes.md.txt +12 -8
- package/doc/dist/html/_sources/functions.md.txt +4 -4
- package/doc/dist/html/_sources/types.md.txt +69 -34
- package/doc/dist/html/benchmarks.html +1 -1
- package/doc/dist/html/changes.html +44 -33
- package/doc/dist/html/contribute.html +1 -1
- package/doc/dist/html/functions.html +7 -7
- package/doc/dist/html/genindex.html +1 -1
- package/doc/dist/html/index.html +3 -3
- package/doc/dist/html/memory.html +1 -1
- package/doc/dist/html/objects.inv +0 -0
- package/doc/dist/html/platforms.html +2 -2
- package/doc/dist/html/search.html +1 -1
- package/doc/dist/html/searchindex.js +1 -1
- package/doc/dist/html/start.html +1 -1
- package/doc/dist/html/types.html +77 -40
- package/doc/functions.md +4 -4
- package/doc/types.md +68 -33
- package/package.json +2 -2
- package/qemu/qemu.js +1 -1
- package/src/call.cc +42 -26
- package/src/call.hh +15 -3
- package/src/ffi.cc +70 -13
- package/src/ffi.hh +7 -0
- package/src/index.js +4 -2
- package/src/parser.cc +3 -5
- package/src/util.cc +44 -1
- package/src/util.hh +4 -0
- package/test/async.js +1 -2
- package/test/callbacks.js +2 -3
- package/test/misc.c +21 -1
- package/test/raylib.js +1 -1
- package/test/sqlite.js +3 -3
- package/test/sync.js +27 -3
- package/build/qemu/2.0.1/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.0.1/koffi_win32_x64.tar.gz +0 -0
package/test/sync.js
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
const koffi = require('./build/koffi.node');
|
|
17
17
|
const assert = require('assert');
|
|
18
|
-
const path = require('path');
|
|
19
18
|
|
|
20
19
|
const Pack1 = koffi.struct('Pack1', {
|
|
21
20
|
a: 'int'
|
|
@@ -62,7 +61,7 @@ const IntFloat = koffi.struct('IntFloat', {
|
|
|
62
61
|
|
|
63
62
|
const BFG = koffi.struct('BFG', {
|
|
64
63
|
a: 'int8_t',
|
|
65
|
-
b: 'int64_t',
|
|
64
|
+
b: [16, 'int64_t'],
|
|
66
65
|
c: 'char',
|
|
67
66
|
d: 'const char *',
|
|
68
67
|
e: 'short',
|
|
@@ -128,7 +127,7 @@ async function main() {
|
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
async function test() {
|
|
131
|
-
let lib_filename =
|
|
130
|
+
let lib_filename = __dirname + '/build/misc' + koffi.extension;
|
|
132
131
|
let lib = koffi.load(lib_filename);
|
|
133
132
|
|
|
134
133
|
const GetMinusOne1 = lib.func('int8_t GetMinusOne1(void)');
|
|
@@ -160,6 +159,7 @@ async function test() {
|
|
|
160
159
|
const ConcatenateToStr8 = lib.func('ConcatenateToStr8', 'str', [...Array(8).fill('int64_t'), koffi.struct('IJK8', {i: 'int64_t', j: 'int64_t', k: 'int64_t'}), 'int64_t']);
|
|
161
160
|
const MakeBFG = lib.func('BFG __stdcall MakeBFG(_Out_ BFG *p, int x, double y, const char *str)');
|
|
162
161
|
const MakePackedBFG = lib.func('AliasBFG __fastcall MakePackedBFG(int x, double y, _Out_ PackedBFG *p, const char *str)');
|
|
162
|
+
const MakePolymorphBFG = lib.func('void MakePolymorphBFG(int type, int x, double y, const char *str, _Out_ void *p)');
|
|
163
163
|
const ReturnBigString = process.platform == 'win32' ?
|
|
164
164
|
lib.stdcall(1, koffi.disposable('str', koffi.free), ['str']) :
|
|
165
165
|
lib.func('const char * __stdcall ReturnBigString(const char *str)');
|
|
@@ -186,6 +186,7 @@ async function test() {
|
|
|
186
186
|
const MultiplyIntegers = lib.func('void MultiplyIntegers(int multiplier, _Inout_ int *values, int len)');
|
|
187
187
|
const ThroughStr = lib.func('str ThroughStr(StrStruct s)');
|
|
188
188
|
const ThroughStr16 = lib.func('str16 ThroughStr16(StrStruct s)');
|
|
189
|
+
const ReverseBytes = lib.func('void ReverseBytes(_Inout_ void *array, int len)');
|
|
189
190
|
|
|
190
191
|
// Simple signed value returns
|
|
191
192
|
assert.equal(GetMinusOne1(), -1);
|
|
@@ -295,6 +296,17 @@ async function test() {
|
|
|
295
296
|
assert.deepEqual(out, bfg);
|
|
296
297
|
}
|
|
297
298
|
|
|
299
|
+
// Polymorph pointer
|
|
300
|
+
{
|
|
301
|
+
let bfg = {};
|
|
302
|
+
|
|
303
|
+
MakePolymorphBFG(0, 2, 7, 'boo', koffi.as(bfg, 'BFG *'));
|
|
304
|
+
assert.deepEqual(bfg, { a: 2, b: 4, c: -25, d: 'X/boo/X', e: 54, inner: { f: 14, g: 5 }});
|
|
305
|
+
|
|
306
|
+
MakePolymorphBFG(1, 2, 7, 'bies', koffi.as(bfg, 'PackedBFG *'));
|
|
307
|
+
assert.deepEqual(bfg, { a: 2, b: 4, c: -25, d: 'X/bies/X', e: 54, inner: { f: 14, g: 5 }});
|
|
308
|
+
}
|
|
309
|
+
|
|
298
310
|
// Big string
|
|
299
311
|
{
|
|
300
312
|
let str = 'fooBAR!'.repeat(1024 * 1024);
|
|
@@ -394,4 +406,16 @@ async function test() {
|
|
|
394
406
|
assert.equal(ThroughStr16({ str: null, str16: 'World!' }), 'World!');
|
|
395
407
|
assert.equal(ThroughStr16({ str: 'World!', str16: null }), null);
|
|
396
408
|
}
|
|
409
|
+
|
|
410
|
+
// Transparent typed arrays for void pointers
|
|
411
|
+
{
|
|
412
|
+
let arr8 = Uint8Array.from([1, 2, 3, 4, 5]);
|
|
413
|
+
let arr16 = Int16Array.from([1, 2, 3, 4, 5]);
|
|
414
|
+
|
|
415
|
+
ReverseBytes(arr8, arr8.byteLength);
|
|
416
|
+
assert.deepEqual(arr8, Uint8Array.from([5, 4, 3, 2, 1]));
|
|
417
|
+
|
|
418
|
+
ReverseBytes(arr16, arr16.byteLength);
|
|
419
|
+
assert.deepEqual(arr16, Int16Array.from([1280, 1024, 768, 512, 256]));
|
|
420
|
+
}
|
|
397
421
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|