yeptris 0.6.18.2-arm-linux-eabihf

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.
Files changed (142) hide show
  1. checksums.yaml +7 -0
  2. data/README.adoc +141 -0
  3. data/ext/build_windows_native.rb +41 -0
  4. data/ext/libyeptris/extconf.rb +57 -0
  5. data/ext/yeptris_native/cbor_ruby.c +193 -0
  6. data/ext/yeptris_native/extconf.rb +47 -0
  7. data/ext/yeptris_native/json_ruby.c +354 -0
  8. data/ext/yeptris_native/yeptris_native.c +497 -0
  9. data/lib/yeptris/cbor.rb +130 -0
  10. data/lib/yeptris/document.rb +255 -0
  11. data/lib/yeptris/ffi.rb +426 -0
  12. data/lib/yeptris/json/descriptor.rb +266 -0
  13. data/lib/yeptris/json.rb +394 -0
  14. data/lib/yeptris/materializer.rb +354 -0
  15. data/lib/yeptris/native-3.4.so +0 -0
  16. data/lib/yeptris/node.rb +453 -0
  17. data/lib/yeptris/psych/class_loader.rb +24 -0
  18. data/lib/yeptris/psych/coder_shim.rb +55 -0
  19. data/lib/yeptris/psych/drop_in.rb +63 -0
  20. data/lib/yeptris/psych/encodable.rb +14 -0
  21. data/lib/yeptris/psych/handler.rb +90 -0
  22. data/lib/yeptris/psych/parser.rb +105 -0
  23. data/lib/yeptris/psych/scalar_scanner.rb +149 -0
  24. data/lib/yeptris/psych/visitors.rb +545 -0
  25. data/lib/yeptris/psych.rb +622 -0
  26. data/lib/yeptris/schema.rb +253 -0
  27. data/lib/yeptris/valueml.rb +455 -0
  28. data/lib/yeptris/yaml/descriptor.rb +56 -0
  29. data/lib/yeptris/yaml.rb +422 -0
  30. data/lib/yeptris.rb +113 -0
  31. data/libyeptris.so +0 -0
  32. data/vendor/libyeptris/CMakeLists.txt +254 -0
  33. data/vendor/libyeptris/cmake/yeptris-config.cmake.in +5 -0
  34. data/vendor/libyeptris/cmake/yeptris.pc.in +11 -0
  35. data/vendor/libyeptris/src/CMakeLists.txt +167 -0
  36. data/vendor/libyeptris/src/include/yeptris/api.h +32 -0
  37. data/vendor/libyeptris/src/include/yeptris/cbor.h +101 -0
  38. data/vendor/libyeptris/src/include/yeptris/dom.h +190 -0
  39. data/vendor/libyeptris/src/include/yeptris/emit.h +81 -0
  40. data/vendor/libyeptris/src/include/yeptris/error.h +41 -0
  41. data/vendor/libyeptris/src/include/yeptris/events.h +157 -0
  42. data/vendor/libyeptris/src/include/yeptris/json.h +45 -0
  43. data/vendor/libyeptris/src/include/yeptris/json.hpp +258 -0
  44. data/vendor/libyeptris/src/include/yeptris/jsonc_compat.h +115 -0
  45. data/vendor/libyeptris/src/include/yeptris/marshal.h +52 -0
  46. data/vendor/libyeptris/src/include/yeptris/parse.h +48 -0
  47. data/vendor/libyeptris/src/include/yeptris/plan.h +100 -0
  48. data/vendor/libyeptris/src/include/yeptris/resolve.h +71 -0
  49. data/vendor/libyeptris/src/include/yeptris/schema.h +121 -0
  50. data/vendor/libyeptris/src/include/yeptris/tape.h +123 -0
  51. data/vendor/libyeptris/src/include/yeptris/types.h +38 -0
  52. data/vendor/libyeptris/src/include/yeptris/values.h +102 -0
  53. data/vendor/libyeptris/src/include/yeptris/version.h.in +29 -0
  54. data/vendor/libyeptris/src/include/yeptris/visit.h +77 -0
  55. data/vendor/libyeptris/src/include/yeptris/yajl_compat.h +135 -0
  56. data/vendor/libyeptris/src/include/yeptris.h +23 -0
  57. data/vendor/libyeptris/src/yeptris/build.c +376 -0
  58. data/vendor/libyeptris/src/yeptris/cbor/cbor.h +25 -0
  59. data/vendor/libyeptris/src/yeptris/cbor/decode.c +981 -0
  60. data/vendor/libyeptris/src/yeptris/cbor/encode.c +835 -0
  61. data/vendor/libyeptris/src/yeptris/cbor/sink.h +58 -0
  62. data/vendor/libyeptris/src/yeptris/common/chartype.c +41 -0
  63. data/vendor/libyeptris/src/yeptris/common/chartype.h +77 -0
  64. data/vendor/libyeptris/src/yeptris/common/cpu.c +81 -0
  65. data/vendor/libyeptris/src/yeptris/common/cpu.h +40 -0
  66. data/vendor/libyeptris/src/yeptris/common/error.c +65 -0
  67. data/vendor/libyeptris/src/yeptris/common/error.h +79 -0
  68. data/vendor/libyeptris/src/yeptris/common/mutex.h +45 -0
  69. data/vendor/libyeptris/src/yeptris/common/nametab.c +275 -0
  70. data/vendor/libyeptris/src/yeptris/common/nametab.h +68 -0
  71. data/vendor/libyeptris/src/yeptris/common/port.h +74 -0
  72. data/vendor/libyeptris/src/yeptris/common/simd_text.c +49 -0
  73. data/vendor/libyeptris/src/yeptris/common/simd_text.h +295 -0
  74. data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +534 -0
  75. data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +662 -0
  76. data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +298 -0
  77. data/vendor/libyeptris/src/yeptris/common/string_view.c +34 -0
  78. data/vendor/libyeptris/src/yeptris/common/string_view.h +93 -0
  79. data/vendor/libyeptris/src/yeptris/doc.h +56 -0
  80. data/vendor/libyeptris/src/yeptris/dom/dom.c +1192 -0
  81. data/vendor/libyeptris/src/yeptris/dom/dom.h +312 -0
  82. data/vendor/libyeptris/src/yeptris/dom/hpool.c +107 -0
  83. data/vendor/libyeptris/src/yeptris/dom/mapindex.c +173 -0
  84. data/vendor/libyeptris/src/yeptris/dom/mapindex.h +61 -0
  85. data/vendor/libyeptris/src/yeptris/dom/mutate.c +431 -0
  86. data/vendor/libyeptris/src/yeptris/emit/emit.c +434 -0
  87. data/vendor/libyeptris/src/yeptris/emit/float/api.h +38 -0
  88. data/vendor/libyeptris/src/yeptris/emit/float/dragon.c +405 -0
  89. data/vendor/libyeptris/src/yeptris/emit/float/floatint.h +231 -0
  90. data/vendor/libyeptris/src/yeptris/emit/float/print.c +396 -0
  91. data/vendor/libyeptris/src/yeptris/emit/style.c +81 -0
  92. data/vendor/libyeptris/src/yeptris/emit/style.h +24 -0
  93. data/vendor/libyeptris/src/yeptris/emit/writer.c +816 -0
  94. data/vendor/libyeptris/src/yeptris/emit/writer.h +76 -0
  95. data/vendor/libyeptris/src/yeptris/encoding/bom.c +31 -0
  96. data/vendor/libyeptris/src/yeptris/encoding/encoding.h +63 -0
  97. data/vendor/libyeptris/src/yeptris/encoding/transcode.c +148 -0
  98. data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +178 -0
  99. data/vendor/libyeptris/src/yeptris/events/capture.c +150 -0
  100. data/vendor/libyeptris/src/yeptris/events/capture.h +39 -0
  101. data/vendor/libyeptris/src/yeptris/events/iterparse.c +208 -0
  102. data/vendor/libyeptris/src/yeptris/events/pull.c +97 -0
  103. data/vendor/libyeptris/src/yeptris/events/push.c +104 -0
  104. data/vendor/libyeptris/src/yeptris/events/recorder.c +107 -0
  105. data/vendor/libyeptris/src/yeptris/events/values.c +527 -0
  106. data/vendor/libyeptris/src/yeptris/events/values_priv.h +51 -0
  107. data/vendor/libyeptris/src/yeptris/events/yaml_compat.c +86 -0
  108. data/vendor/libyeptris/src/yeptris/events/yaml_compat.h +90 -0
  109. data/vendor/libyeptris/src/yeptris/jsonapi/jsonc_compat.c +687 -0
  110. data/vendor/libyeptris/src/yeptris/jsonapi/yajl_compat.c +728 -0
  111. data/vendor/libyeptris/src/yeptris/marshal.c +782 -0
  112. data/vendor/libyeptris/src/yeptris/memory/allocator.c +20 -0
  113. data/vendor/libyeptris/src/yeptris/memory/allocator.h +43 -0
  114. data/vendor/libyeptris/src/yeptris/memory/arena.c +134 -0
  115. data/vendor/libyeptris/src/yeptris/memory/arena.h +52 -0
  116. data/vendor/libyeptris/src/yeptris/memory/pool.c +122 -0
  117. data/vendor/libyeptris/src/yeptris/memory/pool.h +36 -0
  118. data/vendor/libyeptris/src/yeptris/parse/engine.c +3698 -0
  119. data/vendor/libyeptris/src/yeptris/parse/engine.h +65 -0
  120. data/vendor/libyeptris/src/yeptris/parse/events.h +124 -0
  121. data/vendor/libyeptris/src/yeptris/parse/numbers.c +349 -0
  122. data/vendor/libyeptris/src/yeptris/parse/numbers.h +33 -0
  123. data/vendor/libyeptris/src/yeptris/parse/scalars.c +416 -0
  124. data/vendor/libyeptris/src/yeptris/parse/scalars.h +75 -0
  125. data/vendor/libyeptris/src/yeptris/parse.c +737 -0
  126. data/vendor/libyeptris/src/yeptris/plan.c +824 -0
  127. data/vendor/libyeptris/src/yeptris/resolve/compat11.c +334 -0
  128. data/vendor/libyeptris/src/yeptris/resolve/core12.c +143 -0
  129. data/vendor/libyeptris/src/yeptris/resolve/resolver.h +56 -0
  130. data/vendor/libyeptris/src/yeptris/resolve/tags.c +58 -0
  131. data/vendor/libyeptris/src/yeptris/scan/json.c +792 -0
  132. data/vendor/libyeptris/src/yeptris/scan/json.h +109 -0
  133. data/vendor/libyeptris/src/yeptris/scan/scan.c +463 -0
  134. data/vendor/libyeptris/src/yeptris/scan/scan.h +150 -0
  135. data/vendor/libyeptris/src/yeptris/schema.c +308 -0
  136. data/vendor/libyeptris/src/yeptris/tape.c +1308 -0
  137. data/vendor/libyeptris/src/yeptris/tape_in.h +19 -0
  138. data/vendor/libyeptris/src/yeptris/version.c +7 -0
  139. data/vendor/libyeptris/src/yeptris/visit/dom_visit.c +115 -0
  140. data/vendor/libyeptris/src/yeptris/visit/json_visit.c +293 -0
  141. data/vendor/libyeptris/src/yeptris/visit/yaml_visit.c +127 -0
  142. metadata +199 -0
@@ -0,0 +1,121 @@
1
+ /* schema.h — the fused schema-descriptor materialization API
2
+ * (issue #238, TODO.restructure/83).
3
+ *
4
+ * The descriptor is the ABI, NOT a schema language: XSD/JSON-Schema
5
+ * cannot express consumer semantics (two-names-one-slot merges, value
6
+ * maps, key renames, raw capture) — the CONSUMER compiles those into
7
+ * this flat positional plan, the same way lutaml-model compiles its
8
+ * rule plans. The engine materializes against it in ONE native pass;
9
+ * the intermediate generic document (the Hash/Array the bindings used
10
+ * to build) never exists.
11
+ *
12
+ * Design contract (from the committed consumer, co-designed):
13
+ * - kind CALLBACK is the escape hatch: the raw value span plus the
14
+ * node's byte position come back as records; the host finishes
15
+ * just those fields (custom procs, polymorphism, delegates).
16
+ * - Results are WHOLE DOCUMENTS: this call never crosses the FFI
17
+ * boundary per value — the caller passes output buffers sized by
18
+ * expectation and receives per-node counts.
19
+ * - The descriptor ABI is versioned in lockstep with the bindings
20
+ * ({c-semver}.{binding-patch}); desc_abi changes only with a C
21
+ * minor bump.
22
+ * - Sequences of a plan run the SAME node plan for every element
23
+ * (flags ELEMENT); nested mappings run their child plan slice.
24
+ */
25
+ #ifndef YEPTRIS_SCHEMA_H
26
+ #define YEPTRIS_SCHEMA_H
27
+
28
+ #include <stddef.h>
29
+ #include <stdint.h>
30
+
31
+ #include <yeptris/api.h>
32
+ #include <yeptris/error.h>
33
+ #include <yeptris/parse.h>
34
+
35
+ #ifdef __cplusplus
36
+ extern "C" {
37
+ #endif
38
+
39
+ /* The descriptor ABI version of this header. */
40
+ #define YEPTRIS_DESC_ABI 1u
41
+
42
+ /* node kinds */
43
+ enum {
44
+ YEP_SK_SCALAR = 0, /* typed leaf: type_tag decides the column */
45
+ YEP_SK_SEQUENCE, /* sequence: children[0] is the ELEMENT plan */
46
+ YEP_SK_MAPPING, /* mapping: children are the key plans */
47
+ YEP_SK_CALLBACK, /* escape hatch: raw span + position records */
48
+ };
49
+
50
+ /* scalar type tags (the columns' element types) */
51
+ enum {
52
+ YEP_ST_STR = 0, /* off/len into the input */
53
+ YEP_ST_INT, /* int64_t */
54
+ YEP_ST_FLOAT, /* double */
55
+ YEP_ST_BOOL, /* uint8_t */
56
+ YEP_ST_NULL, /* no payload (count only) */
57
+ YEP_ST_ANY, /* SCALAR: keep the resolver's verdict — the
58
+ column is a YeptrisValue-like record */
59
+ };
60
+
61
+ /* node flags */
62
+ enum {
63
+ YEP_SF_REQUIRED = 1u << 0, /* missing at its mapping -> error */
64
+ YEP_SF_FIRST_WINS = 1u << 1, /* duplicates: first match kept
65
+ (default: last, as at parse) */
66
+ };
67
+
68
+ /* One plan node. ABI-pinned: a pointer plus 16 fixed-width bytes —
69
+ * 24 on LP64, 20 on 32-bit (the hosts' FFI mirrors size :pointer
70
+ * per-process, so the layout contract is the POINTER plus the tail). */
71
+ typedef struct yeptris_desc_node {
72
+ const char* wire_name; /* mapping key to match (NULL: the root) */
73
+ uint8_t kind; /* YEP_SK_* */
74
+ uint8_t type_tag; /* YEP_ST_* (SCALAR) */
75
+ uint16_t flags; /* YEP_SF_* */
76
+ uint32_t child_index; /* SEQUENCE: the element plan; MAPPING: the
77
+ first child. Unused otherwise (0). */
78
+ uint32_t child_count; /* MAPPING: children from child_index. */
79
+ uint32_t reserved; /* must be 0 (ABI headroom) */
80
+ } yeptris_desc_node;
81
+
82
+ YEPTRIS_CT_ASSERT(sizeof(yeptris_desc_node) == sizeof(const char*) + 16);
83
+
84
+ /* One column's output. Caller allocates the payload array (sized by
85
+ * expectation); the call fills it and sets count. No per-value FFI:
86
+ * hosts drain whole columns after the call. */
87
+ typedef struct yeptris_schema_column {
88
+ void* data; /* element type from the plan's type_tag */
89
+ uint32_t capacity; /* elements the buffer holds */
90
+ uint32_t count; /* elements materialized (out) */
91
+ } yeptris_schema_column;
92
+
93
+ /* STR/CALLBACK payload: off/len into the INPUT buffer (zero-copy to
94
+ * the host). CALLBACK also carries the node's byte position. */
95
+ typedef struct yeptris_span2 {
96
+ uint32_t off;
97
+ uint32_t len;
98
+ uint32_t node_off; /* the node's first byte (callbacks) */
99
+ uint32_t pad;
100
+ } yeptris_span2;
101
+
102
+ YEPTRIS_CT_ASSERT(sizeof(yeptris_span2) == 16);
103
+
104
+ /* Parses `source` (YAML or strict JSON — the same front door as
105
+ * yeptris_parse_ex) and materializes against the descriptor in one
106
+ * pass: node i's matches land in cols[i]. The input buffer must
107
+ * outlive the string/callback spans (they borrow it).
108
+ *
109
+ * Status: YEPTRIS_OK; YEPTRIS_ERROR_PARSE (yeptris_last_error);
110
+ * YEPTRIS_ERROR_SCHEMA (a REQUIRED node missing — the error carries
111
+ * the node index; detail via yeptris_last_error); YEPTRIS_ERROR_MEMORY
112
+ * / ARG (NULL descriptor, desc_len 0, desc_abi mismatch). */
113
+ YEPTRIS_API YeptrisStatus yeptris_schema_load(const char* source, size_t len, YeptrisSchema schema,
114
+ const yeptris_desc_node* desc, uint32_t desc_len,
115
+ uint32_t desc_abi, yeptris_schema_column* cols);
116
+
117
+ #ifdef __cplusplus
118
+ }
119
+ #endif
120
+
121
+ #endif /* YEPTRIS_SCHEMA_H */
@@ -0,0 +1,123 @@
1
+ /* tape.h — the compact JSON tape (issue #238's consumer shape,
2
+ * TODO.restructure/85: the simdjson-class materialization).
3
+ *
4
+ * One fused strict walk appends ONE record per token — no DOM nodes,
5
+ * no links, no views. Records are THREE parallel columns (kind byte,
6
+ * off, len) carved from one block: bools encode in the kind, container
7
+ * links ride the off column, and NUMBERS RECORD SPANS ONLY — parse
8
+ * validates the grammar (the lean shape scan) and materialize converts
9
+ * (yeptris_tape_convert; the C-API materializer converts inline).
10
+ * Strings stay zero-copy spans into the caller's buffer.
11
+ *
12
+ * The tape is a document-level result (never per value across FFI);
13
+ * the buffer the spans borrow must outlive it.
14
+ */
15
+ #ifndef YEPTRIS_TAPE_H
16
+ #define YEPTRIS_TAPE_H
17
+
18
+ #include <stddef.h>
19
+ #include <stdint.h>
20
+
21
+ #include <yeptris/api.h>
22
+ #include <yeptris/error.h>
23
+
24
+ #ifdef __cplusplus
25
+ extern "C" {
26
+ #endif
27
+
28
+ /* Record kinds (the kinds column). */
29
+ enum {
30
+ YEP_T_DOC = 0, /* document boundary (records start after it) */
31
+ YEP_T_NULL,
32
+ YEP_T_TRUE, /* the kind IS the value */
33
+ YEP_T_FALSE, /* the kind IS the value */
34
+ YEP_T_INT, /* off/len: signed digit span; convert at materialize */
35
+ YEP_T_FLOAT, /* off/len: float text span; convert at materialize */
36
+ YEP_T_STR, /* off/len: raw span (escapes untouched; the
37
+ qbc kernel found them) */
38
+ YEP_T_SEQ_OPEN, /* off: index of the matching CLOSE */
39
+ YEP_T_MAP_OPEN, /* off: index of the matching CLOSE; keys are
40
+ the STR records at even positions inside */
41
+ YEP_T_CLOSE, /* off: index of the matching OPEN */
42
+ YEP_T_NUM, /* lenient route only: off/len number span with
43
+ the grammar UNVALIDATED at parse —
44
+ yeptris_tape_convert is the authority (it
45
+ classifies int/float and rejects malformed
46
+ spans; simdjson's deferred contract) */
47
+ };
48
+
49
+ /* The interleaved record (TODO.max-perf/07): one 8-byte store per
50
+ * token instead of three column stores. Layout: off:u32 | len:u23 |
51
+ * kind:u8 — a span longer than 0xFEFFFF bytes carries len == 0xFFFFFF
52
+ * with the true length stored as a CONT-terminated extension record
53
+ * (kind YEP_T_CONT; unreachable for <16 MiB tokens). The columns
54
+ * stay the compatibility ABI: yeptris_tape_columns materializes them
55
+ * lazily from the records on first touch. */
56
+ #define YEP_T_CONT 8 /* record-length extension (not a token kind) */
57
+ typedef uint64_t yeptris_tape_rec;
58
+
59
+ typedef struct yeptris_json_tape {
60
+ size_t count;
61
+ uint8_t* kinds; /* compat columns — materialized lazily (see
62
+ yeptris_tape_columns) when the interleaved
63
+ records are the primary storage */
64
+ uint32_t* offs; /* span starts (STR/INT/FLOAT); container links */
65
+ uint32_t* lens; /* span lengths (STR/INT/FLOAT) */
66
+ yeptris_tape_rec* recs; /* primary storage (may be NULL on legacy
67
+ column-built tapes: the strict route) */
68
+ int _cols_ready; /* columns materialized from recs already */
69
+ int _rec_primary; /* the lenient route: recs carry the data and
70
+ the columns are lazy */
71
+ int64_t int_min; /* set by yeptris_tape_convert when an INT span
72
+ exceeds int64 (materialize-time discovery) */
73
+ const void* _src; /* the parsed buffer (spans borrow it; it must
74
+ outlive the tape — same contract as the spans) */
75
+ size_t _srclen;
76
+ void* _block; /* the carved allocation base */
77
+ } yeptris_json_tape;
78
+
79
+ /* Parses strict JSON into the tape. Accepts scalar roots (a single
80
+ * record). Returns YEPTRIS_OK, YEPTRIS_ERROR_PARSE (details via
81
+ * yeptris_last_error), YEPTRIS_ERROR_MEMORY, YEPTRIS_ERROR_ARG. */
82
+ YEPTRIS_API YeptrisStatus yeptris_parse_json_tape(const char* source, size_t len,
83
+ yeptris_json_tape* tape);
84
+
85
+ /* The lenient route (simdjson's deferred contract, opt-in): every
86
+ * STRUCTURAL check stays at parse (bracket matching, alternation,
87
+ * comma/colon placement, literals, string closes/escapes) while
88
+ * NUMBER grammar defers to yeptris_tape_convert — a number records
89
+ * as a YEP_T_NUM charset run (so "1.2.3" is accepted here and
90
+ * rejected at convert, exactly where simdjson's number parse would
91
+ * fail; a run with non-number bytes like "12ab" still rejects
92
+ * structurally at parse). Accepts a superset of the strict route's
93
+ * inputs (tab whitespace becomes legal, RFC 8259); on everything
94
+ * the strict route accepts, the tapes are structurally identical
95
+ * (spans and containers equal; NUM records carry the same bytes the
96
+ * strict INT/FLOAT records carry). Non-ASCII inputs take the strict
97
+ * route unchanged. */
98
+ YEPTRIS_API YeptrisStatus yeptris_parse_json_tape_lenient(const char* source, size_t len,
99
+ yeptris_json_tape* tape);
100
+
101
+ YEPTRIS_API void yeptris_tape_free(yeptris_json_tape* tape);
102
+
103
+ /* Converts the INT/FLOAT records in [from, to): ivals/dvals are
104
+ * parallel to the RECORD indices (slots for other kinds are left
105
+ * untouched; either pointer may be NULL). Returns the number of
106
+ * number records converted, or SIZE_MAX if a span does not re-scan
107
+ * as a number (impossible for a tape this library produced).
108
+ * Sets t->int_min when an INT span exceeds int64. */
109
+ /* Materializes the kinds/offs/lens columns from the interleaved
110
+ * records (no-op when the tape was built column-primary or the
111
+ * columns are already materialized). Consumers reading the column
112
+ * pointers directly (the FFI binding) must call this once first.
113
+ * Returns 0 on success, nonzero on allocation failure. */
114
+ YEPTRIS_API int yeptris_tape_columns(yeptris_json_tape* t);
115
+
116
+ YEPTRIS_API size_t yeptris_tape_convert(yeptris_json_tape* t, size_t from, size_t to,
117
+ int64_t* ivals, double* dvals);
118
+
119
+ #ifdef __cplusplus
120
+ }
121
+ #endif
122
+
123
+ #endif /* YEPTRIS_TAPE_H */
@@ -0,0 +1,38 @@
1
+ /* types.h — opaque public handles.
2
+ *
3
+ * The single canonical source of public types (TODO.impl/02 extends this
4
+ * file; internal types never appear here). Callers never see struct
5
+ * definitions: every handle is opaque and pointer-sized, asserted by the
6
+ * ABI pinning test (test/unit/test_abi.cpp).
7
+ */
8
+ #ifndef YEPTRIS_TYPES_H
9
+ #define YEPTRIS_TYPES_H
10
+
11
+ #include <stddef.h>
12
+
13
+ #ifdef __cplusplus
14
+ extern "C" {
15
+ #endif
16
+
17
+ /* A parsed document; the sole owner of all memory reachable from it.
18
+ * Memory: freed exactly once with yeptris_document_free (TODO.impl/11). */
19
+ typedef struct yeptris_document* YeptrisDocument;
20
+
21
+ /* A node (document, mapping, sequence, scalar, alias) inside a document.
22
+ * Memory: borrowed from its document — valid until the document is freed. */
23
+ typedef struct yeptris_node* YeptrisNode;
24
+
25
+ /* Streaming/streaming-adjacent handles, introduced with their items:
26
+ * parser engine (TODO.impl/07), pull/recorder/iterparse (TODO.impl/12),
27
+ * emitter (TODO.impl/13). Declared now so the handle vocabulary is stable. */
28
+ typedef struct yeptris_parser* YeptrisParser;
29
+ typedef struct yeptris_pull* YeptrisPullParser;
30
+ typedef struct yeptris_recorder* YeptrisRecorder;
31
+ typedef struct yeptris_iterparse* YeptrisIterparse;
32
+ typedef struct yeptris_emitter* YeptrisEmitter;
33
+
34
+ #ifdef __cplusplus
35
+ }
36
+ #endif
37
+
38
+ #endif /* YEPTRIS_TYPES_H */
@@ -0,0 +1,102 @@
1
+ /* values.h — the typed value stream (TODO.impl/15 phase F).
2
+ *
3
+ * The materialization fast path for FFI bindings: one parse, one
4
+ * drain of PRE-CONVERTED typed values. The C side runs the same
5
+ * engine the recorder drives, then converts every scalar by its
6
+ * resolver tag — the host walks a flat array and builds containers,
7
+ * never re-parsing text.
8
+ *
9
+ * The `is_key` bit carries the key/value alternation, so hosts need
10
+ * no pending-key bookkeeping; `tag_id` rides along so hosts with
11
+ * schema quirks (Psych's single-char y/n, PyYAML's dot-required
12
+ * floats) can re-decide a scalar's type from its raw bytes without
13
+ * re-running a conversion grammar.
14
+ */
15
+ #ifndef YEPTRIS_VALUES_H
16
+ #define YEPTRIS_VALUES_H
17
+
18
+ #include <stddef.h>
19
+ #include <stdint.h>
20
+
21
+ #include <yeptris/api.h>
22
+ #include <yeptris/error.h>
23
+ #include <yeptris/resolve.h>
24
+
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ typedef enum {
30
+ YEP_V_DOC = 0, /* document boundary */
31
+ YEP_V_NULL,
32
+ YEP_V_BOOL, /* b carries 0/1 */
33
+ YEP_V_INT, /* i */
34
+ YEP_V_FLOAT, /* d */
35
+ YEP_V_STR, /* off/len bytes */
36
+ YEP_V_TIMESTAMP, /* off/len bytes (host constructs the date) */
37
+ YEP_V_SEQ_OPEN,
38
+ YEP_V_MAP_OPEN,
39
+ YEP_V_CLOSE, /* closes the innermost open container */
40
+ YEP_V_ALIAS, /* off/len: the alias name */
41
+ /* decorates the entry that FOLLOWS it: the anchor name binds to
42
+ * that value (identity for aliases). Emitted only when anchored. */
43
+ YEP_V_ANCHOR, /* off/len: the name */
44
+ } YeptrisValueKind;
45
+
46
+ /* 24 bytes, ABI-pinned. Every scalar carries its raw bytes (off/len)
47
+ * next to a typed payload; `p` holds the INT bits or the FLOAT bits
48
+ * (reinterpreted by kind — hosts unpack it as ONE 64-bit field, so
49
+ * the record costs 7 values, not 8). */
50
+ typedef struct {
51
+ uint8_t kind; /* YeptrisValueKind */
52
+ uint8_t tag_id; /* the resolver's verdict for this scalar */
53
+ uint8_t is_key; /* the entry lands in the inner map's key slot */
54
+ uint8_t b; /* BOOL payload; implicit-plain flag otherwise */
55
+ uint32_t off; /* STR/TIMESTAMP/ALIAS/anchor bytes */
56
+ uint32_t len;
57
+ uint64_t p; /* INT or FLOAT payload, by kind */
58
+ } YeptrisValue;
59
+ YEPTRIS_CT_ASSERT(sizeof(YeptrisValue) == 24);
60
+
61
+ /* Parses `yaml` and drains the typed value stream. On success sets
62
+ * *vals / *count / *arena / *arena_len (both malloc'd; free with
63
+ * yeptris_value_free exactly once). Returns YEPTRIS_OK,
64
+ * YEPTRIS_ERROR_PARSE (details via yeptris_last_error), or
65
+ * YEPTRIS_ERROR_MEMORY / YEPTRIS_ERROR_ARG. */
66
+ YEPTRIS_API YeptrisStatus yeptris_value_drain(const char* yaml, size_t len, YeptrisSchema schema,
67
+ YeptrisValue** vals, size_t* count, char** arena,
68
+ size_t* arena_len);
69
+
70
+ YEPTRIS_API void yeptris_value_free(YeptrisValue* vals, char* arena);
71
+
72
+ /* Columnar projection of the same stream (task #42: the materializer
73
+ * wall is per-record struct decoding in FFI hosts — parallel typed
74
+ * buffers let bindings iterate C-speed arrays and unpack whole
75
+ * columns in one call). Same walk, same semantics, same arena; one
76
+ * carved allocation holds payloads/offs/lens/kinds/tags/is_keys/bools
77
+ * (payloads is the block base — yeptris_value_free_columns frees it
78
+ * and the arena; both are safe on a zero-entry drain). */
79
+ typedef struct {
80
+ size_t count;
81
+ size_t arena_len;
82
+ int64_t* payloads; /* INT or FLOAT bits, by kind */
83
+ uint32_t* offs; /* STR/TIMESTAMP/ALIAS/ANCHOR bytes */
84
+ uint32_t* lens;
85
+ uint8_t* kinds; /* YeptrisValueKind */
86
+ uint8_t* tags; /* resolver verdict per scalar */
87
+ uint8_t* is_keys;
88
+ uint8_t* bools; /* BOOL payload; implicit-plain flag otherwise */
89
+ char* arena;
90
+ } YeptrisValueColumns;
91
+
92
+ YEPTRIS_API YeptrisStatus yeptris_value_drain_columns(const char* yaml, size_t len,
93
+ YeptrisSchema schema,
94
+ YeptrisValueColumns* cols);
95
+
96
+ YEPTRIS_API void yeptris_value_free_columns(YeptrisValueColumns* cols);
97
+
98
+ #ifdef __cplusplus
99
+ }
100
+ #endif
101
+
102
+ #endif /* YEPTRIS_VALUES_H */
@@ -0,0 +1,29 @@
1
+ /* version.h — generated from the CMake project VERSION.
2
+ *
3
+ * CMakeLists.txt project(yeptris VERSION ...) is the single source of truth;
4
+ * scripts/bump-version.sh syncs vcpkg.json and CHANGELOG.md from it. Never
5
+ * hand-edit the generated file (it lives in the build tree).
6
+ */
7
+ #ifndef YEPTRIS_VERSION_H
8
+ #define YEPTRIS_VERSION_H
9
+
10
+ #include <yeptris/api.h>
11
+
12
+ #define YEPTRIS_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
13
+ #define YEPTRIS_VERSION_MINOR @PROJECT_VERSION_MINOR@
14
+ #define YEPTRIS_VERSION_PATCH @PROJECT_VERSION_PATCH@
15
+ #define YEPTRIS_VERSION_STRING "@PROJECT_VERSION@"
16
+
17
+ #ifdef __cplusplus
18
+ extern "C" {
19
+ #endif
20
+
21
+ /* Returns the library version string ("major.minor.patch").
22
+ * Memory: static storage; valid for the lifetime of the process. */
23
+ YEPTRIS_API const char* yeptris_version(void);
24
+
25
+ #ifdef __cplusplus
26
+ }
27
+ #endif
28
+
29
+ #endif /* YEPTRIS_VERSION_H */
@@ -0,0 +1,77 @@
1
+ /* visit.h — language-agnostic value visitor (TODO.restructure/22/24).
2
+ *
3
+ * A push-style sink over the parsed value stream. Hosts that build
4
+ * native objects (Ruby C-API, CPython, etc.) implement the vtable and
5
+ * receive one callback per scalar/container — no intermediate records,
6
+ * no DOM, no host-side walk. The JSON entry is a fused RFC 8259 scan
7
+ * that never allocates a tree; the YAML entry rides the engine; the
8
+ * node entry walks an existing DOM subtree.
9
+ *
10
+ * OCP: a new host is a new vtable, never a core edit. MECE: scanning
11
+ * stays in scan/; this header is only the sink contract. */
12
+ #ifndef YEPTRIS_VISIT_H
13
+ #define YEPTRIS_VISIT_H
14
+
15
+ #include <stddef.h>
16
+ #include <stdint.h>
17
+
18
+ #include <yeptris/api.h>
19
+ #include <yeptris/dom.h>
20
+ #include <yeptris/error.h>
21
+ #include <yeptris/resolve.h>
22
+
23
+ #ifdef __cplusplus
24
+ extern "C" {
25
+ #endif
26
+
27
+ /* Return 0 to continue, nonzero to abort (propagated as the status
28
+ * detail when non-zero; YEPTRIS_ERROR_INTERNAL is the library-side
29
+ * stand-in when the visitor doesn't set a more specific code). */
30
+ typedef struct YeptrisVisitVTable {
31
+ int (*on_null)(void* ctx);
32
+ int (*on_bool)(void* ctx, int truthy);
33
+ int (*on_int)(void* ctx, int64_t v);
34
+ int (*on_float)(void* ctx, double v);
35
+ /* bytes are borrowed from the input (or a short-lived decode
36
+ * scratch for escaped JSON strings — valid only for the duration
37
+ * of the callback). */
38
+ int (*on_string)(void* ctx, const char* p, size_t len);
39
+ int (*on_seq_start)(void* ctx);
40
+ int (*on_seq_end)(void* ctx);
41
+ int (*on_map_start)(void* ctx);
42
+ /* A map key is always a string callback immediately followed by
43
+ * the value; hosts that need the key/value pairing push the key
44
+ * on on_string when is_key is set. */
45
+ int (*on_map_end)(void* ctx);
46
+ /* Optional: 1 when the next scalar/container is a map key. NULL
47
+ * means the visitor does not distinguish (JSON keys are always
48
+ * strings fired via on_string before their value). */
49
+ int (*on_key)(void* ctx, const char* p, size_t len);
50
+ /* Optional document boundary (YAML multi-doc). NULL = ignore. */
51
+ int (*on_doc)(void* ctx);
52
+ /* Optional anchor/alias. NULL = materializer does not support
53
+ * identity (JSON never fires these). */
54
+ int (*on_anchor)(void* ctx, const char* name, size_t len);
55
+ int (*on_alias)(void* ctx, const char* name, size_t len);
56
+ } YeptrisVisitVTable;
57
+
58
+ /* Fused strict-JSON scan → visit. No DOM, no records. On success the
59
+ * visitor saw exactly one value (plus optional ws). */
60
+ YEPTRIS_API YeptrisStatus yeptris_visit_json(const char* data, size_t len,
61
+ const YeptrisVisitVTable* vt, void* ctx);
62
+
63
+ /* YAML parse → visit through the engine (schema selects the resolver).
64
+ * Multi-doc streams fire on_doc before each document's root value. */
65
+ YEPTRIS_API YeptrisStatus yeptris_visit(const char* data, size_t len, YeptrisSchema schema,
66
+ const YeptrisVisitVTable* vt, void* ctx);
67
+
68
+ /* Existing DOM subtree → visit (Node#to_ruby bulk path without
69
+ * records/Marshal). */
70
+ YEPTRIS_API YeptrisStatus yeptris_visit_node(YeptrisNode node, const YeptrisVisitVTable* vt,
71
+ void* ctx);
72
+
73
+ #ifdef __cplusplus
74
+ }
75
+ #endif
76
+
77
+ #endif /* YEPTRIS_VISIT_H */
@@ -0,0 +1,135 @@
1
+ /* yajl_compat.h — the yajl generator migration layer (TODO.impl/21).
2
+ *
3
+ * REAL yajl_gen symbol names over the yeptris core: users link
4
+ * -lyeptris-yajl instead of -lyajl and change nothing else. The
5
+ * generator validates call order (yajl's own state machine) and
6
+ * builds a Yeptris document; get_buf serializes JSON (beautify
7
+ * selects the pretty writer, default compact).
8
+ *
9
+ * v2 scope: the generator (yajl_gen_*) and the SAX parser
10
+ * (yajl_alloc/yajl_parse/...). The parser accumulates yajl_parse
11
+ * feeds and delivers all callbacks at yajl_complete_parse (the core
12
+ * parses whole documents; timing is batched, order and content are
13
+ * yajl's). Strict RFC 8259 always; yajl_allow_comments masks
14
+ * JavaScript comments (block star-slash, line double-slash) outside
15
+ * strings before the strict parse — offsets preserved, yajl's exact
16
+ * semantics. Unsupported options (trailing garbage / multiple
17
+ * values / partial values) are rejected at yajl_config time: zero,
18
+ * per yajl's own error contract.
19
+ */
20
+ #ifndef YEPTRIS_YAJL_COMPAT_H
21
+ #define YEPTRIS_YAJL_COMPAT_H
22
+
23
+ #include <stddef.h>
24
+
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ typedef enum {
30
+ yajl_gen_status_ok = 0,
31
+ yajl_gen_keys_must_be_strings, /* 1 */
32
+ yajl_max_depth_exceeded, /* unused: depth-guarded builder */
33
+ yajl_gen_in_error_state = 3,
34
+ yajl_gen_generation_complete, /* 4: gen after get_buf without clear */
35
+ yajl_gen_invalid_string = 5 /* NULL bytes with len 0 handled; reserved */
36
+ } yajl_gen_status;
37
+
38
+ typedef enum {
39
+ yajl_gen_beautify = 1, /* int: pretty output */
40
+ yajl_gen_indent_string = 2, /* const char*: reserved (fixed 2-space) */
41
+ yajl_gen_validate_utf8 = 3 /* int: always on (the front-end validates) */
42
+ } yajl_gen_option;
43
+
44
+ typedef struct yajl_gen_t* yajl_gen;
45
+ typedef struct yajl_alloc_funcs_t yajl_alloc_funcs;
46
+
47
+ /* NULL alloc (the yajl default) uses the system allocator. */
48
+ yajl_gen yajl_gen_alloc(const yajl_alloc_funcs* afs);
49
+ void yajl_gen_free(yajl_gen g);
50
+ void yajl_gen_reset(yajl_gen g, const char* sep_ignored);
51
+
52
+ /* var-args: (yajl_gen_beautify, int). Returns 1 on success. */
53
+ int yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...);
54
+
55
+ yajl_gen_status yajl_gen_map_open(yajl_gen g);
56
+ yajl_gen_status yajl_gen_map_close(yajl_gen g);
57
+ yajl_gen_status yajl_gen_array_open(yajl_gen g);
58
+ yajl_gen_status yajl_gen_array_close(yajl_gen g);
59
+
60
+ /* In a map, the first call per entry is the KEY: it must be a
61
+ * string (yajl accepts raw bytes; keys serialize JSON-quoted). */
62
+ yajl_gen_status yajl_gen_string(yajl_gen g, const unsigned char* str, size_t len);
63
+ yajl_gen_status yajl_gen_integer(yajl_gen g, long long n);
64
+ yajl_gen_status yajl_gen_double(yajl_gen g, double d);
65
+ yajl_gen_status yajl_gen_number(yajl_gen g, const char* s, size_t len);
66
+ yajl_gen_status yajl_gen_null(yajl_gen g);
67
+ yajl_gen_status yajl_gen_bool(yajl_gen g, int b);
68
+
69
+ /* The serialized document (owned by the generator; valid until the
70
+ * next generating call or reset). Empty until the ROOT closes. */
71
+ const unsigned char* yajl_gen_get_buf(yajl_gen g, size_t* len);
72
+ void yajl_gen_clear(yajl_gen g);
73
+
74
+ /* ---- SAX parser ------------------------------------------------------- */
75
+
76
+ typedef enum { yajl_status_ok = 0, yajl_status_client_canceled, yajl_status_error } yajl_status;
77
+
78
+ const char* yajl_status_to_string(yajl_status code);
79
+
80
+ /* Zero return from a callback cancels the parse
81
+ * (yajl_status_client_canceled). When yajl_number is set it carries
82
+ * EVERY number in string form; yajl_integer/yajl_double are then
83
+ * ignored (yajl's own precedence). */
84
+ typedef struct {
85
+ int (*yajl_null)(void* ctx);
86
+ int (*yajl_boolean)(void* ctx, int boolVal);
87
+ int (*yajl_integer)(void* ctx, long long integerVal);
88
+ int (*yajl_double)(void* ctx, double doubleVal);
89
+ int (*yajl_number)(void* ctx, const char* numberVal, size_t numberLen);
90
+ int (*yajl_string)(void* ctx, const unsigned char* stringVal, size_t stringLen);
91
+ int (*yajl_start_map)(void* ctx);
92
+ int (*yajl_map_key)(void* ctx, const unsigned char* key, size_t stringLen);
93
+ int (*yajl_end_map)(void* ctx);
94
+ int (*yajl_start_array)(void* ctx);
95
+ int (*yajl_end_array)(void* ctx);
96
+ } yajl_callbacks;
97
+
98
+ typedef enum {
99
+ yajl_allow_comments = 0x01, /* JS comments masked, offsets kept */
100
+ yajl_dont_validate_strings = 0x02, /* accepted no-op: always on */
101
+ yajl_allow_trailing_garbage = 0x04,
102
+ yajl_allow_multiple_values = 0x08,
103
+ yajl_allow_partial_values = 0x10
104
+ } yajl_option;
105
+
106
+ typedef struct yajl_handle_t* yajl_handle;
107
+
108
+ /* callbacks may be NULL (pure validation). afs accepted, ignored. */
109
+ yajl_handle yajl_alloc(const yajl_callbacks* callbacks, yajl_alloc_funcs* afs, void* ctx);
110
+ void yajl_free(yajl_handle handle);
111
+
112
+ /* var-args int option: 1 on, 0 off. Returns 0 on unknown/unsupported
113
+ * options (trailing garbage / multiple values / partial values). */
114
+ int yajl_config(yajl_handle h, yajl_option opt, ...);
115
+
116
+ /* Accumulates feeds; callbacks fire at complete_parse. After an
117
+ * error or cancel the handle stays in that state. */
118
+ yajl_status yajl_parse(yajl_handle hand, const unsigned char* jsonText, size_t jsonTextLength);
119
+ yajl_status yajl_complete_parse(yajl_handle hand);
120
+
121
+ /* Malloc'd message (free with yajl_free_error); NULL when no error.
122
+ * verbose adds the offending line and a caret. */
123
+ unsigned char* yajl_get_error(yajl_handle hand, int verbose, const unsigned char* jsonText,
124
+ size_t jsonTextLength);
125
+ void yajl_free_error(yajl_handle hand, unsigned char* str);
126
+
127
+ /* Bytes consumed: the whole input once complete; on error, the
128
+ * offset of the violation. */
129
+ size_t yajl_get_bytes_consumed(yajl_handle hand);
130
+
131
+ #ifdef __cplusplus
132
+ }
133
+ #endif
134
+
135
+ #endif /* YEPTRIS_YAJL_COMPAT_H */
@@ -0,0 +1,23 @@
1
+ /* yeptris.h — umbrella header for libyeptris.
2
+ *
3
+ * Ultra-fast YAML 1.2 parser, emitter and streamer in C; the YAML
4
+ * counterpart of libleptris. Subsystem headers grow with their items
5
+ * (TODO.impl/01-20); this file only includes the public surface.
6
+ */
7
+ #ifndef YEPTRIS_H
8
+ #define YEPTRIS_H
9
+
10
+ #include <yeptris/api.h>
11
+ #include <yeptris/dom.h>
12
+ #include <yeptris/emit.h>
13
+ #include <yeptris/error.h>
14
+ #ifdef YEPTRIS_WITH_CBOR
15
+ #include <yeptris/cbor.h>
16
+ #endif
17
+ #include <yeptris/events.h>
18
+ #include <yeptris/parse.h>
19
+ #include <yeptris/resolve.h>
20
+ #include <yeptris/types.h>
21
+ #include <yeptris/version.h>
22
+
23
+ #endif /* YEPTRIS_H */