node-ctypes 2.4.0 → 2.5.0

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 CHANGED
@@ -7,6 +7,76 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.5.0] - 2026-10-26
11
+
12
+ ### Fixed
13
+
14
+ - **Portable CI validation**: large BigInt-to-float conversion no longer requires
15
+ the floating-point `from_chars` overload introduced in macOS 26, preserving
16
+ the macOS 13.5 deployment target and integer rounding/overflow checks. Paired
17
+ Linux lookup tests accept musl's `libm` alias to `libc` and verify the resolved
18
+ libraries by calling their correctly declared functions. Windows references
19
+ resolve the explicit `msvcrt` library and accept absolute DLL paths instead of
20
+ assuming CPython implements Node's `"c"` alias or returns bare file names.
21
+
22
+ ### Changed
23
+
24
+ - **Parity tests**: migrate the complete former `common/` and `windows/`
25
+ suites into domain-based `cpython_parity/` pairs, `node_specific/` regressions
26
+ and genuine `python_specific/` scheduling checks. Paired JS uses Python-shaped
27
+ classes, `ARRAY`, attribute bindings and `CFUNCTYPE`, with corresponding
28
+ class/method IDs, input matrices and actual C signatures. A structural AST
29
+ guard rejects one-sided files/cases, missing discovery markers and convenience
30
+ APIs in the canonical pairs without adding dependencies or replacing either
31
+ test runner. Python 3.15 CI now runs all references.
32
+ - **Pointer definitions**: expose Python's `_type_` metadata and defer incomplete
33
+ aggregate pointee layout until an actual memory access, so forward-bound
34
+ `_fields_` and self-referential types do not need manual cache invalidation.
35
+ - **Scalar and field conversion**: accept legitimate empty/whitespace field
36
+ names without corrupting constructor/prototype metadata, and convert full-width
37
+ BigInts to floating-point values with CPython rounding and overflow behavior
38
+ rather than an artificial 64-bit integer limit.
39
+ - **Function protocols**: `CFUNCTYPE` callbacks are callable, native functions
40
+ can be cast through the public API, and cached prototype conversion/retval
41
+ hooks are captured at type creation. Pointer-to-pointer values use the pointer
42
+ slot rather than the pointee bytes. Declared integer arguments reject nullish
43
+ values, and string-pointer arguments require strings, compatible C-data or an
44
+ explicit cast instead of an untyped integer address.
45
+ - **Raw memory and finalization**: explicitly sized `string_at` preserves all
46
+ bytes, including invalid UTF-8 and embedded NUL, as a Latin1 string; unsized
47
+ textual reads retain their UTF-8 representation. Address conversion errors
48
+ retain their causes through `ArgumentError`. Materialized aggregate layouts
49
+ reject `_fields_` reassignment, including previously incomplete types.
50
+ - **Typed pointer adapters**: match CPython's distinction between direct and
51
+ adapted arguments. Automatic by-reference conversion, array decay and NULL
52
+ acceptance no longer apply to scalar/array/null `_as_parameter_` results for
53
+ `POINTER(T)`; explicit compatible pointers and `byref` results remain accepted.
54
+ - **Parameter resolution**: terminal primitive `_as_parameter_` results avoid
55
+ allocating a cycle-detection Set. Recursive conversion follows CPython:
56
+ stateful getters may revisit an object before terminating, and the fixed
57
+ 128-step rejection is removed. Non-terminating recursion uses the host runtime
58
+ stack guard; intermediate owners stay alive and getter errors propagate unchanged.
59
+ - **Prototype callers**: eligible synchronous prototype bindings reuse the
60
+ fixed-arity JavaScript wrappers used by library functions. Calls needing
61
+ owners, custom adapters, result conversion or argument-count fallback keep
62
+ the general pipeline. Hook snapshots, original argument arrays, callable
63
+ metadata and prototype asynchronous behavior are preserved. External
64
+ comparisons include explicit already-bound `CFUNCTYPE` caller rows.
65
+ - **Callback conversion**: builtin-only signatures skip the generic argument
66
+ conversion dispatcher while preserving invocation and result conversion. Native
67
+ handlers construct fallback error messages only on failure, with unchanged
68
+ diagnostics and thread-safety checks.
69
+ - **Long UTF-8 arguments**: synchronous calls encode directly into reusable
70
+ scratch storage when it fits, keeping the ordinary encoder for growth.
71
+ String contents are still encoded on every call; the existing retention
72
+ bound, wide-string alignment and independent reentrant buffers are preserved.
73
+ - **Structure argument conversion**: plain-object arguments for functional
74
+ `struct()` definitions containing only builtin non-pointer scalar fields
75
+ skip the transient Proxy and use the same byte initializer as `create()`.
76
+ Field validation, zero defaults, dynamic `create()` / `set()` hooks and
77
+ argument lifetimes are preserved. Classes and complex definitions keep
78
+ their existing conversion paths.
79
+
10
80
  ## [2.4.0] - 2026-10-24
11
81
 
12
82
  ### Added
@@ -904,7 +974,8 @@ It contains breaking changes: see [Migrating from 1.x](README.md#migrating-from-
904
974
 
905
975
  Initial releases.
906
976
 
907
- [Unreleased]: https://github.com/dmazzella/node-ctypes/compare/v2.4.0...HEAD
977
+ [Unreleased]: https://github.com/dmazzella/node-ctypes/compare/v2.5.0...HEAD
978
+ [2.5.0]: https://github.com/dmazzella/node-ctypes/compare/v2.4.0...v2.5.0
908
979
  [2.4.0]: https://github.com/dmazzella/node-ctypes/compare/v2.3.0...v2.4.0
909
980
  [2.3.0]: https://github.com/dmazzella/node-ctypes/compare/v2.2.0...v2.3.0
910
981
  [2.2.0]: https://github.com/dmazzella/node-ctypes/compare/v2.1.1...v2.2.0
package/README.md CHANGED
@@ -236,6 +236,9 @@ that cannot be converted (a plain JS function, an object) raise
236
236
  Declared `POINTER(T)` parameters reject incompatible ctypes instances,
237
237
  arrays and pointer types before entering C. Compatible subclasses and arrays
238
238
  are accepted, and a matching scalar/structure is passed by reference.
239
+ These implicit scalar/array/NULL conversions apply to direct arguments only.
240
+ To adapt one of these values through `_as_parameter_`, return an explicit
241
+ compatible pointer or `byref` value instead, as in CPython.
239
242
  An explicit `cast()` changes the pointer type. Raw addresses and raw
240
243
  Buffer/TypedArray/ArrayBuffer memory remain node-ctypes extensions; use
241
244
  `c_void_p` for portable raw-address code.
@@ -585,9 +588,12 @@ memory passed by value or as an integer address, including values materialized
585
588
  by getters.
586
589
 
587
590
  `_as_parameter_` chains are resolved recursively, including results of
588
- `from_param`, with intermediate owners retained. Cycles and chains exceeding
589
- 128 adapter steps raise explicit argument errors, rather than overflowing
590
- the stack or silently passing an incorrect pointer.
591
+ `from_param`, with intermediate owners retained. As in CPython, an adapter may
592
+ be visited again when a stateful getter eventually returns a usable value;
593
+ object identity alone is not rejected as a cycle, and there is no fixed
594
+ 128-step limit. Non-terminating recursion raises an argument conversion error.
595
+ The available recursion depth and stack-error wording follow the JavaScript
596
+ runtime, rather than CPython's runtime-specific recursion guard.
591
597
 
592
598
  This only covers the call: if C stores a pointer for later use, or returns a
593
599
  pointer into an argument's memory, keep the source object referenced for as
@@ -715,6 +721,11 @@ Plus the Win32 types, structures and pointer types of `ctypes.wintypes` under `w
715
721
  - `create_string_buffer(init, size?)` / `c_buffer` / `create_unicode_buffer(init, size?)` — with `.value` (and `.raw`)
716
722
  - `string_at(addr, size?)` / `wstring_at(addr, size?)` — exactly `size` units, or up to the NUL
717
723
 
724
+ With an explicit byte count, `string_at` returns a lossless Latin1 string:
725
+ `Buffer.from(string_at(addr, n), "latin1")` recovers all `n` original bytes,
726
+ including embedded NUL and invalid UTF-8. Without a count it retains the
727
+ UTF-8 text representation. `wstring_at` counts native wide-character units.
728
+
718
729
  ### Error slots
719
730
 
720
731
  - `get_errno()` / `set_errno(v)`
@@ -734,7 +745,7 @@ Plus the Win32 types, structures and pointer types of `ctypes.wintypes` under `w
734
745
 
735
746
  ## Python ctypes parity & differences
736
747
 
737
- ### What works identically
748
+ ### Supported Python ctypes behavior
738
749
 
739
750
  Structs, unions, bit fields (`_layout_` `"gcc-sysv"` / `"ms"`), anonymous
740
751
  fields, `_pack_`, `_align_`, subclasses of structures and unions, nested layouts,
@@ -846,8 +857,18 @@ Each example in `examples/` has its own README; see the [index](examples/README.
846
857
 
847
858
  From the repository root, `npm --prefix tests test` first builds a small C library (`tests/fixtures/`, into
848
859
  `build/fixture/`) used by the tests of structures by value, array parameters
849
- and reentrant calls; `npm run build:test-fixture` builds it alone. Python
850
- twins of the tests (`tests/common/*.py`) load the same library.
860
+ and reentrant calls; `npm run build:test-fixture` builds it alone. Matched
861
+ Python/JavaScript contracts live under `tests/cpython_parity/`, divided by domain,
862
+ and load the same library. Node-specific async, representation and GC checks
863
+ live under `tests/node_specific/`; genuine Python-only scheduling checks live
864
+ under `tests/python_specific/`. The former `common/` and `windows/` suites have
865
+ been migrated into these domains.
866
+
867
+ Paired JavaScript uses the Python-shaped API: `Structure`/`Union` classes,
868
+ `ARRAY`, library attributes with `argtypes`/`restype`, and `CFUNCTYPE` bindings.
869
+ The structural guard checks neighboring files and matching class/method IDs
870
+ using the existing TypeScript parser and Python AST; runtime assertions remain
871
+ independent checks against CPython, not a claim based on file names alone.
851
872
 
852
873
  ```bash
853
874
  npm install
@@ -855,13 +876,16 @@ npm run build
855
876
  npm --prefix tests install
856
877
  npm --prefix tests test # functional/parity tests
857
878
  NODE_CTYPES_NO_EXTERNAL_BUFFERS=1 npm --prefix tests test # mirrored native memory
879
+ npm --prefix tests run test:parity # matched CPython and JS contracts
880
+ npm --prefix tests run test:parity:check # paired file/case/discovery/style guard
881
+ npm --prefix tests run test:python # all Python references
858
882
  npm run test:types # TypeScript declarations
859
883
  npm run docs # TypeDoc API site in docs/
860
884
  npm run docs:serve # preview
861
885
  ```
862
886
 
863
- See [tests/common/](https://github.com/dmazzella/node-ctypes/tree/main/tests/common) for runnable examples alongside
864
- parallel Python ctypes implementations.
887
+ See the [test suite guide](tests/README.md) for paired-case conventions,
888
+ runtime differences and focused commands.
865
889
 
866
890
  ### Performance comparisons
867
891
 
@@ -916,7 +940,16 @@ variadic calls and async calls with 1/8 calls in flight. Cases without an
916
940
  equivalent documented node:ffi API are listed as **not compared**, not
917
941
  emulated with a different native signature.
918
942
 
943
+ The `CFUNCTYPE` rows measure calls through an already-bound node-ctypes
944
+ prototype, against an independently bound competitor function with the same
945
+ C signature. Bindings are separate to avoid sharing optimization feedback
946
+ with the direct-call rows. These cases do not include prototype construction
947
+ or callback registration.
948
+
919
949
  Both sides call the same C fixture and verify results before/after timing.
950
+ String contents are encoded on every call; node-ctypes reuses scratch storage,
951
+ not previously encoded strings. Measurements describe warmed repeated calls,
952
+ not cold-start allocation costs.
920
953
  String lengths are compared as Numbers, including conversion where the API
921
954
  returns BigInt; wide integers are BigInt in both APIs. Structures are plain
922
955
  objects. Async times include scheduling and are reported per completed call,
Binary file
Binary file
@@ -40,7 +40,7 @@
40
40
  */
41
41
 
42
42
  import { _toNativeReturnType } from "./types.js";
43
- import { adaptCallbackFunction, argumentConverters, argumentsNeedOwners, callWithArgumentOwners, callWithResultHandler, convertArguments, needsArgumentOwners, resultCheck, resultConverter, scalarResult, structResult } from "./conversions.js";
43
+ import { adaptCallbackFunction, argumentConverters, argumentsNeedOwners, callWithArgumentOwners, callWithResultHandler, convertArguments, resultCheck, resultConverter, scalarResult, specializeCall, structResult } from "./conversions.js";
44
44
  import { createTypeKey } from "../utils/cache.js";
45
45
 
46
46
  /**
@@ -72,7 +72,10 @@ export function createLibraryClasses(Library, LRUCache, _toNativeType, _toNative
72
72
  class FunctionWrapper {
73
73
  constructor(cdll, name) {
74
74
  const argtypes = [];
75
+ let declaredArgtypes = [];
76
+ let converters = [];
75
77
  let restype = undefined;
78
+ let resultSignature;
76
79
  let errcheck = null;
77
80
  let cachedFunc = null;
78
81
 
@@ -82,7 +85,9 @@ export function createLibraryClasses(Library, LRUCache, _toNativeType, _toNative
82
85
  // argtypes / restype, come in Python.
83
86
  const resolve = () => {
84
87
  if (!cachedFunc) {
85
- cachedFunc = cdll._createFunction(name, restype === undefined ? cdll._defaultRestype() : restype, argtypes);
88
+ const returnType = restype === undefined ? cdll._defaultRestype() : restype;
89
+ const signature = resultSignature ?? { represent: resultConverter(returnType), check: cdll._resultCheck(returnType, name) };
90
+ cachedFunc = cdll._createFunction(name, returnType, declaredArgtypes, {}, { ...signature, converters });
86
91
  Object.defineProperty(cachedFunc, kErrcheckFunc, { value: func });
87
92
  if (errcheck !== null) {
88
93
  cachedFunc.errcheck = errcheck;
@@ -102,7 +107,11 @@ export function createLibraryClasses(Library, LRUCache, _toNativeType, _toNative
102
107
  get: () => argtypes,
103
108
  set: (value) => {
104
109
  // Python: argtypes = None toglie i tipi degli argomenti.
105
- argtypes.splice(0, argtypes.length, ...(value ?? []));
110
+ const types = [...(value ?? [])];
111
+ const next = argumentConverters(types, native);
112
+ argtypes.splice(0, argtypes.length, ...types);
113
+ declaredArgtypes = types;
114
+ converters = next;
106
115
  cachedFunc = null; // Invalidate cache
107
116
  },
108
117
  configurable: true,
@@ -110,6 +119,8 @@ export function createLibraryClasses(Library, LRUCache, _toNativeType, _toNative
110
119
  restype: {
111
120
  get: () => (restype === undefined ? cdll._defaultRestype() : restype),
112
121
  set: (value) => {
122
+ const returnType = value === undefined ? cdll._defaultRestype() : value;
123
+ resultSignature = { represent: resultConverter(returnType), check: cdll._resultCheck(returnType, name) };
113
124
  restype = value;
114
125
  cachedFunc = null; // Invalidate cache
115
126
  },
@@ -214,7 +225,7 @@ export function createLibraryClasses(Library, LRUCache, _toNativeType, _toNative
214
225
  * Crea una nuova funzione, senza cache (vedi func()).
215
226
  * @protected
216
227
  */
217
- _createFunction(name, returnType, argTypes = [], options = {}) {
228
+ _createFunction(name, returnType, argTypes = [], options = {}, signature) {
218
229
  // Propagate library-level use_last_error / use_errno to the FFIFunction
219
230
  const mergedOptions = {
220
231
  ...options,
@@ -223,26 +234,23 @@ export function createLibraryClasses(Library, LRUCache, _toNativeType, _toNative
223
234
  ...(structResult(returnType) ? { struct_buffer: true } : {}),
224
235
  ...(scalarResult(returnType) ? { scalar_buffer: true } : {}),
225
236
  };
226
- const ffiFunc = this._lib.func(name, _toNativeReturnType(returnType, native), _toNativeTypes(argTypes, native), mergedOptions);
237
+ const ffiFunc = this._lib.func(name, signature?.nativeRestype ?? _toNativeReturnType(returnType, native), signature?.nativeArgtypes ?? _toNativeTypes(argTypes, native), mergedOptions);
227
238
 
228
239
  // =========================================================================
229
240
  // OPTIMIZATION: Create specialized wrapper based on argument types
230
241
  // For primitive-only args, bypass the processing loop entirely
231
242
  // =========================================================================
232
243
 
233
- const argCount = argTypes.length;
234
-
235
244
  // Conversione degli argomenti come il from_param di base di Python
236
245
  // (vedi conversions.js): un convertitore per posizione dichiarata.
237
- const C = argumentConverters(argTypes, native);
238
- const [C0, C1, C2, C3, C4, C5] = C;
246
+ const C = signature?.converters ?? argumentConverters(argTypes, native);
239
247
  const convertAll = (args) => convertArguments(args, C);
240
248
  const hasAdapters = C.some((convert) => convert.requiresOwners);
241
- const baseConvert = resultConverter(returnType);
242
- const check = this._resultCheck(returnType, name);
249
+ const baseConvert = signature === undefined ? resultConverter(returnType) : signature.represent;
250
+ const check = signature === undefined ? this._resultCheck(returnType, name) : signature.check;
243
251
  const convertResult = check === undefined ? baseConvert : baseConvert === undefined ? check : (result) => check(baseConvert(result));
244
252
  const captureHere = convertResult === undefined;
245
- let jsErrcheck = null;
253
+ const callState = { errcheck: null };
246
254
  let checkedSync;
247
255
  const checkedCall = (method, args, checked) => {
248
256
  const originalArgs = Array.isArray(args) ? args : Array.prototype.slice.call(args);
@@ -252,71 +260,13 @@ export function createLibraryClasses(Library, LRUCache, _toNativeType, _toNative
252
260
  return callWithResultHandler(ffiFunc, method, originalArgs, C, finish, hasAdapters || argumentsNeedOwners(originalArgs), call);
253
261
  };
254
262
  const ownedCall = (method, args) => callWithArgumentOwners(ffiFunc, method, args, C);
255
- const invoke = (method, args) => {
256
- if (captureHere && jsErrcheck !== null) return checkedCall(method, args, jsErrcheck);
263
+ const invoke = (method, args, checked) => {
264
+ if (captureHere && checked !== null) return checkedCall(method, args, checked);
257
265
  return captureHere && (hasAdapters || argumentsNeedOwners(args)) ? ownedCall(method, args) : ffiFunc[method](...convertAll(args));
258
266
  };
259
267
 
260
- // Funzioni specializzate per numero di argomenti (niente array per la
261
- // chiamata comune); `method` è "call" o "callAsync".
262
- const specialize = (method) => {
263
- switch (argCount) {
264
- case 0:
265
- return function () {
266
- if (captureHere && jsErrcheck !== null) return checkedCall(method, arguments, jsErrcheck);
267
- return arguments.length === 0 ? ffiFunc[method]() : invoke(method, arguments);
268
- };
269
- case 1:
270
- return function (a0) {
271
- if (captureHere && jsErrcheck !== null) return checkedCall(method, arguments, jsErrcheck);
272
- if (arguments.length !== 1) return invoke(method, arguments);
273
- if (captureHere && (hasAdapters || needsArgumentOwners(a0))) return ownedCall(method, arguments);
274
- return ffiFunc[method](C0(a0));
275
- };
276
- case 2:
277
- return function (a0, a1) {
278
- if (captureHere && jsErrcheck !== null) return checkedCall(method, arguments, jsErrcheck);
279
- if (arguments.length !== 2) return invoke(method, arguments);
280
- if (captureHere && (hasAdapters || needsArgumentOwners(a0) || needsArgumentOwners(a1))) return ownedCall(method, arguments);
281
- return ffiFunc[method](C0(a0), C1(a1));
282
- };
283
- case 3:
284
- return function (a0, a1, a2) {
285
- if (captureHere && jsErrcheck !== null) return checkedCall(method, arguments, jsErrcheck);
286
- if (arguments.length !== 3) return invoke(method, arguments);
287
- if (captureHere && (hasAdapters || needsArgumentOwners(a0) || needsArgumentOwners(a1) || needsArgumentOwners(a2))) return ownedCall(method, arguments);
288
- return ffiFunc[method](C0(a0), C1(a1), C2(a2));
289
- };
290
- case 4:
291
- return function (a0, a1, a2, a3) {
292
- if (captureHere && jsErrcheck !== null) return checkedCall(method, arguments, jsErrcheck);
293
- if (arguments.length !== 4) return invoke(method, arguments);
294
- if (captureHere && (hasAdapters || needsArgumentOwners(a0) || needsArgumentOwners(a1) || needsArgumentOwners(a2) || needsArgumentOwners(a3))) return ownedCall(method, arguments);
295
- return ffiFunc[method](C0(a0), C1(a1), C2(a2), C3(a3));
296
- };
297
- case 5:
298
- return function (a0, a1, a2, a3, a4) {
299
- if (captureHere && jsErrcheck !== null) return checkedCall(method, arguments, jsErrcheck);
300
- if (arguments.length !== 5) return invoke(method, arguments);
301
- if (captureHere && (hasAdapters || needsArgumentOwners(a0) || needsArgumentOwners(a1) || needsArgumentOwners(a2) || needsArgumentOwners(a3) || needsArgumentOwners(a4))) return ownedCall(method, arguments);
302
- return ffiFunc[method](C0(a0), C1(a1), C2(a2), C3(a3), C4(a4));
303
- };
304
- case 6:
305
- return function (a0, a1, a2, a3, a4, a5) {
306
- if (captureHere && jsErrcheck !== null) return checkedCall(method, arguments, jsErrcheck);
307
- if (arguments.length !== 6) return invoke(method, arguments);
308
- if (captureHere && (hasAdapters || needsArgumentOwners(a0) || needsArgumentOwners(a1) || needsArgumentOwners(a2) || needsArgumentOwners(a3) || needsArgumentOwners(a4) || needsArgumentOwners(a5))) return ownedCall(method, arguments);
309
- return ffiFunc[method](C0(a0), C1(a1), C2(a2), C3(a3), C4(a4), C5(a5));
310
- };
311
- default:
312
- return function (...args) {
313
- return invoke(method, args);
314
- };
315
- }
316
- };
317
-
318
- let callMethod = specialize("call");
319
- let asyncCallMethod = specialize("callAsync");
268
+ let callMethod = specializeCall(ffiFunc, "call", C, callState, (args, checked) => invoke("call", args, checked), captureHere);
269
+ let asyncCallMethod = specializeCall(ffiFunc, "callAsync", C, callState, (args, checked) => invoke("callAsync", args, checked), captureHere);
320
270
 
321
271
  // Result handlers run inside the native call scope, after conversion and
322
272
  // with the hook/arguments captured before any argument adapter executes.
@@ -325,12 +275,12 @@ export function createLibraryClasses(Library, LRUCache, _toNativeType, _toNative
325
275
  const rawAsync = asyncCallMethod;
326
276
  const finish = (result) => convertResult(result);
327
277
  callMethod = function (...args) {
328
- if (jsErrcheck !== null) return checkedCall("call", args, jsErrcheck);
278
+ if (callState.errcheck !== null) return checkedCall("call", args, callState.errcheck);
329
279
  if (hasAdapters || argumentsNeedOwners(args)) return callWithArgumentOwners(ffiFunc, "call", args, C, finish);
330
280
  return finish(rawCall.apply(this, args), args);
331
281
  };
332
282
  asyncCallMethod = function (...args) {
333
- if (jsErrcheck !== null) return checkedCall("callAsync", args, jsErrcheck);
283
+ if (callState.errcheck !== null) return checkedCall("callAsync", args, callState.errcheck);
334
284
  if (hasAdapters || argumentsNeedOwners(args)) return callWithArgumentOwners(ffiFunc, "callAsync", args, C, finish);
335
285
  return rawAsync.apply(this, args).then((result) => finish(result, args));
336
286
  };
@@ -366,12 +316,12 @@ export function createLibraryClasses(Library, LRUCache, _toNativeType, _toNative
366
316
  // Esponi errcheck come setter/getter
367
317
  errcheck: {
368
318
  get() {
369
- return jsErrcheck;
319
+ return callState.errcheck;
370
320
  },
371
321
  set(callback) {
372
322
  callback = callback ?? null;
373
323
  if (callback !== null && typeof callback !== "function") throw new TypeError("errcheck must be a function or null");
374
- jsErrcheck = callback;
324
+ callState.errcheck = callback;
375
325
  },
376
326
  enumerable: false,
377
327
  configurable: true,
@@ -448,11 +398,17 @@ export function createLibraryClasses(Library, LRUCache, _toNativeType, _toNative
448
398
  * WinDLL - come CDLL ma con stdcall di default (per Windows)
449
399
  */
450
400
  class WinDLL extends CDLL {
451
- _createFunction(name, returnType, argTypes = [], options = {}) {
452
- return super._createFunction(name, returnType, argTypes, {
453
- abi: "stdcall",
454
- ...options,
455
- });
401
+ _createFunction(name, returnType, argTypes = [], options = {}, signature) {
402
+ return super._createFunction(
403
+ name,
404
+ returnType,
405
+ argTypes,
406
+ {
407
+ abi: "stdcall",
408
+ ...options,
409
+ },
410
+ signature,
411
+ );
456
412
  }
457
413
  }
458
414