yeptris 0.6.58.1-arm-linux-eabihf → 0.6.60.1-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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/ext/yeptris_native/version.h +2 -2
  3. data/lib/yeptris/3.4/native.so +0 -0
  4. data/lib/yeptris/document.rb +15 -0
  5. data/lib/yeptris/ffi.rb +112 -0
  6. data/lib/yeptris/psych/visitors.rb +16 -6
  7. data/lib/yeptris/psych.rb +11 -5
  8. data/lib/yeptris/validation.rb +320 -0
  9. data/lib/yeptris/yaml.rb +128 -6
  10. data/lib/yeptris.rb +2 -1
  11. data/libyeptris.so +0 -0
  12. data/vendor/libyeptris/CMakeLists.txt +1 -1
  13. data/vendor/libyeptris/src/CMakeLists.txt +8 -0
  14. data/vendor/libyeptris/src/include/yeptris/emit.h +30 -2
  15. data/vendor/libyeptris/src/include/yeptris/parse.h +52 -0
  16. data/vendor/libyeptris/src/include/yeptris/resolve.h +8 -0
  17. data/vendor/libyeptris/src/include/yeptris/validate.h +259 -15
  18. data/vendor/libyeptris/src/include/yeptris/values.h +8 -2
  19. data/vendor/libyeptris/src/yeptris/cbor/cbor.h +10 -0
  20. data/vendor/libyeptris/src/yeptris/cbor/decode.c +5 -7
  21. data/vendor/libyeptris/src/yeptris/cbor/encode.c +9 -9
  22. data/vendor/libyeptris/src/yeptris/cbor/from_marshal.c +1 -1
  23. data/vendor/libyeptris/src/yeptris/common/error.h +2 -0
  24. data/vendor/libyeptris/src/yeptris/doc.h +20 -0
  25. data/vendor/libyeptris/src/yeptris/emit/emit.c +85 -13
  26. data/vendor/libyeptris/src/yeptris/emit/writer.c +158 -642
  27. data/vendor/libyeptris/src/yeptris/emit/writer.h +15 -1
  28. data/vendor/libyeptris/src/yeptris/events/push.c +28 -3
  29. data/vendor/libyeptris/src/yeptris/events/values.c +24 -0
  30. data/vendor/libyeptris/src/yeptris/marshal/to_json.c +650 -0
  31. data/vendor/libyeptris/src/yeptris/parse/engine.c +121 -40
  32. data/vendor/libyeptris/src/yeptris/parse/stream_iter.c +326 -0
  33. data/vendor/libyeptris/src/yeptris/parse.c +181 -46
  34. data/vendor/libyeptris/src/yeptris/resolve/compat11.c +1 -1
  35. data/vendor/libyeptris/src/yeptris/resolve/core12.c +11 -3
  36. data/vendor/libyeptris/src/yeptris/resolve/full12.c +201 -0
  37. data/vendor/libyeptris/src/yeptris/resolve/json12.c +12 -6
  38. data/vendor/libyeptris/src/yeptris/resolve/resolver.h +20 -0
  39. data/vendor/libyeptris/src/yeptris/validate/compile.c +306 -0
  40. data/vendor/libyeptris/src/yeptris/validate/internal.h +255 -10
  41. data/vendor/libyeptris/src/yeptris/validate/jsonschema.c +1025 -125
  42. data/vendor/libyeptris/src/yeptris/validate/output.c +246 -0
  43. data/vendor/libyeptris/src/yeptris/validate/regexp.c +791 -163
  44. data/vendor/libyeptris/src/yeptris/validate/registry.c +118 -0
  45. data/vendor/libyeptris/src/yeptris/validate/resources.c +601 -0
  46. data/vendor/libyeptris/src/yeptris/validate/stream.c +1155 -0
  47. data/vendor/libyeptris/src/yeptris/validate/validate.c +330 -226
  48. metadata +10 -1
@@ -0,0 +1,118 @@
1
+ /* registry.c — the tag-driven schema registry (#906 slice 4).
2
+ *
3
+ * The dialect table's reserved slot: user tag -> compiled schema.
4
+ * A small borrowed-pointer table (the caller's compiled schemas are
5
+ * REFERENCED, never copied — the schema bytes/DOM/programs stay the
6
+ * handle's single home, so the compile economy holds and no refcount
7
+ * exists; THE REGISTRY LAW on validate.h pins the free order:
8
+ * registry first, schemas after).
9
+ *
10
+ * Lookup is a linear scan — registries are hand-built (a handful of
11
+ * domain tags), so O(n) probes cost nothing next to a validation walk,
12
+ * and registration order is the only state to reason about (last
13
+ * registration wins). MECE: this TU owns the table; validate.c owns
14
+ * when the walk consults it; jsonschema.c owns the subtree walk it
15
+ * triggers. Nothing here edits the core.
16
+ */
17
+
18
+ #include <string.h>
19
+
20
+ #include <yeptris/validate.h>
21
+
22
+ #include "../common/error.h"
23
+ #include "../memory/allocator.h"
24
+ #include "internal.h"
25
+
26
+ typedef struct {
27
+ char* tag; /* owned copy of the caller's bytes */
28
+ uint32_t tag_len;
29
+ const yeptris_schema* schema; /* borrowed (THE REGISTRY LAW) */
30
+ } reg_entry;
31
+
32
+ struct yeptris_schema_registry {
33
+ reg_entry* entries;
34
+ uint32_t count, cap;
35
+ };
36
+
37
+ YEPTRIS_API yeptris_schema_registry* yeptris_schema_registry_new(void) {
38
+ const yep_allocator* sys = yep_system_allocator();
39
+ yeptris_schema_registry* r = yep_alloc(sys, sizeof(*r));
40
+ if (r == NULL) {
41
+ return NULL;
42
+ }
43
+ r->entries = NULL;
44
+ r->count = 0;
45
+ r->cap = 0;
46
+ return r;
47
+ }
48
+
49
+ YEPTRIS_API YeptrisStatus yeptris_schema_registry_register(yeptris_schema_registry* reg,
50
+ const char* tag, size_t tag_len,
51
+ const yeptris_schema* schema) {
52
+ if (reg == NULL || tag == NULL || tag_len == 0 || tag_len > UINT32_MAX || schema == NULL) {
53
+ return YEPTRIS_ERROR_ARG;
54
+ }
55
+ const yep_allocator* sys = yep_system_allocator();
56
+
57
+ /* replace-on-reregister: the table stays a FUNCTION (one schema
58
+ * per tag), never a multiset a lookup would have to order */
59
+ for (uint32_t i = 0; i < reg->count; i++) {
60
+ if (reg->entries[i].tag_len == tag_len && memcmp(reg->entries[i].tag, tag, tag_len) == 0) {
61
+ reg->entries[i].schema = schema; /* the old binding drops */
62
+ return YEPTRIS_OK;
63
+ }
64
+ }
65
+
66
+ if (reg->count == reg->cap) {
67
+ uint32_t ncap = reg->cap ? reg->cap * 2 : 8;
68
+ reg_entry* ne = yep_alloc(sys, (size_t)ncap * sizeof(reg_entry));
69
+ if (ne == NULL) {
70
+ yep_error_set(yep_error_tls(), YEP_ERR_MEMORY, 0, 0, 0,
71
+ "the schema registry failed to grow");
72
+ return YEPTRIS_ERROR_MEMORY;
73
+ }
74
+ if (reg->entries != NULL) {
75
+ memcpy(ne, reg->entries, (size_t)reg->count * sizeof(reg_entry));
76
+ yep_free(sys, reg->entries);
77
+ }
78
+ reg->entries = ne;
79
+ reg->cap = ncap;
80
+ }
81
+ char* copy = yep_alloc(sys, tag_len);
82
+ if (copy == NULL) {
83
+ yep_error_set(yep_error_tls(), YEP_ERR_MEMORY, 0, 0, 0,
84
+ "the schema registry failed to copy a tag");
85
+ return YEPTRIS_ERROR_MEMORY;
86
+ }
87
+ memcpy(copy, tag, tag_len);
88
+ reg_entry* e = &reg->entries[reg->count++];
89
+ e->tag = copy;
90
+ e->tag_len = (uint32_t)tag_len;
91
+ e->schema = schema;
92
+ return YEPTRIS_OK;
93
+ }
94
+
95
+ YEPTRIS_API const yeptris_schema* yeptris_schema_registry_lookup(const yeptris_schema_registry* reg,
96
+ const char* tag, size_t tag_len) {
97
+ if (reg == NULL || tag == NULL || tag_len == 0 || tag_len > UINT32_MAX) {
98
+ return NULL;
99
+ }
100
+ for (uint32_t i = 0; i < reg->count; i++) {
101
+ if (reg->entries[i].tag_len == tag_len && memcmp(reg->entries[i].tag, tag, tag_len) == 0) {
102
+ return reg->entries[i].schema;
103
+ }
104
+ }
105
+ return NULL;
106
+ }
107
+
108
+ YEPTRIS_API void yeptris_schema_registry_free(yeptris_schema_registry* reg) {
109
+ if (reg == NULL) {
110
+ return;
111
+ }
112
+ const yep_allocator* sys = yep_system_allocator();
113
+ for (uint32_t i = 0; i < reg->count; i++) {
114
+ yep_free(sys, reg->entries[i].tag); /* the borrowed schemas stay the caller's */
115
+ }
116
+ yep_free(sys, reg->entries);
117
+ yep_free(sys, reg);
118
+ }