koffi 2.8.7 → 2.8.9
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/index.js +2 -2
- package/indirect.js +2 -2
- package/package.json +2 -2
- package/src/koffi/src/abi_arm32.cc +1 -1
- package/src/koffi/src/abi_arm64.cc +1 -1
- package/src/koffi/src/abi_riscv64.cc +1 -1
- package/src/koffi/src/abi_x64_sysv.cc +1 -1
- package/src/koffi/src/abi_x64_win.cc +1 -1
- package/src/koffi/src/abi_x86.cc +1 -1
- package/src/koffi/src/call.cc +6 -14
- package/src/koffi/src/call.hh +1 -1
- package/src/koffi/src/util.cc +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
### Koffi 2.8
|
|
6
6
|
|
|
7
|
+
#### Koffi 2.8.9 (2024-05-17)
|
|
8
|
+
|
|
9
|
+
- Fix ABI issue regarding bool return values on x86_64 (and possibly other platforms)
|
|
10
|
+
|
|
11
|
+
#### Koffi 2.8.8 (2024-04-26)
|
|
12
|
+
|
|
13
|
+
- Support use of buffers with mismatched size (truncation or zero-filling)
|
|
14
|
+
|
|
7
15
|
#### Koffi 2.8.7 (2024-04-23)
|
|
8
16
|
|
|
9
17
|
- Improve compatibility with SEHOP on Windows ([@longhun12346](https://github.com/longhun12346))
|
|
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/index.js
CHANGED
|
@@ -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.9",
|
|
382
|
+
stable: "2.8.9",
|
|
383
383
|
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
384
384
|
keywords: [
|
|
385
385
|
"foreign",
|
package/indirect.js
CHANGED
|
@@ -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.9",
|
|
382
|
+
stable: "2.8.9",
|
|
383
383
|
description: "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
384
384
|
keywords: [
|
|
385
385
|
"foreign",
|
package/package.json
CHANGED
|
@@ -518,7 +518,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
|
|
|
518
518
|
|
|
519
519
|
switch (func->ret.type->primitive) {
|
|
520
520
|
case PrimitiveKind::Void: return env.Undefined();
|
|
521
|
-
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.
|
|
521
|
+
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.u8 & 0x1);
|
|
522
522
|
case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
|
|
523
523
|
case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
|
|
524
524
|
case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
|
|
@@ -654,7 +654,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
|
|
|
654
654
|
|
|
655
655
|
switch (func->ret.type->primitive) {
|
|
656
656
|
case PrimitiveKind::Void: return env.Undefined();
|
|
657
|
-
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.
|
|
657
|
+
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.u8 & 0x1);
|
|
658
658
|
case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
|
|
659
659
|
case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
|
|
660
660
|
case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
|
|
@@ -455,7 +455,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
|
|
|
455
455
|
|
|
456
456
|
switch (func->ret.type->primitive) {
|
|
457
457
|
case PrimitiveKind::Void: return env.Undefined();
|
|
458
|
-
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.
|
|
458
|
+
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.u8 & 0x1);
|
|
459
459
|
case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
|
|
460
460
|
case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
|
|
461
461
|
case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
|
|
@@ -495,7 +495,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
|
|
|
495
495
|
|
|
496
496
|
switch (func->ret.type->primitive) {
|
|
497
497
|
case PrimitiveKind::Void: return env.Undefined();
|
|
498
|
-
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.
|
|
498
|
+
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.u8 & 0x1);
|
|
499
499
|
case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
|
|
500
500
|
case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
|
|
501
501
|
case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
|
|
@@ -307,7 +307,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
|
|
|
307
307
|
|
|
308
308
|
switch (func->ret.type->primitive) {
|
|
309
309
|
case PrimitiveKind::Void: return env.Undefined();
|
|
310
|
-
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.
|
|
310
|
+
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.u8 & 0x1);
|
|
311
311
|
case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
|
|
312
312
|
case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
|
|
313
313
|
case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
|
package/src/koffi/src/abi_x86.cc
CHANGED
|
@@ -421,7 +421,7 @@ Napi::Value CallData::Complete(const FunctionInfo *func)
|
|
|
421
421
|
|
|
422
422
|
switch (func->ret.type->primitive) {
|
|
423
423
|
case PrimitiveKind::Void: return env.Undefined();
|
|
424
|
-
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.
|
|
424
|
+
case PrimitiveKind::Bool: return Napi::Boolean::New(env, result.u8 & 0x1);
|
|
425
425
|
case PrimitiveKind::Int8: return Napi::Number::New(env, (double)result.i8);
|
|
426
426
|
case PrimitiveKind::UInt8: return Napi::Number::New(env, (double)result.u8);
|
|
427
427
|
case PrimitiveKind::Int16: return Napi::Number::New(env, (double)result.i16);
|
package/src/koffi/src/call.cc
CHANGED
|
@@ -593,9 +593,7 @@ bool CallData::PushObject(Napi::Object obj, const TypeInfo *type, uint8_t *origi
|
|
|
593
593
|
return false;
|
|
594
594
|
} else if (IsRawBuffer(value)) {
|
|
595
595
|
Span<const uint8_t> buffer = GetRawBuffer(value);
|
|
596
|
-
|
|
597
|
-
if (!PushBuffer(buffer, member.type->size, member.type, dest))
|
|
598
|
-
return false;
|
|
596
|
+
PushBuffer(buffer, member.type->size, member.type, dest);
|
|
599
597
|
} else if (value.IsString()) {
|
|
600
598
|
if (!PushStringArray(value, member.type, dest))
|
|
601
599
|
return false;
|
|
@@ -830,9 +828,7 @@ bool CallData::PushNormalArray(Napi::Array array, Size len, const TypeInfo *type
|
|
|
830
828
|
return false;
|
|
831
829
|
} else if (IsRawBuffer(value)) {
|
|
832
830
|
Span<const uint8_t> buffer = GetRawBuffer(value);
|
|
833
|
-
|
|
834
|
-
if (!PushBuffer(buffer, ref->size, ref, dest))
|
|
835
|
-
return false;
|
|
831
|
+
PushBuffer(buffer, ref->size, ref, dest);
|
|
836
832
|
} else if (value.IsString()) {
|
|
837
833
|
if (!PushStringArray(value, ref, dest))
|
|
838
834
|
return false;
|
|
@@ -896,15 +892,13 @@ bool CallData::PushNormalArray(Napi::Array array, Size len, const TypeInfo *type
|
|
|
896
892
|
return true;
|
|
897
893
|
}
|
|
898
894
|
|
|
899
|
-
|
|
895
|
+
void CallData::PushBuffer(Span<const uint8_t> buffer, Size size, const TypeInfo *type, uint8_t *origin)
|
|
900
896
|
{
|
|
901
|
-
|
|
902
|
-
ThrowError<Napi::Error>(env, "Expected array or buffer of size %1, got %2", size, buffer.len);
|
|
903
|
-
return false;
|
|
904
|
-
}
|
|
897
|
+
buffer.len = std::min(buffer.len, size);
|
|
905
898
|
|
|
906
|
-
// Go fast
|
|
899
|
+
// Go fast brrrrrrr :)
|
|
907
900
|
memcpy_safe(origin, buffer.ptr, (size_t)buffer.len);
|
|
901
|
+
memset_safe(origin + buffer.len, 0, (size_t)(size - buffer.len));
|
|
908
902
|
|
|
909
903
|
#define SWAP(CType) \
|
|
910
904
|
do { \
|
|
@@ -929,8 +923,6 @@ bool CallData::PushBuffer(Span<const uint8_t> buffer, Size size, const TypeInfo
|
|
|
929
923
|
}
|
|
930
924
|
|
|
931
925
|
#undef SWAP
|
|
932
|
-
|
|
933
|
-
return true;
|
|
934
926
|
}
|
|
935
927
|
|
|
936
928
|
bool CallData::PushStringArray(Napi::Value obj, const TypeInfo *type, uint8_t *origin)
|
package/src/koffi/src/call.hh
CHANGED
|
@@ -119,7 +119,7 @@ public:
|
|
|
119
119
|
Size PushString16Value(Napi::Value value, const char16_t **out_str16);
|
|
120
120
|
bool PushObject(Napi::Object obj, const TypeInfo *type, uint8_t *origin);
|
|
121
121
|
bool PushNormalArray(Napi::Array array, Size len, const TypeInfo *type, uint8_t *origin);
|
|
122
|
-
|
|
122
|
+
void PushBuffer(Span<const uint8_t> buffer, Size size, const TypeInfo *type, uint8_t *origin);
|
|
123
123
|
bool PushStringArray(Napi::Value value, const TypeInfo *type, uint8_t *origin);
|
|
124
124
|
bool PushPointer(Napi::Value value, const TypeInfo *type, int directions, void **out_ptr);
|
|
125
125
|
Size PushIndirectString(Napi::Array array, const TypeInfo *ref, uint8_t **out_ptr);
|
package/src/koffi/src/util.cc
CHANGED
|
@@ -1446,9 +1446,7 @@ bool Encode(Napi::Env env, uint8_t *origin, Napi::Value value, const TypeInfo *t
|
|
|
1446
1446
|
return false;
|
|
1447
1447
|
} else if (IsRawBuffer(value)) {
|
|
1448
1448
|
Span<const uint8_t> buffer = GetRawBuffer(value);
|
|
1449
|
-
|
|
1450
|
-
if (!call.PushBuffer(buffer, type->size, type, origin))
|
|
1451
|
-
return false;
|
|
1449
|
+
call.PushBuffer(buffer, type->size, type, origin);
|
|
1452
1450
|
} else if (value.IsString()) {
|
|
1453
1451
|
if (!call.PushStringArray(value, type, origin))
|
|
1454
1452
|
return false;
|