koffi 2.12.2 → 2.12.4
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 +16 -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 +226 -143
- package/index.js +9 -9
- package/indirect.js +9 -9
- package/package.json +2 -2
- package/src/core/base/base.cc +515 -78
- package/src/core/base/base.hh +56 -11
- package/src/core/base/crc.inc +2232 -0
- package/src/core/base/crc_gen.py +109 -0
- package/src/core/base/unicode.inc +426 -0
- package/src/core/{unicode/generate.py → base/unicode_gen.py} +84 -19
- package/src/koffi/CMakeLists.txt +0 -1
- package/src/koffi/src/ffi.cc +0 -1
- package/src/koffi/src/parser.cc +0 -1
- package/src/core/unicode/xid.cc +0 -52
- package/src/core/unicode/xid.hh +0 -29
- package/src/core/unicode/xid.inc +0 -465
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);
|
|
@@ -5192,6 +5209,9 @@ public:
|
|
|
5192
5209
|
CompressionSpeed compression_speed = CompressionSpeed::Default);
|
|
5193
5210
|
bool Close() { return Close(false); }
|
|
5194
5211
|
|
|
5212
|
+
// File-specific
|
|
5213
|
+
bool Rewind();
|
|
5214
|
+
|
|
5195
5215
|
// For compressed streams, Flush may not be complete and only Close() can finalize the file.
|
|
5196
5216
|
// Thread safe method
|
|
5197
5217
|
bool Flush();
|
|
@@ -5495,8 +5515,6 @@ bool OptionToEnum(Span<const OptionDesc> options, Span<const char> str, T *out_v
|
|
|
5495
5515
|
template <typename T>
|
|
5496
5516
|
bool OptionToEnumI(Span<const char *const> options, Span<const char> str, T *out_value)
|
|
5497
5517
|
{
|
|
5498
|
-
static_assert(std::is_enum<T>::value);
|
|
5499
|
-
|
|
5500
5518
|
for (Size i = 0; i < options.len; i++) {
|
|
5501
5519
|
const char *opt = options[i];
|
|
5502
5520
|
|
|
@@ -5512,8 +5530,6 @@ bool OptionToEnumI(Span<const char *const> options, Span<const char> str, T *out
|
|
|
5512
5530
|
template <typename T>
|
|
5513
5531
|
bool OptionToEnumI(Span<const OptionDesc> options, Span<const char> str, T *out_value)
|
|
5514
5532
|
{
|
|
5515
|
-
static_assert(std::is_enum<T>::value);
|
|
5516
|
-
|
|
5517
5533
|
for (Size i = 0; i < options.len; i++) {
|
|
5518
5534
|
const OptionDesc &desc = options[i];
|
|
5519
5535
|
|
|
@@ -5590,6 +5606,11 @@ bool OptionToFlagI(Span<const OptionDesc> options, Span<const char> str, T *out_
|
|
|
5590
5606
|
// Console prompter (simplified readline)
|
|
5591
5607
|
// ------------------------------------------------------------------------
|
|
5592
5608
|
|
|
5609
|
+
struct PromptChoice {
|
|
5610
|
+
char c;
|
|
5611
|
+
const char *str;
|
|
5612
|
+
};
|
|
5613
|
+
|
|
5593
5614
|
class ConsolePrompter {
|
|
5594
5615
|
int prompt_columns = 0;
|
|
5595
5616
|
|
|
@@ -5617,15 +5638,16 @@ public:
|
|
|
5617
5638
|
ConsolePrompter();
|
|
5618
5639
|
|
|
5619
5640
|
bool Read(Span<const char> *out_str = nullptr);
|
|
5620
|
-
|
|
5641
|
+
Size ReadEnum(Span<const PromptChoice> choices, Size value = 0);
|
|
5621
5642
|
|
|
5622
5643
|
void Commit();
|
|
5623
5644
|
|
|
5624
5645
|
private:
|
|
5625
5646
|
bool ReadRaw(Span<const char> *out_str);
|
|
5626
|
-
bool ReadRawYN(bool *out_value);
|
|
5627
5647
|
bool ReadBuffered(Span<const char> *out_str);
|
|
5628
|
-
|
|
5648
|
+
|
|
5649
|
+
Size ReadRawEnum(Span<const PromptChoice> choices, Size value);
|
|
5650
|
+
Size ReadBufferedEnum(Span<const PromptChoice> choices);
|
|
5629
5651
|
|
|
5630
5652
|
void ChangeEntry(Size new_idx);
|
|
5631
5653
|
|
|
@@ -5636,6 +5658,8 @@ private:
|
|
|
5636
5658
|
|
|
5637
5659
|
void Delete(Size start, Size end);
|
|
5638
5660
|
|
|
5661
|
+
void FormatChoices(Span<const PromptChoice> choices, Size value);
|
|
5662
|
+
|
|
5639
5663
|
void RenderRaw();
|
|
5640
5664
|
void RenderBuffered();
|
|
5641
5665
|
|
|
@@ -5650,14 +5674,35 @@ private:
|
|
|
5650
5674
|
const char *Prompt(const char *prompt, const char *default_value, const char *mask, Allocator *alloc);
|
|
5651
5675
|
static inline const char *Prompt(const char *prompt, Allocator *alloc)
|
|
5652
5676
|
{ return Prompt(prompt, nullptr, nullptr, alloc); }
|
|
5653
|
-
|
|
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);
|
|
5654
5680
|
|
|
5655
5681
|
// ------------------------------------------------------------------------
|
|
5656
5682
|
// Mime types
|
|
5657
5683
|
// ------------------------------------------------------------------------
|
|
5658
5684
|
|
|
5659
|
-
const char *GetMimeType(Span<const char> extension, const char *
|
|
5685
|
+
const char *GetMimeType(Span<const char> extension, const char *default_type = "application/octet-stream");
|
|
5660
5686
|
|
|
5661
5687
|
bool CanCompressFile(const char *filename);
|
|
5662
5688
|
|
|
5689
|
+
// ------------------------------------------------------------------------
|
|
5690
|
+
// Unicode
|
|
5691
|
+
// ------------------------------------------------------------------------
|
|
5692
|
+
|
|
5693
|
+
int ComputeCharacterWidth(int32_t uc);
|
|
5694
|
+
|
|
5695
|
+
bool IsXidStart(int32_t uc);
|
|
5696
|
+
bool IsXidContinue(int32_t uc);
|
|
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
|
+
|
|
5663
5708
|
}
|