leptris 1.9.199.0-arm-linux → 1.9.199.1-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/ext/leptris/native/native.c +118 -0
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/native.so +0 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de61273fea68a6eaaa885885c05111519db55930d3d236a94f3dde8f3b2d96f6
|
|
4
|
+
data.tar.gz: 72f0bd31f62636d768d6ae180d5c10294798f0c006566510f6a6dcfbff0e902c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a4d7ac5d37da0125035785441726b64e3eaa497d5f80af169485f127bc64373cb862e596004b8fff7f874926b6b3a59860c00b3f6be2a1394e80ec9958903d46
|
|
7
|
+
data.tar.gz: aef8e4d990cebc7bf5307af0b3aa36e7e5b9a57b39fb98c74c95223f0a7e6ed12f44d59af88dd7b50fe547acb61afb7f87ab98e70fb0701b6835ad9d32ca22f9
|
data/ext/leptris/native/native.c
CHANGED
|
@@ -1941,6 +1941,122 @@ static VALUE nf_snapshot_rows(VALUE self, VALUE document, VALUE addr)
|
|
|
1941
1941
|
return out;
|
|
1942
1942
|
}
|
|
1943
1943
|
|
|
1944
|
+
/* ---- Struct plan executor (moxml "miles faster" round) ------------
|
|
1945
|
+
* The consumer's shape compiles to spec: name (interned String) ->
|
|
1946
|
+
* [Struct class, attrs Hash (name -> slot Symbol), text slot Symbol
|
|
1947
|
+
* or nil, children slot Symbol or nil]. C walks the subtree
|
|
1948
|
+
* pre-order, mints typed structs directly (rb_struct_new +
|
|
1949
|
+
* rb_struct_aset), and attaches each to the nearest OPEN frame —
|
|
1950
|
+
* exactly Moxml::Plan's semantics: an unmatched element is a
|
|
1951
|
+
* barrier (its matched descendants surface at top level). Zero
|
|
1952
|
+
* Ruby frames and zero intermediate rows per element. */
|
|
1953
|
+
static void plan_walk(void *node, int depth, VALUE spec, VALUE stack,
|
|
1954
|
+
VALUE roots)
|
|
1955
|
+
{
|
|
1956
|
+
if (f_node_type(node) == WS_NODE_ELEMENT) {
|
|
1957
|
+
const char *name_c = f_elem_name(node);
|
|
1958
|
+
VALUE entry = name_c ? rb_hash_aref(spec,
|
|
1959
|
+
rb_enc_interned_str(name_c, strlen(name_c),
|
|
1960
|
+
rb_utf8_encoding()))
|
|
1961
|
+
: Qnil;
|
|
1962
|
+
|
|
1963
|
+
/* Complete deeper frames: pre-order means any open frame at
|
|
1964
|
+
* depth >= this element's depth belongs to an earlier
|
|
1965
|
+
* subtree that ended before this row. */
|
|
1966
|
+
while (RARRAY_LEN(stack) >= 2 &&
|
|
1967
|
+
NUM2INT(rb_ary_entry(stack, RARRAY_LEN(stack) - 2)) >=
|
|
1968
|
+
depth) {
|
|
1969
|
+
rb_ary_pop(stack);
|
|
1970
|
+
rb_ary_pop(stack);
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
if (!NIL_P(entry)) {
|
|
1974
|
+
/* volatile: keep live VALUEs on the C stack so the
|
|
1975
|
+
* conservative scanner sees them on every ABI (windows
|
|
1976
|
+
* x64 keeps some only in callee-saved registers). */
|
|
1977
|
+
volatile VALUE klass = rb_ary_entry(entry, 0);
|
|
1978
|
+
volatile VALUE attrs_spec = rb_ary_entry(entry, 1);
|
|
1979
|
+
volatile VALUE text_slot = rb_ary_entry(entry, 2);
|
|
1980
|
+
volatile VALUE children_slot = rb_ary_entry(entry, 3);
|
|
1981
|
+
VALUE value = rb_struct_new(klass);
|
|
1982
|
+
|
|
1983
|
+
for (void *a = f_attr_first(node); a; a = f_attr_next(a)) {
|
|
1984
|
+
const char *an = f_attr_name(a);
|
|
1985
|
+
VALUE slot = an ? rb_hash_aref(attrs_spec,
|
|
1986
|
+
rb_enc_interned_str(an, strlen(an),
|
|
1987
|
+
rb_utf8_encoding()))
|
|
1988
|
+
: Qnil;
|
|
1989
|
+
if (!NIL_P(slot)) {
|
|
1990
|
+
const char *av = f_attr_value(node, a);
|
|
1991
|
+
rb_struct_aset(value, slot,
|
|
1992
|
+
av ? rb_utf8_str_new_cstr(av) : Qnil);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
if (!NIL_P(text_slot)) {
|
|
1996
|
+
void *c;
|
|
1997
|
+
for (c = f_first_child(node); c; c = f_next_sibling(c)) {
|
|
1998
|
+
if (f_node_type(c) == WS_NODE_TEXT) {
|
|
1999
|
+
const char *t = f_text_content(c);
|
|
2000
|
+
rb_struct_aset(value, text_slot,
|
|
2001
|
+
t ? rb_utf8_str_new_cstr(t) : Qnil);
|
|
2002
|
+
break;
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
/* attach: nearest open frame carrying a children array;
|
|
2008
|
+
* barriers (unmatched ancestors) and the root surface
|
|
2009
|
+
* the value at top level — Moxml::Plan's contract. */
|
|
2010
|
+
if (RARRAY_LEN(stack) >= 2 &&
|
|
2011
|
+
rb_ary_entry(stack, RARRAY_LEN(stack) - 1) != Qnil) {
|
|
2012
|
+
rb_ary_push(rb_ary_entry(stack, RARRAY_LEN(stack) - 1),
|
|
2013
|
+
value);
|
|
2014
|
+
} else {
|
|
2015
|
+
rb_ary_push(roots, value);
|
|
2016
|
+
}
|
|
2017
|
+
RB_GC_GUARD(value);
|
|
2018
|
+
RB_GC_GUARD(entry);
|
|
2019
|
+
|
|
2020
|
+
if (!NIL_P(children_slot)) {
|
|
2021
|
+
VALUE children = rb_ary_new();
|
|
2022
|
+
rb_struct_aset(value, children_slot, children);
|
|
2023
|
+
rb_ary_push(stack, INT2NUM(depth));
|
|
2024
|
+
rb_ary_push(stack, children);
|
|
2025
|
+
}
|
|
2026
|
+
} else {
|
|
2027
|
+
/* unmatched: barrier frame — descendants must not
|
|
2028
|
+
* attach through it (Moxml::Plan parity). */
|
|
2029
|
+
rb_ary_push(stack, INT2NUM(depth));
|
|
2030
|
+
rb_ary_push(stack, Qnil);
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
void *c;
|
|
2034
|
+
for (c = f_first_child(node); c; c = f_next_sibling(c)) {
|
|
2035
|
+
plan_walk(c, depth + 1, spec, stack, roots);
|
|
2036
|
+
}
|
|
2037
|
+
} else if (f_node_type(node) == WS_NODE_DOCTYPE ||
|
|
2038
|
+
f_node_type(node) == 9) {
|
|
2039
|
+
void *dc = f_first_child(node);
|
|
2040
|
+
while (dc) {
|
|
2041
|
+
plan_walk(dc, depth, spec, stack, roots);
|
|
2042
|
+
dc = f_next_sibling(dc);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
static VALUE nf_plan_structs(VALUE self, VALUE document, VALUE addr,
|
|
2048
|
+
VALUE spec)
|
|
2049
|
+
{
|
|
2050
|
+
(void)self;
|
|
2051
|
+
(void)document;
|
|
2052
|
+
VALUE roots = rb_ary_new();
|
|
2053
|
+
VALUE stack = rb_ary_new();
|
|
2054
|
+
plan_walk((void *)(uintptr_t)NUM2ULL(addr), 0, spec, stack, roots);
|
|
2055
|
+
RB_GC_GUARD(spec);
|
|
2056
|
+
RB_GC_GUARD(stack);
|
|
2057
|
+
return roots;
|
|
2058
|
+
}
|
|
2059
|
+
|
|
1944
2060
|
/* ---- inner_html in one C pass (TODO.perf/18) --------------------
|
|
1945
2061
|
* Serializes the receiver's children into one growable buffer:
|
|
1946
2062
|
* elements via leptris_element_serialize_into (the same opts the
|
|
@@ -2490,6 +2606,8 @@ void Init_native(void)
|
|
|
2490
2606
|
nf_snapshot_subtree, 2);
|
|
2491
2607
|
rb_define_module_function(m_native, "snapshot_rows",
|
|
2492
2608
|
nf_snapshot_rows, 2);
|
|
2609
|
+
rb_define_module_function(m_native, "plan_structs",
|
|
2610
|
+
nf_plan_structs, 3);
|
|
2493
2611
|
rb_define_module_function(m_native, "doc_handle_attach",
|
|
2494
2612
|
nf_doc_handle_attach, 1);
|
|
2495
2613
|
rb_define_module_function(m_native, "doc_handle_release",
|
data/lib/leptris/version.rb
CHANGED
data/lib/leptris/xml/native.so
CHANGED
|
Binary file
|