yeptris 0.6.7.3-aarch64-linux → 0.6.7.5-aarch64-linux

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 (114) hide show
  1. checksums.yaml +4 -4
  2. data/lib/yeptris/cbor.rb +114 -0
  3. data/lib/yeptris/ffi.rb +33 -5
  4. data/lib/yeptris/psych/visitors.rb +6 -0
  5. data/lib/yeptris.rb +2 -1
  6. data/vendor/libyeptris/CMakeLists.txt +254 -0
  7. data/vendor/libyeptris/cmake/yeptris-config.cmake.in +5 -0
  8. data/vendor/libyeptris/cmake/yeptris.pc.in +11 -0
  9. data/vendor/libyeptris/src/CMakeLists.txt +167 -0
  10. data/vendor/libyeptris/src/include/yeptris/api.h +32 -0
  11. data/vendor/libyeptris/src/include/yeptris/cbor.h +101 -0
  12. data/vendor/libyeptris/src/include/yeptris/dom.h +181 -0
  13. data/vendor/libyeptris/src/include/yeptris/emit.h +81 -0
  14. data/vendor/libyeptris/src/include/yeptris/error.h +41 -0
  15. data/vendor/libyeptris/src/include/yeptris/events.h +157 -0
  16. data/vendor/libyeptris/src/include/yeptris/json.h +45 -0
  17. data/vendor/libyeptris/src/include/yeptris/json.hpp +258 -0
  18. data/vendor/libyeptris/src/include/yeptris/jsonc_compat.h +115 -0
  19. data/vendor/libyeptris/src/include/yeptris/marshal.h +52 -0
  20. data/vendor/libyeptris/src/include/yeptris/parse.h +48 -0
  21. data/vendor/libyeptris/src/include/yeptris/plan.h +100 -0
  22. data/vendor/libyeptris/src/include/yeptris/resolve.h +71 -0
  23. data/vendor/libyeptris/src/include/yeptris/schema.h +119 -0
  24. data/vendor/libyeptris/src/include/yeptris/tape.h +99 -0
  25. data/vendor/libyeptris/src/include/yeptris/types.h +38 -0
  26. data/vendor/libyeptris/src/include/yeptris/values.h +102 -0
  27. data/vendor/libyeptris/src/include/yeptris/version.h.in +29 -0
  28. data/vendor/libyeptris/src/include/yeptris/visit.h +77 -0
  29. data/vendor/libyeptris/src/include/yeptris/yajl_compat.h +135 -0
  30. data/vendor/libyeptris/src/include/yeptris.h +23 -0
  31. data/vendor/libyeptris/src/yeptris/build.c +371 -0
  32. data/vendor/libyeptris/src/yeptris/cbor/cbor.h +25 -0
  33. data/vendor/libyeptris/src/yeptris/cbor/decode.c +846 -0
  34. data/vendor/libyeptris/src/yeptris/cbor/encode.c +821 -0
  35. data/vendor/libyeptris/src/yeptris/common/chartype.c +41 -0
  36. data/vendor/libyeptris/src/yeptris/common/chartype.h +77 -0
  37. data/vendor/libyeptris/src/yeptris/common/cpu.c +81 -0
  38. data/vendor/libyeptris/src/yeptris/common/cpu.h +40 -0
  39. data/vendor/libyeptris/src/yeptris/common/error.c +65 -0
  40. data/vendor/libyeptris/src/yeptris/common/error.h +79 -0
  41. data/vendor/libyeptris/src/yeptris/common/mutex.h +45 -0
  42. data/vendor/libyeptris/src/yeptris/common/nametab.c +275 -0
  43. data/vendor/libyeptris/src/yeptris/common/nametab.h +68 -0
  44. data/vendor/libyeptris/src/yeptris/common/port.h +74 -0
  45. data/vendor/libyeptris/src/yeptris/common/simd_text.c +46 -0
  46. data/vendor/libyeptris/src/yeptris/common/simd_text.h +295 -0
  47. data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +534 -0
  48. data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +662 -0
  49. data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +298 -0
  50. data/vendor/libyeptris/src/yeptris/common/string_view.c +34 -0
  51. data/vendor/libyeptris/src/yeptris/common/string_view.h +93 -0
  52. data/vendor/libyeptris/src/yeptris/doc.h +37 -0
  53. data/vendor/libyeptris/src/yeptris/dom/dom.c +973 -0
  54. data/vendor/libyeptris/src/yeptris/dom/dom.h +290 -0
  55. data/vendor/libyeptris/src/yeptris/dom/hpool.c +107 -0
  56. data/vendor/libyeptris/src/yeptris/dom/mapindex.c +166 -0
  57. data/vendor/libyeptris/src/yeptris/dom/mapindex.h +61 -0
  58. data/vendor/libyeptris/src/yeptris/dom/mutate.c +429 -0
  59. data/vendor/libyeptris/src/yeptris/emit/emit.c +349 -0
  60. data/vendor/libyeptris/src/yeptris/emit/float/api.h +38 -0
  61. data/vendor/libyeptris/src/yeptris/emit/float/dragon.c +405 -0
  62. data/vendor/libyeptris/src/yeptris/emit/float/floatint.h +196 -0
  63. data/vendor/libyeptris/src/yeptris/emit/float/print.c +396 -0
  64. data/vendor/libyeptris/src/yeptris/emit/style.c +81 -0
  65. data/vendor/libyeptris/src/yeptris/emit/style.h +24 -0
  66. data/vendor/libyeptris/src/yeptris/emit/writer.c +746 -0
  67. data/vendor/libyeptris/src/yeptris/emit/writer.h +61 -0
  68. data/vendor/libyeptris/src/yeptris/encoding/bom.c +31 -0
  69. data/vendor/libyeptris/src/yeptris/encoding/encoding.h +63 -0
  70. data/vendor/libyeptris/src/yeptris/encoding/transcode.c +148 -0
  71. data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +178 -0
  72. data/vendor/libyeptris/src/yeptris/events/capture.c +150 -0
  73. data/vendor/libyeptris/src/yeptris/events/capture.h +39 -0
  74. data/vendor/libyeptris/src/yeptris/events/iterparse.c +208 -0
  75. data/vendor/libyeptris/src/yeptris/events/pull.c +97 -0
  76. data/vendor/libyeptris/src/yeptris/events/push.c +104 -0
  77. data/vendor/libyeptris/src/yeptris/events/recorder.c +107 -0
  78. data/vendor/libyeptris/src/yeptris/events/values.c +527 -0
  79. data/vendor/libyeptris/src/yeptris/events/values_priv.h +51 -0
  80. data/vendor/libyeptris/src/yeptris/events/yaml_compat.c +86 -0
  81. data/vendor/libyeptris/src/yeptris/events/yaml_compat.h +90 -0
  82. data/vendor/libyeptris/src/yeptris/jsonapi/jsonc_compat.c +687 -0
  83. data/vendor/libyeptris/src/yeptris/jsonapi/yajl_compat.c +728 -0
  84. data/vendor/libyeptris/src/yeptris/marshal.c +744 -0
  85. data/vendor/libyeptris/src/yeptris/memory/allocator.c +20 -0
  86. data/vendor/libyeptris/src/yeptris/memory/allocator.h +43 -0
  87. data/vendor/libyeptris/src/yeptris/memory/arena.c +134 -0
  88. data/vendor/libyeptris/src/yeptris/memory/arena.h +52 -0
  89. data/vendor/libyeptris/src/yeptris/memory/pool.c +115 -0
  90. data/vendor/libyeptris/src/yeptris/memory/pool.h +36 -0
  91. data/vendor/libyeptris/src/yeptris/parse/engine.c +3689 -0
  92. data/vendor/libyeptris/src/yeptris/parse/engine.h +65 -0
  93. data/vendor/libyeptris/src/yeptris/parse/events.h +124 -0
  94. data/vendor/libyeptris/src/yeptris/parse/numbers.c +349 -0
  95. data/vendor/libyeptris/src/yeptris/parse/numbers.h +33 -0
  96. data/vendor/libyeptris/src/yeptris/parse/scalars.c +416 -0
  97. data/vendor/libyeptris/src/yeptris/parse/scalars.h +75 -0
  98. data/vendor/libyeptris/src/yeptris/parse.c +650 -0
  99. data/vendor/libyeptris/src/yeptris/plan.c +817 -0
  100. data/vendor/libyeptris/src/yeptris/resolve/compat11.c +334 -0
  101. data/vendor/libyeptris/src/yeptris/resolve/core12.c +143 -0
  102. data/vendor/libyeptris/src/yeptris/resolve/resolver.h +56 -0
  103. data/vendor/libyeptris/src/yeptris/resolve/tags.c +58 -0
  104. data/vendor/libyeptris/src/yeptris/scan/json.c +792 -0
  105. data/vendor/libyeptris/src/yeptris/scan/json.h +109 -0
  106. data/vendor/libyeptris/src/yeptris/scan/scan.c +463 -0
  107. data/vendor/libyeptris/src/yeptris/scan/scan.h +150 -0
  108. data/vendor/libyeptris/src/yeptris/schema.c +238 -0
  109. data/vendor/libyeptris/src/yeptris/tape.c +1292 -0
  110. data/vendor/libyeptris/src/yeptris/version.c +7 -0
  111. data/vendor/libyeptris/src/yeptris/visit/dom_visit.c +115 -0
  112. data/vendor/libyeptris/src/yeptris/visit/json_visit.c +293 -0
  113. data/vendor/libyeptris/src/yeptris/visit/yaml_visit.c +127 -0
  114. metadata +111 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2b1a73208a110633e793944db18644b1c62638deb1371591bc6c9e956fb00b3
4
- data.tar.gz: 10d74f98b0969df6236720be0a826b4f15f2c620409d039d9091bde036851760
3
+ metadata.gz: 0b7d5fc414b1459a5bd7507b2cc3f4dc308efd75010d82f132bd7da078c3e999
4
+ data.tar.gz: a27ba76d7a111dd8902ff058e1a26cadd05c3cfa921034bcab70bbad48deff0f
5
5
  SHA512:
6
- metadata.gz: f6a16dac27fcdb4e984d6441118094f85ab72c61bdc9c1fae81dedc523d241a78d3d8e4e53014a8eabda63e56b9219ab27c8b7a27010a4422fc831fb5f639f4e
7
- data.tar.gz: f26d6a62827dd6ed440d4e2686137fc18fba15dc954e14fee1d735f5415a9428914e178f24399c63e5693e8e4fe595e4f1165c60f05b2f25896c184f2e68ddb2
6
+ metadata.gz: 86c23e8e229b87eff443d7e2be1cc16ad57b07a80b8edf5feb7a757e4b611aff34822c78eca5548c72e7eb42a1895f3023b4a50948147e654cb119003ad21a57
7
+ data.tar.gz: 75ef4719add9a892912352792c0fd8e28347a079ccfee167b1520082d77c1d7a17d83baa593024d2c1b03d8ff0e2d9881f85e6dd1ec56dd00a8606fa25dcaf6f
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yeptris
4
+ # CBOR (RFC 8949) over the same FFI document the rest of the
5
+ # binding rides (TODO.cbor/04). Decode materializes through the
6
+ # Psych-compatible path; encode builds the tree with YAMLTree and
7
+ # hands the document to the C encoder — plain data only (aliases
8
+ # and non-decimal tag text are unencodable by the C contract).
9
+ #
10
+ # Representation notes inherited from the decoder: integers beyond
11
+ # int64 and bignums materialize as their shortest-double text, byte
12
+ # strings as tag-chained text — CBOR's JSON-data-model mapping.
13
+ module CBOR
14
+ STRICT = (1 << 0) # decode: reject non-minimal arguments
15
+ CANONICAL = (1 << 1) # encode: s4.2.1 core deterministic profile
16
+
17
+ class Error < Yeptris::Error; end
18
+ class UnencodableError < Error; end
19
+
20
+ module_function
21
+
22
+ def available?
23
+ defined?(::Yeptris::FFI::CBOR_EX) && ::Yeptris::FFI::CBOR_EX
24
+ end
25
+
26
+ def load(data, strict: false)
27
+ raise Error, "libyeptris has no CBOR support" unless available?
28
+
29
+ doc_ptr = ::Yeptris::FFI.yeptris_cbor_decode(data, data.bytesize, strict ? STRICT : 0, nil)
30
+ raise ParseError, ::Yeptris::FFI.last_error_message if doc_ptr.null?
31
+
32
+ # the wrapper's finalizer also frees — its idempotent #free is
33
+ # the ONLY release path (a raw double free corrupts the heap)
34
+ doc = ::Yeptris::Document.new(doc_ptr)
35
+ doc.root.to_ruby
36
+ ensure
37
+ doc&.free
38
+ end
39
+
40
+ def load_sequence(data, strict: false)
41
+ raise Error, "libyeptris has no CBOR support" unless available?
42
+
43
+ items = []
44
+ receiver = ::FFI::Function.new(:int, %i[pointer pointer size_t]) do |_ctx, item, _index|
45
+ # the callback owns the item; materialize then free in place
46
+ # (through the wrapper — the finalizer frees too)
47
+ doc = ::Yeptris::Document.new(item)
48
+ items << doc.root&.to_ruby
49
+ doc.free
50
+ 0
51
+ end
52
+ st = ::Yeptris::FFI.yeptris_cbor_decode_sequence(
53
+ data, data.bytesize, strict ? STRICT : 0, receiver, nil, nil
54
+ )
55
+ raise ParseError, ::Yeptris::FFI.last_error_message if st.zero? && !data.empty?
56
+
57
+ items
58
+ end
59
+
60
+ def dump(obj, canonical: true)
61
+ docs = build_documents([obj])
62
+ begin
63
+ encode_one(docs[0], canonical)
64
+ ensure
65
+ docs.each(&:free)
66
+ end
67
+ end
68
+
69
+ def dump_sequence(objects, canonical: true)
70
+ docs = build_documents(objects)
71
+ begin
72
+ opts = canonical ? CANONICAL : 0
73
+ arr = ::FFI::MemoryPointer.new(:pointer, docs.size)
74
+ arr.write_array_of_pointer(docs.map(&:c_ptr))
75
+ len_ptr = ::FFI::MemoryPointer.new(:size_t)
76
+ take_buffer(
77
+ ::Yeptris::FFI.yeptris_cbor_encode_sequence(arr, docs.size, opts, len_ptr),
78
+ len_ptr
79
+ )
80
+ ensure
81
+ docs.each(&:free)
82
+ end
83
+ end
84
+
85
+ # -- internals ----------------------------------------------------
86
+
87
+ def build_documents(objects)
88
+ # ONE document per object: a visitor's tree is a single
89
+ # document and push sets its root — reuse would overwrite
90
+ objects.map do |obj|
91
+ visitor = ::Yeptris::Psych::Visitors::YAMLTree.new
92
+ visitor.push(obj)
93
+ visitor.document
94
+ end
95
+ end
96
+
97
+ def encode_one(doc, canonical)
98
+ opts = canonical ? CANONICAL : 0
99
+ len_ptr = ::FFI::MemoryPointer.new(:size_t)
100
+ take_buffer(::Yeptris::FFI.yeptris_cbor_encode(doc.c_ptr, opts, len_ptr), len_ptr)
101
+ end
102
+
103
+ # The encode convenience contract: a malloc'd buffer plus its
104
+ # byte length — binary data, freed through the library's own free.
105
+ def take_buffer(ptr, len_ptr)
106
+ raise UnencodableError, ::Yeptris::FFI.last_error_message if ptr.null?
107
+
108
+ len = len_ptr.read_uint64
109
+ ptr.read_bytes(len).force_encoding(Encoding::BINARY)
110
+ ensure
111
+ ::Yeptris::FFI.yeptris_free(ptr) if ptr && !ptr.null?
112
+ end
113
+ end
114
+ end
data/lib/yeptris/ffi.rb CHANGED
@@ -230,17 +230,45 @@ module Yeptris
230
230
  false
231
231
  end
232
232
 
233
+ # CBOR (RFC 8949, TODO.cbor): absent on libraries before the
234
+ # codec's release — the CBOR module feature-detects
235
+ CBOR_EX = begin
236
+ attach_function :yeptris_cbor_decode, %i[pointer size_t uint32 yeptris_status_out],
237
+ :yeptris_document
238
+ callback :cbor_item_cb, %i[pointer yeptris_document size_t], :int
239
+ attach_function :yeptris_cbor_decode_sequence,
240
+ %i[pointer size_t uint32 cbor_item_cb pointer yeptris_status_out], :size_t
241
+ attach_function :yeptris_cbor_encode, %i[yeptris_document uint32 pointer], :pointer
242
+ attach_function :yeptris_cbor_encode_sequence,
243
+ %i[pointer size_t uint32 pointer], :pointer
244
+ true
245
+ rescue ::FFI::NotFoundError
246
+ false
247
+ end
248
+
233
249
  # Owned char* results (serialize*): one reader, freed exactly once.
234
250
  # The release goes through yeptris_free (libyeptris's own
235
251
  # allocator-matching free) because ffi's :free attach has no
236
252
  # Windows process-symbol fallback — libyeptris.dll doesn't export
237
253
  # libc free, so resolving :free against it fails on Windows.
238
- begin
254
+ # A raised attach ABORTS this file mid-evaluation — everything
255
+ # after it (NODE_SCALAR and the kind constants below) never
256
+ # defines, and a lazily autoloaded node.rb then dies with
257
+ # 'uninitialized constant' (#138). Every fallback attaches too.
258
+ YEPTRIS_FREE = begin
239
259
  attach_function :yeptris_free, [:pointer], :void
260
+ :direct
240
261
  rescue ::FFI::NotFoundError
241
- # libyeptris < v0.6.6: POSIX resolves :free through the process
242
- # symbol table, so the direct libc attach still works there.
243
- attach_function :yeptris_free, :free, [:pointer], :void
262
+ begin
263
+ # libyeptris < v0.6.6: POSIX resolves :free through the
264
+ # process symbol table, so the libc attach still works there.
265
+ attach_function :yeptris_free, :free, [:pointer], :void
266
+ :libc
267
+ rescue ::FFI::NotFoundError
268
+ # no owned-buffer release on this lib+platform combination;
269
+ # Owned.string leaks instead of killing the whole file
270
+ :none
271
+ end
244
272
  end
245
273
 
246
274
  module Owned
@@ -258,7 +286,7 @@ module Yeptris
258
286
  else
259
287
  ptr.read_string.force_encoding(Encoding::UTF_8)
260
288
  end
261
- ::Yeptris::FFI.yeptris_free(ptr)
289
+ ::Yeptris::FFI.yeptris_free(ptr) if ::Yeptris::FFI::YEPTRIS_FREE != :none
262
290
  s
263
291
  end
264
292
  end
@@ -41,6 +41,12 @@ module Yeptris
41
41
  BuiltDocument.new(@tree)
42
42
  end
43
43
 
44
+ # The raw document (the CBOR encoder consumes the tree
45
+ # directly; #tree wraps it for stdlib's yaml face)
46
+ def document
47
+ @tree
48
+ end
49
+
44
50
  def finish
45
51
  @tree.serialize(explicit_doc_start: true)
46
52
  end
data/lib/yeptris.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Yeptris
4
4
  # The gem's version lives in the parent namespace's file — the last
5
5
  # internal require (yeptris/version) retired with it.
6
- VERSION = "0.6.7.3".freeze
6
+ VERSION = "0.6.7.5".freeze
7
7
  # The error hierarchy lives in THIS file (the parent namespace's
8
8
  # own file): nested constants do not trigger a parent-constant
9
9
  # autoload, and the law forbids internal requires — defining the
@@ -44,6 +44,7 @@ module Yeptris
44
44
  autoload :ValueML, "yeptris/valueml"
45
45
  autoload :Psych, "yeptris/psych"
46
46
  autoload :Schema, "yeptris/schema"
47
+ autoload :CBOR, "yeptris/cbor"
47
48
  end
48
49
 
49
50
  # NOTE (the #318 poisoned-process class): the Psych error-name aliases
@@ -0,0 +1,254 @@
1
+ # yeptris — Ultra-fast YAML 1.2 parser, emitter and streamer in C
2
+ # The YAML counterpart of libleptris. Pure C library with CLI and bindings.
3
+ cmake_minimum_required(VERSION 3.20)
4
+
5
+ project(yeptris
6
+ VERSION 0.6.7
7
+ DESCRIPTION "Ultra-fast YAML 1.2 parser, emitter and streamer in C"
8
+ LANGUAGES C CXX
9
+ )
10
+
11
+ # C11 (the standard question, settled with evidence 2026-09-18): going
12
+ # C99 needs FOUR downgrades, not one — _Static_assert (fixed: the
13
+ # typedef-array YEPTRIS_CT_ASSERT), typedef redefinition (mapindex.c),
14
+ # _Thread_local (the per-thread error channel) and <stdatomics> (the
15
+ # lock-free handle pool). The last two are architecture-critical and
16
+ # absent from MSVC's C99 mode; pthread TLS / lock-based pools would
17
+ # regress the hot paths and weaken the concurrency contract.
18
+ set(CMAKE_C_STANDARD 11)
19
+ set(CMAKE_C_STANDARD_REQUIRED ON)
20
+ set(CMAKE_C_EXTENSIONS OFF)
21
+
22
+ # C++11 standard for tests and benchmarks.
23
+ set(CMAKE_CXX_STANDARD 11)
24
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
25
+ set(CMAKE_CXX_EXTENSIONS OFF)
26
+
27
+ # MSVC (the windows CI leg): the C++ suites use designated initializers
28
+ # (a GCC/Clang extension at C++11; MSVC requires C++20), and the test
29
+ # targets — test_conformance included — need test/compat on the include
30
+ # path for the dirent surface.
31
+ if(MSVC)
32
+ set(CMAKE_CXX_STANDARD 20)
33
+ endif()
34
+
35
+ # MSVC multi-config: one runtime home so ctest -C Release and the CLI
36
+ # smoke find every exe (the per-target default scattered them)
37
+ if(MSVC)
38
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
39
+ endif()
40
+
41
+ # MSVC's default stack is 1 MiB; the Unix builds run on 8 MiB — deep
42
+ # document paths (the depth guard's teardown) measured against the
43
+ # Unix default get the same room here
44
+ if(MSVC)
45
+ add_link_options(/STACK:8388608)
46
+ endif()
47
+
48
+ # ---------------------------------------------------------------- options --
49
+ option(BUILD_TESTING "Build tests" ON)
50
+ option(YEPTRIS_BUILD_CLI "Build the yeptris CLI tool" ON)
51
+ option(YEPTRIS_BUILD_STATIC "Build the static library" ON)
52
+ option(YEPTRIS_BUILD_SHARED "Build the shared library" OFF)
53
+ option(YEPTRIS_BUILD_BENCHMARKS "Build performance benchmarks (TODO.impl/18)" OFF)
54
+ option(YEPTRIS_BUILD_JSONC_COMPAT
55
+ "Build libyeptris-jsonc: the json-c drop-in migration layer (TODO.impl/21)" ON)
56
+ option(YEPTRIS_WITH_CBOR "Build the CBOR (RFC 8949) codec surface" ON)
57
+ option(YEPTRIS_ENABLE_ASAN "Enable AddressSanitizer" OFF)
58
+ option(YEPTRIS_ENABLE_TSAN "Enable ThreadSanitizer (requires all-TSAN build)" OFF)
59
+ option(YEPTRIS_ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer" OFF)
60
+ option(YEPTRIS_ENABLE_FUZZING "Build libFuzzer harnesses (TODO.impl/19; requires clang)" OFF)
61
+ option(YEPTRIS_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)
62
+
63
+ # LTO: ON for Release/RelWithDebInfo by default (libleptris measured
64
+ # 1.3-3.5x on parse paths); override with -DYEPTRIS_ENABLE_LTO=OFF.
65
+ if(NOT DEFINED YEPTRIS_ENABLE_LTO)
66
+ if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
67
+ set(YEPTRIS_ENABLE_LTO_DEFAULT ON)
68
+ else()
69
+ set(YEPTRIS_ENABLE_LTO_DEFAULT OFF)
70
+ endif()
71
+ else()
72
+ set(YEPTRIS_ENABLE_LTO_DEFAULT ${YEPTRIS_ENABLE_LTO})
73
+ endif()
74
+ option(YEPTRIS_ENABLE_LTO "Enable link-time optimization (default ON for Release)" ${YEPTRIS_ENABLE_LTO_DEFAULT})
75
+
76
+ # ------------------------------------------------------------- sanitizers --
77
+ if(YEPTRIS_ENABLE_ASAN AND YEPTRIS_ENABLE_TSAN)
78
+ message(FATAL_ERROR "ASAN and TSAN are mutually exclusive")
79
+ endif()
80
+
81
+ if(YEPTRIS_ENABLE_ASAN)
82
+ add_compile_options(-fsanitize=address -fno-omit-frame-pointer -g)
83
+ add_link_options(-fsanitize=address)
84
+ message(STATUS "AddressSanitizer: ENABLED")
85
+ endif()
86
+
87
+ if(YEPTRIS_ENABLE_TSAN)
88
+ add_compile_options(-fsanitize=thread -fno-omit-frame-pointer -g)
89
+ add_link_options(-fsanitize=thread)
90
+ message(STATUS "ThreadSanitizer: ENABLED")
91
+ endif()
92
+
93
+ if(YEPTRIS_ENABLE_UBSAN)
94
+ add_compile_options(
95
+ -fsanitize=undefined -fsanitize=float-cast-overflow
96
+ -fno-sanitize-recover=undefined -fno-omit-frame-pointer -g)
97
+ add_link_options(-fsanitize=undefined -fsanitize=float-cast-overflow)
98
+ message(STATUS "UndefinedBehaviorSanitizer: ENABLED (fatal)")
99
+ endif()
100
+
101
+ # libFuzzer implies ASAN (libleptris TODO 40 pattern).
102
+ if(YEPTRIS_ENABLE_FUZZING)
103
+ add_compile_options(-fsanitize=fuzzer-no-link,address -fno-omit-frame-pointer -g)
104
+ add_link_options(-fsanitize=fuzzer,address)
105
+ message(STATUS "libFuzzer: ENABLED (implies ASAN)")
106
+ endif()
107
+
108
+ # -------------------------------------------------------------------- LTO --
109
+ if(YEPTRIS_ENABLE_LTO)
110
+ include(CheckIPOSupported)
111
+ check_ipo_supported(RESULT yeptris_lto_supported OUTPUT yeptris_lto_error)
112
+ if(yeptris_lto_supported)
113
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
114
+ message(STATUS "Link-time optimization: ENABLED")
115
+ else()
116
+ message(WARNING "YEPTRIS_ENABLE_LTO requested but not supported: ${yeptris_lto_error}")
117
+ endif()
118
+ endif()
119
+
120
+ # -------------------------------------------------------------- visibility --
121
+ # Position-independent code for static libraries (embeddable in DSOs).
122
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
123
+
124
+ # Hide all symbols by default; the public surface is exactly the
125
+ # YEPTRIS_API-marked functions (libleptris TODO 80 pattern).
126
+ set(CMAKE_C_VISIBILITY_PRESET hidden)
127
+ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
128
+ set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
129
+
130
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
131
+
132
+ # ---------------------------------------------------------------- warnings --
133
+ # Scoped per-target so fetched dependencies (GTest) keep their own flags.
134
+ function(yeptris_set_warnings target)
135
+ if(MSVC)
136
+ # /wd4100 mirrors -Wno-unused-parameter; /experimental:c11atomics
137
+ # un-breaks the C11 headers' stdatomic gate (the windows sentinel
138
+ # surfaced both — the leg rides in the test matrix now)
139
+ target_compile_options(${target} PRIVATE /W4 /wd4100 /wd4996 /experimental:c11atomics)
140
+ if(YEPTRIS_WARNINGS_AS_ERRORS)
141
+ target_compile_options(${target} PRIVATE /WX)
142
+ endif()
143
+ else()
144
+ target_compile_options(${target} PRIVATE -Wall -Wextra -Wno-unused-parameter)
145
+ if(YEPTRIS_WARNINGS_AS_ERRORS)
146
+ target_compile_options(${target} PRIVATE -Werror)
147
+ endif()
148
+ endif()
149
+ endfunction()
150
+
151
+ # ------------------------------------------------------------- versioning --
152
+ # CMakeLists project(VERSION) is the single source of truth (TODO.impl/01);
153
+ # scripts/bump-version.sh syncs vcpkg.json and CHANGELOG.md from it.
154
+ configure_file(
155
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/include/yeptris/version.h.in
156
+ ${CMAKE_BINARY_DIR}/generated/yeptris/version.h
157
+ @ONLY
158
+ )
159
+
160
+ # --------------------------------------------------------------- subdirs --
161
+ enable_testing()
162
+
163
+ add_subdirectory(src)
164
+
165
+ if(YEPTRIS_BUILD_CLI)
166
+ add_subdirectory(cli)
167
+ endif()
168
+
169
+ if(BUILD_TESTING)
170
+ if(MSVC)
171
+ add_compile_options(-I${CMAKE_SOURCE_DIR}/test/compat)
172
+ endif()
173
+ add_subdirectory(test)
174
+
175
+ # Conformance runner (TODO.impl/16): builds on demand; the corpus
176
+ # arrives via scripts/fetch-corpora.sh.
177
+ add_executable(test_conformance
178
+ test/conformance/main.c
179
+ test/conformance/suite.c
180
+ test/conformance/tree.c)
181
+ # Runs in CI after fetch-corpora.sh; passes-as-skip when absent.
182
+ add_test(NAME conformance
183
+ COMMAND test_conformance ${CMAKE_SOURCE_DIR}/test/conformance/data/yaml-test-suite/src)
184
+ # strict: the suite is at 100% — a regression must fail CI, not hide
185
+ # behind the non-strict exit (a tree-mismatch once slipped through)
186
+ set_tests_properties(conformance PROPERTIES ENVIRONMENT "YEP_STRICT=1")
187
+ # psych-pure's parse-{block,flow,scalar,props,stream} corpora,
188
+ # ported by scripts/port-pure-tml.py (checked-in fixtures)
189
+ add_test(NAME conformance-pure
190
+ COMMAND test_conformance ${CMAKE_SOURCE_DIR}/test/conformance/data/psych-pure)
191
+ set_tests_properties(conformance-pure PROPERTIES ENVIRONMENT "YEP_STRICT=1")
192
+ target_link_libraries(test_conformance PRIVATE yeptris_static)
193
+ target_include_directories(test_conformance PRIVATE
194
+ ${CMAKE_SOURCE_DIR}/src/yeptris
195
+ ${CMAKE_SOURCE_DIR}/src/include
196
+ ${CMAKE_BINARY_DIR}/generated)
197
+ yeptris_set_warnings(test_conformance)
198
+ endif()
199
+
200
+ if(YEPTRIS_BUILD_BENCHMARKS)
201
+ add_subdirectory(benchmarks)
202
+ endif()
203
+
204
+ # --------------------------------------------------------------- install --
205
+ # (TODO.impl/20) targets, headers, pkg-config, and the find_package
206
+ # config; relative paths keep relocatable installs.
207
+ include(GNUInstallDirs)
208
+
209
+ install(TARGETS yeptris_static
210
+ EXPORT yeptris-targets
211
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
212
+ )
213
+ if(TARGET yeptris_jsonc)
214
+ install(TARGETS yeptris_jsonc
215
+ EXPORT yeptris-targets
216
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
217
+ )
218
+ endif()
219
+ if(YEPTRIS_BUILD_CLI AND TARGET yeptris)
220
+ install(TARGETS yeptris DESTINATION ${CMAKE_INSTALL_BINDIR})
221
+ endif()
222
+
223
+ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/include/
224
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
225
+ FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
226
+ )
227
+ install(FILES ${CMAKE_BINARY_DIR}/generated/yeptris/version.h
228
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/yeptris
229
+ )
230
+
231
+ # pkg-config
232
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/yeptris.pc.in
233
+ ${CMAKE_BINARY_DIR}/yeptris.pc @ONLY)
234
+ install(FILES ${CMAKE_BINARY_DIR}/yeptris.pc
235
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
236
+
237
+ # find_package(yeptris) config
238
+ include(CMakePackageConfigHelpers)
239
+ write_basic_package_version_file(
240
+ ${CMAKE_BINARY_DIR}/yeptris-config-version.cmake
241
+ VERSION ${PROJECT_VERSION}
242
+ COMPATIBILITY SameMajorVersion
243
+ )
244
+ install(EXPORT yeptris-targets
245
+ NAMESPACE yeptris::
246
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yeptris)
247
+ configure_package_config_file(
248
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/yeptris-config.cmake.in
249
+ ${CMAKE_BINARY_DIR}/yeptris-config.cmake
250
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yeptris)
251
+ install(FILES ${CMAKE_BINARY_DIR}/yeptris-config.cmake
252
+ ${CMAKE_BINARY_DIR}/yeptris-config-version.cmake
253
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/yeptris)
254
+
@@ -0,0 +1,5 @@
1
+ @PACKAGE_INIT@
2
+
3
+ include("${CMAKE_CURRENT_LIST_DIR}/yeptris-targets.cmake")
4
+
5
+ check_required_components(yeptris)
@@ -0,0 +1,11 @@
1
+ prefix=@CMAKE_INSTALL_PREFIX@
2
+ exec_prefix=${prefix}
3
+ libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
4
+ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
5
+
6
+ Name: yeptris
7
+ Description: @PROJECT_DESCRIPTION@
8
+ Version: @PROJECT_VERSION@
9
+ URL: https://github.com/leptris/yeptris
10
+ Cflags: -I${includedir}
11
+ Libs: -L${libdir} -lyeptris
@@ -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()