yeptris 0.6.5.4 → 0.6.7.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.
- checksums.yaml +4 -4
- data/ext/libyeptris/extconf.rb +57 -0
- data/lib/yeptris/ffi.rb +12 -15
- data/lib/yeptris/json.rb +5 -2
- data/lib/yeptris/psych.rb +76 -3
- data/lib/yeptris.rb +36 -14
- data/vendor/libyeptris/CMakeLists.txt +254 -0
- data/vendor/libyeptris/cmake/yeptris-config.cmake.in +5 -0
- data/vendor/libyeptris/cmake/yeptris.pc.in +11 -0
- data/vendor/libyeptris/src/CMakeLists.txt +167 -0
- data/vendor/libyeptris/src/include/yeptris/api.h +32 -0
- data/vendor/libyeptris/src/include/yeptris/cbor.h +101 -0
- data/vendor/libyeptris/src/include/yeptris/dom.h +181 -0
- data/vendor/libyeptris/src/include/yeptris/emit.h +81 -0
- data/vendor/libyeptris/src/include/yeptris/error.h +41 -0
- data/vendor/libyeptris/src/include/yeptris/events.h +157 -0
- data/vendor/libyeptris/src/include/yeptris/json.h +45 -0
- data/vendor/libyeptris/src/include/yeptris/json.hpp +258 -0
- data/vendor/libyeptris/src/include/yeptris/jsonc_compat.h +115 -0
- data/vendor/libyeptris/src/include/yeptris/marshal.h +52 -0
- data/vendor/libyeptris/src/include/yeptris/parse.h +48 -0
- data/vendor/libyeptris/src/include/yeptris/plan.h +100 -0
- data/vendor/libyeptris/src/include/yeptris/resolve.h +71 -0
- data/vendor/libyeptris/src/include/yeptris/schema.h +119 -0
- data/vendor/libyeptris/src/include/yeptris/tape.h +99 -0
- data/vendor/libyeptris/src/include/yeptris/types.h +38 -0
- data/vendor/libyeptris/src/include/yeptris/values.h +102 -0
- data/vendor/libyeptris/src/include/yeptris/version.h.in +29 -0
- data/vendor/libyeptris/src/include/yeptris/visit.h +77 -0
- data/vendor/libyeptris/src/include/yeptris/yajl_compat.h +135 -0
- data/vendor/libyeptris/src/include/yeptris.h +23 -0
- data/vendor/libyeptris/src/yeptris/build.c +371 -0
- data/vendor/libyeptris/src/yeptris/cbor/cbor.h +25 -0
- data/vendor/libyeptris/src/yeptris/cbor/decode.c +846 -0
- data/vendor/libyeptris/src/yeptris/cbor/encode.c +824 -0
- data/vendor/libyeptris/src/yeptris/common/chartype.c +41 -0
- data/vendor/libyeptris/src/yeptris/common/chartype.h +77 -0
- data/vendor/libyeptris/src/yeptris/common/cpu.c +81 -0
- data/vendor/libyeptris/src/yeptris/common/cpu.h +40 -0
- data/vendor/libyeptris/src/yeptris/common/error.c +65 -0
- data/vendor/libyeptris/src/yeptris/common/error.h +79 -0
- data/vendor/libyeptris/src/yeptris/common/mutex.h +45 -0
- data/vendor/libyeptris/src/yeptris/common/nametab.c +275 -0
- data/vendor/libyeptris/src/yeptris/common/nametab.h +68 -0
- data/vendor/libyeptris/src/yeptris/common/port.h +74 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.c +49 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.h +295 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +534 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +662 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +298 -0
- data/vendor/libyeptris/src/yeptris/common/string_view.c +34 -0
- data/vendor/libyeptris/src/yeptris/common/string_view.h +93 -0
- data/vendor/libyeptris/src/yeptris/doc.h +37 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.c +973 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.h +290 -0
- data/vendor/libyeptris/src/yeptris/dom/hpool.c +107 -0
- data/vendor/libyeptris/src/yeptris/dom/mapindex.c +173 -0
- data/vendor/libyeptris/src/yeptris/dom/mapindex.h +61 -0
- data/vendor/libyeptris/src/yeptris/dom/mutate.c +429 -0
- data/vendor/libyeptris/src/yeptris/emit/emit.c +349 -0
- data/vendor/libyeptris/src/yeptris/emit/float/api.h +38 -0
- data/vendor/libyeptris/src/yeptris/emit/float/dragon.c +405 -0
- data/vendor/libyeptris/src/yeptris/emit/float/floatint.h +203 -0
- data/vendor/libyeptris/src/yeptris/emit/float/print.c +396 -0
- data/vendor/libyeptris/src/yeptris/emit/style.c +81 -0
- data/vendor/libyeptris/src/yeptris/emit/style.h +24 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.c +746 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.h +61 -0
- data/vendor/libyeptris/src/yeptris/encoding/bom.c +31 -0
- data/vendor/libyeptris/src/yeptris/encoding/encoding.h +63 -0
- data/vendor/libyeptris/src/yeptris/encoding/transcode.c +148 -0
- data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +178 -0
- data/vendor/libyeptris/src/yeptris/events/capture.c +150 -0
- data/vendor/libyeptris/src/yeptris/events/capture.h +39 -0
- data/vendor/libyeptris/src/yeptris/events/iterparse.c +208 -0
- data/vendor/libyeptris/src/yeptris/events/pull.c +97 -0
- data/vendor/libyeptris/src/yeptris/events/push.c +104 -0
- data/vendor/libyeptris/src/yeptris/events/recorder.c +107 -0
- data/vendor/libyeptris/src/yeptris/events/values.c +527 -0
- data/vendor/libyeptris/src/yeptris/events/values_priv.h +51 -0
- data/vendor/libyeptris/src/yeptris/events/yaml_compat.c +86 -0
- data/vendor/libyeptris/src/yeptris/events/yaml_compat.h +90 -0
- data/vendor/libyeptris/src/yeptris/jsonapi/jsonc_compat.c +687 -0
- data/vendor/libyeptris/src/yeptris/jsonapi/yajl_compat.c +728 -0
- data/vendor/libyeptris/src/yeptris/marshal.c +744 -0
- data/vendor/libyeptris/src/yeptris/memory/allocator.c +20 -0
- data/vendor/libyeptris/src/yeptris/memory/allocator.h +43 -0
- data/vendor/libyeptris/src/yeptris/memory/arena.c +134 -0
- data/vendor/libyeptris/src/yeptris/memory/arena.h +52 -0
- data/vendor/libyeptris/src/yeptris/memory/pool.c +115 -0
- data/vendor/libyeptris/src/yeptris/memory/pool.h +36 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.c +3689 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.h +65 -0
- data/vendor/libyeptris/src/yeptris/parse/events.h +124 -0
- data/vendor/libyeptris/src/yeptris/parse/numbers.c +349 -0
- data/vendor/libyeptris/src/yeptris/parse/numbers.h +33 -0
- data/vendor/libyeptris/src/yeptris/parse/scalars.c +416 -0
- data/vendor/libyeptris/src/yeptris/parse/scalars.h +75 -0
- data/vendor/libyeptris/src/yeptris/parse.c +650 -0
- data/vendor/libyeptris/src/yeptris/plan.c +817 -0
- data/vendor/libyeptris/src/yeptris/resolve/compat11.c +334 -0
- data/vendor/libyeptris/src/yeptris/resolve/core12.c +143 -0
- data/vendor/libyeptris/src/yeptris/resolve/resolver.h +56 -0
- data/vendor/libyeptris/src/yeptris/resolve/tags.c +58 -0
- data/vendor/libyeptris/src/yeptris/scan/json.c +792 -0
- data/vendor/libyeptris/src/yeptris/scan/json.h +109 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.c +463 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.h +150 -0
- data/vendor/libyeptris/src/yeptris/schema.c +238 -0
- data/vendor/libyeptris/src/yeptris/tape.c +1292 -0
- data/vendor/libyeptris/src/yeptris/version.c +7 -0
- data/vendor/libyeptris/src/yeptris/visit/dom_visit.c +115 -0
- data/vendor/libyeptris/src/yeptris/visit/json_visit.c +293 -0
- data/vendor/libyeptris/src/yeptris/visit/yaml_visit.c +127 -0
- metadata +112 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# libyeptris — core library sources.
|
|
2
|
+
#
|
|
3
|
+
# Subsystems land with their TODO.impl items (common/ 02, memory/ 03,
|
|
4
|
+
# simd/ 04, encoding/ 05, scan/ 06, parse/ 07+). The SIMD per-ISA TUs get
|
|
5
|
+
# their own -m flags here when item 04 lands.
|
|
6
|
+
|
|
7
|
+
set(YEPTRIS_SOURCES
|
|
8
|
+
yeptris/version.c
|
|
9
|
+
yeptris/common/cpu.c
|
|
10
|
+
yeptris/common/chartype.c
|
|
11
|
+
yeptris/common/string_view.c
|
|
12
|
+
yeptris/common/error.c
|
|
13
|
+
yeptris/common/nametab.c
|
|
14
|
+
yeptris/common/simd_text.c
|
|
15
|
+
yeptris/common/simd_text_scalar.c
|
|
16
|
+
yeptris/memory/allocator.c
|
|
17
|
+
yeptris/memory/pool.c
|
|
18
|
+
yeptris/memory/arena.c
|
|
19
|
+
yeptris/encoding/bom.c
|
|
20
|
+
yeptris/encoding/transcode.c
|
|
21
|
+
yeptris/encoding/utf8_validate.c
|
|
22
|
+
yeptris/scan/json.c
|
|
23
|
+
yeptris/scan/scan.c
|
|
24
|
+
yeptris/parse/scalars.c
|
|
25
|
+
yeptris/parse/engine.c
|
|
26
|
+
yeptris/dom/dom.c
|
|
27
|
+
yeptris/dom/hpool.c
|
|
28
|
+
yeptris/dom/mapindex.c
|
|
29
|
+
yeptris/dom/mutate.c
|
|
30
|
+
yeptris/parse.c
|
|
31
|
+
yeptris/build.c
|
|
32
|
+
yeptris/events/capture.c
|
|
33
|
+
yeptris/events/push.c
|
|
34
|
+
yeptris/events/pull.c
|
|
35
|
+
yeptris/events/recorder.c
|
|
36
|
+
yeptris/events/iterparse.c
|
|
37
|
+
yeptris/events/yaml_compat.c
|
|
38
|
+
yeptris/resolve/tags.c
|
|
39
|
+
yeptris/resolve/core12.c
|
|
40
|
+
yeptris/resolve/compat11.c
|
|
41
|
+
yeptris/parse/numbers.c
|
|
42
|
+
yeptris/events/values.c
|
|
43
|
+
yeptris/schema.c
|
|
44
|
+
yeptris/tape.c
|
|
45
|
+
yeptris/plan.c
|
|
46
|
+
|
|
47
|
+
yeptris/marshal.c
|
|
48
|
+
yeptris/visit/json_visit.c
|
|
49
|
+
yeptris/visit/yaml_visit.c
|
|
50
|
+
yeptris/visit/dom_visit.c
|
|
51
|
+
yeptris/emit/style.c
|
|
52
|
+
yeptris/emit/writer.c
|
|
53
|
+
yeptris/emit/emit.c
|
|
54
|
+
yeptris/emit/float/print.c
|
|
55
|
+
yeptris/emit/float/dragon.c
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if(YEPTRIS_WITH_CBOR)
|
|
59
|
+
list(APPEND YEPTRIS_SOURCES yeptris/cbor/decode.c yeptris/cbor/encode.c)
|
|
60
|
+
endif()
|
|
61
|
+
|
|
62
|
+
# AOT SIMD TUs (TODO.impl/04): per-ISA compile flags; the TUs and the
|
|
63
|
+
# dispatch share architecture guards, so links resolve on every platform.
|
|
64
|
+
# CMAKE_OSX_ARCHITECTURES participates: an -arch x86_64 cross-build on
|
|
65
|
+
# an arm Mac compiles the dispatch for x86 — the source pick must
|
|
66
|
+
# follow the TARGET arch, not the host (the all-platform wheels ride
|
|
67
|
+
# this; host-processor-only selection linked NEON objects into an
|
|
68
|
+
# x86_64 image).
|
|
69
|
+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|i[3-6]86)$" OR
|
|
70
|
+
CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
|
|
71
|
+
list(APPEND YEPTRIS_SOURCES yeptris/common/simd_text_avx2.c)
|
|
72
|
+
if(MSVC)
|
|
73
|
+
set_source_files_properties(yeptris/common/simd_text_avx2.c
|
|
74
|
+
PROPERTIES COMPILE_OPTIONS "/arch:AVX2")
|
|
75
|
+
else()
|
|
76
|
+
set_source_files_properties(yeptris/common/simd_text_avx2.c
|
|
77
|
+
PROPERTIES COMPILE_OPTIONS "-mavx2;-mpopcnt")
|
|
78
|
+
endif()
|
|
79
|
+
elseif((CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|ARM64)$" OR
|
|
80
|
+
CMAKE_OSX_ARCHITECTURES MATCHES "arm64") AND NOT CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
|
|
81
|
+
list(APPEND YEPTRIS_SOURCES yeptris/common/simd_text_neon.c)
|
|
82
|
+
endif()
|
|
83
|
+
|
|
84
|
+
set(YEPTRIS_PUBLIC_HEADERS
|
|
85
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris.h
|
|
86
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/api.h
|
|
87
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/dom.h
|
|
88
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/error.h
|
|
89
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/events.h
|
|
90
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/emit.h
|
|
91
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/resolve.h
|
|
92
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/parse.h
|
|
93
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/values.h
|
|
94
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/schema.h
|
|
95
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/tape.h
|
|
96
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/plan.h
|
|
97
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/marshal.h
|
|
98
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/visit.h
|
|
99
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/json.h
|
|
100
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/types.h
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
set(YEPTRIS_INCLUDE_DIRS
|
|
104
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
105
|
+
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/generated>
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# json-c drop-in (TODO.impl/21): REAL json-c symbol names in its own
|
|
109
|
+
# library — users link -lyeptris-jsonc instead of -ljson-c.
|
|
110
|
+
option(YEPTRIS_BUILD_YAJL_COMPAT
|
|
111
|
+
"Build libyeptris-yajl: the yajl generator drop-in (TODO.impl/21)" ON)
|
|
112
|
+
if(YEPTRIS_BUILD_YAJL_COMPAT AND YEPTRIS_BUILD_STATIC)
|
|
113
|
+
add_library(yeptris_yajl STATIC yeptris/jsonapi/yajl_compat.c)
|
|
114
|
+
set_target_properties(yeptris_yajl PROPERTIES OUTPUT_NAME yeptris-yajl)
|
|
115
|
+
target_link_libraries(yeptris_yajl PUBLIC yeptris_static)
|
|
116
|
+
target_include_directories(yeptris_yajl PUBLIC
|
|
117
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
|
118
|
+
target_include_directories(yeptris_yajl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yeptris)
|
|
119
|
+
yeptris_set_warnings(yeptris_yajl)
|
|
120
|
+
add_library(yeptris::yajl ALIAS yeptris_yajl)
|
|
121
|
+
endif()
|
|
122
|
+
|
|
123
|
+
if(YEPTRIS_BUILD_JSONC_COMPAT AND YEPTRIS_BUILD_STATIC)
|
|
124
|
+
add_library(yeptris_jsonc STATIC yeptris/jsonapi/jsonc_compat.c)
|
|
125
|
+
set_target_properties(yeptris_jsonc PROPERTIES OUTPUT_NAME yeptris-jsonc)
|
|
126
|
+
target_link_libraries(yeptris_jsonc PUBLIC yeptris_static)
|
|
127
|
+
target_include_directories(yeptris_jsonc PUBLIC
|
|
128
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
|
129
|
+
# internal headers (emit/writer.h, float/api.h): PRIVATE — they
|
|
130
|
+
# never leak into the compat library's public interface
|
|
131
|
+
target_include_directories(yeptris_jsonc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yeptris)
|
|
132
|
+
yeptris_set_warnings(yeptris_jsonc)
|
|
133
|
+
add_library(yeptris::jsonc ALIAS yeptris_jsonc)
|
|
134
|
+
endif()
|
|
135
|
+
|
|
136
|
+
if(YEPTRIS_BUILD_STATIC)
|
|
137
|
+
find_package(Threads REQUIRED)
|
|
138
|
+
|
|
139
|
+
add_library(yeptris_static STATIC ${YEPTRIS_SOURCES})
|
|
140
|
+
add_library(yeptris::yeptris ALIAS yeptris_static)
|
|
141
|
+
set_target_properties(yeptris_static PROPERTIES OUTPUT_NAME yeptris)
|
|
142
|
+
target_include_directories(yeptris_static
|
|
143
|
+
PUBLIC ${YEPTRIS_INCLUDE_DIRS}
|
|
144
|
+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yeptris) # internal root-relative includes
|
|
145
|
+
target_compile_definitions(yeptris_static PRIVATE YEPTRIS_BUILDING)
|
|
146
|
+
if(YEPTRIS_WITH_CBOR)
|
|
147
|
+
target_compile_definitions(yeptris_static PUBLIC YEPTRIS_WITH_CBOR)
|
|
148
|
+
endif()
|
|
149
|
+
target_link_libraries(yeptris_static PRIVATE Threads::Threads)
|
|
150
|
+
yeptris_set_warnings(yeptris_static)
|
|
151
|
+
endif()
|
|
152
|
+
|
|
153
|
+
if(YEPTRIS_BUILD_SHARED)
|
|
154
|
+
add_library(yeptris_shared SHARED ${YEPTRIS_SOURCES})
|
|
155
|
+
set_target_properties(yeptris_shared
|
|
156
|
+
PROPERTIES OUTPUT_NAME yeptris
|
|
157
|
+
SOVERSION ${PROJECT_VERSION_MAJOR})
|
|
158
|
+
target_include_directories(yeptris_shared
|
|
159
|
+
PUBLIC ${YEPTRIS_INCLUDE_DIRS}
|
|
160
|
+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yeptris
|
|
161
|
+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/yeptris/emit/float)
|
|
162
|
+
target_compile_definitions(yeptris_shared PRIVATE YEPTRIS_BUILDING)
|
|
163
|
+
if(YEPTRIS_WITH_CBOR)
|
|
164
|
+
target_compile_definitions(yeptris_shared PUBLIC YEPTRIS_WITH_CBOR)
|
|
165
|
+
endif()
|
|
166
|
+
yeptris_set_warnings(yeptris_shared)
|
|
167
|
+
endif()
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* api.h — export control for libyeptris.
|
|
2
|
+
*
|
|
3
|
+
* The library is built with hidden visibility; exactly the YEPTRIS_API-marked
|
|
4
|
+
* surface is exported. Define YEPTRIS_BUILDING when compiling libyeptris
|
|
5
|
+
* itself; define YEPTRIS_SHARED when consuming the shared library on Windows.
|
|
6
|
+
*/
|
|
7
|
+
#ifndef YEPTRIS_API_H
|
|
8
|
+
/* YEPTRIS_CT_ASSERT — the compile-time layout gate, C99/MSVC-C-mode/
|
|
9
|
+
* C++ portable (typedef-array; libleptris's same migration): the old
|
|
10
|
+
* C11 _Static_assert was the ONE C11 feature pinning the standard. */
|
|
11
|
+
#define YEPTRIS_CT_ASSERT_(cond, line) typedef char yeptris_ct_assert_##line[(cond) ? 1 : -1]
|
|
12
|
+
#define YEPTRIS_CT_ASSERT(cond) YEPTRIS_CT_ASSERT_(cond, __LINE__)
|
|
13
|
+
|
|
14
|
+
#define YEPTRIS_API_H
|
|
15
|
+
|
|
16
|
+
#if defined(YEPTRIS_BUILDING) && defined(YEPTRIS_SHARED)
|
|
17
|
+
#error "define YEPTRIS_BUILDING (building) or YEPTRIS_SHARED (consuming), not both"
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#if defined(YEPTRIS_BUILDING)
|
|
21
|
+
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
22
|
+
#define YEPTRIS_API __declspec(dllexport)
|
|
23
|
+
#else
|
|
24
|
+
#define YEPTRIS_API __attribute__((visibility("default")))
|
|
25
|
+
#endif
|
|
26
|
+
#elif defined(YEPTRIS_SHARED) && (defined(_WIN32) || defined(__CYGWIN__))
|
|
27
|
+
#define YEPTRIS_API __declspec(dllimport)
|
|
28
|
+
#else
|
|
29
|
+
#define YEPTRIS_API
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
#endif /* YEPTRIS_API_H */
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* cbor.h — the CBOR (RFC 8949) public surface (TODO.cbor).
|
|
2
|
+
*
|
|
3
|
+
* CBOR is the JSON data model in binary: decode builds the same DOM
|
|
4
|
+
* yeptris_parse_json builds, so every query, emit, and binding API
|
|
5
|
+
* applies unchanged. The surface compiles only when the library was
|
|
6
|
+
* built with YEPTRIS_WITH_CBOR (the default). */
|
|
7
|
+
#ifndef YEPTRIS_CBOR_H
|
|
8
|
+
#define YEPTRIS_CBOR_H
|
|
9
|
+
|
|
10
|
+
#include <stddef.h>
|
|
11
|
+
|
|
12
|
+
#include <yeptris/api.h>
|
|
13
|
+
#include <yeptris/error.h>
|
|
14
|
+
#include <yeptris/types.h>
|
|
15
|
+
|
|
16
|
+
#ifdef __cplusplus
|
|
17
|
+
extern "C" {
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
/* Flags. */
|
|
21
|
+
#define YEPTRIS_CBOR_STRICT \
|
|
22
|
+
0x1u /* decode: reject non-minimal length \
|
|
23
|
+
arguments and non-text-string map keys \
|
|
24
|
+
(the deterministic profile's input side) */
|
|
25
|
+
#define YEPTRIS_CBOR_CANONICAL \
|
|
26
|
+
0x2u /* encode: RFC 8949 s4.2.1 core \
|
|
27
|
+
deterministic profile — minimal lengths, \
|
|
28
|
+
definite lengths, preferred floats, map \
|
|
29
|
+
keys sorted bytewise on their encoded \
|
|
30
|
+
forms (the length-first variant of \
|
|
31
|
+
s4.2.3 is NOT selected) */
|
|
32
|
+
|
|
33
|
+
/* Decodes ONE CBOR data item (RFC 8949). buf must remain valid for the
|
|
34
|
+
* lifetime of the returned document (string values are borrowed
|
|
35
|
+
* zero-copy views; indefinite-length chunks concatenate in the
|
|
36
|
+
* document's arena). Trailing bytes after the item are an error —
|
|
37
|
+
* CBOR Sequences (RFC 8742) get their own entry point.
|
|
38
|
+
*
|
|
39
|
+
* Representation notes (full ledger in src/yeptris/cbor/decode.c):
|
|
40
|
+
* integers beyond int64 materialize as shortest-double text; bignums
|
|
41
|
+
* (tags 2/3) stay tag+bytes; byte and text strings are tag-str
|
|
42
|
+
* scalars; undefined and unassigned simple values are diagnostic text
|
|
43
|
+
* ("undefined", "simple(N)"); tag chains ride the node's tag field as
|
|
44
|
+
* a space-separated decimal chain, outermost first.
|
|
45
|
+
*
|
|
46
|
+
* On failure returns NULL; *status (may be NULL) receives the code
|
|
47
|
+
* (YEPTRIS_ERROR_PARSE well-formedness, YEPTRIS_ERROR_ENCODING UTF-8,
|
|
48
|
+
* YEPTRIS_ERROR_DEPTH nesting, YEPTRIS_ERROR_MEMORY) and
|
|
49
|
+
* yeptris_last_error() carries the message with the byte offset.
|
|
50
|
+
*
|
|
51
|
+
* Memory: the caller owns the document; yeptris_document_free releases
|
|
52
|
+
* everything in one call. */
|
|
53
|
+
YEPTRIS_API YeptrisDocument yeptris_cbor_decode(const void* buf, size_t len, uint32_t opts,
|
|
54
|
+
YeptrisStatus* status);
|
|
55
|
+
|
|
56
|
+
/* CBOR Sequences (RFC 8742): top-level data items, concatenated —
|
|
57
|
+
* no framing bytes. Iterates the buffer, one document per item; the
|
|
58
|
+
* callback OWNS each item (free it with yeptris_document_free) and
|
|
59
|
+
* its nonzero return aborts the iteration. Returns the item count
|
|
60
|
+
* delivered so far. An empty sequence is valid (0 items). A truncated
|
|
61
|
+
* or malformed trailing item fails YEPTRIS_ERROR_PARSE with the item
|
|
62
|
+
* index and byte offset on the error channel. opts: decode flags. */
|
|
63
|
+
typedef int (*yeptris_cbor_item_cb)(void* ctx, YeptrisDocument item, size_t index);
|
|
64
|
+
YEPTRIS_API size_t yeptris_cbor_decode_sequence(const void* buf, size_t len, uint32_t opts,
|
|
65
|
+
yeptris_cbor_item_cb cb, void* ctx,
|
|
66
|
+
YeptrisStatus* status);
|
|
67
|
+
|
|
68
|
+
/* Encodes n documents as a CBOR Sequence: the concatenation of the
|
|
69
|
+
* items (opts as yeptris_cbor_encode_into). buf == NULL: the exact
|
|
70
|
+
* byte count. Otherwise writes at most cap and returns the count; a
|
|
71
|
+
* too-small cap writes nothing and returns the need. Returns 0 on a
|
|
72
|
+
* NULL items entry or an unencodable document. */
|
|
73
|
+
YEPTRIS_API size_t yeptris_cbor_encode_sequence_into(YeptrisDocument* items, size_t n,
|
|
74
|
+
uint32_t opts, void* buf, size_t cap);
|
|
75
|
+
|
|
76
|
+
/* Convenience: the sequence in a malloc'd buffer — caller frees. */
|
|
77
|
+
YEPTRIS_API void* yeptris_cbor_encode_sequence(YeptrisDocument* items, size_t n, uint32_t opts,
|
|
78
|
+
size_t* len);
|
|
79
|
+
|
|
80
|
+
/* Encodes the document's first root as ONE data item (sequences are a
|
|
81
|
+
* separate surface). buf == NULL: returns the exact byte count needed.
|
|
82
|
+
* Otherwise writes at most cap bytes and returns the count written; a
|
|
83
|
+
* too-small cap writes nothing and returns the needed size. Returns 0
|
|
84
|
+
* on a NULL document or an unencodable one (aliases, non-decimal tag
|
|
85
|
+
* text, non-numeric INT/FLOAT text) — yeptris_last_error() says why.
|
|
86
|
+
*
|
|
87
|
+
* Canonical opts sort map keys (s4.2.1); without it, insertion order.
|
|
88
|
+
* encode(decode(x)) is byte-stable across repeated calls. */
|
|
89
|
+
YEPTRIS_API size_t yeptris_cbor_encode_into(YeptrisDocument doc, uint32_t opts, void* buf,
|
|
90
|
+
size_t cap);
|
|
91
|
+
|
|
92
|
+
/* Convenience: encodes into a malloc'd buffer — caller frees with
|
|
93
|
+
* free(). Returns NULL on failure; *len (may be NULL) receives the
|
|
94
|
+
* byte count. */
|
|
95
|
+
YEPTRIS_API void* yeptris_cbor_encode(YeptrisDocument doc, uint32_t opts, size_t* len);
|
|
96
|
+
|
|
97
|
+
#ifdef __cplusplus
|
|
98
|
+
}
|
|
99
|
+
#endif
|
|
100
|
+
|
|
101
|
+
#endif /* YEPTRIS_CBOR_H */
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/* document.h / node.h surface — DOM accessors (TODO.impl/11).
|
|
2
|
+
* Pinned enums: bindings hard-code these values (test_abi). */
|
|
3
|
+
|
|
4
|
+
#ifndef YEPTRIS_DOM_PUBLIC_H
|
|
5
|
+
#define YEPTRIS_DOM_PUBLIC_H
|
|
6
|
+
|
|
7
|
+
#include <stddef.h>
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
|
|
10
|
+
#include <yeptris/api.h>
|
|
11
|
+
#include <yeptris/error.h>
|
|
12
|
+
#include <yeptris/types.h>
|
|
13
|
+
|
|
14
|
+
#ifdef __cplusplus
|
|
15
|
+
extern "C" {
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
typedef enum {
|
|
19
|
+
YEPTRIS_NODE_SCALAR = 0,
|
|
20
|
+
YEPTRIS_NODE_SEQUENCE = 1,
|
|
21
|
+
YEPTRIS_NODE_MAPPING = 2,
|
|
22
|
+
YEPTRIS_NODE_ALIAS = 3,
|
|
23
|
+
} YeptrisNodeKind;
|
|
24
|
+
|
|
25
|
+
typedef enum {
|
|
26
|
+
YEPTRIS_STYLE_ANY = 0,
|
|
27
|
+
YEPTRIS_STYLE_PLAIN = 1,
|
|
28
|
+
YEPTRIS_STYLE_SINGLE_QUOTED = 2,
|
|
29
|
+
YEPTRIS_STYLE_DOUBLE_QUOTED = 3,
|
|
30
|
+
YEPTRIS_STYLE_LITERAL = 4,
|
|
31
|
+
YEPTRIS_STYLE_FOLDED = 5,
|
|
32
|
+
} YeptrisScalarStyle;
|
|
33
|
+
|
|
34
|
+
/* Releases the document and everything reachable from it (one call).
|
|
35
|
+
* Handles are invalid afterwards. NULL is accepted. */
|
|
36
|
+
YEPTRIS_API void yeptris_document_free(YeptrisDocument doc);
|
|
37
|
+
|
|
38
|
+
/* Number of documents in the parsed stream. */
|
|
39
|
+
YEPTRIS_API size_t yeptris_document_count(YeptrisDocument doc);
|
|
40
|
+
|
|
41
|
+
/* Root node of document i (0-based); NULL when out of range. */
|
|
42
|
+
YEPTRIS_API YeptrisNode yeptris_document_root(YeptrisDocument doc, size_t index);
|
|
43
|
+
|
|
44
|
+
YEPTRIS_API YeptrisNodeKind yeptris_node_kind(YeptrisNode node);
|
|
45
|
+
|
|
46
|
+
/* Stable identity of the node within its document (bindings key
|
|
47
|
+
* wrapper caches on it; query handles are transient, ids are not).
|
|
48
|
+
* Only for equality — not an index into any public structure. */
|
|
49
|
+
YEPTRIS_API uint32_t yeptris_node_id(YeptrisNode node);
|
|
50
|
+
|
|
51
|
+
/* Scalar content / alias name. Returns NULL for collections.
|
|
52
|
+
* Memory: borrowed from the input (or document-owned when the value was
|
|
53
|
+
* folded/escaped) — valid until yeptris_document_free. */
|
|
54
|
+
YEPTRIS_API const char* yeptris_node_value(YeptrisNode node, size_t* len);
|
|
55
|
+
|
|
56
|
+
YEPTRIS_API YeptrisScalarStyle yeptris_node_style(YeptrisNode node);
|
|
57
|
+
|
|
58
|
+
/* Node properties; empty (NULL, 0) when absent. */
|
|
59
|
+
YEPTRIS_API const char* yeptris_node_tag(YeptrisNode node, size_t* len);
|
|
60
|
+
YEPTRIS_API const char* yeptris_node_anchor(YeptrisNode node, size_t* len);
|
|
61
|
+
|
|
62
|
+
/* Alias target node; NULL for non-aliases. */
|
|
63
|
+
YEPTRIS_API YeptrisNode yeptris_node_alias_target(YeptrisNode node);
|
|
64
|
+
|
|
65
|
+
/* Sequence entry count / entry i. */
|
|
66
|
+
YEPTRIS_API size_t yeptris_node_seq_count(YeptrisNode node);
|
|
67
|
+
YEPTRIS_API YeptrisNode yeptris_node_seq_at(YeptrisNode node, size_t index);
|
|
68
|
+
|
|
69
|
+
/* Mapping pair count / value for a key (linear; interning lands with the
|
|
70
|
+
* full DOM item). The first matching key wins. */
|
|
71
|
+
YEPTRIS_API size_t yeptris_node_map_count(YeptrisNode node);
|
|
72
|
+
YEPTRIS_API YeptrisNode yeptris_node_map_get(YeptrisNode node, const char* key, size_t key_len);
|
|
73
|
+
|
|
74
|
+
/* Ordered pair access: key and value of pair i (0-based). Returns 0
|
|
75
|
+
* and sets the out-params when the index is in range, -1 otherwise. */
|
|
76
|
+
YEPTRIS_API int yeptris_node_map_at(YeptrisNode node, size_t index, YeptrisNode* key,
|
|
77
|
+
YeptrisNode* value);
|
|
78
|
+
|
|
79
|
+
/* ---- Construction (TODO.impl/11 phase 3) ----
|
|
80
|
+
*
|
|
81
|
+
* Build documents from scratch and mutate them; the emitter and every
|
|
82
|
+
* query API above work on synthesized documents unchanged. All values
|
|
83
|
+
* are COPIED into the document — nothing is borrowed from the caller.
|
|
84
|
+
* Nodes belong to exactly one parent (or one document root); a node
|
|
85
|
+
* already attached, a duplicate map key (add), cross-document links,
|
|
86
|
+
* and trees deeper than the nesting cap (YEPTRIS_ERROR_DEPTH) are
|
|
87
|
+
* rejected. Deletion unlinks but keeps arena lifetime: handles stay
|
|
88
|
+
* valid until yeptris_document_free. */
|
|
89
|
+
|
|
90
|
+
/* An empty document with no input; build nodes and set the root. */
|
|
91
|
+
YEPTRIS_API YeptrisDocument yeptris_document_new(void);
|
|
92
|
+
|
|
93
|
+
/* Records a detached node as document i's root. */
|
|
94
|
+
YEPTRIS_API int yeptris_document_set_root(YeptrisDocument doc, YeptrisNode root);
|
|
95
|
+
|
|
96
|
+
YEPTRIS_API YeptrisNode yeptris_node_new_mapping(YeptrisDocument doc);
|
|
97
|
+
YEPTRIS_API YeptrisNode yeptris_node_new_sequence(YeptrisDocument doc);
|
|
98
|
+
|
|
99
|
+
/* Memory: value copied (document lifetime). Plain style types the copy
|
|
100
|
+
* through the schema resolver exactly like parse; quoted/block styles
|
|
101
|
+
* force string. */
|
|
102
|
+
YEPTRIS_API YeptrisNode yeptris_node_new_scalar(YeptrisDocument doc, const char* value, size_t len,
|
|
103
|
+
YeptrisScalarStyle style);
|
|
104
|
+
|
|
105
|
+
/* YEPTRIS_OK, or ERROR_ARG (cross-document/detached misuse),
|
|
106
|
+
* ERROR_MEMORY, ERROR_DEPTH, ERROR_PARSE (duplicate key). */
|
|
107
|
+
YEPTRIS_API int yeptris_node_map_add(YeptrisNode map, const char* key, size_t key_len,
|
|
108
|
+
YeptrisNode value);
|
|
109
|
+
|
|
110
|
+
/* Replace-or-add: an existing key keeps its position and swaps the
|
|
111
|
+
* value; a new key appends. */
|
|
112
|
+
YEPTRIS_API int yeptris_node_map_set(YeptrisNode map, const char* key, size_t key_len,
|
|
113
|
+
YeptrisNode value);
|
|
114
|
+
|
|
115
|
+
YEPTRIS_API int yeptris_node_seq_add(YeptrisNode seq, YeptrisNode value);
|
|
116
|
+
YEPTRIS_API int yeptris_node_seq_del(YeptrisNode seq, size_t index);
|
|
117
|
+
|
|
118
|
+
/* Replace the entry at index (same position kept). */
|
|
119
|
+
YEPTRIS_API int yeptris_node_seq_set(YeptrisNode seq, size_t index, YeptrisNode value);
|
|
120
|
+
YEPTRIS_API int yeptris_node_map_del(YeptrisNode map, const char* key, size_t key_len);
|
|
121
|
+
|
|
122
|
+
/* ---- bulk build (TODO.impl/15 phase D: the dump-side mirror of the
|
|
123
|
+
* recorder's bulk drain — ONE call builds a whole document, so
|
|
124
|
+
* bindings never pay per-node FFI) ------------------------------------- */
|
|
125
|
+
|
|
126
|
+
typedef enum {
|
|
127
|
+
YEPTRIS_BUILD_SCALAR = 1, /* push a scalar (value bytes in the blob) */
|
|
128
|
+
YEPTRIS_BUILD_SEQ = 2, /* open a sequence */
|
|
129
|
+
YEPTRIS_BUILD_MAP = 3, /* open a mapping */
|
|
130
|
+
YEPTRIS_BUILD_END = 4, /* close the innermost open container */
|
|
131
|
+
YEPTRIS_BUILD_TAG = 5, /* tag the last-placed node (tag bytes in
|
|
132
|
+
* the blob) — #300: nil mapping keys need
|
|
133
|
+
* Psych's explicit `!` tag */
|
|
134
|
+
} YeptrisBuildOp;
|
|
135
|
+
|
|
136
|
+
/* 12 bytes, ABI-pinned: op, style (scalar: YeptrisScalarStyle;
|
|
137
|
+
* ignored for containers), reserved, then the value slice. */
|
|
138
|
+
typedef struct {
|
|
139
|
+
uint8_t op;
|
|
140
|
+
uint8_t style;
|
|
141
|
+
uint16_t reserved;
|
|
142
|
+
uint32_t off;
|
|
143
|
+
uint32_t len;
|
|
144
|
+
} YeptrisBuildEntry;
|
|
145
|
+
#if defined(__cplusplus)
|
|
146
|
+
static_assert(sizeof(YeptrisBuildEntry) == 12, "build entry layout pinned");
|
|
147
|
+
#else
|
|
148
|
+
_Static_assert(sizeof(YeptrisBuildEntry) == 12, "build entry layout pinned");
|
|
149
|
+
#endif
|
|
150
|
+
|
|
151
|
+
/* Walks the entries in order — the same document-order grammar as the
|
|
152
|
+
* event stream: scalars link into the innermost open container (in a
|
|
153
|
+
* mapping, entries alternate key/value), SEQ/MAP open a child
|
|
154
|
+
* container, END closes it; after the last entry exactly one root
|
|
155
|
+
* must remain open-free and becomes the document root. Scalars copy
|
|
156
|
+
* their bytes from the blob (nothing is borrowed). Duplicate keys
|
|
157
|
+
* keep the LAST value, exactly as the parser accepts them (host
|
|
158
|
+
* mappings cannot produce one; the check would cost O(n^2) on wide
|
|
159
|
+
* maps). Returns YEPTRIS_OK, ERROR_ARG (NULL inputs),
|
|
160
|
+
* ERROR_PARSE (imbalanced walk: END on an empty stack, entries after
|
|
161
|
+
* the root closed, an unclosed container, a dangling key, a bad op
|
|
162
|
+
* or out-of-range slice), ERROR_DEPTH, or ERROR_MEMORY. */
|
|
163
|
+
YEPTRIS_API YeptrisStatus yeptris_document_build(YeptrisDocument doc,
|
|
164
|
+
const YeptrisBuildEntry* entries, size_t count,
|
|
165
|
+
const char* blob, size_t blob_len);
|
|
166
|
+
|
|
167
|
+
/* Appends a pre-built key node (duplicate rejected). */
|
|
168
|
+
YEPTRIS_API int yeptris_node_map_add_node(YeptrisNode map, YeptrisNode key, YeptrisNode value);
|
|
169
|
+
|
|
170
|
+
/* Props on synthesized nodes (copied in). An alias node carries its
|
|
171
|
+
* display name and resolves to `target` for queries/serialization. */
|
|
172
|
+
YEPTRIS_API int yeptris_node_set_anchor(YeptrisNode node, const char* name, size_t len);
|
|
173
|
+
YEPTRIS_API int yeptris_node_set_tag(YeptrisNode node, const char* tag, size_t len);
|
|
174
|
+
YEPTRIS_API YeptrisNode yeptris_node_new_alias(YeptrisDocument doc, YeptrisNode target,
|
|
175
|
+
const char* name, size_t len);
|
|
176
|
+
|
|
177
|
+
#ifdef __cplusplus
|
|
178
|
+
}
|
|
179
|
+
#endif
|
|
180
|
+
|
|
181
|
+
#endif /* YEPTRIS_DOM_PUBLIC_H */
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* emit.h — serialization (TODO.impl/13).
|
|
2
|
+
*
|
|
3
|
+
* One writer engine serves DOM walks and (with 13C) event streams;
|
|
4
|
+
* sizing runs the SAME engine dry, so the size query and the write
|
|
5
|
+
* agree by construction — zero reallocations after the reserve.
|
|
6
|
+
*
|
|
7
|
+
* Roundtrip fidelity: re-serializing a parsed document re-emits its
|
|
8
|
+
* recorded scalar styles (a plain stays plain where safe, quoted stays
|
|
9
|
+
* quoted, block scalars stay block). Byte stability:
|
|
10
|
+
* serialize(parse(serialize(x))) == serialize(x) — gated by the
|
|
11
|
+
* corpus roundtrip test.
|
|
12
|
+
*/
|
|
13
|
+
#ifndef YEPTRIS_EMIT_H
|
|
14
|
+
#define YEPTRIS_EMIT_H
|
|
15
|
+
|
|
16
|
+
#include <stddef.h>
|
|
17
|
+
#include <stdint.h>
|
|
18
|
+
|
|
19
|
+
#include <yeptris/api.h>
|
|
20
|
+
#include <yeptris/types.h>
|
|
21
|
+
|
|
22
|
+
#ifdef __cplusplus
|
|
23
|
+
extern "C" {
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
/* Emission options (13B). Versioned by size: initialize with
|
|
27
|
+
* {sizeof(yeptris_emit_options)} so future fields stay optional. */
|
|
28
|
+
typedef struct yeptris_emit_options {
|
|
29
|
+
uint32_t size; /* sizeof(yeptris_emit_options) */
|
|
30
|
+
int canonical; /* fixed form: flow collections, quoted strings,
|
|
31
|
+
* typed words, shortest floats; a parse of the
|
|
32
|
+
* output re-serializes byte-identically */
|
|
33
|
+
int best_width; /* 0 = library default (80): flow collections
|
|
34
|
+
* wrap after a value when the current line
|
|
35
|
+
* exceeds the width (13B) */
|
|
36
|
+
int explicit_doc_start; /* nonzero: every document carries the
|
|
37
|
+
* leading --- marker (Psych/libyaml's
|
|
38
|
+
* implicit=false parity). Default 0: a
|
|
39
|
+
* single document is emitted bare. Only
|
|
40
|
+
* read when the caller's struct is large
|
|
41
|
+
* enough (size-versioned). */
|
|
42
|
+
} yeptris_emit_options;
|
|
43
|
+
|
|
44
|
+
/* Options-aware entries; opts == NULL selects the fidelity mode
|
|
45
|
+
* (recorded styles re-emitted). Same contracts as below. */
|
|
46
|
+
YEPTRIS_API size_t yeptris_serialize_into_ex(YeptrisDocument doc, const yeptris_emit_options* opts,
|
|
47
|
+
char* buf, size_t cap);
|
|
48
|
+
YEPTRIS_API char* yeptris_serialize_ex(YeptrisDocument doc, const yeptris_emit_options* opts,
|
|
49
|
+
size_t* len);
|
|
50
|
+
|
|
51
|
+
/* Serializes the document set. buf == NULL: returns the exact byte
|
|
52
|
+
* count needed and writes nothing. Otherwise writes at most cap bytes
|
|
53
|
+
* (NUL-terminated when cap allows) and returns the count written;
|
|
54
|
+
* when cap is too small nothing is written and the needed size is
|
|
55
|
+
* returned. Returns 0 on a NULL document. */
|
|
56
|
+
YEPTRIS_API size_t yeptris_serialize_into(YeptrisDocument doc, char* buf, size_t cap);
|
|
57
|
+
|
|
58
|
+
/* Streaming emission (13C): bytes are delivered in chunks to sink as
|
|
59
|
+
* the walk proceeds — memory bounded by the largest scalar, never the
|
|
60
|
+
* document. Returns the total byte count, or 0 on a NULL argument or
|
|
61
|
+
* when the sink aborts (nonzero return aborts the walk). */
|
|
62
|
+
typedef int (*yeptris_emit_sink)(void* ctx, const char* bytes, size_t len);
|
|
63
|
+
YEPTRIS_API size_t yeptris_serialize_stream(YeptrisDocument doc, const yeptris_emit_options* opts,
|
|
64
|
+
yeptris_emit_sink sink, void* ctx);
|
|
65
|
+
|
|
66
|
+
/* Convenience: serializes into a malloc'd buffer (caller frees).
|
|
67
|
+
* Returns NULL on allocation failure or a NULL document; *len (may be
|
|
68
|
+
* NULL) receives the byte count. The buffer is NUL-terminated. */
|
|
69
|
+
YEPTRIS_API char* yeptris_serialize(YeptrisDocument doc, size_t* len);
|
|
70
|
+
|
|
71
|
+
/* Frees a buffer the library returned (the serialize* family's
|
|
72
|
+
* "caller frees" contract). The buffer was allocated by THIS
|
|
73
|
+
* library's allocator — freeing it with the host's free is
|
|
74
|
+
* wrong-CRT on Windows (the #318 mingw lesson). NULL is a no-op. */
|
|
75
|
+
YEPTRIS_API void yeptris_free(void* p);
|
|
76
|
+
|
|
77
|
+
#ifdef __cplusplus
|
|
78
|
+
}
|
|
79
|
+
#endif
|
|
80
|
+
|
|
81
|
+
#endif /* YEPTRIS_EMIT_H */
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* error.h — public status codes.
|
|
2
|
+
*
|
|
3
|
+
* Public entry points write only these codes (the internal error channel —
|
|
4
|
+
* thread-local + per-document messages with line/column — lands with
|
|
5
|
+
* TODO.impl/02). Enum values are ABI: bindings hard-code them and the ABI
|
|
6
|
+
* pinning test (test/unit/test_abi.cpp) fails if one shifts without a major
|
|
7
|
+
* version bump.
|
|
8
|
+
*/
|
|
9
|
+
#include <stdint.h>
|
|
10
|
+
|
|
11
|
+
#ifndef YEPTRIS_ERROR_H
|
|
12
|
+
#define YEPTRIS_ERROR_H
|
|
13
|
+
|
|
14
|
+
#ifdef __cplusplus
|
|
15
|
+
extern "C" {
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
typedef enum {
|
|
19
|
+
YEPTRIS_OK = 0, /* success */
|
|
20
|
+
YEPTRIS_ERROR_PARSE = 1, /* malformed YAML (details + line/col via the error channel) */
|
|
21
|
+
YEPTRIS_ERROR_MEMORY = 2, /* allocation failure; document remains freeable */
|
|
22
|
+
YEPTRIS_ERROR_DEPTH = 3, /* nesting exceeds max_depth (default 1000) */
|
|
23
|
+
YEPTRIS_ERROR_ENCODING = 4, /* invalid input encoding / ill-formed UTF-8 */
|
|
24
|
+
YEPTRIS_ERROR_IO = 5, /* caller-supplied I/O failure */
|
|
25
|
+
YEPTRIS_ERROR_ARG = 6, /* invalid argument (NULL handle, bad option) */
|
|
26
|
+
YEPTRIS_ERROR_UNSUPPORTED = 7, /* requested feature not built in */
|
|
27
|
+
YEPTRIS_ERROR_INTERNAL = 8, /* invariant violation — a bug, please report */
|
|
28
|
+
YEPTRIS_ERROR_SCHEMA = 9, /* descriptor materialization: a REQUIRED node missing (issue #238) */
|
|
29
|
+
} YeptrisStatus;
|
|
30
|
+
|
|
31
|
+
/* Message of the most recent failure on the calling thread, with its
|
|
32
|
+
* 1-based line/column (0 = unknown). Returns "" when the last operation
|
|
33
|
+
* succeeded. Memory: thread-local static storage; valid until the next
|
|
34
|
+
* library call on this thread. */
|
|
35
|
+
YEPTRIS_API const char* yeptris_last_error(uint32_t* line, uint32_t* col);
|
|
36
|
+
|
|
37
|
+
#ifdef __cplusplus
|
|
38
|
+
}
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
#endif /* YEPTRIS_ERROR_H */
|