koffi 2.5.1 → 2.5.3

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 (27) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/build/2.5.3/koffi_darwin_arm64/koffi.node +0 -0
  3. package/build/{2.5.1 → 2.5.3}/koffi_darwin_x64/koffi.node +0 -0
  4. package/build/{2.5.1 → 2.5.3}/koffi_freebsd_arm64/koffi.node +0 -0
  5. package/build/{2.5.1 → 2.5.3}/koffi_freebsd_ia32/koffi.node +0 -0
  6. package/build/{2.5.1 → 2.5.3}/koffi_freebsd_x64/koffi.node +0 -0
  7. package/build/{2.5.1 → 2.5.3}/koffi_linux_arm32hf/koffi.node +0 -0
  8. package/build/{2.5.1 → 2.5.3}/koffi_linux_arm64/koffi.node +0 -0
  9. package/build/{2.5.1 → 2.5.3}/koffi_linux_ia32/koffi.node +0 -0
  10. package/build/{2.5.1 → 2.5.3}/koffi_linux_riscv64hf64/koffi.node +0 -0
  11. package/build/{2.5.1 → 2.5.3}/koffi_linux_x64/koffi.node +0 -0
  12. package/build/{2.5.1 → 2.5.3}/koffi_openbsd_ia32/koffi.node +0 -0
  13. package/build/{2.5.1 → 2.5.3}/koffi_openbsd_x64/koffi.node +0 -0
  14. package/build/2.5.3/koffi_win32_arm64/koffi.node +0 -0
  15. package/build/{2.5.1 → 2.5.3}/koffi_win32_ia32/koffi.node +0 -0
  16. package/build/{2.5.1 → 2.5.3}/koffi_win32_x64/koffi.node +0 -0
  17. package/package.json +2 -2
  18. package/src/index.d.ts +12 -7
  19. package/src/koffi/src/call.cc +4 -4
  20. package/build/2.5.1/koffi_darwin_arm64/koffi.node +0 -0
  21. package/build/2.5.1/koffi_win32_arm64/koffi.node +0 -0
  22. /package/build/{2.5.1 → 2.5.3}/koffi_win32_arm64/koffi.exp +0 -0
  23. /package/build/{2.5.1 → 2.5.3}/koffi_win32_arm64/koffi.lib +0 -0
  24. /package/build/{2.5.1 → 2.5.3}/koffi_win32_ia32/koffi.exp +0 -0
  25. /package/build/{2.5.1 → 2.5.3}/koffi_win32_ia32/koffi.lib +0 -0
  26. /package/build/{2.5.1 → 2.5.3}/koffi_win32_x64/koffi.exp +0 -0
  27. /package/build/{2.5.1 → 2.5.3}/koffi_win32_x64/koffi.lib +0 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@
4
4
 
5
5
  ### Koffi 2.5
6
6
 
7
+ #### Koffi 2.5.3
8
+
9
+ **Main changes:**
10
+
11
+ - Add missing union exports in TS definition file
12
+ - Fix some parameter names in TS definition file
13
+
14
+ #### Koffi 2.5.2
15
+
16
+ **Main changes:**
17
+
18
+ - Default initialize unset object/struct members
19
+
7
20
  #### Koffi 2.5.1
8
21
 
9
22
  **Main changes:**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.5.1",
4
- "stable": "2.5.1",
3
+ "version": "2.5.3",
4
+ "stable": "2.5.3",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
package/src/index.d.ts CHANGED
@@ -86,8 +86,13 @@ declare module 'koffi' {
86
86
  export function pack(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
87
87
  export function pack(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
88
88
 
89
- // export function union(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
90
- // export function union(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
89
+ export function union(name: string, def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
90
+ export function union(def: Record<string, TypeSpecWithAlignment>): IKoffiCType;
91
+
92
+ export class Union {
93
+ constructor(type: TypeSpec);
94
+ [s: string]: any;
95
+ }
91
96
 
92
97
  export function array(ref: TypeSpec, len: number, hint?: ArrayHint | null): IKoffiCType;
93
98
 
@@ -96,12 +101,12 @@ declare module 'koffi' {
96
101
  /** @deprecated */ export function handle(name: string): IKoffiCType;
97
102
  /** @deprecated */ export function handle(): IKoffiCType;
98
103
 
99
- export function pointer(value: TypeSpec): IKoffiCType;
100
- export function pointer(value: TypeSpec, asteriskCount: number): IKoffiCType;
101
- export function pointer(name: string, value: TypeSpec, asteriskCount: number): IKoffiCType;
104
+ export function pointer(ref: TypeSpec): IKoffiCType;
105
+ export function pointer(ref: TypeSpec, asteriskCount: number): IKoffiCType;
106
+ export function pointer(name: string, ref: TypeSpec, asteriskCount: number): IKoffiCType;
102
107
 
103
- export function out(value: TypeSpec): IKoffiCType;
104
- export function inout(value: TypeSpec): IKoffiCType;
108
+ export function out(type: TypeSpec): IKoffiCType;
109
+ export function inout(type: TypeSpec): IKoffiCType;
105
110
 
106
111
  export function disposable(type: TypeSpec): IKoffiCType;
107
112
  export function disposable(name: string, type: TypeSpec): IKoffiCType;
@@ -405,14 +405,14 @@ bool CallData::PushObject(Napi::Object obj, const TypeInfo *type, uint8_t *origi
405
405
  RG_UNREACHABLE();
406
406
  }
407
407
 
408
+ memset(origin, 0, type->size);
409
+
408
410
  for (Size i = 0; i < members.len; i++) {
409
411
  const RecordMember &member = members[i];
410
412
  Napi::Value value = obj.Get(member.name);
411
413
 
412
- if (value.IsUndefined()) [[unlikely]] {
413
- ThrowError<Napi::TypeError>(env, "Missing expected object property '%1'", member.name);
414
- return false;
415
- }
414
+ if (value.IsUndefined())
415
+ continue;
416
416
 
417
417
  uint8_t *dest = origin + member.offset;
418
418