leptris 1.9.210.0-x86_64-linux → 1.9.210.1-x86_64-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ca7765a5d86b9c3985938b465495717e7145ddd1c791d06e610fed43df82c7f
4
- data.tar.gz: 3d702a97777edfcebdf2a9ec700d34220b6d626188ba22afff538d020c6ab5e5
3
+ metadata.gz: b67387b3f669ae9c37e8b1fdcd04616cf40eeabac9632c5c5cbb59b9ee18b71e
4
+ data.tar.gz: da145b10dceb9a4599c734ec2749f4d2c6de7087a9029a83323324f0444d1ee1
5
5
  SHA512:
6
- metadata.gz: a3e04b566c70563c17bbb76a19c3876b56cd174e0ddda3364ee56ea9d2231aabea79dbf96c16a60317ce9f0d1b9b928bafee5332cf851c020f2fb89f37a2cf8d
7
- data.tar.gz: eeb9f0c5e071989d67e4385b4dc03cb350635f8625ef69a26a99bab974f96bb5726aab82bdd1214eec4047e04f246b425ee79d4fa0852c808f5ceed92c7d7c8a
6
+ metadata.gz: 1fa3fcc5568b57775ed4968ddbc56d79be0d47c9e5728631f928231e71f2d3baa5d470fedee176a15159a4358aa88a507b7428619c89ea7a08061c0c14e7dd02
7
+ data.tar.gz: 82e8e6d7f3e9de5b267d78553b27f6aab06d98d7b9aa940442b9f9d614e1633f9eef763269ae485e162ff1ba4d76ec373e3f6484f9dc4048e2df5dac7a9727d7
data/CHANGELOG.md CHANGED
@@ -5,6 +5,29 @@ All notable changes to Leptris will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ### Added — Descriptor typed scalars + the fused materialize entry (#230's consumer contract)
11
+
12
+ - **Typed scalars**: attribute and child plan rows accept
13
+ `type: :string | :integer | :float | :boolean`. The tag travels
14
+ through the plan ABI (host-defined, echoed verbatim) and
15
+ `PlanValue#to_ruby` returns the cast value — Integer / Float /
16
+ true / false — on element scalars AND collected attributes, so
17
+ per-value cast probes disappear from the consumer's loop
18
+ (lutaml-model's `cast_element_present`/`apply_value_map` class
19
+ of cost). Lenient on unparseable input (raw String wins);
20
+ `#string_value` stays the raw escape hatch regardless of tag.
21
+ - **`Descriptor#materialize(source)`** — the fused loop, pointed
22
+ at the parse: source bytes → typed rows in ONE call (parse,
23
+ plan walk, document free; the standalone PlanValue tree is all
24
+ that surfaces). Byte-parity with parse + `#walk(root)`.
25
+ - Mirrors the yeptris schema-ABI shape (leptris/yeptris#238:
26
+ SCALAR + type_tag STR|INT|FLOAT|BOOL, whole-document results)
27
+ so a framework compiles one descriptor vocabulary and runs it
28
+ on every engine. Native in-pass int/float parsing (no string
29
+ round-trip) is the recorded engine-side headroom.
30
+
8
31
  ## [1.9.210.0] - 2026-09-20
9
32
 
10
33
  ### Performance — engine sync (1.9.210)
data/README.adoc CHANGED
@@ -67,8 +67,11 @@ vendors precompiled `libleptris` + `libutf8proc` binaries for the
67
67
  common engine platforms under `lib/leptris/vendor/`:
68
68
 
69
69
  - `arm64-darwin`, `x86_64-darwin`
70
- - `x86_64-linux`, `aarch64-linux` (glibc; the musl variants are
71
- tried as fallback for Alpine hosts)
70
+ - `x86_64-linux`, `aarch64-linux` (glibc) and `x86_64-linux-musl`,
71
+ `aarch64-linux-musl` (tried as fallback for Alpine hosts)
72
+ - `arm-linux`, `arm-linux-musl` (32-bit ARM EABI5)
73
+ - `ppc64le-linux`, `s390x-linux`, `s390x-linux-musl` (POWER8+ LE
74
+ and IBM Z, qemu-built)
72
75
 
73
76
  `gem install leptris` just works on both engines — the FFI layer
74
77
  selects the matching vendored binary at require time (the binding
@@ -127,7 +130,10 @@ Leptris::XML::FFI.leptris_last_error # => "..."
127
130
  `Leptris::XML.parse_html(html)` parses tolerant HTML4/5 into a
128
131
  standard Document — the same nodes, pool, serializer, and
129
132
  XPath/XSLT/XQuery machinery as XML (libleptris 1.9.75, the last
130
- Nokogiri capability gap):
133
+ Nokogiri capability gap). The `Leptris::HTML`, `Leptris::HTML4`,
134
+ and `Leptris::HTML5` module facades provide the
135
+ Nokogiri-shaped entry points over the same engine
136
+ (`Leptris::HTML5.parse(html)`, `Leptris::HTML(html)`):
131
137
 
132
138
  [source,ruby]
133
139
  ----
@@ -345,18 +351,45 @@ puts doc.to_xml
345
351
  `Element#replace(node)` / `#swap(node)` :: replace in parent.
346
352
  `Element#wrap(node_or_markup)` :: wrap this element in a new one.
347
353
  `Node#unlink` :: detach from the tree.
354
+ `Element#attribute_pairs` :: bulk read-only attribute listing — `[[name, value], ...]` in document order, duplicates included; one C crossing on the native layer (libleptris 1.9.210 era).
355
+
356
+ Document diffing (`Leptris::XML.diff(a, b)`) yields an op list with
357
+ `#ops`, per-kind counts via `#summary`
358
+ (`{update_attr: 1, insert: 1}`, `{}` when identical), and `#to_json`
359
+ for the op list — the `leptris diff --summary/--json` CLI modes'
360
+ library face.
348
361
 
349
362
  === Building from scratch (no parse)
350
363
 
364
+ `Document.create` starts an empty document; build up from there
365
+ (document-level prolog parts included — PIs, comments, the XML
366
+ declaration, and the DOCTYPE are all first-class):
367
+
351
368
  [source,ruby]
352
369
  ----
353
- # Create an empty Document by parsing a sentinel and replacing the root,
354
- # or build incrementally on a one-element seed.
355
- doc = Leptris::XML.parse("<root/>")
356
- doc.root.name = "catalog"
357
- # ... then create_element / add_child as above.
370
+ doc = Leptris::XML::Document.create
371
+ book = doc.create_element("book")
372
+ book[:id] = "b3"
373
+ book << doc.create_element("title")
374
+ doc.root = doc.create_element("catalog")
375
+ doc.root << book
376
+ doc.add_comment("built programmatically") # epilog comment
377
+ doc.set_doctype("catalog", system_id: "catalog.dtd")
378
+
379
+ puts doc.to_xml
358
380
  ----
359
381
 
382
+ [horizontal]
383
+ `Document.create` :: empty document (no root yet).
384
+ `Document#root=` :: attach the root element (bottom-up construction).
385
+ `Document#set_doctype(name, public_id:, system_id:)` :: programmatic DOCTYPE.
386
+ `Document#doctype` (alias `#internal_subset`) :: the `DocType` reader (name/root_name/public_id/system_id/internal_subset).
387
+ `Document#clear_declaration` :: un-set the XML declaration (serialize as if the input had none; idempotent).
388
+ `Document#remove_doctype` :: un-set the DOCTYPE (true when removed; the DocType stays readable until `#free`).
389
+ `Document#add_pi(target, data)` / `#remove_pi(target_or_index)` :: document-level processing instructions.
390
+ `Document#add_comment(str)` :: epilog comment.
391
+ `Document#create_entity_reference(name)` :: `&name;` node, serializes verbatim once attached.
392
+
360
393
  == Namespaces
361
394
 
362
395
  [horizontal]
@@ -711,11 +744,16 @@ Notable differences:
711
744
  past Document disposal will see the error; silence-replace-UAF patterns
712
745
  from Nokogiri do not apply.
713
746
  * No `Nokogiri::CSS` parser. HTML parsing is supported
714
- (`Leptris::XML.parse_html`, libleptris 1.9.75); Nokogiri's
747
+ (`Leptris::HTML` / `Leptris::HTML4` / `Leptris::HTML5` facades
748
+ over `Leptris::XML.parse_html`, libleptris 1.9.75); Nokogiri's
715
749
  HTML-specific node subclasses have no equivalent.
716
- * No RelaxNG / DTD validation, no schema caching (XSLT 1.0–3.0
750
+ * RelaxNG and DTD validation ARE supported (`Leptris::XML::RelaxNG`,
751
+ `Leptris::XML::DTD` — parse once, validate many, structured
752
+ errors). No W3C XML Schema and no schema caching (XSLT 1.0–3.0
717
753
  and an XQuery 1.0 core are supported — see above).
718
- * No built-in JRuby / TruffleRuby support only CRuby via `ffi`.
754
+ * TruffleRuby and JRuby ARE supported out of the box (#160): the
755
+ `ruby`-platform variant vendors precompiled binaries and the
756
+ binding is FFI-based (no MRI C extension required to load).
719
757
 
720
758
  == Performance
721
759
 
@@ -10,3 +10,18 @@ Status: DONE
10
10
  parse 10–12×, serialize 2.9–3.2×, inner_html 4–5×, attr reads
11
11
  6–9×, text 9–11×, element_children walks at parity. Will
12
12
  re-record on the next clean window (load < 15).
13
+
14
+ ## Re-recorded 2026-09-21 — clean window (load ~12, 1.9.210.0, 84k-element/1.3MB catalog, interleaved best-of-5, nokogiri 1.19.4)
15
+
16
+ - [x] Standing harness (MEDIUM fixture): parse medium **11.1x** /
17
+ small 1.88x; xpath 2.4-20x (predicate 15-20x, complex
18
+ 11-14x); traverse 1.5-1.7x; serialize 2.25-3.13x
19
+ - [x] Warm `children` walks **2.06-2.08x** (was 1.86x at 1.9.152)
20
+ - [x] Cold parse+first-touch walks **0.58-0.74x (avg ~0.66x)** —
21
+ the loss nearly HALVED from 0.34x; the engine's
22
+ document-block/arena work (1.9.210) shows here
23
+ - [x] Attr cold row (fresh wrappers) 1.18x
24
+ - [ ] **Open front: cold TEXT row 0.66x** — fresh text-node
25
+ materialization (`element_children.each(&:content)` cold)
26
+ loses where warm text aggregation was 6.18x. Next perf
27
+ round's target.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.210.0"
4
+ VERSION = "1.9.210.1"
5
5
  end
@@ -28,7 +28,33 @@ require "ffi"
28
28
  # Namespace binding per plan: +ns:+ is :none (default), :any, or
29
29
  # { exact: "urn:..." }; +flags: [:mixed_content, :ordered, :cdata,
30
30
  # :ns_lenient].
31
+ #
32
+ # == Typed scalars (#230's fused-consumer contract, mirroring the
33
+ # yeptris schema ABI)
34
+ #
35
+ # Attribute and child rows accept +type: :string (default),
36
+ # :integer, :float, or :boolean+. The tag travels through the plan
37
+ # ABI (host-defined, echoed verbatim) and PlanValue#to_ruby returns
38
+ # the cast value — Integer / Float / true / false — so per-value
39
+ # cast probes disappear from the consumer. Unparseable values fall
40
+ # back to the raw String (lenient, first-wins house style);
41
+ # #string_value always returns the raw String regardless of tag.
42
+ #
43
+ # descriptor = Leptris::XML::Descriptor.build(
44
+ # name: "catalog",
45
+ # children: [
46
+ # { name: "price", kind: :scalar, type: :float },
47
+ # { name: "in_stock", kind: :scalar, type: :boolean },
48
+ # ])
49
+ # descriptor.materialize(xml_source).to_ruby # typed, one call
31
50
  class Leptris::XML::Descriptor
51
+ TYPE_TAGS = {
52
+ string: 0,
53
+ integer: 1,
54
+ float: 2,
55
+ boolean: 3,
56
+ }.freeze
57
+ private_constant :TYPE_TAGS
32
58
  class Handle < ::FFI::AutoPointer
33
59
  def self.release(ptr)
34
60
  Leptris::XML::FFI.leptris_plan_free(ptr)
@@ -136,7 +162,7 @@ class Leptris::XML::Descriptor
136
162
  ap = Leptris::XML::FFI::AttrPlan.new(attr_memory[j])
137
163
  ap[:wire_name] = anchor_string(anchors, row.fetch(:name))
138
164
  ap[:kind] = kind_code(row[:kind] || :scalar)
139
- ap[:type_tag] = row[:type_tag] || 0
165
+ ap[:type_tag] = type_tag_code(row)
140
166
  end
141
167
  ep[:attribute_count] = attrs.size
142
168
  ep[:attribute_plans] = attr_memory
@@ -148,7 +174,7 @@ class Leptris::XML::Descriptor
148
174
  cp = Leptris::XML::FFI::ChildPlan.new(child_memory[j])
149
175
  cp[:wire_name] = anchor_string(anchors, row.fetch(:name))
150
176
  cp[:kind] = kind_code(row[:kind] || :scalar)
151
- cp[:type_tag] = row[:type_tag] || 0
177
+ cp[:type_tag] = type_tag_code(row)
152
178
  cp[:child_plan_index] = row[:child_plan_index] || -1
153
179
  # Rule-level ns form (libleptris 1.9.178, #1115): siblings
154
180
  # under one parent can require different URIs when set;
@@ -189,6 +215,20 @@ class Leptris::XML::Descriptor
189
215
  end
190
216
  private_class_method :kind_code
191
217
 
218
+ # +type: :string/:integer/:float/:boolean+ (or a raw numeric
219
+ # type_tag passthrough for hosts with their own vocabulary).
220
+ # Public: PlanValue's attribute casts share the vocabulary.
221
+ def self.type_tag_code(row)
222
+ if row.key?(:type)
223
+ TYPE_TAGS.fetch(row[:type]) do
224
+ raise ArgumentError,
225
+ "type must be one of #{TYPE_TAGS.keys.inspect}, got #{row[:type].inspect}"
226
+ end
227
+ else
228
+ row[:type_tag] || 0
229
+ end
230
+ end
231
+
192
232
  def initialize(handle, plans, root_index)
193
233
  @handle = handle
194
234
  @plans = plans
@@ -211,4 +251,21 @@ class Leptris::XML::Descriptor
211
251
  Leptris::XML::PlanValue.new(ResultHandle.new(raw),
212
252
  owner: true, plans: @plans, plan: @plans[0])
213
253
  end
254
+
255
+ # The fused loop (#230, pointed at the parse): source bytes →
256
+ # typed rows in ONE call — parse, walk the compiled plan, free
257
+ # the document; the returned PlanValue tree is standalone and
258
+ # the Document never surfaces. Byte-for-byte parity with
259
+ # #walk on the same source's root element.
260
+ def materialize(source)
261
+ document = Leptris::XML::Document.parse(source)
262
+ begin
263
+ root = document.root
264
+ raise Leptris::XML::Error,
265
+ "materialize: document has no root element" if root.nil?
266
+ walk(root)
267
+ ensure
268
+ document.free
269
+ end
270
+ end
214
271
  end
@@ -94,12 +94,40 @@ class Leptris::XML::PlanValue
94
94
  when :callback
95
95
  { value: string_value, position: position, type_tag: type_tag }
96
96
  else
97
- string_value
97
+ typed_string_value
98
98
  end
99
99
  end
100
100
 
101
101
  private
102
102
 
103
+ # SCALAR honoring the plan row's type tag (#230's typed-scalars
104
+ # contract): 1=Integer, 2=Float, 3=boolean. Lenient on
105
+ # unparseable input — the raw String wins (first-wins house
106
+ # style; strict validation belongs to the consumer's callback
107
+ # rows). #string_value stays the raw escape.
108
+ def typed_string_value
109
+ case type_tag
110
+ when 1
111
+ s = string_value
112
+ Integer(s, 10) rescue s
113
+ when 2
114
+ s = string_value
115
+ begin
116
+ Float(s)
117
+ rescue ArgumentError, TypeError
118
+ s
119
+ end
120
+ when 3
121
+ case string_value
122
+ when "true", "1" then true
123
+ when "false", "0" then false
124
+ else string_value
125
+ end
126
+ else
127
+ string_value
128
+ end
129
+ end
130
+
103
131
  # The element plan that a child row with this wire_name recurses
104
132
  # into (nil for non-nested rows — their values carry no plan).
105
133
  def child_row_plan(child_wire_name)
@@ -114,8 +142,31 @@ class Leptris::XML::PlanValue
114
142
  result = {}
115
143
  ((@plan && @plan[:attributes]) || []).each do |row|
116
144
  v = attribute(row[:name])
117
- result[row[:name]] = v unless v.nil?
145
+ result[row[:name]] = cast_attribute(v, row) unless v.nil?
118
146
  end
119
147
  result
120
148
  end
149
+
150
+ # Attribute values come back as plain Strings from the walk;
151
+ # apply the row's type tag with the same lenient semantics as
152
+ # typed_string_value.
153
+ def cast_attribute(value, row)
154
+ tag = Leptris::XML::Descriptor.type_tag_code(row)
155
+ case tag
156
+ when 1 then Integer(value, 10) rescue value
157
+ when 2
158
+ begin
159
+ Float(value)
160
+ rescue ArgumentError, TypeError
161
+ value
162
+ end
163
+ when 3
164
+ case value
165
+ when "true", "1" then true
166
+ when "false", "0" then false
167
+ else value
168
+ end
169
+ else value
170
+ end
171
+ end
121
172
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.210.0
4
+ version: 1.9.210.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Ribose Inc.