teptris 0.2.26-aarch64-linux → 0.2.29-aarch64-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9015612a2cef8cc7e6cb87507211d38ae526d92a446a0dcb5d21f6c9ffc7a389
4
- data.tar.gz: ff9036e1a2725b3405618325506ef508f87c7b1bb92049ff1587ea746f6a2748
3
+ metadata.gz: 477a02cb5a2389ff022cbb1b6589e4a684b11b29836afac63e6e9e6e85bc622f
4
+ data.tar.gz: 057a9b7e89921edc84147357d44d8844155a9e79a1fc54f84a9151a9ac32bc12
5
5
  SHA512:
6
- metadata.gz: c6c01d4de20806279f9831c8976bd9b46d3a4296cbfbab723c7e51fdccc944b0d221f9e1fc503d8d31821168caac3bac8bbb8a6adb82ebbbaf86b3998a5372af
7
- data.tar.gz: fcff4cab03a7673b1d43ef70e05a8209fde11b1793aa10933debfc699bf765c6d3dc06df7e9c3c8197842268f8f9bb792f8c978b7756956e0d92f135452cdeb3
6
+ metadata.gz: f77168573b78bcbc4b4051c74e7be7296ff42b4727eea93fc91c48711698e7013143401a18e8b4eac539d56f5087d05e3deeb0eb1216e4852f25f3370f4ae9b0
7
+ data.tar.gz: e489a2f3b3eb893126ab803c539eb7e2df63da5fc38850d83cf4ffd4377fc3d044b7ac6abb6fe92a234b9d4378907a023e97cfa91b56904517a12cae91904317
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Tree-shaped schema-descriptor materialization (teptris#46, mirroring
4
+ # leptris v1): compile a plan tree once, then materialize a whole TOML
5
+ # subtree against it in ONE native pass — unplanned keys are never
6
+ # materialized.
7
+ #
8
+ # descriptor = Teptris::Descriptor.build(
9
+ # children: [
10
+ # { name: "name", kind: :scalar },
11
+ # { name: "port", kind: :scalar },
12
+ # { name: "hosts", kind: :collection },
13
+ # { name: "items", kind: :nested, plan: {
14
+ # children: [{ name: "id", kind: :scalar }] } },
15
+ # { name: "everything_else", kind: :raw },
16
+ # ])
17
+ # descriptor.walk(toml_string) # => { "name" => "svc", ... }
18
+ #
19
+ # Row kinds: :scalar (any TOML value), :collection (array of scalars),
20
+ # :nested (recurse via +plan:+; also spans arrays of tables), :raw
21
+ # (the untouched native subtree). Rows absent from the document read
22
+ # as nil.
23
+ class Teptris::Descriptor
24
+ KINDS = { scalar: 1, collection: 2, nested: 3, raw: 4 }.freeze
25
+ private_constant :KINDS
26
+
27
+ attr_reader :rows, :first_row
28
+
29
+ def self.build(tree)
30
+ rows = []
31
+ first_row = [0] # plan 0 = the root: asm walks plan index 0
32
+ counter = [0]
33
+ compile(tree, rows, first_row, counter)
34
+ first_row << rows.length # sentinel: end of the last plan's rows
35
+ d = allocate
36
+ d.instance_variable_set(:@rows, rows.freeze)
37
+ d.instance_variable_set(:@first_row, first_row.freeze)
38
+ d.instance_variable_set(:@handle,
39
+ TeptrisExt.plan_build(rows, first_row))
40
+ d.freeze
41
+ end
42
+
43
+ # Pre-order: each plan's rows are one CONTIGUOUS block; nested
44
+ # sub-plans are compiled after the parent's block starts and their
45
+ # indices patch the parent's NESTED rows. first_row must eventually
46
+ # carry plan_count + 1 entries (the sentinel is rows.length).
47
+ def self.compile(tree, rows, first_row, counter)
48
+ idx = counter[0]
49
+ counter[0] += 1
50
+ first_row[idx] = rows.length
51
+ (tree[:children] || []).each do |ch|
52
+ kind = KINDS.fetch(ch[:kind])
53
+ if kind == 3
54
+ sub = counter[0]
55
+ pos = rows.length
56
+ rows << nil # patched with the real sub index below
57
+ sub = compile(ch[:plan], rows, first_row, counter)
58
+ rows[pos] = [ch[:name].to_s, kind, sub]
59
+ else
60
+ rows << [ch[:name].to_s, kind, 0]
61
+ end
62
+ end
63
+ idx
64
+ end
65
+ private_class_method :compile
66
+
67
+ def walk(toml)
68
+ TeptrisExt.plan_emit(@handle, toml)
69
+ end
70
+ end
data/lib/teptris/toml.rb CHANGED
@@ -36,13 +36,16 @@ module Teptris
36
36
  TeptrisExt.load(toml, opts)
37
37
  end
38
38
 
39
- # Reserved: fused descriptor materialization, the same descriptor
40
- # shape as leptris/yeptris#238 see docs/DESCRIPTOR_ABI.md.
39
+ # One-pass schema materialization over a compiled
40
+ # Teptris::Descriptor: unplanned keys are never materialized
41
+ # (teptris#46).
41
42
  def load_schema(toml, descriptor)
42
- raise Error,
43
- "descriptor materialization lands with the co-designed " \
44
- "ABI (leptris/yeptris#238); entry point is reserved " \
45
- "see docs/DESCRIPTOR_ABI.md (descriptor #{descriptor.class})"
43
+ unless descriptor.is_a?(Teptris::Descriptor)
44
+ raise ArgumentError,
45
+ "descriptor must be a Teptris::Descriptor (use " \
46
+ "Teptris::Descriptor.build), got #{descriptor.class}"
47
+ end
48
+ descriptor.walk(toml)
46
49
  end
47
50
 
48
51
  def engine_version
@@ -1,3 +1,3 @@
1
1
  module Teptris
2
- VERSION = "0.2.26"
2
+ VERSION = "0.2.29"
3
3
  end
data/lib/teptris.rb CHANGED
@@ -2,6 +2,7 @@ require "date"
2
2
 
3
3
  require_relative "teptris/version"
4
4
  require_relative "teptris/error"
5
+ require_relative "teptris/descriptor"
5
6
  require_relative "teptris/toml"
6
7
 
7
8
  # Windows ucrt rubies name their DLL per minor (x64-ucrt-ruby330.dll), so
data/lib/teptris_ext.so CHANGED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.26
4
+ version: 0.2.29
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - teptris contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-16 00:00:00.000000000 Z
11
+ date: 2026-09-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An FFI binding over libteptris, a C11 TOML 1.0 parser/emitter. API shape
14
14
  mirrors the tomlib gem.
@@ -18,6 +18,7 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - lib/teptris.rb
21
+ - lib/teptris/descriptor.rb
21
22
  - lib/teptris/error.rb
22
23
  - lib/teptris/toml.rb
23
24
  - lib/teptris/version.rb