yeptris 0.6.12.1 → 0.6.12.3

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/yeptris/ffi.rb +62 -25
  3. data/lib/yeptris.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffeaeb76cbc3a0a575cf5fce09e5ceff42ae233fa38125c4fb575eb15c2aafab
4
- data.tar.gz: d6667ffc31e29fd13f97d7bd5378b6a3611c39f849f7a69075d9e90c6e262df6
3
+ metadata.gz: 5900164f14038b2ef4e6c7b3e7764c335faf037559f9743099787e2ffcadb2f7
4
+ data.tar.gz: b539d2090254785c57c6dfd5a08e46200b668b0061619691e779a5c186a3978a
5
5
  SHA512:
6
- metadata.gz: 52298af429a38b41b55adf972d89156e5c214367debc1ccf618fd8e1a438414004861c8b6a7e9a1cc1e5235c68ba07a734ae580da668b3b7751b708102c9d46c
7
- data.tar.gz: c40301fda3424c9ef0d3d314a71dbf05b9a50af488c12b470f14cb8523912416ceb762de6e73ca6b44a97ac04b549d565113b688333320dabe9f3a2861895e50
6
+ metadata.gz: d837519cc77193279158957e4757a0b2ee6f250467d293422676135b6aee89058eac9dbb48c6b7a5f3eb79ca77cc1e076399f93935ed75d652612244b845db74
7
+ data.tar.gz: 5eff7ba15bd3c4314508d226ebaa4d2e3aa0eb0a7cc2887645078acbbecd193cbaa443af6877891b226224719b8955700f8567ec8a0446cc42fa713349993864
data/lib/yeptris/ffi.rb CHANGED
@@ -28,6 +28,32 @@ module Yeptris
28
28
  MSG
29
29
  end
30
30
 
31
+ class << self
32
+ # #138's class, hit again by the oiml-cs report: a stale
33
+ # libyeptris on the machine (the Windows base-name dedupe makes
34
+ # a system copy win) lacks newer symbols, and a raising attach
35
+ # aborts this file mid-evaluation — every constant after it
36
+ # never defines, so the next autoload dies with
37
+ # 'uninitialized constant Yeptris::FFI::NODE_SCALAR'. Attaches
38
+ # now record the miss and define a raising stub of the same
39
+ # name: the load completes, optional surfaces fail with a clear
40
+ # message at USE, and the ESSENTIAL self-check at the bottom of
41
+ # this file raises the friendly load error for truly old
42
+ # engines.
43
+ def attach_function(name, args, ret, opts = {})
44
+ super
45
+ rescue ::FFI::NotFoundError, ::FFI::TypeError
46
+ define_singleton_method(name) do |*_a, **_kw|
47
+ raise ::FFI::NotFoundError,
48
+ "yeptris: #{name} is unavailable — the loaded " \
49
+ "libyeptris is older than this gem. Update the engine " \
50
+ "library (or clear the stale copy shadowing it)."
51
+ end
52
+ (@missing ||= []) << name
53
+ nil
54
+ end
55
+ end
56
+
31
57
 
32
58
  typedef :pointer, :yeptris_document
33
59
  typedef :pointer, :yeptris_node
@@ -194,18 +220,14 @@ module Yeptris
194
220
  # instead of walking per-value records in pure Ruby. Same feature-
195
221
  # detect discipline as the columnar drain (older libraries fall
196
222
  # back to the record walk).
197
- MARSHAL = begin
198
- MARSHAL_ALL_DOCS = 0
199
- MARSHAL_FIRST_DOC = 1
200
- attach_function :yeptris_marshal,
201
- %i[pointer size_t int int pointer pointer], :int
202
- attach_function :yeptris_marshal_node,
203
- %i[yeptris_node pointer pointer], :int
204
- attach_function :yeptris_marshal_free, [:pointer], :void
205
- true
206
- rescue ::FFI::NotFoundError
207
- false
208
- end
223
+ MARSHAL_ALL_DOCS = 0
224
+ MARSHAL_FIRST_DOC = 1
225
+ attach_function :yeptris_marshal,
226
+ %i[pointer size_t int int pointer pointer], :int
227
+ attach_function :yeptris_marshal_node,
228
+ %i[yeptris_node pointer pointer], :int
229
+ attach_function :yeptris_marshal_free, [:pointer], :void
230
+ MARSHAL = !(@missing ||= []).include?(:yeptris_marshal_node)
209
231
 
210
232
  # bulk build (TODO.impl/15 phase D): one call raises a document
211
233
  BUILD_SCALAR = 1
@@ -238,19 +260,15 @@ module Yeptris
238
260
 
239
261
  # CBOR (RFC 8949, TODO.cbor): absent on libraries before the
240
262
  # codec's release — the CBOR module feature-detects
241
- CBOR_EX = begin
242
- attach_function :yeptris_cbor_decode, %i[pointer size_t uint32 yeptris_status_out],
243
- :yeptris_document
244
- callback :cbor_item_cb, %i[pointer yeptris_document size_t], :int
245
- attach_function :yeptris_cbor_decode_sequence,
246
- %i[pointer size_t uint32 cbor_item_cb pointer yeptris_status_out], :size_t
247
- attach_function :yeptris_cbor_encode, %i[yeptris_document uint32 pointer], :pointer
248
- attach_function :yeptris_cbor_encode_sequence,
249
- %i[pointer size_t uint32 pointer], :pointer
250
- true
251
- rescue ::FFI::NotFoundError
252
- false
253
- end
263
+ attach_function :yeptris_cbor_decode, %i[pointer size_t uint32 yeptris_status_out],
264
+ :yeptris_document
265
+ callback :cbor_item_cb, %i[pointer yeptris_document size_t], :int
266
+ attach_function :yeptris_cbor_decode_sequence,
267
+ %i[pointer size_t uint32 cbor_item_cb pointer yeptris_status_out], :size_t
268
+ attach_function :yeptris_cbor_encode, %i[yeptris_document uint32 pointer], :pointer
269
+ attach_function :yeptris_cbor_encode_sequence,
270
+ %i[pointer size_t uint32 pointer], :pointer
271
+ CBOR_EX = !(@missing ||= []).include?(:yeptris_cbor_decode)
254
272
 
255
273
  # Owned char* results (serialize*): one reader, freed exactly once.
256
274
  # The release goes through yeptris_free (libyeptris's own
@@ -368,5 +386,24 @@ module Yeptris
368
386
  ERROR_ARG = 6
369
387
  ERROR_UNSUPPORTED = 7
370
388
  ERROR_INTERNAL = 8
389
+ # The load-time essentials (the read path + the ownership
390
+ # contract): absent on engines far older than the optional
391
+ # surfaces — raise the friendly error once every constant has
392
+ # fully defined, so no partial-module state leaks into autoloads
393
+ # (the #138 class, closed at the root).
394
+ ESSENTIAL = %i[
395
+ yeptris_version yeptris_last_error yeptris_parse yeptris_parse_ex
396
+ yeptris_parse_json yeptris_document_free yeptris_document_count
397
+ yeptris_document_root yeptris_node_kind yeptris_node_value
398
+ yeptris_node_tag_id yeptris_node_style yeptris_document_new
399
+ yeptris_document_set_root yeptris_serialize yeptris_serialize_ex
400
+ ].freeze
401
+ missing_core = ESSENTIAL & (@missing ||= [])
402
+ raise ::FFI::NotFoundError,
403
+ "yeptris: the loaded libyeptris is older than this gem " \
404
+ "requires (missing: #{missing_core.join(', ')}). Update the " \
405
+ "engine library, or clear the stale copy shadowing it." \
406
+ unless missing_core.empty?
407
+
371
408
  end
372
409
  end
data/lib/yeptris.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Yeptris
4
4
  # The gem's version lives in the parent namespace's file — the last
5
5
  # internal require (yeptris/version) retired with it.
6
- VERSION = "0.6.12.1".freeze
6
+ VERSION = "0.6.12.3".freeze
7
7
  # The error hierarchy lives in THIS file (the parent namespace's
8
8
  # own file): nested constants do not trigger a parent-constant
9
9
  # autoload, and the law forbids internal requires — defining the
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.12.1
4
+ version: 0.6.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.