koffi 2.3.15 → 2.3.16

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 (39) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/2.3.16/koffi_darwin_arm64/koffi.node +0 -0
  3. package/build/{2.3.15 → 2.3.16}/koffi_darwin_x64/koffi.node +0 -0
  4. package/build/2.3.16/koffi_freebsd_arm64/koffi.node +0 -0
  5. package/build/2.3.16/koffi_freebsd_ia32/koffi.node +0 -0
  6. package/build/{2.3.15 → 2.3.16}/koffi_freebsd_x64/koffi.node +0 -0
  7. package/build/{2.3.15 → 2.3.16}/koffi_linux_arm32hf/koffi.node +0 -0
  8. package/build/2.3.16/koffi_linux_arm64/koffi.node +0 -0
  9. package/build/2.3.16/koffi_linux_ia32/koffi.node +0 -0
  10. package/build/{2.3.15 → 2.3.16}/koffi_linux_riscv64hf64/koffi.node +0 -0
  11. package/build/{2.3.15 → 2.3.16}/koffi_linux_x64/koffi.node +0 -0
  12. package/build/{2.3.15 → 2.3.16}/koffi_openbsd_ia32/koffi.node +0 -0
  13. package/build/2.3.16/koffi_openbsd_x64/koffi.node +0 -0
  14. package/build/2.3.16/koffi_win32_arm64/koffi.exp +0 -0
  15. package/build/2.3.16/koffi_win32_arm64/koffi.lib +0 -0
  16. package/build/2.3.16/koffi_win32_arm64/koffi.node +0 -0
  17. package/build/{2.3.15 → 2.3.16}/koffi_win32_ia32/koffi.exp +0 -0
  18. package/build/{2.3.15 → 2.3.16}/koffi_win32_ia32/koffi.lib +0 -0
  19. package/build/2.3.16/koffi_win32_ia32/koffi.node +0 -0
  20. package/build/{2.3.15 → 2.3.16}/koffi_win32_x64/koffi.exp +0 -0
  21. package/build/{2.3.15/koffi_win32_arm64 → 2.3.16/koffi_win32_x64}/koffi.lib +0 -0
  22. package/build/2.3.16/koffi_win32_x64/koffi.node +0 -0
  23. package/package.json +2 -2
  24. package/src/cnoke/cnoke.js +1 -1
  25. package/src/cnoke/package.json +1 -1
  26. package/src/cnoke/src/builder.js +2 -2
  27. package/src/koffi/CMakeLists.txt +4 -0
  28. package/src/koffi/src/ffi.cc +19 -14
  29. package/build/2.3.15/koffi_darwin_arm64/koffi.node +0 -0
  30. package/build/2.3.15/koffi_freebsd_arm64/koffi.node +0 -0
  31. package/build/2.3.15/koffi_freebsd_ia32/koffi.node +0 -0
  32. package/build/2.3.15/koffi_linux_arm64/koffi.node +0 -0
  33. package/build/2.3.15/koffi_linux_ia32/koffi.node +0 -0
  34. package/build/2.3.15/koffi_openbsd_x64/koffi.node +0 -0
  35. package/build/2.3.15/koffi_win32_arm64/koffi.exp +0 -0
  36. package/build/2.3.15/koffi_win32_arm64/koffi.node +0 -0
  37. package/build/2.3.15/koffi_win32_ia32/koffi.node +0 -0
  38. package/build/2.3.15/koffi_win32_x64/koffi.lib +0 -0
  39. package/build/2.3.15/koffi_win32_x64/koffi.node +0 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@
4
4
 
5
5
  ### Koffi 2.3
6
6
 
7
+ #### Koffi 2.3.16
8
+
9
+ **Main changes:**
10
+
11
+ - Fix Windows ARM64 build to work with official Node.js version
12
+ - Compile Windows builds with Visual Studio 2022 17.5.3
13
+
14
+ **Other changes:**
15
+
16
+ - Support null in koffi.free() and koffi.address()
17
+
7
18
  #### Koffi 2.3.15
8
19
 
9
20
  **Main changes:**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.3.15",
4
- "stable": "2.3.15",
3
+ "version": "2.3.16",
4
+ "stable": "2.3.16",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
@@ -155,7 +155,7 @@ Options:
155
155
  (default: ${cnoke.DefaultOptions.mode})
156
156
  -D, --debug Shortcut for --config Debug
157
157
 
158
- --prebuild Use prebuilt binari if available
158
+ --prebuild Use prebuilt binary if available
159
159
 
160
160
  -a, --arch <ARCH> Change architecture and ABI
161
161
  (default: ${cnoke.determine_arch()})
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnoke",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
4
4
  "description": "Build native Node addons based on CMake, without extra dependency",
5
5
  "keywords": [
6
6
  "native",
@@ -103,7 +103,7 @@ function Builder(config = {}) {
103
103
  let basename = `node-v${runtime_version}-headers.tar.gz`;
104
104
  let urls = [
105
105
  `https://nodejs.org/dist/v${runtime_version}/${basename}`,
106
- `https://unofficial-builds.nodejs.org/download/release/v${runtime_version}/${basename}`
106
+ // `https://unofficial-builds.nodejs.org/download/release/v${runtime_version}/${basename}`
107
107
  ];
108
108
  let destname = `${cache_dir}/${basename}`;
109
109
 
@@ -130,7 +130,7 @@ function Builder(config = {}) {
130
130
  if (!fs.existsSync(destname)) {
131
131
  let urls = [
132
132
  `https://nodejs.org/dist/v${runtime_version}/${dirname}/node.lib`,
133
- `https://unofficial-builds.nodejs.org/download/release/v${runtime_version}/${dirname}/node.lib`
133
+ // `https://unofficial-builds.nodejs.org/download/release/v${runtime_version}/${dirname}/node.lib`
134
134
  ];
135
135
  await tools.download_http(urls, destname);
136
136
  }
@@ -20,6 +20,8 @@
20
20
  # OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  cmake_minimum_required(VERSION 3.6)
23
+ cmake_policy(SET CMP0091 NEW)
24
+
23
25
  project(koffi C CXX ASM)
24
26
 
25
27
  include(CheckCXXCompilerFlag)
@@ -58,6 +60,8 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
58
60
  # CMAKE_SYSTEM_PROCESSOR is wrong on Windows ARM64
59
61
 
60
62
  if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch|arm" OR CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64" OR CMAKE_OSX_ARCHITECTURES MATCHES "arm")
63
+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
64
+
61
65
  if(WIN32)
62
66
  get_filename_component(cl_dir "${CMAKE_CXX_COMPILER}" DIRECTORY)
63
67
  file(TO_CMAKE_PATH "${cl_dir}/armasm64.exe" asm_compiler)
@@ -723,18 +723,25 @@ static Napi::Value CreateDisposableType(const Napi::CallbackInfo &info)
723
723
  return WrapType(env, instance, type);
724
724
  }
725
725
 
726
- static inline bool CheckExternalPointer(Napi::Env env, Napi::Value value)
726
+ static inline bool GetExternalPointer(Napi::Env env, Napi::Value value, void **out_ptr)
727
727
  {
728
728
  InstanceData *instance = env.GetInstanceData<InstanceData>();
729
729
 
730
- if (!value.IsExternal() || CheckValueTag(instance, value, &TypeInfoMarker) ||
731
- CheckValueTag(instance, value, &CastMarker) ||
732
- CheckValueTag(instance, value, &MagicUnionMarker)) {
730
+ if (IsNullOrUndefined(value)) {
731
+ *out_ptr = 0;
732
+ return true;
733
+ } else if (value.IsExternal() && !CheckValueTag(instance, value, &TypeInfoMarker) &&
734
+ !CheckValueTag(instance, value, &CastMarker) &&
735
+ !CheckValueTag(instance, value, &MagicUnionMarker)) {
736
+ Napi::External<void> external = value.As<Napi::External<void>>();
737
+ void *ptr = external.Data();
738
+
739
+ *out_ptr = ptr;
740
+ return true;
741
+ } else {
733
742
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value for ptr, expected external pointer", GetValueType(instance, value));
734
743
  return false;
735
744
  }
736
-
737
- return true;
738
745
  }
739
746
 
740
747
  static Napi::Value CallFree(const Napi::CallbackInfo &info)
@@ -745,11 +752,10 @@ static Napi::Value CallFree(const Napi::CallbackInfo &info)
745
752
  ThrowError<Napi::TypeError>(env, "Expected 1 argument, got %1", info.Length());
746
753
  return env.Null();
747
754
  }
748
- if (!CheckExternalPointer(env, info[0]))
749
- return env.Null();
750
755
 
751
- Napi::External<void> external = info[0].As<Napi::External<void>>();
752
- void *ptr = external.Data();
756
+ void *ptr = nullptr;
757
+ if (!GetExternalPointer(env, info[0], &ptr))
758
+ return env.Null();
753
759
 
754
760
  free(ptr);
755
761
 
@@ -2030,11 +2036,10 @@ static Napi::Value GetPointerAddress(const Napi::CallbackInfo &info)
2030
2036
  ThrowError<Napi::TypeError>(env, "Expected 1 argument, got %1", info.Length());
2031
2037
  return env.Null();
2032
2038
  }
2033
- if (!CheckExternalPointer(env, info[0]))
2034
- return env.Null();
2035
2039
 
2036
- Napi::External<void> external = info[0].As<Napi::External<void>>();
2037
- void *ptr = external.Data();
2040
+ void *ptr = nullptr;
2041
+ if (!GetExternalPointer(env, info[0], &ptr))
2042
+ return env.Null();
2038
2043
 
2039
2044
  uint64_t ptr64 = (uint64_t)(uintptr_t)ptr;
2040
2045
  Napi::BigInt bigint = Napi::BigInt::New(env, ptr64);