koffi 2.8.0 → 2.8.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 +8 -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.node +0 -0
- package/build/koffi/win32_ia32/koffi.node +0 -0
- package/build/koffi/win32_x64/koffi.node +0 -0
- package/doc/functions.md +3 -2
- package/doc/output.md +1 -1
- package/index.js +3 -3
- package/indirect.js +3 -3
- package/package.json +2 -2
- package/src/cnoke/src/tools.js +1 -1
- package/src/koffi/src/ffi.cc +7 -4
- package/src/koffi/src/ffi.hh +3 -0
- package/src/koffi/src/util.cc +13 -3
- package/src/koffi/src/util.hh +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
### Koffi 2.8
|
|
6
6
|
|
|
7
|
+
#### Koffi 2.8.2 (2024-04-07)
|
|
8
|
+
|
|
9
|
+
- Support [loading library](functions.md#loading-options) with RTLD_GLOBAL on POSIX platforms
|
|
10
|
+
|
|
11
|
+
#### Koffi 2.8.1 (2024-04-04)
|
|
12
|
+
|
|
13
|
+
- Fix incompatibility with Node 20.12+ and 21.6+
|
|
14
|
+
|
|
7
15
|
#### Koffi 2.8.0 (2024-02-12)
|
|
8
16
|
|
|
9
17
|
- Support pushing pointers for string arguments
|
|
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/functions.md
CHANGED
|
@@ -21,13 +21,14 @@ On some platforms (such as with the [musl C library on Linux](https://wiki.musl-
|
|
|
21
21
|
|
|
22
22
|
## Loading options
|
|
23
23
|
|
|
24
|
-
*New in Koffi 2.6*
|
|
24
|
+
*New in Koffi 2.6 and Koffi 2.8.2*
|
|
25
25
|
|
|
26
26
|
The `load` function can take an optional object argument, with the following options:
|
|
27
27
|
|
|
28
28
|
```js
|
|
29
29
|
const options = {
|
|
30
|
-
lazy: true // Use RTLD_LAZY (lazy-binding) on POSIX platforms (by default, use RTLD_NOW)
|
|
30
|
+
lazy: true, // Use RTLD_LAZY (lazy-binding) on POSIX platforms (by default, use RTLD_NOW)
|
|
31
|
+
global: true // Use RTLD_GLOBAL on POSIX platforms (by default, use RTLD_LOCAL)
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
const lib = koffi.load('/path/to/shared/library.so', options);
|
package/doc/output.md
CHANGED
|
@@ -30,7 +30,7 @@ const koffi = require('koffi');
|
|
|
30
30
|
const user32 = koffi.load('user32.dll');
|
|
31
31
|
|
|
32
32
|
const DWORD = koffi.alias('DWORD', 'uint32_t');
|
|
33
|
-
const HANDLE = koffi.pointer(koffi.opaque(
|
|
33
|
+
const HANDLE = koffi.pointer('HANDLE', koffi.opaque());
|
|
34
34
|
const HWND = koffi.alias('HWND', HANDLE);
|
|
35
35
|
|
|
36
36
|
const FindWindowEx = user32.func('HWND __stdcall FindWindowExW(HWND hWndParent, HWND hWndChildAfter, const char16_t *lpszClass, const char16_t *lpszWindow)');
|
package/index.js
CHANGED
|
@@ -43,7 +43,7 @@ var require_tools = __commonJS({
|
|
|
43
43
|
try {
|
|
44
44
|
fs2.renameSync(file.path, dest);
|
|
45
45
|
} catch (err) {
|
|
46
|
-
if (
|
|
46
|
+
if (!fs2.existsSync(dest))
|
|
47
47
|
reject(err);
|
|
48
48
|
}
|
|
49
49
|
resolve();
|
|
@@ -378,8 +378,8 @@ var require_package = __commonJS({
|
|
|
378
378
|
"build/dist/src/koffi/package.json"(exports2, module2) {
|
|
379
379
|
module2.exports = {
|
|
380
380
|
name: "koffi",
|
|
381
|
-
version: "2.8.
|
|
382
|
-
stable: "2.8.
|
|
381
|
+
version: "2.8.2",
|
|
382
|
+
stable: "2.8.2",
|
|
383
383
|
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
384
384
|
keywords: [
|
|
385
385
|
"foreign",
|
package/indirect.js
CHANGED
|
@@ -43,7 +43,7 @@ var require_tools = __commonJS({
|
|
|
43
43
|
try {
|
|
44
44
|
fs2.renameSync(file.path, dest);
|
|
45
45
|
} catch (err) {
|
|
46
|
-
if (
|
|
46
|
+
if (!fs2.existsSync(dest))
|
|
47
47
|
reject(err);
|
|
48
48
|
}
|
|
49
49
|
resolve();
|
|
@@ -378,8 +378,8 @@ var require_package = __commonJS({
|
|
|
378
378
|
"build/dist/src/koffi/package.json"(exports2, module2) {
|
|
379
379
|
module2.exports = {
|
|
380
380
|
name: "koffi",
|
|
381
|
-
version: "2.8.
|
|
382
|
-
stable: "2.8.
|
|
381
|
+
version: "2.8.2",
|
|
382
|
+
stable: "2.8.2",
|
|
383
383
|
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
384
384
|
keywords: [
|
|
385
385
|
"foreign",
|
package/package.json
CHANGED
package/src/cnoke/src/tools.js
CHANGED
package/src/koffi/src/ffi.cc
CHANGED
|
@@ -1717,10 +1717,15 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
|
|
|
1717
1717
|
}
|
|
1718
1718
|
|
|
1719
1719
|
#ifndef _WIN32
|
|
1720
|
-
|
|
1720
|
+
int flags = 0;
|
|
1721
|
+
|
|
1721
1722
|
if (info.Length() >= 2) {
|
|
1722
1723
|
Napi::Object options = info[1].As<Napi::Object>();
|
|
1723
|
-
|
|
1724
|
+
|
|
1725
|
+
flags |= options.Get("lazy").ToBoolean() ? RTLD_LAZY : RTLD_NOW;
|
|
1726
|
+
flags |= options.Get("global").ToBoolean() ? RTLD_GLOBAL : RTLD_LOCAL;
|
|
1727
|
+
} else {
|
|
1728
|
+
flags = RTLD_NOW | RTLD_LOCAL;
|
|
1724
1729
|
}
|
|
1725
1730
|
#endif
|
|
1726
1731
|
|
|
@@ -1744,8 +1749,6 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
|
|
|
1744
1749
|
}
|
|
1745
1750
|
#else
|
|
1746
1751
|
if (info[0].IsString()) {
|
|
1747
|
-
int flags = lazy ? RTLD_LAZY : RTLD_NOW;
|
|
1748
|
-
|
|
1749
1752
|
std::string filename = info[0].As<Napi::String>();
|
|
1750
1753
|
module = dlopen(filename.c_str(), flags);
|
|
1751
1754
|
|
package/src/koffi/src/ffi.hh
CHANGED
|
@@ -272,7 +272,10 @@ struct InstanceData {
|
|
|
272
272
|
Size base_types_len;
|
|
273
273
|
|
|
274
274
|
bool debug;
|
|
275
|
+
|
|
275
276
|
uint64_t tag_lower;
|
|
277
|
+
BucketArray<napi_type_tag> tags;
|
|
278
|
+
HashMap<const void *, napi_type_tag *> tags_map;
|
|
276
279
|
|
|
277
280
|
const TypeInfo *void_type;
|
|
278
281
|
const TypeInfo *char_type;
|
package/src/koffi/src/util.cc
CHANGED
|
@@ -579,12 +579,22 @@ const char *GetValueType(const InstanceData *instance, Napi::Value value)
|
|
|
579
579
|
return "Unknown";
|
|
580
580
|
}
|
|
581
581
|
|
|
582
|
-
void SetValueTag(
|
|
582
|
+
void SetValueTag(InstanceData *instance, Napi::Value value, const void *marker)
|
|
583
583
|
{
|
|
584
584
|
RG_ASSERT(marker);
|
|
585
585
|
|
|
586
|
-
napi_type_tag tag =
|
|
587
|
-
|
|
586
|
+
napi_type_tag *tag = instance->tags_map.FindValue(marker, nullptr);
|
|
587
|
+
|
|
588
|
+
if (!tag) {
|
|
589
|
+
tag = instance->tags.AppendDefault();
|
|
590
|
+
|
|
591
|
+
tag->lower = instance->tag_lower;
|
|
592
|
+
tag->upper = (uint64_t)marker;
|
|
593
|
+
|
|
594
|
+
instance->tags_map.Set(marker, tag);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
napi_status status = napi_type_tag_object(value.Env(), value, tag);
|
|
588
598
|
RG_ASSERT(status == napi_ok);
|
|
589
599
|
}
|
|
590
600
|
|
package/src/koffi/src/util.hh
CHANGED
|
@@ -102,7 +102,7 @@ bool CanStoreType(const TypeInfo *type);
|
|
|
102
102
|
// Can be slow, only use for error messages
|
|
103
103
|
const char *GetValueType(const InstanceData *instance, Napi::Value value);
|
|
104
104
|
|
|
105
|
-
void SetValueTag(
|
|
105
|
+
void SetValueTag(InstanceData *instance, Napi::Value value, const void *marker);
|
|
106
106
|
bool CheckValueTag(const InstanceData *instance, Napi::Value value, const void *marker);
|
|
107
107
|
|
|
108
108
|
static inline bool IsNullOrUndefined(Napi::Value value)
|