teptris 0.1.0-x86_64-linux → 0.2.1-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 +4 -4
- data/lib/teptris/toml.rb +15 -31
- data/lib/teptris/version.rb +1 -1
- data/lib/teptris.rb +2 -2
- data/lib/teptris_ext.so +0 -0
- metadata +3 -17
- data/lib/teptris/lib.rb +0 -81
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c6b4fa55a2f3b969f87ed98cff73671fc3020944e3ddd36b2c52743f1751892
|
|
4
|
+
data.tar.gz: 231ca4226e1e5141431eafa4e9ebd2285d610b9d5126b4b54bc62e47e4a621b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ebf019d4969abe75279cb75c31b3dddb24e7e4bb1f4d5e435ef4335ba1a3ae09ba7704482238a6e68c3a1516283fd74a5d8fa057856c97f4de2f825c793eb15
|
|
7
|
+
data.tar.gz: 1c5d6847faacfc42701283a2dfc29ac38c9ea079a34cb08edf332c7bb6ab5ed0ac1c75543c0c7274277087496ecd4acfdb5251f47c859082c1070d24f69fc81d
|
data/lib/teptris/toml.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require "date"
|
|
2
2
|
|
|
3
3
|
require_relative "error"
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
if
|
|
29
|
-
permitted
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
data/lib/teptris/version.rb
CHANGED
data/lib/teptris.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require "
|
|
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
|
data/lib/teptris_ext.so
ADDED
|
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
|
|
4
|
+
version: 0.2.1
|
|
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
|