lutaml-model 0.8.167 → 0.8.168
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/.github/workflows/downstream-performance.yml +5 -0
- data/Gemfile +1 -1
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/leptris/native_emission.rb +145 -116
- data/lib/lutaml/xml/leptris/plan_compiler.rb +17 -9
- data/lib/lutaml/xml/leptris.rb +8 -4
- data/spec/lutaml/xml/leptris/emission_graph_deferred_spec.rb +34 -0
- data/spec/lutaml/xml/leptris/native_emission_render_contract_spec.rb +89 -0
- metadata +3 -2
- data/spec/lutaml/xml/leptris/native_emission_raw_gate_spec.rb +0 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dccd6b591db573af7a95aedba2d2ee63b0b63c8f7d5dc728e9eea3e3f783a201
|
|
4
|
+
data.tar.gz: 9c305247097d0d3dd7c680022e1890caaa5116aad634f0c2b518fc0b3995deea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c714643359a9bea977fd832fe5893d848fc367f88a064d98f9534091b1bbf1c38876d1398b7ae1d252bc318eee485cb481ab9e350fede9c6fbf1f9da2456c795
|
|
7
|
+
data.tar.gz: 8c8182e6387347352ec8982adbcb3294d714b17c74b72aa28dd8f2ee9f5a17a2eedd3867e40504d63e813a357ff38d2846e58504961115336f9d64e7659498b5
|
|
@@ -185,6 +185,11 @@ jobs:
|
|
|
185
185
|
# create-pull-request push 403s on every main push (#1128).
|
|
186
186
|
permissions:
|
|
187
187
|
contents: write
|
|
188
|
+
# create-pull-request opens the baseline PR through the API —
|
|
189
|
+
# the git push (contents:write) authenticates, but PR creation
|
|
190
|
+
# needs its own grant ("Resource not accessible by
|
|
191
|
+
# integration").
|
|
192
|
+
pull-requests: write
|
|
188
193
|
steps:
|
|
189
194
|
# persist-credentials: false — checkout's persisted Authorization
|
|
190
195
|
# extraheader collides with create-pull-request's own token on the
|
data/Gemfile
CHANGED
|
@@ -49,7 +49,7 @@ gem "rexml"
|
|
|
49
49
|
# exact-URI attribute rows, nested-attribute capture, wildcard rows,
|
|
50
50
|
# walk-side ns retention and leniency, :unqualified rows, and the
|
|
51
51
|
# address-based text attach all ride it.
|
|
52
|
-
gem "leptris", ">= 1.9.
|
|
52
|
+
gem "leptris", ">= 1.9.406.0" # RAW op (leptris#1941) — matches MIN_LEPTRIS_VERSION, the single capability line; the emission lane additionally version-gates namespaced trees to >= 1.9.407.0 (attr ns_prefix deep-copy, leptris#1967/#1968)
|
|
53
53
|
gem "teptris"
|
|
54
54
|
gem "yeptris" unless Gem.win_platform?
|
|
55
55
|
# TODO: revert rng branch to main when lutaml/rng#32 is merged
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -35,6 +35,7 @@ module Lutaml
|
|
|
35
35
|
ORDERED_ROW_KINDS = %i[scalar collection_native collection_cb
|
|
36
36
|
nested ordered_deferred].freeze
|
|
37
37
|
DEFERRED_ROW_KINDS = %i[raw ordered_deferred].freeze
|
|
38
|
+
PLANNED_ROW_KINDS = %i[nested ordered_deferred].freeze
|
|
38
39
|
NESTED_ROW_KINDS = %i[nested ordered_deferred].freeze
|
|
39
40
|
NS_EMITTABLE_ROW_KINDS = %i[scalar collection nested
|
|
40
41
|
collection_native
|
|
@@ -52,16 +53,17 @@ module Lutaml
|
|
|
52
53
|
:lutaml_model_leptris_native_emission_op_buffer_base
|
|
53
54
|
|
|
54
55
|
class << self
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
# plan: the compiled plan; instance: the emitting instance.
|
|
57
|
+
# A nil instance runs the static checks only.
|
|
58
|
+
def compatible?(plan, instance = nil, register = nil)
|
|
59
|
+
return false if plan.nil?
|
|
60
|
+
return false if namespaced_tree?(plan[:tree]) &&
|
|
61
|
+
!engine_ns_prefix_safe?
|
|
62
|
+
return false unless ordered_ns_emittable?(plan, instance)
|
|
63
|
+
return false if plan[:ordered] && instance.is_a?(::Lutaml::Model::Serialize) &&
|
|
64
|
+
instance.element_order.nil?
|
|
65
|
+
|
|
66
|
+
subtree_gate_ok?(plan, instance, register)
|
|
65
67
|
end
|
|
66
68
|
|
|
67
69
|
# The engine's attr-row ns_prefix deep-copy fix rides
|
|
@@ -69,11 +71,12 @@ module Lutaml
|
|
|
69
71
|
# engines keep the binding's freed FFI anchor pointer in the
|
|
70
72
|
# built plan and read freed heap bytes at serialize time —
|
|
71
73
|
# garbage prefixes (CT_RPr:val) and empty output (the
|
|
72
|
-
# lutaml-model#1126 uniword signatures)
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
74
|
+
# lutaml-model#1126 uniword signatures) on every EXACT-ns
|
|
75
|
+
# row the ops lane emits. A pure bugfix release ships no
|
|
76
|
+
# capability constant, so this is a version-floor gate like
|
|
77
|
+
# MIN_LEPTRIS_VERSION — the floor is the capability line.
|
|
78
|
+
# Namespace-less trees never consult the descriptor's ns
|
|
79
|
+
# rows and stay on the lane regardless.
|
|
77
80
|
def engine_ns_prefix_safe?(version = ::Leptris::VERSION)
|
|
78
81
|
Gem::Version.new(version.to_s) >=
|
|
79
82
|
Gem::Version.new("1.9.407.0")
|
|
@@ -95,27 +98,13 @@ module Lutaml
|
|
|
95
98
|
|
|
96
99
|
(tree[:children] || []).any? do |r|
|
|
97
100
|
next true if r[:ns].is_a?(::Hash)
|
|
98
|
-
next false unless r[:
|
|
101
|
+
next false unless r[:plan] &&
|
|
102
|
+
PLANNED_ROW_KINDS.include?(r[:kind])
|
|
99
103
|
|
|
100
104
|
namespaced_tree?(r[:plan])
|
|
101
105
|
end
|
|
102
106
|
end
|
|
103
107
|
|
|
104
|
-
# plan: the compiled plan; instance: the emitting instance.
|
|
105
|
-
# A nil instance runs the static checks only.
|
|
106
|
-
def compatible?(plan, instance = nil, register = nil)
|
|
107
|
-
return false if plan.nil?
|
|
108
|
-
return false unless raw_op_supported?
|
|
109
|
-
return false if namespaced_tree?(plan[:tree]) &&
|
|
110
|
-
!engine_ns_prefix_safe?
|
|
111
|
-
return false unless ordered_ns_emittable?(plan, instance)
|
|
112
|
-
return false if plan[:ordered] && instance.is_a?(::Lutaml::Model::Serialize) &&
|
|
113
|
-
instance.element_order.nil?
|
|
114
|
-
|
|
115
|
-
subtree_gate_ok?(plan, instance, register,
|
|
116
|
-
prefixed_source?(instance))
|
|
117
|
-
end
|
|
118
|
-
|
|
119
108
|
# Prefixed spelling is only faithful when the ROOT instance
|
|
120
109
|
# preserves a prefixed source: the DOM lane inherits the
|
|
121
110
|
# root's prefix spelling down the tree (nested children
|
|
@@ -135,20 +124,35 @@ module Lutaml
|
|
|
135
124
|
# it. The identity map mirrors that numbering exactly —
|
|
136
125
|
# op plan_index values are these absolute slots.
|
|
137
126
|
def emission_graph_for(plan, register)
|
|
127
|
+
slot_map(emission_tree_for(plan, register))
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# THE slot numbering (leptris#1966 SSOT): every consumer
|
|
131
|
+
# numbering the tree — the emission graph, the flat layout,
|
|
132
|
+
# the ruby gem's flatten_plan — must derive from THIS walk:
|
|
133
|
+
# identity-memoized pre-order over planned rows. Shared
|
|
134
|
+
# subtrees (memoized plans reachable from many parents —
|
|
135
|
+
# the theme docx's clrScheme/fontScheme shapes) get ONE
|
|
136
|
+
# slot at first encounter; occurrence-arithmetic (counting
|
|
137
|
+
# a shared subtree's size at every reference) drifts 70/75
|
|
138
|
+
# nodes on that document and handed the engine op streams
|
|
139
|
+
# whose plan_index pointed at the wrong plan.
|
|
140
|
+
def slot_map(tree)
|
|
138
141
|
map = {}.compare_by_identity
|
|
139
142
|
counter = [0]
|
|
140
|
-
walk = lambda do |
|
|
141
|
-
return map[
|
|
143
|
+
walk = lambda do |t|
|
|
144
|
+
return map[t] if map.key?(t)
|
|
142
145
|
|
|
143
146
|
idx = counter[0]
|
|
144
147
|
counter[0] += 1
|
|
145
|
-
map[
|
|
146
|
-
(
|
|
147
|
-
walk.call(r[:plan]) if r[:
|
|
148
|
+
map[t] = idx
|
|
149
|
+
(t[:children] || []).each do |r|
|
|
150
|
+
walk.call(r[:plan]) if r[:plan] &&
|
|
151
|
+
PLANNED_ROW_KINDS.include?(r[:kind])
|
|
148
152
|
end
|
|
149
153
|
idx
|
|
150
154
|
end
|
|
151
|
-
walk.call(
|
|
155
|
+
walk.call(tree)
|
|
152
156
|
map
|
|
153
157
|
end
|
|
154
158
|
|
|
@@ -159,9 +163,7 @@ module Lutaml
|
|
|
159
163
|
# clrScheme → color → ordered srgbClr) must ride the
|
|
160
164
|
# emission descriptor + identity graph — ops against the
|
|
161
165
|
# parse descriptor reference child plans the compiled tree
|
|
162
|
-
# never materialized (:raw rows carry no plan)
|
|
163
|
-
# engine rejects the program (INVALID_ARG, -5) or cross-
|
|
164
|
-
# wires subtree slots.
|
|
166
|
+
# never materialized (:raw rows carry no plan).
|
|
165
167
|
def deferred_rows?(tree)
|
|
166
168
|
(tree[:children] || []).any? do |r|
|
|
167
169
|
next true if DEFERRED_ROW_KINDS.include?(r[:kind])
|
|
@@ -178,10 +180,7 @@ module Lutaml
|
|
|
178
180
|
# instance must carry a pristine parse-built element_order
|
|
179
181
|
# with Element/Text entries only (comments and PIs keep the
|
|
180
182
|
# DOM lane; mutation reroutes through the reconciler).
|
|
181
|
-
def subtree_gate_ok?(plan, instance, register
|
|
182
|
-
prefixed_source = nil)
|
|
183
|
-
prefixed_source = prefixed_source?(instance) if
|
|
184
|
-
prefixed_source.nil?
|
|
183
|
+
def subtree_gate_ok?(plan, instance, register)
|
|
185
184
|
return false unless plan[:rows].all? do |row|
|
|
186
185
|
gate_row_kind?(row, register)
|
|
187
186
|
end
|
|
@@ -198,7 +197,7 @@ module Lutaml
|
|
|
198
197
|
|
|
199
198
|
return true unless instance.is_a?(::Lutaml::Model::Serialize)
|
|
200
199
|
|
|
201
|
-
plan[:rows].each do |(rule, attr, kind, _sp, delegate,
|
|
200
|
+
plan[:rows].each do |(rule, attr, kind, _sp, delegate, _type)|
|
|
202
201
|
next unless rule.name
|
|
203
202
|
next if kind == :child_deferred
|
|
204
203
|
next unless NESTED_ROW_KINDS.include?(kind)
|
|
@@ -207,24 +206,14 @@ module Lutaml
|
|
|
207
206
|
Array(value).each do |item|
|
|
208
207
|
next unless item
|
|
209
208
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
child_plan = child_type.is_a?(Class) &&
|
|
216
|
-
PlanCompiler.compile(child_type, register)
|
|
209
|
+
# leptris#1966: the emit compiles the ITEM CLASS's
|
|
210
|
+
# plan (nested_plans[[item.class, name]]) — the gate
|
|
211
|
+
# must gate exactly what emit emits. Unknown classes
|
|
212
|
+
# refuse here: the doc takes the DOM lane.
|
|
213
|
+
child_plan = PlanCompiler.compile(item.class, register)
|
|
217
214
|
return false unless child_plan
|
|
218
|
-
# The ns gate is per-tree and per-instance: a
|
|
219
|
-
# namespace-less parent can nest namespaced children
|
|
220
|
-
# whose EXACT rows would still spell prefix:local,
|
|
221
|
-
# and each child preserves (or not) its own source
|
|
222
|
-
# prefix.
|
|
223
|
-
return false unless ordered_ns_emittable?(child_plan,
|
|
224
|
-
prefixed_source)
|
|
225
215
|
return false unless subtree_gate_ok?(child_plan, item,
|
|
226
|
-
register
|
|
227
|
-
prefixed_source)
|
|
216
|
+
register)
|
|
228
217
|
end
|
|
229
218
|
end
|
|
230
219
|
true
|
|
@@ -276,18 +265,19 @@ module Lutaml
|
|
|
276
265
|
end
|
|
277
266
|
end
|
|
278
267
|
|
|
279
|
-
# Only two shapes ride the ops lane:
|
|
280
|
-
#
|
|
281
|
-
#
|
|
282
|
-
# -
|
|
283
|
-
#
|
|
284
|
-
#
|
|
285
|
-
#
|
|
286
|
-
#
|
|
287
|
-
#
|
|
288
|
-
#
|
|
289
|
-
#
|
|
290
|
-
#
|
|
268
|
+
# Only two shapes ride the ops lane: nil (:none) and
|
|
269
|
+
# :unqualified — the unwritten local spelling, nothing to
|
|
270
|
+
# declare — and EXACT Hash forms, ONLY under a
|
|
271
|
+
# prefixed-preserved root. The engine's plan serializer
|
|
272
|
+
# spells prefix:local for every EXACT row and cannot
|
|
273
|
+
# express the default-xmlns form (a prefix-less EXACT row
|
|
274
|
+
# emits a bare name with NO declaration, changing element
|
|
275
|
+
# identity), so admitting constructed or default-parsed
|
|
276
|
+
# instances flipped the pinned output format (uniword
|
|
277
|
+
# bold `<b xmlns=...>` and custprops `<property>`
|
|
278
|
+
# regressions). A prefixed-parsed root pins the prefixed
|
|
279
|
+
# form itself — Priority 1 format preservation — and the
|
|
280
|
+
# ops spelling matches it, inherited down the tree.
|
|
291
281
|
def ns_emittable?(ns_form, prefixed_source = nil)
|
|
292
282
|
return true if ns_form.nil? || ns_form == :unqualified
|
|
293
283
|
return false unless ns_form.is_a?(Hash) && ns_form[:prefix] &&
|
|
@@ -308,7 +298,6 @@ module Lutaml
|
|
|
308
298
|
base = (Thread.current[OP_BUFFER_BASE_KEY] ||= 0)
|
|
309
299
|
len = base
|
|
310
300
|
result = nil
|
|
311
|
-
bailed = false
|
|
312
301
|
begin
|
|
313
302
|
op_slot(buf, len)
|
|
314
303
|
buf[len][:kind] = :element
|
|
@@ -324,17 +313,14 @@ module Lutaml
|
|
|
324
313
|
emit_element(buf, len + 1, instance, plan, register,
|
|
325
314
|
root_index, graph)
|
|
326
315
|
end
|
|
327
|
-
# A nil walk
|
|
328
|
-
# row the ops lane cannot spell
|
|
329
|
-
# buffer tail and hand the instance back to
|
|
330
|
-
# DOM-lane fallback. The ensure's trim uses
|
|
331
|
-
# known-good length.
|
|
316
|
+
# A nil walk is the bail signal: a valued cycle-point or
|
|
317
|
+
# type-only row the ops lane cannot spell (#1130).
|
|
318
|
+
# Reset the buffer tail and hand the instance back to
|
|
319
|
+
# the caller's DOM-lane fallback. The ensure's trim uses
|
|
320
|
+
# the last known-good length.
|
|
332
321
|
if len.nil?
|
|
333
|
-
bailed = true
|
|
334
322
|
len = base
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
unless bailed
|
|
323
|
+
else
|
|
338
324
|
op_slot(buf, len)
|
|
339
325
|
buf[len][:kind] = :end
|
|
340
326
|
len += 1
|
|
@@ -351,8 +337,6 @@ module Lutaml
|
|
|
351
337
|
buf.slice!(len..) if buf.size > len
|
|
352
338
|
Thread.current[OP_BUFFER_BASE_KEY] = base
|
|
353
339
|
end
|
|
354
|
-
return nil if bailed
|
|
355
|
-
|
|
356
340
|
result
|
|
357
341
|
end
|
|
358
342
|
|
|
@@ -386,7 +370,20 @@ module Lutaml
|
|
|
386
370
|
# materialize without a register).
|
|
387
371
|
return build.call if register.nil?
|
|
388
372
|
|
|
389
|
-
|
|
373
|
+
# leptris#1966: a memoized tree whose planned-children
|
|
374
|
+
# count no longer matches the plan's rows is STALE — the
|
|
375
|
+
# first build ran while the plan's rows were still
|
|
376
|
+
# filling. Rebuild and invalidate the memos derived from
|
|
377
|
+
# the tree.
|
|
378
|
+
cached = plan[:emission_tree]
|
|
379
|
+
if cached && (cached[:children] || []).length == plan[:rows].length
|
|
380
|
+
return cached
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
plan[:emission_tree] = build.call
|
|
384
|
+
plan[:emission_descriptor] = nil
|
|
385
|
+
plan[:flat_layout_emission] = nil
|
|
386
|
+
plan[:emission_tree]
|
|
390
387
|
end
|
|
391
388
|
|
|
392
389
|
def emission_descriptor_for(plan, register)
|
|
@@ -543,7 +540,7 @@ module Lutaml
|
|
|
543
540
|
tree = emission_tree_for(child_plan, register)
|
|
544
541
|
graph[tree]
|
|
545
542
|
else
|
|
546
|
-
|
|
543
|
+
flat_layout_for(plan, instance, register)[row_index]&.last
|
|
547
544
|
end
|
|
548
545
|
next unless child_index
|
|
549
546
|
|
|
@@ -636,6 +633,7 @@ module Lutaml
|
|
|
636
633
|
def emit_element(buf, len, instance, plan, register, plan_index,
|
|
637
634
|
graph = nil)
|
|
638
635
|
my_index = plan_index
|
|
636
|
+
layout = flat_layout_for(plan, instance, register)
|
|
639
637
|
|
|
640
638
|
len = emit_attributes(buf, len, instance, plan, my_index, register)
|
|
641
639
|
|
|
@@ -717,7 +715,7 @@ module Lutaml
|
|
|
717
715
|
tree = emission_tree_for(child_plan, register)
|
|
718
716
|
graph[tree]
|
|
719
717
|
else
|
|
720
|
-
|
|
718
|
+
layout[row_index]&.last
|
|
721
719
|
end
|
|
722
720
|
next unless child_index
|
|
723
721
|
|
|
@@ -758,34 +756,59 @@ module Lutaml
|
|
|
758
756
|
out || item.to_xml
|
|
759
757
|
end
|
|
760
758
|
|
|
761
|
-
#
|
|
762
|
-
#
|
|
763
|
-
#
|
|
764
|
-
#
|
|
765
|
-
#
|
|
766
|
-
#
|
|
767
|
-
#
|
|
768
|
-
#
|
|
769
|
-
#
|
|
770
|
-
#
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
759
|
+
# {nested row_index => [child tree, relative flat index]} —
|
|
760
|
+
# children of this plan occupy slots my_index+1 .. in row
|
|
761
|
+
# order, each nested row's subtree sized once.
|
|
762
|
+
# leptris#1966 SSOT: the layout world MUST be the same
|
|
763
|
+
# world the ops' descriptor comes from — emission_lane?
|
|
764
|
+
# picks `d` in emit, so it picks the layout here too. The
|
|
765
|
+
# old plan-only predicate let an ordered plan with a
|
|
766
|
+
# built (element_order-less) instance number ops against
|
|
767
|
+
# the EMISSION tree while build_result ran on the PARSE
|
|
768
|
+
# descriptor (75 vs 93 slots — the theme-docx -5).
|
|
769
|
+
def flat_layout_for(plan, instance = nil, register = nil)
|
|
770
|
+
if instance && emission_lane?(plan, instance)
|
|
771
|
+
# Never memoize a nil-register build: child types can
|
|
772
|
+
# only materialize with a register (an early nil-register
|
|
773
|
+
# call would cache an EMPTY layout and every later
|
|
774
|
+
# emission would drop the subtrees).
|
|
775
|
+
return build_flat_layout(emission_tree_for(plan, register)) if
|
|
776
|
+
register.nil?
|
|
777
|
+
|
|
778
|
+
plan[:flat_layout_emission] ||= build_flat_layout(
|
|
779
|
+
emission_tree_for(plan, register),
|
|
780
|
+
)
|
|
781
|
+
return plan[:flat_layout_emission]
|
|
782
|
+
end
|
|
783
|
+
|
|
784
|
+
plan[:flat_layout] ||= build_flat_layout(plan[:tree])
|
|
785
|
+
end
|
|
786
|
+
|
|
787
|
+
def build_flat_layout(tree)
|
|
788
|
+
|
|
789
|
+
slots = slot_map(tree)
|
|
790
|
+
layout = {}
|
|
791
|
+
(tree[:children] || []).each_with_index do |row, i|
|
|
792
|
+
next unless row[:plan] &&
|
|
793
|
+
PLANNED_ROW_KINDS.include?(row[:kind])
|
|
794
|
+
|
|
795
|
+
layout[i] = [row[:plan], slots[row[:plan]]]
|
|
796
|
+
end
|
|
797
|
+
layout
|
|
798
|
+
|
|
799
|
+
end
|
|
800
|
+
|
|
801
|
+
def subtree_size(tree)
|
|
802
|
+
# Mirror flatten_plan's allocation: every planned row kind
|
|
803
|
+
# costs its full subtree (:nested AND :ordered_deferred —
|
|
804
|
+
# counting deferred children as 1 shifted every later slot
|
|
805
|
+
# after the first deferred subtree, leptris#1966).
|
|
806
|
+
1 + (tree[:children] || []).sum do |row|
|
|
807
|
+
if row[:plan] && PLANNED_ROW_KINDS.include?(row[:kind])
|
|
808
|
+
subtree_size(row[:plan])
|
|
809
|
+
else
|
|
810
|
+
0
|
|
786
811
|
end
|
|
787
|
-
walk.call(plan[:tree])
|
|
788
|
-
map
|
|
789
812
|
end
|
|
790
813
|
end
|
|
791
814
|
|
|
@@ -809,6 +832,10 @@ module Lutaml
|
|
|
809
832
|
attr_rows.each do |rule, attr, _sp, delegate|
|
|
810
833
|
value = value_of(instance, attr, delegate)
|
|
811
834
|
next if value.nil?
|
|
835
|
+
# The DOM lane's write_attribute contract: render_default:
|
|
836
|
+
# false suppresses an attribute whose value is still the
|
|
837
|
+
# default (a parse that omitted it), derived rules excepted.
|
|
838
|
+
next unless rule.render?(value, instance)
|
|
812
839
|
|
|
813
840
|
name = rule.name.to_s
|
|
814
841
|
row_index = row_indices[name]
|
|
@@ -837,9 +864,11 @@ module Lutaml
|
|
|
837
864
|
entry = by_name[name]
|
|
838
865
|
next unless entry
|
|
839
866
|
|
|
840
|
-
|
|
867
|
+
rule, attr, delegate = entry
|
|
841
868
|
value = value_of(instance, attr, delegate)
|
|
842
869
|
next if value.nil?
|
|
870
|
+
# Same render_default contract as the plain path.
|
|
871
|
+
next unless rule.render?(value, instance)
|
|
843
872
|
|
|
844
873
|
row_index = row_indices[name]
|
|
845
874
|
next unless row_index
|
|
@@ -343,15 +343,6 @@ module Lutaml
|
|
|
343
343
|
attributes: plan_attrs, children: rows }
|
|
344
344
|
tree[:ns] = model_ns if model_ns
|
|
345
345
|
tree[:flags] = flags unless flags.empty?
|
|
346
|
-
begin
|
|
347
|
-
# Lazy: the Opal boot loads this file, and leptris is a
|
|
348
|
-
# native gem there — the require only belongs on the
|
|
349
|
-
# engines-enabled path.
|
|
350
|
-
require "leptris/xml/descriptor"
|
|
351
|
-
descriptor = ::Leptris::XML::Descriptor.build(**tree)
|
|
352
|
-
rescue StandardError
|
|
353
|
-
return nil
|
|
354
|
-
end
|
|
355
346
|
|
|
356
347
|
return opt_out!(:attr_ns_claim_conflict) if attr_local_claims
|
|
357
348
|
.any? { |_, c| c[:ns].positive? && c[:plain].positive? }
|
|
@@ -379,6 +370,23 @@ module Lutaml
|
|
|
379
370
|
type_tag: wildcard_tag }
|
|
380
371
|
end
|
|
381
372
|
|
|
373
|
+
# leptris#1966: the descriptor freezes the tree's slot
|
|
374
|
+
# table — it must see the tree FINAL. The wildcard
|
|
375
|
+
# catch-all above used to append to `rows` AFTER this
|
|
376
|
+
# build, so every slot past the wildcard shifted one and
|
|
377
|
+
# the ops lane wrote children into leaf slots (status=-5
|
|
378
|
+
# on the theme docx). The tree is complete here; freeze
|
|
379
|
+
# now.
|
|
380
|
+
begin
|
|
381
|
+
# Lazy: the Opal boot loads this file, and leptris is a
|
|
382
|
+
# native gem there — the require only belongs on the
|
|
383
|
+
# engines-enabled path.
|
|
384
|
+
require "leptris/xml/descriptor"
|
|
385
|
+
descriptor = ::Leptris::XML::Descriptor.build(**tree)
|
|
386
|
+
rescue StandardError
|
|
387
|
+
return nil
|
|
388
|
+
end
|
|
389
|
+
|
|
382
390
|
{ descriptor: descriptor, tree: tree, rows: compiled,
|
|
383
391
|
attr_rows: attr_rows, mapping: mapping,
|
|
384
392
|
row_tags: row_tags, namespaced: namespaced,
|
data/lib/lutaml/xml/leptris.rb
CHANGED
|
@@ -16,10 +16,14 @@ module Lutaml
|
|
|
16
16
|
# form (#1560, 1.9.323), build_result with the address-based
|
|
17
17
|
# text attach (#408, 1.9.334/1.9.336), and the plan-value
|
|
18
18
|
# attributes batch face (PlanValue#attributes_snapshot,
|
|
19
|
-
# leptris-ruby#447)
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
|
|
19
|
+
# leptris-ruby#447), and — the binding addition — the RAW op +
|
|
20
|
+
# emission row identity the ordered/deferred splice rides
|
|
21
|
+
# (leptris#1941, 1.9.406). Bundles resolving an older gem keep
|
|
22
|
+
# the interpretive path — PlanCompiler.compile answers nil —
|
|
23
|
+
# the opt-out protocol; a bundle pinned below the floor (e.g.
|
|
24
|
+
# the metanorma consumer matrix at 1.9.405.0) never sees the
|
|
25
|
+
# ops lane, so it cannot splice ops the engine cannot parse.
|
|
26
|
+
MIN_LEPTRIS_VERSION = "1.9.406.0"
|
|
23
27
|
|
|
24
28
|
# Memoized: the compiler consults this on every cache hit (per
|
|
25
29
|
# child row per node), and the comparison minted a Gem::Version
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# leptris#1966 root cause: the emission graph numbered :nested rows
|
|
4
|
+
# only, but emission_rows_for materializes :ordered_deferred rows
|
|
5
|
+
# WITH child :plan trees (the deferred subtree is fully materialized
|
|
6
|
+
# — the recursive gate guarantees it). A valued deferred row under
|
|
7
|
+
# an ordered parent (uniword's theme/styles shapes) then looked up
|
|
8
|
+
# graph[tree] at emit time, got nil, and the element op carried
|
|
9
|
+
# plan_index=nil — the engine rejected the stream with -5. The
|
|
10
|
+
# graph must number every row kind that carries a plan.
|
|
11
|
+
RSpec.describe Lutaml::Xml::Leptris::NativeEmission,
|
|
12
|
+
".emission_graph_for numbers deferred subtrees" do
|
|
13
|
+
let(:child_tree) do
|
|
14
|
+
{ name: "p", children: [{ name: "t", kind: :scalar }] }
|
|
15
|
+
end
|
|
16
|
+
let(:tree) do
|
|
17
|
+
{ name: "root", children: [
|
|
18
|
+
{ name: "body", kind: :ordered_deferred, plan: child_tree },
|
|
19
|
+
] }
|
|
20
|
+
end
|
|
21
|
+
let(:fake_row) do
|
|
22
|
+
rule = Struct.new(:name).new("body")
|
|
23
|
+
[rule, nil, :scalar]
|
|
24
|
+
end
|
|
25
|
+
let(:plan) do
|
|
26
|
+
{ ordered: true, tree: tree, emission_tree: tree, rows: [fake_row] }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "assigns the deferred subtree a graph slot" do
|
|
30
|
+
graph = described_class.emission_graph_for(plan, :register)
|
|
31
|
+
expect(graph[tree]).to eq(0)
|
|
32
|
+
expect(graph[child_tree]).to eq(1)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# lutaml-model#1136: the native emission lane ignored the DOM lane's
|
|
4
|
+
# render contract for attributes — an attribute whose value is still
|
|
5
|
+
# the default (a parse that omitted it from the source) must not
|
|
6
|
+
# emit when the mapping declares render_default: false. uniword's
|
|
7
|
+
# Style round-trip caught it: a parsed style without w:default came
|
|
8
|
+
# back with the ghost `w:default="0"` (the custom boolean type's
|
|
9
|
+
# serialization of its default).
|
|
10
|
+
|
|
11
|
+
require "lutaml/model"
|
|
12
|
+
require "lutaml/xml/leptris"
|
|
13
|
+
|
|
14
|
+
RSpec.describe "native emission honors the attribute render contract" do
|
|
15
|
+
let(:flag_type) do
|
|
16
|
+
Class.new(Lutaml::Model::Type::Value) do
|
|
17
|
+
def self.cast(value)
|
|
18
|
+
return true if ["1", true].include?(value)
|
|
19
|
+
return false if ["0", false].include?(value)
|
|
20
|
+
|
|
21
|
+
value
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def serialize(_format, _register = nil)
|
|
25
|
+
self.class.cast(@value) ? "1" : "0"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.name
|
|
29
|
+
"EmissionRenderFlag"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
let(:model_class) do
|
|
35
|
+
flag = flag_type
|
|
36
|
+
klass = Class.new(Lutaml::Model::Serializable) do
|
|
37
|
+
attribute :name, :string
|
|
38
|
+
attribute :default, flag
|
|
39
|
+
attribute :custom_style, flag
|
|
40
|
+
|
|
41
|
+
xml do
|
|
42
|
+
element "style"
|
|
43
|
+
map_attribute "name", to: :name
|
|
44
|
+
map_attribute "default", to: :default, render_default: false,
|
|
45
|
+
render_nil: false
|
|
46
|
+
map_attribute "customStyle", to: :custom_style,
|
|
47
|
+
render_default: false
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.name
|
|
51
|
+
"EmissionRenderStyle"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
stub_const("EmissionRender::Style", klass)
|
|
55
|
+
klass
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
let(:source) do
|
|
59
|
+
'<style xmlns="http://example.com/style" name="H1"/>'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
around do |example|
|
|
63
|
+
Lutaml::Model::Config.with_adapter(xml: :leptris) { example.run }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "omits parsed-omitted attributes that carry render_default: false" do
|
|
67
|
+
instance = model_class.from_xml(source)
|
|
68
|
+
xml = instance.to_xml
|
|
69
|
+
expect(xml).to include("name=\"H1\"")
|
|
70
|
+
expect(xml).not_to include("default")
|
|
71
|
+
expect(xml).not_to include("customStyle")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "still emits attributes the source actually carried" do
|
|
75
|
+
xml = model_class.from_xml(
|
|
76
|
+
'<style xmlns="http://example.com/style" name="H1" default="1"/>',
|
|
77
|
+
).to_xml
|
|
78
|
+
expect(xml).to include("default=")
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "keeps the DOM lane's contract on the recorded-order path" do
|
|
82
|
+
instance = model_class.from_xml(
|
|
83
|
+
'<style xmlns="http://example.com/style" customStyle="1" name="A"/>',
|
|
84
|
+
)
|
|
85
|
+
xml = instance.to_xml
|
|
86
|
+
expect(xml).to include("customStyle=")
|
|
87
|
+
expect(xml).not_to include("default=")
|
|
88
|
+
end
|
|
89
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lutaml-model
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.168
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -2018,10 +2018,11 @@ files:
|
|
|
2018
2018
|
- spec/lutaml/xml/general_namespace_spec.rb
|
|
2019
2019
|
- spec/lutaml/xml/html_entities_spec.rb
|
|
2020
2020
|
- spec/lutaml/xml/indent_spec.rb
|
|
2021
|
+
- spec/lutaml/xml/leptris/emission_graph_deferred_spec.rb
|
|
2021
2022
|
- spec/lutaml/xml/leptris/native_emission_nested_sharing_spec.rb
|
|
2022
2023
|
- spec/lutaml/xml/leptris/native_emission_ns_parity_spec.rb
|
|
2023
2024
|
- spec/lutaml/xml/leptris/native_emission_ordered_spec.rb
|
|
2024
|
-
- spec/lutaml/xml/leptris/
|
|
2025
|
+
- spec/lutaml/xml/leptris/native_emission_render_contract_spec.rb
|
|
2025
2026
|
- spec/lutaml/xml/leptris/plan_hydrator_ns_snapshot_spec.rb
|
|
2026
2027
|
- spec/lutaml/xml/leptris_string_encoding_spec.rb
|
|
2027
2028
|
- spec/lutaml/xml/line_ending_spec.rb
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# leptris#1941 consumer-gap law: the RAW-splice capability rides
|
|
4
|
-
# engine 1.9.406.0 (PLAN_OP_RAW + row identity). A bundle resolving
|
|
5
|
-
# an OLDER leptris gem — e.g. the metanorma consumer matrix pinned to
|
|
6
|
-
# 1.9.405.0 — must take the DOM lane, not the ops lane: splicing
|
|
7
|
-
# :raw without the engine constant emitted EMPTY fragments and the
|
|
8
|
-
# round-trip parse died on "empty input". The gate probes the FFI
|
|
9
|
-
# constant, so capability tracks the loaded gem, not a version
|
|
10
|
-
# table that drifts.
|
|
11
|
-
RSpec.describe Lutaml::Xml::Leptris::NativeEmission, ".raw_op_supported?" do
|
|
12
|
-
it "is false for an FFI surface without the RAW op" do
|
|
13
|
-
plain = Class.new
|
|
14
|
-
expect(described_class.raw_op_supported?(plain)).to be(false)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "is true when PLAN_OP_RAW is defined" do
|
|
18
|
-
with_raw = Class.new
|
|
19
|
-
with_raw.const_set(:PLAN_OP_RAW, 4)
|
|
20
|
-
expect(described_class.raw_op_supported?(with_raw)).to be(true)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "probes the loaded gem by default (harness runs 1.9.406.0)" do
|
|
24
|
-
expect(described_class.raw_op_supported?).to be(true)
|
|
25
|
-
end
|
|
26
|
-
end
|