koffi 2.5.11 → 2.5.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 +75 -70
- package/build/koffi/darwin_arm64/koffi.node +0 -0
- package/build/koffi/darwin_x64/koffi.node +0 -0
- package/build/koffi/freebsd_arm64/koffi.node +0 -0
- package/build/koffi/freebsd_ia32/koffi.node +0 -0
- package/build/koffi/freebsd_x64/koffi.node +0 -0
- package/build/koffi/linux_arm32hf/koffi.node +0 -0
- package/build/koffi/linux_arm64/koffi.node +0 -0
- package/build/koffi/linux_ia32/koffi.node +0 -0
- package/build/koffi/linux_riscv64hf64/koffi.node +0 -0
- package/build/koffi/linux_x64/koffi.node +0 -0
- package/build/koffi/openbsd_ia32/koffi.node +0 -0
- package/build/koffi/openbsd_x64/koffi.node +0 -0
- package/build/koffi/win32_arm64/koffi.node +0 -0
- package/build/koffi/win32_ia32/koffi.node +0 -0
- package/build/koffi/win32_x64/koffi.node +0 -0
- package/doc/callbacks.md +1 -1
- package/doc/conf.py +2 -1
- package/doc/functions.md +11 -0
- package/doc/index.rst +5 -2
- package/doc/{types.md → input.md} +43 -39
- package/doc/migration.md +4 -4
- package/doc/output.md +169 -0
- package/doc/packaging.md +1 -1
- package/doc/pointers.md +52 -2
- package/doc/polymorphism.md +108 -0
- package/package.json +7 -3
- package/src/cnoke/package.json +5 -1
- package/src/core/libcc/libcc.cc +2 -4
- package/src/core/libcc/libcc.hh +4 -1
- package/src/index.js +2 -2
- package/src/koffi/src/call.hh +1 -1
- package/src/koffi/src/ffi.cc +4 -4
- package/src/koffi/src/ffi.hh +1 -1
- package/src/koffi/src/util.cc +1 -1
- package/doc/parameters.md +0 -336
package/CHANGELOG.md
CHANGED
|
@@ -4,16 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
### Koffi 2.5
|
|
6
6
|
|
|
7
|
-
#### Koffi 2.5.
|
|
7
|
+
#### Koffi 2.5.12 (2023-08-21)
|
|
8
8
|
|
|
9
|
-
-
|
|
9
|
+
- Fix native module bundling for FreeBSD ARM64 and Linux RISC-V 64
|
|
10
|
+
- Increase maximum number of parameters to 64
|
|
11
|
+
|
|
12
|
+
#### Koffi 2.5.11 (2023-08-03)
|
|
13
|
+
|
|
14
|
+
- Support casting function pointers with [koffi.as()](polymorphism.md#input-polymorphism)
|
|
10
15
|
- Build in C++20 mode
|
|
11
16
|
|
|
12
|
-
#### Koffi 2.5.10
|
|
17
|
+
#### Koffi 2.5.10 (2023-08-01)
|
|
13
18
|
|
|
14
19
|
- Fix CMake regression when client has to build Koffi
|
|
15
20
|
|
|
16
|
-
#### Koffi 2.5.9
|
|
21
|
+
#### Koffi 2.5.9 (2023-07-28)
|
|
17
22
|
|
|
18
23
|
**Main changes:**
|
|
19
24
|
|
|
@@ -25,43 +30,43 @@
|
|
|
25
30
|
- Add missing unload() export to TS file
|
|
26
31
|
- Add export for koffi.types in TS file
|
|
27
32
|
|
|
28
|
-
#### Koffi 2.5.8
|
|
33
|
+
#### Koffi 2.5.8 (2023-07-26)
|
|
29
34
|
|
|
30
35
|
- Add more search paths for native Koffi modules
|
|
31
36
|
- Add section [about bundling](start.md#bundling-koffi) to documentation
|
|
32
37
|
|
|
33
|
-
#### Koffi 2.5.7
|
|
38
|
+
#### Koffi 2.5.7 (2023-07-19)
|
|
34
39
|
|
|
35
40
|
- Point package to new repository
|
|
36
41
|
|
|
37
|
-
#### Koffi 2.5.6
|
|
42
|
+
#### Koffi 2.5.6 (2023-07-19)
|
|
38
43
|
|
|
39
44
|
- Increase limit of output parameters from 16 to 32
|
|
40
45
|
|
|
41
|
-
#### Koffi 2.5.5
|
|
46
|
+
#### Koffi 2.5.5 (2023-07-17)
|
|
42
47
|
|
|
43
48
|
- Support decoding non-char null-terminated arrays
|
|
44
49
|
|
|
45
|
-
#### Koffi 2.5.4
|
|
50
|
+
#### Koffi 2.5.4 (2023-07-14)
|
|
46
51
|
|
|
47
52
|
- Fix `koffi.pointer()` not accepting disposable types
|
|
48
53
|
- Fix potential issues when making pointers to anonymous types
|
|
49
54
|
|
|
50
|
-
#### Koffi 2.5.3
|
|
55
|
+
#### Koffi 2.5.3 (2023-07-05)
|
|
51
56
|
|
|
52
57
|
- Add missing union exports in TS definition file
|
|
53
58
|
- Fix some parameter names in TS definition file
|
|
54
59
|
|
|
55
|
-
#### Koffi 2.5.2
|
|
60
|
+
#### Koffi 2.5.2 (2023-07-04)
|
|
56
61
|
|
|
57
62
|
- Default initialize unset object/struct members
|
|
58
63
|
|
|
59
|
-
#### Koffi 2.5.1
|
|
64
|
+
#### Koffi 2.5.1 (2023-06-20)
|
|
60
65
|
|
|
61
66
|
- Fix crash with some struct types in System V 64 ABI
|
|
62
67
|
- Always use direct passthrough for buffer arguments
|
|
63
68
|
|
|
64
|
-
#### Koffi 2.5.0
|
|
69
|
+
#### Koffi 2.5.0 (2023-06-20)
|
|
65
70
|
|
|
66
71
|
**New features:**
|
|
67
72
|
|
|
@@ -74,12 +79,12 @@
|
|
|
74
79
|
|
|
75
80
|
### Koffi 2.4
|
|
76
81
|
|
|
77
|
-
#### Koffi 2.4.2
|
|
82
|
+
#### Koffi 2.4.2 (2023-06-04)
|
|
78
83
|
|
|
79
84
|
- Support calling variadic function pointers
|
|
80
85
|
- Add documentation for function pointers
|
|
81
86
|
|
|
82
|
-
#### Koffi 2.4.1
|
|
87
|
+
#### Koffi 2.4.1 (2023-06-03)
|
|
83
88
|
|
|
84
89
|
**Main changes:**
|
|
85
90
|
|
|
@@ -96,49 +101,49 @@
|
|
|
96
101
|
|
|
97
102
|
### Koffi 2.3
|
|
98
103
|
|
|
99
|
-
#### Koffi 2.3.20
|
|
104
|
+
#### Koffi 2.3.20 (2023-05-15)
|
|
100
105
|
|
|
101
106
|
- Support explicit library unloading with `lib.unload()`
|
|
102
107
|
|
|
103
|
-
#### Koffi 2.3.19
|
|
108
|
+
#### Koffi 2.3.19 (2023-04-21)
|
|
104
109
|
|
|
105
110
|
- Actually allow non-ambiguous [string] values for `void *` arguments
|
|
106
111
|
|
|
107
|
-
#### Koffi 2.3.18
|
|
112
|
+
#### Koffi 2.3.18 (2023-04-21)
|
|
108
113
|
|
|
109
114
|
- Fix possible crash on exit caused by unregistered callbacks
|
|
110
115
|
|
|
111
|
-
#### Koffi 2.3.17
|
|
116
|
+
#### Koffi 2.3.17 (2023-04-20)
|
|
112
117
|
|
|
113
118
|
- Allow strings for input `void *`, `int8_t *` and `int16_t *` pointer arguments
|
|
114
119
|
- Support using `[string]` (single-element string arrays) for polymorphic input/output arguments
|
|
115
120
|
|
|
116
|
-
#### Koffi 2.3.16
|
|
121
|
+
#### Koffi 2.3.16 (2023-04-11)
|
|
117
122
|
|
|
118
123
|
- Fix Windows ARM64 build to work with official Node.js version
|
|
119
124
|
- Compile Windows builds with Visual Studio 2022 17.5.3
|
|
120
125
|
- Support null in `koffi.free()` and `koffi.address()`
|
|
121
126
|
|
|
122
|
-
#### Koffi 2.3.15
|
|
127
|
+
#### Koffi 2.3.15 (2023-04-10)
|
|
123
128
|
|
|
124
129
|
- Improve manual decoding of 0-terminated strings
|
|
125
130
|
- Add checks around array conversion hints
|
|
126
131
|
|
|
127
|
-
#### Koffi 2.3.14
|
|
132
|
+
#### Koffi 2.3.14 (2023-04-05)
|
|
128
133
|
|
|
129
134
|
- Add `koffi.errno()` function to get and set current errno value
|
|
130
135
|
- Add `koffi.os.errno` object with valid errno codes
|
|
131
136
|
|
|
132
|
-
#### Koffi 2.3.13
|
|
137
|
+
#### Koffi 2.3.13 (2023-03-30)
|
|
133
138
|
|
|
134
139
|
- Add `koffi.address()` to get the raw value of a wrapper pointer
|
|
135
140
|
|
|
136
|
-
#### Koffi 2.3.12
|
|
141
|
+
#### Koffi 2.3.12 (2023-03-30)
|
|
137
142
|
|
|
138
143
|
- Fix broken syntax in TS definition file
|
|
139
144
|
- Add missing exported properties in TS file
|
|
140
145
|
|
|
141
|
-
#### Koffi 2.3.11
|
|
146
|
+
#### Koffi 2.3.11 (2023-03-30)
|
|
142
147
|
|
|
143
148
|
**Main changes:**
|
|
144
149
|
|
|
@@ -150,27 +155,27 @@
|
|
|
150
155
|
- Avoid using `statx()` to allow compilation with glibc < 2.28
|
|
151
156
|
- Reorganize NPM package files to be less convoluted
|
|
152
157
|
|
|
153
|
-
#### Koffi 2.3.9
|
|
158
|
+
#### Koffi 2.3.9 (2023-03-10)
|
|
154
159
|
|
|
155
160
|
- Relicense under MIT license
|
|
156
161
|
|
|
157
|
-
#### Koffi 2.3.8
|
|
162
|
+
#### Koffi 2.3.8 (2023-02-28)
|
|
158
163
|
|
|
159
164
|
- Disable non-ready union support
|
|
160
165
|
- Simplify Windows stack allocation and drop NOACCESS and GUARD pages
|
|
161
166
|
- Adjust Windows TEB SEH chain and GuaranteedStackBytes for Koffi calls
|
|
162
167
|
|
|
163
|
-
#### Koffi 2.3.7
|
|
168
|
+
#### Koffi 2.3.7 (2023-02-27)
|
|
164
169
|
|
|
165
170
|
- Fix missing require in index.js ([@gastonFrecceroNapse](https://github.com/gastonFrecceroNapse))
|
|
166
171
|
- Reduce NPM package bloat (from 65 MB to 20 MB) caused by changes in 2.3.6
|
|
167
172
|
|
|
168
|
-
#### Koffi 2.3.6
|
|
173
|
+
#### Koffi 2.3.6 (2023-02-26)
|
|
169
174
|
|
|
170
175
|
- Fix broken TS definition file
|
|
171
176
|
- Keep all prebuilt binaries and load correct one at runtime
|
|
172
177
|
|
|
173
|
-
#### Koffi 2.3.5
|
|
178
|
+
#### Koffi 2.3.5 (2023-02-24)
|
|
174
179
|
|
|
175
180
|
**Main fixes:**
|
|
176
181
|
|
|
@@ -186,15 +191,15 @@
|
|
|
186
191
|
- Mark optional properties in TS TypeInfo class
|
|
187
192
|
- Minor performance improvements
|
|
188
193
|
|
|
189
|
-
#### Koffi 2.3.4
|
|
194
|
+
#### Koffi 2.3.4 (2023-01-31)
|
|
190
195
|
|
|
191
196
|
- Fix error when installing Koffi on Windows (2.3.2)
|
|
192
197
|
|
|
193
|
-
#### Koffi 2.3.2
|
|
198
|
+
#### Koffi 2.3.2 (2023-01-30)
|
|
194
199
|
|
|
195
200
|
**Main changes:**
|
|
196
201
|
|
|
197
|
-
- Fix type parser issues (such as ignoring some [disposable qualifiers](
|
|
202
|
+
- Fix type parser issues (such as ignoring some [disposable qualifiers](pointers.md#disposable-types))
|
|
198
203
|
- Fix crash when using disposable types in output parameters
|
|
199
204
|
- Add basic [koffi.stats()](misc.md#usage-statistics) interface
|
|
200
205
|
|
|
@@ -203,18 +208,18 @@
|
|
|
203
208
|
- Avoid CNoke dependency
|
|
204
209
|
- Clear out development dependencies from package.json
|
|
205
210
|
|
|
206
|
-
#### Koffi 2.3.1
|
|
211
|
+
#### Koffi 2.3.1 (2023-01-3O)
|
|
207
212
|
|
|
208
213
|
- Error out when trying to use ambiguous `void *` arguments (input and/or output)
|
|
209
214
|
- Adjust TypeScript definitions ([@insraq](https://github.com/insraq))
|
|
210
215
|
- Fix possible crash when parsing invalid prototype
|
|
211
216
|
|
|
212
|
-
#### Koffi 2.3.0
|
|
217
|
+
#### Koffi 2.3.0 (2023-01-25)
|
|
213
218
|
|
|
214
219
|
**Main changes:**
|
|
215
220
|
|
|
216
221
|
- Allow buffers (TypedArray or ArrayBuffer) values for input and/or output pointer arguments (for polymorphic arguments)
|
|
217
|
-
- Support opaque buffers (TypedArray or ArrayBuffer) values in `koffi.decode()` to [decode output buffers](
|
|
222
|
+
- Support opaque buffers (TypedArray or ArrayBuffer) values in `koffi.decode()` to [decode output buffers](polymorphism.md#output-buffers)
|
|
218
223
|
- Decode non-string types as arrays when an [explicit length is passed to koffi.decode()](callbacks.md#decoding-pointer-arguments)
|
|
219
224
|
|
|
220
225
|
**Other changes:**
|
|
@@ -228,21 +233,21 @@
|
|
|
228
233
|
|
|
229
234
|
### Koffi 2.2
|
|
230
235
|
|
|
231
|
-
#### Koffi 2.2.5
|
|
236
|
+
#### Koffi 2.2.5 (2023-01-23)
|
|
232
237
|
|
|
233
238
|
- Relicense Koffi under LGPL 3.0
|
|
234
239
|
|
|
235
|
-
#### Koffi 2.2.4
|
|
240
|
+
#### Koffi 2.2.4 (2023-01-19)
|
|
236
241
|
|
|
237
242
|
- Fix memory leak on Windows (in Koffi 2.2.3) when running many async calls
|
|
238
243
|
- Reorganize documentation pages
|
|
239
244
|
|
|
240
|
-
#### Koffi 2.2.3
|
|
245
|
+
#### Koffi 2.2.3 (2023-01-17)
|
|
241
246
|
|
|
242
247
|
- Support native code that uses [Structured Exception Handling (SEH)](https://learn.microsoft.com/en-us/cpp/cpp/structured-exception-handling-c-cpp) on Windows (x86, x64 and ARM64)
|
|
243
248
|
- Try to use ebp/rbp as frame pointer in x86/x64 ASM code
|
|
244
249
|
|
|
245
|
-
#### Koffi 2.2.2
|
|
250
|
+
#### Koffi 2.2.2 (2023-01-14)
|
|
246
251
|
|
|
247
252
|
**Main fixes:**
|
|
248
253
|
|
|
@@ -256,16 +261,16 @@
|
|
|
256
261
|
- Check N-API version when module is loaded
|
|
257
262
|
- Optimize callback unregistration
|
|
258
263
|
|
|
259
|
-
#### Koffi 2.2.1
|
|
264
|
+
#### Koffi 2.2.1 (2022-12-21)
|
|
260
265
|
|
|
261
266
|
- Fix crash when [calling callback again after FFI call inside previous callback](https://github.com/Koromix/rygel/issues/15)
|
|
262
267
|
|
|
263
|
-
#### Koffi 2.2.0
|
|
268
|
+
#### Koffi 2.2.0 (2022-12-20)
|
|
264
269
|
|
|
265
270
|
**New features:**
|
|
266
271
|
|
|
267
272
|
- Add [koffi.decode()](callbacks.md#decoding-pointer-arguments) for callback pointer arguments
|
|
268
|
-
- Support transparent [output string parameters](
|
|
273
|
+
- Support transparent [output string parameters](output.md#string-buffer-example)
|
|
269
274
|
- Add `koffi.offsetof()` utility function
|
|
270
275
|
- Support optional *this* binding in `koffi.register()`
|
|
271
276
|
|
|
@@ -276,11 +281,11 @@
|
|
|
276
281
|
|
|
277
282
|
### Koffi 2.1
|
|
278
283
|
|
|
279
|
-
#### Koffi 2.1.5
|
|
284
|
+
#### Koffi 2.1.5 (2022-11-27)
|
|
280
285
|
|
|
281
286
|
- Add missing README.md file to NPM package
|
|
282
287
|
|
|
283
|
-
#### Koffi 2.1.4
|
|
288
|
+
#### Koffi 2.1.4 (2022-11-25)
|
|
284
289
|
|
|
285
290
|
**Main changes:**
|
|
286
291
|
|
|
@@ -291,24 +296,24 @@
|
|
|
291
296
|
|
|
292
297
|
- Moved Koffi to a new repository: https://github.com/Koromix/rygel/
|
|
293
298
|
|
|
294
|
-
#### Koffi 2.1.3
|
|
299
|
+
#### Koffi 2.1.3 (2022-10-31)
|
|
295
300
|
|
|
296
301
|
- Support up to 16 output parameters (instead of 8)
|
|
297
302
|
|
|
298
|
-
#### Koffi 2.1.2
|
|
303
|
+
#### Koffi 2.1.2 (2022-10-31)
|
|
299
304
|
|
|
300
305
|
- Support up to 8 output parameters (instead of 4)
|
|
301
306
|
|
|
302
|
-
#### Koffi 2.1.1
|
|
307
|
+
#### Koffi 2.1.1 (2022-08-16)
|
|
303
308
|
|
|
304
309
|
- Fix potential memory allocation bugs
|
|
305
310
|
|
|
306
|
-
#### Koffi 2.1.0
|
|
311
|
+
#### Koffi 2.1.0 (2022-08-13)
|
|
307
312
|
|
|
308
313
|
**Main changes:**
|
|
309
314
|
|
|
310
|
-
- Add [koffi.as()](
|
|
311
|
-
- Add [endian-sensitive integer types](
|
|
315
|
+
- Add [koffi.as()](polymorphism.md#input-polymorphism) to support polymorphic APIs based on `void *` parameters
|
|
316
|
+
- Add [endian-sensitive integer types](input.md#endian-sensitive-types): `intX_le_t`, `intX_be_t`, `uintX_le_t`, `uintX_be_t`
|
|
312
317
|
- Accept typed arrays for `void *` parameters
|
|
313
318
|
- Introduce `koffi.opaque()` to replace `koffi.handle()` (which remains supported until Koffi 3.0)
|
|
314
319
|
- Support JS Array and TypedArray to fill struct and array pointer members
|
|
@@ -323,15 +328,15 @@
|
|
|
323
328
|
|
|
324
329
|
### Koffi 2.0
|
|
325
330
|
|
|
326
|
-
#### Koffi 2.0.1
|
|
331
|
+
#### Koffi 2.0.1 (2022-07-30)
|
|
327
332
|
|
|
328
333
|
- Return `undefined` (instead of null) for `void` functions
|
|
329
334
|
|
|
330
|
-
#### Koffi 2.0.0
|
|
335
|
+
#### Koffi 2.0.0 (2022-07-29)
|
|
331
336
|
|
|
332
337
|
**Major new features:**
|
|
333
338
|
|
|
334
|
-
- Add [disposable types](
|
|
339
|
+
- Add [disposable types](pointers.md#disposable-types) for automatic disposal of C values (such as heap-allocated strings)
|
|
335
340
|
- Add support for [registered callbacks](callbacks.md#registered-callbacks), that can be called after the initial FFI call
|
|
336
341
|
- Support named pointer types
|
|
337
342
|
- Support complex type specifications outside of prototype parser
|
|
@@ -353,15 +358,15 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
353
358
|
|
|
354
359
|
### Koffi 1.3
|
|
355
360
|
|
|
356
|
-
#### Koffi 1.3.12
|
|
361
|
+
#### Koffi 1.3.12 (2022-07-27)
|
|
357
362
|
|
|
358
363
|
- Fix support for Yarn package manager
|
|
359
364
|
|
|
360
|
-
#### Koffi 1.3.11
|
|
365
|
+
#### Koffi 1.3.11 (2022-07-26)
|
|
361
366
|
|
|
362
367
|
- Fix broken parsing of `void *` when used for first parameter
|
|
363
368
|
|
|
364
|
-
#### Koffi 1.3.10
|
|
369
|
+
#### Koffi 1.3.10 (2022-07-25)
|
|
365
370
|
|
|
366
371
|
**Main fixes:**
|
|
367
372
|
|
|
@@ -373,11 +378,11 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
373
378
|
|
|
374
379
|
- Various documentation fixes and improvements
|
|
375
380
|
|
|
376
|
-
#### Koffi 1.3.9
|
|
381
|
+
#### Koffi 1.3.9 (2022-07-15)
|
|
377
382
|
|
|
378
383
|
- Fix prebuild compatibility with Electron on Windows x64
|
|
379
384
|
|
|
380
|
-
#### Koffi 1.3.8
|
|
385
|
+
#### Koffi 1.3.8 (2022-07-12)
|
|
381
386
|
|
|
382
387
|
**Main changes:**
|
|
383
388
|
|
|
@@ -388,7 +393,7 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
388
393
|
|
|
389
394
|
- Fix and harmonize a few error messages
|
|
390
395
|
|
|
391
|
-
#### Koffi 1.3.7
|
|
396
|
+
#### Koffi 1.3.7 (2022-07-07)
|
|
392
397
|
|
|
393
398
|
**Main fixes:**
|
|
394
399
|
|
|
@@ -401,7 +406,7 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
401
406
|
- Add str/str16 type aliases for string/string16
|
|
402
407
|
- Various documentation fixes and improvements
|
|
403
408
|
|
|
404
|
-
#### Koffi 1.3.6
|
|
409
|
+
#### Koffi 1.3.6 (2022-07-01)
|
|
405
410
|
|
|
406
411
|
**Main fixes:**
|
|
407
412
|
|
|
@@ -413,7 +418,7 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
413
418
|
- Prebuild with Clang for Windows x64 and Linux x64 binaries
|
|
414
419
|
- Various documentation improvements
|
|
415
420
|
|
|
416
|
-
#### Koffi 1.3.5
|
|
421
|
+
#### Koffi 1.3.5 (2022-06-25)
|
|
417
422
|
|
|
418
423
|
**Main changes:**
|
|
419
424
|
|
|
@@ -425,11 +430,11 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
425
430
|
- Reduce default async memory stack and heap size
|
|
426
431
|
- Various documentation improvements
|
|
427
432
|
|
|
428
|
-
#### Koffi 1.3.4
|
|
433
|
+
#### Koffi 1.3.4 (2022-06-24)
|
|
429
434
|
|
|
430
435
|
- Fix possible OpenBSD i386 crash with `(void)` functions
|
|
431
436
|
|
|
432
|
-
#### Koffi 1.3.3
|
|
437
|
+
#### Koffi 1.3.3 (2022-06-24)
|
|
433
438
|
|
|
434
439
|
**Main fixes:**
|
|
435
440
|
|
|
@@ -441,16 +446,16 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
441
446
|
- Disable unsafe compiler optimizations
|
|
442
447
|
- Various documentation improvements
|
|
443
448
|
|
|
444
|
-
#### Koffi 1.3.2
|
|
449
|
+
#### Koffi 1.3.2 (2022-06-23)
|
|
445
450
|
|
|
446
451
|
- Support compilation in C++14 mode (graceful degradation)
|
|
447
452
|
- Support older toolchains on Linux (tested on Debian 9)
|
|
448
453
|
|
|
449
|
-
#### Koffi 1.3.1
|
|
454
|
+
#### Koffi 1.3.1 (2022-06-22)
|
|
450
455
|
|
|
451
456
|
- The prebuilt binary is tested when Koffi is installed, and a rebuild happens if it fails to load
|
|
452
457
|
|
|
453
|
-
#### Koffi 1.3.0
|
|
458
|
+
#### Koffi 1.3.0 (2022-06-22)
|
|
454
459
|
|
|
455
460
|
**Major changes:**
|
|
456
461
|
|
|
@@ -468,15 +473,15 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
468
473
|
|
|
469
474
|
### Koffi 1.2
|
|
470
475
|
|
|
471
|
-
#### Koffi 1.2.4
|
|
476
|
+
#### Koffi 1.2.4 (2022-06-12)
|
|
472
477
|
|
|
473
478
|
- Windows ARM64 is now supported
|
|
474
479
|
|
|
475
|
-
#### Koffi 1.2.3
|
|
480
|
+
#### Koffi 1.2.3 (2022-06-11)
|
|
476
481
|
|
|
477
482
|
- A prebuilt binary for macOS ARM64 (M1) is now included
|
|
478
483
|
|
|
479
|
-
#### Koffi 1.2.1
|
|
484
|
+
#### Koffi 1.2.1 (2022-06-11)
|
|
480
485
|
|
|
481
486
|
This entry documents changes since version 1.1.0.
|
|
482
487
|
|
|
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
|
package/doc/callbacks.md
CHANGED
package/doc/conf.py
CHANGED
package/doc/functions.md
CHANGED
|
@@ -217,3 +217,14 @@ let delta = substract(100, 58);
|
|
|
217
217
|
|
|
218
218
|
console.log(sum, delta); // Prints 9 and 42
|
|
219
219
|
```
|
|
220
|
+
|
|
221
|
+
## Conversion of parameters
|
|
222
|
+
|
|
223
|
+
By default, Koffi will only forward and translate arguments from Javascript to C. However, many C functions use pointer arguments for output values, or input/output values.
|
|
224
|
+
|
|
225
|
+
Among other thing, in the the following pages you will learn more about:
|
|
226
|
+
|
|
227
|
+
- How Koffi translates [input parameters](input.md) to C
|
|
228
|
+
- How you can [define and use pointers](pointers.md)
|
|
229
|
+
- How to deal with [output parameters](output.md)
|
|
230
|
+
- How to handle [polymorphic API](polymorphism.md)
|
package/doc/index.rst
CHANGED
|
@@ -15,6 +15,8 @@ Koffi requires a recent `Node.js <https://nodejs.org/>`_ version with N-API vers
|
|
|
15
15
|
|
|
16
16
|
The source code is available here: https://github.com/Koromix/rygel/ (in the *src/koffi* subdirectory).
|
|
17
17
|
|
|
18
|
+
New releases are frequent, look at the :ref:`changelog<changelog>` for more information.
|
|
19
|
+
|
|
18
20
|
Table of contents
|
|
19
21
|
-----------------
|
|
20
22
|
|
|
@@ -24,10 +26,11 @@ Table of contents
|
|
|
24
26
|
platforms
|
|
25
27
|
start
|
|
26
28
|
functions
|
|
27
|
-
|
|
29
|
+
input
|
|
28
30
|
pointers
|
|
31
|
+
output
|
|
32
|
+
polymorphism
|
|
29
33
|
unions
|
|
30
|
-
parameters
|
|
31
34
|
callbacks
|
|
32
35
|
misc
|
|
33
36
|
packaging
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Input parameters
|
|
2
2
|
|
|
3
3
|
## Primitive types
|
|
4
4
|
|
|
@@ -6,47 +6,47 @@
|
|
|
6
6
|
|
|
7
7
|
While the C standard allows for variation in the size of most integer types, Koffi enforces the same definition for most primitive types, listed below:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Undefined |
|
|
12
|
-
Number (integer) |
|
|
13
|
-
Number (integer) |
|
|
14
|
-
Number (integer) |
|
|
15
|
-
|
|
16
|
-
Number (integer) |
|
|
17
|
-
Number (integer) |
|
|
18
|
-
Number (integer) |
|
|
19
|
-
Number (integer) |
|
|
20
|
-
|
|
21
|
-
Number (integer) |
|
|
22
|
-
Number (integer) |
|
|
23
|
-
Number (integer) |
|
|
24
|
-
|
|
25
|
-
Number (integer) |
|
|
26
|
-
Number (integer) |
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Number (float) |
|
|
30
|
-
Number (float) |
|
|
31
|
-
Number (float) |
|
|
32
|
-
Number (float) |
|
|
9
|
+
C type | JS type | Bytes | Signedness | Note
|
|
10
|
+
----------------------------- | ---------------- | ----- | ---------- | ---------------------------
|
|
11
|
+
void | Undefined | 0 | | Only valid as a return type
|
|
12
|
+
int8, int8_t | Number (integer) | 1 | Signed |
|
|
13
|
+
uint8, uint8_t | Number (integer) | 1 | Unsigned |
|
|
14
|
+
char | Number (integer) | 1 | Signed |
|
|
15
|
+
uchar, unsigned char | Number (integer) | 1 | Unsigned |
|
|
16
|
+
char16, char16_t | Number (integer) | 2 | Signed |
|
|
17
|
+
int16, int16_t | Number (integer) | 2 | Signed |
|
|
18
|
+
uint16, uint16_t | Number (integer) | 2 | Unsigned |
|
|
19
|
+
short | Number (integer) | 2 | Signed |
|
|
20
|
+
ushort, unsigned short | Number (integer) | 2 | Unsigned |
|
|
21
|
+
int32, int32_t | Number (integer) | 4 | Signed |
|
|
22
|
+
uint32, uint32_t | Number (integer) | 4 | Unsigned |
|
|
23
|
+
int | Number (integer) | 4 | Signed |
|
|
24
|
+
uint, unsigned int | Number (integer) | 4 | Unsigned |
|
|
25
|
+
int64, int64_t | Number (integer) | 8 | Signed |
|
|
26
|
+
uint64, uint64_t | Number (integer) | 8 | Unsigned |
|
|
27
|
+
longlong, long long | Number (integer) | 8 | Signed |
|
|
28
|
+
ulonglong, unsigned long long | Number (integer) | 8 | Unsigned |
|
|
29
|
+
float32 | Number (float) | 4 | |
|
|
30
|
+
float64 | Number (float) | 8 | |
|
|
31
|
+
float | Number (float) | 4 | |
|
|
32
|
+
double | Number (float) | 8 | |
|
|
33
33
|
|
|
34
34
|
Koffi also accepts BigInt values when converting from JS to C integers. If the value exceeds the range of the C type, Koffi will convert the number to an undefined value. In the reverse direction, BigInt values are automatically used when needed for big 64-bit integers.
|
|
35
35
|
|
|
36
36
|
Koffi defines a few more types that can change size depending on the OS and the architecture:
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
C type | JS type | Signedness | Note
|
|
39
39
|
---------------- | ---------------- | ---------- | ------------------------------------------------
|
|
40
|
-
Boolean |
|
|
41
|
-
Number (integer) |
|
|
42
|
-
Number (integer) |
|
|
43
|
-
Number (integer) |
|
|
44
|
-
Number (integer) |
|
|
45
|
-
Number (integer) |
|
|
46
|
-
Number (integer) |
|
|
47
|
-
Number (integer) |
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
bool | Boolean | | Usually one byte
|
|
41
|
+
long | Number (integer) | Signed | 4 or 8 bytes depending on platform (LP64, LLP64)
|
|
42
|
+
ulong | Number (integer) | Unsigned | 4 or 8 bytes depending on platform (LP64, LLP64)
|
|
43
|
+
unsigned long | Number (integer) | Unsigned | 4 or 8 bytes depending on platform (LP64, LLP64)
|
|
44
|
+
intptr | Number (integer) | Signed | 4 or 8 bytes depending on register width
|
|
45
|
+
intptr_t | Number (integer) | Signed | 4 or 8 bytes depending on register width
|
|
46
|
+
uintptr | Number (integer) | Unsigned | 4 or 8 bytes depending on register width
|
|
47
|
+
uintptr_t | Number (integer) | Unsigned | 4 or 8 bytes depending on register width
|
|
48
|
+
str, string | String | | JS strings are converted to and from UTF-8
|
|
49
|
+
str16, string16 | String | | JS strings are converted to and from UTF-16 (LE)
|
|
50
50
|
|
|
51
51
|
Primitive types can be specified by name (in a string) or through `koffi.types`:
|
|
52
52
|
|
|
@@ -142,14 +142,14 @@ const Function2 = lib.func('Function', A, [A]);
|
|
|
142
142
|
|
|
143
143
|
Many C libraries use some kind of object-oriented API, with a pair of functions dedicated to create and delete objects. An obvious example of this can be found in stdio.h, with the opaque `FILE *` pointer. You can open and close files with `fopen()` and `fclose()`, and manipule the opaque pointer with other functions such as `fread()` or `ftell()`.
|
|
144
144
|
|
|
145
|
-
In Koffi, you can manage this with opaque types. Declare the opaque type with `koffi.opaque(name)`, and use a pointer to this type either as a return type or some kind of [output parameter](
|
|
145
|
+
In Koffi, you can manage this with opaque types. Declare the opaque type with `koffi.opaque(name)`, and use a pointer to this type either as a return type or some kind of [output parameter](output.md) (with a double pointer).
|
|
146
146
|
|
|
147
147
|
```{note}
|
|
148
148
|
Opaque types **have changed in version 2.0, and again in version 2.1**.
|
|
149
149
|
|
|
150
150
|
In Koffi 1.x, opaque handles were defined in a way that made them usable directly as parameter and return types, obscuring the underlying pointer.
|
|
151
151
|
|
|
152
|
-
Now, you must use them through a pointer, and use an array for output parameters. This is shown in the example below (look for the call to `ConcatNewOut` in the JS part), and is described in the section on [output parameters](
|
|
152
|
+
Now, you must use them through a pointer, and use an array for output parameters. This is shown in the example below (look for the call to `ConcatNewOut` in the JS part), and is described in the section on [output parameters](output.md).
|
|
153
153
|
|
|
154
154
|
In addition to this, you should use `koffi.opaque()` (introduced in Koffi 2.1) instead of `koffi.handle()` which is deprecated, and will be removed eventually in Koffi 3.0.
|
|
155
155
|
|
|
@@ -376,6 +376,10 @@ Koffi can also convert JS strings to fixed-sized arrays in the following cases:
|
|
|
376
376
|
|
|
377
377
|
The reverse case is also true, Koffi can convert a C fixed-size buffer to a JS string. This happens by default for char, char16 and char16_t arrays, but you can also explicitly ask for this with the `String` array hint (e.g. `koffi.array('char', 8, 'String')`).
|
|
378
378
|
|
|
379
|
-
###
|
|
379
|
+
### Dynamic arrays (pointers)
|
|
380
380
|
|
|
381
381
|
In C, dynamically-sized arrays are usually passed around as pointers. Read more about [array pointers](pointers.md#array-pointers-dynamic-arrays) in the relevant section.
|
|
382
|
+
|
|
383
|
+
## Union types
|
|
384
|
+
|
|
385
|
+
The declaration and use of [unions types](unions.md) will be explained in a later section, they are only briefly mentioned here if you need them.
|