teptris 0.1.0-x86_64-linux → 0.2.0-x86_64-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: a68a9553a1b25317ee148bb0816095f18ed405b4da9b7a7dab04b23fd9293876
4
- data.tar.gz: edd5e556c22fcfd6e8282aa66fa233879a9d7c50ccdbf68b74806f069498db25
3
+ metadata.gz: 93a95708be6683b6ee27b6f88b25a700c7e221258f94710f794ec0b4db7f2e96
4
+ data.tar.gz: 572a23b71c3d319281c6eee7ab632c59df7c48052ee2ec814626a1735af47e00
5
5
  SHA512:
6
- metadata.gz: 70dc23d3bc00dac9181f84f560a0f282b5755047d97473f56606c6622489ea088b2318b2050fe3d78ba1d5f94d1bcfdee61af302a12f50d4873fa5e812832a49
7
- data.tar.gz: c1baf8697f6abaf5ca479aa9998826e761ef36b98df9f9e6770345f500a12981f799d8a9ec7de1ff8232ef5a83c3e394a06bc23f0f71cce91c06114b2e30ec8e
6
+ metadata.gz: acc8c7a6920e0a08443c9ff16db1642fa0c04d8006d56d6a50fb406aff20b01d3ed64373390976958d1c835fa454d4b821fab26d830928f06d945b6a49c0695a
7
+ data.tar.gz: 67eac1aaf760fdd7597b701fcbdb8f976b51a25dd16ff98b6b77c8b4ce5a75d2f92c1de0ea07145bfeb29763ebf223cb1fcaf2dd59bf71bb3d15b43aaab4b746
data/lib/teptris/toml.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "date"
2
2
 
3
3
  require_relative "error"
4
- require_relative "lib"
4
+
5
5
  require_relative "version"
6
6
 
7
7
  module Teptris
@@ -12,7 +12,9 @@ module Teptris
12
12
  module TOML
13
13
  class << self
14
14
  def load(toml)
15
- parse_and_materialize(toml, 0, nil)
15
+ raise ArgumentError, "input must be a String" unless toml.is_a?(String)
16
+
17
+ TeptrisExt.load(toml)
16
18
  end
17
19
 
18
20
  # Safe-load shaped entry point for frameworks: permitted_classes
@@ -23,18 +25,19 @@ module Teptris
23
25
  unless %i[native string].include?(datetime_policy)
24
26
  raise ArgumentError, "datetime_policy must be :native or :string"
25
27
  end
26
- mode = datetime_policy == :string ? 1 : 0
27
- permitted = permitted_classes && Set.new(permitted_classes)
28
- if permitted && mode.zero?
29
- permitted << String # TOML scalars are always materialized
28
+ opts = {}
29
+ opts[:string_datetimes] = true if datetime_policy == :string
30
+ if permitted_classes && datetime_policy == :native
31
+ permitted = permitted_classes + [:__scalar]
32
+ opts[:forbid_time] = true unless permitted.include?(Time)
33
+ opts[:forbid_date] = true unless permitted.include?(Date)
30
34
  end
31
- parse_and_materialize(toml, mode, permitted)
35
+ load(toml) if opts.empty?
36
+ TeptrisExt.load(toml, opts)
32
37
  end
33
38
 
34
39
  # Reserved: fused descriptor materialization, the same descriptor
35
- # shape as leptris/yeptris#238 — see docs/DESCRIPTOR_ABI.md. The
36
- # entry point exists so frameworks can code against it today; the
37
- # fused native pass lands with the co-designed ABI.
40
+ # shape as leptris/yeptris#238 — see docs/DESCRIPTOR_ABI.md.
38
41
  def load_schema(toml, descriptor)
39
42
  raise Error,
40
43
  "descriptor materialization lands with the co-designed " \
@@ -42,27 +45,8 @@ module Teptris
42
45
  "see docs/DESCRIPTOR_ABI.md (descriptor #{descriptor.class})"
43
46
  end
44
47
 
45
- private
46
-
47
- def parse_and_materialize(toml, mode, permitted)
48
- raise ArgumentError, "input must be a String" unless toml.is_a?(String)
49
-
50
- data = FFI::MemoryPointer.from_string(toml)
51
- docp = FFI::MemoryPointer.new(:pointer)
52
- st = Lib.teptris_parse(data, toml.bytesize, nil, docp)
53
- handle = docp.read_pointer
54
- if st != Teptris::TEPTRIS_OK
55
- raise build_parse_error(handle)
56
- end
57
- begin
58
- @mode = mode
59
- @permitted = permitted
60
- load_flat(handle)
61
- ensure
62
- @mode = nil
63
- @permitted = nil
64
- Lib.teptris_document_free(handle)
65
- end
48
+ def engine_version
49
+ TeptrisExt.engine_version
66
50
  end
67
51
 
68
52
  public
@@ -1,3 +1,3 @@
1
1
  module Teptris
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/teptris.rb CHANGED
@@ -1,9 +1,9 @@
1
- require "set"
1
+ require "date"
2
2
 
3
3
  require_relative "teptris/version"
4
4
  require_relative "teptris/error"
5
- require_relative "teptris/lib"
6
5
  require_relative "teptris/toml"
6
+ require "teptris_ext" # the native extension IS the binding (no fallback)
7
7
 
8
8
  module Teptris
9
9
  TEPTRIS_OK = 0
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - teptris contributors
@@ -9,21 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2026-09-13 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ffi
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.15'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.15'
12
+ dependencies: []
27
13
  description: An FFI binding over libteptris, a C11 TOML 1.0 parser/emitter. API shape
28
14
  mirrors the tomlib gem.
29
15
  email:
@@ -34,9 +20,9 @@ files:
34
20
  - lib/libteptris.so
35
21
  - lib/teptris.rb
36
22
  - lib/teptris/error.rb
37
- - lib/teptris/lib.rb
38
23
  - lib/teptris/toml.rb
39
24
  - lib/teptris/version.rb
25
+ - lib/teptris_ext.so
40
26
  homepage: https://github.com/leptris/teptris-ruby
41
27
  licenses:
42
28
  - MIT
data/lib/teptris/lib.rb DELETED
@@ -1,81 +0,0 @@
1
- require "ffi"
2
-
3
- module Teptris
4
- # Loads the shared libteptris: TEPTRIS_LIB_PATH env, vendored
5
- # lib/platform/<tag>/, the sibling C checkout's build tree, then the
6
- # system paths (yeptris-ruby resolution chain).
7
- module Lib
8
- extend FFI::Library
9
-
10
- NAMES = %w[libteptris.dylib libteptris.so libteptris.dll].freeze
11
-
12
- def self.candidates
13
- out = []
14
- out << ENV["TEPTRIS_LIB_PATH"] if ENV["TEPTRIS_LIB_PATH"]
15
- out.concat(Dir[File.expand_path("../libteptris.*", __dir__)])
16
- NAMES.each do |n|
17
- %w[build build-release build-shared build-bench].each do |b|
18
- out << File.expand_path("../../teptris/#{b}/src/#{n}", __dir__)
19
- end
20
- out << n
21
- end
22
- out.compact
23
- end
24
-
25
- loaded = nil
26
- candidates.each do |c|
27
- begin
28
- ffi_lib c
29
- loaded = c
30
- break
31
- rescue LoadError
32
- next
33
- end
34
- end
35
- raise Error, "libteptris not found (set TEPTRIS_LIB_PATH)" unless loaded
36
- LIBRARY_PATH = loaded
37
-
38
- typedef :pointer, :doc
39
- typedef :pointer, :node
40
-
41
- attach_function :teptris_parse, [:pointer, :size_t, :pointer, :pointer], :int
42
- attach_function :teptris_document_free, [:doc], :void
43
- attach_function :teptris_document_error, [:doc], :pointer
44
- attach_function :teptris_document_root, [:doc], :node
45
- attach_function :teptris_document_emit, [:doc, :pointer, :pointer], :int
46
- attach_function :teptris_node_kind, [:node], :int
47
- attach_function :teptris_node_string, [:node, :pointer], :int
48
- attach_function :teptris_node_integer, [:node, :pointer], :int
49
- attach_function :teptris_node_float, [:node, :pointer], :int
50
- attach_function :teptris_node_boolean, [:node, :pointer], :int
51
- attach_function :teptris_node_datetime, [:node, :pointer], :int
52
- attach_function :teptris_node_array_length, [:node], :size_t
53
- attach_function :teptris_node_array_at, [:node, :size_t], :node
54
- attach_function :teptris_node_table_length, [:node], :size_t
55
- attach_function :teptris_node_table_at, [:node, :size_t, :pointer], :node
56
- attach_function :teptris_document_flatten, [:doc, :pointer, :pointer], :int
57
- attach_function :teptris_flatten_free, [:pointer], :void
58
-
59
- class ErrorStruct < FFI::Struct
60
- layout :status, :int, :line, :size_t, :column, :size_t, :message, :string
61
- end
62
-
63
- class ViewStruct < FFI::Struct
64
- layout :ptr, :pointer, :len, :size_t
65
- end
66
-
67
- class DateTimeStruct < FFI::Struct
68
- layout :year, :int32,
69
- :month, :uint8, :day, :uint8,
70
- :hour, :uint8, :minute, :uint8, :second, :uint8,
71
- :_pad, [:uint8, 3],
72
- :nanosecond, :uint32, :offset_seconds, :int32
73
- end
74
- end
75
-
76
- KIND = {
77
- string: 0, integer: 1, float: 2, boolean: 3,
78
- datetime: 4, datetime_local: 5, date_local: 6, time_local: 7,
79
- array: 8, table: 9
80
- }.freeze
81
- end