koffi 2.3.10-beta.3 → 2.3.10
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 +11 -0
- package/build/2.3.10/koffi_darwin_arm64/koffi.node +0 -0
- package/build/2.3.10/koffi_darwin_x64/koffi.node +0 -0
- package/build/2.3.10/koffi_freebsd_arm64/koffi.node +0 -0
- package/build/2.3.10/koffi_freebsd_ia32/koffi.node +0 -0
- package/build/2.3.10/koffi_freebsd_x64/koffi.node +0 -0
- package/build/2.3.10/koffi_linux_arm32hf/koffi.node +0 -0
- package/build/2.3.10/koffi_linux_arm64/koffi.node +0 -0
- package/build/2.3.10/koffi_linux_ia32/koffi.node +0 -0
- package/build/2.3.10/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/build/2.3.10/koffi_linux_x64/koffi.node +0 -0
- package/build/2.3.10/koffi_openbsd_ia32/koffi.node +0 -0
- package/build/2.3.10/koffi_openbsd_x64/koffi.node +0 -0
- package/build/2.3.10/koffi_win32_arm64/koffi.node +0 -0
- package/build/2.3.10/koffi_win32_ia32/koffi.node +0 -0
- package/build/2.3.10/koffi_win32_x64/koffi.node +0 -0
- package/package.json +2 -2
- package/src/cnoke/package.json +2 -8
- package/src/core/libcc/brotli.cc +194 -0
- package/src/core/libcc/libcc.cc +111 -615
- package/src/core/libcc/libcc.hh +102 -28
- package/src/core/libcc/lz4.cc +204 -0
- package/src/core/libcc/miniz.cc +361 -0
- package/src/koffi/CMakeLists.txt +1 -1
- package/src/koffi/src/call.cc +18 -0
- package/build/2.3.10-beta.3/koffi_darwin_arm64/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_darwin_x64/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_freebsd_arm64/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_freebsd_ia32/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_freebsd_x64/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_linux_arm32hf/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_linux_arm64/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_linux_ia32/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_linux_x64/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_openbsd_ia32/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_openbsd_x64/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_win32_arm64/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_win32_ia32/koffi.node +0 -0
- package/build/2.3.10-beta.3/koffi_win32_x64/koffi.node +0 -0
- /package/build/{2.3.10-beta.3 → 2.3.10}/koffi_win32_arm64/koffi.exp +0 -0
- /package/build/{2.3.10-beta.3 → 2.3.10}/koffi_win32_arm64/koffi.lib +0 -0
- /package/build/{2.3.10-beta.3 → 2.3.10}/koffi_win32_ia32/koffi.exp +0 -0
- /package/build/{2.3.10-beta.3 → 2.3.10}/koffi_win32_ia32/koffi.lib +0 -0
- /package/build/{2.3.10-beta.3 → 2.3.10}/koffi_win32_x64/koffi.exp +0 -0
- /package/build/{2.3.10-beta.3 → 2.3.10}/koffi_win32_x64/koffi.lib +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
### Koffi 2.3
|
|
6
6
|
|
|
7
|
+
#### Koffi 2.3.10
|
|
8
|
+
|
|
9
|
+
**Main changes:**
|
|
10
|
+
|
|
11
|
+
- Allow numbers and BigInts to be used for pointer arguments
|
|
12
|
+
|
|
13
|
+
**Other changes:**
|
|
14
|
+
|
|
15
|
+
- Use SQLITE_TRANSIENT in SQLite test code
|
|
16
|
+
- Reorganize NPM package files to be less convoluted
|
|
17
|
+
|
|
7
18
|
#### Koffi 2.3.9
|
|
8
19
|
|
|
9
20
|
**Main changes:**
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
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/cnoke/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cnoke",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "Build native Node addons based on CMake, without extra dependency",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"native",
|
|
@@ -16,11 +16,5 @@
|
|
|
16
16
|
"author": "Niels Martignène <niels.martignene@protonmail.com>",
|
|
17
17
|
"index": "src/index.js",
|
|
18
18
|
"bin": "cnoke.js",
|
|
19
|
-
"license": "MIT"
|
|
20
|
-
"files": [
|
|
21
|
-
"cnoke.js",
|
|
22
|
-
"LICENSE.txt",
|
|
23
|
-
"README.md",
|
|
24
|
-
"assets"
|
|
25
|
-
]
|
|
19
|
+
"license": "MIT"
|
|
26
20
|
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Copyright 2023 Niels Martignène <niels.martignene@protonmail.com>
|
|
2
|
+
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
// this software and associated documentation files (the “Software”), to deal in
|
|
5
|
+
// the Software without restriction, including without limitation the rights to use,
|
|
6
|
+
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
7
|
+
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
8
|
+
// subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
// copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
|
14
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
15
|
+
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
16
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
17
|
+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
18
|
+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
19
|
+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
20
|
+
// OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
#include "libcc.hh"
|
|
23
|
+
|
|
24
|
+
#include "vendor/brotli/c/include/brotli/decode.h"
|
|
25
|
+
#include "vendor/brotli/c/include/brotli/encode.h"
|
|
26
|
+
|
|
27
|
+
namespace RG {
|
|
28
|
+
|
|
29
|
+
class BrotliDecompressor: public StreamDecompressor {
|
|
30
|
+
BrotliDecoderState *state = nullptr;
|
|
31
|
+
bool done = false;
|
|
32
|
+
|
|
33
|
+
uint8_t in_buf[256 * 1024];
|
|
34
|
+
Size in_len = 0;
|
|
35
|
+
|
|
36
|
+
uint8_t out_buf[256 * 1024];
|
|
37
|
+
Size out_len = 0;
|
|
38
|
+
|
|
39
|
+
public:
|
|
40
|
+
BrotliDecompressor(StreamReader *reader) : StreamDecompressor(reader) {}
|
|
41
|
+
~BrotliDecompressor();
|
|
42
|
+
|
|
43
|
+
bool Init(CompressionType type) override;
|
|
44
|
+
Size Read(Size max_len, void *out_buf) override;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
BrotliDecompressor::~BrotliDecompressor()
|
|
48
|
+
{
|
|
49
|
+
if (state) {
|
|
50
|
+
BrotliDecoderDestroyInstance(state);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
bool BrotliDecompressor::Init(CompressionType)
|
|
55
|
+
{
|
|
56
|
+
state = BrotliDecoderCreateInstance(nullptr, nullptr, nullptr);
|
|
57
|
+
if (!state)
|
|
58
|
+
throw std::bad_alloc();
|
|
59
|
+
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Size BrotliDecompressor::Read(Size max_len, void *user_buf)
|
|
64
|
+
{
|
|
65
|
+
for (;;) {
|
|
66
|
+
if (out_len || done) {
|
|
67
|
+
Size copy_len = std::min(max_len, out_len);
|
|
68
|
+
|
|
69
|
+
out_len -= copy_len;
|
|
70
|
+
memcpy(user_buf, out_buf, copy_len);
|
|
71
|
+
memmove(out_buf, out_buf + copy_len, out_len);
|
|
72
|
+
|
|
73
|
+
SetEOF(!out_len && done);
|
|
74
|
+
return copy_len;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (in_len < RG_SIZE(in_buf)) {
|
|
78
|
+
Size raw_len = ReadRaw(RG_SIZE(in_buf) - in_len, in_buf + in_len);
|
|
79
|
+
if (raw_len < 0)
|
|
80
|
+
return -1;
|
|
81
|
+
in_len += raw_len;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const uint8_t *next_in = in_buf;
|
|
85
|
+
uint8_t *next_out = out_buf + out_len;
|
|
86
|
+
size_t avail_in = (size_t)in_len;
|
|
87
|
+
size_t avail_out = (size_t)(RG_SIZE(out_buf) - out_len);
|
|
88
|
+
|
|
89
|
+
BrotliDecoderResult ret = BrotliDecoderDecompressStream(state, &avail_in, &next_in,
|
|
90
|
+
&avail_out, &next_out, nullptr);
|
|
91
|
+
|
|
92
|
+
if (ret == BROTLI_DECODER_RESULT_SUCCESS) {
|
|
93
|
+
done = true;
|
|
94
|
+
} else if (ret == BROTLI_DECODER_RESULT_ERROR) {
|
|
95
|
+
LogError("Malformed Brotli stream in '%1'", GetFileName());
|
|
96
|
+
return -1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
memmove_safe(in_buf, next_in, (size_t)avail_in);
|
|
100
|
+
in_len = avail_in;
|
|
101
|
+
|
|
102
|
+
out_len = next_out - out_buf - out_len;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
RG_UNREACHABLE();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
class BrotliCompressor: public StreamCompressor {
|
|
109
|
+
BrotliEncoderStateStruct *state = nullptr;
|
|
110
|
+
|
|
111
|
+
public:
|
|
112
|
+
BrotliCompressor(StreamWriter *writer) : StreamCompressor(writer) {}
|
|
113
|
+
~BrotliCompressor();
|
|
114
|
+
|
|
115
|
+
bool Init(CompressionType type, CompressionSpeed speed) override;
|
|
116
|
+
bool Write(Span<const uint8_t> buf) override;
|
|
117
|
+
bool Finalize() override;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
BrotliCompressor::~BrotliCompressor()
|
|
121
|
+
{
|
|
122
|
+
if (state) {
|
|
123
|
+
BrotliEncoderDestroyInstance(state);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
bool BrotliCompressor::Init(CompressionType, CompressionSpeed speed)
|
|
128
|
+
{
|
|
129
|
+
state = BrotliEncoderCreateInstance(nullptr, nullptr, nullptr);
|
|
130
|
+
if (!state)
|
|
131
|
+
throw std::bad_alloc();
|
|
132
|
+
|
|
133
|
+
RG_STATIC_ASSERT(BROTLI_MIN_QUALITY == 0 && BROTLI_MAX_QUALITY == 11);
|
|
134
|
+
|
|
135
|
+
switch (speed) {
|
|
136
|
+
case CompressionSpeed::Default: { BrotliEncoderSetParameter(state, BROTLI_PARAM_QUALITY, 6); } break;
|
|
137
|
+
case CompressionSpeed::Slow: { BrotliEncoderSetParameter(state, BROTLI_PARAM_QUALITY, 11); } break;
|
|
138
|
+
case CompressionSpeed::Fast: { BrotliEncoderSetParameter(state, BROTLI_PARAM_QUALITY, 0); } break;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
bool BrotliCompressor::Write(Span<const uint8_t> buf)
|
|
145
|
+
{
|
|
146
|
+
uint8_t output_buf[2048];
|
|
147
|
+
|
|
148
|
+
while (buf.len || BrotliEncoderHasMoreOutput(state)) {
|
|
149
|
+
const uint8_t *next_in = buf.ptr;
|
|
150
|
+
uint8_t *next_out = output_buf;
|
|
151
|
+
size_t avail_in = (size_t)buf.len;
|
|
152
|
+
size_t avail_out = RG_SIZE(output_buf);
|
|
153
|
+
|
|
154
|
+
if (!BrotliEncoderCompressStream(state, BROTLI_OPERATION_PROCESS,
|
|
155
|
+
&avail_in, &next_in, &avail_out, &next_out, nullptr)) {
|
|
156
|
+
LogError("Failed to compress '%1' with Brotli", GetFileName());
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
if (!WriteRaw(MakeSpan(output_buf, next_out - output_buf)))
|
|
160
|
+
return false;
|
|
161
|
+
|
|
162
|
+
buf.len -= next_in - buf.ptr;
|
|
163
|
+
buf.ptr = next_in;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
bool BrotliCompressor::Finalize()
|
|
170
|
+
{
|
|
171
|
+
uint8_t output_buf[2048];
|
|
172
|
+
|
|
173
|
+
do {
|
|
174
|
+
const uint8_t *next_in = nullptr;
|
|
175
|
+
uint8_t *next_out = output_buf;
|
|
176
|
+
size_t avail_in = 0;
|
|
177
|
+
size_t avail_out = RG_SIZE(output_buf);
|
|
178
|
+
|
|
179
|
+
if (!BrotliEncoderCompressStream(state, BROTLI_OPERATION_FINISH,
|
|
180
|
+
&avail_in, &next_in, &avail_out, &next_out, nullptr)) {
|
|
181
|
+
LogError("Failed to compress '%1' with Brotli", GetFileName());
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
if (!WriteRaw(MakeSpan(output_buf, next_out - output_buf)))
|
|
185
|
+
return false;
|
|
186
|
+
} while (BrotliEncoderHasMoreOutput(state));
|
|
187
|
+
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
RG_REGISTER_DECOMPRESSOR(CompressionType::Brotli, BrotliDecompressor);
|
|
192
|
+
RG_REGISTER_COMPRESSOR(CompressionType::Brotli, BrotliCompressor);
|
|
193
|
+
|
|
194
|
+
}
|