koffi 3.0.0-alpha.10 → 3.0.0-alpha.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 (36) hide show
  1. package/build/koffi/darwin_arm64/koffi.node +0 -0
  2. package/build/koffi/darwin_x64/koffi.node +0 -0
  3. package/build/koffi/freebsd_arm64/koffi.node +0 -0
  4. package/build/koffi/freebsd_ia32/koffi.node +0 -0
  5. package/build/koffi/freebsd_x64/koffi.node +0 -0
  6. package/build/koffi/linux_arm64/koffi.node +0 -0
  7. package/build/koffi/linux_ia32/koffi.node +0 -0
  8. package/build/koffi/linux_loong64/koffi.node +0 -0
  9. package/build/koffi/linux_riscv64d/koffi.node +0 -0
  10. package/build/koffi/linux_x64/koffi.node +0 -0
  11. package/build/koffi/musl_arm64/koffi.node +0 -0
  12. package/build/koffi/musl_x64/koffi.node +0 -0
  13. package/build/koffi/openbsd_ia32/koffi.node +0 -0
  14. package/build/koffi/openbsd_x64/koffi.node +0 -0
  15. package/build/koffi/win32_ia32/koffi.node +0 -0
  16. package/build/koffi/win32_x64/koffi.node +0 -0
  17. package/index.d.ts +3 -7
  18. package/package.json +1 -1
  19. package/src/koffi/index.cjs +22 -1
  20. package/src/koffi/index.js +22 -1
  21. package/src/koffi/indirect.cjs +22 -1
  22. package/src/koffi/indirect.js +10 -1
  23. package/src/koffi/src/abi/arm64.cc +47 -141
  24. package/src/koffi/src/abi/loong64_asm.S +50 -50
  25. package/src/koffi/src/abi/riscv64.cc +1006 -567
  26. package/src/koffi/src/abi/riscv64_asm.S +50 -50
  27. package/src/koffi/src/abi/x64sysv.cc +73 -84
  28. package/src/koffi/src/abi/x64win.cc +46 -70
  29. package/src/koffi/src/abi/x86.cc +46 -88
  30. package/src/koffi/src/abi/x86_asm.S +2 -2
  31. package/src/koffi/src/call.cc +651 -53
  32. package/src/koffi/src/call.hh +25 -1
  33. package/src/koffi/src/ffi.cc +307 -572
  34. package/src/koffi/src/ffi.hh +35 -38
  35. package/src/koffi/src/util.cc +97 -96
  36. package/src/koffi/src/util.hh +65 -49
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
package/index.d.ts CHANGED
@@ -43,10 +43,6 @@ export type KoffiFunc<T extends (...args: any) => any> = T & {
43
43
  info: PrototypeInfo;
44
44
  };
45
45
 
46
- export type CallbackHandle = {
47
- [Symbol.dispose](): void;
48
- };
49
-
50
46
  type LoadOptions = {
51
47
  lazy?: boolean,
52
48
  global?: boolean,
@@ -120,9 +116,9 @@ export function proto(convention: string, result: TypeSpec, arguments: TypeSpec[
120
116
  export function proto(name: string | null | undefined, result: TypeSpec, arguments: TypeSpec[]): TypeObject;
121
117
  export function proto(convention: string, name: string | null | undefined, result: TypeSpec, arguments: TypeSpec[]): TypeObject;
122
118
 
123
- export function register(callback: Function, type: TypeSpec): CallbackHandle;
124
- export function register(thisValue: any, callback: Function, type: TypeSpec): CallbackHandle;
125
- export function unregister(callback: CallbackHandle): void;
119
+ export function register(callback: Function, type: TypeSpec): bigint;
120
+ /** @deprecated */ export function register(thisValue: any, callback: Function, type: TypeSpec): bigint;
121
+ export function unregister(callback: bigint): void;
126
122
 
127
123
  export function as(value: any, type: TypeSpec): IKoffiPointerCast;
128
124
  export function decode(value: any, type: TypeSpec): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "3.0.0-alpha.10",
3
+ "version": "3.0.0-alpha.11",
4
4
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
5
5
  "keywords": [
6
6
  "foreign",
@@ -131,7 +131,7 @@ var init_abi = __esm({
131
131
  var package_default;
132
132
  var init_package = __esm({
133
133
  "package.json"() {
134
- package_default = { name: "koffi", version: "3.0.0-alpha.10", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
134
+ package_default = { name: "koffi", version: "3.0.0-alpha.11", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
135
135
  }
136
136
  });
137
137
 
@@ -184,6 +184,7 @@ function loadDynamic(root, pkg2, triplets2) {
184
184
  }
185
185
  function wrapNative(native2) {
186
186
  let load = native2.load;
187
+ let register = native2.register;
187
188
  native2.sizeof = (spec) => native2.type(spec).size;
188
189
  native2.alignof = (spec) => native2.type(spec).alignment;
189
190
  native2.offsetof = (spec, name) => {
@@ -195,6 +196,14 @@ function wrapNative(native2) {
195
196
  throw new Error(`Record type ${type.name} does not have member '${name}'`);
196
197
  return member.offset;
197
198
  };
199
+ native2.register = (...args) => {
200
+ if (args.length >= 3 && typeof args[1] == "function") {
201
+ process.emitWarning("Using koffi.register() with a custom this value was deprecated in Koffi 3.0, use function.bind() instead", "Warning", "KOFFI009");
202
+ args[1] = args[1].bind(args[0]);
203
+ args = args.slice(1);
204
+ }
205
+ return register(...args);
206
+ };
198
207
  native2.resolve = import_node_util.default.deprecate(native2.type, "The koffi.resolve() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI007");
199
208
  native2.introspect = import_node_util.default.deprecate(native2.type, "The koffi.introspect() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI008");
200
209
  native2.load = (...args) => {
@@ -256,6 +265,12 @@ var require_static = __commonJS({
256
265
  } catch (err) {
257
266
  }
258
267
  }
268
+ if (native2 == null && pkg2 == "linux-riscv64d") {
269
+ try {
270
+ native2 = requireNative2("../../build/koffi/linux_riscv64d/koffi.node");
271
+ } catch (err) {
272
+ }
273
+ }
259
274
  if (native2 == null && pkg2 == "freebsd-ia32") {
260
275
  try {
261
276
  native2 = requireNative2("../../build/koffi/freebsd_ia32/koffi.node");
@@ -310,6 +325,12 @@ var require_static = __commonJS({
310
325
  } catch (err) {
311
326
  }
312
327
  }
328
+ if (native2 == null && pkg2 == "linux-loong64") {
329
+ try {
330
+ native2 = requireNative2("../../build/koffi/linux_loong64/koffi.node");
331
+ } catch (err) {
332
+ }
333
+ }
313
334
  return native2;
314
335
  }
315
336
  module2.exports = {
@@ -94,7 +94,7 @@ function decodeElfHeader(buf) {
94
94
  }
95
95
 
96
96
  // package.json
97
- var package_default = { name: "koffi", version: "3.0.0-alpha.10", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
97
+ var package_default = { name: "koffi", version: "3.0.0-alpha.11", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
98
98
 
99
99
  // src/init.js
100
100
  var requireNative = createRequire(import.meta.url);
@@ -140,6 +140,7 @@ function loadDynamic(root, pkg2, triplets2) {
140
140
  }
141
141
  function wrapNative(native2) {
142
142
  let load = native2.load;
143
+ let register = native2.register;
143
144
  native2.sizeof = (spec) => native2.type(spec).size;
144
145
  native2.alignof = (spec) => native2.type(spec).alignment;
145
146
  native2.offsetof = (spec, name) => {
@@ -151,6 +152,14 @@ function wrapNative(native2) {
151
152
  throw new Error(`Record type ${type.name} does not have member '${name}'`);
152
153
  return member.offset;
153
154
  };
155
+ native2.register = (...args) => {
156
+ if (args.length >= 3 && typeof args[1] == "function") {
157
+ process.emitWarning("Using koffi.register() with a custom this value was deprecated in Koffi 3.0, use function.bind() instead", "Warning", "KOFFI009");
158
+ args[1] = args[1].bind(args[0]);
159
+ args = args.slice(1);
160
+ }
161
+ return register(...args);
162
+ };
154
163
  native2.resolve = util.deprecate(native2.type, "The koffi.resolve() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI007");
155
164
  native2.introspect = util.deprecate(native2.type, "The koffi.introspect() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI008");
156
165
  native2.load = (...args) => {
@@ -199,6 +208,12 @@ function loadStatic(pkg2) {
199
208
  } catch (err) {
200
209
  }
201
210
  }
211
+ if (native2 == null && pkg2 == "linux-riscv64d") {
212
+ try {
213
+ native2 = requireNative2("../../build/koffi/linux_riscv64d/koffi.node");
214
+ } catch (err) {
215
+ }
216
+ }
202
217
  if (native2 == null && pkg2 == "freebsd-ia32") {
203
218
  try {
204
219
  native2 = requireNative2("../../build/koffi/freebsd_ia32/koffi.node");
@@ -253,6 +268,12 @@ function loadStatic(pkg2) {
253
268
  } catch (err) {
254
269
  }
255
270
  }
271
+ if (native2 == null && pkg2 == "linux-loong64") {
272
+ try {
273
+ native2 = requireNative2("../../build/koffi/linux_loong64/koffi.node");
274
+ } catch (err) {
275
+ }
276
+ }
256
277
  return native2;
257
278
  }
258
279
 
@@ -131,7 +131,7 @@ var init_abi = __esm({
131
131
  var package_default;
132
132
  var init_package = __esm({
133
133
  "package.json"() {
134
- package_default = { name: "koffi", version: "3.0.0-alpha.10", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
134
+ package_default = { name: "koffi", version: "3.0.0-alpha.11", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
135
135
  }
136
136
  });
137
137
 
@@ -184,6 +184,7 @@ function loadDynamic(root, pkg2, triplets2) {
184
184
  }
185
185
  function wrapNative(native2) {
186
186
  let load = native2.load;
187
+ let register = native2.register;
187
188
  native2.sizeof = (spec) => native2.type(spec).size;
188
189
  native2.alignof = (spec) => native2.type(spec).alignment;
189
190
  native2.offsetof = (spec, name) => {
@@ -195,6 +196,14 @@ function wrapNative(native2) {
195
196
  throw new Error(`Record type ${type.name} does not have member '${name}'`);
196
197
  return member.offset;
197
198
  };
199
+ native2.register = (...args) => {
200
+ if (args.length >= 3 && typeof args[1] == "function") {
201
+ process.emitWarning("Using koffi.register() with a custom this value was deprecated in Koffi 3.0, use function.bind() instead", "Warning", "KOFFI009");
202
+ args[1] = args[1].bind(args[0]);
203
+ args = args.slice(1);
204
+ }
205
+ return register(...args);
206
+ };
198
207
  native2.resolve = import_node_util.default.deprecate(native2.type, "The koffi.resolve() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI007");
199
208
  native2.introspect = import_node_util.default.deprecate(native2.type, "The koffi.introspect() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI008");
200
209
  native2.load = (...args) => {
@@ -256,6 +265,12 @@ var require_static = __commonJS({
256
265
  } catch (err) {
257
266
  }
258
267
  }
268
+ if (native2 == null && pkg2 == "linux-riscv64d") {
269
+ try {
270
+ native2 = requireNative2("../../build/koffi/linux_riscv64d/koffi.node");
271
+ } catch (err) {
272
+ }
273
+ }
259
274
  if (native2 == null && pkg2 == "freebsd-ia32") {
260
275
  try {
261
276
  native2 = requireNative2("../../build/koffi/freebsd_ia32/koffi.node");
@@ -310,6 +325,12 @@ var require_static = __commonJS({
310
325
  } catch (err) {
311
326
  }
312
327
  }
328
+ if (native2 == null && pkg2 == "linux-loong64") {
329
+ try {
330
+ native2 = requireNative2("../../build/koffi/linux_loong64/koffi.node");
331
+ } catch (err) {
332
+ }
333
+ }
313
334
  return native2;
314
335
  }
315
336
  module2.exports = {
@@ -94,7 +94,7 @@ function decodeElfHeader(buf) {
94
94
  }
95
95
 
96
96
  // package.json
97
- var package_default = { name: "koffi", version: "3.0.0-alpha.10", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
97
+ var package_default = { name: "koffi", version: "3.0.0-alpha.11", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
98
98
 
99
99
  // src/init.js
100
100
  var requireNative = createRequire(import.meta.url);
@@ -140,6 +140,7 @@ function loadDynamic(root, pkg2, triplets2) {
140
140
  }
141
141
  function wrapNative(native2) {
142
142
  let load = native2.load;
143
+ let register = native2.register;
143
144
  native2.sizeof = (spec) => native2.type(spec).size;
144
145
  native2.alignof = (spec) => native2.type(spec).alignment;
145
146
  native2.offsetof = (spec, name) => {
@@ -151,6 +152,14 @@ function wrapNative(native2) {
151
152
  throw new Error(`Record type ${type.name} does not have member '${name}'`);
152
153
  return member.offset;
153
154
  };
155
+ native2.register = (...args) => {
156
+ if (args.length >= 3 && typeof args[1] == "function") {
157
+ process.emitWarning("Using koffi.register() with a custom this value was deprecated in Koffi 3.0, use function.bind() instead", "Warning", "KOFFI009");
158
+ args[1] = args[1].bind(args[0]);
159
+ args = args.slice(1);
160
+ }
161
+ return register(...args);
162
+ };
154
163
  native2.resolve = util.deprecate(native2.type, "The koffi.resolve() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI007");
155
164
  native2.introspect = util.deprecate(native2.type, "The koffi.introspect() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI008");
156
165
  native2.load = (...args) => {