koffi 2.5.4 → 2.5.5

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 (25) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/{2.5.4 → 2.5.5}/koffi_darwin_arm64/koffi.node +0 -0
  3. package/build/{2.5.4 → 2.5.5}/koffi_darwin_x64/koffi.node +0 -0
  4. package/build/{2.5.4 → 2.5.5}/koffi_freebsd_arm64/koffi.node +0 -0
  5. package/build/{2.5.4 → 2.5.5}/koffi_freebsd_ia32/koffi.node +0 -0
  6. package/build/{2.5.4 → 2.5.5}/koffi_freebsd_x64/koffi.node +0 -0
  7. package/build/{2.5.4 → 2.5.5}/koffi_linux_arm32hf/koffi.node +0 -0
  8. package/build/{2.5.4 → 2.5.5}/koffi_linux_arm64/koffi.node +0 -0
  9. package/build/{2.5.4 → 2.5.5}/koffi_linux_ia32/koffi.node +0 -0
  10. package/build/{2.5.4 → 2.5.5}/koffi_linux_riscv64hf64/koffi.node +0 -0
  11. package/build/{2.5.4 → 2.5.5}/koffi_linux_x64/koffi.node +0 -0
  12. package/build/{2.5.4 → 2.5.5}/koffi_openbsd_ia32/koffi.node +0 -0
  13. package/build/{2.5.4 → 2.5.5}/koffi_openbsd_x64/koffi.node +0 -0
  14. package/build/2.5.5/koffi_win32_arm64/koffi.node +0 -0
  15. package/build/{2.5.4 → 2.5.5}/koffi_win32_ia32/koffi.node +0 -0
  16. package/build/{2.5.4 → 2.5.5}/koffi_win32_x64/koffi.node +0 -0
  17. package/package.json +2 -2
  18. package/src/koffi/src/util.cc +8 -10
  19. package/build/2.5.4/koffi_win32_arm64/koffi.node +0 -0
  20. /package/build/{2.5.4 → 2.5.5}/koffi_win32_arm64/koffi.exp +0 -0
  21. /package/build/{2.5.4 → 2.5.5}/koffi_win32_arm64/koffi.lib +0 -0
  22. /package/build/{2.5.4 → 2.5.5}/koffi_win32_ia32/koffi.exp +0 -0
  23. /package/build/{2.5.4 → 2.5.5}/koffi_win32_ia32/koffi.lib +0 -0
  24. /package/build/{2.5.4 → 2.5.5}/koffi_win32_x64/koffi.exp +0 -0
  25. /package/build/{2.5.4 → 2.5.5}/koffi_win32_x64/koffi.lib +0 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  ### Koffi 2.5
6
6
 
7
+ #### Koffi 2.5.5
8
+
9
+ **Main changes:**
10
+
11
+ - Support decoding non-char NUL-terminated arrays
12
+
7
13
  #### Koffi 2.5.4
8
14
 
9
15
  **Main changes:**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.5.4",
4
- "stable": "2.5.4",
3
+ "version": "2.5.5",
4
+ "stable": "2.5.5",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
@@ -1065,26 +1065,24 @@ Napi::Value Decode(Napi::Env env, const uint8_t *ptr, const TypeInfo *type, cons
1065
1065
  if (*len >= 0) {
1066
1066
  type = MakeArrayType(instance, type, *len);
1067
1067
  } else {
1068
- if (!(type->flags & (int)TypeFlag::IsCharLike)) [[unlikely]] {
1069
- ThrowError<Napi::TypeError>(env, "Only char-like types can find their length automatically", type->name);
1070
- return env.Null();
1071
- }
1072
-
1073
1068
  switch (type->primitive) {
1074
- case PrimitiveKind::Int8: {
1069
+ case PrimitiveKind::Int8:
1070
+ case PrimitiveKind::UInt8: {
1075
1071
  Size count = strlen((const char *)ptr);
1076
1072
  type = MakeArrayType(instance, type, count);
1077
1073
  } break;
1078
- case PrimitiveKind::Int16: {
1074
+ case PrimitiveKind::Int16:
1075
+ case PrimitiveKind::UInt16: {
1079
1076
  Size count = WideStringLength((const char16_t *)ptr, RG_SIZE_MAX);
1080
1077
  type = MakeArrayType(instance, type, count);
1081
1078
  } break;
1082
1079
 
1083
- default: { RG_UNREACHABLE(); } break;
1080
+ default: {
1081
+ ThrowError<Napi::TypeError>(env, "Cannot determine null-terminated length for type %1", type->name);
1082
+ return env.Null();
1083
+ } break;
1084
1084
  }
1085
-
1086
1085
  }
1087
-
1088
1086
  }
1089
1087
 
1090
1088
  #define RETURN_INT(Type, NewCall) \