koffi 2.7.1 → 2.7.3
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 +10 -0
- package/README.md +2 -2
- 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_arm32hf/koffi.node +0 -0
- package/build/koffi/linux_arm64/koffi.node +0 -0
- package/build/koffi/linux_ia32/koffi.node +0 -0
- package/build/koffi/linux_riscv64hf64/koffi.node +0 -0
- package/build/koffi/linux_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/misc.md +1 -1
- package/doc/unions.md +2 -2
- package/index.d.ts +2 -1
- package/index.js +23 -23
- package/indirect.js +23 -23
- package/package.json +2 -2
- package/src/core/libcc/brotli.cc +16 -24
- package/src/core/libcc/libcc.cc +63 -69
- package/src/core/libcc/libcc.hh +103 -110
- package/src/core/libcc/lz4.cc +18 -25
- package/src/core/libcc/miniz.cc +10 -18
- package/src/koffi/src/call.cc +1 -1
- package/src/koffi/src/util.cc +7 -13
- package/src/koffi/src/util.hh +9 -1
- package/vendor/node-addon-api/CHANGELOG.md +76 -0
- package/vendor/node-addon-api/LICENSE.md +2 -6
- package/vendor/node-addon-api/README.md +10 -9
- package/vendor/node-addon-api/benchmark/binding.gyp +4 -4
- package/vendor/node-addon-api/common.gypi +1 -2
- package/vendor/node-addon-api/doc/array.md +1 -1
- package/vendor/node-addon-api/doc/async_worker_variants.md +16 -16
- package/vendor/node-addon-api/doc/cmake-js.md +1 -1
- package/vendor/node-addon-api/doc/env.md +11 -0
- package/vendor/node-addon-api/doc/hierarchy.md +2 -0
- package/vendor/node-addon-api/doc/setup.md +53 -71
- package/vendor/node-addon-api/doc/syntax_error.md +66 -0
- package/vendor/node-addon-api/doc/value.md +2 -0
- package/vendor/node-addon-api/index.js +2 -1
- package/vendor/node-addon-api/napi-inl.h +68 -65
- package/vendor/node-addon-api/napi.h +15 -5
- package/vendor/node-addon-api/node_addon_api.gyp +32 -0
- package/vendor/node-addon-api/package.json +14 -3
- package/vendor/node-addon-api/test/addon.cc +7 -1
- package/vendor/node-addon-api/test/addon.js +5 -9
- package/vendor/node-addon-api/test/addon_data.cc +3 -3
- package/vendor/node-addon-api/test/addon_data.js +16 -38
- package/vendor/node-addon-api/test/bigint.cc +0 -1
- package/vendor/node-addon-api/test/binding.cc +12 -1
- package/vendor/node-addon-api/test/binding.gyp +10 -8
- package/vendor/node-addon-api/test/child_processes/addon.js +11 -0
- package/vendor/node-addon-api/test/child_processes/addon_data.js +24 -0
- package/vendor/node-addon-api/test/child_processes/objectwrap_function.js +22 -0
- package/vendor/node-addon-api/test/child_processes/threadsafe_function_exception.js +33 -0
- package/vendor/node-addon-api/test/child_processes/typed_threadsafe_function_exception.js +19 -0
- package/vendor/node-addon-api/test/common/index.js +57 -3
- package/vendor/node-addon-api/test/env_misc.cc +25 -0
- package/vendor/node-addon-api/test/env_misc.js +12 -0
- package/vendor/node-addon-api/test/error.cc +47 -0
- package/vendor/node-addon-api/test/error.js +16 -0
- package/vendor/node-addon-api/test/index.js +5 -0
- package/vendor/node-addon-api/test/objectwrap_function.cc +10 -12
- package/vendor/node-addon-api/test/objectwrap_function.js +4 -20
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_exception.cc +50 -0
- package/vendor/node-addon-api/test/threadsafe_function/threadsafe_function_exception.js +20 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_exception.cc +39 -0
- package/vendor/node-addon-api/test/typed_threadsafe_function/typed_threadsafe_function_exception.js +13 -0
package/src/core/libcc/libcc.cc
CHANGED
|
@@ -1932,6 +1932,23 @@ bool GetDebugFlag(const char *name)
|
|
|
1932
1932
|
}
|
|
1933
1933
|
}
|
|
1934
1934
|
|
|
1935
|
+
#ifndef NDEBUG
|
|
1936
|
+
const char *DebugLogContext(const char *filename, int line)
|
|
1937
|
+
{
|
|
1938
|
+
static RG_THREAD_LOCAL LocalArray<char, 1024> buf;
|
|
1939
|
+
|
|
1940
|
+
buf.len = Fmt(buf.data, " [%1:%2] ", filename, line).len;
|
|
1941
|
+
|
|
1942
|
+
if (buf.len > 32) {
|
|
1943
|
+
char *ptr = buf.end() - 32;
|
|
1944
|
+
memcpy(ptr, " [...", 6);
|
|
1945
|
+
return ptr;
|
|
1946
|
+
} else {
|
|
1947
|
+
return buf.data;
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
#endif
|
|
1951
|
+
|
|
1935
1952
|
static void RunLogFilter(Size idx, LogLevel level, const char *ctx, const char *msg)
|
|
1936
1953
|
{
|
|
1937
1954
|
const std::function<LogFilterFunc> &func = *log_filters[idx];
|
|
@@ -2001,9 +2018,9 @@ void DefaultLogHandler(LogLevel level, const char *ctx, const char *msg)
|
|
|
2001
2018
|
{
|
|
2002
2019
|
switch (level) {
|
|
2003
2020
|
case LogLevel::Debug:
|
|
2004
|
-
case LogLevel::Info: { PrintLn(stderr, "%!D..%1
|
|
2005
|
-
case LogLevel::Warning: { PrintLn(stderr, "%!M..%1
|
|
2006
|
-
case LogLevel::Error: { PrintLn(stderr, "%!R..%1
|
|
2021
|
+
case LogLevel::Info: { PrintLn(stderr, "%!D..%1%!0%2", ctx ? ctx : "", msg); } break;
|
|
2022
|
+
case LogLevel::Warning: { PrintLn(stderr, "%!M..%1%!0%2", ctx ? ctx : "", msg); } break;
|
|
2023
|
+
case LogLevel::Error: { PrintLn(stderr, "%!R..%1%!0%2", ctx ? ctx : "", msg); } break;
|
|
2007
2024
|
}
|
|
2008
2025
|
|
|
2009
2026
|
fflush(stderr);
|
|
@@ -2047,11 +2064,10 @@ bool RedirectLogToWindowsEvents(const char *name)
|
|
|
2047
2064
|
|
|
2048
2065
|
// Append context
|
|
2049
2066
|
if (ctx) {
|
|
2050
|
-
Size len = ConvertUtf8ToWin32Wide(ctx, buf_w.
|
|
2067
|
+
Size len = ConvertUtf8ToWin32Wide(ctx, buf_w.TakeAvailable());
|
|
2051
2068
|
if (len < 0)
|
|
2052
2069
|
return;
|
|
2053
|
-
|
|
2054
|
-
buf_w.len += len + 2;
|
|
2070
|
+
buf_w.len += len;
|
|
2055
2071
|
}
|
|
2056
2072
|
|
|
2057
2073
|
// Append message
|
|
@@ -6182,6 +6198,15 @@ StreamWriter stderr_st(stderr, "<stderr>");
|
|
|
6182
6198
|
static CreateDecompressorFunc *DecompressorFunctions[RG_LEN(CompressionTypeNames)];
|
|
6183
6199
|
static CreateCompressorFunc *CompressorFunctions[RG_LEN(CompressionTypeNames)];
|
|
6184
6200
|
|
|
6201
|
+
void StreamReader::SetDecoder(StreamDecoder *decoder)
|
|
6202
|
+
{
|
|
6203
|
+
RG_ASSERT(decoder);
|
|
6204
|
+
RG_ASSERT(!filename);
|
|
6205
|
+
RG_ASSERT(!this->decoder);
|
|
6206
|
+
|
|
6207
|
+
this->decoder = decoder;
|
|
6208
|
+
}
|
|
6209
|
+
|
|
6185
6210
|
bool StreamReader::Open(Span<const uint8_t> buf, const char *filename,
|
|
6186
6211
|
CompressionType compression_type)
|
|
6187
6212
|
{
|
|
@@ -6286,9 +6311,9 @@ bool StreamReader::Close(bool implicit)
|
|
|
6286
6311
|
{
|
|
6287
6312
|
RG_ASSERT(implicit || this != &stdin_st);
|
|
6288
6313
|
|
|
6289
|
-
if (
|
|
6290
|
-
|
|
6291
|
-
|
|
6314
|
+
if (decoder) {
|
|
6315
|
+
delete decoder;
|
|
6316
|
+
decoder = nullptr;
|
|
6292
6317
|
}
|
|
6293
6318
|
|
|
6294
6319
|
switch (source.type) {
|
|
@@ -6308,7 +6333,6 @@ bool StreamReader::Close(bool implicit)
|
|
|
6308
6333
|
|
|
6309
6334
|
filename = nullptr;
|
|
6310
6335
|
error = true;
|
|
6311
|
-
compression_type = CompressionType::None;
|
|
6312
6336
|
source.type = SourceType::Memory;
|
|
6313
6337
|
source.eof = false;
|
|
6314
6338
|
eof = false;
|
|
@@ -6323,6 +6347,11 @@ bool StreamReader::Rewind()
|
|
|
6323
6347
|
if (error) [[unlikely]]
|
|
6324
6348
|
return false;
|
|
6325
6349
|
|
|
6350
|
+
if (decoder) [[unlikely]] {
|
|
6351
|
+
LogError("Cannot rewind stream with decoder");
|
|
6352
|
+
return false;
|
|
6353
|
+
}
|
|
6354
|
+
|
|
6326
6355
|
switch (source.type) {
|
|
6327
6356
|
case SourceType::Memory: { source.u.memory.pos = 0; } break;
|
|
6328
6357
|
case SourceType::File: {
|
|
@@ -6339,14 +6368,6 @@ bool StreamReader::Rewind()
|
|
|
6339
6368
|
} break;
|
|
6340
6369
|
}
|
|
6341
6370
|
|
|
6342
|
-
if (decompressor) {
|
|
6343
|
-
RG_ASSERT(compression_type != CompressionType::None);
|
|
6344
|
-
delete decompressor;
|
|
6345
|
-
|
|
6346
|
-
if (!InitDecompressor(compression_type))
|
|
6347
|
-
return false;
|
|
6348
|
-
}
|
|
6349
|
-
|
|
6350
6371
|
source.eof = false;
|
|
6351
6372
|
eof = false;
|
|
6352
6373
|
|
|
@@ -6376,14 +6397,10 @@ Size StreamReader::Read(Span<uint8_t> out_buf)
|
|
|
6376
6397
|
return -1;
|
|
6377
6398
|
|
|
6378
6399
|
Size read_len = 0;
|
|
6379
|
-
if (
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
read_len = decompressor->Read(out_buf.len, out_buf.ptr);
|
|
6400
|
+
if (decoder) {
|
|
6401
|
+
read_len = decoder->Read(out_buf.len, out_buf.ptr);
|
|
6383
6402
|
error |= (read_len < 0);
|
|
6384
6403
|
} else {
|
|
6385
|
-
RG_ASSERT(compression_type == CompressionType::None);
|
|
6386
|
-
|
|
6387
6404
|
read_len = ReadRaw(out_buf.len, out_buf.ptr);
|
|
6388
6405
|
eof = source.eof;
|
|
6389
6406
|
}
|
|
@@ -6421,7 +6438,7 @@ Size StreamReader::ReadAll(Size max_len, HeapArray<uint8_t> *out_buf)
|
|
|
6421
6438
|
// For some files (such as in /proc), the file size is reported as 0 even though there
|
|
6422
6439
|
// is content inside, because these files are generated on demand. So we need to take
|
|
6423
6440
|
// the slow path for apparently empty files.
|
|
6424
|
-
if (
|
|
6441
|
+
if (!decoder && ComputeRawLen() > 0) {
|
|
6425
6442
|
if (raw_len > max_len) {
|
|
6426
6443
|
LogError("File '%1' is too large (limit = %2)", filename, FmtDiskSize(max_len));
|
|
6427
6444
|
return -1;
|
|
@@ -6510,19 +6527,10 @@ bool StreamReader::InitDecompressor(CompressionType type)
|
|
|
6510
6527
|
return false;
|
|
6511
6528
|
}
|
|
6512
6529
|
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
if (!decompressor) {
|
|
6516
|
-
error = true;
|
|
6517
|
-
return false;
|
|
6518
|
-
}
|
|
6519
|
-
if (!decompressor->Init(type)) {
|
|
6520
|
-
error = true;
|
|
6521
|
-
return false;
|
|
6522
|
-
}
|
|
6530
|
+
decoder = func(this, type);
|
|
6531
|
+
RG_ASSERT(decoder);
|
|
6523
6532
|
}
|
|
6524
6533
|
|
|
6525
|
-
compression_type = type;
|
|
6526
6534
|
return true;
|
|
6527
6535
|
}
|
|
6528
6536
|
|
|
@@ -6621,23 +6629,23 @@ void LineReader::PushLogFilter()
|
|
|
6621
6629
|
char ctx_buf[1024];
|
|
6622
6630
|
|
|
6623
6631
|
if (line_number > 0) {
|
|
6624
|
-
Fmt(ctx_buf, "%1
|
|
6632
|
+
Fmt(ctx_buf, "%1%2(%3): ", ctx ? ctx : "", st->GetFileName(), line_number);
|
|
6625
6633
|
} else {
|
|
6626
|
-
Fmt(ctx_buf, "%1%2
|
|
6634
|
+
Fmt(ctx_buf, "%1%2: ", ctx ? ctx : "", st->GetFileName());
|
|
6627
6635
|
}
|
|
6628
6636
|
|
|
6629
6637
|
func(level, ctx_buf, msg);
|
|
6630
6638
|
});
|
|
6631
6639
|
}
|
|
6632
6640
|
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6641
|
+
void StreamWriter::SetEncoder(StreamEncoder *encoder)
|
|
6642
|
+
{
|
|
6643
|
+
RG_ASSERT(encoder);
|
|
6644
|
+
RG_ASSERT(!filename);
|
|
6645
|
+
RG_ASSERT(!this->encoder);
|
|
6637
6646
|
|
|
6638
|
-
|
|
6639
|
-
}
|
|
6640
|
-
#endif
|
|
6647
|
+
this->encoder = encoder;
|
|
6648
|
+
}
|
|
6641
6649
|
|
|
6642
6650
|
bool StreamWriter::Open(HeapArray<uint8_t> *mem, const char *filename,
|
|
6643
6651
|
CompressionType compression_type, CompressionSpeed compression_speed)
|
|
@@ -6802,10 +6810,8 @@ bool StreamWriter::Write(Span<const uint8_t> buf)
|
|
|
6802
6810
|
if (error) [[unlikely]]
|
|
6803
6811
|
return false;
|
|
6804
6812
|
|
|
6805
|
-
if (
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
error |= !compressor->Write(buf);
|
|
6813
|
+
if (encoder) {
|
|
6814
|
+
error |= !encoder->Write(buf);
|
|
6809
6815
|
return !error;
|
|
6810
6816
|
} else {
|
|
6811
6817
|
return WriteRaw(buf);
|
|
@@ -6817,11 +6823,11 @@ bool StreamWriter::Close(bool implicit)
|
|
|
6817
6823
|
RG_ASSERT(implicit || this != &stdout_st);
|
|
6818
6824
|
RG_ASSERT(implicit || this != &stderr_st);
|
|
6819
6825
|
|
|
6820
|
-
if (
|
|
6821
|
-
|
|
6822
|
-
error |= !compressor->Finalize();
|
|
6826
|
+
if (encoder) {
|
|
6827
|
+
error = error || !encoder->Finalize();
|
|
6823
6828
|
|
|
6824
|
-
delete
|
|
6829
|
+
delete encoder;
|
|
6830
|
+
encoder = nullptr;
|
|
6825
6831
|
}
|
|
6826
6832
|
|
|
6827
6833
|
switch (dest.type) {
|
|
@@ -6880,7 +6886,6 @@ bool StreamWriter::Close(bool implicit)
|
|
|
6880
6886
|
|
|
6881
6887
|
filename = nullptr;
|
|
6882
6888
|
error = true;
|
|
6883
|
-
compression_type = CompressionType::None;
|
|
6884
6889
|
dest.type = DestinationType::Memory;
|
|
6885
6890
|
str_alloc.ReleaseAll();
|
|
6886
6891
|
|
|
@@ -6898,21 +6903,10 @@ bool StreamWriter::InitCompressor(CompressionType type, CompressionSpeed speed)
|
|
|
6898
6903
|
return false;
|
|
6899
6904
|
}
|
|
6900
6905
|
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
if (!compressor) {
|
|
6904
|
-
error = true;
|
|
6905
|
-
return false;
|
|
6906
|
-
}
|
|
6907
|
-
if (!compressor->Init(type, speed)) {
|
|
6908
|
-
error = true;
|
|
6909
|
-
return false;
|
|
6910
|
-
}
|
|
6906
|
+
encoder = func(this, type, speed);
|
|
6907
|
+
RG_ASSERT(encoder);
|
|
6911
6908
|
}
|
|
6912
6909
|
|
|
6913
|
-
compression_type = type;
|
|
6914
|
-
compression_speed = speed;
|
|
6915
|
-
|
|
6916
6910
|
return true;
|
|
6917
6911
|
}
|
|
6918
6912
|
|
|
@@ -7013,14 +7007,14 @@ bool IsDecompressorAvailable(CompressionType compression_type)
|
|
|
7013
7007
|
static bool CheckIniKey(Span<const char> key)
|
|
7014
7008
|
{
|
|
7015
7009
|
const auto test_char = [](char c) { return IsAsciiAlphaOrDigit(c) || c == '_' ||
|
|
7016
|
-
c == '-' || c == '.' || c == '/'; };
|
|
7010
|
+
c == '-' || c == '.' || c == '/' || c == '@'; };
|
|
7017
7011
|
|
|
7018
7012
|
if (!key.len) {
|
|
7019
7013
|
LogError("INI key cannot be empty");
|
|
7020
7014
|
return false;
|
|
7021
7015
|
}
|
|
7022
7016
|
if (!std::all_of(key.begin(), key.end(), test_char)) {
|
|
7023
|
-
LogError("INI key must only contain alphanumeric, '.', '-' or '
|
|
7017
|
+
LogError("INI key must only contain alphanumeric, '.', '-', '_', '/' or '@' characters");
|
|
7024
7018
|
return false;
|
|
7025
7019
|
}
|
|
7026
7020
|
|