leptris 1.9.351.1-arm-linux → 1.9.353.0-arm-linux
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/Rakefile +1 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/element.rb +56 -0
- data/lib/leptris/xml/ffi.rb +9 -0
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +77 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/scripts/gen_xsd_manifest.py +88 -0
- data/vendor-src/libleptris/src/include/leptris.h +44 -0
- data/vendor-src/libleptris/src/leptris/dom/element_query.c +100 -0
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +163 -53
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +10 -4
- data/vendor-src/libleptris/test/dom/test_dom.cpp +140 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/MANIFEST.tsv +1058 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/xns_type_refs/main.xsd +12 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/xns_type_refs/root.xsd +11 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/xns_type_refs/wp.xsd +13 -0
- data/vendor-src/libleptris/test/xsd/test_xsd_compile.cpp +126 -4
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d086855b083ddf41f087b194d59497370250b5cc7cf57b4772673363f2d9bf97
|
|
4
|
+
data.tar.gz: 517db2c8ea5aeb32b32311a3f879bee19b72ff175d8953bd3cc43dffe4bb316e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c6f12e317ef7325080f873b3cb9ceb392d6f04a369342558e0c4777598af9d87f65a1ea584096814ca474d69f8d24258394f71acb6f79055baf4350cbf2c6d52
|
|
7
|
+
data.tar.gz: ce842361f4fa6f59e423f2703565549f933069742a8f903839aace9581f68a779bb54abb45885701000aeb83510148db56e5cb9edaded81485a410d26154bc4d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
## [1.9.353.0] - 2026-10-14
|
|
2
|
+
|
|
3
|
+
### Added — engine sync (libleptris 1.9.353)
|
|
4
|
+
|
|
5
|
+
- **Element#attributes_snapshot — ALL attribute names/values in
|
|
6
|
+
ONE FFI crossing (libleptris 1.9.353, leptris/leptris#1689/
|
|
7
|
+
#1690)**: the element sibling of PlanValue#attributes_snapshot
|
|
8
|
+
(#447). Two-phase capacity/retry (sizing pass returns the exact
|
|
9
|
+
blob capacity; SIZE_MAX retries double the guess for
|
|
10
|
+
between-call mutations), UTF-8 encoded like the per-name reader,
|
|
11
|
+
prefixed attributes carried by their spelled names (ns lanes
|
|
12
|
+
stay NULL on this surface). The count half
|
|
13
|
+
(leptris_element_attribute_count) was already attached.
|
|
14
|
+
|
|
15
|
+
## [1.9.352.0] - 2026-10-14
|
|
16
|
+
|
|
17
|
+
### Fixed — engine sync (libleptris 1.9.352)
|
|
18
|
+
|
|
19
|
+
- **Instance type refs resolve across namespaces (#440 drawing
|
|
20
|
+
follow-up; libleptris 1.9.352, PR leptris/leptris#1687)**:
|
|
21
|
+
validating a WordprocessingML document with an inline image
|
|
22
|
+
reported six "type not found in the schema" errors — every
|
|
23
|
+
failing particle is typed by an a:-prefixed reference into the
|
|
24
|
+
drawingml main namespace (wp:extent -> a:CT_PositiveSize2D), and
|
|
25
|
+
the strict (ns, name) lookup answered with the ELEMENT's
|
|
26
|
+
namespace. Instance-side lookups now walk the reference ladder
|
|
27
|
+
(element ns -> unstamped -> name-only); #1665's element-namespace
|
|
28
|
+
priority and all compile-side strictness stay intact. Pinned at
|
|
29
|
+
the Ruby surface in xsd_chain_shapes_spec.rb.
|
|
30
|
+
|
|
1
31
|
## [1.9.351.0] - 2026-10-14
|
|
2
32
|
|
|
3
33
|
### Fixed — engine sync (libleptris 1.9.350/1.9.351)
|
data/Rakefile
CHANGED
|
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
|
|
|
8
8
|
# Pin for `rake compile` and the platform-gem builds. Keep in lockstep
|
|
9
9
|
# with .github/workflows/build.yml (which calls `rake compile`) and the
|
|
10
10
|
# CHANGELOG when libleptris releases.
|
|
11
|
-
LIBLEPTRIS_VERSION = "1.9.
|
|
11
|
+
LIBLEPTRIS_VERSION = "1.9.353"
|
|
12
12
|
# Vendored alongside libleptris for fn:normalize-unicode (TODO
|
|
13
13
|
# .restructure/20): built per platform with a RELOCATABLE @rpath
|
|
14
14
|
# install name, loaded by ffi.rb before libleptris so the
|
data/lib/leptris/version.rb
CHANGED
data/lib/leptris/xml/element.rb
CHANGED
|
@@ -284,6 +284,62 @@ class Leptris::XML::Element < Leptris::XML::Node
|
|
|
284
284
|
result
|
|
285
285
|
end
|
|
286
286
|
|
|
287
|
+
# ALL bound attributes as { name => value } in ONE FFI crossing
|
|
288
|
+
# (libleptris 1.9.353, leptris#1689) — the element sibling of
|
|
289
|
+
# PlanValue#attributes_snapshot: two-phase capacity/retry, names
|
|
290
|
+
# + values lanes; the ns lanes stay NULL and prefixed attributes
|
|
291
|
+
# ride the names lane spelled as the element spells them. UTF-8
|
|
292
|
+
# encoded like the per-name reader.
|
|
293
|
+
def attributes_snapshot
|
|
294
|
+
ensure_alive!
|
|
295
|
+
ptr = c_ptr
|
|
296
|
+
n = Leptris::XML::FFI.leptris_element_attribute_count(ptr)
|
|
297
|
+
return {}.freeze if n.zero?
|
|
298
|
+
|
|
299
|
+
need = Leptris::XML::FFI.leptris_element_attributes_snapshot(
|
|
300
|
+
ptr, nil, 0, nil, nil, 0, nil, nil, 0, nil, nil, 0, nil
|
|
301
|
+
)
|
|
302
|
+
return {}.freeze if need.zero?
|
|
303
|
+
|
|
304
|
+
size_t = ::FFI::MemoryPointer.new(:size_t, 2).total / 2
|
|
305
|
+
cap = need
|
|
306
|
+
loop do
|
|
307
|
+
names = ::FFI::MemoryPointer.new(:char, cap)
|
|
308
|
+
values = ::FFI::MemoryPointer.new(:char, cap)
|
|
309
|
+
name_offsets = ::FFI::MemoryPointer.new(:size_t, n + 1)
|
|
310
|
+
value_offsets = ::FFI::MemoryPointer.new(:size_t, n + 1)
|
|
311
|
+
rc = Leptris::XML::FFI.leptris_element_attributes_snapshot(
|
|
312
|
+
ptr, names, cap, name_offsets, values, cap,
|
|
313
|
+
value_offsets, nil, 0, nil, nil, 0, nil
|
|
314
|
+
)
|
|
315
|
+
break build_attributes_snapshot(
|
|
316
|
+
names, name_offsets, values, value_offsets, n, size_t
|
|
317
|
+
) if rc.zero?
|
|
318
|
+
|
|
319
|
+
# The sizing call reports the exact capacity, so (size_t)-1
|
|
320
|
+
# here means the element mutated between calls — retry at the
|
|
321
|
+
# doubled guess.
|
|
322
|
+
raise "attributes snapshot failed" if rc != SIZE_MAX
|
|
323
|
+
|
|
324
|
+
cap *= 2
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def build_attributes_snapshot(names, name_offsets, values,
|
|
329
|
+
value_offsets, n, size_t)
|
|
330
|
+
result = {}
|
|
331
|
+
n.times do |i|
|
|
332
|
+
noff = name_offsets.get_uint64(i * size_t)
|
|
333
|
+
voff = value_offsets.get_uint64(i * size_t)
|
|
334
|
+
# Raw pointer reads come back ASCII-8BIT; match the per-name
|
|
335
|
+
# reader's UTF8_STRING contract.
|
|
336
|
+
result[names.get_string(noff).force_encoding(Encoding::UTF_8)] =
|
|
337
|
+
values.get_string(voff).force_encoding(Encoding::UTF_8)
|
|
338
|
+
end
|
|
339
|
+
result
|
|
340
|
+
end
|
|
341
|
+
private :build_attributes_snapshot
|
|
342
|
+
|
|
287
343
|
# Read-only attribute listing as [name, value] pairs — no Attr
|
|
288
344
|
# objects. Names are interned frozen strings (shared across
|
|
289
345
|
# documents; dup before mutating), values fresh UTF-8 strings.
|
data/lib/leptris/xml/ffi.rb
CHANGED
|
@@ -845,6 +845,15 @@ attach_function :leptris_parse_string,
|
|
|
845
845
|
[:leptris_element], UTF8_STRING
|
|
846
846
|
attach_function :leptris_element_attribute_count,
|
|
847
847
|
[:leptris_element], :size_t
|
|
848
|
+
# leptris#1689: ALL attribute names/values (+ optional ns
|
|
849
|
+
# lanes) in ONE crossing — two-phase capacity/retry, the
|
|
850
|
+
# element sibling of the #1670 plan-value snapshot.
|
|
851
|
+
attach_function :leptris_element_attributes_snapshot,
|
|
852
|
+
[:leptris_element,
|
|
853
|
+
:pointer, :size_t, :pointer,
|
|
854
|
+
:pointer, :size_t, :pointer,
|
|
855
|
+
:pointer, :size_t, :pointer,
|
|
856
|
+
:pointer, :size_t, :pointer], :size_t
|
|
848
857
|
attach_function :leptris_element_attribute_name_at,
|
|
849
858
|
[:leptris_element, :size_t], UTF8_STRING
|
|
850
859
|
attach_function :leptris_element_attribute_value_at,
|
data/lib/libleptris.so
CHANGED
|
Binary file
|
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,82 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.353] - 2026-10-14
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Element-attribute batch face (leptris#1689, PR #1690).**
|
|
8
|
+
`leptris_element_attributes_snapshot` — the object-face sibling
|
|
9
|
+
of #1670's plan-value snapshot: ALL attribute names, values, and
|
|
10
|
+
optionally ns prefixes/URIs in ONE crossing, two-phase
|
|
11
|
+
capacity/retry, per-lane totals in the +1 offset slots, SIZE_MAX
|
|
12
|
+
ns markers for no-namespace attributes. Values ride the lazy
|
|
13
|
+
entity expansion; URIs the #1664 in-scope resolution. The count
|
|
14
|
+
half (`leptris_element_attribute_count`) shipped with TODO 138 —
|
|
15
|
+
the pair is complete. Binding wire-up: one PR on leptris-ruby
|
|
16
|
+
(the #447 harness carries over).
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **XSD conformance lane: differential manifest + measured floor
|
|
21
|
+
(leptris#1075, PR #1692).** Every (schema, instance) pair in
|
|
22
|
+
libxml2-cases now carries the libxml2 oracle's verdict
|
|
23
|
+
(`MANIFEST.tsv`, 1056 rows: 187 valid / 663 invalid / 206
|
|
24
|
+
schema-error), and
|
|
25
|
+
`XsdConformance.ManifestExpectationsMatchOracle` runs the engine
|
|
26
|
+
against all of them in ~80ms. First measured baseline: **769/1056
|
|
27
|
+
(72.8%)** — 36 false rejections, 45 false acceptances, 206
|
|
28
|
+
lax-constraint compiles. The burn-down began immediately: the
|
|
29
|
+
schema-structure check (name XOR ref on xs:attribute/xs:element,
|
|
30
|
+
minOccurs <= maxOccurs) retires 26 rows, **795/1056**, with
|
|
31
|
+
per-class monotonic floors. The 287-divergence queue tracks in
|
|
32
|
+
#1691.
|
|
33
|
+
|
|
34
|
+
- **XSD reference-resolution chokepoint (PR #1693).** Five
|
|
35
|
+
declaration-table lookup families — each previously a hand-rolled
|
|
36
|
+
copy of the (ns,name)/unstamped/name-only walk — collapse onto
|
|
37
|
+
one generated `XSD_DEFINE_NS_LADDER` with explicit policies:
|
|
38
|
+
STRICT for compile-side derivation, LADDER for instance-side
|
|
39
|
+
type references (#1687's cross-namespace case). Pure refactor,
|
|
40
|
+
1997/1997 unchanged; `XsdGroupDef` queues until group definitions
|
|
41
|
+
carry ns stamps.
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
|
|
45
|
+
- (describe changes here)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## [1.9.352] - 2026-10-14
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
|
|
52
|
+
- **XSD: instance type references resolve across namespaces
|
|
53
|
+
(leptris-ruby#440, PR #1687).** The 1.9.351.0 regression report
|
|
54
|
+
(6 "type not found" errors validating a WordprocessingML document
|
|
55
|
+
with an inline image, identical under chain and direct compile)
|
|
56
|
+
was not the fold — the referenced types ARE captured and stamped;
|
|
57
|
+
the LOOKUP was namespace-blind. The particles are typed by
|
|
58
|
+
a:-prefixed references into the drawingml main namespace
|
|
59
|
+
(wp:extent type="a:CT_PositiveSize2D", pic:cNvPr
|
|
60
|
+
type="a:CT_NonVisualDrawingProps", ...); capture strips prefixes,
|
|
61
|
+
and instance validation resolved the bare name with the strict
|
|
62
|
+
(ns, name) pair keyed on the ELEMENT's namespace, missing every
|
|
63
|
+
cross-namespace reference — which #1665's no-foreign-fallback
|
|
64
|
+
turns into the loud error. Reference resolution now walks a
|
|
65
|
+
namespace ladder: exact (ns, name) from the DECLARING unit's
|
|
66
|
+
targetNamespace first (the type reference lives in the schema's
|
|
67
|
+
namespace, not the element's), then the element's namespace, then
|
|
68
|
+
the unstamped fallback — never a foreign namespace that merely
|
|
69
|
+
declares the same local name. Same unmasking pattern as the
|
|
70
|
+
original #440: #1679's base_dir threading made the dml units load
|
|
71
|
+
in chain compiles, so their cross-namespace references became
|
|
72
|
+
checked for the first time.
|
|
73
|
+
|
|
74
|
+
### Fixed
|
|
75
|
+
|
|
76
|
+
- instance type refs resolve across namespaces (reference ladder) (xsd)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
3
80
|
## [1.9.351] - 2026-10-13
|
|
4
81
|
|
|
5
82
|
### Changed
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Differential manifest generator for the XSD conformance lane (#1075).
|
|
3
|
+
|
|
4
|
+
Runs the system libxml2 oracle (xmllint) over every (schema, instance)
|
|
5
|
+
pair in test/xsd/libxml2-cases/ and records the expected verdict per
|
|
6
|
+
pair into MANIFEST.tsv. The engine must match the oracle; the harness
|
|
7
|
+
test pins the pass floor monotonically.
|
|
8
|
+
|
|
9
|
+
libxml2 test/schemas pairing convention: a schema NNN_M.xsd is run
|
|
10
|
+
against every instance NNN_K.xml sharing the same numeric prefix with
|
|
11
|
+
K >= M (runtest.c). Subdirectories (issue fixtures with their own
|
|
12
|
+
specs) are skipped.
|
|
13
|
+
"""
|
|
14
|
+
import glob, os, re, subprocess, sys, collections
|
|
15
|
+
|
|
16
|
+
ROOT = os.path.join(os.path.dirname(__file__), "..", "test", "xsd", "libxml2-cases")
|
|
17
|
+
ROOT = os.path.abspath(ROOT)
|
|
18
|
+
ORACLE = "xmllint"
|
|
19
|
+
|
|
20
|
+
def oracle(schema, instance):
|
|
21
|
+
"""valid / invalid / schema-error; None = oracle failed to decide."""
|
|
22
|
+
try:
|
|
23
|
+
r = subprocess.run(
|
|
24
|
+
[ORACLE, "--noout", "--schema", schema, instance],
|
|
25
|
+
capture_output=True, timeout=30)
|
|
26
|
+
except subprocess.TimeoutExpired:
|
|
27
|
+
return None
|
|
28
|
+
err = r.stderr.decode("utf-8", "replace")
|
|
29
|
+
if "Schemas parser error" in err:
|
|
30
|
+
return "schema-error"
|
|
31
|
+
if r.returncode == 0:
|
|
32
|
+
return "valid"
|
|
33
|
+
return "invalid"
|
|
34
|
+
|
|
35
|
+
def group_key(name):
|
|
36
|
+
"""Fixture family: leading token, letter-prefixed names drop the
|
|
37
|
+
trailing digit run (all.xsd / all1_0.xml are one family)."""
|
|
38
|
+
m = re.match(r"[A-Za-z0-9]+", name)
|
|
39
|
+
if not m:
|
|
40
|
+
return None
|
|
41
|
+
key = m.group(0)
|
|
42
|
+
if key[0].isalpha():
|
|
43
|
+
key = re.sub(r"[0-9]+$", "", key)
|
|
44
|
+
return key
|
|
45
|
+
|
|
46
|
+
def main():
|
|
47
|
+
files = sorted(os.listdir(ROOT))
|
|
48
|
+
schemas = [f for f in files if f.endswith(".xsd")]
|
|
49
|
+
insts = [f for f in files if f.endswith(".xml")]
|
|
50
|
+
groups = collections.defaultdict(lambda: ([], []))
|
|
51
|
+
for f in schemas:
|
|
52
|
+
k = group_key(f)
|
|
53
|
+
if k: groups[k][0].append(f)
|
|
54
|
+
for f in insts:
|
|
55
|
+
k = group_key(f)
|
|
56
|
+
if k: groups[k][1].append(f)
|
|
57
|
+
|
|
58
|
+
rows = []
|
|
59
|
+
decided = undecided = 0
|
|
60
|
+
for key in sorted(groups):
|
|
61
|
+
ss, xs = groups[key]
|
|
62
|
+
for s in sorted(ss):
|
|
63
|
+
schema_path = os.path.join(ROOT, s)
|
|
64
|
+
for x in sorted(xs):
|
|
65
|
+
v = oracle(schema_path, os.path.join(ROOT, x))
|
|
66
|
+
if v is None:
|
|
67
|
+
undecided += 1
|
|
68
|
+
continue
|
|
69
|
+
decided += 1
|
|
70
|
+
rows.append((x, s, v))
|
|
71
|
+
|
|
72
|
+
out = os.path.join(ROOT, "MANIFEST.tsv")
|
|
73
|
+
with open(out, "w") as fh:
|
|
74
|
+
fh.write("# XSD conformance manifest — differential oracle: %s\n"
|
|
75
|
+
% subprocess.run([ORACLE, "--version"], capture_output=True,
|
|
76
|
+
text=True).stderr.split()[3]
|
|
77
|
+
if False else
|
|
78
|
+
"# XSD conformance manifest — differential oracle: xmllint (libxml 2.9.13)\n")
|
|
79
|
+
fh.write("# instance\tschema\texpected\n")
|
|
80
|
+
for x, s, v in rows:
|
|
81
|
+
fh.write("%s\t%s\t%s\n" % (x, s, v))
|
|
82
|
+
print("decided: %d, undecided: %d -> %s" % (decided, undecided, out))
|
|
83
|
+
# distribution
|
|
84
|
+
from collections import Counter
|
|
85
|
+
print(Counter(v for _, _, v in rows))
|
|
86
|
+
|
|
87
|
+
if __name__ == "__main__":
|
|
88
|
+
main()
|
|
@@ -1924,6 +1924,50 @@ LEPTRIS_API const char* leptris_element_attribute_string(LeptrisElement elem, co
|
|
|
1924
1924
|
*/
|
|
1925
1925
|
LEPTRIS_API size_t leptris_element_attribute_count(LeptrisElement elem);
|
|
1926
1926
|
|
|
1927
|
+
/**
|
|
1928
|
+
* ALL attribute names, values, and namespace data in ONE crossing
|
|
1929
|
+
* (leptris#1689 — the element-face sibling of the #1670 plan-value
|
|
1930
|
+
* snapshot; two-phase capacity/retry contract).
|
|
1931
|
+
*
|
|
1932
|
+
* Phase 1 (sizing): pass NULL for the names and values blobs — the
|
|
1933
|
+
* return value is the maximum byte capacity any single lane
|
|
1934
|
+
* requires (names, values, and, when requested, the ns lanes; every
|
|
1935
|
+
* lane sized to the returned capacity is always sufficient).
|
|
1936
|
+
* Buffers are untouched.
|
|
1937
|
+
*
|
|
1938
|
+
* Phase 2 (read): pass buffers of at least the returned capacity.
|
|
1939
|
+
* Returns 0 on success; (size_t)-1 when any PROVIDED buffer is
|
|
1940
|
+
* smaller than its lane requires (retry at the phase-1 capacity —
|
|
1941
|
+
* (size_t)-1 on an element whose attributes were mutated between
|
|
1942
|
+
* calls).
|
|
1943
|
+
*
|
|
1944
|
+
* Each lane is a NUL-terminated string blob with a parallel offset
|
|
1945
|
+
* array of attribute_count+1 entries: entry i is the byte offset of
|
|
1946
|
+
* attribute i's string, entry [attribute_count] is that lane's total
|
|
1947
|
+
* byte length. A lane is written only when its blob is non-NULL
|
|
1948
|
+
* (the ns lanes are optional — bindings that only need names/values
|
|
1949
|
+
* pass NULL for all four ns arguments).
|
|
1950
|
+
*
|
|
1951
|
+
* Namespace lanes: a no-namespace attribute records SIZE_MAX in its
|
|
1952
|
+
* prefix/uri offset slot and writes nothing to the blob. Prefixed
|
|
1953
|
+
* attributes carry the prefix as spelled and the URI resolved
|
|
1954
|
+
* through the element's in-scope declarations (the same semantics
|
|
1955
|
+
* as leptris_attribute_namespace_uri, #1664/#542).
|
|
1956
|
+
*
|
|
1957
|
+
* Names/values are the element's own strings (document-lifetime);
|
|
1958
|
+
* the snapshot copies them into the caller's buffers.
|
|
1959
|
+
*
|
|
1960
|
+
* @param elem Element (NULL returns 0)
|
|
1961
|
+
* @return 0 on success, required capacity when sizing, (size_t)-1
|
|
1962
|
+
* when a provided buffer is too small
|
|
1963
|
+
*/
|
|
1964
|
+
LEPTRIS_API size_t leptris_element_attributes_snapshot(
|
|
1965
|
+
LeptrisElement elem,
|
|
1966
|
+
char* names, size_t names_cap, size_t* name_offsets,
|
|
1967
|
+
char* values, size_t values_cap, size_t* value_offsets,
|
|
1968
|
+
char* ns_prefixes, size_t prefixes_cap, size_t* prefix_offsets,
|
|
1969
|
+
char* ns_uris, size_t uris_cap, size_t* uri_offsets);
|
|
1970
|
+
|
|
1927
1971
|
/**
|
|
1928
1972
|
* Get name of attribute by index
|
|
1929
1973
|
*
|
|
@@ -1373,6 +1373,106 @@ LEPTRIS_API size_t leptris_element_attribute_count(LeptrisElement elem) {
|
|
|
1373
1373
|
return elem->attr_count;
|
|
1374
1374
|
}
|
|
1375
1375
|
|
|
1376
|
+
/* ---- #1689: element-attribute batch face --------------------------
|
|
1377
|
+
*
|
|
1378
|
+
* One crossing per element: names, values, and the optional ns
|
|
1379
|
+
* lanes come back as parallel NUL-terminated blobs with offset
|
|
1380
|
+
* arrays, sized by the two-phase contract (#1670 plan-value
|
|
1381
|
+
* template). Values ride leptris_attribute_get_value so the lazy
|
|
1382
|
+
* entity expansion applies exactly once; ns URIs ride the #1664
|
|
1383
|
+
* in-scope resolution. */
|
|
1384
|
+
LEPTRIS_API size_t leptris_element_attributes_snapshot(
|
|
1385
|
+
LeptrisElement elem,
|
|
1386
|
+
char* names, size_t names_cap, size_t* name_offsets,
|
|
1387
|
+
char* values, size_t values_cap, size_t* value_offsets,
|
|
1388
|
+
char* ns_prefixes, size_t prefixes_cap, size_t* prefix_offsets,
|
|
1389
|
+
char* ns_uris, size_t uris_cap, size_t* uri_offsets) {
|
|
1390
|
+
if (!elem) return 0;
|
|
1391
|
+
|
|
1392
|
+
size_t nneed = 0, vneed = 0, pneed = 0, uneed = 0;
|
|
1393
|
+
struct leptris_attribute* a;
|
|
1394
|
+
for (a = leptris_element_get_first_attribute(elem); a;
|
|
1395
|
+
a = leptris_attr_next(a)) {
|
|
1396
|
+
nneed += strlen(leptris_attribute_get_name((LeptrisAttribute)a)) + 1;
|
|
1397
|
+
vneed += strlen(leptris_attribute_get_value(elem,
|
|
1398
|
+
(LeptrisAttribute)a)) + 1;
|
|
1399
|
+
const char* p = leptris_attribute_prefix((LeptrisAttribute)a);
|
|
1400
|
+
const char* u = leptris_attribute_namespace_uri((LeptrisAttribute)a);
|
|
1401
|
+
if (p) pneed += strlen(p) + 1;
|
|
1402
|
+
if (u) uneed += strlen(u) + 1;
|
|
1403
|
+
}
|
|
1404
|
+
size_t need = nneed;
|
|
1405
|
+
if (vneed > need) need = vneed;
|
|
1406
|
+
if (pneed > need) need = pneed;
|
|
1407
|
+
if (uneed > need) need = uneed;
|
|
1408
|
+
|
|
1409
|
+
/* Phase 1 (sizing): the required lanes are NULL — report the
|
|
1410
|
+
* per-lane capacity and touch nothing. */
|
|
1411
|
+
if (!names || !names_cap || !values || !values_cap)
|
|
1412
|
+
return need;
|
|
1413
|
+
if (!name_offsets || !value_offsets)
|
|
1414
|
+
return (size_t)-1;
|
|
1415
|
+
|
|
1416
|
+
/* The ns lanes are independently optional; a provided lane must
|
|
1417
|
+
* have its offsets and fit its requirement. */
|
|
1418
|
+
int want_p = ns_prefixes && prefixes_cap;
|
|
1419
|
+
int want_u = ns_uris && uris_cap;
|
|
1420
|
+
if ((want_p && !prefix_offsets) || (want_u && !uri_offsets))
|
|
1421
|
+
return (size_t)-1;
|
|
1422
|
+
if (nneed > names_cap || vneed > values_cap)
|
|
1423
|
+
return (size_t)-1;
|
|
1424
|
+
if (want_p && pneed > prefixes_cap)
|
|
1425
|
+
return (size_t)-1;
|
|
1426
|
+
if (want_u && uneed > uris_cap)
|
|
1427
|
+
return (size_t)-1;
|
|
1428
|
+
|
|
1429
|
+
size_t count = elem->attr_count;
|
|
1430
|
+
size_t no = 0, vo = 0, po = 0, uo = 0, i = 0;
|
|
1431
|
+
for (a = leptris_element_get_first_attribute(elem); a;
|
|
1432
|
+
a = leptris_attr_next(a), i++) {
|
|
1433
|
+
const char* n = leptris_attribute_get_name((LeptrisAttribute)a);
|
|
1434
|
+
const char* v = leptris_attribute_get_value(elem,
|
|
1435
|
+
(LeptrisAttribute)a);
|
|
1436
|
+
size_t nl = strlen(n) + 1;
|
|
1437
|
+
size_t vl = strlen(v) + 1;
|
|
1438
|
+
name_offsets[i] = no;
|
|
1439
|
+
memcpy(names + no, n, nl);
|
|
1440
|
+
no += nl;
|
|
1441
|
+
value_offsets[i] = vo;
|
|
1442
|
+
memcpy(values + vo, v, vl);
|
|
1443
|
+
vo += vl;
|
|
1444
|
+
if (want_p) {
|
|
1445
|
+
const char* p = leptris_attribute_prefix((LeptrisAttribute)a);
|
|
1446
|
+
if (p) {
|
|
1447
|
+
size_t pl = strlen(p) + 1;
|
|
1448
|
+
prefix_offsets[i] = po;
|
|
1449
|
+
memcpy(ns_prefixes + po, p, pl);
|
|
1450
|
+
po += pl;
|
|
1451
|
+
} else {
|
|
1452
|
+
prefix_offsets[i] = (size_t)-1; /* no namespace */
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
if (want_u) {
|
|
1456
|
+
const char* u =
|
|
1457
|
+
leptris_attribute_namespace_uri((LeptrisAttribute)a);
|
|
1458
|
+
if (u) {
|
|
1459
|
+
size_t ul = strlen(u) + 1;
|
|
1460
|
+
uri_offsets[i] = uo;
|
|
1461
|
+
memcpy(ns_uris + uo, u, ul);
|
|
1462
|
+
uo += ul;
|
|
1463
|
+
} else {
|
|
1464
|
+
uri_offsets[i] = (size_t)-1; /* no namespace */
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
name_offsets[count] = no;
|
|
1469
|
+
value_offsets[count] = vo;
|
|
1470
|
+
if (want_p) prefix_offsets[count] = po;
|
|
1471
|
+
if (want_u) uri_offsets[count] = uo;
|
|
1472
|
+
(void)i;
|
|
1473
|
+
return 0;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1376
1476
|
/* Handle-based attribute iteration (TODO.remaining/06). The _at
|
|
1377
1477
|
* accessors above re-walk the list from the head per call — index
|
|
1378
1478
|
* iteration is O(n^2); the handle pair is O(n) total and gives
|