koffi 2.5.10 → 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 +78 -68
- 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 +114 -4
- package/src/core/libcc/libcc.hh +44 -16
- package/src/index.js +2 -2
- package/src/koffi/CMakeLists.txt +1 -1
- package/src/koffi/src/call.cc +16 -6
- package/src/koffi/src/call.hh +1 -1
- package/src/koffi/src/ffi.cc +6 -5
- 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,11 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
### Koffi 2.5
|
|
6
6
|
|
|
7
|
-
#### Koffi 2.5.
|
|
7
|
+
#### Koffi 2.5.12 (2023-08-21)
|
|
8
|
+
|
|
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)
|
|
15
|
+
- Build in C++20 mode
|
|
16
|
+
|
|
17
|
+
#### Koffi 2.5.10 (2023-08-01)
|
|
8
18
|
|
|
9
19
|
- Fix CMake regression when client has to build Koffi
|
|
10
20
|
|
|
11
|
-
#### Koffi 2.5.9
|
|
21
|
+
#### Koffi 2.5.9 (2023-07-28)
|
|
12
22
|
|
|
13
23
|
**Main changes:**
|
|
14
24
|
|
|
@@ -20,43 +30,43 @@
|
|
|
20
30
|
- Add missing unload() export to TS file
|
|
21
31
|
- Add export for koffi.types in TS file
|
|
22
32
|
|
|
23
|
-
#### Koffi 2.5.8
|
|
33
|
+
#### Koffi 2.5.8 (2023-07-26)
|
|
24
34
|
|
|
25
35
|
- Add more search paths for native Koffi modules
|
|
26
36
|
- Add section [about bundling](start.md#bundling-koffi) to documentation
|
|
27
37
|
|
|
28
|
-
#### Koffi 2.5.7
|
|
38
|
+
#### Koffi 2.5.7 (2023-07-19)
|
|
29
39
|
|
|
30
40
|
- Point package to new repository
|
|
31
41
|
|
|
32
|
-
#### Koffi 2.5.6
|
|
42
|
+
#### Koffi 2.5.6 (2023-07-19)
|
|
33
43
|
|
|
34
44
|
- Increase limit of output parameters from 16 to 32
|
|
35
45
|
|
|
36
|
-
#### Koffi 2.5.5
|
|
46
|
+
#### Koffi 2.5.5 (2023-07-17)
|
|
37
47
|
|
|
38
48
|
- Support decoding non-char null-terminated arrays
|
|
39
49
|
|
|
40
|
-
#### Koffi 2.5.4
|
|
50
|
+
#### Koffi 2.5.4 (2023-07-14)
|
|
41
51
|
|
|
42
52
|
- Fix `koffi.pointer()` not accepting disposable types
|
|
43
53
|
- Fix potential issues when making pointers to anonymous types
|
|
44
54
|
|
|
45
|
-
#### Koffi 2.5.3
|
|
55
|
+
#### Koffi 2.5.3 (2023-07-05)
|
|
46
56
|
|
|
47
57
|
- Add missing union exports in TS definition file
|
|
48
58
|
- Fix some parameter names in TS definition file
|
|
49
59
|
|
|
50
|
-
#### Koffi 2.5.2
|
|
60
|
+
#### Koffi 2.5.2 (2023-07-04)
|
|
51
61
|
|
|
52
62
|
- Default initialize unset object/struct members
|
|
53
63
|
|
|
54
|
-
#### Koffi 2.5.1
|
|
64
|
+
#### Koffi 2.5.1 (2023-06-20)
|
|
55
65
|
|
|
56
66
|
- Fix crash with some struct types in System V 64 ABI
|
|
57
67
|
- Always use direct passthrough for buffer arguments
|
|
58
68
|
|
|
59
|
-
#### Koffi 2.5.0
|
|
69
|
+
#### Koffi 2.5.0 (2023-06-20)
|
|
60
70
|
|
|
61
71
|
**New features:**
|
|
62
72
|
|
|
@@ -69,12 +79,12 @@
|
|
|
69
79
|
|
|
70
80
|
### Koffi 2.4
|
|
71
81
|
|
|
72
|
-
#### Koffi 2.4.2
|
|
82
|
+
#### Koffi 2.4.2 (2023-06-04)
|
|
73
83
|
|
|
74
84
|
- Support calling variadic function pointers
|
|
75
85
|
- Add documentation for function pointers
|
|
76
86
|
|
|
77
|
-
#### Koffi 2.4.1
|
|
87
|
+
#### Koffi 2.4.1 (2023-06-03)
|
|
78
88
|
|
|
79
89
|
**Main changes:**
|
|
80
90
|
|
|
@@ -91,49 +101,49 @@
|
|
|
91
101
|
|
|
92
102
|
### Koffi 2.3
|
|
93
103
|
|
|
94
|
-
#### Koffi 2.3.20
|
|
104
|
+
#### Koffi 2.3.20 (2023-05-15)
|
|
95
105
|
|
|
96
106
|
- Support explicit library unloading with `lib.unload()`
|
|
97
107
|
|
|
98
|
-
#### Koffi 2.3.19
|
|
108
|
+
#### Koffi 2.3.19 (2023-04-21)
|
|
99
109
|
|
|
100
110
|
- Actually allow non-ambiguous [string] values for `void *` arguments
|
|
101
111
|
|
|
102
|
-
#### Koffi 2.3.18
|
|
112
|
+
#### Koffi 2.3.18 (2023-04-21)
|
|
103
113
|
|
|
104
114
|
- Fix possible crash on exit caused by unregistered callbacks
|
|
105
115
|
|
|
106
|
-
#### Koffi 2.3.17
|
|
116
|
+
#### Koffi 2.3.17 (2023-04-20)
|
|
107
117
|
|
|
108
118
|
- Allow strings for input `void *`, `int8_t *` and `int16_t *` pointer arguments
|
|
109
119
|
- Support using `[string]` (single-element string arrays) for polymorphic input/output arguments
|
|
110
120
|
|
|
111
|
-
#### Koffi 2.3.16
|
|
121
|
+
#### Koffi 2.3.16 (2023-04-11)
|
|
112
122
|
|
|
113
123
|
- Fix Windows ARM64 build to work with official Node.js version
|
|
114
124
|
- Compile Windows builds with Visual Studio 2022 17.5.3
|
|
115
125
|
- Support null in `koffi.free()` and `koffi.address()`
|
|
116
126
|
|
|
117
|
-
#### Koffi 2.3.15
|
|
127
|
+
#### Koffi 2.3.15 (2023-04-10)
|
|
118
128
|
|
|
119
129
|
- Improve manual decoding of 0-terminated strings
|
|
120
130
|
- Add checks around array conversion hints
|
|
121
131
|
|
|
122
|
-
#### Koffi 2.3.14
|
|
132
|
+
#### Koffi 2.3.14 (2023-04-05)
|
|
123
133
|
|
|
124
134
|
- Add `koffi.errno()` function to get and set current errno value
|
|
125
135
|
- Add `koffi.os.errno` object with valid errno codes
|
|
126
136
|
|
|
127
|
-
#### Koffi 2.3.13
|
|
137
|
+
#### Koffi 2.3.13 (2023-03-30)
|
|
128
138
|
|
|
129
139
|
- Add `koffi.address()` to get the raw value of a wrapper pointer
|
|
130
140
|
|
|
131
|
-
#### Koffi 2.3.12
|
|
141
|
+
#### Koffi 2.3.12 (2023-03-30)
|
|
132
142
|
|
|
133
143
|
- Fix broken syntax in TS definition file
|
|
134
144
|
- Add missing exported properties in TS file
|
|
135
145
|
|
|
136
|
-
#### Koffi 2.3.11
|
|
146
|
+
#### Koffi 2.3.11 (2023-03-30)
|
|
137
147
|
|
|
138
148
|
**Main changes:**
|
|
139
149
|
|
|
@@ -145,27 +155,27 @@
|
|
|
145
155
|
- Avoid using `statx()` to allow compilation with glibc < 2.28
|
|
146
156
|
- Reorganize NPM package files to be less convoluted
|
|
147
157
|
|
|
148
|
-
#### Koffi 2.3.9
|
|
158
|
+
#### Koffi 2.3.9 (2023-03-10)
|
|
149
159
|
|
|
150
160
|
- Relicense under MIT license
|
|
151
161
|
|
|
152
|
-
#### Koffi 2.3.8
|
|
162
|
+
#### Koffi 2.3.8 (2023-02-28)
|
|
153
163
|
|
|
154
164
|
- Disable non-ready union support
|
|
155
165
|
- Simplify Windows stack allocation and drop NOACCESS and GUARD pages
|
|
156
166
|
- Adjust Windows TEB SEH chain and GuaranteedStackBytes for Koffi calls
|
|
157
167
|
|
|
158
|
-
#### Koffi 2.3.7
|
|
168
|
+
#### Koffi 2.3.7 (2023-02-27)
|
|
159
169
|
|
|
160
170
|
- Fix missing require in index.js ([@gastonFrecceroNapse](https://github.com/gastonFrecceroNapse))
|
|
161
171
|
- Reduce NPM package bloat (from 65 MB to 20 MB) caused by changes in 2.3.6
|
|
162
172
|
|
|
163
|
-
#### Koffi 2.3.6
|
|
173
|
+
#### Koffi 2.3.6 (2023-02-26)
|
|
164
174
|
|
|
165
175
|
- Fix broken TS definition file
|
|
166
176
|
- Keep all prebuilt binaries and load correct one at runtime
|
|
167
177
|
|
|
168
|
-
#### Koffi 2.3.5
|
|
178
|
+
#### Koffi 2.3.5 (2023-02-24)
|
|
169
179
|
|
|
170
180
|
**Main fixes:**
|
|
171
181
|
|
|
@@ -181,15 +191,15 @@
|
|
|
181
191
|
- Mark optional properties in TS TypeInfo class
|
|
182
192
|
- Minor performance improvements
|
|
183
193
|
|
|
184
|
-
#### Koffi 2.3.4
|
|
194
|
+
#### Koffi 2.3.4 (2023-01-31)
|
|
185
195
|
|
|
186
196
|
- Fix error when installing Koffi on Windows (2.3.2)
|
|
187
197
|
|
|
188
|
-
#### Koffi 2.3.2
|
|
198
|
+
#### Koffi 2.3.2 (2023-01-30)
|
|
189
199
|
|
|
190
200
|
**Main changes:**
|
|
191
201
|
|
|
192
|
-
- 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))
|
|
193
203
|
- Fix crash when using disposable types in output parameters
|
|
194
204
|
- Add basic [koffi.stats()](misc.md#usage-statistics) interface
|
|
195
205
|
|
|
@@ -198,18 +208,18 @@
|
|
|
198
208
|
- Avoid CNoke dependency
|
|
199
209
|
- Clear out development dependencies from package.json
|
|
200
210
|
|
|
201
|
-
#### Koffi 2.3.1
|
|
211
|
+
#### Koffi 2.3.1 (2023-01-3O)
|
|
202
212
|
|
|
203
213
|
- Error out when trying to use ambiguous `void *` arguments (input and/or output)
|
|
204
214
|
- Adjust TypeScript definitions ([@insraq](https://github.com/insraq))
|
|
205
215
|
- Fix possible crash when parsing invalid prototype
|
|
206
216
|
|
|
207
|
-
#### Koffi 2.3.0
|
|
217
|
+
#### Koffi 2.3.0 (2023-01-25)
|
|
208
218
|
|
|
209
219
|
**Main changes:**
|
|
210
220
|
|
|
211
221
|
- Allow buffers (TypedArray or ArrayBuffer) values for input and/or output pointer arguments (for polymorphic arguments)
|
|
212
|
-
- 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)
|
|
213
223
|
- Decode non-string types as arrays when an [explicit length is passed to koffi.decode()](callbacks.md#decoding-pointer-arguments)
|
|
214
224
|
|
|
215
225
|
**Other changes:**
|
|
@@ -223,21 +233,21 @@
|
|
|
223
233
|
|
|
224
234
|
### Koffi 2.2
|
|
225
235
|
|
|
226
|
-
#### Koffi 2.2.5
|
|
236
|
+
#### Koffi 2.2.5 (2023-01-23)
|
|
227
237
|
|
|
228
238
|
- Relicense Koffi under LGPL 3.0
|
|
229
239
|
|
|
230
|
-
#### Koffi 2.2.4
|
|
240
|
+
#### Koffi 2.2.4 (2023-01-19)
|
|
231
241
|
|
|
232
242
|
- Fix memory leak on Windows (in Koffi 2.2.3) when running many async calls
|
|
233
243
|
- Reorganize documentation pages
|
|
234
244
|
|
|
235
|
-
#### Koffi 2.2.3
|
|
245
|
+
#### Koffi 2.2.3 (2023-01-17)
|
|
236
246
|
|
|
237
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)
|
|
238
248
|
- Try to use ebp/rbp as frame pointer in x86/x64 ASM code
|
|
239
249
|
|
|
240
|
-
#### Koffi 2.2.2
|
|
250
|
+
#### Koffi 2.2.2 (2023-01-14)
|
|
241
251
|
|
|
242
252
|
**Main fixes:**
|
|
243
253
|
|
|
@@ -251,16 +261,16 @@
|
|
|
251
261
|
- Check N-API version when module is loaded
|
|
252
262
|
- Optimize callback unregistration
|
|
253
263
|
|
|
254
|
-
#### Koffi 2.2.1
|
|
264
|
+
#### Koffi 2.2.1 (2022-12-21)
|
|
255
265
|
|
|
256
266
|
- Fix crash when [calling callback again after FFI call inside previous callback](https://github.com/Koromix/rygel/issues/15)
|
|
257
267
|
|
|
258
|
-
#### Koffi 2.2.0
|
|
268
|
+
#### Koffi 2.2.0 (2022-12-20)
|
|
259
269
|
|
|
260
270
|
**New features:**
|
|
261
271
|
|
|
262
272
|
- Add [koffi.decode()](callbacks.md#decoding-pointer-arguments) for callback pointer arguments
|
|
263
|
-
- Support transparent [output string parameters](
|
|
273
|
+
- Support transparent [output string parameters](output.md#string-buffer-example)
|
|
264
274
|
- Add `koffi.offsetof()` utility function
|
|
265
275
|
- Support optional *this* binding in `koffi.register()`
|
|
266
276
|
|
|
@@ -271,11 +281,11 @@
|
|
|
271
281
|
|
|
272
282
|
### Koffi 2.1
|
|
273
283
|
|
|
274
|
-
#### Koffi 2.1.5
|
|
284
|
+
#### Koffi 2.1.5 (2022-11-27)
|
|
275
285
|
|
|
276
286
|
- Add missing README.md file to NPM package
|
|
277
287
|
|
|
278
|
-
#### Koffi 2.1.4
|
|
288
|
+
#### Koffi 2.1.4 (2022-11-25)
|
|
279
289
|
|
|
280
290
|
**Main changes:**
|
|
281
291
|
|
|
@@ -286,24 +296,24 @@
|
|
|
286
296
|
|
|
287
297
|
- Moved Koffi to a new repository: https://github.com/Koromix/rygel/
|
|
288
298
|
|
|
289
|
-
#### Koffi 2.1.3
|
|
299
|
+
#### Koffi 2.1.3 (2022-10-31)
|
|
290
300
|
|
|
291
301
|
- Support up to 16 output parameters (instead of 8)
|
|
292
302
|
|
|
293
|
-
#### Koffi 2.1.2
|
|
303
|
+
#### Koffi 2.1.2 (2022-10-31)
|
|
294
304
|
|
|
295
305
|
- Support up to 8 output parameters (instead of 4)
|
|
296
306
|
|
|
297
|
-
#### Koffi 2.1.1
|
|
307
|
+
#### Koffi 2.1.1 (2022-08-16)
|
|
298
308
|
|
|
299
309
|
- Fix potential memory allocation bugs
|
|
300
310
|
|
|
301
|
-
#### Koffi 2.1.0
|
|
311
|
+
#### Koffi 2.1.0 (2022-08-13)
|
|
302
312
|
|
|
303
313
|
**Main changes:**
|
|
304
314
|
|
|
305
|
-
- Add [koffi.as()](
|
|
306
|
-
- 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`
|
|
307
317
|
- Accept typed arrays for `void *` parameters
|
|
308
318
|
- Introduce `koffi.opaque()` to replace `koffi.handle()` (which remains supported until Koffi 3.0)
|
|
309
319
|
- Support JS Array and TypedArray to fill struct and array pointer members
|
|
@@ -318,15 +328,15 @@
|
|
|
318
328
|
|
|
319
329
|
### Koffi 2.0
|
|
320
330
|
|
|
321
|
-
#### Koffi 2.0.1
|
|
331
|
+
#### Koffi 2.0.1 (2022-07-30)
|
|
322
332
|
|
|
323
333
|
- Return `undefined` (instead of null) for `void` functions
|
|
324
334
|
|
|
325
|
-
#### Koffi 2.0.0
|
|
335
|
+
#### Koffi 2.0.0 (2022-07-29)
|
|
326
336
|
|
|
327
337
|
**Major new features:**
|
|
328
338
|
|
|
329
|
-
- Add [disposable types](
|
|
339
|
+
- Add [disposable types](pointers.md#disposable-types) for automatic disposal of C values (such as heap-allocated strings)
|
|
330
340
|
- Add support for [registered callbacks](callbacks.md#registered-callbacks), that can be called after the initial FFI call
|
|
331
341
|
- Support named pointer types
|
|
332
342
|
- Support complex type specifications outside of prototype parser
|
|
@@ -348,15 +358,15 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
348
358
|
|
|
349
359
|
### Koffi 1.3
|
|
350
360
|
|
|
351
|
-
#### Koffi 1.3.12
|
|
361
|
+
#### Koffi 1.3.12 (2022-07-27)
|
|
352
362
|
|
|
353
363
|
- Fix support for Yarn package manager
|
|
354
364
|
|
|
355
|
-
#### Koffi 1.3.11
|
|
365
|
+
#### Koffi 1.3.11 (2022-07-26)
|
|
356
366
|
|
|
357
367
|
- Fix broken parsing of `void *` when used for first parameter
|
|
358
368
|
|
|
359
|
-
#### Koffi 1.3.10
|
|
369
|
+
#### Koffi 1.3.10 (2022-07-25)
|
|
360
370
|
|
|
361
371
|
**Main fixes:**
|
|
362
372
|
|
|
@@ -368,11 +378,11 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
368
378
|
|
|
369
379
|
- Various documentation fixes and improvements
|
|
370
380
|
|
|
371
|
-
#### Koffi 1.3.9
|
|
381
|
+
#### Koffi 1.3.9 (2022-07-15)
|
|
372
382
|
|
|
373
383
|
- Fix prebuild compatibility with Electron on Windows x64
|
|
374
384
|
|
|
375
|
-
#### Koffi 1.3.8
|
|
385
|
+
#### Koffi 1.3.8 (2022-07-12)
|
|
376
386
|
|
|
377
387
|
**Main changes:**
|
|
378
388
|
|
|
@@ -383,7 +393,7 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
383
393
|
|
|
384
394
|
- Fix and harmonize a few error messages
|
|
385
395
|
|
|
386
|
-
#### Koffi 1.3.7
|
|
396
|
+
#### Koffi 1.3.7 (2022-07-07)
|
|
387
397
|
|
|
388
398
|
**Main fixes:**
|
|
389
399
|
|
|
@@ -396,7 +406,7 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
396
406
|
- Add str/str16 type aliases for string/string16
|
|
397
407
|
- Various documentation fixes and improvements
|
|
398
408
|
|
|
399
|
-
#### Koffi 1.3.6
|
|
409
|
+
#### Koffi 1.3.6 (2022-07-01)
|
|
400
410
|
|
|
401
411
|
**Main fixes:**
|
|
402
412
|
|
|
@@ -408,7 +418,7 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
408
418
|
- Prebuild with Clang for Windows x64 and Linux x64 binaries
|
|
409
419
|
- Various documentation improvements
|
|
410
420
|
|
|
411
|
-
#### Koffi 1.3.5
|
|
421
|
+
#### Koffi 1.3.5 (2022-06-25)
|
|
412
422
|
|
|
413
423
|
**Main changes:**
|
|
414
424
|
|
|
@@ -420,11 +430,11 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
420
430
|
- Reduce default async memory stack and heap size
|
|
421
431
|
- Various documentation improvements
|
|
422
432
|
|
|
423
|
-
#### Koffi 1.3.4
|
|
433
|
+
#### Koffi 1.3.4 (2022-06-24)
|
|
424
434
|
|
|
425
435
|
- Fix possible OpenBSD i386 crash with `(void)` functions
|
|
426
436
|
|
|
427
|
-
#### Koffi 1.3.3
|
|
437
|
+
#### Koffi 1.3.3 (2022-06-24)
|
|
428
438
|
|
|
429
439
|
**Main fixes:**
|
|
430
440
|
|
|
@@ -436,16 +446,16 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
436
446
|
- Disable unsafe compiler optimizations
|
|
437
447
|
- Various documentation improvements
|
|
438
448
|
|
|
439
|
-
#### Koffi 1.3.2
|
|
449
|
+
#### Koffi 1.3.2 (2022-06-23)
|
|
440
450
|
|
|
441
451
|
- Support compilation in C++14 mode (graceful degradation)
|
|
442
452
|
- Support older toolchains on Linux (tested on Debian 9)
|
|
443
453
|
|
|
444
|
-
#### Koffi 1.3.1
|
|
454
|
+
#### Koffi 1.3.1 (2022-06-22)
|
|
445
455
|
|
|
446
456
|
- The prebuilt binary is tested when Koffi is installed, and a rebuild happens if it fails to load
|
|
447
457
|
|
|
448
|
-
#### Koffi 1.3.0
|
|
458
|
+
#### Koffi 1.3.0 (2022-06-22)
|
|
449
459
|
|
|
450
460
|
**Major changes:**
|
|
451
461
|
|
|
@@ -463,15 +473,15 @@ Consult the [migration guide](migration.md) for more information.
|
|
|
463
473
|
|
|
464
474
|
### Koffi 1.2
|
|
465
475
|
|
|
466
|
-
#### Koffi 1.2.4
|
|
476
|
+
#### Koffi 1.2.4 (2022-06-12)
|
|
467
477
|
|
|
468
478
|
- Windows ARM64 is now supported
|
|
469
479
|
|
|
470
|
-
#### Koffi 1.2.3
|
|
480
|
+
#### Koffi 1.2.3 (2022-06-11)
|
|
471
481
|
|
|
472
482
|
- A prebuilt binary for macOS ARM64 (M1) is now included
|
|
473
483
|
|
|
474
|
-
#### Koffi 1.2.1
|
|
484
|
+
#### Koffi 1.2.1 (2022-06-11)
|
|
475
485
|
|
|
476
486
|
This entry documents changes since version 1.1.0.
|
|
477
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.
|