leptris 1.9.342.0 → 1.9.343.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: 9d35a3680b1e44935421bd7896695114dae8c8038f9ec61250acf5b0f7a127fb
4
- data.tar.gz: 53ab93d7bf80c535f3dd7f1c5c8d4beeb3c58a3667a42bfce94a7810e93324a8
3
+ metadata.gz: ceb72a0b1dfa706199190da83dccfa607f9a84f693e3f8ce4b89a9b47f8130e2
4
+ data.tar.gz: cc9cfdbc044dd5afa0ee06392d0eec59198cdf6fb1b9aeb00d11353056fdd429
5
5
  SHA512:
6
- metadata.gz: 4996a04e9d83156b0b5384d90f29299cc1f9c21cb9b51f2e627f2949d6dbd310440ecf4842fd66ddedb28093d430441731ecd3e4703390abb56b9f9d0ef9acbc
7
- data.tar.gz: c3d1a0e6a67cbef6cab74096f82d0d03d574c67c81515d0a1a46aa86042ed6b9045efd62c339fccb7ac89a645f8cc482c3928c8573221c0677de66d66ddc575f
6
+ metadata.gz: ee4d2f91c99c182cd7ae8290c064a70680b72735d8bf6f8ea1216a596fdd3425da2bf56551990cd549a0963297b8eaa3891d3646702a0fbf63c7ad04935a6723
7
+ data.tar.gz: a2d0897a24e68e991c254c003dc357f588aefa4f8fe4501950dfda0ee6d814eea64cb765a72a0599802695e4145ec1f5d451d5cb113fdfc150d7930355df63bc
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.342.0"
4
+ VERSION = "1.9.343.0"
5
5
  end
@@ -48,6 +48,28 @@ module Leptris::XML::XSD
48
48
  end
49
49
  end
50
50
 
51
+ # Deterministic drop (#362.3 / moxml): frees the compiled
52
+ # schema NOW instead of waiting for GC — long-lived validation
53
+ # services holding dozens of schemas stop parking engine-side
54
+ # trees for the process lifetime. The AutoPointer's GC
55
+ # finalizer is disarmed first (autorelease=false), so the free
56
+ # happens exactly once. Faces on a released schema raise.
57
+ #
58
+ # schema = Leptris::XML::XSD.compile_file(path)
59
+ # schema.release # => true
60
+ # schema.released? # => true
61
+ def release
62
+ return true if released?
63
+ @handle.autorelease = false
64
+ Leptris::XML::FFI.leptris_xsd_free(@handle)
65
+ @released = true
66
+ true
67
+ end
68
+
69
+ def released?
70
+ instance_variable_defined?(:@released) ? @released : false
71
+ end
72
+
51
73
  # Compile a schema from XML text. Raises Error when the text is
52
74
  # not usable at all (not well-formed, no root); schema-level
53
75
  # problems compile to a handle whose #error carries the detail
@@ -82,12 +104,14 @@ module Leptris::XML::XSD
82
104
  # Number of top-level schema declarations the compiler
83
105
  # recognized (elements, types, groups, ...).
84
106
  def declaration_count
107
+ check_released!
85
108
  Leptris::XML::FFI.leptris_xsd_declaration_count(@handle)
86
109
  end
87
110
 
88
111
  # The engine's schema-level error message, or nil when the
89
112
  # schema compiled cleanly.
90
113
  def error
114
+ check_released!
91
115
  msg = Leptris::XML::FFI.leptris_xsd_error(@handle)
92
116
  msg.nil? || msg.empty? ? nil : msg
93
117
  end
@@ -97,6 +121,7 @@ module Leptris::XML::XSD
97
121
  # name) — restriction chains validate every hop's facets,
98
122
  # cycle-guarded. Unknown type names raise (the -1 contract).
99
123
  def simple_valid?(type_name, lexical)
124
+ check_released!
100
125
  tri_state(
101
126
  Leptris::XML::FFI.leptris_xsd_simple_valid(
102
127
  @handle, type_name.to_s, lexical.to_s),
@@ -109,6 +134,7 @@ module Leptris::XML::XSD
109
134
  # and child content models through the Thompson NFA. Returns
110
135
  # true/false.
111
136
  def valid?(document)
137
+ check_released!
112
138
  tri_state(
113
139
  Leptris::XML::FFI.leptris_xsd_validate(
114
140
  @handle, document.c_ptr), "invalid document handle")
@@ -117,6 +143,7 @@ module Leptris::XML::XSD
117
143
  # The enumerated failure list of the last #validate run
118
144
  # (empty when valid; the NEXT validate replaces the list).
119
145
  def validate_errors(document)
146
+ check_released!
120
147
  valid?(document)
121
148
  Leptris::XML::FFI.leptris_xsd_error_count(@handle).times.map do |i|
122
149
  Leptris::XML::FFI.leptris_xsd_error_at(@handle, i)
@@ -129,6 +156,7 @@ module Leptris::XML::XSD
129
156
  # + effective namespace extracted per child). Unknown element
130
157
  # declarations raise (the -1 contract).
131
158
  def content_valid?(element_name, children)
159
+ check_released!
132
160
  kids = children.to_a
133
161
  nb, na = Leptris::XML::CStringArray.to_c(
134
162
  kids.map { |c| c.name.to_s })
@@ -142,6 +170,11 @@ module Leptris::XML::XSD
142
170
 
143
171
  private
144
172
 
173
+ def check_released!
174
+ raise Leptris::XML::UseAfterFreeError,
175
+ "schema released (moxml #362.3)" if released?
176
+ end
177
+
145
178
  # A child's effective namespace URI (nil = none) — read
146
179
  # through its own c_ptr, so docless wrappers work.
147
180
  def child_ns_uri(node)
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.9.342.0
4
+ version: 1.9.343.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.