leptris 1.9.420.0-arm-linux → 1.9.420.2-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ad82073dfdf75345e6adbb01d2af07b0be13b4ba098885f7fdd3b0220ff2556
4
- data.tar.gz: 2091520873efe5a504a79f6782c85fd565834727488f6c88c34f6c8a564fcf93
3
+ metadata.gz: a630971cb93e51ae80e31f78afbe7660ad38575bc5e52c7cfbd958cf8168d3af
4
+ data.tar.gz: a66e3a535c36e9e1de8bd3200d244f3893ee6472ff921819ead23d2171e1d522
5
5
  SHA512:
6
- metadata.gz: 784eae5ae8cfe51bf2cf1ce0afe21c5e32d95f6353d38d530d2f445ff6c38d3b8a577b38b18f7cbcd3f96597ef69e2110d2390a2b7f13b662f227b076bb07c3f
7
- data.tar.gz: 0cff032c94f0c3b684c3b8721d5be2513f430a2679a241a66a733a3d54bb159d92a5681fb7327acc5ddf626e800de4461ecc6d80a2dca7ac2a0307ec01199a4e
6
+ metadata.gz: f0722926cc11a8a02258c094e6fa548a6e356a287acc60e639ad2429c27a354d1c5ca391843d36be152ccd5a4685418fcba037e70024c1a0bcf125672aa22676
7
+ data.tar.gz: 3a5b391d0e98e25d28efac9dc5398b5cd08598e02848ce1131901db2e77dc59980438a928f553752ae745dd9153930c8360bb612bc86c89921e0e14aea2acef8
@@ -211,6 +211,7 @@ static ID id_bulk_rows_mark;
211
211
  static ID id_ptr_new, id_freed_new, id_alive;
212
212
  static ID id_iv_c_address, id_iv_document, id_iv_parent;
213
213
  static ID id_iv_mx_context, id_iv_mx_adapter, id_iv_mx_native;
214
+ static ID id_cs_factory, id_af_factory;
214
215
  static ID id_iv_structure_memoizable, id_iv_native_fast;
215
216
  static ID id_iv_pub_document, id_iv_addr_reads_fast, id_iv_node_type;
216
217
  static void check_status_c(int st);
@@ -235,6 +236,12 @@ struct native_node {
235
236
  * memo) — treat it as read-only, like an interned String. */
236
237
  VALUE name_val, name_ver;
237
238
  VALUE children_val, children_ver;
239
+ /* Shape (b) hydration (leptris-ruby#631): the flat attribute
240
+ * pairs array in exactly nf_attribute_pairs' shape, filled by
241
+ * the subtree prime — the walk+read lane's attribute reads
242
+ * answer from the crossing instead of a per-element pairs
243
+ * crossing. Version-stamped like the other memos. */
244
+ VALUE attrs_val, attrs_ver;
238
245
  };
239
246
 
240
247
  static VALUE columnar_node_for(VALUE document, VALUE owner_klass,
@@ -258,6 +265,8 @@ static void nn_mark(void *p)
258
265
  rb_gc_mark(n->name_val);
259
266
  if (n->children_val != Qnil)
260
267
  rb_gc_mark(n->children_val);
268
+ if (n->attrs_val != Qnil)
269
+ rb_gc_mark(n->attrs_val);
261
270
  }
262
271
 
263
272
  static size_t nn_size(const void *p) { (void)p; return sizeof(struct native_node); }
@@ -1702,6 +1711,57 @@ static VALUE nn_set_root(VALUE klass, VALUE document, VALUE element)
1702
1711
  * consumer's NativeNode subclass or NativeNode itself — a non-
1703
1712
  * TypedData class would crash on first read, so the type is checked
1704
1713
  * here against the registry. */
1714
+ /* ---- moxml-native consumer-contract binding (lutaml/moxml#548,
1715
+ * leptris-ruby#634) ----------------------------------------------
1716
+ * The factory-parameterized contract: the consumer registers its
1717
+ * shape factories ONCE per klass, and the binding defines the
1718
+ * contract's hot methods IN C — children serving the #530 memo'd
1719
+ * list wrapped by the consumer's set factory (the contract-required
1720
+ * object constructed without the Ruby dispatch chain), attribute
1721
+ * serving the engine's decode-authoritative getter wrapped by the
1722
+ * attribute factory. The context rides the primed @mx_context ivar
1723
+ * (the wrap path writes it); unprimed instances pass nil. */
1724
+ static VALUE cc_children(VALUE self)
1725
+ {
1726
+ VALUE list = nn_children(self);
1727
+ VALUE factory =
1728
+ rb_attr_get(rb_obj_class(self), id_cs_factory);
1729
+ VALUE context = rb_ivar_get(self, id_iv_mx_context);
1730
+ if (NIL_P(factory)) return list;
1731
+ return rb_funcall(factory, rb_intern("new"), 2, list, context);
1732
+ }
1733
+
1734
+ static VALUE cc_attribute(VALUE self, VALUE name)
1735
+ {
1736
+ struct native_node *n;
1737
+ TypedData_Get_Struct(self, struct native_node, &nn_type, n);
1738
+ VALUE factory = rb_attr_get(rb_obj_class(self), id_af_factory);
1739
+ if (NIL_P(factory)) return Qnil;
1740
+ const char *v = f_attr(n->ptr, StringValueCStr(name));
1741
+ if (!v) return Qnil;
1742
+ return rb_funcall(factory, rb_intern("new"), 3,
1743
+ rb_utf8_str_new_cstr(StringValueCStr(name)),
1744
+ rb_utf8_str_new_cstr(v), self);
1745
+ }
1746
+
1747
+ static VALUE nf_bind_consumer_contract(VALUE self, VALUE klass,
1748
+ VALUE set_factory,
1749
+ VALUE attr_factory)
1750
+ {
1751
+ (void)self;
1752
+ if (!RB_TYPE_P(klass, T_CLASS))
1753
+ rb_raise(rb_eTypeError, "expected a class");
1754
+ if (klass != c_native_node &&
1755
+ rb_class_inherited_p(klass, c_native_node) != Qtrue)
1756
+ rb_raise(rb_eTypeError,
1757
+ "the class must subclass Leptris::XML::NativeNode");
1758
+ rb_ivar_set(klass, id_cs_factory, set_factory);
1759
+ rb_ivar_set(klass, id_af_factory, attr_factory);
1760
+ rb_define_method(klass, "children", cc_children, 0);
1761
+ rb_define_method(klass, "attribute", cc_attribute, 1);
1762
+ return Qtrue;
1763
+ }
1764
+
1705
1765
  static VALUE nf_define_hot_readers(VALUE self, VALUE klass)
1706
1766
  {
1707
1767
  (void)self;
@@ -2724,8 +2784,25 @@ static void walk_rows_impl(void *node, int depth, VALUE out)
2724
2784
  static VALUE nf_attribute_pairs(VALUE self, VALUE document, VALUE addr)
2725
2785
  {
2726
2786
  (void)self;
2727
- (void)document;
2728
2787
  void *node = (void *)(uintptr_t)NUM2ULL(addr);
2788
+ /* Shape (b) cache-first (leptris-ruby#631): the subtree prime
2789
+ * hydrates the flat pairs array per element — when the
2790
+ * address-keyed wrapper exists and its memo matches the
2791
+ * document version, the answer IS the memo (zero crossings,
2792
+ * the same object identity on repeat reads). */
2793
+ if (document != Qnil) {
2794
+ VALUE key = ULL2NUM((uint64_t)(uintptr_t)node);
2795
+ VALUE w = rb_hash_aref(native_cache_of(document), key);
2796
+ if (!NIL_P(w) &&
2797
+ rb_typeddata_is_kind_of(w, &nn_type)) {
2798
+ struct native_node *cn;
2799
+ TypedData_Get_Struct(w, struct native_node, &nn_type, cn);
2800
+ if (cn->document != Qnil && cn->attrs_val != Qnil &&
2801
+ cn->attrs_ver ==
2802
+ rb_ivar_get(cn->document, id_iv_version))
2803
+ return cn->attrs_val;
2804
+ }
2805
+ }
2729
2806
  VALUE out = rb_ary_new();
2730
2807
  if (f_node_type(node) != WS_NODE_ELEMENT) return out;
2731
2808
 
@@ -2748,6 +2825,22 @@ static VALUE nf_attribute_pairs(VALUE self, VALUE document, VALUE addr)
2748
2825
  }
2749
2826
  xfree(names);
2750
2827
  xfree(values);
2828
+ /* Shape (b) write-back: when the address-keyed wrapper exists,
2829
+ * the captured array lands in its memo — the next read (or any
2830
+ * consumer reading the same address again) answers from it
2831
+ * until the version moves. */
2832
+ if (document != Qnil && out != Qnil) {
2833
+ VALUE key = ULL2NUM((uint64_t)(uintptr_t)node);
2834
+ VALUE w = rb_hash_aref(native_cache_of(document), key);
2835
+ if (!NIL_P(w) && rb_typeddata_is_kind_of(w, &nn_type)) {
2836
+ struct native_node *cn;
2837
+ TypedData_Get_Struct(w, struct native_node, &nn_type, cn);
2838
+ if (cn->document != Qnil)
2839
+ rb_ivar_get(cn->document, id_iv_version);
2840
+ cn->attrs_val = out;
2841
+ cn->attrs_ver = rb_ivar_get(cn->document, id_iv_version);
2842
+ }
2843
+ }
2751
2844
  return out;
2752
2845
  }
2753
2846
 
@@ -2865,6 +2958,33 @@ static VALUE nn_prime_children_of(VALUE document, VALUE owner_klass,
2865
2958
  rb_utf8_encoding())
2866
2959
  : Qnil;
2867
2960
  nn->name_ver = ver;
2961
+ /* Shape (b) hydration (leptris-ruby#631): the attr
2962
+ * packet rides the SAME crossing — the pairs face's
2963
+ * exact output shape, served cache-first by the face
2964
+ * afterwards. Zero attributes leaves the memo nil (the
2965
+ * face's empty answer is cheap to recompute). */
2966
+ size_t total = f_attr_pairs(c, NULL, NULL, NULL, 0);
2967
+ if (total > 0) {
2968
+ const char **anames = ALLOC_N(const char *, total);
2969
+ const char **avalues = ALLOC_N(const char *, total);
2970
+ size_t n2 = f_attr_pairs(c, anames, avalues, NULL, total);
2971
+ VALUE flat = rb_ary_new_capa(2 * n2);
2972
+ for (size_t i = 0; i < n2; i++) {
2973
+ rb_ary_push(flat, anames[i]
2974
+ ? rb_enc_interned_str(
2975
+ anames[i],
2976
+ strlen(anames[i]),
2977
+ rb_utf8_encoding())
2978
+ : Qnil);
2979
+ rb_ary_push(flat, avalues[i]
2980
+ ? rb_utf8_str_new_cstr(avalues[i])
2981
+ : Qnil);
2982
+ }
2983
+ xfree(anames);
2984
+ xfree(avalues);
2985
+ nn->attrs_val = flat;
2986
+ nn->attrs_ver = ver;
2987
+ }
2868
2988
  nn->children_val = nn_prime_children_of(document, owner_klass,
2869
2989
  c, ver);
2870
2990
  nn->children_ver = ver;
@@ -2872,12 +2992,29 @@ static VALUE nn_prime_children_of(VALUE document, VALUE owner_klass,
2872
2992
  /* leaf kinds: memo the name exactly as nn_name computes
2873
2993
  * it (f_elem_name answers "" for nameless kinds); their
2874
2994
  * (empty) children keep the fetch path, which
2875
- * memo-stores the same way. */
2995
+ * memo-stores the same way. Shape (b): the leaf's
2996
+ * CONTENT hydrates on the same crossing — nn_content's
2997
+ * memo serves it afterwards with zero crossings. nil
2998
+ * content stays uncached (nn_content's nil discipline). */
2876
2999
  const char *name = f_elem_name(c);
2877
3000
  nn->name_val = name ? rb_enc_interned_str(name, strlen(name),
2878
3001
  rb_utf8_encoding())
2879
3002
  : Qnil;
2880
3003
  nn->name_ver = ver;
3004
+ {
3005
+ const char *cs = NULL;
3006
+ switch (kind) {
3007
+ case WS_NODE_TEXT: cs = f_text_content(c); break;
3008
+ case WS_NODE_COMMENT: cs = f_comment_content(c); break;
3009
+ case WS_NODE_CDATA: cs = f_cdata_content(c); break;
3010
+ case WS_NODE_PI: cs = f_pi_data(c); break;
3011
+ default: cs = NULL; break;
3012
+ }
3013
+ if (cs) {
3014
+ nn->content_val = rb_utf8_str_new_cstr(cs);
3015
+ nn->content_ver = ver;
3016
+ }
3017
+ }
2881
3018
  }
2882
3019
  rb_ary_push(out, wrapper);
2883
3020
  }
@@ -4277,6 +4414,8 @@ static void leptris_native_setup(void)
4277
4414
  id_iv_c_address = rb_intern("@c_address");
4278
4415
  id_iv_document = rb_intern("@document");
4279
4416
  id_iv_mx_context = rb_intern("@context");
4417
+ id_cs_factory = rb_intern("@cs_factory");
4418
+ id_af_factory = rb_intern("@af_factory");
4280
4419
  id_iv_mx_native = rb_intern("@native");
4281
4420
  id_iv_mx_adapter = rb_intern("@adapter");
4282
4421
  id_bulk_rows_mark = rb_intern("BulkIdentityRows");
@@ -4388,6 +4527,8 @@ static void leptris_native_setup(void)
4388
4527
  nf_set_binding_attribute, 4);
4389
4528
  rb_define_module_function(m_native, "define_hot_readers",
4390
4529
  nf_define_hot_readers, 1);
4530
+ rb_define_module_function(m_native, "bind_consumer_contract",
4531
+ nf_bind_consumer_contract, 3);
4391
4532
  rb_define_module_function(m_native, "insert_binding_child",
4392
4533
  nf_insert_binding_child, 4);
4393
4534
  rb_define_module_function(m_native, "at_xpath_first",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.420.0"
4
+ VERSION = "1.9.420.2"
5
5
  end
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.420.0
4
+ version: 1.9.420.2
5
5
  platform: arm-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-13 00:00:00.000000000 Z
11
+ date: 2026-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi