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
|
@@ -51,16 +51,44 @@ LICENSE_HEADER = """// Copyright (C) 2025 Niels Martignène <niels.martignene@p
|
|
|
51
51
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
52
52
|
// OTHER DEALINGS IN THE SOFTWARE."""
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
WcWidthResult = namedtuple('WcWidthResult', ['null', 'wide'])
|
|
55
|
+
XidResult = namedtuple('XidResult', ['id_start', 'id_continue'])
|
|
55
56
|
|
|
56
|
-
def
|
|
57
|
+
def parse_version(core):
|
|
58
|
+
lines = iter(core.splitlines())
|
|
59
|
+
version = next(lines).strip("\n\r \t#") + ' -- ' + next(lines).strip("\n\r \t#")
|
|
60
|
+
|
|
61
|
+
return version
|
|
62
|
+
|
|
63
|
+
def parse_properties_wcwidth(core, asian):
|
|
64
|
+
null = []
|
|
65
|
+
wide = []
|
|
66
|
+
|
|
67
|
+
for (chars, parts, comments) in parse_properties(core):
|
|
68
|
+
if comments[0] in ['Me', 'Mn', 'Mc', 'Cf', 'Zl', 'Zp']:
|
|
69
|
+
null.extend(chars)
|
|
70
|
+
for (chars, parts, comments) in parse_properties(asian):
|
|
71
|
+
if parts[1] in ['F', 'W'] and not comments[0] in ['Mn', 'Mc']:
|
|
72
|
+
wide.extend(chars)
|
|
73
|
+
|
|
74
|
+
return WcWidthResult(null = compress(null),
|
|
75
|
+
wide = compress(wide))
|
|
76
|
+
|
|
77
|
+
def parse_properties_xid(core):
|
|
57
78
|
id_start = []
|
|
58
79
|
id_continue = []
|
|
59
80
|
|
|
60
|
-
|
|
61
|
-
|
|
81
|
+
for (chars, parts, comments) in parse_properties(core):
|
|
82
|
+
if parts[1] == 'ID_Start':
|
|
83
|
+
id_start.extend(chars)
|
|
84
|
+
elif parts[1] == 'ID_Continue':
|
|
85
|
+
id_continue.extend(chars)
|
|
62
86
|
|
|
63
|
-
|
|
87
|
+
return XidResult(id_start = compress(id_start),
|
|
88
|
+
id_continue = compress(id_continue))
|
|
89
|
+
|
|
90
|
+
def parse_properties(text):
|
|
91
|
+
for line in text.splitlines():
|
|
64
92
|
line = line.strip()
|
|
65
93
|
|
|
66
94
|
if not line or line[0] == '#':
|
|
@@ -69,29 +97,61 @@ def parse_properties_xid(text):
|
|
|
69
97
|
parts = [part.strip() for part in re.split('[;#]', line)]
|
|
70
98
|
if len(parts) < 3:
|
|
71
99
|
continue
|
|
100
|
+
comments = parts[2].split(' ')
|
|
72
101
|
|
|
73
102
|
if '..' in parts[0]:
|
|
74
103
|
start, end = parts[0].split('..')
|
|
75
104
|
else:
|
|
76
105
|
start, end = parts[0], parts[0]
|
|
77
106
|
start, end = int(start, 16), int(end, 16)
|
|
107
|
+
chars = list(range(start, end + 1))
|
|
78
108
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
109
|
+
yield (chars, parts, comments)
|
|
110
|
+
|
|
111
|
+
def compress(chars):
|
|
112
|
+
ranges = []
|
|
113
|
+
|
|
114
|
+
if chars:
|
|
115
|
+
chars = sorted(set(chars))
|
|
116
|
+
iterator = iter(chars)
|
|
83
117
|
|
|
84
|
-
|
|
118
|
+
prev = next(iterator)
|
|
119
|
+
start = prev
|
|
85
120
|
|
|
86
|
-
|
|
121
|
+
for c in iterator:
|
|
122
|
+
if c != prev + 1:
|
|
123
|
+
ranges.append((start, prev + 1))
|
|
124
|
+
start = c
|
|
125
|
+
prev = c
|
|
126
|
+
|
|
127
|
+
end = chars[-1] + 1
|
|
128
|
+
ranges.append((start, end))
|
|
129
|
+
|
|
130
|
+
return ranges
|
|
131
|
+
|
|
132
|
+
def write_header(version, wcwidth, xid, f):
|
|
87
133
|
f.write(f"""{LICENSE_HEADER}
|
|
88
134
|
|
|
89
|
-
// This file is autogenerated by
|
|
90
|
-
// Version: {
|
|
135
|
+
// This file is autogenerated by unicode_gen.py
|
|
136
|
+
// Version: {version}
|
|
91
137
|
|
|
92
138
|
namespace RG {{
|
|
93
139
|
|
|
94
|
-
static const int32_t
|
|
140
|
+
static const int32_t WcWidthNull[] = {{""")
|
|
141
|
+
for i, v in enumerate(wcwidth.null):
|
|
142
|
+
if i % 5 == 0: f.write('\n ')
|
|
143
|
+
f.write(f' 0x{v[0]:05X}, 0x{v[1]:05X}{"," if i + 1 < len(wcwidth.null) else ""}')
|
|
144
|
+
f.write("""
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
static const int32_t WcWidthWide[] = {""")
|
|
148
|
+
for i, v in enumerate(wcwidth.wide):
|
|
149
|
+
if i % 5 == 0: f.write('\n ')
|
|
150
|
+
f.write(f' 0x{v[0]:05X}, 0x{v[1]:05X}{"," if i + 1 < len(wcwidth.wide) else ""}')
|
|
151
|
+
f.write("""
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
static const int32_t XidStartTable[] = {""")
|
|
95
155
|
for i, v in enumerate(xid.id_start):
|
|
96
156
|
if i % 5 == 0: f.write('\n ')
|
|
97
157
|
f.write(f' 0x{v[0]:05X}, 0x{v[1]:05X}{"," if i + 1 < len(xid.id_start) else ""}')
|
|
@@ -116,9 +176,14 @@ if __name__ == "__main__":
|
|
|
116
176
|
|
|
117
177
|
url = args.url.strip('/') + '/ucd/'
|
|
118
178
|
|
|
119
|
-
# XID
|
|
120
179
|
with urllib.request.urlopen(url + 'DerivedCoreProperties.txt') as f:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
180
|
+
core = f.read().decode('UTF-8')
|
|
181
|
+
with urllib.request.urlopen(url + 'EastAsianWidth.txt') as f:
|
|
182
|
+
asian = f.read().decode('UTF-8')
|
|
183
|
+
|
|
184
|
+
version = parse_version(core)
|
|
185
|
+
wcwidth = parse_properties_wcwidth(core, asian)
|
|
186
|
+
xid = parse_properties_xid(core)
|
|
187
|
+
|
|
188
|
+
with open(os.path.join(args.output_dir, 'unicode.inc'), 'w') as f:
|
|
189
|
+
write_header(version, wcwidth, xid, f)
|
package/src/koffi/CMakeLists.txt
CHANGED
package/src/koffi/src/ffi.cc
CHANGED
package/src/koffi/src/parser.cc
CHANGED
package/src/core/unicode/xid.cc
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// Copyright (C) 2025 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 "src/core/base/base.hh"
|
|
23
|
-
#include "xid.inc"
|
|
24
|
-
|
|
25
|
-
namespace RG {
|
|
26
|
-
|
|
27
|
-
static bool TestUnicodeTable(Span<const int32_t> table, int32_t uc)
|
|
28
|
-
{
|
|
29
|
-
RG_ASSERT(table.len > 0);
|
|
30
|
-
RG_ASSERT(table.len % 2 == 0);
|
|
31
|
-
|
|
32
|
-
auto it = std::upper_bound(table.begin(), table.end(), uc,
|
|
33
|
-
[](int32_t uc, int32_t x) { return uc < x; });
|
|
34
|
-
Size idx = it - table.ptr;
|
|
35
|
-
|
|
36
|
-
// Each pair of value in table represents a valid interval
|
|
37
|
-
return idx & 0x1;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
bool IsXidStart(int32_t uc)
|
|
41
|
-
{
|
|
42
|
-
bool match = IsAsciiAlpha(uc) || uc == '_' || TestUnicodeTable(XidStartTable, uc);
|
|
43
|
-
return match;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
bool IsXidContinue(int32_t uc)
|
|
47
|
-
{
|
|
48
|
-
bool match = IsAsciiAlphaOrDigit(uc) || uc == '_' || TestUnicodeTable(XidContinueTable, uc);
|
|
49
|
-
return match;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}
|
package/src/core/unicode/xid.hh
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Copyright (C) 2025 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 "src/core/base/base.hh"
|
|
23
|
-
|
|
24
|
-
namespace RG {
|
|
25
|
-
|
|
26
|
-
bool IsXidStart(int32_t uc);
|
|
27
|
-
bool IsXidContinue(int32_t uc);
|
|
28
|
-
|
|
29
|
-
}
|