koffi 2.5.18-beta.3 → 2.5.19
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 +5 -0
- 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.exp +0 -0
- package/build/koffi/win32_arm64/koffi.lib +0 -0
- package/build/koffi/win32_arm64/koffi.node +0 -0
- package/build/koffi/win32_ia32/koffi.exp +0 -0
- package/build/koffi/win32_ia32/koffi.lib +0 -0
- package/build/koffi/win32_ia32/koffi.node +0 -0
- package/build/koffi/win32_x64/koffi.exp +0 -0
- package/build/koffi/win32_x64/koffi.lib +0 -0
- package/build/koffi/win32_x64/koffi.node +0 -0
- package/doc/misc.md +15 -0
- package/package.json +2 -2
- package/src/cnoke/package.json +1 -1
- package/src/index.d.ts +2 -0
- package/src/index.js +7 -7
- package/src/koffi/CMakeLists.txt +4 -0
- package/src/koffi/examples/electron-builder/package.json +1 -1
- package/src/koffi/examples/electron-forge/package.json +1 -1
- package/src/koffi/examples/node-esbuild/package.json +1 -1
- package/src/koffi/examples/nwjs/src/package.json +1 -1
- package/src/koffi/src/call.cc +11 -0
- package/src/koffi/src/ffi.cc +21 -9
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
### Koffi 2.5
|
|
6
6
|
|
|
7
|
+
#### Koffi 2.5.19 (2023-08-29)
|
|
8
|
+
|
|
9
|
+
- Create thread-safe function broker lazily
|
|
10
|
+
- Add [koffi.reset()](misc.md#reset-internal-state) for type names and async broker
|
|
11
|
+
|
|
7
12
|
#### Koffi 2.5.18 (2023-08-27)
|
|
8
13
|
|
|
9
14
|
- Fix compatibility with Electron
|
|
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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/doc/misc.md
CHANGED
|
@@ -125,3 +125,18 @@ assert.equal(koffi.errno(), koffi.os.errno.EBADF);
|
|
|
125
125
|
|
|
126
126
|
console.log('close() with invalid FD is POSIX compliant!');
|
|
127
127
|
```
|
|
128
|
+
|
|
129
|
+
## Reset internal state
|
|
130
|
+
|
|
131
|
+
*New in Koffi 2.5.19*
|
|
132
|
+
|
|
133
|
+
You can use `koffi.reset()` to clear some Koffi internal state such as:
|
|
134
|
+
|
|
135
|
+
- Parser type names
|
|
136
|
+
- Asynchronous function broker (useful to avoid false positive with `jest --detectOpenHandles`)
|
|
137
|
+
|
|
138
|
+
This function is mainly intended for test code, when you execute the same code over and over and you need to reuse type names.
|
|
139
|
+
|
|
140
|
+
```{warning}
|
|
141
|
+
Trying to use a function or a type defined before the reset is undefined behavior and will likely lead to a crash!
|
|
142
|
+
```
|
package/package.json
CHANGED
package/src/cnoke/package.json
CHANGED
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -4,9 +4,9 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
4
4
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// src/cnoke/src/tools.js
|
|
7
|
+
// build/dist/src/cnoke/src/tools.js
|
|
8
8
|
var require_tools = __commonJS({
|
|
9
|
-
"src/cnoke/src/tools.js"(exports2, module2) {
|
|
9
|
+
"build/dist/src/cnoke/src/tools.js"(exports2, module2) {
|
|
10
10
|
"use strict";
|
|
11
11
|
var crypto = require("crypto");
|
|
12
12
|
var fs2 = require("fs");
|
|
@@ -373,13 +373,13 @@ var require_tools = __commonJS({
|
|
|
373
373
|
}
|
|
374
374
|
});
|
|
375
375
|
|
|
376
|
-
// src/koffi/package.json
|
|
376
|
+
// build/dist/src/koffi/package.json
|
|
377
377
|
var require_package = __commonJS({
|
|
378
|
-
"src/koffi/package.json"(exports2, module2) {
|
|
378
|
+
"build/dist/src/koffi/package.json"(exports2, module2) {
|
|
379
379
|
module2.exports = {
|
|
380
380
|
name: "koffi",
|
|
381
|
-
version: "2.5.
|
|
382
|
-
stable: "2.5.
|
|
381
|
+
version: "2.5.19",
|
|
382
|
+
stable: "2.5.19",
|
|
383
383
|
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
384
384
|
keywords: [
|
|
385
385
|
"foreign",
|
|
@@ -429,7 +429,7 @@ var require_package = __commonJS({
|
|
|
429
429
|
}
|
|
430
430
|
});
|
|
431
431
|
|
|
432
|
-
// src/koffi/src/index.js
|
|
432
|
+
// build/dist/src/koffi/src/index.js
|
|
433
433
|
var util = require("util");
|
|
434
434
|
var fs = require("fs");
|
|
435
435
|
var { get_napi_version, determine_arch } = require_tools();
|
package/src/koffi/CMakeLists.txt
CHANGED
|
@@ -47,6 +47,10 @@ endif()
|
|
|
47
47
|
|
|
48
48
|
# ---- Koffi ----
|
|
49
49
|
|
|
50
|
+
# Recompute the version string after each commit
|
|
51
|
+
if(EXISTS "${CMAKE_SOURCE_DIR}/../../.git/logs/HEAD")
|
|
52
|
+
configure_file("${CMAKE_SOURCE_DIR}/../../.git/logs/HEAD" git_logs_HEAD COPYONLY)
|
|
53
|
+
endif()
|
|
50
54
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/package.json)
|
|
51
55
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/package.json PKG)
|
|
52
56
|
else()
|
package/src/koffi/src/call.cc
CHANGED
|
@@ -1236,6 +1236,17 @@ void CallData::PopOutArguments()
|
|
|
1236
1236
|
|
|
1237
1237
|
void *CallData::ReserveTrampoline(const FunctionInfo *proto, Napi::Function func)
|
|
1238
1238
|
{
|
|
1239
|
+
if (!instance->broker) {
|
|
1240
|
+
if (napi_create_threadsafe_function(env, nullptr, nullptr,
|
|
1241
|
+
Napi::String::New(env, "Koffi Async Callback Broker"),
|
|
1242
|
+
0, 1, nullptr, nullptr, nullptr,
|
|
1243
|
+
CallData::RelayAsync, &instance->broker) != napi_ok) {
|
|
1244
|
+
LogError("Failed to create async callback broker");
|
|
1245
|
+
return nullptr;
|
|
1246
|
+
}
|
|
1247
|
+
napi_unref_threadsafe_function(env, instance->broker);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1239
1250
|
int16_t idx;
|
|
1240
1251
|
{
|
|
1241
1252
|
std::lock_guard<std::mutex> lock(shared.mutex);
|
package/src/koffi/src/ffi.cc
CHANGED
|
@@ -2068,6 +2068,25 @@ static Napi::Object InitBaseTypes(Napi::Env env)
|
|
|
2068
2068
|
return types;
|
|
2069
2069
|
}
|
|
2070
2070
|
|
|
2071
|
+
static Napi::Value ResetKoffi(const Napi::CallbackInfo &info)
|
|
2072
|
+
{
|
|
2073
|
+
Napi::Env env = info.Env();
|
|
2074
|
+
InstanceData *instance = env.GetInstanceData<InstanceData>();
|
|
2075
|
+
|
|
2076
|
+
if (instance->broker) {
|
|
2077
|
+
napi_release_threadsafe_function(instance->broker, napi_tsfn_abort);
|
|
2078
|
+
instance->broker = nullptr;
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
instance->types.Clear();
|
|
2082
|
+
instance->types_map.Clear();
|
|
2083
|
+
instance->callbacks.Clear();
|
|
2084
|
+
|
|
2085
|
+
InitBaseTypes(env);
|
|
2086
|
+
|
|
2087
|
+
return env.Undefined();
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2071
2090
|
static InstanceData *CreateInstance(Napi::Env env)
|
|
2072
2091
|
{
|
|
2073
2092
|
InstanceData *instance = new InstanceData();
|
|
@@ -2078,15 +2097,6 @@ static InstanceData *CreateInstance(Napi::Env env)
|
|
|
2078
2097
|
instance->debug = GetDebugFlag("DUMP_CALLS");
|
|
2079
2098
|
FillRandomSafe(&instance->tag_lower, RG_SIZE(instance->tag_lower));
|
|
2080
2099
|
|
|
2081
|
-
if (napi_create_threadsafe_function(env, nullptr, nullptr,
|
|
2082
|
-
Napi::String::New(env, "Koffi Async Callback Broker"),
|
|
2083
|
-
0, 1, nullptr, nullptr, nullptr,
|
|
2084
|
-
CallData::RelayAsync, &instance->broker) != napi_ok) {
|
|
2085
|
-
LogError("Failed to create async callback broker");
|
|
2086
|
-
return nullptr;
|
|
2087
|
-
}
|
|
2088
|
-
napi_unref_threadsafe_function(env, instance->broker);
|
|
2089
|
-
|
|
2090
2100
|
#ifdef _WIN32
|
|
2091
2101
|
TEB *teb = GetTEB();
|
|
2092
2102
|
|
|
@@ -2141,6 +2151,8 @@ static Napi::Object InitModule(Napi::Env env, Napi::Object exports)
|
|
|
2141
2151
|
exports.Set("address", Napi::Function::New(env, GetPointerAddress));
|
|
2142
2152
|
exports.Set("call", Napi::Function::New(env, CallPointerSync));
|
|
2143
2153
|
|
|
2154
|
+
exports.Set("reset", Napi::Function::New(env, ResetKoffi));
|
|
2155
|
+
|
|
2144
2156
|
exports.Set("errno", Napi::Function::New(env, GetOrSetErrNo));
|
|
2145
2157
|
|
|
2146
2158
|
Napi::Object os = Napi::Object::New(env);
|