koffi 2.3.9 → 2.3.10-beta.2
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/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_darwin_arm64/koffi.node +0 -0
- package/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_darwin_x64/koffi.node +0 -0
- package/build/2.3.10-beta.2/koffi_freebsd_arm64/koffi.node +0 -0
- package/build/2.3.10-beta.2/koffi_freebsd_ia32/koffi.node +0 -0
- package/build/2.3.10-beta.2/koffi_freebsd_x64/koffi.node +0 -0
- package/build/2.3.10-beta.2/koffi_linux_arm32hf/koffi.node +0 -0
- package/build/2.3.10-beta.2/koffi_linux_arm64/koffi.node +0 -0
- package/build/2.3.10-beta.2/koffi_linux_ia32/koffi.node +0 -0
- package/build/2.3.10-beta.2/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/build/2.3.10-beta.2/koffi_linux_x64/koffi.node +0 -0
- package/build/2.3.10-beta.2/koffi_openbsd_ia32/koffi.node +0 -0
- package/build/2.3.10-beta.2/koffi_openbsd_x64/koffi.node +0 -0
- package/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_win32_arm64/koffi.node +0 -0
- package/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_win32_ia32/koffi.node +0 -0
- package/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_win32_x64/koffi.node +0 -0
- package/package.json +5 -5
- package/src/core/libcc/libcc.cc +73 -21
- package/src/core/libcc/libcc.hh +11 -2
- package/src/{koffi/src/index.js → index.js} +12 -16
- package/src/koffi/build/2.3.9/koffi_freebsd_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.9/koffi_freebsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.9/koffi_freebsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.9/koffi_linux_arm32hf/koffi.node +0 -0
- package/src/koffi/build/2.3.9/koffi_linux_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.9/koffi_linux_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.9/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/src/koffi/build/2.3.9/koffi_linux_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.9/koffi_openbsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.9/koffi_openbsd_x64/koffi.node +0 -0
- /package/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_win32_arm64/koffi.exp +0 -0
- /package/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_win32_arm64/koffi.lib +0 -0
- /package/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_win32_ia32/koffi.exp +0 -0
- /package/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_win32_ia32/koffi.lib +0 -0
- /package/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_win32_x64/koffi.exp +0 -0
- /package/{src/koffi/build/2.3.9 → build/2.3.10-beta.2}/koffi_win32_x64/koffi.lib +0 -0
- /package/src/{koffi/src/index.d.ts → index.d.ts} +0 -0
|
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koffi",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.10-beta.2",
|
|
4
4
|
"stable": "2.3.9",
|
|
5
5
|
"description": "Fast and simple C FFI (foreign function interface) for Node.js",
|
|
6
6
|
"keywords": [
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://koffi.dev/",
|
|
20
20
|
"author": "Niels Martignène <niels.martignene@protonmail.com>",
|
|
21
|
-
"main": "src/
|
|
22
|
-
"types": "src/
|
|
21
|
+
"main": "src/index.js",
|
|
22
|
+
"types": "src/index.d.ts",
|
|
23
23
|
"scripts": {
|
|
24
24
|
"install": "node src/cnoke/cnoke.js --prebuild -d src/koffi"
|
|
25
25
|
},
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"cnoke": {
|
|
28
28
|
"napi": 8,
|
|
29
|
-
"require": "./src/
|
|
30
|
-
"output": "
|
|
29
|
+
"require": "./src/index.js",
|
|
30
|
+
"output": "build/{{version}}/koffi_{{platform}}_{{arch}}"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/core/libcc/libcc.cc
CHANGED
|
@@ -7415,51 +7415,103 @@ void InitPackedMap(Span<const AssetInfo> assets)
|
|
|
7415
7415
|
|
|
7416
7416
|
#endif
|
|
7417
7417
|
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
Span<const uint8_t> PatchAsset(const AssetInfo &asset, Allocator *alloc,
|
|
7421
|
-
FunctionRef<void(const char *, StreamWriter *)> func)
|
|
7418
|
+
bool PatchFile(StreamReader *reader, StreamWriter *writer,
|
|
7419
|
+
FunctionRef<void(Span<const char>, StreamWriter *)> func)
|
|
7422
7420
|
{
|
|
7423
|
-
RG_ASSERT(alloc);
|
|
7424
|
-
|
|
7425
|
-
HeapArray<uint8_t> buf(alloc);
|
|
7426
|
-
|
|
7427
|
-
StreamReader reader(asset.data, nullptr, asset.compression_type);
|
|
7428
|
-
StreamWriter writer(&buf, nullptr, asset.compression_type);
|
|
7429
|
-
|
|
7430
7421
|
char c;
|
|
7431
|
-
while (reader
|
|
7422
|
+
while (reader->Read(1, &c) == 1) {
|
|
7432
7423
|
if (c == '{') {
|
|
7433
7424
|
char name[33] = {};
|
|
7434
|
-
Size name_len = reader
|
|
7425
|
+
Size name_len = reader->Read(1, &name[0]);
|
|
7435
7426
|
RG_ASSERT(name_len >= 0);
|
|
7436
7427
|
|
|
7437
7428
|
if (IsAsciiAlpha(name[0]) || name[0] == '_') {
|
|
7438
7429
|
do {
|
|
7439
|
-
Size read_len = reader
|
|
7430
|
+
Size read_len = reader->Read(1, &name[name_len]);
|
|
7440
7431
|
RG_ASSERT(read_len >= 0);
|
|
7441
7432
|
|
|
7442
7433
|
if (name[name_len] == '}') {
|
|
7443
7434
|
name[name_len] = 0;
|
|
7444
|
-
|
|
7435
|
+
|
|
7436
|
+
Span<const char> key = MakeSpan(name, name_len);
|
|
7437
|
+
func(key, writer);
|
|
7445
7438
|
|
|
7446
7439
|
break;
|
|
7447
7440
|
} else if (!IsAsciiAlphaOrDigit(name[name_len]) && name[name_len] != '_') {
|
|
7448
|
-
writer
|
|
7449
|
-
writer
|
|
7441
|
+
writer->Write('{');
|
|
7442
|
+
writer->Write(name, name_len + 1);
|
|
7450
7443
|
|
|
7451
7444
|
break;
|
|
7452
7445
|
}
|
|
7453
7446
|
} while (++name_len < RG_SIZE(name));
|
|
7454
7447
|
} else {
|
|
7455
|
-
writer
|
|
7456
|
-
writer
|
|
7448
|
+
writer->Write('{');
|
|
7449
|
+
writer->Write(name[0]);
|
|
7457
7450
|
}
|
|
7458
7451
|
} else {
|
|
7459
|
-
writer
|
|
7452
|
+
writer->Write(c);
|
|
7460
7453
|
}
|
|
7461
7454
|
}
|
|
7462
|
-
|
|
7455
|
+
|
|
7456
|
+
if (!reader->IsValid())
|
|
7457
|
+
return false;
|
|
7458
|
+
if (!writer->IsValid())
|
|
7459
|
+
return false;
|
|
7460
|
+
|
|
7461
|
+
return true;
|
|
7462
|
+
}
|
|
7463
|
+
|
|
7464
|
+
bool PatchFile(Span<const uint8_t> data, StreamWriter *writer,
|
|
7465
|
+
FunctionRef<void(Span<const char>, StreamWriter *)> func)
|
|
7466
|
+
{
|
|
7467
|
+
StreamReader reader(data, nullptr);
|
|
7468
|
+
|
|
7469
|
+
if (!PatchFile(&reader, writer, func)) {
|
|
7470
|
+
RG_ASSERT(reader.IsValid());
|
|
7471
|
+
return false;
|
|
7472
|
+
}
|
|
7473
|
+
|
|
7474
|
+
return true;
|
|
7475
|
+
}
|
|
7476
|
+
|
|
7477
|
+
bool PatchFile(const AssetInfo &asset, StreamWriter *writer,
|
|
7478
|
+
FunctionRef<void(Span<const char>, StreamWriter *)> func)
|
|
7479
|
+
{
|
|
7480
|
+
StreamReader reader(asset.data, nullptr, asset.compression_type);
|
|
7481
|
+
|
|
7482
|
+
if (!PatchFile(&reader, writer, func)) {
|
|
7483
|
+
RG_ASSERT(reader.IsValid());
|
|
7484
|
+
return false;
|
|
7485
|
+
}
|
|
7486
|
+
|
|
7487
|
+
return true;
|
|
7488
|
+
}
|
|
7489
|
+
|
|
7490
|
+
Span<const uint8_t> PatchFile(Span<const uint8_t> data, Allocator *alloc,
|
|
7491
|
+
FunctionRef<void(Span<const char>, StreamWriter *)> func)
|
|
7492
|
+
{
|
|
7493
|
+
RG_ASSERT(alloc);
|
|
7494
|
+
|
|
7495
|
+
HeapArray<uint8_t> buf(alloc);
|
|
7496
|
+
StreamWriter writer(&buf, nullptr);
|
|
7497
|
+
|
|
7498
|
+
PatchFile(data, &writer, func);
|
|
7499
|
+
|
|
7500
|
+
bool success = writer.Close();
|
|
7501
|
+
RG_ASSERT(success);
|
|
7502
|
+
|
|
7503
|
+
return buf.Leak();
|
|
7504
|
+
}
|
|
7505
|
+
|
|
7506
|
+
Span<const uint8_t> PatchFile(const AssetInfo &asset, Allocator *alloc,
|
|
7507
|
+
FunctionRef<void(Span<const char>, StreamWriter *)> func)
|
|
7508
|
+
{
|
|
7509
|
+
RG_ASSERT(alloc);
|
|
7510
|
+
|
|
7511
|
+
HeapArray<uint8_t> buf(alloc);
|
|
7512
|
+
StreamWriter writer(&buf, nullptr, asset.compression_type);
|
|
7513
|
+
|
|
7514
|
+
PatchFile(asset, &writer, func);
|
|
7463
7515
|
|
|
7464
7516
|
bool success = writer.Close();
|
|
7465
7517
|
RG_ASSERT(success);
|
package/src/core/libcc/libcc.hh
CHANGED
|
@@ -4610,8 +4610,17 @@ static inline const AssetInfo *FindPackedAsset(const char *name)
|
|
|
4610
4610
|
|
|
4611
4611
|
#endif
|
|
4612
4612
|
|
|
4613
|
-
|
|
4614
|
-
|
|
4613
|
+
// These functions won't win any beauty or speed contest but whatever
|
|
4614
|
+
bool PatchFile(StreamReader *reader, StreamWriter *writer,
|
|
4615
|
+
FunctionRef<void(Span<const char>, StreamWriter *)> func);
|
|
4616
|
+
bool PatchFile(Span<const uint8_t> data, StreamWriter *writer,
|
|
4617
|
+
FunctionRef<void(Span<const char>, StreamWriter *)> func);
|
|
4618
|
+
bool PatchFile(const AssetInfo &asset, StreamWriter *writer,
|
|
4619
|
+
FunctionRef<void(Span<const char>, StreamWriter *)> func);
|
|
4620
|
+
Span<const uint8_t> PatchFile(Span<const uint8_t> data, Allocator *alloc,
|
|
4621
|
+
FunctionRef<void(Span<const char> key, StreamWriter *)> func);
|
|
4622
|
+
Span<const uint8_t> PatchFile(const AssetInfo &asset, Allocator *alloc,
|
|
4623
|
+
FunctionRef<void(Span<const char> key, StreamWriter *)> func);
|
|
4615
4624
|
|
|
4616
4625
|
// ------------------------------------------------------------------------
|
|
4617
4626
|
// Options
|
|
@@ -21,17 +21,10 @@
|
|
|
21
21
|
|
|
22
22
|
'use strict';
|
|
23
23
|
|
|
24
|
-
const cnoke = require('
|
|
24
|
+
const cnoke = require('./cnoke/src/index.js');
|
|
25
25
|
const util = require('util');
|
|
26
26
|
const fs = require('fs');
|
|
27
|
-
|
|
28
|
-
const pkg = (() => {
|
|
29
|
-
try {
|
|
30
|
-
return require('../../../package.json');
|
|
31
|
-
} catch (err) {
|
|
32
|
-
return require('../package.json');
|
|
33
|
-
}
|
|
34
|
-
})();
|
|
27
|
+
const pkg = require('../package.json');
|
|
35
28
|
|
|
36
29
|
if (process.versions.napi == null || process.versions.napi < pkg.cnoke.napi) {
|
|
37
30
|
let major = parseInt(process.versions.node, 10);
|
|
@@ -45,16 +38,19 @@ if (process.versions.napi == null || process.versions.napi < pkg.cnoke.napi) {
|
|
|
45
38
|
}
|
|
46
39
|
|
|
47
40
|
let arch = cnoke.determine_arch();
|
|
48
|
-
let
|
|
41
|
+
let filenames = [__dirname + `/../build/${pkg.version}/koffi_${process.platform}_${arch}/koffi.node`];
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
filename = dev_filename;
|
|
43
|
+
if (process.resourcesPath != null) {
|
|
44
|
+
filenames.push(
|
|
45
|
+
process.resourcesPath + `/koffi/${pkg.version}/koffi_${process.platform}_${arch}/koffi.node`,
|
|
46
|
+
process.resourcesPath + `/build/${pkg.version}/koffi_${process.platform}_${arch}/koffi.node`
|
|
47
|
+
);
|
|
56
48
|
}
|
|
57
49
|
|
|
50
|
+
let filename = filenames.find(filename => fs.existsSync(filename));
|
|
51
|
+
if (filename == null)
|
|
52
|
+
throw new Error('Cannot find the native Koffi module; did you bundle it correctly?');
|
|
53
|
+
|
|
58
54
|
let native = require(filename);
|
|
59
55
|
|
|
60
56
|
module.exports = {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|