leptris 1.2.1 → 1.3.0

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: e9d9e951ee8e7b15451e02933c6e5e80d6cb78fa970ff4411153ec1358c50ab1
4
- data.tar.gz: 5aab53987963478c27bb0d9bfe96e804672dcc6b7da1842cc3422f9e0b91c235
3
+ metadata.gz: e181133c2d381d3ed81fbab6ad41b99c0a72ed89cc651a7882c069eee06535fa
4
+ data.tar.gz: 768c1463a6746f331251d10f5499293b4c00c0914037fee33a08725b7855ac7c
5
5
  SHA512:
6
- metadata.gz: 7de27428d6e469b405889481a78bdbe1680d28e4b8c4bd2041ccfb49dd3b9a620359f5d66a4bc4f4573e16c332916348cf4313bedbb1c5d1876cf08cb64b243e
7
- data.tar.gz: c71f63da347773adfd341782dd10326ff5993c673080e63554013eed453137014f76f2b4a0474b9fa452c5009f573d4d65f01213822016e296735a0a1eea30e3
6
+ metadata.gz: f0c45bea9042ffec94231c4c799aa43145592d1dff5268ee75e75212b015be689ad875dac84b76ee8a7cf0624bb1b983c39b3dba8ef3966bc8591275648c7738
7
+ data.tar.gz: eb2803ee6a55c4dcd543678bcb9899c5651269d9737d92bffa9f8f156ddb87b22838f6c12b610644ee585ed6854041f4815f5b4a6f1de4cceb8dd8ae5aceca50
data/CHANGELOG.md CHANGED
@@ -5,6 +5,35 @@ All notable changes to Leptris will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.0] - 2026-08-23
9
+
10
+ Lockstep with libleptris 1.3.0 — takes full advantage of the
11
+ concurrency-release surface.
12
+
13
+ ### Added
14
+
15
+ - **EXSLT extension pack**: `Document#exslt` enables the first-party
16
+ str:/set:/math: function pack (replace, tokenize, split, concat,
17
+ padding; distinct, intersection, difference, leading, trailing;
18
+ max, min, abs, sqrt, power) as native C handlers on that document.
19
+ - `Document#last_error` — per-document error retrieval (thread-safe
20
+ successor to the library-global string).
21
+ - `leptris_thread_cleanup` bound — optional release of per-thread
22
+ registry entries when worker threads exit.
23
+
24
+ ### Changed
25
+
26
+ - Namespace-bound XPath builds its binding set in **one FFI call**
27
+ via `leptris_xpath_ns_set_new_from_pairs` (flat alternating
28
+ prefix/URI array through the CStringArray adapter) instead of
29
+ N+1 calls.
30
+ - `NodeSet#each` fetches mixed-kind results through
31
+ `leptris_xpath_result_get_nodes_ex`, which copies ALL node kinds —
32
+ the per-index fallback for the under-copying legacy accessor
33
+ (leptris#477 residual) is gone.
34
+ - `leptris_version_components` is now officially declared upstream
35
+ (it was exported-but-undeclared; the export gate caught it).
36
+
8
37
  ## [1.2.1] - 2026-08-23
9
38
 
10
39
  Completes the libleptris 1.2.0 public surface in the binding.
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
8
8
  # Pin for `rake compile` and the platform-gem builds. Keep in lockstep
9
9
  # with .github/workflows/build.yml (which calls `rake compile`) and the
10
10
  # CHANGELOG when libleptris releases.
11
- LIBLEPTRIS_VERSION = "1.2.0"
11
+ LIBLEPTRIS_VERSION = "1.3.0"
12
12
 
13
13
  CMAKE_FLAGS = %w[
14
14
  -DCMAKE_BUILD_TYPE=Release
@@ -34,8 +34,10 @@ task :compile do
34
34
  sh "cmake --build #{build}/build --config Release -j 4"
35
35
  # Windows names the shared library leptris.dll (no "lib" prefix);
36
36
  # vendoring under the uniform libleptris.* name keeps the FFI
37
- # search order simple.
38
- lib = Dir.glob("#{build}/build/**/libleptris.{dylib,so}").first ||
37
+ # search order simple. libleptris >= 1.3.0 renames the DLL to
38
+ # libleptris.dll on Windows too (leptris/leptris#507, issue
39
+ # TODO.concurrency/05) — accept both names.
40
+ lib = Dir.glob("#{build}/build/**/libleptris.{dylib,so,dll}").first ||
39
41
  Dir.glob("#{build}/build/**/leptris.dll").first
40
42
  raise "libleptris shared library not found after build" unless lib
41
43
  ext = File.extname(lib)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.2.1"
4
+ VERSION = "1.3.0"
5
5
  end
@@ -223,6 +223,23 @@ class Leptris::XML::Document
223
223
  @wrapper_cache.clear
224
224
  end
225
225
 
226
+ # Enable the first-party EXSLT-style extension pack on this
227
+ # document: str:/set:/math: prefixed functions (replace, tokenize,
228
+ # split, concat, padding; distinct, intersection, difference,
229
+ # leading, trailing; max, min, abs, sqrt, power) as native C
230
+ # handlers. Returns self for chaining.
231
+ def exslt
232
+ Leptris::XML::FFI.check_status(
233
+ Leptris::XML::FFI.leptris_exslt_enable(@c_ptr))
234
+ self
235
+ end
236
+
237
+ # The most recent error recorded against this document, or nil.
238
+ def last_error
239
+ msg = Leptris::XML::FFI.leptris_document_last_error(@c_ptr)
240
+ msg.nil? || msg.empty? ? nil : msg
241
+ end
242
+
226
243
  def name; "document"; end
227
244
  def document; self; end
228
245
  def encoding
@@ -344,6 +344,10 @@ module Leptris
344
344
  [:leptris_document, :string, :pointer, :pointer], :leptris_status
345
345
  attach_function :leptris_xpath_result_get_nodes,
346
346
  [:leptris_xpath_result, :pointer, :size_t], :size_t
347
+ # v1.3.0: copies ALL node kinds (the legacy accessor drops
348
+ # non-element entries) and can also report per-entry kinds.
349
+ attach_function :leptris_xpath_result_get_nodes_ex,
350
+ [:leptris_xpath_result, :pointer, :pointer, :size_t], :size_t
347
351
  attach_function :leptris_xpath_result_boolean,
348
352
  [:leptris_xpath_result], :int
349
353
  attach_function :leptris_xpath_result_number,
@@ -374,6 +378,10 @@ module Leptris
374
378
  [:leptris_xpath_ns_set], :void
375
379
  attach_function :leptris_xpath_ns_set_add,
376
380
  [:leptris_xpath_ns_set, :string, :string], :leptris_status
381
+ # One-call constructor: flat array of 2*pair_count alternating
382
+ # prefix/URI strings (v1.3.0).
383
+ attach_function :leptris_xpath_ns_set_new_from_pairs,
384
+ [:pointer, :size_t], :leptris_xpath_ns_set
377
385
  attach_function :leptris_xpath_eval_ns,
378
386
  [:leptris_document, :leptris_element, :string, :leptris_xpath_ns_set],
379
387
  :leptris_xpath_result
@@ -433,7 +441,18 @@ module Leptris
433
441
  [:leptris_document, :pointer, :pointer], :leptris_status
434
442
  attach_function :leptris_status_string, [:leptris_status], :string
435
443
  attach_function :leptris_error_message, [:leptris_status], :string
444
+ # Thread-local since v1.3.0; reliable under the
445
+ # one-document-per-thread contract.
436
446
  attach_function :leptris_last_error, [], :string
447
+ attach_function :leptris_document_last_error,
448
+ [:leptris_document], :string
449
+ # Optional: release per-thread registry entries when a worker
450
+ # thread exits (long-lived threads never need it).
451
+ attach_function :leptris_thread_cleanup, [], :void
452
+ # First-party EXSLT-style extension pack (str:/set:/math:),
453
+ # registered natively on one document.
454
+ attach_function :leptris_exslt_enable,
455
+ [:leptris_document], :leptris_status
437
456
 
438
457
  LEPTRIS_OK = 0
439
458
  LEPTRIS_ERROR_MEMORY = -1
@@ -55,16 +55,17 @@ module Leptris::XML::Searchable
55
55
 
56
56
  protected
57
57
 
58
- # Builds a caller-owned namespace binding set, evaluates via
58
+ # Builds a caller-owned namespace binding set in one FFI call
59
+ # (ns_set_new_from_pairs takes a flat alternating prefix/URI array,
60
+ # the same wire format CStringArray owns), evaluates via
59
61
  # leptris_xpath_eval_ns, and frees the set regardless of outcome.
60
62
  def xpath_eval_with_namespaces(doc_ptr, context_ptr, expr, ns)
61
- set = Leptris::XML::FFI.leptris_xpath_ns_set_new
63
+ flat = ns.flat_map { |prefix, uri| [prefix.to_s, uri.to_s] }
64
+ buffer, _anchors = Leptris::XML::CStringArray.to_c(flat)
65
+ set = Leptris::XML::FFI.leptris_xpath_ns_set_new_from_pairs(
66
+ buffer, flat.length / 2)
67
+ raise Leptris::XML::Error, "leptris_xpath_ns_set_new_from_pairs failed" if set.null?
62
68
  begin
63
- ns.each do |prefix, uri|
64
- Leptris::XML::FFI.check_status(
65
- Leptris::XML::FFI.leptris_xpath_ns_set_add(
66
- set, prefix.to_s, uri.to_s))
67
- end
68
69
  Leptris::XML::FFI.leptris_xpath_eval_ns(doc_ptr, context_ptr, expr, set)
69
70
  ensure
70
71
  Leptris::XML::FFI.leptris_xpath_ns_set_free(set)
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.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.