koffi 2.9.1 → 2.9.2
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 +51 -46
- 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_arm32/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_riscv64/koffi.node +0 -0
- package/build/koffi/linux_x64/koffi.node +0 -0
- package/build/koffi/musl_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/README.md +27 -0
- package/doc/assets.ini +19 -0
- package/doc/develop.sh +14 -0
- package/doc/flaat/flaat.css +25 -0
- package/doc/flaat/flaat.js +150 -0
- package/doc/flaat/normal.css +320 -0
- package/doc/flaat/print.css +30 -0
- package/doc/flaat/small.css +94 -0
- package/doc/{benchmarks.md → pages/benchmarks.md} +14 -18
- package/doc/{callbacks.md → pages/callbacks.md} +27 -36
- package/doc/{contribute.md → pages/contribute.md} +10 -12
- package/doc/{functions.md → pages/functions.md} +29 -34
- package/doc/pages/index.md +20 -0
- package/doc/{input.md → pages/input.md} +28 -33
- package/doc/{migration.md → pages/migration.md} +7 -10
- package/doc/{misc.md → pages/misc.md} +19 -23
- package/doc/{output.md → pages/output.md} +17 -20
- package/doc/{packaging.md → pages/packaging.md} +8 -10
- package/doc/{platforms.md → pages/platforms.md} +2 -4
- package/doc/{pointers.md → pages/pointers.md} +13 -16
- package/doc/{start.md → pages/start.md} +12 -14
- package/doc/{unions.md → pages/unions.md} +5 -7
- package/doc/{variables.md → pages/variables.md} +7 -11
- package/doc/pages.ini +88 -0
- package/doc/static/koffi.css +21 -0
- package/doc/static/koffi.js +21 -0
- package/doc/static/koffi.png +0 -0
- package/doc/static/print.css +22 -0
- package/doc/templates/page.html +40 -0
- package/index.js +2 -2
- package/indirect.js +2 -2
- package/package.json +2 -2
- package/src/koffi/src/call.cc +2 -0
- package/doc/Makefile +0 -20
- package/doc/benchmarks.xlsx +0 -0
- package/doc/changelog.md +0 -5
- package/doc/conf.py +0 -118
- package/doc/index.rst +0 -47
- package/doc/make.bat +0 -35
- package/doc/poetry.lock +0 -521
- package/doc/pyproject.toml +0 -19
- package/doc/static/bench_linux.png +0 -0
- package/doc/static/bench_windows.png +0 -0
- package/doc/static/custom.css +0 -70
- package/doc/static/node_c.webp +0 -0
- package/doc/static/opensans/LICENSE.txt +0 -202
- package/doc/static/opensans/OpenSans.css +0 -39
- package/doc/static/opensans/OpenSans_v17_Latin_Bold.woff +0 -0
- package/doc/static/opensans/OpenSans_v17_Latin_Bold.woff2 +0 -0
- package/doc/static/opensans/OpenSans_v17_Latin_BoldItalic.woff +0 -0
- package/doc/static/opensans/OpenSans_v17_Latin_BoldItalic.woff2 +0 -0
- package/doc/static/opensans/OpenSans_v17_Latin_Italic.woff +0 -0
- package/doc/static/opensans/OpenSans_v17_Latin_Italic.woff2 +0 -0
- package/doc/static/opensans/OpenSans_v17_Latin_Regular.woff +0 -0
- package/doc/static/opensans/OpenSans_v17_Latin_Regular.woff2 +0 -0
- package/doc/static/perf_linux_20220623.png +0 -0
- package/doc/static/perf_linux_20220623_2.png +0 -0
- package/doc/static/perf_linux_20220627.png +0 -0
- package/doc/static/perf_linux_20220628.png +0 -0
- package/doc/static/perf_linux_20220812.png +0 -0
- package/doc/static/perf_windows_20220623.png +0 -0
- package/doc/static/perf_windows_20220623_2.png +0 -0
- package/doc/static/perf_windows_20220627.png +0 -0
- package/doc/static/perf_windows_20220628.png +0 -0
- package/doc/static/perf_windows_20220812.png +0 -0
- package/doc/templates/badges.html +0 -7
- package/doc/templates/logo.html +0 -3
- /package/doc/static/{perf_linux_20231028.png → perf_linux.png} +0 -0
- /package/doc/static/{perf_windows_20231028.png → perf_windows.png} +0 -0
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
## Node.js
|
|
1
|
+
# Node.js
|
|
4
2
|
|
|
5
3
|
Koffi requires a recent [Node.js](https://nodejs.org/) version with [N-API](https://nodejs.org/api/n-api.html) version 8 support:
|
|
6
4
|
|
|
@@ -12,7 +10,7 @@ Koffi requires a recent [Node.js](https://nodejs.org/) version with [N-API](http
|
|
|
12
10
|
|
|
13
11
|
Use [NVM](https://github.com/nvm-sh/nvm) to install more recent Node versions on older Linux distributions.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
# Supported platforms
|
|
16
14
|
|
|
17
15
|
The following combinations of OS and architectures __are officially supported and tested__ at the moment:
|
|
18
16
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
## How pointers are used
|
|
1
|
+
# How pointers are used
|
|
4
2
|
|
|
5
3
|
In C, pointer arguments are used for differenty purposes. It is important to distinguish these use cases because Koffi provides different ways to deal with each of them:
|
|
6
4
|
|
|
@@ -9,9 +7,9 @@ In C, pointer arguments are used for differenty purposes. It is important to dis
|
|
|
9
7
|
- **Pointers to primitive types**: This is more rare, and generally used for output or input/output arguments. The Win32 API has a lot of these.
|
|
10
8
|
- **Arrays**: in C, you dynamically-sized arrays are usually passed to functions with pointers, either NULL-terminated (or any other sentinel value) or with an additional length argument.
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
# Pointer types
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
## Struct pointers
|
|
15
13
|
|
|
16
14
|
The following Win32 example uses `GetCursorPos()` (with an output parameter) to retrieve and show the current cursor position.
|
|
17
15
|
|
|
@@ -37,7 +35,7 @@ if (!GetCursorPos(pos))
|
|
|
37
35
|
console.log(pos);
|
|
38
36
|
```
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
## Opaque pointers
|
|
41
39
|
|
|
42
40
|
*New in Koffi 2.0*
|
|
43
41
|
|
|
@@ -51,7 +49,7 @@ const GetHandleInformation = lib.func('bool __stdcall GetHandleInformation(HANDL
|
|
|
51
49
|
const CloseHandle = lib.func('bool __stdcall CloseHandle(HANDLE h)');
|
|
52
50
|
```
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
## Pointer to primitive types
|
|
55
53
|
|
|
56
54
|
In javascript, it is not possible to pass a primitive value by reference to another function. This means that you cannot call a function and expect it to modify the value of one of its number or string parameter.
|
|
57
55
|
|
|
@@ -88,7 +86,7 @@ AddInt(sum, 6);
|
|
|
88
86
|
console.log(sum[0]); // Prints 42
|
|
89
87
|
```
|
|
90
88
|
|
|
91
|
-
|
|
89
|
+
## Dynamic arrays
|
|
92
90
|
|
|
93
91
|
In C, dynamically-sized arrays are usually passed around as pointers. The length is either passed as an additional argument, or inferred from the array content itself, for example with a terminating sentinel value (such as a NULL pointers in the case of an array of strings).
|
|
94
92
|
|
|
@@ -130,9 +128,9 @@ let total = ComputeTotalLength(strings);
|
|
|
130
128
|
console.log(total); // Prints 14
|
|
131
129
|
```
|
|
132
130
|
|
|
133
|
-
By default, just like for objects, array arguments are copied from JS to C but not vice-versa. You can however change the direction as documented in the section on [output parameters](output
|
|
131
|
+
By default, just like for objects, array arguments are copied from JS to C but not vice-versa. You can however change the direction as documented in the section on [output parameters](output).
|
|
134
132
|
|
|
135
|
-
|
|
133
|
+
# Handling void pointers
|
|
136
134
|
|
|
137
135
|
*New in Koffi 2.1*
|
|
138
136
|
|
|
@@ -195,7 +193,7 @@ let hdr = {};
|
|
|
195
193
|
console.log('PNG header:', hdr);
|
|
196
194
|
```
|
|
197
195
|
|
|
198
|
-
|
|
196
|
+
# Disposable types
|
|
199
197
|
|
|
200
198
|
*New in Koffi 2.0*
|
|
201
199
|
|
|
@@ -230,7 +228,7 @@ let copy = strdup('Hello!');
|
|
|
230
228
|
console.log(copy); // Prints Hello!
|
|
231
229
|
```
|
|
232
230
|
|
|
233
|
-
When you declare functions with the [prototype-like syntax](functions
|
|
231
|
+
When you declare functions with the [prototype-like syntax](functions#definition-syntax), you can either use named disposable types or use the '!' shortcut qualifier with compatibles types, as shown in the example below. This qualifier creates an anonymous disposable type that calls `koffi.free(ptr)`.
|
|
234
232
|
|
|
235
233
|
```js
|
|
236
234
|
// ES6 syntax: import koffi from 'koffi';
|
|
@@ -247,10 +245,9 @@ console.log(copy); // Prints World!
|
|
|
247
245
|
|
|
248
246
|
Disposable types can only be created from pointer or string types.
|
|
249
247
|
|
|
250
|
-
|
|
251
|
-
Be careful on Windows: if your shared library uses a different CRT (such as msvcrt), the memory could have been allocated by a different malloc/free implementation or heap, resulting in undefined behavior if you use `koffi.free()`.
|
|
252
|
-
```
|
|
248
|
+
> [!WARNING]
|
|
249
|
+
> Be careful on Windows: if your shared library uses a different CRT (such as msvcrt), the memory could have been allocated by a different malloc/free implementation or heap, resulting in undefined behavior if you use `koffi.free()`.
|
|
253
250
|
|
|
254
|
-
|
|
251
|
+
# Unwrap pointers
|
|
255
252
|
|
|
256
253
|
You can use `koffi.address(ptr)` on a pointer to get the numeric value as a [BigInt object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt).
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
## Install Koffi
|
|
1
|
+
# Install Koffi
|
|
4
2
|
|
|
5
3
|
You can install Koffi with npm:
|
|
6
4
|
|
|
@@ -18,14 +16,14 @@ const koffi = require('koffi');
|
|
|
18
16
|
import koffi from 'koffi';
|
|
19
17
|
```
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
# Simple examples
|
|
22
20
|
|
|
23
21
|
Below you can find two examples:
|
|
24
22
|
|
|
25
23
|
* The first one runs on Linux. The functions are declared with the C-like prototype language.
|
|
26
24
|
* The second one runs on Windows, and uses the node-ffi like syntax to declare functions.
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
## For Linux
|
|
29
27
|
|
|
30
28
|
This is a small example for Linux systems, which uses `gettimeofday()`, `localtime_r()` and `printf()` to print the current time.
|
|
31
29
|
|
|
@@ -52,7 +50,7 @@ const tm = koffi.struct('tm', {
|
|
|
52
50
|
tm_sec: 'int',
|
|
53
51
|
tm_min: 'int',
|
|
54
52
|
tm_hour: 'int',
|
|
55
|
-
|
|
53
|
+
tmay: 'int',
|
|
56
54
|
tm_mon: 'int',
|
|
57
55
|
tm_year: 'int',
|
|
58
56
|
tm_wday: 'int',
|
|
@@ -76,7 +74,7 @@ printf('Hello World!\n');
|
|
|
76
74
|
printf('Local time: %02d:%02d:%02d\n', 'int', now.tm_hour, 'int', now.tm_min, 'int', now.tm_sec);
|
|
77
75
|
```
|
|
78
76
|
|
|
79
|
-
|
|
77
|
+
## For Windows
|
|
80
78
|
|
|
81
79
|
This is a small example targeting the Win32 API, using `MessageBox()` to show a *Hello World!* message to the user.
|
|
82
80
|
|
|
@@ -103,18 +101,18 @@ const MessageBoxA = lib.func('__stdcall', 'MessageBoxA', 'int', ['void *', 'str'
|
|
|
103
101
|
const MessageBoxW = lib.func('__stdcall', 'MessageBoxW', 'int', ['void *', 'str16', 'str16', 'uint']);
|
|
104
102
|
|
|
105
103
|
let ret = MessageBoxA(null, 'Do you want another message box?', 'Koffi', MB_YESNO | MB_ICONQUESTION);
|
|
104
|
+
|
|
106
105
|
if (ret == IDYES)
|
|
107
106
|
MessageBoxW(null, 'Hello World!', 'Koffi', MB_ICONINFORMATION);
|
|
108
107
|
```
|
|
109
108
|
|
|
110
|
-
|
|
109
|
+
# Bundling Koffi
|
|
111
110
|
|
|
112
|
-
Please read the [dedicated page](packaging
|
|
111
|
+
Please read the [dedicated page](packaging) for information about bundling and packaging applications using Koffi.
|
|
113
112
|
|
|
114
|
-
|
|
113
|
+
# Build manually
|
|
115
114
|
|
|
116
|
-
Follow the [build instrutions](contribute
|
|
115
|
+
Follow the [build instrutions](contribute#build-from-source) if you want to build the native Koffi code yourself.
|
|
117
116
|
|
|
118
|
-
|
|
119
|
-
This is only needed if you want to hack on Koffi. The official NPM package provide prebuilt binaries and you don't need to compile anything if you only want to use Koffi in Node.js.
|
|
120
|
-
```
|
|
117
|
+
> [!NOTE]
|
|
118
|
+
> This is only needed if you want to hack on Koffi. The official NPM package provide prebuilt binaries and you don't need to compile anything if you only want to use Koffi in Node.js.
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
# Union
|
|
1
|
+
# Union definition
|
|
2
2
|
|
|
3
3
|
*New in Koffi 2.5*
|
|
4
4
|
|
|
5
|
-
## Union definition
|
|
6
|
-
|
|
7
5
|
You can declare unions with a syntax similar to structs, but with the `koffi.union()` function. This function takes two arguments: the first one is the name of the type, and the second one is an object containing the union member names and types. You can omit the first argument to declare an anonymous union.
|
|
8
6
|
|
|
9
7
|
The following example illustrates how to declare the same union in C and in JS with Koffi:
|
|
@@ -22,9 +20,9 @@ const IntOrDouble = koffi.union('IntOrDouble', {
|
|
|
22
20
|
});
|
|
23
21
|
```
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
# Input unions
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
## Passing union values to C
|
|
28
26
|
|
|
29
27
|
You can instantiate an union object with `koffi.Union(type)`. This will create a special object that contains at most one active member.
|
|
30
28
|
|
|
@@ -53,7 +51,7 @@ DoSomething('int', { i: 42 });
|
|
|
53
51
|
DoSomething('string', { str: 'Hello!' });
|
|
54
52
|
```
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
## Win32 example
|
|
57
55
|
|
|
58
56
|
The following example uses the [SendInput](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput) Win32 API to emit the Win+D shortcut and hide windows (show the desktop).
|
|
59
57
|
|
|
@@ -138,7 +136,7 @@ function make_keyboard_event(vk, down) {
|
|
|
138
136
|
}
|
|
139
137
|
```
|
|
140
138
|
|
|
141
|
-
|
|
139
|
+
# Output unions
|
|
142
140
|
|
|
143
141
|
Unlike structs, Koffi does not know which union member is valid, and it cannot decode it automatically. You can however use special `koffi.Union` objects for output parameters, and decode the memory after the call.
|
|
144
142
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
## Variable definitions
|
|
1
|
+
# Variable definitions
|
|
4
2
|
|
|
5
3
|
*New in Koffi 2.6*
|
|
6
4
|
|
|
@@ -21,7 +19,7 @@ You cannot directly manipulate these variables, use:
|
|
|
21
19
|
- [koffi.decode()](#decode-to-js-values) to read their value
|
|
22
20
|
- [koffi.encode()](#encode-to-c-memory) to change their valuèe
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
# Decode to JS values
|
|
25
23
|
|
|
26
24
|
*New in Koffi 2.2, changed in Koffi 2.3*
|
|
27
25
|
|
|
@@ -61,11 +59,10 @@ The example below will decode the symbol `my_string` defined above but only the
|
|
|
61
59
|
console.log(koffi.decode(my_string, 'const char *', 3)) // Prints "foo"
|
|
62
60
|
```
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
In Koffi 2.2 and earlier versions, the length argument is only used to decode strings and is ignored otherwise.
|
|
66
|
-
```
|
|
62
|
+
> [!NOTE]
|
|
63
|
+
> In Koffi 2.2 and earlier versions, the length argument is only used to decode strings and is ignored otherwise.
|
|
67
64
|
|
|
68
|
-
|
|
65
|
+
# Encode to C memory
|
|
69
66
|
|
|
70
67
|
*New in Koffi 2.6*
|
|
71
68
|
|
|
@@ -101,6 +98,5 @@ When encoding strings (either directly or embedded in arrays or structs), the me
|
|
|
101
98
|
|
|
102
99
|
There is also an optional ending `length` argument that you can use to encode an array. For example, here is how you can encode an array with 3 float values: `koffi.encode(symbol, 'float', [1, 2, 3], 3)`. This is equivalent to `koffi.encode(symbol, koffi.array('float', 3), [1, 2, 3])`.
|
|
103
100
|
|
|
104
|
-
|
|
105
|
-
The length argument did not work correctly before Koffi 2.6.11.
|
|
106
|
-
```
|
|
101
|
+
> [!NOTE]
|
|
102
|
+
> The length argument did not work correctly before Koffi 2.6.11.
|
package/doc/pages.ini
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[pages/index.md]
|
|
2
|
+
Title = Koffi
|
|
3
|
+
Menu = Overview
|
|
4
|
+
Description = Koffi presentation and features
|
|
5
|
+
Template = templates/page.html
|
|
6
|
+
|
|
7
|
+
[pages/platforms.md]
|
|
8
|
+
Title = Requirements | Koffi
|
|
9
|
+
Menu = Documentation / Requirements
|
|
10
|
+
Description = Supported systemd and architectures
|
|
11
|
+
Template = templates/page.html
|
|
12
|
+
|
|
13
|
+
[pages/start.md]
|
|
14
|
+
Title = Get started | Koffi
|
|
15
|
+
Menu = Documentation / Get started
|
|
16
|
+
Description = Install and start using Koffi in your Node.js project
|
|
17
|
+
Template = templates/page.html
|
|
18
|
+
|
|
19
|
+
[pages/functions.md]
|
|
20
|
+
Title = Function calls | Koffi
|
|
21
|
+
Menu = Documentation / Function calls
|
|
22
|
+
Description = Call native functions
|
|
23
|
+
Template = templates/page.html
|
|
24
|
+
|
|
25
|
+
[pages/input.md]
|
|
26
|
+
Title = Input parameters | Koffi
|
|
27
|
+
Menu = Documentation / Input parameters
|
|
28
|
+
Template = templates/page.html
|
|
29
|
+
|
|
30
|
+
[pages/pointers.md]
|
|
31
|
+
Title = Data pointers | Koffi
|
|
32
|
+
Menu = Documentation / Data pointers
|
|
33
|
+
Template = templates/page.html
|
|
34
|
+
|
|
35
|
+
[pages/output.md]
|
|
36
|
+
Title = Output parameters | Koffi
|
|
37
|
+
Menu = Documentation / Output parameters
|
|
38
|
+
Template = templates/page.html
|
|
39
|
+
|
|
40
|
+
[pages/unions.md]
|
|
41
|
+
Title = Union values | Koffi
|
|
42
|
+
Menu = Documentation / Union values
|
|
43
|
+
Template = templates/page.html
|
|
44
|
+
|
|
45
|
+
[pages/variables.md]
|
|
46
|
+
Title = Exported variables | Koffi
|
|
47
|
+
Menu = Documentation / Exported variables
|
|
48
|
+
Template = templates/page.html
|
|
49
|
+
|
|
50
|
+
[pages/callbacks.md]
|
|
51
|
+
Title = Callbacks | Koffi
|
|
52
|
+
Menu = Documentation / Javascript callbacks
|
|
53
|
+
Template = templates/page.html
|
|
54
|
+
|
|
55
|
+
[pages/misc.md]
|
|
56
|
+
Title = Miscellaneous | Koffi
|
|
57
|
+
Menu = Documentation / Miscellaneous
|
|
58
|
+
Template = templates/page.html
|
|
59
|
+
|
|
60
|
+
[pages/packaging.md]
|
|
61
|
+
Title = Packaging | Koffi
|
|
62
|
+
Menu = Documentation / Bundlers and Koffi
|
|
63
|
+
Template = templates/page.html
|
|
64
|
+
|
|
65
|
+
[pages/benchmarks.md]
|
|
66
|
+
Title = Benchmarks | Koffi
|
|
67
|
+
Menu = Benchmarks
|
|
68
|
+
Description = Performance of Koffi compared to NAPI and node-ffi
|
|
69
|
+
Template = templates/page.html
|
|
70
|
+
|
|
71
|
+
[pages/contribute.md]
|
|
72
|
+
Title = Contribute | Koffi
|
|
73
|
+
Menu = Contribute
|
|
74
|
+
Description = How to get, build and test Koffi code
|
|
75
|
+
Template = templates/page.html
|
|
76
|
+
|
|
77
|
+
[changelog]
|
|
78
|
+
SourceFile = ../../src/koffi/CHANGELOG.md
|
|
79
|
+
Title = Changelog | Koffi
|
|
80
|
+
Menu = Changelog / Version history
|
|
81
|
+
Description = List of Koffi versions
|
|
82
|
+
Template = templates/page.html
|
|
83
|
+
|
|
84
|
+
[pages/migration.md]
|
|
85
|
+
Title = Migration | Koffi
|
|
86
|
+
Menu = Changelog / Migration guide
|
|
87
|
+
Description = Migration between major Koffi versions
|
|
88
|
+
Template = templates/page.html
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* Copyright (C) 2024 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
|
+
|
|
3
|
+
This program is free software: you can redistribute it and/or modify
|
|
4
|
+
it under the terms of the GNU General Public License as published by
|
|
5
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
(at your option) any later version.
|
|
7
|
+
|
|
8
|
+
This program is distributed in the hope that it will be useful,
|
|
9
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
GNU General Public License for more details.
|
|
12
|
+
|
|
13
|
+
You should have received a copy of the GNU General Public License
|
|
14
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
15
|
+
|
|
16
|
+
@import url('../flaat/flaat.css');
|
|
17
|
+
@import url('../../../vendor/highlight.js/styles/base16/tomorrow.css');
|
|
18
|
+
|
|
19
|
+
html {
|
|
20
|
+
--primary_color: #ec7400;
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (C) 2024 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
|
+
//
|
|
3
|
+
// This program is free software: you can redistribute it and/or modify
|
|
4
|
+
// it under the terms of the GNU General Public License as published by
|
|
5
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
// (at your option) any later version.
|
|
7
|
+
//
|
|
8
|
+
// This program is distributed in the hope that it will be useful,
|
|
9
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
// GNU General Public License for more details.
|
|
12
|
+
//
|
|
13
|
+
// You should have received a copy of the GNU General Public License
|
|
14
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
15
|
+
|
|
16
|
+
import '../flaat/flaat.js';
|
|
17
|
+
import * as hljs from '../../../vendor/highlight.js/highlight.js';
|
|
18
|
+
|
|
19
|
+
window.addEventListener('load', e => {
|
|
20
|
+
hljs.highlightAll();
|
|
21
|
+
});
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* Copyright (C) 2024 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
|
+
|
|
3
|
+
This program is free software: you can redistribute it and/or modify
|
|
4
|
+
it under the terms of the GNU General Public License as published by
|
|
5
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
(at your option) any later version.
|
|
7
|
+
|
|
8
|
+
This program is distributed in the hope that it will be useful,
|
|
9
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
GNU General Public License for more details.
|
|
12
|
+
|
|
13
|
+
You should have received a copy of the GNU General Public License
|
|
14
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
15
|
+
|
|
16
|
+
@media print {
|
|
17
|
+
.schema { width: 90%; }
|
|
18
|
+
|
|
19
|
+
.columns { display: block; }
|
|
20
|
+
.columns > * { width: auto; }
|
|
21
|
+
.columns > * + * { margin-top: 3em; }
|
|
22
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en" class="nojs">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
|
|
7
|
+
<title>{{ TITLE }}</title>
|
|
8
|
+
<meta name="author" content="Niels Martignène">
|
|
9
|
+
<meta name="description" content="{{ DESCRIPTION }}">
|
|
10
|
+
<link rel="icon" href="{{ ASSET favicon.png }}">
|
|
11
|
+
|
|
12
|
+
<meta name="theme-color" content="#6aa051">
|
|
13
|
+
<link rel="stylesheet" href="{{ ASSET static/site.min.css }}">
|
|
14
|
+
|
|
15
|
+
<script type="text/javascript" src="{{ ASSET static/site.min.js }}" async></script>
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<body>
|
|
19
|
+
<div id="deploy"></div>
|
|
20
|
+
|
|
21
|
+
<nav id="top">
|
|
22
|
+
<menu>
|
|
23
|
+
<a id="logo" href="/"><img src="{{ ASSET favicon.png }}" alt="Logo Rekkord" /></a>
|
|
24
|
+
|
|
25
|
+
{{ LINKS }}
|
|
26
|
+
|
|
27
|
+
<div style="flex: 1;"></div>
|
|
28
|
+
|
|
29
|
+
<li><a href="https://www.npmjs.com/package/koffi" style="border-bottom-color: transparent; margin-top: 8px;"><img src="https://img.shields.io/badge/NPM-2.9.2-brightgreen" alt="NPM"/></a></li>
|
|
30
|
+
<li><a href="https://github.com/Koromix/koffi" style="border-bottom-color: transparent; margin-top: 8px;"><img src="https://img.shields.io/badge/GitHub-Koffi-ff6600" alt="GitHub"/></a></li>
|
|
31
|
+
</menu>
|
|
32
|
+
</nav>
|
|
33
|
+
|
|
34
|
+
{{ TOC }}
|
|
35
|
+
|
|
36
|
+
<main>
|
|
37
|
+
{{ CONTENT }}
|
|
38
|
+
</main>
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
package/index.js
CHANGED
|
@@ -363,8 +363,8 @@ var require_package = __commonJS({
|
|
|
363
363
|
"../../bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
|
|
364
364
|
module2.exports = {
|
|
365
365
|
name: "koffi",
|
|
366
|
-
version: "2.9.
|
|
367
|
-
stable: "2.9.
|
|
366
|
+
version: "2.9.2",
|
|
367
|
+
stable: "2.9.2",
|
|
368
368
|
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
369
369
|
keywords: [
|
|
370
370
|
"foreign",
|
package/indirect.js
CHANGED
|
@@ -363,8 +363,8 @@ var require_package = __commonJS({
|
|
|
363
363
|
"../../bin/Koffi/package/src/koffi/package.json"(exports2, module2) {
|
|
364
364
|
module2.exports = {
|
|
365
365
|
name: "koffi",
|
|
366
|
-
version: "2.9.
|
|
367
|
-
stable: "2.9.
|
|
366
|
+
version: "2.9.2",
|
|
367
|
+
stable: "2.9.2",
|
|
368
368
|
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
369
369
|
keywords: [
|
|
370
370
|
"foreign",
|
package/package.json
CHANGED
package/src/koffi/src/call.cc
CHANGED
|
@@ -321,6 +321,7 @@ Size CallData::PushString16Value(Napi::Value value, const char16_t **out_str16)
|
|
|
321
321
|
size_t len = 0;
|
|
322
322
|
napi_status status;
|
|
323
323
|
|
|
324
|
+
mem->heap.ptr = AlignUp(mem->heap.ptr, 2);
|
|
324
325
|
buf.ptr = (char16_t *)mem->heap.ptr;
|
|
325
326
|
buf.len = std::max((Size)0, mem->heap.len - Kibibytes(32)) / 2;
|
|
326
327
|
|
|
@@ -426,6 +427,7 @@ Size CallData::PushString32Value(Napi::Value value, const char32_t **out_str32)
|
|
|
426
427
|
if (buf16.len < 0) [[unlikely]]
|
|
427
428
|
return -1;
|
|
428
429
|
|
|
430
|
+
mem->heap.ptr = AlignUp(mem->heap.ptr, 4);
|
|
429
431
|
buf.ptr = (char32_t *)mem->heap.ptr;
|
|
430
432
|
buf.len = std::max((Size)0, mem->heap.len - Kibibytes(32)) / 4;
|
|
431
433
|
|
package/doc/Makefile
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# Minimal makefile for Sphinx documentation
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
# You can set these variables from the command line, and also
|
|
5
|
-
# from the environment for the first two.
|
|
6
|
-
SPHINXOPTS ?=
|
|
7
|
-
SPHINXBUILD ?= sphinx-build
|
|
8
|
-
SOURCEDIR = .
|
|
9
|
-
BUILDDIR = dist
|
|
10
|
-
|
|
11
|
-
# Put it first so that "make" without argument is like "make help".
|
|
12
|
-
help:
|
|
13
|
-
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
-
|
|
15
|
-
.PHONY: help Makefile
|
|
16
|
-
|
|
17
|
-
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
-
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
-
%: Makefile
|
|
20
|
-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
package/doc/benchmarks.xlsx
DELETED
|
Binary file
|
package/doc/changelog.md
DELETED
package/doc/conf.py
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
# -- Project information -----------------------------------------------------
|
|
5
|
-
|
|
6
|
-
project = 'Koffi'
|
|
7
|
-
copyright = '2022, Niels Martignène'
|
|
8
|
-
author = 'Niels Martignène'
|
|
9
|
-
|
|
10
|
-
root = None
|
|
11
|
-
version = None
|
|
12
|
-
revision = None
|
|
13
|
-
stable = None
|
|
14
|
-
|
|
15
|
-
names = ['../../src/koffi/package.json', '../package.json']
|
|
16
|
-
|
|
17
|
-
for name in names:
|
|
18
|
-
filename = os.path.dirname(__file__) + '/' + name
|
|
19
|
-
|
|
20
|
-
if not os.path.exists(filename):
|
|
21
|
-
continue;
|
|
22
|
-
|
|
23
|
-
with open(filename) as f:
|
|
24
|
-
config = json.load(f)
|
|
25
|
-
|
|
26
|
-
root = os.path.dirname(name)
|
|
27
|
-
version = config['version']
|
|
28
|
-
revision = config['version']
|
|
29
|
-
stable = config['stable']
|
|
30
|
-
|
|
31
|
-
break
|
|
32
|
-
|
|
33
|
-
if root is None:
|
|
34
|
-
raise FileNotFoundError('Cannot find Koffi package.json')
|
|
35
|
-
|
|
36
|
-
# -- General configuration ---------------------------------------------------
|
|
37
|
-
|
|
38
|
-
extensions = [
|
|
39
|
-
'myst_parser',
|
|
40
|
-
'sphinx.ext.autosectionlabel',
|
|
41
|
-
'sphinxext.rediraffe'
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
# Add any paths that contain templates here, relative to this directory.
|
|
45
|
-
templates_path = ['templates']
|
|
46
|
-
|
|
47
|
-
exclude_patterns = []
|
|
48
|
-
|
|
49
|
-
# -- Options for HTML output -------------------------------------------------
|
|
50
|
-
|
|
51
|
-
html_title = project
|
|
52
|
-
|
|
53
|
-
html_theme = 'furo'
|
|
54
|
-
|
|
55
|
-
html_static_path = ['static']
|
|
56
|
-
|
|
57
|
-
html_theme_options = {
|
|
58
|
-
'light_css_variables': {
|
|
59
|
-
'font-stack': 'Open Sans',
|
|
60
|
-
'color-content-foreground': '#383838',
|
|
61
|
-
'color-brand-primary': '#383838',
|
|
62
|
-
'color-brand-content': '#e97713'
|
|
63
|
-
},
|
|
64
|
-
'dark_css_variables': {
|
|
65
|
-
'font-stack': 'Open Sans',
|
|
66
|
-
'color-content-foreground': '#ffffffdd',
|
|
67
|
-
'color-brand-primary': '#ffffffdd',
|
|
68
|
-
'color-brand-content': '#e97713'
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
html_link_suffix = ''
|
|
73
|
-
|
|
74
|
-
html_css_files = [
|
|
75
|
-
'opensans/OpenSans.css',
|
|
76
|
-
'custom.css'
|
|
77
|
-
]
|
|
78
|
-
|
|
79
|
-
html_sidebars = {
|
|
80
|
-
"**": [
|
|
81
|
-
"logo.html",
|
|
82
|
-
"sidebar/search.html",
|
|
83
|
-
"sidebar/scroll-start.html",
|
|
84
|
-
"sidebar/navigation.html",
|
|
85
|
-
"sidebar/ethical-ads.html",
|
|
86
|
-
"badges.html",
|
|
87
|
-
"sidebar/scroll-end.html",
|
|
88
|
-
"sidebar/variant-selector.html"
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
html_context = {
|
|
93
|
-
"root": root,
|
|
94
|
-
"stable": stable
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
# -- MyST parser options -------------------------------------------------
|
|
98
|
-
|
|
99
|
-
myst_enable_extensions = [
|
|
100
|
-
'linkify',
|
|
101
|
-
'substitution'
|
|
102
|
-
]
|
|
103
|
-
|
|
104
|
-
myst_substitutions = html_context
|
|
105
|
-
|
|
106
|
-
myst_heading_anchors = 3
|
|
107
|
-
|
|
108
|
-
myst_linkify_fuzzy_links = False
|
|
109
|
-
|
|
110
|
-
myst_number_code_blocks = ['c', 'js', 'sh', 'batch']
|
|
111
|
-
|
|
112
|
-
# -- Redirections -------------------------------------------------
|
|
113
|
-
|
|
114
|
-
rediraffe_redirects = {
|
|
115
|
-
"changes.md": "changelog.md",
|
|
116
|
-
"bundling.md": "packaging.md",
|
|
117
|
-
"parameters.md": "input.md"
|
|
118
|
-
}
|