moxml 0.6.6 → 0.6.7
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/lib/moxml/adapter/leptris.rb +37 -6
- data/lib/moxml/adapter/libxml.rb +4 -1
- data/lib/moxml/adapter/nokogiri.rb +4 -1
- data/lib/moxml/adapter/oga.rb +4 -1
- data/lib/moxml/adapter/ox.rb +4 -1
- data/lib/moxml/adapter/rexml.rb +4 -1
- data/lib/moxml/document.rb +2 -1
- data/lib/moxml/lazy_bulk_rows.rb +10 -2
- data/lib/moxml/node.rb +4 -2
- data/lib/moxml/version.rb +1 -1
- 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: c48f1775cb2f4eb3de69655fec93e1bb5d7ad5052b4ed4b82470a687ff2ccf96
|
|
4
|
+
data.tar.gz: a7ed111098b147489ca3c4b78c7ca3b2df121d669dc91074a478d1d87e2b5e64
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 30761cf2d3ebd5d745308cf86db52c19785ab34fb8356c11f6c06bc4b07ba00c765294de0cea52251fc535c05003f2bf14c0b664b0fbd35e9749ce9e362563f6
|
|
7
|
+
data.tar.gz: cd36f13d7b1296d4025ac852755e818661c4c47f17abb0b6d77cd1995ce28757939a9fe7ad5b47de741e8493a42f6e0f764843e6f9314336e3967a620750fb19
|
|
@@ -3207,6 +3207,21 @@ module Moxml
|
|
|
3207
3207
|
SET_ATTRIBUTE_NATIVE =
|
|
3208
3208
|
NATIVE_READ_LAYER && NN.method_defined?(:set_attribute)
|
|
3209
3209
|
|
|
3210
|
+
# TODO.perf/41 (leptris-ruby#622 ask 3): the module-level C
|
|
3211
|
+
# entry Native.set_binding_attribute(document, addr, name,
|
|
3212
|
+
# value) — free/readonly gates + binding-version bump + engine
|
|
3213
|
+
# set in one crossing. It serves the (document, address) pairs
|
|
3214
|
+
# the TypedData instance face cannot reach: AddressNode tokens
|
|
3215
|
+
# on the address-native lane and native nodes on exts without
|
|
3216
|
+
# the instance method. Semantically the bridge's twin: the
|
|
3217
|
+
# version bump IS the binding-memo invalidation (both
|
|
3218
|
+
# surfaces' memos drop on mutation), and callers invalidate
|
|
3219
|
+
# the wrapper caches exactly as before.
|
|
3220
|
+
SET_BINDING_ATTRIBUTE =
|
|
3221
|
+
NATIVE_READ_LAYER &&
|
|
3222
|
+
defined?(::Leptris::XML::Native) &&
|
|
3223
|
+
::Leptris::XML::Native.respond_to?(:set_binding_attribute)
|
|
3224
|
+
|
|
3210
3225
|
def set_attribute(element, name, value)
|
|
3211
3226
|
# Native write face (leptris-ruby#204's nn_set_attribute):
|
|
3212
3227
|
# gates + version bump + engine set in one C frame on the
|
|
@@ -3218,6 +3233,18 @@ module Moxml
|
|
|
3218
3233
|
return element.set_attribute(name.to_s, value.to_s)
|
|
3219
3234
|
end
|
|
3220
3235
|
|
|
3236
|
+
# TODO.perf/41: the module-level entry for the addressed
|
|
3237
|
+
# lane — one crossing instead of to_binding's Pointer wrap
|
|
3238
|
+
# + registry mint + memo'd hash write.
|
|
3239
|
+
if SET_BINDING_ATTRIBUTE
|
|
3240
|
+
doc, addr = attr_packet_target(element)
|
|
3241
|
+
if doc
|
|
3242
|
+
return ::Leptris::XML::Native.set_binding_attribute(
|
|
3243
|
+
doc, addr, name.to_s, value.to_s
|
|
3244
|
+
)
|
|
3245
|
+
end
|
|
3246
|
+
end
|
|
3247
|
+
|
|
3221
3248
|
element = to_binding(element) if NATIVE_READ_LAYER
|
|
3222
3249
|
element[name.to_s] = value.to_s
|
|
3223
3250
|
end
|
|
@@ -4146,10 +4173,11 @@ module Moxml
|
|
|
4146
4173
|
# AST walk is per-expression, so the verdict caches too.
|
|
4147
4174
|
PARENT_AXIS_CACHE = XPath::Cache.new(100)
|
|
4148
4175
|
|
|
4149
|
-
def xpath(node, expression, namespaces = {})
|
|
4176
|
+
def xpath(node, expression, namespaces = {}, context: nil)
|
|
4150
4177
|
namespaces = normalize_xpath_namespaces(namespaces)
|
|
4151
4178
|
node = to_binding(node) if NATIVE_READ_LAYER
|
|
4152
|
-
native = native_xpath(node, expression, namespaces
|
|
4179
|
+
native = native_xpath(node, expression, namespaces,
|
|
4180
|
+
context: context)
|
|
4153
4181
|
return native unless native.nil?
|
|
4154
4182
|
|
|
4155
4183
|
engine_xpath(node, expression, namespaces)
|
|
@@ -4178,9 +4206,10 @@ module Moxml
|
|
|
4178
4206
|
hit.is_a?(::Moxml::Node) ? hit : node
|
|
4179
4207
|
end
|
|
4180
4208
|
|
|
4181
|
-
def at_xpath(node, expression, namespaces = {})
|
|
4209
|
+
def at_xpath(node, expression, namespaces = {}, context: nil)
|
|
4182
4210
|
namespaces = normalize_xpath_namespaces(namespaces)
|
|
4183
|
-
native = native_xpath(node, expression, namespaces,
|
|
4211
|
+
native = native_xpath(node, expression, namespaces,
|
|
4212
|
+
first_only: true, context: context)
|
|
4184
4213
|
return native unless native.nil?
|
|
4185
4214
|
|
|
4186
4215
|
result = engine_xpath(node, expression, namespaces)
|
|
@@ -4199,7 +4228,8 @@ module Moxml
|
|
|
4199
4228
|
|
|
4200
4229
|
# @return [Array, Object, nil] native results, or nil when the
|
|
4201
4230
|
# query must run on the Ruby engine
|
|
4202
|
-
def native_xpath(node, expression, namespaces, first_only: false
|
|
4231
|
+
def native_xpath(node, expression, namespaces, first_only: false,
|
|
4232
|
+
context: nil)
|
|
4203
4233
|
# Canonical natives (the #219 unification) are bare TypedData
|
|
4204
4234
|
# wrappers — no Searchable methods, no document handle for
|
|
4205
4235
|
# the gates below. The memoized bridge recovers the binding
|
|
@@ -4321,7 +4351,8 @@ module Moxml
|
|
|
4321
4351
|
# The one-crossing mint is deferred: a caller that only
|
|
4322
4352
|
# asks #size never pays for the rows (#527). The holder
|
|
4323
4353
|
# runs Document#xpath_result_rows_bulk on first read.
|
|
4324
|
-
return Moxml::LazyBulkRows.new(document, result_ptr
|
|
4354
|
+
return Moxml::LazyBulkRows.new(document, result_ptr,
|
|
4355
|
+
context, self)
|
|
4325
4356
|
end
|
|
4326
4357
|
|
|
4327
4358
|
# The binding's #to_a mints one Ruby wrapper per result
|
data/lib/moxml/adapter/libxml.rb
CHANGED
|
@@ -1086,7 +1086,10 @@ module Moxml
|
|
|
1086
1086
|
end
|
|
1087
1087
|
end
|
|
1088
1088
|
|
|
1089
|
-
|
|
1089
|
+
# rubocop:disable Lint/UnusedMethodArgument -- the protocol passes the
|
|
1090
|
+
# priming triple; engines without a bulk mint ignore it
|
|
1091
|
+
def xpath(node, expression, namespaces = nil, context: nil)
|
|
1092
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
|
1090
1093
|
native_node = unpatch_node(node)
|
|
1091
1094
|
return [] unless native_node
|
|
1092
1095
|
|
|
@@ -647,7 +647,10 @@ module Moxml
|
|
|
647
647
|
native.system_id
|
|
648
648
|
end
|
|
649
649
|
|
|
650
|
-
|
|
650
|
+
# rubocop:disable Lint/UnusedMethodArgument -- the protocol passes the
|
|
651
|
+
# priming triple; engines without a bulk mint ignore it
|
|
652
|
+
def xpath(node, expression, namespaces = nil, context: nil)
|
|
653
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
|
651
654
|
if empty_default_namespace_binding?(namespaces)
|
|
652
655
|
return Moxml::XPath.evaluate_natives(node, expression,
|
|
653
656
|
namespaces,
|
data/lib/moxml/adapter/oga.rb
CHANGED
|
@@ -587,7 +587,10 @@ module Moxml
|
|
|
587
587
|
end
|
|
588
588
|
end
|
|
589
589
|
|
|
590
|
-
|
|
590
|
+
# rubocop:disable Lint/UnusedMethodArgument -- the protocol passes the
|
|
591
|
+
# priming triple; engines without a bulk mint ignore it
|
|
592
|
+
def xpath(node, expression, namespaces = nil, context: nil)
|
|
593
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
|
591
594
|
# oga's engine has no xmlns: default-namespace idiom
|
|
592
595
|
# (D-01); the reference engine implements it (model,
|
|
593
596
|
# Names and namespaces).
|
data/lib/moxml/adapter/ox.rb
CHANGED
|
@@ -715,7 +715,10 @@ module Moxml
|
|
|
715
715
|
# with HeadedOx and Leptris). Ox's locate() only covers a
|
|
716
716
|
# small XPath subset; the engine provides all axes,
|
|
717
717
|
# predicates, functions and variables.
|
|
718
|
-
|
|
718
|
+
# rubocop:disable Lint/UnusedMethodArgument -- the protocol passes the
|
|
719
|
+
# priming triple; engines without a bulk mint ignore it
|
|
720
|
+
def xpath(node, expression, namespaces = {}, context: nil)
|
|
721
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
|
719
722
|
wrapped = if node.is_a?(Moxml::Node)
|
|
720
723
|
node
|
|
721
724
|
else
|
data/lib/moxml/adapter/rexml.rb
CHANGED
|
@@ -640,7 +640,10 @@ module Moxml
|
|
|
640
640
|
ns
|
|
641
641
|
end
|
|
642
642
|
|
|
643
|
-
|
|
643
|
+
# rubocop:disable Lint/UnusedMethodArgument -- the protocol passes the
|
|
644
|
+
# priming triple; engines without a bulk mint ignore it
|
|
645
|
+
def xpath(node, expression, namespaces = {}, context: nil)
|
|
646
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
|
644
647
|
# REXML's engine answers no text nodes for text() node
|
|
645
648
|
# tests (D-07, both axes); the reference engine does
|
|
646
649
|
# (model, XPath evaluation).
|
data/lib/moxml/document.rb
CHANGED
|
@@ -296,7 +296,8 @@ module Moxml
|
|
|
296
296
|
def xpath(expression, namespaces = nil)
|
|
297
297
|
expression = lax_document_path(expression) if relative_name_test?(expression)
|
|
298
298
|
|
|
299
|
-
result = adapter.xpath(@native, expression, namespaces
|
|
299
|
+
result = adapter.xpath(@native, expression, namespaces,
|
|
300
|
+
context: context)
|
|
300
301
|
|
|
301
302
|
# Handle different result types:
|
|
302
303
|
# - Scalar values (from functions): return directly
|
data/lib/moxml/lazy_bulk_rows.rb
CHANGED
|
@@ -16,9 +16,17 @@ module Moxml
|
|
|
16
16
|
class LazyBulkRows
|
|
17
17
|
include LazyNodeSet
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
# (context, adapter): the consumer contract triple for the primed
|
|
20
|
+
# mint (TODO.perf/40, leptris-ruby#622 ask 2) — the bulk face
|
|
21
|
+
# writes @mx_context/@mx_adapter in C and extends all-native
|
|
22
|
+
# results with BulkIdentityRows, so NodeSet's per-row wrap prime
|
|
23
|
+
# disappears from the iterate-every-result lane. nil (older
|
|
24
|
+
# bindings) keeps the unprimed mint.
|
|
25
|
+
def initialize(document, result_ptr, context = nil, adapter = nil)
|
|
20
26
|
@document = document
|
|
21
27
|
@ptr = result_ptr
|
|
28
|
+
@context = context
|
|
29
|
+
@adapter = adapter
|
|
22
30
|
@rows = nil
|
|
23
31
|
ObjectSpace.define_finalizer(
|
|
24
32
|
self, self.class.finalizer(result_ptr.address)
|
|
@@ -62,7 +70,7 @@ module Moxml
|
|
|
62
70
|
return @rows if @rows
|
|
63
71
|
|
|
64
72
|
ObjectSpace.undefine_finalizer(self)
|
|
65
|
-
@rows = @document.xpath_result_rows_bulk(@ptr)
|
|
73
|
+
@rows = @document.xpath_result_rows_bulk(@ptr, @context, @adapter)
|
|
66
74
|
@ptr = nil
|
|
67
75
|
@rows
|
|
68
76
|
end
|
data/lib/moxml/node.rb
CHANGED
|
@@ -415,7 +415,8 @@ module Moxml
|
|
|
415
415
|
end
|
|
416
416
|
|
|
417
417
|
def xpath(expression, namespaces = {})
|
|
418
|
-
result = adapter.xpath(@native, expression, namespaces
|
|
418
|
+
result = adapter.xpath(@native, expression, namespaces,
|
|
419
|
+
context: context)
|
|
419
420
|
# Adapter contract: Array<native> | LazyNodeSet | scalar.
|
|
420
421
|
# Scalars (count(), string-length(), booleans) pass through
|
|
421
422
|
# unwrapped; the set forms wrap lazily.
|
|
@@ -476,7 +477,8 @@ module Moxml
|
|
|
476
477
|
def css(expression)
|
|
477
478
|
NodeSet.new(
|
|
478
479
|
adapter.xpath(@native, Css.to_xpath(expression,
|
|
479
|
-
absolute: document?)
|
|
480
|
+
absolute: document?),
|
|
481
|
+
context: context),
|
|
480
482
|
context,
|
|
481
483
|
)
|
|
482
484
|
end
|
data/lib/moxml/version.rb
CHANGED