teptris 0.3.0.0-x86_64-linux → 0.3.0.2-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/ext/teptris_ext/engine/README.md +1 -1
- data/ext/teptris_ext/engine/src/include/teptris/teptris.h +10 -0
- data/ext/teptris_ext/engine/src/include/teptris/version.h +3 -3
- data/ext/teptris_ext/engine/src/teptris/api.c +6 -0
- data/ext/teptris_ext/engine/src/teptris/emit/emitter.c +72 -0
- data/ext/teptris_ext/engine/src/teptris/emit/emitter.h +3 -0
- data/ext/teptris_ext/materialize.c +17 -2
- data/lib/teptris/3.3/teptris_ext.so +0 -0
- data/lib/teptris/3.4/teptris_ext.so +0 -0
- data/lib/teptris/4.0/teptris_ext.so +0 -0
- data/lib/teptris/toml.rb +7 -0
- data/lib/teptris/version.rb +1 -1
- data/sig/teptris.rbs +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0461415ae4e574998841ddf2bb9445121bd1bba2f422b089e4005606af348eef
|
|
4
|
+
data.tar.gz: 650b43acbcd31807c282f1cdc24884149b66b944f15d5b4057623425b6696576
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c45432a8f17d4a32b3b7525a4c857a4974a2f573fda71679f384f2129feb5b3830284839eff336478ddd010d20f584b98574019df644e293d29658a5e9f9c78
|
|
7
|
+
data.tar.gz: f9a89fe3909eeda919a120b135ce94cf67f3de4ad58db3da3cff5e9ef31004d3d3973da074c99856481c7d4e497d57a40dc1a1e877b46be2a590be5f2f3771f5
|
|
@@ -142,6 +142,16 @@ TEPTRIS_API teptris_status teptris_document_emit(const teptris_document *doc,
|
|
|
142
142
|
TEPTRIS_API teptris_status teptris_document_emit_json(const teptris_document *doc,
|
|
143
143
|
char **buf, size_t *len);
|
|
144
144
|
|
|
145
|
+
/* Natural-JSON emit: host-shaped values - real numbers, JSON
|
|
146
|
+
* booleans, datetimes as RFC 3339 strings (offset form carries its
|
|
147
|
+
* offset; the four TOML datetime shapes render date, time,
|
|
148
|
+
* date-time, and offset date-time). Two deliberate, lossy mappings:
|
|
149
|
+
* non-finite floats (TOML allows nan/inf) become null, and a
|
|
150
|
+
* datetime is indistinguishable from a same-shaped JSON string.
|
|
151
|
+
* Memory: *buf is malloc'd; caller frees with free(). */
|
|
152
|
+
TEPTRIS_API teptris_status teptris_document_emit_json_natural(
|
|
153
|
+
const teptris_document *doc, char **buf, size_t *len);
|
|
154
|
+
|
|
145
155
|
/* Bulk drain for FFI/ctypes bindings: the whole tree in ONE crossing as
|
|
146
156
|
* a self-describing flat buffer (explicit little-endian):
|
|
147
157
|
* table 0x01 u32 n *(u32 klen key node)
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
#define TEPTRIS_VERSION_H
|
|
3
3
|
|
|
4
4
|
#define TEPTRIS_VERSION_MAJOR 0
|
|
5
|
-
#define TEPTRIS_VERSION_MINOR
|
|
6
|
-
#define TEPTRIS_VERSION_PATCH
|
|
7
|
-
#define TEPTRIS_VERSION_STRING "0.
|
|
5
|
+
#define TEPTRIS_VERSION_MINOR 3
|
|
6
|
+
#define TEPTRIS_VERSION_PATCH 0
|
|
7
|
+
#define TEPTRIS_VERSION_STRING "0.3.0"
|
|
8
8
|
|
|
9
9
|
#endif /* TEPTRIS_VERSION_H */
|
|
@@ -218,6 +218,12 @@ teptris_status teptris_document_emit_json(const teptris_document *doc,
|
|
|
218
218
|
return teptris_emit_document_json(doc, buf, len);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
teptris_status teptris_document_emit_json_natural(
|
|
222
|
+
const teptris_document *doc, char **buf, size_t *len)
|
|
223
|
+
{
|
|
224
|
+
return teptris_emit_document_json_natural(doc, buf, len);
|
|
225
|
+
}
|
|
226
|
+
|
|
221
227
|
/* --------------------------------------------------- bulk flatten ----- */
|
|
222
228
|
|
|
223
229
|
typedef struct {
|
|
@@ -699,6 +699,78 @@ static void emit_json_value(ebuf *b, const teptris_node *n)
|
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
701
|
|
|
702
|
+
/* Natural-JSON emit (#101 v1): host-shaped values instead of the
|
|
703
|
+
* toml-test dialect - real numbers, booleans as JSON booleans,
|
|
704
|
+
* datetimes as RFC 3339 strings (offset form carries its offset).
|
|
705
|
+
* The two lossy spots are deliberate and documented in the header:
|
|
706
|
+
* non-finite floats become null (JSON has no nan/inf), and the
|
|
707
|
+
* datetime KIND is not distinguishable from a same-shaped string. */
|
|
708
|
+
static void emit_json_nat_value(ebuf *b, const teptris_node *n)
|
|
709
|
+
{
|
|
710
|
+
switch (n->kind) {
|
|
711
|
+
case TEPTRIS_TABLE:
|
|
712
|
+
eb_c(b, '{');
|
|
713
|
+
for (size_t i = 0; i < n->as.table.len; i++) {
|
|
714
|
+
if (i > 0) {
|
|
715
|
+
eb_c(b, ',');
|
|
716
|
+
}
|
|
717
|
+
json_string(b, n->as.table.entries[i].key);
|
|
718
|
+
eb_c(b, ':');
|
|
719
|
+
emit_json_nat_value(b, n->as.table.entries[i].value);
|
|
720
|
+
}
|
|
721
|
+
eb_c(b, '}');
|
|
722
|
+
break;
|
|
723
|
+
case TEPTRIS_ARRAY:
|
|
724
|
+
eb_c(b, '[');
|
|
725
|
+
for (size_t i = 0; i < n->as.array.len; i++) {
|
|
726
|
+
if (i > 0) {
|
|
727
|
+
eb_c(b, ',');
|
|
728
|
+
}
|
|
729
|
+
emit_json_nat_value(b, n->as.array.items[i]);
|
|
730
|
+
}
|
|
731
|
+
eb_c(b, ']');
|
|
732
|
+
break;
|
|
733
|
+
case TEPTRIS_STRING:
|
|
734
|
+
json_string(b, n->as.str);
|
|
735
|
+
break;
|
|
736
|
+
case TEPTRIS_INTEGER:
|
|
737
|
+
emit_i64(b, n->as.i);
|
|
738
|
+
break;
|
|
739
|
+
case TEPTRIS_FLOAT:
|
|
740
|
+
if (isnan(n->as.f) || isinf(n->as.f)) {
|
|
741
|
+
eb_str(b, "null");
|
|
742
|
+
} else {
|
|
743
|
+
emit_float(b, n->as.f);
|
|
744
|
+
}
|
|
745
|
+
break;
|
|
746
|
+
case TEPTRIS_BOOLEAN:
|
|
747
|
+
eb_str(b, n->as.b ? "true" : "false");
|
|
748
|
+
break;
|
|
749
|
+
default:
|
|
750
|
+
eb_c(b, '"');
|
|
751
|
+
emit_dt(b, &n->as.dt, (teptris_kind)n->kind);
|
|
752
|
+
eb_c(b, '"');
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
teptris_status teptris_emit_document_json_natural(
|
|
757
|
+
const teptris_document *doc, char **buf, size_t *len)
|
|
758
|
+
{
|
|
759
|
+
if (doc == NULL || doc->root == NULL) {
|
|
760
|
+
return TEPTRIS_ERR_ARG;
|
|
761
|
+
}
|
|
762
|
+
ebuf b = {0, 0, 0, TEPTRIS_OK};
|
|
763
|
+
eb_reserve(&b, 256);
|
|
764
|
+
emit_json_nat_value(&b, doc->root);
|
|
765
|
+
if (b.st != TEPTRIS_OK) {
|
|
766
|
+
return b.st;
|
|
767
|
+
}
|
|
768
|
+
eb_c(&b, '\0');
|
|
769
|
+
*buf = b.p;
|
|
770
|
+
*len = b.len - 1;
|
|
771
|
+
return TEPTRIS_OK;
|
|
772
|
+
}
|
|
773
|
+
|
|
702
774
|
teptris_status teptris_emit_document_json(const teptris_document *doc,
|
|
703
775
|
char **buf, size_t *len)
|
|
704
776
|
{
|
|
@@ -8,4 +8,7 @@ teptris_status teptris_emit_document(const teptris_document *doc, char **buf,
|
|
|
8
8
|
teptris_status teptris_emit_document_json(const teptris_document *doc,
|
|
9
9
|
char **buf, size_t *len);
|
|
10
10
|
|
|
11
|
+
teptris_status teptris_emit_document_json_natural(
|
|
12
|
+
const teptris_document *doc, char **buf, size_t *len);
|
|
13
|
+
|
|
11
14
|
#endif /* TEPTRIS_EMITTER_H */
|
|
@@ -438,7 +438,9 @@ static void build_value(teptris_builder *b, VALUE v) {
|
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
static VALUE
|
|
441
|
+
static VALUE dump_with(VALUE obj,
|
|
442
|
+
teptris_status (*emit)(const teptris_document *,
|
|
443
|
+
char **, size_t *)) {
|
|
442
444
|
if (!RB_TYPE_P(obj, T_HASH))
|
|
443
445
|
rb_raise(rb_eArgError, "cannot dump %s (root must be a Hash)",
|
|
444
446
|
rb_obj_classname(obj));
|
|
@@ -454,7 +456,7 @@ static VALUE ext_dump(VALUE self, VALUE obj) {
|
|
|
454
456
|
}
|
|
455
457
|
char *buf = NULL;
|
|
456
458
|
size_t len = 0;
|
|
457
|
-
st =
|
|
459
|
+
st = emit(doc, &buf, &len);
|
|
458
460
|
teptris_document_free(doc);
|
|
459
461
|
teptris_builder_free(b); /* doc already transferred/freed */
|
|
460
462
|
if (st != TEPTRIS_OK)
|
|
@@ -464,6 +466,17 @@ static VALUE ext_dump(VALUE self, VALUE obj) {
|
|
|
464
466
|
return out;
|
|
465
467
|
}
|
|
466
468
|
|
|
469
|
+
static VALUE ext_dump(VALUE self, VALUE obj) {
|
|
470
|
+
return dump_with(obj, teptris_document_emit);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/* Natural JSON (engine 0.3.0): real numbers, booleans, RFC 3339
|
|
474
|
+
* datetime strings — the mappings Teptris.dump_json_natural
|
|
475
|
+
* documents. Non-finite floats become null. */
|
|
476
|
+
static VALUE ext_dump_json_natural(VALUE self, VALUE obj) {
|
|
477
|
+
return dump_with(obj, teptris_document_emit_json_natural);
|
|
478
|
+
}
|
|
479
|
+
|
|
467
480
|
/* ------------------------------------------------- plan-walk (teptris#46) */
|
|
468
481
|
|
|
469
482
|
static void plan_free(void *p) { teptris_plan_free((teptris_plan *)p); }
|
|
@@ -1213,6 +1226,8 @@ void Init_teptris_ext(void) {
|
|
|
1213
1226
|
rb_define_method(cLazyValue, "to_a", lazy_to, 0);
|
|
1214
1227
|
rb_define_method(cLazyValue, "value", lazy_to, 0);
|
|
1215
1228
|
rb_define_module_function(m, "dump", ext_dump, 1);
|
|
1229
|
+
rb_define_module_function(m, "dump_json_natural", ext_dump_json_natural,
|
|
1230
|
+
1);
|
|
1216
1231
|
rb_define_module_function(m, "engine_version", ext_version, 0);
|
|
1217
1232
|
rb_define_module_function(m, "plan_build", ext_plan_build, 2);
|
|
1218
1233
|
rb_define_module_function(m, "plan_emit", ext_plan_emit, 2);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/teptris/toml.rb
CHANGED
|
@@ -150,6 +150,13 @@ module Teptris::TOML
|
|
|
150
150
|
TeptrisExt.dump(obj)
|
|
151
151
|
end
|
|
152
152
|
|
|
153
|
+
# Natural JSON (engine 0.3.0): real numbers, booleans, RFC 3339
|
|
154
|
+
# datetime strings. Non-finite floats become null — the same
|
|
155
|
+
# documented lossy mapping as teptris.h's natural-JSON contract.
|
|
156
|
+
def dump_json_natural(obj)
|
|
157
|
+
TeptrisExt.dump_json_natural(obj)
|
|
158
|
+
end
|
|
159
|
+
|
|
153
160
|
private
|
|
154
161
|
|
|
155
162
|
def _validate_batch!(input, safe_load, datetime_policy, kind: :strings)
|
data/lib/teptris/version.rb
CHANGED
data/sig/teptris.rbs
CHANGED
|
@@ -49,6 +49,8 @@ module Teptris
|
|
|
49
49
|
|
|
50
50
|
def self.dump: (untyped obj) -> String
|
|
51
51
|
|
|
52
|
+
def self.dump_json_natural: (untyped obj) -> String
|
|
53
|
+
|
|
52
54
|
def self.engine_version: () -> String
|
|
53
55
|
|
|
54
56
|
def self._validate_batch!: (untyped input, untyped safe_load,
|
|
@@ -122,6 +124,8 @@ module TeptrisExt
|
|
|
122
124
|
|
|
123
125
|
def self.dump: (untyped obj) -> String
|
|
124
126
|
|
|
127
|
+
def self.dump_json_natural: (untyped obj) -> String
|
|
128
|
+
|
|
125
129
|
def self.engine_version: () -> String
|
|
126
130
|
|
|
127
131
|
def self.plan_build: (Array[[String, Integer, Integer]] rows,
|
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.3.0.
|
|
4
|
+
version: 0.3.0.2
|
|
5
5
|
platform: x86_64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- teptris contributors
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A native C extension over libteptris, a C99 TOML 1.1 parser/emitter.
|
|
14
14
|
API shape mirrors the tomlib gem.
|