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,258 @@
1
+ // json.hpp — the nlohmann-flavored C++17 wrapper (TODO.impl/21).
2
+ //
3
+ // Value semantics over the C ABI: yeptris::json owns its document
4
+ // (RAII), children are views into it. JSON in, JSON out — strict
5
+ // parsing via yeptris_parse_json, output via the JSON writer.
6
+ // Errors throw (nlohmann discipline); no exceptions in the C core.
7
+ //
8
+ // Deliberately a view, not a copy: j["k"] returns a child that stays
9
+ // valid while the parent json lives (the nlohmann ergonomics without
10
+ // the deep-template machinery).
11
+
12
+ #ifndef YEPTRIS_JSON_HPP
13
+ #define YEPTRIS_JSON_HPP
14
+
15
+ #include <cstdint>
16
+ #include <stdexcept>
17
+ #include <string>
18
+ #include <string_view>
19
+ #include <type_traits>
20
+
21
+ #include <yeptris/dom.h>
22
+ #include <yeptris/json.h>
23
+
24
+ namespace yeptris {
25
+
26
+ class parse_error : public std::runtime_error {
27
+ public:
28
+ explicit parse_error(const char* msg) : std::runtime_error(msg) {}
29
+ };
30
+
31
+ class type_error : public std::logic_error {
32
+ public:
33
+ explicit type_error(const char* msg) : std::logic_error(msg) {}
34
+ };
35
+
36
+ class json {
37
+ public:
38
+ json() = default;
39
+
40
+ json(const json&) = delete;
41
+ json& operator=(const json&) = delete;
42
+
43
+ json(json&& other) noexcept : doc_(other.doc_), node_(other.node_), owns_(other.owns_) {
44
+ other.doc_ = nullptr;
45
+ other.node_ = nullptr;
46
+ other.owns_ = false;
47
+ }
48
+
49
+ json& operator=(json&& other) noexcept {
50
+ if (this != &other) {
51
+ destroy();
52
+ doc_ = other.doc_;
53
+ node_ = other.node_;
54
+ owns_ = other.owns_;
55
+ other.doc_ = nullptr;
56
+ other.node_ = nullptr;
57
+ other.owns_ = false;
58
+ }
59
+ return *this;
60
+ }
61
+
62
+ ~json() {
63
+ destroy();
64
+ }
65
+
66
+ static json parse(std::string_view text) {
67
+ YeptrisStatus st = YEPTRIS_OK;
68
+ YeptrisDocument d = yeptris_parse_json(text.data(), text.size(), &st);
69
+ if (d == nullptr) {
70
+ uint32_t line = 0, col = 0;
71
+ const char* msg = yeptris_last_error(&line, &col);
72
+ throw parse_error(msg ? msg : "not valid JSON");
73
+ }
74
+ json j;
75
+ j.doc_ = d;
76
+ j.node_ = yeptris_document_root(d, 0);
77
+ j.owns_ = true;
78
+ return j;
79
+ }
80
+
81
+ std::string dump() const {
82
+ check_root();
83
+ size_t len = 0;
84
+ char* out = yeptris_serialize_json(doc_, &len);
85
+ if (out == nullptr) {
86
+ throw std::runtime_error("serialization failed");
87
+ }
88
+ std::string s(out, len);
89
+ free(out);
90
+ return s;
91
+ }
92
+
93
+ // ---- type queries (nlohmann names) ----
94
+ bool is_object() const {
95
+ return kind() == YEPTRIS_NODE_MAPPING;
96
+ }
97
+ bool is_array() const {
98
+ return kind() == YEPTRIS_NODE_SEQUENCE;
99
+ }
100
+ bool is_string() const {
101
+ return kind() == YEPTRIS_NODE_SCALAR && !is_number() && !is_boolean() && !is_null();
102
+ }
103
+ bool is_number() const {
104
+ return is_number_integer() || is_number_float();
105
+ }
106
+ bool is_number_integer() const {
107
+ return typed_ok<int64_t>();
108
+ }
109
+ bool is_number_float() const {
110
+ return typed_ok<double>();
111
+ }
112
+ bool is_boolean() const {
113
+ return typed_ok<bool>();
114
+ }
115
+ bool is_null() const;
116
+
117
+ // ---- object access ----
118
+ json operator[](std::string_view key) const {
119
+ require(YEPTRIS_NODE_MAPPING, "object");
120
+ YeptrisNode n = yeptris_node_map_get(node_, key.data(), key.size());
121
+ if (n == nullptr) {
122
+ throw std::out_of_range("key not found");
123
+ }
124
+ return child(n);
125
+ }
126
+
127
+ json at(std::string_view key) const {
128
+ return (*this)[key];
129
+ }
130
+
131
+ bool contains(std::string_view key) const {
132
+ return kind() == YEPTRIS_NODE_MAPPING &&
133
+ yeptris_node_map_get(node_, key.data(), key.size()) != nullptr;
134
+ }
135
+
136
+ size_t size() const {
137
+ if (kind() == YEPTRIS_NODE_MAPPING) {
138
+ return yeptris_node_map_count(node_);
139
+ }
140
+ if (kind() == YEPTRIS_NODE_SEQUENCE) {
141
+ return yeptris_node_seq_count(node_);
142
+ }
143
+ return 0;
144
+ }
145
+
146
+ // ---- array access ----
147
+ json operator[](size_t index) const {
148
+ require(YEPTRIS_NODE_SEQUENCE, "array");
149
+ if (index >= yeptris_node_seq_count(node_)) {
150
+ throw std::out_of_range("index out of range");
151
+ }
152
+ return child(yeptris_node_seq_at(node_, index));
153
+ }
154
+
155
+ json at(size_t index) const {
156
+ return (*this)[index];
157
+ }
158
+
159
+ // ---- typed getters ----
160
+ std::string get_string() const {
161
+ if (kind() != YEPTRIS_NODE_SCALAR) {
162
+ throw type_error("not a scalar");
163
+ }
164
+ size_t len = 0;
165
+ const char* v = yeptris_node_value(node_, &len);
166
+ return std::string(v ? v : "", len); /* json-c semantics: the
167
+ raw text — "1" for numbers, "true" for booleans */
168
+ }
169
+
170
+ int64_t get_int() const {
171
+ int64_t v = 0;
172
+ if (yeptris_node_int(node_, &v) != YEPTRIS_OK) {
173
+ throw type_error("not an integer");
174
+ }
175
+ return v;
176
+ }
177
+
178
+ double get_double() const {
179
+ double v = 0;
180
+ if (yeptris_node_float(node_, &v) != YEPTRIS_OK) {
181
+ throw type_error("not a float");
182
+ }
183
+ return v;
184
+ }
185
+
186
+ bool get_bool() const {
187
+ int v = 0;
188
+ if (yeptris_node_bool(node_, &v) != YEPTRIS_OK) {
189
+ throw type_error("not a boolean");
190
+ }
191
+ return v != 0;
192
+ }
193
+
194
+ private:
195
+ json(YeptrisDocument doc, YeptrisNode node) : doc_(doc), node_(node), owns_(false) {}
196
+
197
+ json child(YeptrisNode n) const {
198
+ return json(doc_, n);
199
+ }
200
+
201
+ void destroy() {
202
+ if (owns_ && doc_ != nullptr) {
203
+ yeptris_document_free(doc_);
204
+ }
205
+ doc_ = nullptr;
206
+ node_ = nullptr;
207
+ owns_ = false;
208
+ }
209
+
210
+ void check_root() const {
211
+ if (doc_ == nullptr) {
212
+ throw std::logic_error("empty json");
213
+ }
214
+ }
215
+
216
+ int kind() const {
217
+ return node_ != nullptr ? (int)yeptris_node_kind(node_) : -1;
218
+ }
219
+
220
+ void require(int k, const char* what) const {
221
+ if (kind() != k) {
222
+ throw type_error(what);
223
+ }
224
+ }
225
+
226
+ template <typename T> bool typed_ok() const {
227
+ if (node_ == nullptr || kind() != YEPTRIS_NODE_SCALAR) {
228
+ return false;
229
+ }
230
+ if constexpr (std::is_same_v<T, int64_t>) {
231
+ int64_t v;
232
+ return yeptris_node_int(node_, &v) == YEPTRIS_OK;
233
+ } else if constexpr (std::is_same_v<T, double>) {
234
+ double v;
235
+ return yeptris_node_float(node_, &v) == YEPTRIS_OK;
236
+ } else {
237
+ int v;
238
+ return yeptris_node_bool(node_, &v) == YEPTRIS_OK;
239
+ }
240
+ }
241
+
242
+ YeptrisDocument doc_ = nullptr;
243
+ YeptrisNode node_ = nullptr;
244
+ bool owns_ = false;
245
+ };
246
+
247
+ inline bool json::is_null() const {
248
+ if (kind() != YEPTRIS_NODE_SCALAR) {
249
+ return false;
250
+ }
251
+ size_t len = 0;
252
+ const char* v = yeptris_node_value(node_, &len);
253
+ return len == 4 && v != nullptr && std::string_view(v, len) == "null";
254
+ }
255
+
256
+ } // namespace yeptris
257
+
258
+ #endif // YEPTRIS_JSON_HPP
@@ -0,0 +1,115 @@
1
+ /* jsonc_compat.h — the json-c migration layer (TODO.impl/21).
2
+ *
3
+ * REAL json-c symbol names over the yeptris core: users link
4
+ * -lyeptris-jsonc instead of -ljson-c and change nothing else.
5
+ *
6
+ * Scope (v1, the read path): parsing, type queries, value getters,
7
+ * object/array access, and JSON output. The building API
8
+ * (json_object_new_ etc.) landed with DOM mutation
9
+ * (TODO.impl/11 phase 3): the new_object family, object_add,
10
+ * array_add, and the delete entry points.
11
+ *
12
+ * Lifetime: the object returned by json_tokener_parse owns the
13
+ * document; json_object_put frees it. Objects obtained by reference
14
+ * (children) are owned by their document — put on them is a no-op
15
+ * returning 1 (json-c children outlive callers the same way).
16
+ */
17
+ #ifndef YEPTRIS_JSONC_COMPAT_H
18
+ #define YEPTRIS_JSONC_COMPAT_H
19
+
20
+ #include <stddef.h>
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ /* Values mirror json-c's json_type. */
27
+ typedef enum {
28
+ json_type_null = 0,
29
+ json_type_boolean,
30
+ json_type_double,
31
+ json_type_int,
32
+ json_type_object,
33
+ json_type_array,
34
+ json_type_string
35
+ } json_type;
36
+
37
+ typedef struct json_object json_object;
38
+
39
+ /* json-c's string flags for to_json_string_ext */
40
+ #define JSON_C_TO_STRING_PLAIN 0
41
+ #define JSON_C_TO_STRING_SPACED (1 << 0)
42
+ #define JSON_C_TO_STRING_PRETTY (1 << 1)
43
+ #define JSON_C_TO_STRING_PRETTY_TAB (1 << 2)
44
+ #define JSON_C_TO_STRING_NOZERO (1 << 3)
45
+
46
+ /* Parses one JSON document (strict; trailing whitespace allowed).
47
+ * Returns NULL on invalid input. The result owns its document —
48
+ * release with json_object_put. */
49
+ json_object* json_tokener_parse(const char* str);
50
+ json_object* json_tokener_parse_ex(const char* buf, int len);
51
+ void json_tokener_free(json_object* obj);
52
+
53
+ /* Lifetime: put on the ROOT frees the document (once); on a child it
54
+ * is a no-op returning 1. get returns the object unchanged. */
55
+ int json_object_put(json_object* obj);
56
+ json_object* json_object_get(json_object* obj);
57
+
58
+ /* Type queries. */
59
+ json_type json_object_get_type(const json_object* obj);
60
+ int json_object_is_type(const json_object* obj, json_type type);
61
+
62
+ /* Value getters (0 when the type does not match, like json-c). */
63
+ const char* json_object_get_string(json_object* obj);
64
+ int32_t json_object_get_int(const json_object* obj);
65
+ int64_t json_object_get_int64(const json_object* obj);
66
+ double json_object_get_double(const json_object* obj);
67
+ int json_object_get_boolean(const json_object* obj);
68
+
69
+ /* Object access: *value receives the field (a borrowed reference). */
70
+ int json_object_object_get_ex(const json_object* obj, const char* key, json_object** value);
71
+ size_t json_object_object_length(const json_object* obj);
72
+
73
+ /* Array access (borrowed references). */
74
+ size_t json_object_array_length(const json_object* obj);
75
+ json_object* json_object_array_get_idx(const json_object* obj, size_t idx);
76
+
77
+ /* Output: strict JSON. The returned pointer is owned by the object
78
+ * (freed with it) — json-c's contract. Roots only in v1: serializing
79
+ * an attached child returns NULL (subtree output arrives with the
80
+ * pretty printer). */
81
+ const char* json_object_to_json_string(json_object* obj);
82
+ const char* json_object_to_json_string_ext(json_object* obj, int flags);
83
+
84
+ /* ---- Building (TODO.impl/21 v2, over DOM mutation 11/3) ----
85
+ *
86
+ * json-c semantics: new_* returns an unowned object; adding it to a
87
+ * parent transfers ownership (a put on it afterwards is a no-op); the
88
+ * caller's pointer stays valid until the ROOT is put. Values are
89
+ * copied. Duplicate keys replace in place (position kept). NULL val
90
+ * to object_add deletes the key (legacy json-c behavior). */
91
+ json_object* json_object_new_object(void);
92
+ json_object* json_object_new_array(void);
93
+ json_object* json_object_new_string(const char* s);
94
+ json_object* json_object_new_string_len(const char* s, int len);
95
+ json_object* json_object_new_int(int32_t i);
96
+ json_object* json_object_new_int64(int64_t i);
97
+ json_object* json_object_new_double(double d);
98
+ json_object* json_object_new_boolean(int b);
99
+
100
+ /* 0 added, 1 replaced, -1 error (obj not an object, or OOM). */
101
+ int json_object_object_add(json_object* obj, const char* key, json_object* val);
102
+ int json_object_object_del(json_object* obj, const char* key);
103
+
104
+ /* 0 ok, -1 error (obj not an array, or OOM). */
105
+ int json_object_array_add(json_object* obj, json_object* val);
106
+ int json_object_array_del_idx(json_object* obj, size_t idx, size_t count);
107
+
108
+ /* index < len replaces in place; index == len appends. */
109
+ int json_object_array_put_idx(json_object* obj, size_t idx, json_object* val);
110
+
111
+ #ifdef __cplusplus
112
+ }
113
+ #endif
114
+
115
+ #endif /* YEPTRIS_JSONC_COMPAT_H */
@@ -0,0 +1,52 @@
1
+ /* marshal.h — Ruby Marshal 4.8 emission (TODO.restructure/21).
2
+ *
3
+ * The binding materialization fast path: the C side converts the
4
+ * value records directly into Ruby's Marshal wire format, so the host
5
+ * materializes the whole object graph with ONE core-C call
6
+ * (Marshal.load) instead of walking per-value records in Ruby.
7
+ *
8
+ * Semantics are pinned to the binding walks (the ':sym' plain scan,
9
+ * Psych's single-char y/n and dot-required floats, alias identity
10
+ * via object links). Constructs the format cannot express return
11
+ * YEPTRIS_ERROR_UNSUPPORTED — the host falls back to the record walk.
12
+ *
13
+ * Memory: *out is a single malloc'd buffer; free with
14
+ * yeptris_marshal_free exactly once. */
15
+ #ifndef YEPTRIS_MARSHAL_H
16
+ #define YEPTRIS_MARSHAL_H
17
+
18
+ #include <stddef.h>
19
+
20
+ #include <yeptris/api.h>
21
+ #include <yeptris/dom.h>
22
+ #include <yeptris/resolve.h>
23
+
24
+ #ifdef __cplusplus
25
+ extern "C" {
26
+ #endif
27
+
28
+ typedef enum {
29
+ /* the whole stream as one Ruby Array of documents (load_all) */
30
+ YEPTRIS_MARSHAL_ALL_DOCS = 0,
31
+ /* just the first document's root (load) */
32
+ YEPTRIS_MARSHAL_FIRST_DOC = 1,
33
+ } YeptrisMarshalMode;
34
+
35
+ /* Parses `data` and emits Marshal 4.8 bytes of the object graph the
36
+ * value stream describes. Returns YEPTRIS_OK, YEPTRIS_ERROR_PARSE /
37
+ * _MEMORY / _ARG, or YEPTRIS_ERROR_UNSUPPORTED (merge keys or
38
+ * timestamps: materialize those through the record walk). */
39
+ YEPTRIS_API YeptrisStatus yeptris_marshal(const char* data, size_t len, YeptrisSchema schema,
40
+ YeptrisMarshalMode mode, char** out, size_t* out_len);
41
+
42
+ /* The same emission for one node subtree of a built document — the
43
+ * bulk path behind Node#to_ruby (one call, not one per node). */
44
+ YEPTRIS_API YeptrisStatus yeptris_marshal_node(YeptrisNode node, char** out, size_t* out_len);
45
+
46
+ YEPTRIS_API void yeptris_marshal_free(char* out);
47
+
48
+ #ifdef __cplusplus
49
+ }
50
+ #endif
51
+
52
+ #endif /* YEPTRIS_MARSHAL_H */
@@ -0,0 +1,48 @@
1
+ /* parse.h — the parse entry points (TODO.impl/07/11 public surface). */
2
+
3
+ #ifndef YEPTRIS_PARSE_H
4
+ #define YEPTRIS_PARSE_H
5
+
6
+ #include <stddef.h>
7
+
8
+ #include <yeptris/api.h>
9
+ #include <yeptris/error.h>
10
+ #include <yeptris/resolve.h>
11
+ #include <yeptris/types.h>
12
+
13
+ #ifdef __cplusplus
14
+ extern "C" {
15
+ #endif
16
+
17
+ /* Parses a YAML document set. buf must remain valid for the lifetime of
18
+ * the returned document (scalar values are borrowed zero-copy views).
19
+ * On failure returns NULL; *status (may be NULL) receives the code and
20
+ * yeptris_last_error() carries the message with line/column.
21
+ *
22
+ * Memory: the caller owns the document; free it with
23
+ * yeptris_document_free — one call releases everything. */
24
+ YEPTRIS_API YeptrisDocument yeptris_parse(const char* buf, size_t len, YeptrisStatus* status);
25
+
26
+ /* Per-parse options (TODO.impl/10): schema selects the implicit-typing
27
+ * resolver (default YEPTRIS_SCHEMA_12_CORE), max_depth caps nesting
28
+ * (0: the library default), strict/tab_policy/recover are reserved
29
+ * pins of the option shape (the strict grammar is the default today;
30
+ * lenient modes land with the recover work). Zero-initialized = the
31
+ * yeptris_parse defaults. */
32
+ typedef struct YeptrisParseOptions {
33
+ YeptrisSchema schema;
34
+ int max_depth;
35
+ int strict;
36
+ int tab_policy;
37
+ int recover;
38
+ } YeptrisParseOptions;
39
+
40
+ YEPTRIS_API YeptrisDocument yeptris_parse_ex(const char* buf, size_t len,
41
+ const YeptrisParseOptions* opts,
42
+ YeptrisStatus* status);
43
+
44
+ #ifdef __cplusplus
45
+ }
46
+ #endif
47
+
48
+ #endif /* YEPTRIS_PARSE_H */
@@ -0,0 +1,100 @@
1
+ /* plan.h — the compiled plan walk (TODO.restructure/87 slice one,
2
+ * yeptris#293): a Descriptor-shaped plan compiled from a JSON spec,
3
+ * applied to a parsed JSON tape in ONE C pass producing typed
4
+ * COLUMNAR output — no Ruby/Python tree, no per-node host dispatch.
5
+ *
6
+ * Slice one covers the lutaml-model shape: a root collection (seq or
7
+ * map-of-rows) whose rows are mappings of scalar leaves (int, float,
8
+ * str, bool). Nested paths, the YAML leg, and partial descriptors
9
+ * compose later per the board item.
10
+ *
11
+ * The plan borrows nothing; the result borrows the tape's source
12
+ * buffer for string spans (free the result before the tape/source).
13
+ */
14
+ #ifndef YEPTRIS_PLAN_H
15
+ #define YEPTRIS_PLAN_H
16
+
17
+ #include <stddef.h>
18
+ #include <stdint.h>
19
+
20
+ #include <yeptris/api.h>
21
+ #include <yeptris/error.h>
22
+ #include <yeptris/tape.h>
23
+
24
+ #ifdef __cplusplus
25
+ extern "C" {
26
+ #endif
27
+
28
+ /* Column kinds (mirrors the spec's leaf "kind"). */
29
+ enum {
30
+ YEP_PLAN_INT = 0,
31
+ YEP_PLAN_FLOAT,
32
+ YEP_PLAN_STR,
33
+ YEP_PLAN_BOOL,
34
+ };
35
+
36
+ typedef struct yeptris_plan yeptris_plan;
37
+ typedef struct yeptris_plan_result yeptris_plan_result;
38
+
39
+ /* Compiles a plan from a strict-JSON spec document:
40
+ *
41
+ * {"kind":"seq","path":"items","children":[
42
+ * {"name":"id","kind":"int"}, {"name":"ok","kind":"bool"}, ...]}
43
+ *
44
+ * kind: "seq" or "map" — the ROWS container's shape at the root.
45
+ * path: the root mapping's key holding the rows — a string, or an
46
+ * ARRAY of strings for a segmented (nested) path walked
47
+ * mapping by mapping. Empty/absent: the seq root itself.
48
+ * Leaf kinds: int, float, str, bool. Returns NULL with *st on
49
+ * a malformed spec (ARG/PARSE) or allocation failure. */
50
+ YEPTRIS_API yeptris_plan* yeptris_plan_compile(const char* spec, size_t len, YeptrisStatus* st);
51
+
52
+ YEPTRIS_API void yeptris_plan_free(yeptris_plan* plan);
53
+
54
+ YEPTRIS_API size_t yeptris_plan_column_count(const yeptris_plan* plan);
55
+
56
+ /* Applies the plan to a tape (from yeptris_parse_json_tape; the
57
+ * LENIENT tape also works — NUM records convert at extraction).
58
+ * Every row of the collection fills one slot per column; missing or
59
+ * null leaves mark the slot null. Returns NULL with *st on
60
+ * PARSE (document shape disagreement) or MEMORY. */
61
+ YEPTRIS_API yeptris_plan_result*
62
+ yeptris_tape_plan_walk(const yeptris_json_tape* tape, const yeptris_plan* plan, YeptrisStatus* st);
63
+
64
+ /* The YAML/DOM leg: the same compiled plan applied to a parsed
65
+ * yeptris document (yeptris_parse — any schema). Typed extraction
66
+ * rides the parse-time tag ids; string columns expose (ptr,len)
67
+ * views into the document's regions (input or string arena), so the
68
+ * RESULT BORROWS the document — free the result first. Same status
69
+ * contract as the tape walk. */
70
+ YEPTRIS_API yeptris_plan_result*
71
+ yeptris_document_plan_walk(YeptrisDocument doc, const yeptris_plan* plan, YeptrisStatus* st);
72
+
73
+ YEPTRIS_API void yeptris_plan_result_free(yeptris_plan_result* r);
74
+
75
+ /* Result accessors: rows, and per-column kind + typed arrays. The
76
+ * arrays hold `rows` entries; NULL markers are the per-column u8
77
+ * bitmap (1 = null/missing). String columns expose spans into the
78
+ * tape's source. */
79
+ YEPTRIS_API size_t yeptris_plan_result_rows(const yeptris_plan_result* r);
80
+ YEPTRIS_API int yeptris_plan_result_kind(const yeptris_plan_result* r, size_t col);
81
+ YEPTRIS_API const int64_t* yeptris_plan_result_ints(const yeptris_plan_result* r, size_t col);
82
+ YEPTRIS_API const double* yeptris_plan_result_floats(const yeptris_plan_result* r, size_t col);
83
+ YEPTRIS_API const uint32_t* yeptris_plan_result_str_offs(const yeptris_plan_result* r, size_t col);
84
+ YEPTRIS_API const uint32_t* yeptris_plan_result_str_lens(const yeptris_plan_result* r, size_t col);
85
+ /* The DOM leg's string column: rows (ptr,len) views into the
86
+ * document (NULL on the tape leg — use the offs/lens pair there). */
87
+ typedef struct yeptris_plan_str {
88
+ const char* p;
89
+ size_t len;
90
+ } yeptris_plan_str;
91
+
92
+ YEPTRIS_API const yeptris_plan_str* yeptris_plan_result_strs(const yeptris_plan_result* r,
93
+ size_t col);
94
+ YEPTRIS_API const uint8_t* yeptris_plan_result_nulls(const yeptris_plan_result* r, size_t col);
95
+
96
+ #ifdef __cplusplus
97
+ }
98
+ #endif
99
+
100
+ #endif /* YEPTRIS_PLAN_H */
@@ -0,0 +1,71 @@
1
+ /* resolve.h — schema resolvers and typed scalar access (TODO.impl/10).
2
+ *
3
+ * Typing is pluggable and outside the grammar: a resolver decides,
4
+ * per plain scalar, which implicit tag it carries. YAML 1.2 core
5
+ * correctness and Psych/libyaml 1.1 parity are two resolvers over one
6
+ * interface; the parse options select one per document.
7
+ *
8
+ * Resolution assigns a dense tag id at parse time (stored on DOM
9
+ * nodes); typed VALUE conversion happens on accessor demand — parse
10
+ * speed never pays for typing the caller never reads.
11
+ */
12
+ #ifndef YEPTRIS_RESOLVE_H
13
+ #define YEPTRIS_RESOLVE_H
14
+
15
+ #include <stddef.h>
16
+ #include <stdint.h>
17
+
18
+ #include <yeptris/api.h>
19
+ #include <yeptris/error.h>
20
+ #include <yeptris/types.h>
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ /* Tag ids. The core set is preallocated and stable (ABI-pinned);
27
+ * custom tags resolve to YEPTRIS_TAG_CUSTOM and keep their string. */
28
+ typedef enum {
29
+ YEPTRIS_TAG_STR = 0,
30
+ YEPTRIS_TAG_INT = 1,
31
+ YEPTRIS_TAG_FLOAT = 2,
32
+ YEPTRIS_TAG_BOOL = 3,
33
+ YEPTRIS_TAG_NULL = 4,
34
+ YEPTRIS_TAG_TIMESTAMP = 5,
35
+ YEPTRIS_TAG_SEQ = 6,
36
+ YEPTRIS_TAG_MAP = 7,
37
+ YEPTRIS_TAG_BINARY = 8,
38
+ YEPTRIS_TAG_MERGE = 9,
39
+ YEPTRIS_TAG_VALUE = 10,
40
+ YEPTRIS_TAG_CUSTOM = 11,
41
+ } YeptrisTagId;
42
+
43
+ /* Schemas. */
44
+ typedef enum {
45
+ YEPTRIS_SCHEMA_12_CORE = 0, /* default: the yaml-test-suite target */
46
+ YEPTRIS_SCHEMA_11_COMPAT, /* libyaml/Psych implicit typing */
47
+ } YeptrisSchema;
48
+
49
+ /* Canonical tag URI for a core id ("tag:yaml.org,2002:str"); NULL for
50
+ * YEPTRIS_TAG_CUSTOM. */
51
+ YEPTRIS_API const char* yeptris_tag_uri(YeptrisTagId id);
52
+
53
+ /* The tag a scalar resolved to (PLAIN scalars carry their implicit
54
+ * tag; quoted/other styles are always STR; explicit tags map to their
55
+ * core id when they match one, else CUSTOM). Non-scalars: SEQ/MAP.
56
+ * YEPTRIS_ERROR_ARG on a bad handle. */
57
+ YEPTRIS_API YeptrisTagId yeptris_node_tag_id(YeptrisNode node);
58
+
59
+ /* Typed access (lazy conversion from the raw view; resolution's tag
60
+ * id decides eligibility, the conversion revalidates the bytes):
61
+ * YEPTRIS_ERROR_PARSE when the scalar's tag does not match the
62
+ * accessor (e.g. an INT accessor on a STR). */
63
+ YEPTRIS_API YeptrisStatus yeptris_node_int(YeptrisNode node, int64_t* out);
64
+ YEPTRIS_API YeptrisStatus yeptris_node_float(YeptrisNode node, double* out);
65
+ YEPTRIS_API YeptrisStatus yeptris_node_bool(YeptrisNode node, int* out);
66
+
67
+ #ifdef __cplusplus
68
+ }
69
+ #endif
70
+
71
+ #endif /* YEPTRIS_RESOLVE_H */