leptris 1.9.199.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.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3890 -0
  3. data/CLAUDE.md +115 -0
  4. data/CONTEXT.md +39 -0
  5. data/LICENSE.md +33 -0
  6. data/README.adoc +755 -0
  7. data/Rakefile +407 -0
  8. data/TODO.perf/01-ext-accelerated-default-reads.md +28 -0
  9. data/TODO.perf/02-auto-enable-native-layer.md +19 -0
  10. data/TODO.perf/03-bulk-xpath-result-materialization.md +18 -0
  11. data/TODO.perf/04-ext-bound-serialization.md +15 -0
  12. data/TODO.perf/05-native-surface-completion.md +19 -0
  13. data/TODO.perf/06-perf-battery-native-legs.md +16 -0
  14. data/TODO.perf/07-native-read-floor.md +31 -0
  15. data/TODO.perf/08-version-coherent-native-mutations.md +24 -0
  16. data/TODO.perf/09-adoption-lift-fast-path.md +38 -0
  17. data/TODO.perf/10-bulk-attribute-materialization.md +20 -0
  18. data/TODO.perf/11-moxml-gap-battery.md +18 -0
  19. data/TODO.perf/12-document-lifetime-in-c.md +47 -0
  20. data/TODO.perf/13-structural-memos.md +49 -0
  21. data/TODO.perf/14-insert-family-c-bound.md +31 -0
  22. data/TODO.perf/15-compiled-expression-cache.md +35 -0
  23. data/TODO.perf/16-at-xpath-single-result-seam.md +38 -0
  24. data/TODO.perf/17-precomputed-fast-path-flags.md +35 -0
  25. data/TODO.perf/18-inner-html-one-c-pass.md +32 -0
  26. data/TODO.perf/19-lazy-node-pointer.md +39 -0
  27. data/TODO.perf/20-css-translation-cache.md +24 -0
  28. data/TODO.perf/21-key-memo-consult.md +20 -0
  29. data/TODO.perf/22-eager-nodeset-materialization.md +30 -0
  30. data/TODO.perf/23-cbound-value-mutations.md +27 -0
  31. data/TODO.perf/24-immutable-read-lanes.md +22 -0
  32. data/TODO.perf/25-scope-owned-bulk-path.md +39 -0
  33. data/TODO.perf/26-post-mutation-memo-seeding.md +26 -0
  34. data/TODO.perf/27-c-yield-traversal.md +38 -0
  35. data/TODO.perf/28-address-fills.md +25 -0
  36. data/TODO.perf/29-ns-xpath-compiled.md +23 -0
  37. data/TODO.perf/30-copy-and-element-child-faces.md +31 -0
  38. data/TODO.perf/31-battery-rounds-4-8.md +23 -0
  39. data/TODO.perf/32-clean-host-floor-table.md +29 -0
  40. data/TODO.perf/33-cbound-root-set.md +29 -0
  41. data/TODO.perf/34-fragment-fast-lane.md +41 -0
  42. data/TODO.perf/35-parse-default-c-face.md +24 -0
  43. data/TODO.perf/36-raise-in-c-serializer-encoding.md +34 -0
  44. data/TODO.perf/37-document-lazy-pointer.md +28 -0
  45. data/TODO.perf/38-bulk-walk-and-bench-gate.md +23 -0
  46. data/TODO.restructure/01-constraint-compliance-audit.md +40 -0
  47. data/TODO.restructure/02-deep-copy-seam.md +21 -0
  48. data/TODO.restructure/03-evaluation-context-seam.md +18 -0
  49. data/TODO.restructure/04-spec-mece-restructure.md +20 -0
  50. data/TODO.restructure/05-memory-documentation.md +13 -0
  51. data/TODO.restructure/06-architecture-map-refresh.md +12 -0
  52. data/TODO.restructure/07-external-gates.md +16 -0
  53. data/TODO.restructure/08-new-code-audit-and-ext-memo.md +11 -0
  54. data/TODO.restructure/09-iteration-scope.md +29 -0
  55. data/TODO.restructure/10-cold-attr-read-diet.md +19 -0
  56. data/TODO.restructure/11-construction-factory-diet.md +16 -0
  57. data/TODO.restructure/12-resultattr-merge.md +12 -0
  58. data/TODO.restructure/13-spec-mece-followup.md +9 -0
  59. data/TODO.restructure/14-constraint-audit-refresh.md +15 -0
  60. data/TODO.restructure/15-readme-feature-documentation.md +10 -0
  61. data/TODO.restructure/16-claudemd-map-refresh.md +5 -0
  62. data/TODO.restructure/17-perf-drift-record.md +12 -0
  63. data/TODO.restructure/18-audit-spec-doubles-and-gem-contents.md +12 -0
  64. data/TODO.restructure/19-gitignore-hygiene.md +10 -0
  65. data/TODO.restructure/20-utf8proc-enablement.md +34 -0
  66. data/TODO.restructure/21-typeddata-variant-prototype.md +42 -0
  67. data/TODO.restructure/22-sax-drain-bulk-strip.md +28 -0
  68. data/docs/adr/0001-lockstep-mirror.md +17 -0
  69. data/docs/adr/0002-utf8-at-the-seam.md +19 -0
  70. data/docs/adr/0003-readonly-memoization-pattern.md +34 -0
  71. data/docs/adr/0004-lifetime-guard.md +21 -0
  72. data/docs/adr/0005-autoload-manifest-ordering.md +19 -0
  73. data/docs/adr/0006-ruby-variant-policy.md +25 -0
  74. data/ext/build_windows_native.rb +42 -0
  75. data/ext/leptris/native/extconf.rb +55 -0
  76. data/ext/leptris/native/native.c +2528 -0
  77. data/leptris.gemspec +43 -0
  78. data/lib/leptris/version.rb +5 -0
  79. data/lib/leptris/xml/attr.rb +76 -0
  80. data/lib/leptris/xml/c_string_array.rb +37 -0
  81. data/lib/leptris/xml/cdata.rb +27 -0
  82. data/lib/leptris/xml/comment.rb +27 -0
  83. data/lib/leptris/xml/css_to_xpath.rb +192 -0
  84. data/lib/leptris/xml/descriptor.rb +214 -0
  85. data/lib/leptris/xml/diff.rb +74 -0
  86. data/lib/leptris/xml/doc_type.rb +54 -0
  87. data/lib/leptris/xml/document.rb +716 -0
  88. data/lib/leptris/xml/document_fragment.rb +63 -0
  89. data/lib/leptris/xml/element.rb +771 -0
  90. data/lib/leptris/xml/entity_reference.rb +13 -0
  91. data/lib/leptris/xml/evaluation_context.rb +32 -0
  92. data/lib/leptris/xml/ffi.rb +1527 -0
  93. data/lib/leptris/xml/iteration_scope.rb +56 -0
  94. data/lib/leptris/xml/iterparse.rb +144 -0
  95. data/lib/leptris/xml/namespace.rb +43 -0
  96. data/lib/leptris/xml/native.so +0 -0
  97. data/lib/leptris/xml/native_layer.rb +92 -0
  98. data/lib/leptris/xml/node.rb +686 -0
  99. data/lib/leptris/xml/node_set.rb +212 -0
  100. data/lib/leptris/xml/parse_options.rb +97 -0
  101. data/lib/leptris/xml/plan_value.rb +121 -0
  102. data/lib/leptris/xml/processing_instruction.rb +90 -0
  103. data/lib/leptris/xml/pull.rb +212 -0
  104. data/lib/leptris/xml/relaxng.rb +126 -0
  105. data/lib/leptris/xml/result_attr.rb +39 -0
  106. data/lib/leptris/xml/result_text.rb +36 -0
  107. data/lib/leptris/xml/sax/document.rb +45 -0
  108. data/lib/leptris/xml/sax/dom_dispatch.rb +144 -0
  109. data/lib/leptris/xml/sax/parser.rb +326 -0
  110. data/lib/leptris/xml/sax/recorder.rb +374 -0
  111. data/lib/leptris/xml/sax.rb +14 -0
  112. data/lib/leptris/xml/schematron.rb +88 -0
  113. data/lib/leptris/xml/searchable.rb +361 -0
  114. data/lib/leptris/xml/serialization.rb +180 -0
  115. data/lib/leptris/xml/text.rb +32 -0
  116. data/lib/leptris/xml/xpath.rb +89 -0
  117. data/lib/leptris/xml/xquery.rb +77 -0
  118. data/lib/leptris/xml/xslt.rb +85 -0
  119. data/lib/leptris/xml.rb +108 -0
  120. data/lib/leptris.rb +53 -0
  121. data/lib/libleptris.so +0 -0
  122. data/lib/libutf8proc.so.3 +0 -0
  123. data/scripts/gem_smoke.rb +36 -0
  124. metadata +214 -0
data/CLAUDE.md ADDED
@@ -0,0 +1,115 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project
6
+
7
+ `leptris-ruby` is the official Ruby binding for `libleptris`
8
+ (https://github.com/leptris/leptris), a pure-C99 XML 1.0 parser with a
9
+ W3C-conformant XPath 1.0 engine (438/438 on the W3C suite), full SAX,
10
+ pull parsing, and C14N. The binding is **FFI-based** (no C extension,
11
+ no compilation at install) and ships **precompiled platform gems**
12
+ with the shared library vendored inside: x86_64/aarch64-linux (glibc
13
+ and musl), x86_64/arm64-darwin, x64-mingw32/ucrt, aarch64-mingw-ucrt,
14
+ plus the pure-Ruby fallback gem.
15
+
16
+ Version lockstep: the gem version is
17
+ `{libleptris full semver}.{binding patch}` — gem `1.9.76.0` pairs
18
+ with libleptris `1.9.76`; binding-only changes bump the fourth
19
+ segment (`1.9.76.1`), an upstream adoption moves to `{C}.0`. A C
20
+ release means one PR carrying version.rb + the Rakefile
21
+ `LIBLEPTRIS_VERSION` pin + the CHANGELOG entry, then the release
22
+ workflow (`next_version={C}.0`).
23
+
24
+ ## Commands
25
+
26
+ ```bash
27
+ bundle exec rake compile # build libleptris (pinned tarball) into lib/
28
+ bundle exec rspec # full suite (uses the vendored library)
29
+ bundle exec rspec spec/xml/xpath_spec.rb:42 # one example
30
+ bundle exec rake gem:native:arm64-darwin # platform gem
31
+ ```
32
+
33
+ `LEPTRIS_LIB_PATH=/path/to/libleptris.dylib bundle exec rspec` runs
34
+ against an arbitrary build (e.g. a libleptris checkout under test).
35
+
36
+ ## Architecture
37
+
38
+ The C DOM is the single source of truth; Ruby objects are thin FFI
39
+ handles. One Ruby method = one FFI call wherever possible.
40
+
41
+ ```
42
+ lib/leptris.rb — Leptris::VERSION + eager FFI bootstrap
43
+ lib/leptris/xml.rb — autoload registry, error classes,
44
+ Leptris::XML.parse / parse_html
45
+ lib/leptris/xml/ffi.rb — every public C declaration + seam
46
+ helpers (check_status, read_owned_string,
47
+ serialize_into_string, scratch buffers)
48
+ lib/leptris/xml/document.rb — the only C-memory owner (finalizer);
49
+ factories; Document.copy_of: the single
50
+ deep-copy seam behind Node#dup/Element#dup
51
+ lib/leptris/xml/node.rb — Node.wrap: the ONLY wrapper constructor
52
+ (identity cache + type dispatch,
53
+ ResultText for sequence items)
54
+ lib/leptris/xml/element.rb — attributes via the v1.1.0 iteration
55
+ face; namespace= (nil-detach/rebind)
56
+ lib/leptris/xml/result_text.rb — sequence/map/array result items
57
+ (values captured at materialization)
58
+ lib/leptris/xml/result_attr.rb — attribute-node result items
59
+ (name/value captured at materialization)
60
+ lib/leptris/xml/iteration_scope.rb — owning context for iterparse
61
+ elements (liveness, identity, memos)
62
+ lib/leptris/xml/node_set.rb — lazy XPath/XQuery results; batch fetch
63
+ via get_nodes_ex; ResultText capture
64
+ lib/leptris/xml/searchable.rb — xpath/css/at_*; result materialization
65
+ lib/leptris/xml/evaluation_context.rb — receiver -> (document,
66
+ context-node ptr) for the expression faces
67
+ lib/leptris/xml/xpath.rb — compiled expressions (parse once,
68
+ eval many)
69
+ lib/leptris/xml/xquery.rb — compiled XQuery 1.0 core face
70
+ lib/leptris/xml/xslt.rb — compiled XSLT 1.0-3.0 face
71
+ lib/leptris/xml/sax/ — callback SAX (streaming + DOM dispatch)
72
+ lib/leptris/xml/pull.rb — StAX-style pull parsing
73
+ lib/leptris/xml/iterparse.rb — bounded-memory element iteration
74
+ lib/leptris/xml/serialization.rb — serialize/c14n (Document + Element
75
+ one-liners over this module)
76
+ lib/leptris/xml/c_string_array.rb — NULL-terminated char** adapter
77
+ lib/leptris/xml/css_to_xpath.rb — minimal CSS translation
78
+ ```
79
+
80
+ ### Ownership and seams
81
+
82
+ - `Document` owns C memory (explicit `#free` or GC finalizer; wrapper
83
+ cache is a strong Hash cleared on free). Every other class is a
84
+ borrowed handle valid while its Document lives.
85
+ - All wrapper construction goes through `Node.wrap` — wrapper
86
+ identity (`doc.root.equal?(doc.root)`) is guaranteed by the
87
+ per-document cache.
88
+ - Status checks go through `FFI.check_status`; C `char*` returns go
89
+ through `FFI.read_owned_string`; array wire format (both
90
+ directions) goes through `CStringArray`. Never hand-roll these.
91
+ - The release workflow's publish loop is idempotent (already-published
92
+ gems are skipped).
93
+
94
+ ## Conventions
95
+
96
+ - Autoload only — no `require_relative` or intra-library `require`
97
+ inside `lib/` (sanctioned exceptions, with reasons in-file:
98
+ `leptris/version` at the gem root and the eager FFI bootstrap).
99
+ - No `instance_variable_set`/`_get` across objects; no `send` to
100
+ private methods; no `respond_to?` type checks (dispatch on types
101
+ with `is_a?`/`case`); specs use real documents, never doubles.
102
+ - New C surface: attach in `ffi.rb`, sugar where it earns its keep,
103
+ specs against a locally built library, CHANGELOG, lockstep release.
104
+ - All changes via PRs; no AI attribution; `git add` explicit paths.
105
+
106
+ ## Reference
107
+
108
+ - Domain vocabulary: CONTEXT.md. Settled decisions: docs/adr/ —
109
+ check both before proposing refactors; they exist so reviews
110
+ stop re-deriving settled questions.
111
+ - libleptris public headers (`src/include/leptris/*.h`) are the
112
+ contract; when symbols change, bump lockstep and run
113
+ `rake audit:symbols` (attached == exported on the vendored
114
+ library; fails listing both directions of drift).
115
+ - Upstream issues worth tracking live at leptris/leptris.
data/CONTEXT.md ADDED
@@ -0,0 +1,39 @@
1
+ # Domain glossary
2
+
3
+ The vocabulary for talking about leptris-ruby. Architecture reviews
4
+ use these names; see docs/adr/ for settled decisions.
5
+
6
+ **The DOM** — the C tree built by libleptris. Single source of
7
+ truth: every Ruby object is a view over it, and one Ruby method is
8
+ one FFI call wherever possible.
9
+
10
+ **The seam** — `Leptris::XML::FFI`: every attach, every struct
11
+ layout, every buffer protocol, and the encoding policy (UTF-8 on
12
+ both faces: returns and callback params). ABI knowledge appears
13
+ nowhere else (document.rb's finalizer is ownership machinery;
14
+ CStringArray is the char** adapter).
15
+
16
+ **Ownership / the borrowed handle** — Document owns C memory
17
+ (explicit `#free` or GC finalizer); every other object (Node,
18
+ Element, Text, Comment, CDATA, PI, Attr, DocumentFragment, DocType)
19
+ is a handle borrowed for its document's lifetime. Mutations raise
20
+ ReadOnlyError on readonly documents; use of a handle after `#free`
21
+ raises UseAfterFreeError.
22
+
23
+ **Wrapper identity** — `Node.wrap` is the only wrapper constructor;
24
+ the per-document strong cache makes the same C node always yield the
25
+ same Ruby object (`doc.root.equal?(doc.root)`).
26
+
27
+ **The readonly contract** — `readonly: true` makes reads memoizable
28
+ because they cannot go stale; every read method follows the same
29
+ three-line pattern (return memo → compute → store memo). Mutations
30
+ are refused; detached factories still work.
31
+
32
+ **Lockstep** — the gem's major.minor tracks libleptris; a C release
33
+ is one PR (version.rb + Rakefile pin + CHANGELOG) then the release
34
+ workflow; ffi.rb mirrors the public header so the attached-vs-
35
+ exported audit (`nm -gU`) catches drift.
36
+
37
+ **The recover mode** — `recover: true` parses return an empty
38
+ document with the failure recorded on the thread-global last error
39
+ (+ position), instead of raising ParseError.
data/LICENSE.md ADDED
@@ -0,0 +1,33 @@
1
+ Licenses & Copyright
2
+ ====================
3
+
4
+ This license file adheres to the formatting guidelines of
5
+ [readable-licenses](https://github.com/nevir/readable-licenses).
6
+
7
+
8
+ Ribose's BSD 2-Clause License
9
+ -----------------------------
10
+
11
+ Copyright (c) 2025, [Ribose Inc](https://www.ribose.com).
12
+ All rights reserved.
13
+
14
+ Redistribution and use in source and binary forms, with or without modification,
15
+ are permitted provided that the following conditions are met:
16
+
17
+ 1. Redistributions of source code must retain the above copyright notice,
18
+ this list of conditions and the following disclaimer.
19
+
20
+ 2. Redistributions in binary form must reproduce the above copyright notice,
21
+ this list of conditions and the following disclaimer in the documentation
22
+ and/or other materials provided with the distribution.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
28
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.