koffi 2.12.3 → 2.12.5-beta.1
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 +6 -0
- 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_loong64/koffi.node +0 -0
- package/build/koffi/linux_riscv64d/koffi.node +0 -0
- package/build/koffi/linux_x64/koffi.node +0 -0
- package/build/koffi/musl_arm64/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/index.d.ts +15 -13
- package/index.js +9 -9
- package/indirect.js +9 -9
- package/package.json +2 -2
- package/src/core/base/base.cc +395 -74
- package/src/core/base/base.hh +44 -11
- package/src/core/base/crc.inc +2232 -0
- package/src/core/base/crc_gen.py +109 -0
- package/src/koffi/src/ffi.cc +45 -28
- package/src/koffi/src/parser.cc +15 -21
- package/src/koffi/src/parser.hh +2 -3
package/src/core/base/base.hh
CHANGED
|
@@ -3975,6 +3975,16 @@ public:
|
|
|
3975
3975
|
operator FmtArg() const { return FmtCustom(*this); }
|
|
3976
3976
|
};
|
|
3977
3977
|
|
|
3978
|
+
class FmtEscape {
|
|
3979
|
+
Span<const char> str;
|
|
3980
|
+
|
|
3981
|
+
public:
|
|
3982
|
+
FmtEscape(Span<const char> str) : str(str) {}
|
|
3983
|
+
|
|
3984
|
+
void Format(FunctionRef<void(Span<const char>)> append) const;
|
|
3985
|
+
operator FmtArg() const { return FmtCustom(*this); }
|
|
3986
|
+
};
|
|
3987
|
+
|
|
3978
3988
|
class FmtUrlSafe {
|
|
3979
3989
|
Span<const char> str;
|
|
3980
3990
|
const char *passthrough;
|
|
@@ -4627,8 +4637,15 @@ const char *GetUserCachePath(const char *name, Allocator *alloc); // Can return
|
|
|
4627
4637
|
const char *GetSystemConfigPath(const char *name, Allocator *alloc);
|
|
4628
4638
|
const char *GetTemporaryDirectory();
|
|
4629
4639
|
|
|
4630
|
-
|
|
4631
|
-
|
|
4640
|
+
enum class FindConfigFlag {
|
|
4641
|
+
IgnoreAppDir = 1 << 0
|
|
4642
|
+
};
|
|
4643
|
+
|
|
4644
|
+
const char *FindConfigFile(const char *directory, Span<const char *const> names,
|
|
4645
|
+
Allocator *alloc, HeapArray<const char *> *out_possibilities = nullptr);
|
|
4646
|
+
static inline const char *FindConfigFile(Span<const char *const> names, Allocator *alloc,
|
|
4647
|
+
HeapArray<const char *> *out_possibilities = nullptr)
|
|
4648
|
+
{ return FindConfigFile(nullptr, names, alloc, out_possibilities); }
|
|
4632
4649
|
|
|
4633
4650
|
const char *CreateUniqueFile(Span<const char> directory, const char *prefix, const char *extension,
|
|
4634
4651
|
Allocator *alloc, int *out_fd = nullptr);
|
|
@@ -5498,8 +5515,6 @@ bool OptionToEnum(Span<const OptionDesc> options, Span<const char> str, T *out_v
|
|
|
5498
5515
|
template <typename T>
|
|
5499
5516
|
bool OptionToEnumI(Span<const char *const> options, Span<const char> str, T *out_value)
|
|
5500
5517
|
{
|
|
5501
|
-
static_assert(std::is_enum<T>::value);
|
|
5502
|
-
|
|
5503
5518
|
for (Size i = 0; i < options.len; i++) {
|
|
5504
5519
|
const char *opt = options[i];
|
|
5505
5520
|
|
|
@@ -5515,8 +5530,6 @@ bool OptionToEnumI(Span<const char *const> options, Span<const char> str, T *out
|
|
|
5515
5530
|
template <typename T>
|
|
5516
5531
|
bool OptionToEnumI(Span<const OptionDesc> options, Span<const char> str, T *out_value)
|
|
5517
5532
|
{
|
|
5518
|
-
static_assert(std::is_enum<T>::value);
|
|
5519
|
-
|
|
5520
5533
|
for (Size i = 0; i < options.len; i++) {
|
|
5521
5534
|
const OptionDesc &desc = options[i];
|
|
5522
5535
|
|
|
@@ -5593,6 +5606,11 @@ bool OptionToFlagI(Span<const OptionDesc> options, Span<const char> str, T *out_
|
|
|
5593
5606
|
// Console prompter (simplified readline)
|
|
5594
5607
|
// ------------------------------------------------------------------------
|
|
5595
5608
|
|
|
5609
|
+
struct PromptChoice {
|
|
5610
|
+
char c;
|
|
5611
|
+
const char *str;
|
|
5612
|
+
};
|
|
5613
|
+
|
|
5596
5614
|
class ConsolePrompter {
|
|
5597
5615
|
int prompt_columns = 0;
|
|
5598
5616
|
|
|
@@ -5620,15 +5638,16 @@ public:
|
|
|
5620
5638
|
ConsolePrompter();
|
|
5621
5639
|
|
|
5622
5640
|
bool Read(Span<const char> *out_str = nullptr);
|
|
5623
|
-
|
|
5641
|
+
Size ReadEnum(Span<const PromptChoice> choices, Size value = 0);
|
|
5624
5642
|
|
|
5625
5643
|
void Commit();
|
|
5626
5644
|
|
|
5627
5645
|
private:
|
|
5628
5646
|
bool ReadRaw(Span<const char> *out_str);
|
|
5629
|
-
bool ReadRawYN(bool *out_value);
|
|
5630
5647
|
bool ReadBuffered(Span<const char> *out_str);
|
|
5631
|
-
|
|
5648
|
+
|
|
5649
|
+
Size ReadRawEnum(Span<const PromptChoice> choices, Size value);
|
|
5650
|
+
Size ReadBufferedEnum(Span<const PromptChoice> choices);
|
|
5632
5651
|
|
|
5633
5652
|
void ChangeEntry(Size new_idx);
|
|
5634
5653
|
|
|
@@ -5639,6 +5658,8 @@ private:
|
|
|
5639
5658
|
|
|
5640
5659
|
void Delete(Size start, Size end);
|
|
5641
5660
|
|
|
5661
|
+
void FormatChoices(Span<const PromptChoice> choices, Size value);
|
|
5662
|
+
|
|
5642
5663
|
void RenderRaw();
|
|
5643
5664
|
void RenderBuffered();
|
|
5644
5665
|
|
|
@@ -5653,13 +5674,15 @@ private:
|
|
|
5653
5674
|
const char *Prompt(const char *prompt, const char *default_value, const char *mask, Allocator *alloc);
|
|
5654
5675
|
static inline const char *Prompt(const char *prompt, Allocator *alloc)
|
|
5655
5676
|
{ return Prompt(prompt, nullptr, nullptr, alloc); }
|
|
5656
|
-
|
|
5677
|
+
|
|
5678
|
+
Size PromptEnum(const char *prompt, Span<const PromptChoice> choices, Size value = 0);
|
|
5679
|
+
Size PromptEnum(const char *prompt, Span<const char *const> strings, Size value = 0);
|
|
5657
5680
|
|
|
5658
5681
|
// ------------------------------------------------------------------------
|
|
5659
5682
|
// Mime types
|
|
5660
5683
|
// ------------------------------------------------------------------------
|
|
5661
5684
|
|
|
5662
|
-
const char *GetMimeType(Span<const char> extension, const char *
|
|
5685
|
+
const char *GetMimeType(Span<const char> extension, const char *default_type = "application/octet-stream");
|
|
5663
5686
|
|
|
5664
5687
|
bool CanCompressFile(const char *filename);
|
|
5665
5688
|
|
|
@@ -5672,4 +5695,14 @@ int ComputeCharacterWidth(int32_t uc);
|
|
|
5672
5695
|
bool IsXidStart(int32_t uc);
|
|
5673
5696
|
bool IsXidContinue(int32_t uc);
|
|
5674
5697
|
|
|
5698
|
+
// ------------------------------------------------------------------------
|
|
5699
|
+
// CRC
|
|
5700
|
+
// ------------------------------------------------------------------------
|
|
5701
|
+
|
|
5702
|
+
uint32_t CRC32(uint32_t state, Span<const uint8_t> buf);
|
|
5703
|
+
uint32_t CRC32C(uint32_t state, Span<const uint8_t> buf);
|
|
5704
|
+
|
|
5705
|
+
uint64_t CRC64xz(uint64_t state, Span<const uint8_t> buf);
|
|
5706
|
+
uint64_t CRC64nvme(uint64_t state, Span<const uint8_t> buf);
|
|
5707
|
+
|
|
5675
5708
|
}
|