koffi 1.1.0-beta.5 → 1.1.0-beta.6
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/CMakeLists.txt +2 -5
- package/build/qemu/1.1.0-beta.6/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.6/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.6/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.6/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.6/koffi_linux_arm.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.6/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.6/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.6/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.6/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.6/koffi_win32_x64.tar.gz +0 -0
- package/package.json +1 -1
- package/src/call.cc +17 -4
- package/src/call.hh +4 -13
- package/src/ffi.cc +6 -6
- package/src/ffi.hh +0 -1
- package/build/qemu/1.1.0-beta.5/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.5/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.5/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.5/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.5/koffi_linux_arm.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.5/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.5/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.5/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.5/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/1.1.0-beta.5/koffi_win32_x64.tar.gz +0 -0
package/CMakeLists.txt
CHANGED
|
@@ -65,9 +65,6 @@ if(WIN32)
|
|
|
65
65
|
target_compile_definitions(koffi PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
|
|
66
66
|
target_link_libraries(koffi PRIVATE ws2_32)
|
|
67
67
|
endif()
|
|
68
|
-
if(MSVC)
|
|
69
|
-
target_compile_options(koffi PRIVATE
|
|
70
|
-
else()
|
|
71
|
-
target_compile_options(koffi PRIVATE -fno-exceptions -Wno-missing-field-initializers
|
|
72
|
-
-fno-strict-aliasing)
|
|
68
|
+
if(NOT MSVC)
|
|
69
|
+
target_compile_options(koffi PRIVATE -fno-exceptions -fno-strict-aliasing)
|
|
73
70
|
endif()
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/src/call.cc
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
namespace RG {
|
|
22
22
|
|
|
23
|
-
CallData::CallData(Napi::Env env, const FunctionInfo *func, InstanceMemory *mem
|
|
24
|
-
: env(env), instance(
|
|
23
|
+
CallData::CallData(Napi::Env env, InstanceData *instance, const FunctionInfo *func, InstanceMemory *mem)
|
|
24
|
+
: env(env), instance(instance), func(func), debug(instance->debug),
|
|
25
25
|
mem(mem), old_stack_mem(mem->stack), old_heap_mem(mem->heap)
|
|
26
26
|
{
|
|
27
27
|
mem->depth++;
|
|
@@ -67,7 +67,7 @@ const char *CallData::PushString(const Napi::Value &value)
|
|
|
67
67
|
|
|
68
68
|
len++;
|
|
69
69
|
|
|
70
|
-
buf.ptr = (char *)Allocator::Allocate(&
|
|
70
|
+
buf.ptr = (char *)Allocator::Allocate(&call_alloc, (Size)len);
|
|
71
71
|
buf.len = (Size)len;
|
|
72
72
|
|
|
73
73
|
status = napi_get_value_string_utf8(env, value, buf.ptr, (size_t)buf.len, &len);
|
|
@@ -104,7 +104,7 @@ const char16_t *CallData::PushString16(const Napi::Value &value)
|
|
|
104
104
|
|
|
105
105
|
len++;
|
|
106
106
|
|
|
107
|
-
buf.ptr = (char16_t *)Allocator::Allocate(&
|
|
107
|
+
buf.ptr = (char16_t *)Allocator::Allocate(&call_alloc, (Size)len * 2);
|
|
108
108
|
buf.len = (Size)len;
|
|
109
109
|
|
|
110
110
|
status = napi_get_value_string_utf16(env, value, buf.ptr, (size_t)buf.len, &len);
|
|
@@ -822,6 +822,19 @@ Napi::Object CallData::PopArray(const uint8_t *src, const TypeInfo *type, int16_
|
|
|
822
822
|
RG_UNREACHABLE();
|
|
823
823
|
}
|
|
824
824
|
|
|
825
|
+
Napi::Value CallData::Run(const Napi::CallbackInfo &info)
|
|
826
|
+
{
|
|
827
|
+
if (!RG_UNLIKELY(Prepare(info)))
|
|
828
|
+
return env.Null();
|
|
829
|
+
|
|
830
|
+
if (debug) {
|
|
831
|
+
DumpDebug();
|
|
832
|
+
}
|
|
833
|
+
Execute();
|
|
834
|
+
|
|
835
|
+
return Complete();
|
|
836
|
+
}
|
|
837
|
+
|
|
825
838
|
static void DumpMemory(const char *type, Span<const uint8_t> bytes)
|
|
826
839
|
{
|
|
827
840
|
if (bytes.len) {
|
package/src/call.hh
CHANGED
|
@@ -55,26 +55,17 @@ class CallData {
|
|
|
55
55
|
} result;
|
|
56
56
|
uint8_t *return_ptr = nullptr;
|
|
57
57
|
|
|
58
|
+
LinkedAllocator call_alloc;
|
|
59
|
+
|
|
58
60
|
public:
|
|
59
|
-
CallData(Napi::Env env, const FunctionInfo *func, InstanceMemory *mem
|
|
61
|
+
CallData(Napi::Env env, InstanceData *instance, const FunctionInfo *func, InstanceMemory *mem);
|
|
60
62
|
~CallData();
|
|
61
63
|
|
|
62
64
|
bool Prepare(const Napi::CallbackInfo &info);
|
|
63
65
|
void Execute();
|
|
64
66
|
Napi::Value Complete();
|
|
65
67
|
|
|
66
|
-
Napi::Value Run(const Napi::CallbackInfo &info)
|
|
67
|
-
{
|
|
68
|
-
if (!RG_UNLIKELY(Prepare(info)))
|
|
69
|
-
return env.Null();
|
|
70
|
-
|
|
71
|
-
if (debug) {
|
|
72
|
-
DumpDebug();
|
|
73
|
-
}
|
|
74
|
-
Execute();
|
|
75
|
-
|
|
76
|
-
return Complete();
|
|
77
|
-
}
|
|
68
|
+
Napi::Value Run(const Napi::CallbackInfo &info);
|
|
78
69
|
|
|
79
70
|
void DumpDebug() const;
|
|
80
71
|
|
package/src/ffi.cc
CHANGED
|
@@ -401,7 +401,7 @@ static Napi::Value TranslateNormalCall(const Napi::CallbackInfo &info)
|
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
InstanceMemory *mem = AllocateCallMemory(instance);
|
|
404
|
-
CallData call(env, func, mem
|
|
404
|
+
CallData call(env, instance, func, mem);
|
|
405
405
|
|
|
406
406
|
return call.Run(info);
|
|
407
407
|
}
|
|
@@ -461,7 +461,7 @@ static Napi::Value TranslateVariadicCall(const Napi::CallbackInfo &info)
|
|
|
461
461
|
return env.Null();
|
|
462
462
|
|
|
463
463
|
InstanceMemory *mem = AllocateCallMemory(instance);
|
|
464
|
-
CallData call(env, &func, mem
|
|
464
|
+
CallData call(env, instance, &func, mem);
|
|
465
465
|
|
|
466
466
|
return call.Run(info);
|
|
467
467
|
}
|
|
@@ -474,10 +474,10 @@ class AsyncCall: public Napi::AsyncWorker {
|
|
|
474
474
|
bool prepared = false;
|
|
475
475
|
|
|
476
476
|
public:
|
|
477
|
-
AsyncCall(Napi::Env env,
|
|
478
|
-
Napi::Function &callback)
|
|
477
|
+
AsyncCall(Napi::Env env, InstanceData *instance, const FunctionInfo *func,
|
|
478
|
+
InstanceMemory *mem, Napi::Function &callback)
|
|
479
479
|
: Napi::AsyncWorker(callback), env(env), func(func->Ref()),
|
|
480
|
-
call(env, func, mem
|
|
480
|
+
call(env, instance, func, mem) {}
|
|
481
481
|
~AsyncCall() { func->Unref(); }
|
|
482
482
|
|
|
483
483
|
bool Prepare(const Napi::CallbackInfo &info) {
|
|
@@ -537,7 +537,7 @@ static Napi::Value TranslateAsyncCall(const Napi::CallbackInfo &info)
|
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
InstanceMemory *mem = AllocateCallMemory(instance);
|
|
540
|
-
AsyncCall *async = new AsyncCall(env,
|
|
540
|
+
AsyncCall *async = new AsyncCall(env, instance, func, mem, callback);
|
|
541
541
|
|
|
542
542
|
if (async->Prepare(info) && instance->debug) {
|
|
543
543
|
async->DumpDebug();
|
package/src/ffi.hh
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|