koffi 1.3.8 → 1.3.11

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.
Files changed (95) hide show
  1. package/ChangeLog.md +24 -0
  2. package/build/qemu/1.3.11/koffi_darwin_arm64.tar.gz +0 -0
  3. package/build/qemu/1.3.11/koffi_darwin_x64.tar.gz +0 -0
  4. package/build/qemu/1.3.11/koffi_freebsd_arm64.tar.gz +0 -0
  5. package/build/qemu/1.3.11/koffi_freebsd_ia32.tar.gz +0 -0
  6. package/build/qemu/1.3.11/koffi_freebsd_x64.tar.gz +0 -0
  7. package/build/qemu/1.3.11/koffi_linux_arm32hf.tar.gz +0 -0
  8. package/build/qemu/1.3.11/koffi_linux_arm64.tar.gz +0 -0
  9. package/build/qemu/1.3.11/koffi_linux_ia32.tar.gz +0 -0
  10. package/build/qemu/1.3.11/koffi_linux_riscv64hf64.tar.gz +0 -0
  11. package/build/qemu/1.3.11/koffi_linux_x64.tar.gz +0 -0
  12. package/build/qemu/1.3.11/koffi_openbsd_ia32.tar.gz +0 -0
  13. package/build/qemu/1.3.11/koffi_openbsd_x64.tar.gz +0 -0
  14. package/build/qemu/1.3.11/koffi_win32_arm64.tar.gz +0 -0
  15. package/build/qemu/1.3.11/koffi_win32_ia32.tar.gz +0 -0
  16. package/build/qemu/1.3.11/koffi_win32_x64.tar.gz +0 -0
  17. package/doc/benchmarks.md +2 -2
  18. package/doc/conf.py +1 -1
  19. package/doc/contribute.md +1 -1
  20. package/doc/dist/doctrees/benchmarks.doctree +0 -0
  21. package/doc/dist/doctrees/changes.doctree +0 -0
  22. package/doc/dist/doctrees/contribute.doctree +0 -0
  23. package/doc/dist/doctrees/environment.pickle +0 -0
  24. package/doc/dist/doctrees/functions.doctree +0 -0
  25. package/doc/dist/doctrees/index.doctree +0 -0
  26. package/doc/dist/doctrees/memory.doctree +0 -0
  27. package/doc/dist/doctrees/platforms.doctree +0 -0
  28. package/doc/dist/doctrees/start.doctree +0 -0
  29. package/doc/dist/doctrees/types.doctree +0 -0
  30. package/doc/dist/html/.buildinfo +1 -1
  31. package/doc/dist/html/_sources/benchmarks.md.txt +2 -2
  32. package/doc/dist/html/_sources/contribute.md.txt +1 -2
  33. package/doc/dist/html/_sources/functions.md.txt +137 -15
  34. package/doc/dist/html/_sources/index.rst.txt +2 -0
  35. package/doc/dist/html/_sources/memory.md.txt +1 -1
  36. package/doc/dist/html/_sources/types.md.txt +27 -11
  37. package/doc/dist/html/_static/basic.css +14 -12
  38. package/doc/dist/html/_static/pygments.css +54 -54
  39. package/doc/dist/html/benchmarks.html +3 -3
  40. package/doc/dist/html/changes.html +9 -1
  41. package/doc/dist/html/contribute.html +2 -3
  42. package/doc/dist/html/functions.html +206 -86
  43. package/doc/dist/html/genindex.html +1 -1
  44. package/doc/dist/html/index.html +7 -7
  45. package/doc/dist/html/memory.html +4 -4
  46. package/doc/dist/html/objects.inv +0 -0
  47. package/doc/dist/html/platforms.html +2 -2
  48. package/doc/dist/html/search.html +1 -1
  49. package/doc/dist/html/searchindex.js +1 -1
  50. package/doc/dist/html/start.html +55 -55
  51. package/doc/dist/html/types.html +172 -159
  52. package/doc/functions.md +9 -7
  53. package/doc/index.rst +2 -0
  54. package/doc/memory.md +1 -1
  55. package/doc/poetry.lock +692 -0
  56. package/doc/pyproject.toml +18 -0
  57. package/doc/{_static → static}/bench_linux.png +0 -0
  58. package/doc/{_static → static}/bench_windows.png +0 -0
  59. package/doc/{_static → static}/custom.css +0 -0
  60. package/doc/{_static → static}/perf_linux_20220623.png +0 -0
  61. package/doc/{_static → static}/perf_linux_20220623_2.png +0 -0
  62. package/doc/{_static → static}/perf_linux_20220627.png +0 -0
  63. package/doc/{_static → static}/perf_linux_20220628.png +0 -0
  64. package/doc/{_static → static}/perf_windows_20220623.png +0 -0
  65. package/doc/{_static → static}/perf_windows_20220623_2.png +0 -0
  66. package/doc/{_static → static}/perf_windows_20220627.png +0 -0
  67. package/doc/{_static → static}/perf_windows_20220628.png +0 -0
  68. package/doc/types.md +1 -1
  69. package/package.json +1 -1
  70. package/qemu/qemu.js +3 -3
  71. package/qemu/registry/machines.json +1 -1
  72. package/src/abi_arm32.cc +3 -3
  73. package/src/abi_riscv64.cc +1 -1
  74. package/src/abi_x64_sysv.cc +1 -1
  75. package/src/abi_x64_win.cc +1 -1
  76. package/src/abi_x64_win_fwd.asm +2 -2
  77. package/src/abi_x86.cc +5 -5
  78. package/src/parser.cc +2 -1
  79. package/test/misc.c +1 -1
  80. package/test/sync.js +2 -2
  81. package/build/qemu/1.3.8/koffi_darwin_arm64.tar.gz +0 -0
  82. package/build/qemu/1.3.8/koffi_darwin_x64.tar.gz +0 -0
  83. package/build/qemu/1.3.8/koffi_freebsd_arm64.tar.gz +0 -0
  84. package/build/qemu/1.3.8/koffi_freebsd_ia32.tar.gz +0 -0
  85. package/build/qemu/1.3.8/koffi_freebsd_x64.tar.gz +0 -0
  86. package/build/qemu/1.3.8/koffi_linux_arm32hf.tar.gz +0 -0
  87. package/build/qemu/1.3.8/koffi_linux_arm64.tar.gz +0 -0
  88. package/build/qemu/1.3.8/koffi_linux_ia32.tar.gz +0 -0
  89. package/build/qemu/1.3.8/koffi_linux_riscv64hf64.tar.gz +0 -0
  90. package/build/qemu/1.3.8/koffi_linux_x64.tar.gz +0 -0
  91. package/build/qemu/1.3.8/koffi_openbsd_ia32.tar.gz +0 -0
  92. package/build/qemu/1.3.8/koffi_openbsd_x64.tar.gz +0 -0
  93. package/build/qemu/1.3.8/koffi_win32_arm64.tar.gz +0 -0
  94. package/build/qemu/1.3.8/koffi_win32_ia32.tar.gz +0 -0
  95. package/build/qemu/1.3.8/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
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: 'int' });
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.8",
3
+ "version": "1.3.11",
4
4
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
5
5
  "keywords": [
6
6
  "foreign",
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 != machine.qemu.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
- missing++;
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
- missing++;
275
+ success = false;
276
276
  }
277
277
  }));
278
278
 
@@ -199,7 +199,7 @@
199
199
  "Windows x64": {
200
200
  "arch": "x64",
201
201
  "directory": "C:/Users/windows/Desktop/luigi_x64",
202
- "build": "C:\\Node64\\node64.cmd node ../cnoke/cnoke.js --prefer-clang"
202
+ "build": "C:\\Node64\\node64.cmd node ../cnoke/cnoke.js"
203
203
  },
204
204
 
205
205
  "Windows ARM64": {
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
- uint64_t *vec_ptr = (uint64_t *)own_sp;
549
- uint32_t *gpr_ptr = (uint32_t *)(vec_ptr + 8);
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)*(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
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);
@@ -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)*(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
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);
@@ -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)*(int32_t *)((param.gpr_count ? gpr_ptr : args_ptr)++);
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);
@@ -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)*(int32_t *)(j < 4 ? gpr_ptr + j : args_ptr);
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);
@@ -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+128]
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+128]
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)*(int32_t *)(args_ptr++);
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
- if (offset < tokens.len && tokens[offset] != ")" && !Match("void")) {
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
@@ -158,7 +158,7 @@ EXPORT int32_t GetMinusOne4(void)
158
158
  return -1;
159
159
  }
160
160
 
161
- EXPORT int64_t GetMinusOne8(void)
161
+ EXPORT int64_t GetMinusOne8(void *dummy)
162
162
  {
163
163
  return -1;
164
164
  }
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
  {