koffi 2.3.18 → 2.3.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.
Files changed (26) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/2.3.19/koffi_darwin_arm64/koffi.node +0 -0
  3. package/build/{2.3.18 → 2.3.19}/koffi_darwin_x64/koffi.node +0 -0
  4. package/build/{2.3.18 → 2.3.19}/koffi_freebsd_arm64/koffi.node +0 -0
  5. package/build/{2.3.18 → 2.3.19}/koffi_freebsd_ia32/koffi.node +0 -0
  6. package/build/{2.3.18 → 2.3.19}/koffi_freebsd_x64/koffi.node +0 -0
  7. package/build/{2.3.18 → 2.3.19}/koffi_linux_arm32hf/koffi.node +0 -0
  8. package/build/{2.3.18 → 2.3.19}/koffi_linux_arm64/koffi.node +0 -0
  9. package/build/{2.3.18 → 2.3.19}/koffi_linux_ia32/koffi.node +0 -0
  10. package/build/{2.3.18 → 2.3.19}/koffi_linux_riscv64hf64/koffi.node +0 -0
  11. package/build/{2.3.18 → 2.3.19}/koffi_linux_x64/koffi.node +0 -0
  12. package/build/{2.3.18 → 2.3.19}/koffi_openbsd_ia32/koffi.node +0 -0
  13. package/build/{2.3.18 → 2.3.19}/koffi_openbsd_x64/koffi.node +0 -0
  14. package/build/2.3.19/koffi_win32_arm64/koffi.node +0 -0
  15. package/build/{2.3.18 → 2.3.19}/koffi_win32_ia32/koffi.node +0 -0
  16. package/build/{2.3.18 → 2.3.19}/koffi_win32_x64/koffi.node +0 -0
  17. package/package.json +2 -2
  18. package/src/koffi/src/call.cc +13 -8
  19. package/build/2.3.18/koffi_darwin_arm64/koffi.node +0 -0
  20. package/build/2.3.18/koffi_win32_arm64/koffi.node +0 -0
  21. /package/build/{2.3.18 → 2.3.19}/koffi_win32_arm64/koffi.exp +0 -0
  22. /package/build/{2.3.18 → 2.3.19}/koffi_win32_arm64/koffi.lib +0 -0
  23. /package/build/{2.3.18 → 2.3.19}/koffi_win32_ia32/koffi.exp +0 -0
  24. /package/build/{2.3.18 → 2.3.19}/koffi_win32_ia32/koffi.lib +0 -0
  25. /package/build/{2.3.18 → 2.3.19}/koffi_win32_x64/koffi.exp +0 -0
  26. /package/build/{2.3.18 → 2.3.19}/koffi_win32_x64/koffi.lib +0 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  ### Koffi 2.3
6
6
 
7
+ #### Koffi 2.3.19
8
+
9
+ **Main fixes:**
10
+
11
+ - Actually allow non-ambiguous [string] values for `void *` arguments
12
+
7
13
  #### Koffi 2.3.18
8
14
 
9
15
  **Main fixes:**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.3.18",
4
- "stable": "2.3.18",
3
+ "version": "2.3.19",
4
+ "stable": "2.3.19",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
@@ -981,19 +981,24 @@ bool CallData::PushPointer(Napi::Value value, const TypeInfo *type, int directio
981
981
  Size out_max_len = -1;
982
982
 
983
983
  if (value.IsArray()) {
984
- if (RG_UNLIKELY(!type->ref.type->size)) {
985
- ThrowError<Napi::TypeError>(env, "Cannot pass %1 value to void *, use koffi.as()",
986
- type->ref.type != instance->void_type ? "opaque" : "ambiguous");
987
- return false;
988
- }
989
-
990
984
  Napi::Array array = value.As<Napi::Array>();
991
985
  Size len = PushIndirectString(array, type->ref.type, &ptr);
992
986
 
993
987
  if (len >= 0) {
988
+ if (RG_UNLIKELY(!type->ref.type->size && type->ref.type != instance->void_type)) {
989
+ ThrowError<Napi::TypeError>(env, "Cannot pass [string] value to %1", type->name);
990
+ return false;
991
+ }
992
+
994
993
  out_kind = (type->ref.type->size == 2) ? OutArgument::Kind::String16 : OutArgument::Kind::String;
995
994
  out_max_len = len;
996
995
  } else {
996
+ if (RG_UNLIKELY(!type->ref.type->size)) {
997
+ ThrowError<Napi::TypeError>(env, "Cannot pass %1 value to %2, use koffi.as()",
998
+ type->ref.type != instance->void_type ? "opaque" : "ambiguous", type->name);
999
+ return false;
1000
+ }
1001
+
997
1002
  Size len = (Size)array.Length();
998
1003
  Size size = len * type->ref.type->size;
999
1004
 
@@ -1026,8 +1031,8 @@ bool CallData::PushPointer(Napi::Value value, const TypeInfo *type, int directio
1026
1031
  } else if (RG_LIKELY(type->ref.type->primitive == PrimitiveKind::Record ||
1027
1032
  type->ref.type->primitive == PrimitiveKind::Union)) {
1028
1033
  if (RG_UNLIKELY(!type->ref.type->size)) {
1029
- ThrowError<Napi::TypeError>(env, "Cannot pass %1 value to void *, use koffi.as()",
1030
- type->ref.type != instance->void_type ? "opaque" : "ambiguous");
1034
+ ThrowError<Napi::TypeError>(env, "Cannot pass %1 value to %2, use koffi.as()",
1035
+ type->ref.type != instance->void_type ? "opaque" : "ambiguous", type->name);
1031
1036
  return false;
1032
1037
  }
1033
1038