koffi 1.3.9 → 1.3.12
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 +24 -0
- package/build/qemu/1.3.12/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.3.12/koffi_win32_x64.tar.gz +0 -0
- package/doc/benchmarks.md +2 -2
- package/doc/conf.py +1 -1
- package/doc/contribute.md +1 -1
- package/doc/dist/doctrees/benchmarks.doctree +0 -0
- package/doc/dist/doctrees/changes.doctree +0 -0
- package/doc/dist/doctrees/contribute.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/memory.doctree +0 -0
- package/doc/dist/doctrees/types.doctree +0 -0
- package/doc/dist/html/.buildinfo +1 -1
- package/doc/dist/html/_sources/benchmarks.md.txt +2 -2
- package/doc/dist/html/_sources/contribute.md.txt +1 -2
- package/doc/dist/html/_sources/functions.md.txt +137 -15
- package/doc/dist/html/_sources/index.rst.txt +2 -0
- package/doc/dist/html/_sources/memory.md.txt +1 -1
- package/doc/dist/html/_sources/types.md.txt +27 -11
- package/doc/dist/html/_static/basic.css +14 -12
- package/doc/dist/html/_static/pygments.css +54 -54
- package/doc/dist/html/benchmarks.html +3 -3
- package/doc/dist/html/changes.html +1 -1
- package/doc/dist/html/contribute.html +2 -3
- package/doc/dist/html/functions.html +206 -86
- package/doc/dist/html/genindex.html +1 -1
- package/doc/dist/html/index.html +6 -7
- package/doc/dist/html/memory.html +4 -4
- 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 +55 -55
- package/doc/dist/html/types.html +172 -159
- package/doc/functions.md +9 -7
- package/doc/index.rst +2 -0
- package/doc/memory.md +1 -1
- package/doc/poetry.lock +692 -0
- package/doc/pyproject.toml +18 -0
- package/doc/{_static → static}/bench_linux.png +0 -0
- package/doc/{_static → static}/bench_windows.png +0 -0
- package/doc/{_static → static}/custom.css +0 -0
- package/doc/{_static → static}/perf_linux_20220623.png +0 -0
- package/doc/{_static → static}/perf_linux_20220623_2.png +0 -0
- package/doc/{_static → static}/perf_linux_20220627.png +0 -0
- package/doc/{_static → static}/perf_linux_20220628.png +0 -0
- package/doc/{_static → static}/perf_windows_20220623.png +0 -0
- package/doc/{_static → static}/perf_windows_20220623_2.png +0 -0
- package/doc/{_static → static}/perf_windows_20220627.png +0 -0
- package/doc/{_static → static}/perf_windows_20220628.png +0 -0
- package/doc/types.md +1 -1
- package/package.json +9 -7
- package/qemu/qemu.js +3 -3
- package/src/abi_arm32.cc +3 -3
- package/src/abi_riscv64.cc +1 -1
- package/src/abi_x64_sysv.cc +1 -1
- package/src/abi_x64_win.cc +1 -1
- package/src/abi_x64_win_fwd.asm +2 -2
- package/src/abi_x86.cc +5 -5
- package/src/parser.cc +2 -1
- package/test/misc.c +1 -1
- package/test/sync.js +2 -2
- package/build/qemu/1.3.9/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.3.9/koffi_win32_x64.tar.gz +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "koffi"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = ""
|
|
5
|
+
authors = ["Niels Martignène <niels.martignene@protonmail.com>"]
|
|
6
|
+
|
|
7
|
+
[tool.poetry.dependencies]
|
|
8
|
+
python = "^3.7"
|
|
9
|
+
Sphinx = "^5.0.2"
|
|
10
|
+
linkify-it-py = "^2.0.0"
|
|
11
|
+
myst-parser = "^0.18.0"
|
|
12
|
+
furo = "^2022.6.21"
|
|
13
|
+
|
|
14
|
+
[tool.poetry.dev-dependencies]
|
|
15
|
+
|
|
16
|
+
[build-system]
|
|
17
|
+
requires = ["poetry-core>=1.0.0"]
|
|
18
|
+
build-backend = "poetry.core.masonry.api"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/doc/types.md
CHANGED
|
@@ -63,7 +63,7 @@ Primitive types can be specified by name (in a string) or through `koffi.types`:
|
|
|
63
63
|
|
|
64
64
|
```js
|
|
65
65
|
// These two lines do the same:
|
|
66
|
-
let struct1 = koffi.struct({ dummy: '
|
|
66
|
+
let struct1 = koffi.struct({ dummy: 'long' });
|
|
67
67
|
let struct2 = koffi.struct({ dummy: koffi.types.long });
|
|
68
68
|
```
|
|
69
69
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koffi",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.12",
|
|
4
4
|
"description": "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foreign",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"author": "Niels Martignène <niels.martignene@protonmail.com>",
|
|
20
20
|
"main": "src/index.js",
|
|
21
21
|
"scripts": {
|
|
22
|
-
"install": "cnoke --prebuild
|
|
22
|
+
"install": "cnoke --prebuild",
|
|
23
23
|
"test": "node qemu/qemu.js test",
|
|
24
24
|
"prepublishOnly": "node qemu/qemu.js pack"
|
|
25
25
|
},
|
|
26
26
|
"license": "AGPL-3.0",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"cnoke": "^3.
|
|
28
|
+
"cnoke": "^3.1.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"chalk": "^4.1.2",
|
|
@@ -37,6 +37,11 @@
|
|
|
37
37
|
"ref-struct-di": "^1.1.1",
|
|
38
38
|
"tar": "^6.1.11"
|
|
39
39
|
},
|
|
40
|
+
"cnoke": {
|
|
41
|
+
"prebuild": "build/qemu/{{version}}/koffi_{{platform}}_{{arch}}.tar.gz",
|
|
42
|
+
"require": "./build/koffi.node",
|
|
43
|
+
"napi": 8
|
|
44
|
+
},
|
|
40
45
|
"files": [
|
|
41
46
|
"src",
|
|
42
47
|
"doc",
|
|
@@ -59,8 +64,5 @@
|
|
|
59
64
|
"ChangeLog.md",
|
|
60
65
|
"CMakeLists.txt",
|
|
61
66
|
"build/qemu/*/*.tar.gz"
|
|
62
|
-
]
|
|
63
|
-
"engines": {
|
|
64
|
-
"napi": 8
|
|
65
|
-
}
|
|
67
|
+
]
|
|
66
68
|
}
|
package/qemu/qemu.js
CHANGED
|
@@ -249,11 +249,11 @@ async function start(detach = true) {
|
|
|
249
249
|
let filename = dirname + '/VERSION';
|
|
250
250
|
let version = fs.existsSync(filename) ? parseInt(fs.readFileSync(filename).toString(), 10) : 0;
|
|
251
251
|
|
|
252
|
-
if (version
|
|
252
|
+
if (version < machine.qemu.version) {
|
|
253
253
|
log(machine, 'Machine version mismatch', chalk.bold.gray('[ignore]'));
|
|
254
254
|
|
|
255
255
|
ignore.add(machine);
|
|
256
|
-
|
|
256
|
+
success = false;
|
|
257
257
|
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
@@ -272,7 +272,7 @@ async function start(detach = true) {
|
|
|
272
272
|
log(machine, 'Start', chalk.bold.red('[error]'));
|
|
273
273
|
|
|
274
274
|
ignore.add(machine);
|
|
275
|
-
|
|
275
|
+
success = false;
|
|
276
276
|
}
|
|
277
277
|
}));
|
|
278
278
|
|
package/src/abi_arm32.cc
CHANGED
|
@@ -545,8 +545,8 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
545
545
|
const FunctionInfo *proto = trampoline.proto;
|
|
546
546
|
Napi::Function func = trampoline.func.Value();
|
|
547
547
|
|
|
548
|
-
|
|
549
|
-
uint32_t *gpr_ptr =
|
|
548
|
+
uint32_t *vec_ptr = (uint32_t *)own_sp;
|
|
549
|
+
uint32_t *gpr_ptr = vec_ptr + 16;
|
|
550
550
|
uint32_t *args_ptr = (uint32_t *)caller_sp;
|
|
551
551
|
|
|
552
552
|
uint8_t *return_ptr = proto->ret.use_memory ? (uint8_t *)gpr_ptr[0] : nullptr;
|
|
@@ -599,7 +599,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
599
599
|
arguments.Append(arg);
|
|
600
600
|
} break;
|
|
601
601
|
case PrimitiveKind::UInt32: {
|
|
602
|
-
double d = (double)*(
|
|
602
|
+
double d = (double)*(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
603
603
|
|
|
604
604
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
605
605
|
arguments.Append(arg);
|
package/src/abi_riscv64.cc
CHANGED
|
@@ -540,7 +540,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
540
540
|
arguments.Append(arg);
|
|
541
541
|
} break;
|
|
542
542
|
case PrimitiveKind::UInt32: {
|
|
543
|
-
double d = (double)*(
|
|
543
|
+
double d = (double)*(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
544
544
|
|
|
545
545
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
546
546
|
arguments.Append(arg);
|
package/src/abi_x64_sysv.cc
CHANGED
|
@@ -591,7 +591,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
591
591
|
arguments.Append(arg);
|
|
592
592
|
} break;
|
|
593
593
|
case PrimitiveKind::UInt32: {
|
|
594
|
-
double d = (double)*(
|
|
594
|
+
double d = (double)*(uint32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
|
|
595
595
|
|
|
596
596
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
597
597
|
arguments.Append(arg);
|
package/src/abi_x64_win.cc
CHANGED
|
@@ -406,7 +406,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
406
406
|
arguments.Append(arg);
|
|
407
407
|
} break;
|
|
408
408
|
case PrimitiveKind::UInt32: {
|
|
409
|
-
double d = (double)*(
|
|
409
|
+
double d = (double)*(uint32_t *)(j < 4 ? gpr_ptr + j : args_ptr);
|
|
410
410
|
args_ptr += (j >= 4);
|
|
411
411
|
|
|
412
412
|
Napi::Value arg = Napi::Number::New(env, d);
|
package/src/abi_x64_win_fwd.asm
CHANGED
|
@@ -161,7 +161,7 @@ trampoline macro ID
|
|
|
161
161
|
mov qword ptr [rsp+56], r9
|
|
162
162
|
mov rcx, ID
|
|
163
163
|
lea rdx, qword ptr [rsp+32]
|
|
164
|
-
lea r8, qword ptr [rsp+
|
|
164
|
+
lea r8, qword ptr [rsp+160]
|
|
165
165
|
lea r9, qword ptr [rsp+96]
|
|
166
166
|
call RelayCallback
|
|
167
167
|
mov rax, qword ptr [rsp+96]
|
|
@@ -185,7 +185,7 @@ trampoline_xmm macro ID
|
|
|
185
185
|
movsd qword ptr [rsp+88], xmm3
|
|
186
186
|
mov rcx, ID
|
|
187
187
|
lea rdx, qword ptr [rsp+32]
|
|
188
|
-
lea r8, qword ptr [rsp+
|
|
188
|
+
lea r8, qword ptr [rsp+160]
|
|
189
189
|
lea r9, qword ptr [rsp+96]
|
|
190
190
|
call RelayCallback
|
|
191
191
|
mov rax, qword ptr [rsp+96]
|
package/src/abi_x86.cc
CHANGED
|
@@ -428,12 +428,12 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
428
428
|
|
|
429
429
|
if (proto->convention == CallConvention::Stdcall) {
|
|
430
430
|
out_reg->ret_pop = (int)proto->args_size;
|
|
431
|
-
#ifndef _WIN32
|
|
432
|
-
} else if (return_ptr) {
|
|
433
|
-
out_reg->ret_pop = 4;
|
|
434
|
-
#endif
|
|
435
431
|
} else {
|
|
432
|
+
#ifdef _WIN32
|
|
436
433
|
out_reg->ret_pop = 0;
|
|
434
|
+
#else
|
|
435
|
+
out_reg->ret_pop = return_ptr ? 4 : 0;
|
|
436
|
+
#endif
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
LocalArray<napi_value, MaxParameters> arguments;
|
|
@@ -483,7 +483,7 @@ void CallData::Relay(Size idx, uint8_t *own_sp, uint8_t *caller_sp, BackRegister
|
|
|
483
483
|
arguments.Append(arg);
|
|
484
484
|
} break;
|
|
485
485
|
case PrimitiveKind::UInt32: {
|
|
486
|
-
double d = (double)*(
|
|
486
|
+
double d = (double)*(uint32_t *)(args_ptr++);
|
|
487
487
|
|
|
488
488
|
Napi::Value arg = Napi::Number::New(env, d);
|
|
489
489
|
arguments.Append(arg);
|
package/src/parser.cc
CHANGED
|
@@ -44,7 +44,8 @@ bool PrototypeParser::Parse(const char *str, FunctionInfo *out_func)
|
|
|
44
44
|
out_func->name = ParseIdentifier();
|
|
45
45
|
|
|
46
46
|
Consume("(");
|
|
47
|
-
|
|
47
|
+
offset += (offset + 1 < tokens.len && tokens[offset] == "void" && tokens[offset + 1] == ")");
|
|
48
|
+
if (offset < tokens.len && tokens[offset] != ")") {
|
|
48
49
|
for (;;) {
|
|
49
50
|
ParameterInfo param = {};
|
|
50
51
|
|
package/test/misc.c
CHANGED
package/test/sync.js
CHANGED
|
@@ -130,7 +130,7 @@ async function test() {
|
|
|
130
130
|
const GetMinusOne1 = lib.func('int8_t GetMinusOne1(void)');
|
|
131
131
|
const GetMinusOne2 = lib.func('int16_t GetMinusOne2(void)');
|
|
132
132
|
const GetMinusOne4 = lib.func('int32_t GetMinusOne4(void)');
|
|
133
|
-
const GetMinusOne8 = lib.func('int64_t GetMinusOne8(void)');
|
|
133
|
+
const GetMinusOne8 = lib.func('int64_t GetMinusOne8(void *dummy)');
|
|
134
134
|
const FillPack1 = lib.func('FillPack1', 'void', ['int', koffi.out(koffi.pointer(Pack1))]);
|
|
135
135
|
const RetPack1 = lib.func('RetPack1', Pack1, ['int']);
|
|
136
136
|
const AddPack1 = lib.fastcall('AddPack1', 'void', ['int', koffi.inout(koffi.pointer(Pack1))]);
|
|
@@ -187,7 +187,7 @@ async function test() {
|
|
|
187
187
|
assert.equal(GetMinusOne1(), -1);
|
|
188
188
|
assert.equal(GetMinusOne2(), -1);
|
|
189
189
|
assert.equal(GetMinusOne4(), -1);
|
|
190
|
-
assert.equal(GetMinusOne8(), -1);
|
|
190
|
+
assert.equal(GetMinusOne8(null), -1);
|
|
191
191
|
|
|
192
192
|
// Simple tests with Pack1
|
|
193
193
|
{
|
|
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
|