yeptris 0.6.15.2 → 0.6.16.2

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.
@@ -0,0 +1,58 @@
1
+ /* sink.h — the CBOR decode seam (#157).
2
+ *
3
+ * The grammar loop (decode.c's cbor_item machinery) is the single
4
+ * source of CBOR semantics; a sink implements the item constructors
5
+ * on top of it. Two sinks exist: the DOM builder (the default, the
6
+ * yeptris_cbor_decode public path) and the native ext's VALUE builder
7
+ * (one pass, no intermediate). Sinks receive the resolver's tag_id
8
+ * and the pending semantic-tag chain in its text form ("N N N",
9
+ * outermost first — NULL when the item carries no chain).
10
+ */
11
+ #ifndef YEP_CBOR_SINK_H
12
+ #define YEP_CBOR_SINK_H
13
+
14
+ #include <stddef.h>
15
+ #include <stdint.h>
16
+
17
+ #include <yeptris/api.h> /* YEPTRIS_API (the ext links these) */
18
+
19
+ typedef struct yep_cbor_sink {
20
+ void* ctx;
21
+ /* All callbacks return 0 on sink failure (the decoder reports
22
+ * MEMORY). They may raise through host languages (longjmp): the
23
+ * decoder owns no host-managed state across them except the
24
+ * indefinite buffer, which its own exit paths free. */
25
+ /* is_key: 1 = the item lands in the enclosing map's key slot
26
+ * (sinks key-intern strings; the DOM ignores it). Rendered text:
27
+ * numbers-as-text, false/true/null/undefined, simple(N) — the
28
+ * exact bytes the DOM path stores. */
29
+ int (*text)(void* ctx, const char* s, uint32_t n, uint8_t tag_id, int is_key, const char* tag,
30
+ uint32_t tag_len);
31
+ /* Known integers: value = negative ? -(mag) : mag, mag <= 2^63. */
32
+ int (*int_val)(void* ctx, int negative, uint64_t mag, int is_key, const char* tag,
33
+ uint32_t tag_len);
34
+ int (*float_val)(void* ctx, double dv, int is_key, const char* tag, uint32_t tag_len);
35
+ /* Strings. borrowed: 1 = p is the input (a sink may record the
36
+ * offset), 0 = the decoder's scratch buffer (copy or take it). */
37
+ int (*str_val)(void* ctx, const unsigned char* p, uint32_t n, int borrowed, int is_key,
38
+ const char* tag, uint32_t tag_len);
39
+ int (*bytes_val)(void* ctx, const unsigned char* p, uint32_t n, int borrowed, int is_key,
40
+ const char* tag, uint32_t tag_len);
41
+ /* Containers. cap: expected item count (maps: pairs*2), UINT64_MAX
42
+ * for indefinite. close fires for BOTH the definite-complete and
43
+ * the break paths, after the last child. */
44
+ int (*open)(void* ctx, int is_map, uint64_t cap, const char* tag, uint32_t tag_len);
45
+ int (*close)(void* ctx, int is_map);
46
+ } yep_cbor_sink;
47
+
48
+ /* The generic engine: the grammar, driving `sink`. Same reject/
49
+ * encoding/depth semantics as the DOM entry. */
50
+ YEPTRIS_API int yep_cbor_decode_gen(const unsigned char* p, size_t len, int strict,
51
+ size_t* consumed, const yep_cbor_sink* sink);
52
+
53
+ /* The DOM sink: pairs yep_cbor_decode_gen with a yep_dom* (the
54
+ * yep_cbor_decode_dom public path's driver; d is a yep_dom*). */
55
+ YEPTRIS_API int yep_cbor_decode_dom_sink(void* d, const unsigned char* p, size_t len, int strict,
56
+ size_t* consumed);
57
+
58
+ #endif /* YEP_CBOR_SINK_H */
@@ -134,8 +134,17 @@ static void wr_indent(yep_writer* w, int depth) {
134
134
 
135
135
  static void emit_dq(yep_writer* w, const char* p, uint32_t n) {
136
136
  wr_byte(w, '"');
137
+ uint32_t run = 0;
137
138
  for (uint32_t i = 0; i < n; i++) {
138
139
  unsigned char c = (unsigned char)p[i];
140
+ if (c >= 0x20 && c != '"' && c != '\\' && c != 0x7f) {
141
+ run++;
142
+ continue;
143
+ }
144
+ if (run) {
145
+ wr_put(w, p + i - run, run);
146
+ run = 0;
147
+ }
139
148
  if (c == '"' || c == '\\') {
140
149
  wr_byte(w, '\\');
141
150
  wr_byte(w, (char)c);
@@ -161,10 +170,11 @@ static void emit_dq(yep_writer* w, const char* p, uint32_t n) {
161
170
  char hex[4] = {'\\', 'x', hd[(c >> 4) & 0xf], hd[c & 0xf]};
162
171
  wr_put(w, hex, 4);
163
172
  }
164
- } else {
165
- wr_byte(w, (char)c);
166
173
  }
167
174
  }
175
+ if (run) {
176
+ wr_put(w, p + n - run, run);
177
+ }
168
178
  wr_byte(w, '"');
169
179
  }
170
180
 
@@ -315,6 +325,10 @@ enum { YEP_SC_NOTHING = 0, YEP_SC_PLAIN, YEP_SC_SQ, YEP_SC_DQ, YEP_SC_LITERAL };
315
325
 
316
326
  static uint8_t sc_route(yep_writer* w, const char* p, uint32_t len, int as_key, uint8_t sty_in,
317
327
  int has_tag) {
328
+ if ((sty_in == 1) && len > 0 &&
329
+ (as_key ? yep_style_plain_key_safe(p, len) : yep_style_plain_safe(p, len))) {
330
+ return YEP_SC_PLAIN; /* plain-safe implies no breaks: memchr skipped */
331
+ }
318
332
  int multiline = (len > 0 && memchr(p, '\n', len) != NULL);
319
333
  int blockable = 0;
320
334
  if (multiline && !as_key) {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.15.2
4
+ version: 0.6.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-21 00:00:00.000000000 Z
11
+ date: 2026-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -50,11 +50,13 @@ files:
50
50
  - lib/yeptris/materializer.rb
51
51
  - lib/yeptris/node.rb
52
52
  - lib/yeptris/psych.rb
53
+ - lib/yeptris/psych/class_loader.rb
53
54
  - lib/yeptris/psych/coder_shim.rb
54
55
  - lib/yeptris/psych/drop_in.rb
55
56
  - lib/yeptris/psych/encodable.rb
56
57
  - lib/yeptris/psych/handler.rb
57
58
  - lib/yeptris/psych/parser.rb
59
+ - lib/yeptris/psych/scalar_scanner.rb
58
60
  - lib/yeptris/psych/visitors.rb
59
61
  - lib/yeptris/schema.rb
60
62
  - lib/yeptris/valueml.rb
@@ -89,6 +91,7 @@ files:
89
91
  - vendor/libyeptris/src/yeptris/cbor/cbor.h
90
92
  - vendor/libyeptris/src/yeptris/cbor/decode.c
91
93
  - vendor/libyeptris/src/yeptris/cbor/encode.c
94
+ - vendor/libyeptris/src/yeptris/cbor/sink.h
92
95
  - vendor/libyeptris/src/yeptris/common/chartype.c
93
96
  - vendor/libyeptris/src/yeptris/common/chartype.h
94
97
  - vendor/libyeptris/src/yeptris/common/cpu.c