koffi 2.10.1 → 2.11.0
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 +305 -99
- 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_arm64/koffi.node +0 -0
- package/build/koffi/linux_armhf/koffi.node +0 -0
- package/build/koffi/linux_ia32/koffi.node +0 -0
- package/build/koffi/linux_riscv64/koffi.node +0 -0
- package/build/koffi/linux_x64/koffi.node +0 -0
- package/build/koffi/musl_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/doc/assets.ini +1 -1
- package/doc/{flaat/flaat.css → flat/flat.css} +2 -0
- package/doc/{flaat → flat}/normal.css +124 -31
- package/doc/{flaat → flat}/print.css +1 -2
- package/doc/flat/reset.css +41 -0
- package/doc/{flaat → flat}/small.css +5 -2
- package/doc/{flaat/flaat.js → flat/static.js} +21 -10
- package/doc/pages/contribute.md +3 -3
- package/doc/pages/output.md +32 -1
- package/doc/pages/packaging.md +5 -5
- package/doc/pages/pointers.md +9 -0
- package/doc/static/koffi.css +3 -2
- package/index.js +2 -2
- package/indirect.js +2 -2
- package/package.json +2 -2
- package/src/koffi/src/ffi.cc +39 -0
package/src/koffi/src/ffi.cc
CHANGED
|
@@ -2107,6 +2107,44 @@ static Napi::Value EncodeValue(const Napi::CallbackInfo &info)
|
|
|
2107
2107
|
return env.Undefined();
|
|
2108
2108
|
}
|
|
2109
2109
|
|
|
2110
|
+
static Napi::Value CreateView(const Napi::CallbackInfo &info)
|
|
2111
|
+
{
|
|
2112
|
+
Napi::Env env = info.Env();
|
|
2113
|
+
InstanceData *instance = env.GetInstanceData<InstanceData>();
|
|
2114
|
+
|
|
2115
|
+
if (info.Length() < 1) {
|
|
2116
|
+
ThrowError<Napi::TypeError>(env, "Expected 2 arguments, got %1", info.Length());
|
|
2117
|
+
return env.Null();
|
|
2118
|
+
}
|
|
2119
|
+
if (!info[1].IsNumber()) {
|
|
2120
|
+
ThrowError<Napi::TypeError>(env, "Unexpected %1 value for length, expected integer", GetValueType(instance, info[1]));
|
|
2121
|
+
return env.Null();
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
void *ptr = nullptr;
|
|
2125
|
+
if (!GetExternalPointer(env, info[0], &ptr))
|
|
2126
|
+
return env.Null();
|
|
2127
|
+
Size len = (Size)info[1].As<Napi::Number>().Int64Value();
|
|
2128
|
+
|
|
2129
|
+
if (len < 0) {
|
|
2130
|
+
ThrowError<Napi::TypeError>(env, "Array length must be positive and non-zero");
|
|
2131
|
+
return env.Null();
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
if (len) {
|
|
2135
|
+
Napi::ArrayBuffer view = Napi::ArrayBuffer::New(env, ptr, (size_t)len);
|
|
2136
|
+
|
|
2137
|
+
if (!view.ByteLength()) {
|
|
2138
|
+
ThrowError<Napi::Error>(env, "This runtime does not support external buffers");
|
|
2139
|
+
return env.Null();
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
return view;
|
|
2143
|
+
} else {
|
|
2144
|
+
return Napi::ArrayBuffer::New(env, 0);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2110
2148
|
static Napi::Value ResetKoffi(const Napi::CallbackInfo &info)
|
|
2111
2149
|
{
|
|
2112
2150
|
Napi::Env env = info.Env();
|
|
@@ -2364,6 +2402,7 @@ static Napi::Object InitModule(Napi::Env env, Napi::Object exports)
|
|
|
2364
2402
|
exports.Set("address", Napi::Function::New(env, GetPointerAddress, "address"));
|
|
2365
2403
|
exports.Set("call", Napi::Function::New(env, CallPointerSync, "call"));
|
|
2366
2404
|
exports.Set("encode", Napi::Function::New(env, EncodeValue, "encode"));
|
|
2405
|
+
exports.Set("view", Napi::Function::New(env, CreateView, "view"));
|
|
2367
2406
|
|
|
2368
2407
|
exports.Set("reset", Napi::Function::New(env, ResetKoffi, "reset"));
|
|
2369
2408
|
|