├── .gitattributes ├── .github └── workflows │ ├── ci.yml │ ├── publish-docs.yaml │ └── publish-release.yaml ├── .gitignore ├── .swiftformat ├── .swiftlint.yml ├── LICENSE ├── Makefile ├── Package.resolved ├── Package.swift ├── README.md ├── Sources ├── Cfyaml │ ├── .libtool-version │ ├── .tarball-version │ ├── AUTHORS │ ├── Dockerfile │ ├── Dockerfile-build-deb │ ├── Dockerfile.alpine │ ├── Dockerfile.centos │ ├── LICENSE │ ├── Makefile │ ├── Makefile.am │ ├── Makefile.in │ ├── README.md │ ├── aclocal.m4 │ ├── autom4te.cache │ │ ├── output.0 │ │ ├── output.1 │ │ ├── output.2 │ │ ├── output.3 │ │ ├── requests │ │ ├── traces.0 │ │ ├── traces.1 │ │ ├── traces.2 │ │ └── traces.3 │ ├── bootstrap.sh │ ├── build-aux │ │ ├── ar-lib │ │ ├── compile │ │ ├── config.guess │ │ ├── config.guess~ │ │ ├── config.sub │ │ ├── config.sub~ │ │ ├── depcomp │ │ ├── git-version-gen │ │ ├── install-sh │ │ ├── install-sh~ │ │ ├── ltmain.sh │ │ ├── missing │ │ ├── shave │ │ ├── shave-libtool │ │ ├── shave-libtool.in │ │ ├── shave.in │ │ └── tap-driver.sh │ ├── config.h │ ├── config.h.in │ ├── config.h.in~ │ ├── config.log │ ├── config.status │ ├── configure │ ├── configure.ac │ ├── configure~ │ ├── doc │ │ ├── Makefile │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── canned-man │ │ │ └── fy-tool.1 │ │ ├── conf.py │ │ ├── index.rst │ │ ├── intro.rst │ │ ├── libfyaml.rst │ │ └── man │ │ │ └── fy-tool.rst │ ├── include │ │ └── libfyaml.h │ ├── libfyaml.pc │ ├── libfyaml.pc.in │ ├── libtool │ ├── m4 │ │ ├── ax_check_enable_debug.m4 │ │ ├── ax_check_flag.m4 │ │ ├── ax_pthread.m4 │ │ ├── libtool.m4 │ │ ├── ltoptions.m4 │ │ ├── ltsugar.m4 │ │ ├── ltversion.m4 │ │ ├── lt~obsolete.m4 │ │ └── shave.m4 │ ├── scripts │ │ ├── create-virtual-env │ │ ├── install-linuxdoc.sh │ │ ├── run-check-errors.sh │ │ ├── run-compare-dump.sh │ │ ├── run-compare-examples.sh │ │ ├── run-compare-parse.sh │ │ ├── run-compare-scan.sh │ │ ├── run-compare-testsuite.sh │ │ ├── run-emit-check.sh │ │ ├── run-kcachegrind.sh │ │ ├── run-list-testsuite.sh │ │ ├── run-massif.sh │ │ ├── run-test.sh │ │ ├── run-valgrind.sh │ │ └── show-desc.sh │ ├── src │ │ ├── Makefile │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── blake3 │ │ │ ├── .deps │ │ │ │ ├── libb3avx2_la-blake3.Plo │ │ │ │ ├── libb3avx2_la-blake3_avx2.Plo │ │ │ │ ├── libb3avx2_la-blake3_avx2_x86-64_unix.Plo │ │ │ │ ├── libb3avx512_la-blake3.Plo │ │ │ │ ├── libb3avx512_la-blake3_avx512.Plo │ │ │ │ ├── libb3avx512_la-blake3_avx512_x86-64_unix.Plo │ │ │ │ ├── libb3neon_la-blake3.Plo │ │ │ │ ├── libb3neon_la-blake3_neon.Plo │ │ │ │ ├── libb3portable_la-blake3.Plo │ │ │ │ ├── libb3portable_la-blake3_portable.Plo │ │ │ │ ├── libb3sse2_la-blake3.Plo │ │ │ │ ├── libb3sse2_la-blake3_sse2.Plo │ │ │ │ ├── libb3sse2_la-blake3_sse2_x86-64_unix.Plo │ │ │ │ ├── libb3sse41_la-blake3.Plo │ │ │ │ ├── libb3sse41_la-blake3_sse41.Plo │ │ │ │ ├── libb3sse41_la-blake3_sse41_x86-64_unix.Plo │ │ │ │ ├── libfyaml_la-blake3_backend.Plo │ │ │ │ ├── libfyaml_la-blake3_be_cpusimd.Plo │ │ │ │ ├── libfyaml_la-blake3_host_state.Plo │ │ │ │ └── libfyaml_la-fy-blake3.Plo │ │ │ ├── blake3.c │ │ │ ├── blake3.h │ │ │ ├── blake3_avx2.c │ │ │ ├── blake3_avx2_x86-64_unix.S │ │ │ ├── blake3_avx512.c │ │ │ ├── blake3_avx512_x86-64_unix.S │ │ │ ├── blake3_backend.c │ │ │ ├── blake3_be_cpusimd.c │ │ │ ├── blake3_host_state.c │ │ │ ├── blake3_impl.h │ │ │ ├── blake3_internal.h │ │ │ ├── blake3_neon.c │ │ │ ├── blake3_portable.c │ │ │ ├── blake3_sse2.c │ │ │ ├── blake3_sse2_x86-64_unix.S │ │ │ ├── blake3_sse41.c │ │ │ ├── blake3_sse41_x86-64_unix.S │ │ │ └── fy-blake3.c │ │ ├── internal │ │ │ ├── .deps │ │ │ │ ├── fy_b3sum-fy-b3sum.Po │ │ │ │ ├── fy_thread-fy-thread.Po │ │ │ │ └── libfyaml_parser-libfyaml-parser.Po │ │ │ ├── fy-b3sum.c │ │ │ ├── fy-thread.c │ │ │ └── libfyaml-parser.c │ │ ├── lib │ │ │ ├── .deps │ │ │ │ ├── libfyaml_la-fy-accel.Plo │ │ │ │ ├── libfyaml_la-fy-atom.Plo │ │ │ │ ├── libfyaml_la-fy-composer.Plo │ │ │ │ ├── libfyaml_la-fy-diag.Plo │ │ │ │ ├── libfyaml_la-fy-doc.Plo │ │ │ │ ├── libfyaml_la-fy-docbuilder.Plo │ │ │ │ ├── libfyaml_la-fy-docstate.Plo │ │ │ │ ├── libfyaml_la-fy-dump.Plo │ │ │ │ ├── libfyaml_la-fy-emit.Plo │ │ │ │ ├── libfyaml_la-fy-event.Plo │ │ │ │ ├── libfyaml_la-fy-input.Plo │ │ │ │ ├── libfyaml_la-fy-parse.Plo │ │ │ │ ├── libfyaml_la-fy-path.Plo │ │ │ │ ├── libfyaml_la-fy-token.Plo │ │ │ │ ├── libfyaml_la-fy-types.Plo │ │ │ │ └── libfyaml_la-fy-walk.Plo │ │ │ ├── fy-accel.c │ │ │ ├── fy-accel.h │ │ │ ├── fy-atom.c │ │ │ ├── fy-atom.h │ │ │ ├── fy-composer.c │ │ │ ├── fy-composer.h │ │ │ ├── fy-diag.c │ │ │ ├── fy-diag.h │ │ │ ├── fy-doc.c │ │ │ ├── fy-doc.h │ │ │ ├── fy-docbuilder.c │ │ │ ├── fy-docbuilder.h │ │ │ ├── fy-docstate.c │ │ │ ├── fy-docstate.h │ │ │ ├── fy-dump.c │ │ │ ├── fy-dump.h │ │ │ ├── fy-emit-accum.h │ │ │ ├── fy-emit.c │ │ │ ├── fy-emit.h │ │ │ ├── fy-event.c │ │ │ ├── fy-event.h │ │ │ ├── fy-input.c │ │ │ ├── fy-input.h │ │ │ ├── fy-parse.c │ │ │ ├── fy-parse.h │ │ │ ├── fy-path.c │ │ │ ├── fy-path.h │ │ │ ├── fy-token.c │ │ │ ├── fy-token.h │ │ │ ├── fy-types.c │ │ │ ├── fy-types.h │ │ │ ├── fy-walk.c │ │ │ └── fy-walk.h │ │ ├── thread │ │ │ ├── .deps │ │ │ │ └── libfyaml_la-fy-thread.Plo │ │ │ ├── fy-thread.c │ │ │ └── fy-thread.h │ │ ├── tool │ │ │ ├── .deps │ │ │ │ └── fy_tool-fy-tool.Po │ │ │ └── fy-tool.c │ │ ├── util │ │ │ ├── .deps │ │ │ │ ├── libfyaml_la-fy-blob.Plo │ │ │ │ ├── libfyaml_la-fy-ctype.Plo │ │ │ │ ├── libfyaml_la-fy-utf8.Plo │ │ │ │ └── libfyaml_la-fy-utils.Plo │ │ │ ├── fy-align.h │ │ │ ├── fy-bit64.h │ │ │ ├── fy-blob.c │ │ │ ├── fy-blob.h │ │ │ ├── fy-ctype.c │ │ │ ├── fy-ctype.h │ │ │ ├── fy-endian.h │ │ │ ├── fy-id.h │ │ │ ├── fy-list.h │ │ │ ├── fy-typelist.h │ │ │ ├── fy-utf8.c │ │ │ ├── fy-utf8.h │ │ │ ├── fy-utils.c │ │ │ └── fy-utils.h │ │ ├── valgrind │ │ │ └── fy-valgrind.h │ │ └── xxhash │ │ │ ├── .deps │ │ │ └── libfyaml_la-xxhash.Plo │ │ │ ├── xxhash.c │ │ │ └── xxhash.h │ ├── stamp-h1 │ └── test │ │ ├── .deps │ │ ├── libfyaml_test-libfyaml-test-core.Po │ │ ├── libfyaml_test-libfyaml-test-emit.Po │ │ ├── libfyaml_test-libfyaml-test-meta.Po │ │ ├── libfyaml_test-libfyaml-test-private-id.Po │ │ ├── libfyaml_test-libfyaml-test-private.Po │ │ └── libfyaml_test-libfyaml-test.Po │ │ ├── Makefile │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── emitter-examples │ │ ├── anchors-1.yaml │ │ ├── anchors-2.yaml │ │ ├── anchors-3.yaml │ │ ├── anchors-4.1.yaml │ │ ├── anchors-4.yaml │ │ ├── anchors-on-empty-scalars.yaml │ │ ├── anchors-on-empty-scalars1.yaml │ │ ├── anchors-on-empty-scalars2.yaml │ │ ├── anchors-on-empty-scalars3.yaml │ │ ├── anchors-on-empty-scalars4.yaml │ │ ├── anchors.yaml │ │ ├── array.yaml │ │ ├── block.yaml │ │ ├── block2.yaml │ │ ├── block3.yaml │ │ ├── block4.yaml │ │ ├── block6.yaml │ │ ├── block7.yaml │ │ ├── blocked.yaml │ │ ├── blockind.yaml │ │ ├── c1.yaml │ │ ├── c10.yaml │ │ ├── c11.yaml │ │ ├── c12.yaml │ │ ├── c13.yaml │ │ ├── c2.yaml │ │ ├── c3.yaml │ │ ├── c4.yaml │ │ ├── c5.yaml │ │ ├── c6.yaml │ │ ├── c7.yaml │ │ ├── c8.yaml │ │ ├── c9.yaml │ │ ├── compact1.yaml │ │ ├── compactblockmap.yaml │ │ ├── complexkey.yaml │ │ ├── complexkey2.yaml │ │ ├── complexkey3.yaml │ │ ├── complexkey4.yaml │ │ ├── complexkey5.yaml │ │ ├── complexkey6.yaml │ │ ├── complexkey7.yaml │ │ ├── complexkey8.yaml │ │ ├── complexkey9.yaml │ │ ├── docstartend.yaml │ │ ├── dqscalar.yaml │ │ ├── dqzero.yaml │ │ ├── emoji.yaml │ │ ├── emptydoc.yaml │ │ ├── emptykey.yaml │ │ ├── emptystream.yaml │ │ ├── flow.yaml │ │ ├── flow1.yaml │ │ ├── flow2.yaml │ │ ├── fold.yaml │ │ ├── fold2.yaml │ │ ├── fold3.yaml │ │ ├── fold4.yaml │ │ ├── fold5.yaml │ │ ├── folded.yaml │ │ ├── folded2.yaml │ │ ├── folding.yaml │ │ ├── global-tag.yaml │ │ ├── invoice.yaml │ │ ├── json.yaml │ │ ├── keyflow.yaml │ │ ├── keykey.yaml │ │ ├── keykey2.yaml │ │ ├── line.yaml │ │ ├── literal.yaml │ │ ├── literal1.yaml │ │ ├── literal2.yaml │ │ ├── literal3.yaml │ │ ├── literal4.yaml │ │ ├── mapping.yaml │ │ ├── mergekeyspec.yaml │ │ ├── multi-document.yaml │ │ ├── multiline-quoted-key.yaml │ │ ├── multiline-simple-key.yaml │ │ ├── nodeprop.yaml │ │ ├── nodeprop2.yaml │ │ ├── numbers-flow.yaml │ │ ├── numbers.yaml │ │ ├── plain-scalars-with-commas.yaml │ │ ├── plainlines.yaml │ │ ├── plainscalar.yaml │ │ ├── quoted.yaml │ │ ├── quotedbackslash.yaml │ │ ├── scalar-multiline.yaml │ │ ├── scalar-singlequoted.yaml │ │ ├── scalar-space.yaml │ │ ├── scalar-space1.yaml │ │ ├── scalars.yaml │ │ ├── scalars2.yaml │ │ ├── scanner-c-1.yaml │ │ ├── scanner-c-10.yaml │ │ ├── scanner-c-11.yaml │ │ ├── scanner-c-12.yaml │ │ ├── scanner-c-13.yaml │ │ ├── scanner-c-2.yaml │ │ ├── scanner-c-3.yaml │ │ ├── scanner-c-4.yaml │ │ ├── scanner-c-5.yaml │ │ ├── scanner-c-6.yaml │ │ ├── scanner-c-7.yaml │ │ ├── scanner-c-8-2.yaml │ │ ├── scanner-c-8.yaml │ │ ├── scanner-c-9.yaml │ │ ├── seq.yaml │ │ ├── seq1.yaml │ │ ├── seq2.yaml │ │ ├── seq3.yaml │ │ ├── seq4.yaml │ │ ├── seq5.yaml │ │ ├── seq6.yaml │ │ ├── sets.yaml │ │ ├── simple.yaml │ │ ├── simple1.yaml │ │ ├── simple2.yaml │ │ ├── simpleanchor.yaml │ │ ├── simpleanchor1.yaml │ │ ├── simpleanchor2.yaml │ │ ├── simpleanchor3.yaml │ │ ├── simpleanchor4.yaml │ │ ├── simplefolded.yaml │ │ ├── simplekey.yaml │ │ ├── simplekey1.yaml │ │ ├── simplekey2.yaml │ │ ├── simplekey3.yaml │ │ ├── simplekey4.yaml │ │ ├── simplekey5.yaml │ │ ├── simpleliteral.yaml │ │ ├── simpleseq.yaml │ │ ├── simpleseq1.yaml │ │ ├── singlepairimp.yaml │ │ ├── singlepairimp2.yaml │ │ ├── sqscalar.yaml │ │ ├── sqscalarspace.yaml │ │ ├── strings.yaml │ │ ├── t.yaml │ │ ├── t1.yaml │ │ ├── t2.yaml │ │ ├── t3.yaml │ │ ├── t4.yaml │ │ ├── t5.yaml │ │ ├── tabsmix.yaml │ │ ├── tagdirective.yaml │ │ ├── tagesc.yaml │ │ ├── tags-1.yaml │ │ ├── tags.yaml │ │ ├── test.yaml │ │ ├── test1.yaml │ │ ├── test2.yaml │ │ ├── u.yaml │ │ ├── u1.yaml │ │ ├── u2.yaml │ │ ├── u3.yaml │ │ ├── utf8-simple.yaml │ │ ├── utf8.yaml │ │ ├── v.yaml │ │ ├── v1.yaml │ │ ├── v2.yaml │ │ ├── version.yaml │ │ ├── weirdplain.yaml │ │ ├── ws0.yaml │ │ ├── ws1.yaml │ │ ├── ws2.yaml │ │ ├── ws3.yaml │ │ ├── y.yaml │ │ ├── yaml-version.yaml │ │ ├── yy.yaml │ │ └── zeroexplicit.yaml │ │ ├── jsontestsuite.test │ │ ├── libfyaml-test-core.c │ │ ├── libfyaml-test-emit.c │ │ ├── libfyaml-test-meta.c │ │ ├── libfyaml-test-private-id.c │ │ ├── libfyaml-test-private.c │ │ ├── libfyaml-test.c │ │ ├── libfyaml.test │ │ ├── test-env │ │ ├── test-errors │ │ ├── 0002 │ │ │ ├── === │ │ │ ├── in.yaml │ │ │ └── test.error │ │ ├── 0003 │ │ │ ├── === │ │ │ ├── in.yaml │ │ │ └── test.error │ │ ├── 0004 │ │ │ ├── === │ │ │ ├── in.yaml │ │ │ └── test.error │ │ ├── 0005 │ │ │ ├── === │ │ │ ├── in.yaml │ │ │ └── test.error │ │ ├── 0006 │ │ │ ├── === │ │ │ ├── in.yaml │ │ │ └── test.error │ │ ├── 0007 │ │ │ ├── === │ │ │ ├── in.yaml │ │ │ └── test.error │ │ ├── 0008 │ │ │ ├── === │ │ │ ├── in.yaml │ │ │ └── test.error │ │ ├── 0009 │ │ │ ├── === │ │ │ ├── in.yaml │ │ │ └── test.error │ │ ├── 0010 │ │ │ ├── === │ │ │ ├── in.yaml │ │ │ └── test.error │ │ └── 0011 │ │ │ ├── === │ │ │ ├── in.yaml │ │ │ └── test.error │ │ ├── testemitter-restreaming.test │ │ ├── testemitter-streaming.test │ │ ├── testemitter.test │ │ ├── testerrors.test │ │ ├── testsuite-evstream.test │ │ ├── testsuite-json.test │ │ ├── testsuite-resolution.test │ │ └── testsuite.test ├── CfyamlPatches │ ├── apply.sh │ └── v0.9 │ │ ├── 0001-Prepare-for-Swift-package-build.patch │ │ ├── 0002-Setup-testing-for-the-event-creation-in-streaming-mo.patch │ │ ├── 0003-Fixes-creating-blank-aka-ws-only-scalars-with-emit-e.patch │ │ ├── 0004-Allow-zero-length-scalars-created-with-emit-event-ap.patch │ │ ├── 0005-Allow-plain-scalars-created-via-emit-event-apis-to-i.patch │ │ ├── 0006-Allow-prefix-only-tags-to-pass-fy_tag_scan.patch │ │ ├── 0007-Force-doc-end-marker-when-pretty-emit-mode-forces-a-.patch │ │ └── 0008-Emit-doc-start-marker-on-its-own-line-for-single-sca.patch ├── PotentASN1 │ ├── ASN1.swift │ ├── ASN1DERReader.swift │ ├── ASN1DERWriter.swift │ ├── ASN1Decoder.swift │ ├── ASN1Encoder.swift │ ├── ASN1Serialization.swift │ ├── AnyString.swift │ ├── AnyTime.swift │ ├── BigInts.swift │ ├── BitString.swift │ ├── Dates.swift │ ├── ObjectIdentifier.swift │ ├── Schema.swift │ ├── SchemaSpecified.swift │ ├── SchemaState.swift │ ├── Tagged.swift │ └── TaggedValue.swift ├── PotentCBOR │ ├── CBOR.swift │ ├── CBORDecoder.swift │ ├── CBOREncoder.swift │ ├── CBORReader.swift │ ├── CBORSerialization.swift │ ├── CBORStream.swift │ └── CBORWriter.swift ├── PotentCodables │ ├── AnyCodingKey.swift │ ├── AnyValue │ │ ├── AnyValue.swift │ │ ├── AnyValueDecoder.swift │ │ └── AnyValueEncoder.swift │ ├── DecoderSupport.swift │ ├── EncoderSupport.swift │ ├── Errors.swift │ ├── Float16.swift │ ├── KeyStrategy.swift │ ├── KeyedNestedDecoder.swift │ ├── KeyedNestedEncoder.swift │ ├── PotentCodables.docc │ │ ├── Data Formats │ │ │ ├── ASN1 │ │ │ │ ├── ASN1 ReadingWriting.md │ │ │ │ ├── ASN1 SchemaEncodingDecoding.md │ │ │ │ └── PotentASN1.md │ │ │ ├── CBOR │ │ │ │ ├── CBOR Serialization.md │ │ │ │ └── PotentCBOR.md │ │ │ ├── JSON │ │ │ │ └── PotentJSON.md │ │ │ └── YAML │ │ │ │ └── PotentYAML.md │ │ ├── General │ │ │ ├── Combine.md │ │ │ ├── Custom References.md │ │ │ ├── Data Formats.md │ │ │ ├── GettingStarted.md │ │ │ ├── Implementing Formats.md │ │ │ ├── PolymorphicEncodingDecoding.md │ │ │ ├── Protocols.md │ │ │ ├── TreeValues.md │ │ │ └── Using AnyValue.md │ │ └── PotentCodables.md │ ├── Refs.swift │ ├── Regexes.swift │ ├── TimeZone.swift │ ├── TopLevel.swift │ ├── TreeValueDecodingContainer.swift │ ├── Value.swift │ ├── ValueDecoder.swift │ ├── ValueEncoder.swift │ ├── ValueTransformer.swift │ ├── ValueTransformerProviding.swift │ └── ZonedDate.swift ├── PotentJSON │ ├── Errors.swift │ ├── JSON.swift │ ├── JSONDecoder.swift │ ├── JSONEncoder.swift │ ├── JSONReader.swift │ ├── JSONSerialization.swift │ └── JSONWriter.swift └── PotentYAML │ ├── Errors.swift │ ├── Libfyaml.swift │ ├── YAML.swift │ ├── YAMLDecoder.swift │ ├── YAMLEncoder.swift │ ├── YAMLReader.swift │ ├── YAMLSchema.swift │ ├── YAMLSchemaCore.swift │ ├── YAMLSerialization.swift │ └── YAMLWriter.swift └── Tests ├── .swiftlint.yml ├── ASN1AnyStringTests.swift ├── ASN1AnyValueTests.swift ├── ASN1DERBigIntTests.swift ├── ASN1DERTests.swift ├── ASN1DecoderTests.swift ├── ASN1EncoderTests.swift ├── ASN1SchemaDecodeTests.swift ├── ASN1SchemaEncodeTests.swift ├── ASN1SchemaTests.swift ├── ASN1Tests.swift ├── ASN1ValueTests.swift ├── AnyCodingKeyTests.swift ├── AnyValueCoderTests.swift ├── AnyValueTests.swift ├── Assertions.swift ├── CBORAnyValueTests.swift ├── CBORCodableRoundtripTests.swift ├── CBORDecoderTests.swift ├── CBOREncoderTests.swift ├── CBORReaderTests.swift ├── CBORTests.swift ├── CBORValueTests.swift ├── CBORWriterTests.swift ├── ConfigurationTests.swift ├── Datas.swift ├── Dates.swift ├── JSONAnyValueTests.swift ├── JSONDecoderTests.swift ├── JSONEncoderTests.swift ├── JSONOrderTests.swift ├── JSONReaderTests.swift ├── JSONValueTests.swift ├── JSONWriterTests.swift ├── RefTests.swift ├── TimeZoneTests.swift ├── UnkeyedCodingContainerTests.swift ├── ValueCoderTests.swift ├── ValueTransformerProvidingTests.swift ├── ValueTransformerTests.swift ├── YAMLAnyValueTests.swift ├── YAMLDecoderTests.swift ├── YAMLEncoderTests.swift ├── YAMLErrorTests.swift ├── YAMLOrderTests.swift ├── YAMLReaderTests.swift ├── YAMLSchemaTests.swift ├── YAMLTests.swift ├── YAMLValueTests.swift └── YAMLWriterTests.swift /.gitattributes: -------------------------------------------------------------------------------- 1 | /Sources/Cfyaml/* linguist-vendored -------------------------------------------------------------------------------- /.github/workflows/publish-docs.yaml: -------------------------------------------------------------------------------- 1 | name: Publish Docs 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | 7 | permissions: 8 | contents: write 9 | 10 | concurrency: 11 | group: publish-docs-${{github.ref_name}} 12 | cancel-in-progress: false 13 | 14 | jobs: 15 | 16 | build: 17 | 18 | runs-on: macos-latest 19 | 20 | steps: 21 | - uses: actions/checkout@v4 22 | 23 | - name: Select Xcode 24 | run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer 25 | 26 | - run: | 27 | mkdir -p docs 28 | mkdir -p allsgs 29 | mkdir -p sgs 30 | 31 | - name: Build Symbol Graph 32 | run: | 33 | swift build -Xswiftc -emit-symbol-graph -Xswiftc -emit-symbol-graph-dir -Xswiftc allsgs 34 | cp allsgs/Potent*.json sgs 35 | 36 | - name: Build Docs 37 | run: >- 38 | swift package 39 | --allow-writing-to-directory docs/${{ github.ref_name }} 40 | generate-documentation 41 | --enable-inherited-docs 42 | --additional-symbol-graph-dir sgs 43 | --target PotentCodables 44 | --output-path docs/${{ github.ref_name }} 45 | --transform-for-static-hosting 46 | --hosting-base-path PotentCodables/${{ github.ref_name }} 47 | 48 | - name: Archive Docs 49 | run: tar -czf docs.tar.gz docs 50 | 51 | - name: Upload Docs Archive 52 | uses: actions/upload-artifact@v4 53 | with: 54 | name: docs-${{ github.ref_name }} 55 | path: docs.tar.gz 56 | 57 | deploy: 58 | 59 | runs-on: ubuntu-latest 60 | needs: [ build ] 61 | 62 | steps: 63 | - uses: actions/checkout@v4 64 | 65 | - name: Download Docs Archive 66 | uses: actions/download-artifact@v4 67 | with: 68 | name: docs-${{ github.ref_name }} 69 | path: '.' 70 | 71 | - name: Unarchive Docs 72 | run: tar -xvf docs.tar.gz 73 | 74 | - name: Deploy Docs 75 | uses: JamesIves/github-pages-deploy-action@v4 76 | with: 77 | folder: docs 78 | clean: false 79 | 80 | -------------------------------------------------------------------------------- /.github/workflows/publish-release.yaml: -------------------------------------------------------------------------------- 1 | name: Publish Release 2 | 3 | on: 4 | push: 5 | tags: [ "[0-9]+.[0-9]+.[0-9]+**" ] 6 | 7 | permissions: 8 | contents: write 9 | 10 | concurrency: 11 | group: publish-release-${{github.ref_name}} 12 | cancel-in-progress: false 13 | 14 | jobs: 15 | 16 | build: 17 | 18 | runs-on: macos-latest 19 | 20 | steps: 21 | - uses: actions/checkout@v4 22 | 23 | - name: Select Xcode 24 | run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer 25 | 26 | - run: | 27 | mkdir -p docs 28 | mkdir -p allsgs 29 | mkdir -p sgs 30 | 31 | - name: Build Symbol Graph 32 | run: | 33 | swift build -Xswiftc -emit-symbol-graph -Xswiftc -emit-symbol-graph-dir -Xswiftc allsgs 34 | cp allsgs/Potent*.json sgs 35 | 36 | - name: Build Docs 37 | run: >- 38 | swift package 39 | --allow-writing-to-directory docs/${{ github.ref_name }} 40 | generate-documentation 41 | --enable-inherited-docs 42 | --additional-symbol-graph-dir sgs 43 | --target PotentCodables 44 | --output-path docs/${{ github.ref_name }} 45 | --transform-for-static-hosting 46 | --hosting-base-path PotentCodables/${{ github.ref_name }} 47 | 48 | - name: Archive Docs 49 | run: tar -czf docs.tar.gz docs 50 | 51 | - name: Upload Docs Archive 52 | uses: actions/upload-artifact@v4 53 | with: 54 | name: docs-${{ github.ref_name }} 55 | path: docs.tar.gz 56 | 57 | publish: 58 | 59 | runs-on: ubuntu-latest 60 | needs: [ build ] 61 | 62 | steps: 63 | - uses: actions/checkout@v4 64 | 65 | - name: Download Docs Archive 66 | uses: actions/download-artifact@v4 67 | with: 68 | name: docs-${{ github.ref_name }} 69 | path: '.' 70 | 71 | - name: Unarchive Docs 72 | run: tar -xvf docs.tar.gz 73 | 74 | - name: Deploy Docs 75 | uses: JamesIves/github-pages-deploy-action@v4 76 | with: 77 | folder: docs 78 | clean: false 79 | 80 | - name: Check Version Format in Tag 81 | id: version 82 | uses: nowsprinting/check-version-format-action@v4 83 | 84 | - name: Create GitHub Release 85 | uses: softprops/action-gh-release@v2 86 | env: 87 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 88 | with: 89 | name: 🚀 v${{ github.ref_name }} 90 | tag_name: ${{ github.ref_name }} 91 | generate_release_notes: true 92 | prerelease: ${{ steps.version.outputs.is_stable != 'true' }} 93 | make_latest: ${{ steps.version.outputs.is_stable == 'true' }} 94 | draft: false 95 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /.derived-data 4 | /.swiftpm 5 | /TestResults 6 | -------------------------------------------------------------------------------- /.swiftformat: -------------------------------------------------------------------------------- 1 | --swiftversion 5.4 2 | --indent 2 3 | --maxwidth 120 4 | --elseposition next-line 5 | --patternlet inline 6 | --stripunusedargs closure-only 7 | --wraparguments before-first 8 | --wraparguments before-first 9 | --header "//\n// {file}\n// PotentCodables\n//\n// Copyright © {created.year} Outfox, inc.\n//\n//\n// Distributed under the MIT License, See LICENSE for details.\n//" 10 | --enable blankLinesBetweenScopes 11 | --disable consecutiveBlankLines,blankLinesAtEndOfScope,blankLinesAtStartOfScope,redundantReturn,wrapMultilineStatementBraces 12 | -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | opt_in_rules: 2 | - file_header 3 | 4 | disabled_rules: 5 | - cyclomatic_complexity 6 | 7 | included: 8 | - Sources 9 | - Tests 10 | 11 | excluded: 12 | - Sources/SundayServer/Routable.swift 13 | 14 | vertical_whitespace: 15 | max_empty_lines: 3 16 | 17 | nesting: 18 | type_level: 2 19 | 20 | statement_position: 21 | statement_mode: uncuddled_else 22 | 23 | identifier_name: 24 | excluded: [id, ok, in, is, at, of] 25 | 26 | trailing_comma: 27 | mandatory_comma: true 28 | 29 | file_length: 30 | warning: 1500 31 | error: 3000 32 | ignore_comment_only_lines: true 33 | 34 | line_length: 35 | - 150 36 | - 175 37 | 38 | function_parameter_count: 39 | - 8 40 | - 11 41 | 42 | function_body_length: 43 | - 300 44 | - 350 45 | 46 | type_body_length: 47 | - 700 48 | - 1000 49 | 50 | large_tuple: 51 | - 4 52 | - 5 53 | 54 | file_header: 55 | required_pattern: |- 56 | \Q// 57 | // \E[a-zA-Z0-9-_.]+\Q 58 | // PotentCodables 59 | // 60 | // Copyright © \E\d{4}\Q Outfox, inc. 61 | // 62 | // 63 | // Distributed under the MIT License, See LICENSE for details. 64 | // 65 | \E 66 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Outfox, inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "BigInt", 6 | "repositoryURL": "https://github.com/attaswift/BigInt.git", 7 | "state": { 8 | "branch": null, 9 | "revision": "0ed110f7555c34ff468e72e1686e59721f2b0da6", 10 | "version": "5.3.0" 11 | } 12 | }, 13 | { 14 | "package": "Float16", 15 | "repositoryURL": "https://github.com/SusanDoggie/Float16.git", 16 | "state": { 17 | "branch": null, 18 | "revision": "936ae66adccf1c91bcaeeb9c0cddde78a13695c3", 19 | "version": "1.1.1" 20 | } 21 | }, 22 | { 23 | "package": "Regex", 24 | "repositoryURL": "https://github.com/sharplet/Regex.git", 25 | "state": { 26 | "branch": null, 27 | "revision": "76c2b73d4281d77fc3118391877efd1bf972f515", 28 | "version": "2.1.1" 29 | } 30 | }, 31 | { 32 | "package": "swift-collections", 33 | "repositoryURL": "https://github.com/apple/swift-collections.git", 34 | "state": { 35 | "branch": null, 36 | "revision": "937e904258d22af6e447a0b72c0bc67583ef64a2", 37 | "version": "1.0.4" 38 | } 39 | }, 40 | { 41 | "package": "SwiftDocCPlugin", 42 | "repositoryURL": "https://github.com/swiftlang/swift-docc-plugin", 43 | "state": { 44 | "branch": null, 45 | "revision": "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64", 46 | "version": "1.4.3" 47 | } 48 | }, 49 | { 50 | "package": "SymbolKit", 51 | "repositoryURL": "https://github.com/swiftlang/swift-docc-symbolkit", 52 | "state": { 53 | "branch": null, 54 | "revision": "b45d1f2ed151d057b54504d653e0da5552844e34", 55 | "version": "1.0.0" 56 | } 57 | }, 58 | { 59 | "package": "swift-numerics", 60 | "repositoryURL": "https://github.com/apple/swift-numerics", 61 | "state": { 62 | "branch": null, 63 | "revision": "0a5bc04095a675662cf24757cc0640aa2204253b", 64 | "version": "1.0.2" 65 | } 66 | } 67 | ] 68 | }, 69 | "version": 1 70 | } 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🧪 PotentCodables 2 | ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/outfoxx/PotentCodables/ci.yml?branch=main) 3 | ![Coverage](https://sonarcloud.io/api/project_badges/measure?project=outfoxx_PotentCodables&metric=coverage) 4 | [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Foutfoxx%2FPotentCodables%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/outfoxx/PotentCodables) 5 | [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Foutfoxx%2FPotentCodables%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/outfoxx/PotentCodables) 6 | 7 | ## A potent set of implementations and extension to the Swift `Codable` system 8 | 9 | ### Why? 10 | The framework aims to solve three major pain points experienced with Swift's `Codable` system: 11 | 12 | * Allow decoding and/or encoding values of unknown structure (e.g. any encoded value) 13 | * Support polymorphic type encoding/decoding while still allowing Swift to implement `Codable` 14 | * Reduce the complexity and amount of code required to implement and test new serialization formats 15 | * Provide a library of fully featured implementations of popular serialization formats 16 | 17 | ## Integration 18 | 19 | ### Swift Package Manager 20 | PotentCodables currently supports Swift Package Manager for project integration. Add a package dependency similar to the following: 21 | ```swift 22 | .package(url: "https://github.com/outfoxx/PotentCodables.git", from: "1.0.0") 23 | ``` 24 | 25 | ## Documentation 26 | 27 | ### [View Package Documentation](https://outfoxx.github.io/PotentCodables/main/documentation/potentcodables) 28 | -------------------------------------------------------------------------------- /Sources/Cfyaml/.libtool-version: -------------------------------------------------------------------------------- 1 | 1:4:2 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/.tarball-version: -------------------------------------------------------------------------------- 1 | 0.9 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/AUTHORS: -------------------------------------------------------------------------------- 1 | Pantelis Antoniou 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu 2 | FROM ${IMAGE} 3 | # install build dependencies 4 | RUN apt-get update -qq 5 | RUN apt-get install --no-install-recommends -y \ 6 | gcc autoconf automake libtool git make libyaml-dev libltdl-dev \ 7 | pkg-config check python3 python3-pip python3-setuptools 8 | # install sphinx doc dependencies 9 | RUN pip3 install wheel sphinx git+http://github.com/return42/linuxdoc.git sphinx_rtd_theme sphinx-markdown-builder 10 | # configure argument 11 | ARG CONFIG_ARGS 12 | ENV CONFIG_ARGS=${CONFIG_ARGS:-"--enable-debug --prefix=/usr"} 13 | COPY . /build 14 | WORKDIR /build 15 | # do a maintainer clean if the directory was unclean (it can fail) 16 | RUN make maintainer-clean >/dev/null 2>&1|| true 17 | RUN ./bootstrap.sh 2>&1 18 | RUN ./configure 2>&1 ${CONFIG_ARGS} 19 | RUN make 20 | RUN make check 21 | RUN make distcheck 22 | RUN make doc-html 23 | -------------------------------------------------------------------------------- /Sources/Cfyaml/Dockerfile-build-deb: -------------------------------------------------------------------------------- 1 | ARG IMAGE=ubuntu 2 | FROM ${IMAGE} 3 | # install build dependencies 4 | RUN apt-get update -qq 5 | RUN apt-get install --no-install-recommends --fix-missing -y \ 6 | gcc autoconf automake libtool git make libyaml-dev libltdl-dev \ 7 | pkg-config check python3 python3-pip python3-setuptools \ 8 | devscripts build-essential lintian debhelper dh-buildinfo dh-autoreconf fakeroot \ 9 | gnupg 10 | # install sphinx doc dependencies 11 | RUN pip3 install wheel sphinx git+http://github.com/return42/linuxdoc.git sphinx_rtd_theme sphinx-markdown-builder 12 | # configure argument 13 | ARG CONFIG_ARGS 14 | ENV CONFIG_ARGS=${CONFIG_ARGS} 15 | COPY . /build 16 | WORKDIR /build 17 | # do a maintainer clean if the directory was unclean (it can fail) 18 | RUN make maintainer-clean >/dev/null 2>&1|| true 19 | RUN ./bootstrap.sh 2>&1 20 | RUN ./configure 2>&1 ${CONFIG_ARGS} 21 | RUN make deb 22 | -------------------------------------------------------------------------------- /Sources/Cfyaml/Dockerfile.alpine: -------------------------------------------------------------------------------- 1 | ARG IMAGE=alpine 2 | FROM ${IMAGE} 3 | # install build dependencies 4 | RUN apk update 5 | RUN apk add musl-dev gcc autoconf automake libtool git make pkgconf bash 6 | # configure argument 7 | ARG CONFIG_ARGS 8 | ENV CONFIG_ARGS=${CONFIG_ARGS:-"--enable-debug --prefix=/usr"} 9 | COPY . /build 10 | WORKDIR /build 11 | # do a maintainer clean if the directory was unclean (it can fail) 12 | RUN make maintainer-clean >/dev/null 2>&1|| true 13 | RUN ./bootstrap.sh 2>&1 14 | RUN ./configure 2>&1 ${CONFIG_ARGS} 15 | RUN make 16 | # NOTE: no check, since alpine it's only a build test distro 17 | -------------------------------------------------------------------------------- /Sources/Cfyaml/Dockerfile.centos: -------------------------------------------------------------------------------- 1 | ARG IMAGE=centos 2 | FROM ${IMAGE} 3 | # install build dependencies 4 | RUN yum update -y 5 | RUN yum install -y gcc autoconf automake libtool git make pkgconf 6 | # configure argument 7 | ARG CONFIG_ARGS 8 | ENV CONFIG_ARGS=${CONFIG_ARGS:-"--enable-debug --prefix=/usr"} 9 | COPY . /build 10 | WORKDIR /build 11 | # do a maintainer clean if the directory was unclean (it can fail) 12 | RUN make maintainer-clean >/dev/null 2>&1|| true 13 | RUN ./bootstrap.sh 2>&1 14 | RUN ./configure 2>&1 ${CONFIG_ARGS} 15 | RUN make 16 | # NOTE: no check, since alpine it's only a build test distro 17 | -------------------------------------------------------------------------------- /Sources/Cfyaml/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Pantelis Antoniou 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /Sources/Cfyaml/Makefile.am: -------------------------------------------------------------------------------- 1 | BUILT_SOURCES = .version 2 | .version: 3 | echo $(VERSION) > $@-t && mv $@-t $@ 4 | dist-hook: 5 | echo $(VERSION) > $(distdir)/.tarball-version 6 | tarball-version: 7 | echo $(VERSION) > .tarball-version 8 | 9 | # files to keep in the distribution (in case you want to boostrap) 10 | EXTRA_DIST=bootstrap.sh \ 11 | build-aux/shave.in build-aux/shave-libtool.in \ 12 | build-aux/git-version-gen \ 13 | README.md LICENSE \ 14 | Dockerfile Dockerfile-build-deb \ 15 | Dockerfile.alpine Dockerfile.centos 16 | 17 | MAINTAINERCLEANFILES = \ 18 | Makefile.in src/Makefile.in config.h.in configure \ 19 | install-sh ltmain.sh missing mkinstalldirs \ 20 | config.log config.status config.guess config.sub config.h \ 21 | build-stamp compile depcomp acinclude.m4 aclocal.m4 \ 22 | stamp-h1 \ 23 | ar-lib m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \ 24 | m4/lt~obsolete.m4 src/mock/.dirstamp src/mock/Makefile.in \ 25 | config.h.in~ \ 26 | test-driver test/Makefile.in \ 27 | build-aux/ar-lib build-aux/compile build-aux/config.guess \ 28 | build-aux/config.sub build-aux/depcomp build-aux/install-sh \ 29 | build-aux/ltmain.sh build-aux/missing build-aux/tap-driver.sh 30 | 31 | DISTCLEANFILES = \ 32 | .version 33 | 34 | clean-local: 35 | 36 | SUBDIRS = src test doc 37 | 38 | pkgconfigdir = $(libdir)/pkgconfig 39 | pkgconfig_DATA = libfyaml.pc 40 | 41 | maintainer-clean-local: 42 | @rm -rf install sphinx 43 | @rm -rf install artifacts 44 | 45 | # extra file to put in the distribution 46 | EXTRA_DIST += \ 47 | scripts/create-virtual-env \ 48 | scripts/install-linuxdoc.sh \ 49 | scripts/run-check-errors.sh \ 50 | scripts/run-compare-dump.sh \ 51 | scripts/run-compare-examples.sh \ 52 | scripts/run-compare-parse.sh \ 53 | scripts/run-compare-scan.sh \ 54 | scripts/run-compare-testsuite.sh \ 55 | scripts/run-emit-check.sh \ 56 | scripts/run-kcachegrind.sh \ 57 | scripts/run-list-testsuite.sh \ 58 | scripts/run-massif.sh \ 59 | scripts/run-test.sh \ 60 | scripts/run-valgrind.sh \ 61 | scripts/show-desc.sh 62 | 63 | if HAVE_DOCKER 64 | docker: Dockerfile 65 | @DOCKER@ build -t libfyaml:$(VERSION) $(top_srcdir) 66 | endif 67 | -------------------------------------------------------------------------------- /Sources/Cfyaml/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # potato autoconf 3 | touch build-aux/tap-driver.sh 4 | autoreconf -fvi 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/doc/Makefile.am: -------------------------------------------------------------------------------- 1 | BUILDDIR=_build 2 | 3 | if HAVE_SPHINX 4 | 5 | MANPAGES1 = $(BUILDDIR)/man/fy-tool.1 6 | 7 | doc-%: 8 | srctree=@top_srcdir@ @SPHINX@ -M `echo $@ | sed -s 's/^doc-//g'` "@srcdir@" "$(BUILDDIR)" 9 | 10 | # if we have sphinx generate the manpages 11 | $(MANPAGES1): doc-man 12 | 13 | else 14 | 15 | # otherwise, install the canned ones 16 | MANPAGES1 = $(srcdir)/canned-man/fy-tool.1 17 | 18 | endif 19 | 20 | install-data-hook: $(MANPAGES1) 21 | $(MKDIR_P) "$(DESTDIR)$(mandir)/man1" 22 | @for i in "$(MANPAGES1)"; do \ 23 | $(INSTALL_DATA) $$i "$(DESTDIR)$(mandir)/man1"; \ 24 | done 25 | (cd "$(DESTDIR)$(mandir)/man1" && $(LN_S) -f fy-tool.1 fy-dump.1) 26 | (cd "$(DESTDIR)$(mandir)/man1" && $(LN_S) -f fy-tool.1 fy-filter.1) 27 | (cd "$(DESTDIR)$(mandir)/man1" && $(LN_S) -f fy-tool.1 fy-testsuite.1) 28 | (cd "$(DESTDIR)$(mandir)/man1" && $(LN_S) -f fy-tool.1 fy-join.1) 29 | (cd "$(DESTDIR)$(mandir)/man1" && $(LN_S) -f fy-tool.1 fy-ypath.1) 30 | (cd "$(DESTDIR)$(mandir)/man1" && $(LN_S) -f fy-tool.1 fy-compose.1) 31 | 32 | uninstall-hook: 33 | @for i in "$(MANPAGES1)"; do \ 34 | rm -f "$(DESTDIR)$(mandir)/man1/`basename $$i`"; \ 35 | done 36 | (cd "$(DESTDIR)$(mandir)/man1" && \ 37 | rm -f fy-dump.1 fy-filter.1 fy-testsuite.1 fy-join.1 fy-ypath.1 fy-compose.1) 38 | 39 | clean-local: 40 | @rm -rf "$(BUILDDIR)" 41 | 42 | maintainer-clean-local: 43 | @rm -rf Makefile.in 44 | 45 | EXTRA_DIST = \ 46 | conf.py \ 47 | index.rst \ 48 | intro.rst \ 49 | libfyaml.rst \ 50 | man/fy-tool.rst \ 51 | canned-man/fy-tool.1 52 | -------------------------------------------------------------------------------- /Sources/Cfyaml/doc/index.rst: -------------------------------------------------------------------------------- 1 | .. libfyaml documentation master file, created by 2 | sphinx-quickstart on Sat May 25 20:55:33 2019. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to libfyaml's documentation! 7 | ==================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :caption: Contents: 12 | 13 | intro 14 | man/fy-tool 15 | libfyaml 16 | 17 | 18 | Indices and tables 19 | ================== 20 | 21 | * :ref:`genindex` 22 | * :ref:`modindex` 23 | * :ref:`search` 24 | -------------------------------------------------------------------------------- /Sources/Cfyaml/doc/intro.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | This is the documentation for libfyaml, a fancy 1.2 YAML and JSON parser/writer. 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/doc/libfyaml.rst: -------------------------------------------------------------------------------- 1 | Public API 2 | ========== 3 | 4 | .. kernel-doc:: include/libfyaml.h 5 | :internal: 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/libfyaml.pc: -------------------------------------------------------------------------------- 1 | prefix=/usr/local 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: libfyaml 7 | Description: Fancy YAML 1.3 parser library 8 | Version: 0.9 9 | Libs: -L${libdir} -lpthread -lfyaml 10 | Cflags: -I${includedir} -D_THREAD_SAFE -pthread 11 | -------------------------------------------------------------------------------- /Sources/Cfyaml/libfyaml.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libfyaml 7 | Description: Fancy YAML 1.3 parser library 8 | Version: @PACKAGE_VERSION@ 9 | Libs: -L${libdir} @ASAN_LIBS@ @PTHREAD_LIBS@ -lfyaml 10 | Cflags: -I${includedir} @ASAN_CFLAGS@ @PTHREAD_CFLAGS@ 11 | -------------------------------------------------------------------------------- /Sources/Cfyaml/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004, 2011-2019, 2021-2022 Free Software Foundation, 4 | # Inc. 5 | # Written by Scott James Remnant, 2004 6 | # 7 | # This file is free software; the Free Software Foundation gives 8 | # unlimited permission to copy and/or distribute it, with or without 9 | # modifications, as long as this notice is preserved. 10 | 11 | # @configure_input@ 12 | 13 | # serial 4245 ltversion.m4 14 | # This file is part of GNU Libtool 15 | 16 | m4_define([LT_PACKAGE_VERSION], [2.4.7]) 17 | m4_define([LT_PACKAGE_REVISION], [2.4.7]) 18 | 19 | AC_DEFUN([LTVERSION_VERSION], 20 | [macro_version='2.4.7' 21 | macro_revision='2.4.7' 22 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 23 | _LT_DECL(, macro_revision, 0) 24 | ]) 25 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/create-virtual-env: -------------------------------------------------------------------------------- 1 | virtualenv -p python3 sphinx 2 | . sphinx/bin/activate 3 | pip3 install sphinx 4 | pip3 install git+http://github.com/return42/linuxdoc.git 5 | pip3 install sphinx_rtd_theme 6 | pip3 install sphinx-markdown-builder 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/install-linuxdoc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | pip3 install --user git+http://github.com/return42/linuxdoc.git 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/run-compare-dump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # VALGRIND="" 3 | VALGRIND="valgrind" 4 | BN=`basename $1` 5 | ON="output/$BN" 6 | mkdir -p output 7 | a="$ON.libyaml.dump" 8 | b="$ON.libfyaml.dump" 9 | ./src/libfyaml-parser -mlibyaml-dump "$1" >"$a" 10 | ./src/libfyaml-parser -mdump "$1" >"$b" 11 | diff -au "$a" "$b" | tee "$ON.dump.diff" 12 | ./src/libfyaml-parser -mscan -d0 "$1" >"$ON.dump.log" 2>&1 13 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/run-compare-examples.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for i in $*; do 4 | echo "checking: $i" 5 | ./run-compare-scan.sh $i 6 | ./run-compare-parse.sh $i 7 | echo 8 | done 9 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/run-compare-parse.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # VALGRIND="" 3 | VALGRIND="valgrind" 4 | BN=`basename $1` 5 | ON="output/$BN" 6 | mkdir -p output 7 | a="$ON.libyaml.parse" 8 | b="$ON.libfyaml.parse" 9 | ./src/libfyaml-parser -mlibyaml-parse "$1" >"$a" 10 | ./src/libfyaml-parser -mparse "$1" >"$b" 11 | diff -u "$a" "$b" | tee "$ON.parse.diff" 12 | ./src/libfyaml-parser -mparse -d0 "$1" >"$ON.parse.log" 2>&1 13 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/run-compare-scan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # VALGRIND="" 3 | VALGRIND="valgrind" 4 | BN=`basename $1` 5 | ON="output/$BN" 6 | mkdir -p output 7 | a="$ON.libyaml.scan" 8 | b="$ON.libfyaml.scan" 9 | ./src/libfyaml-parser -mlibyaml-scan "$1" >"$a" 10 | ./src/libfyaml-parser -mscan "$1" >"$b" 11 | diff -u "$a" "$b" | tee "$ON.scan.diff" 12 | ./src/libfyaml-parser -mscan -d0 "$1" >"$ON.scan.log" 2>&1 13 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/run-emit-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | BN=`basename $1` 3 | ON="output/$BN" 4 | mkdir -p output 5 | a="$ON.1.dump" 6 | b="$ON.2.dump" 7 | ./src/fy-tool --testsuite "$1" >"$a" 8 | ./src/fy-tool --dump "$1" | ./src/fy-tool --testsuite - >"$b" 9 | diff -au "$a" "$b" | tee "$ON.12.diff" 10 | if [ ! -s "${ON}.12.diff" ] ; then 11 | rm -f "${ON}.1.dump" "${ON}.2.dump" "${ON}.12.diff" 12 | fi 13 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/run-kcachegrind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # LD_LIBRARY_PATH=${PWD}/src/.libs/ valgrind --leak-check=full ./src/.libs/libfyaml-parser -mscan "$1" 2>&1 | tee valgrind.log 3 | LD_LIBRARY_PATH=${PWD}/src/.libs/ valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes \ 4 | ./src/.libs/libfyaml-parser $* 2>&1 | tee valgrind.log 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/run-list-testsuite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ERROR=1 4 | PASS=1 5 | 6 | while true; do 7 | case "$1" in 8 | -- ) shift; break ;; 9 | 10 | --pass | -p) 11 | ERROR=0 12 | PASS=1 13 | shift ;; 14 | 15 | --errors | -e ) 16 | ERROR=1 17 | PASS=0 18 | shift ;; 19 | 20 | * ) break ;; 21 | esac 22 | done 23 | 24 | declare -a rf 25 | 26 | # check tty mode (whether we can colorize) 27 | if [ -t 1 ]; then 28 | GRN="\e[32m" 29 | RED="\e[31m" 30 | GRY="\e[37m" 31 | YLW="\e[33m" 32 | CYN="\e[36m" 33 | NRM="\e[0m" 34 | else 35 | GRN="" 36 | RED="" 37 | GRY="" 38 | YLW="" 39 | CYN="" 40 | NRM="" 41 | fi 42 | 43 | rf=() 44 | i=0 45 | for prefix in $*; do 46 | echo "Collecting tests from $prefix" 47 | while read full ; do 48 | 49 | # full-path:prefix:path-without-prefix:path-without-prefix-filename 50 | relative=`echo $full | sed -e "s#^$prefix##g"` 51 | file=`echo $relative | sed -e "s#/in.yaml##g" | tr '/' '-'` 52 | rf+=( "$full:$prefix:$relative:$file" ) 53 | # echo ${rf[$i]} 54 | i=$(($i + 1)) 55 | done < <(find "$prefix" -name "in.yaml" -print | sort) 56 | done 57 | 58 | count=${#rf[@]} 59 | 60 | for (( i=0; i < $count; i++)); do 61 | v="${rf[$i]}" 62 | full=`echo $v | cut -d: -f1` 63 | prefix=`echo $v | cut -d: -f2` 64 | relative=`echo $v | cut -d: -f3` 65 | file=`echo $v | cut -d: -f4` 66 | # echo "$i: full=$full prefix=$prefix relative=$relative file=$file" 67 | 68 | f="output/$file.yaml" 69 | 70 | has_yaml=1 71 | 72 | desc=`echo $full | sed -e 's#in.yaml#===#'` 73 | desctxt="" 74 | if [ -e "$desc" ]; then 75 | descf=`realpath "$desc"` 76 | desctxt=`cat 2>/dev/null "$descf"` 77 | has_desc=1 78 | else 79 | has_desc=0 80 | fi 81 | 82 | errf=`echo $full | sed -e 's#in.yaml#error#'` 83 | if [ -e "$errf" ] ; then 84 | expected_error="1" 85 | has_error=1 86 | else 87 | expected_error="0" 88 | has_error=0 89 | fi 90 | 91 | if [ $expected_error == 0 -a $PASS != 1 ]; then 92 | continue 93 | fi 94 | 95 | if [ $expected_error == 1 -a $ERROR != 1 ]; then 96 | continue 97 | fi 98 | 99 | if [ $expected_error == 0 ]; then 100 | col="$GRN" 101 | else 102 | col="$RED" 103 | fi 104 | echo -e "$col$file$NRM: $desctxt" 105 | done 106 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/run-massif.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # LD_LIBRARY_PATH=${PWD}/src/.libs/ valgrind --leak-check=full ./src/.libs/libfyaml-parser -mscan "$1" 2>&1 | tee valgrind.log 3 | LD_LIBRARY_PATH=${PWD}/src/.libs/ valgrind --tool=massif ./src/.libs/libfyaml-parser $* 2>&1 | tee massif.log 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/run-valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # LD_LIBRARY_PATH=${PWD}/src/.libs/ valgrind --leak-check=full ./src/.libs/libfyaml-parser -mscan "$1" 2>&1 | tee valgrind.log 3 | LD_LIBRARY_PATH=${PWD}/src/.libs/ valgrind --track-origins=yes --leak-check=full --error-exitcode=5 ./src/.libs/libfyaml-parser $* 2>&1 | tee valgrind.log 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/scripts/show-desc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | for i in output/*.desc; do echo -n "$i: "; cat $i; done 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3avx2_la-blake3.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3avx2_la-blake3_avx2.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3avx2_la-blake3_avx2_x86-64_unix.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3avx512_la-blake3.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3avx512_la-blake3_avx512.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3avx512_la-blake3_avx512_x86-64_unix.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3neon_la-blake3.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3neon_la-blake3_neon.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3portable_la-blake3.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3portable_la-blake3_portable.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3sse2_la-blake3.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3sse2_la-blake3_sse2.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3sse2_la-blake3_sse2_x86-64_unix.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3sse41_la-blake3.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3sse41_la-blake3_sse41.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libb3sse41_la-blake3_sse41_x86-64_unix.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libfyaml_la-blake3_backend.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libfyaml_la-blake3_be_cpusimd.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libfyaml_la-blake3_host_state.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/blake3/.deps/libfyaml_la-fy-blake3.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/internal/.deps/fy_b3sum-fy-b3sum.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/internal/.deps/fy_thread-fy-thread.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/internal/.deps/libfyaml_parser-libfyaml-parser.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-accel.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-atom.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-composer.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-diag.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-doc.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-docbuilder.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-docstate.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-dump.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-emit.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-event.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-input.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-parse.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-path.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-token.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-types.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/.deps/libfyaml_la-fy-walk.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/fy-accel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-accel.h - YAML accelerated access methods 3 | * 4 | * Copyright (c) 2020 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | #ifndef FY_ACCEL_H 9 | #define FY_ACCEL_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include "config.h" 13 | #endif 14 | 15 | #include 16 | 17 | #include 18 | 19 | #include "fy-list.h" 20 | #include "fy-typelist.h" 21 | 22 | struct fy_accel_entry { 23 | struct list_head node; 24 | const void *key; 25 | const void *value; 26 | uint8_t hash[0]; 27 | }; 28 | FY_TYPE_FWD_DECL_LIST(accel_entry); 29 | FY_TYPE_DECL_LIST(accel_entry); 30 | 31 | struct fy_accel; 32 | 33 | struct fy_hash_desc { 34 | unsigned int size; 35 | unsigned int max_bucket_grow_limit; 36 | bool unique; 37 | int (*hash)(struct fy_accel *xl, const void *key, void *userdata, void *hash); 38 | bool (*eq)(struct fy_accel *xl, const void *hash, const void *key1, const void *key2, void *userdata); 39 | }; 40 | 41 | struct fy_accel { 42 | const struct fy_hash_desc *hd; 43 | void *userdata; 44 | unsigned int count; 45 | unsigned int nbuckets; 46 | unsigned int next_exp2; 47 | struct fy_accel_entry_list *buckets; 48 | }; 49 | 50 | int 51 | fy_accel_setup(struct fy_accel *xl, 52 | const struct fy_hash_desc *hd, 53 | void *userdata, 54 | unsigned int min_buckets); 55 | 56 | void fy_accel_cleanup(struct fy_accel *xl); 57 | 58 | int fy_accel_resize(struct fy_accel *xl, unsigned int min_buckets); 59 | int fy_accel_grow(struct fy_accel *xl); 60 | int fy_accel_shrink(struct fy_accel *xl); 61 | 62 | int fy_accel_insert(struct fy_accel *xl, const void *key, const void *value); 63 | const void *fy_accel_lookup(struct fy_accel *xl, const void *key); 64 | int fy_accel_remove(struct fy_accel *xl, const void *key); 65 | 66 | struct fy_accel_entry_iter { 67 | struct fy_accel *xl; 68 | const void *key; 69 | void *hash; 70 | struct fy_accel_entry_list *xlel; 71 | struct fy_accel_entry *xle; 72 | uint64_t hash_inline[4]; /* to avoid allocation */ 73 | }; 74 | 75 | struct fy_accel_entry * 76 | fy_accel_entry_insert(struct fy_accel *xl, const void *key, const void *value); 77 | 78 | struct fy_accel_entry * 79 | fy_accel_entry_lookup(struct fy_accel *xl, const void *key); 80 | struct fy_accel_entry * 81 | fy_accel_entry_lookup_key_value(struct fy_accel *xl, const void *key, const void *value); 82 | 83 | void fy_accel_entry_remove(struct fy_accel *xl, struct fy_accel_entry *xle); 84 | 85 | struct fy_accel_entry * 86 | fy_accel_entry_iter_start(struct fy_accel_entry_iter *xli, 87 | struct fy_accel *xl, const void *key); 88 | void fy_accel_entry_iter_finish(struct fy_accel_entry_iter *xli); 89 | struct fy_accel_entry * 90 | fy_accel_entry_iter_next(struct fy_accel_entry_iter *xli); 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/fy-composer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-composer.h - YAML composer 3 | * 4 | * Copyright (c) 2021 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | #ifndef FY_COMPOSER_H 9 | #define FY_COMPOSER_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include "config.h" 13 | #endif 14 | 15 | #include 16 | 17 | #include 18 | 19 | #include "fy-list.h" 20 | #include "fy-typelist.h" 21 | 22 | #include "fy-emit-accum.h" 23 | #include "fy-path.h" 24 | 25 | struct fy_composer; 26 | struct fy_token; 27 | struct fy_diag; 28 | struct fy_event; 29 | struct fy_eventp; 30 | struct fy_document_builder; 31 | 32 | struct fy_composer_ops { 33 | /* single process event callback */ 34 | enum fy_composer_return (*process_event)(struct fy_composer *fyc, struct fy_path *path, struct fy_event *fye); 35 | struct fy_document_builder *(*create_document_builder)(struct fy_composer *fyc); 36 | }; 37 | 38 | struct fy_composer_cfg { 39 | const struct fy_composer_ops *ops; 40 | void *userdata; 41 | struct fy_diag *diag; 42 | }; 43 | 44 | struct fy_composer { 45 | struct fy_composer_cfg cfg; 46 | struct fy_path_list paths; 47 | }; 48 | 49 | struct fy_composer *fy_composer_create(struct fy_composer_cfg *cfg); 50 | void fy_composer_destroy(struct fy_composer *fyc); 51 | int fy_composer_process_event(struct fy_composer *fyc, struct fy_event *fye); 52 | 53 | struct fy_composer_cfg *fy_composer_get_cfg(struct fy_composer *fyc); 54 | void *fy_composer_get_cfg_userdata(struct fy_composer *fyc); 55 | struct fy_diag *fy_composer_get_diag(struct fy_composer *fyc); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/fy-docstate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-docstate.h - YAML document state header. 3 | * 4 | * Copyright (c) 2019 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | #ifndef FY_DOCSTATE_H 9 | #define FY_DOCSTATE_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include "config.h" 13 | #endif 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include "fy-ctype.h" 23 | #include "fy-list.h" 24 | #include "fy-typelist.h" 25 | #include "fy-token.h" 26 | 27 | struct fy_document; 28 | 29 | struct fy_document_state { 30 | int refs; 31 | struct fy_version version; 32 | bool version_explicit : 1; 33 | bool tags_explicit : 1; 34 | bool start_implicit : 1; 35 | bool end_implicit : 1; 36 | bool started_explicit : 1; 37 | bool json_mode : 1; 38 | struct fy_mark start_mark; 39 | struct fy_mark end_mark; 40 | struct fy_token *fyt_vd; /* version directive */ 41 | struct fy_token_list fyt_td; /* tag directives */ 42 | }; 43 | 44 | struct fy_document_state *fy_document_state_alloc(void); 45 | void fy_document_state_free(struct fy_document_state *fyds); 46 | struct fy_document_state *fy_document_state_ref(struct fy_document_state *fyds); 47 | void fy_document_state_unref(struct fy_document_state *fyds); 48 | 49 | int fy_document_state_append_tag(struct fy_document_state *fyds, 50 | const char *handle, const char *prefix, 51 | bool is_default); 52 | 53 | struct fy_document_state *fy_document_state_default( 54 | const struct fy_version *default_version, 55 | const struct fy_tag * const *default_tags); 56 | 57 | struct fy_document_state *fy_document_state_copy(struct fy_document_state *fyds); 58 | int fy_document_state_merge(struct fy_document_state *fyds, 59 | struct fy_document_state *fydsc); 60 | 61 | struct fy_token *fy_document_state_lookup_tag_directive(struct fy_document_state *fyds, 62 | const char *handle, size_t handle_size); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/fy-event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-event.h - YAML parser private event definition 3 | * 4 | * Copyright (c) 2019 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | #ifndef FY_EVENT_H 9 | #define FY_EVENT_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include "config.h" 13 | #endif 14 | 15 | #include 16 | 17 | #include 18 | 19 | #include "fy-list.h" 20 | #include "fy-typelist.h" 21 | 22 | /* private event type */ 23 | FY_TYPE_FWD_DECL_LIST(eventp); 24 | struct fy_eventp { 25 | struct list_head node; 26 | struct fy_event e; 27 | }; 28 | FY_TYPE_DECL_LIST(eventp); 29 | 30 | struct fy_eventp *fy_eventp_alloc(void); 31 | void fy_eventp_free(struct fy_eventp *fyep); 32 | 33 | /* called from internal emitter */ 34 | void fy_eventp_release(struct fy_eventp *fyep); 35 | 36 | struct fy_eventp *fy_parse_eventp_alloc(struct fy_parser *fyp); 37 | void fy_parse_eventp_recycle(struct fy_parser *fyp, struct fy_eventp *fyep); 38 | 39 | struct fy_eventp *fy_emit_eventp_alloc(struct fy_emitter *fye); 40 | void fy_emit_eventp_recycle(struct fy_emitter *emit, struct fy_eventp *fyep); 41 | 42 | struct fy_eventp *fy_parse_eventp_clone(struct fy_parser *fyp, struct fy_eventp *fyep_src, bool strip_anchors); 43 | struct fy_token *fy_event_get_and_clear_anchor_token(struct fy_event *fye); 44 | const char *fy_event_get_anchor(struct fy_event *fye, size_t *anchor_lenp); 45 | 46 | struct fy_document_iterator; 47 | 48 | struct fy_eventp *fy_document_iterator_eventp_alloc(struct fy_document_iterator *fydi); 49 | void fy_document_iterator_eventp_recycle(struct fy_document_iterator *fydi, struct fy_eventp *fyep); 50 | struct fy_event *fy_document_iterator_event_create(struct fy_document_iterator *document_iterator, enum fy_event_type type, ...); 51 | struct fy_event *fy_document_iterator_event_vcreate(struct fy_document_iterator *document_iterator, enum fy_event_type type, va_list ap); 52 | void fy_document_iterator_event_free(struct fy_document_iterator *document_iterator, struct fy_event *fye); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/lib/fy-types.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-types.c - types definition 3 | * 4 | * Copyright (c) 2019 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | #ifdef HAVE_CONFIG_H 9 | #include "config.h" 10 | #endif 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include "fy-parse.h" 28 | 29 | /* parse only types */ 30 | FY_PARSE_TYPE_DEFINE_SIMPLE(indent); 31 | FY_PARSE_TYPE_DEFINE_SIMPLE(simple_key); 32 | FY_PARSE_TYPE_DEFINE_SIMPLE(parse_state_log); 33 | FY_PARSE_TYPE_DEFINE_SIMPLE(flow); 34 | FY_PARSE_TYPE_DEFINE_SIMPLE(streaming_alias); 35 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/thread/.deps/libfyaml_la-fy-thread.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/thread/fy-thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-thread.h - Lighting fast thread pool implementation 3 | * 4 | * Copyright (c) 2023 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | #ifndef FY_THREAD_H 9 | #define FY_THREAD_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include "config.h" 13 | #endif 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #ifndef __APPLE__ 22 | #include 23 | #else 24 | #include 25 | #endif 26 | 27 | #include "fy-bit64.h" 28 | #include "fy-align.h" 29 | 30 | #include 31 | 32 | // #define FY_THREAD_DEBUG /* define to enable debugging information to stderr */ 33 | // #define FY_THREAD_PORTABLE /* define to use the portable implementation even on linux */ 34 | 35 | struct fy_work_pool { 36 | _Atomic(size_t) work_left; 37 | #if defined(__linux__) && !defined(FY_THREAD_PORTABLE) 38 | _Atomic(uint32_t) done; 39 | #elif defined(__APPLE__) 40 | dispatch_semaphore_t sem; 41 | #else 42 | sem_t sem; 43 | #endif 44 | }; 45 | 46 | struct fy_thread { 47 | struct fy_thread_pool *tp; 48 | unsigned int id; 49 | pthread_t tid; 50 | _Atomic(struct fy_thread_work *)work; 51 | _Atomic(struct fy_thread_work *)next_work; 52 | #if defined(__linux__) && !defined(FY_THREAD_PORTABLE) 53 | _Atomic(uint32_t) submit; 54 | _Atomic(uint32_t) done; 55 | #else 56 | pthread_mutex_t lock; 57 | pthread_cond_t cond; 58 | pthread_mutex_t wait_lock; 59 | pthread_cond_t wait_cond; 60 | #endif 61 | }; 62 | 63 | struct fy_thread_pool { 64 | struct fy_thread_pool_cfg cfg; 65 | unsigned int num_threads; 66 | struct fy_thread *threads; 67 | _Atomic(uint64_t) *freep; 68 | _Atomic(uint64_t) *lootp; 69 | pthread_key_t key; 70 | }; 71 | 72 | /* those are internal only */ 73 | int fy_thread_pool_setup(struct fy_thread_pool *tp, const struct fy_thread_pool_cfg *cfg); 74 | void fy_thread_pool_cleanup(struct fy_thread_pool *tp); 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/tool/.deps/fy_tool-fy-tool.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/util/.deps/libfyaml_la-fy-blob.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/util/.deps/libfyaml_la-fy-ctype.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/util/.deps/libfyaml_la-fy-utf8.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/util/.deps/libfyaml_la-fy-utils.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/util/fy-align.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-align.h - various align related stuff 3 | * 4 | * Copyright (c) 2023 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | #ifndef FY_ALIGN_H 10 | #define FY_ALIGN_H 11 | 12 | #ifdef HAVE_CONFIG_H 13 | #include "config.h" 14 | #endif 15 | 16 | #include 17 | #include 18 | 19 | #if defined(__GNUC__) || defined(__clang__) 20 | #define FY_ALIGNED_TO(x) __attribute__ ((aligned(x))) 21 | #elif defined(_MSC_VER) 22 | #define FY_ALIGNED_TO(x) __declspec(align(x)) 23 | #else 24 | #define FY_ALIGNED_TO(x) /* nothing */ 25 | #endif 26 | 27 | #define FY_ALIGN(_align, _x) (((_x) + ((_align) - 1)) & ~((_align) - 1)) 28 | 29 | /* cachelines are universally 64 bytes */ 30 | #define FY_CACHELINE_SIZE 64 31 | #define FY_CACHELINE_SIZE_ALIGN(_x) FY_ALIGN(FY_CACHELINE_SIZE, _x) 32 | #define FY_CACHELINE_ALIGN FY_ALIGNED_TO(FY_CACHELINE_SIZE) 33 | 34 | /* provide posix_memalign for platforms that don't have it */ 35 | #ifdef _WIN32 36 | static inline int posix_memalign(void **ptr, size_t align, size_t size) 37 | { 38 | void *p; 39 | 40 | /* must be a power of two */ 41 | if ((size & (size -1)) != 0) { 42 | *ptr = NULL; 43 | return EINVAL; 44 | } 45 | 46 | p = _aligned_malloc(size, align); 47 | if (!p) { 48 | *ptr = NULL; 49 | return ENOMEM; 50 | } 51 | return p; 52 | } 53 | 54 | static inline void posix_memalign_free(void *p) 55 | { 56 | _aligned_free(p); 57 | } 58 | 59 | #else 60 | /* normal implementations just use free */ 61 | static inline void posix_memalign_free(void *p) 62 | { 63 | free(p); 64 | } 65 | #endif 66 | 67 | static inline void *fy_align_alloc(size_t align, size_t size) 68 | { 69 | void *p; 70 | int rc; 71 | 72 | size = FY_ALIGN(align, size); 73 | rc = posix_memalign(&p, align, size); 74 | if (rc) 75 | return NULL; 76 | return p; 77 | } 78 | 79 | static inline void fy_align_free(void *p) 80 | { 81 | if (p) 82 | posix_memalign_free(p); 83 | } 84 | 85 | static inline void *fy_cacheline_alloc(size_t size) 86 | { 87 | return fy_align_alloc(FY_CACHELINE_SIZE, size); 88 | } 89 | 90 | static inline void fy_cacheline_free(void *p) 91 | { 92 | fy_align_free(p); 93 | } 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/util/fy-bit64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-bit64.h - various bit64 methods 3 | * 4 | * Copyright (c) 2023 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | #ifndef FY_BIT64_H 10 | #define FY_BIT64_H 11 | 12 | #ifdef HAVE_CONFIG_H 13 | #include "config.h" 14 | #endif 15 | 16 | #include 17 | 18 | #define FY_BIT64(x) ((uint64_t)1 << (x)) 19 | #define FY_BIT64_COUNT(_x) (((_x) + 63) / 64) 20 | #define FY_BIT64_SIZE(_x) ((size_t)((((_x) + 63) / 64) * sizeof(uint64_t))) 21 | 22 | #if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__) 23 | 24 | #define FY_BIT64_LOWEST(_x) ((unsigned int)__builtin_ctzll((unsigned long long)(_x))) 25 | #define FY_BIT64_HIGHEST(_x) ((unsigned int)__builtin_clzll((unsigned long long)(_x))) 26 | #define FY_BIT64_POPCNT(_x) ((unsigned int)__builtin_popcountl((unsigned long long)(_x))) 27 | 28 | static inline unsigned int fy_bit64_lowest(uint64_t x) 29 | { 30 | return FY_BIT64_LOWEST(x); 31 | } 32 | 33 | static inline unsigned int fy_bit64_highest(uint64_t x) 34 | { 35 | return FY_BIT64_HIGHEST(x); 36 | } 37 | 38 | static inline unsigned int FY_bit64_popcnt(uint64_t x) 39 | { 40 | return FY_BIT64_POPCNT(x); 41 | } 42 | 43 | #else /* portable implementation */ 44 | 45 | static inline unsigned int FY_BIT64_LOWEST(uint64_t x) 46 | { 47 | unsigned int c = 0; 48 | 49 | if (!(x & 0x00000000ffffffffULL)) { x >>= 32; c += 32; } 50 | if (!(x & 0x000000000000ffffULL)) { x >>= 16; c += 16; } 51 | if (!(x & 0x00000000000000ffULL)) { x >>= 8; c += 8; } 52 | if (!(x & 0x000000000000000fULL)) { x >>= 4; c += 4; } 53 | if (!(x & 0x0000000000000003ULL)) { x >>= 2; c += 2; } 54 | if (!(x & 0x0000000000000001ULL)) { c += 1; } 55 | return c; 56 | } 57 | 58 | static inline unsigned int FY_BIT64_HIGHEST(uint64_t x) 59 | { 60 | unsigned int c = 0; 61 | 62 | if (x & 0xffffffff00000000ULL) { x >>= 32; c += 32; } 63 | if (x & 0x00000000ffff0000ULL) { x >>= 16; c += 16; } 64 | if (x & 0x000000000000ff00ULL) { x >>= 8; c += 8; } 65 | if (x & 0x00000000000000f0ULL) { x >>= 4; c += 4; } 66 | if (x & 0x000000000000000cULL) { x >>= 2; c += 2; } 67 | if (x & 0x0000000000000002ULL) { c += 1; } 68 | return c; 69 | } 70 | 71 | static inline unsigned int FY_BIT64_POPCNT(uint64_t x) 72 | { 73 | unsigned int count; 74 | 75 | for (count = 0; x; x &= x - 1) 76 | count++; 77 | return count; 78 | } 79 | 80 | #define FY_BIT64_LOWEST(_x) fy_bit64_lowest(_x) 81 | #define FY_BIT64_HIGEST(_x) fy_bit64_highest(_x) 82 | #define FY_BIT64_POPCNT(_x) fy_bit64_popcnt(_x) 83 | 84 | #endif 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/util/fy-blob.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-blob.c - binary blob handling 3 | * 4 | * Copyright (c) 2023 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | #ifdef HAVE_CONFIG_H 9 | #include "config.h" 10 | #endif 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "fy-blob.h" 19 | 20 | /* define optimized methods for probing */ 21 | BR_DEFINE_WX(br_probe_w, 8, false, false); 22 | BR_DEFINE_WX(br_probe_w, 16, false, false); 23 | BR_DEFINE_WX(br_probe_w, 32, false, false); 24 | BR_DEFINE_WX(br_probe_w, 64, false, false); 25 | 26 | /* define optimized methods for writing */ 27 | BR_DEFINE_WX(br_native_w, 8, false, true); 28 | BR_DEFINE_WX(br_native_w, 16, false, true); 29 | BR_DEFINE_WX(br_native_w, 32, false, true); 30 | BR_DEFINE_WX(br_native_w, 64, false, true); 31 | 32 | BR_DEFINE_WX(br_bswap_w, 8, true, true); 33 | BR_DEFINE_WX(br_bswap_w, 16, true, true); 34 | BR_DEFINE_WX(br_bswap_w, 32, true, true); 35 | BR_DEFINE_WX(br_bswap_w, 64, true, true); 36 | 37 | void *fy_blob_read(const char *file, size_t *sizep) 38 | { 39 | struct stat sb; 40 | void *blob = NULL; 41 | uint8_t *p; 42 | size_t size, left; 43 | ssize_t rdn; 44 | int fd = -1, rc; 45 | 46 | if (!file || !sizep) 47 | goto err_out; 48 | 49 | fd = open(file, O_RDONLY); 50 | if (fd < 0) 51 | goto err_out; 52 | 53 | rc = fstat(fd, &sb); 54 | if (rc < 0) 55 | goto err_out; 56 | 57 | size = sb.st_size; 58 | blob = malloc(size); 59 | if (!blob) 60 | goto err_out; 61 | 62 | p = blob; 63 | left = size; 64 | while (left > 0) { 65 | do { 66 | rdn = read(fd, p, left); 67 | } while (rdn == -1 && errno == EAGAIN); 68 | if (rdn < 0) 69 | goto err_out; 70 | p += rdn; 71 | left -= rdn; 72 | } 73 | close(fd); 74 | 75 | *sizep = size; 76 | return blob; 77 | 78 | err_out: 79 | if (blob) 80 | free(blob); 81 | if (fd >= 0) 82 | close(fd); 83 | return NULL; 84 | } 85 | 86 | int fy_blob_write(const char *file, const void *blob, size_t size) 87 | { 88 | int fd = -1; 89 | const uint8_t *p; 90 | size_t left; 91 | ssize_t wrn; 92 | 93 | if (!file || !blob) 94 | return -1; 95 | 96 | fd = open(file, O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IRGRP | S_IROTH); 97 | if (fd < 0) 98 | goto err_out; 99 | 100 | p = blob; 101 | left = size; 102 | while (left > 0) { 103 | do { 104 | wrn = write(fd, p, left); 105 | } while (wrn == -1 && errno == EAGAIN); 106 | if (wrn < 0) 107 | goto err_out; 108 | p += wrn; 109 | left -= wrn; 110 | } 111 | close(fd); 112 | 113 | return 0; 114 | 115 | err_out: 116 | if (fd >= 0) 117 | close(fd); 118 | return -1; 119 | } 120 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/util/fy-ctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-ctype.c - ctype utilities 3 | * 4 | * Copyright (c) 2019 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | */ 9 | #ifdef HAVE_CONFIG_H 10 | #include "config.h" 11 | #endif 12 | 13 | #include 14 | #include 15 | 16 | #include "fy-ctype.h" 17 | 18 | const char *fy_uri_esc(const char *s, size_t len, uint8_t *code, int *code_len) 19 | { 20 | const char *e = s + len; 21 | int j, k, width; 22 | uint8_t octet; 23 | char c; 24 | 25 | width = 0; 26 | k = 0; 27 | do { 28 | /* check for enough space for %XX */ 29 | if ((e - s) < 3) 30 | return NULL; 31 | 32 | /* if more than one run, expect '%' */ 33 | if (s[0] != '%') 34 | return NULL; 35 | 36 | octet = 0; 37 | for (j = 0; j < 2; j++) { 38 | c = s[1 + j]; 39 | octet <<= 4; 40 | if (c >= '0' && c <= '9') 41 | octet |= c - '0'; 42 | else if (c >= 'a' && c <= 'f') 43 | octet |= 10 + c - 'a'; 44 | else 45 | octet |= 10 + c - 'A'; 46 | } 47 | if (!width) { 48 | width = fy_utf8_width_by_first_octet(octet); 49 | if (!width) 50 | return NULL; 51 | k = 0; 52 | } 53 | if (k >= *code_len) 54 | return NULL; 55 | 56 | code[k++] = octet; 57 | 58 | /* skip over the 3 character escape */ 59 | s += 3; 60 | 61 | } while (--width > 0); 62 | 63 | *code_len = k; 64 | 65 | return s; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/util/fy-endian.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fy-endian.h - simple system endian header wrapper 3 | * 4 | * Copyright (c) 2023 Pantelis Antoniou 5 | * 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | #ifndef FY_ENDIAN_H 9 | #define FY_ENDIAN_H 10 | 11 | #if defined(__linux__) || defined(__CYGWIN__) || defined(__OpenBSD__) 12 | # include 13 | #elif defined(__APPLE__) 14 | # include 15 | # include 16 | #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) 17 | # include 18 | #elif defined(_MSC_VER) 19 | # include 20 | # ifdef __GNUC__ 21 | # include 22 | # endif 23 | #else 24 | # error unsupported platform 25 | #endif 26 | 27 | #if !defined(__BYTE_ORDER) && defined(BYTE_ORDER) 28 | #define __BYTE_ORDER BYTE_ORDER 29 | #endif 30 | 31 | #if !defined(__BIG_ENDIAN) && defined(BIG_ENDIAN) 32 | #define __BIG_ENDIAN BIG_ENDIAN 33 | #endif 34 | 35 | #if !defined(__LITTLE_ENDIAN) && defined(LITTLE_ENDIAN) 36 | #define __LITTLE_ENDIAN LITTLE_ENDIAN 37 | #endif 38 | 39 | #if !defined(__BYTE_ORDER) || !defined(__BIG_ENDIAN) || !defined(__LITTLE_ENDIAN) 40 | # error Platform does not define endian macros 41 | #endif 42 | 43 | /* no-one cares about PDP endian anymore */ 44 | 45 | /* make the macros work for 8 bit too */ 46 | #ifndef bswap_8 47 | #define bswap_8(x) (x) 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Sources/Cfyaml/src/xxhash/.deps/libfyaml_la-xxhash.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/stamp-h1: -------------------------------------------------------------------------------- 1 | timestamp for config.h 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/.deps/libfyaml_test-libfyaml-test-core.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/.deps/libfyaml_test-libfyaml-test-emit.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/.deps/libfyaml_test-libfyaml-test-meta.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/.deps/libfyaml_test-libfyaml-test-private-id.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/.deps/libfyaml_test-libfyaml-test-private.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/.deps/libfyaml_test-libfyaml-test.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors-1.yaml: -------------------------------------------------------------------------------- 1 | base: &base 2 | name: this-is-a-name 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors-2.yaml: -------------------------------------------------------------------------------- 1 | base: &base { name: this-is-a-name } 2 | 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors-3.yaml: -------------------------------------------------------------------------------- 1 | &base { name: this-is-a-name } 2 | 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors-4.1.yaml: -------------------------------------------------------------------------------- 1 | base: &base 2 | name: Everyone has same name 3 | age: 10 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors-4.yaml: -------------------------------------------------------------------------------- 1 | base: &base 2 | name: Everyone has same name 3 | age: 10 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors-on-empty-scalars.yaml: -------------------------------------------------------------------------------- 1 | - &a 2 | - a 3 | - 4 | &a1 : a 5 | b: &b 6 | - 7 | &c : &a2 8 | - 9 | ? &d 10 | - 11 | ? &e 12 | : &a3 13 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors-on-empty-scalars1.yaml: -------------------------------------------------------------------------------- 1 | - 2 | ? &e 3 | : &a 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors-on-empty-scalars2.yaml: -------------------------------------------------------------------------------- 1 | - 2 | ? 3 | : 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors-on-empty-scalars3.yaml: -------------------------------------------------------------------------------- 1 | - 2 | ? a 3 | : 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors-on-empty-scalars4.yaml: -------------------------------------------------------------------------------- 1 | - 2 | ? &a 3 | : 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/anchors.yaml: -------------------------------------------------------------------------------- 1 | base: &base 2 | name: Everyone has same name 3 | 4 | foo: &foo 5 | <<: *base 6 | age: 10 7 | 8 | bar: &bar 9 | <<: *base 10 | age: 20 11 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/array.yaml: -------------------------------------------------------------------------------- 1 | - member 2 | - member2 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/block.yaml: -------------------------------------------------------------------------------- 1 | - item 1 2 | # STREAM_START FYTT_STREAM_START 3 | # BLOCK_SEQUENCE_START FYTT_BLOCK_SEQUENCE_START 4 | # BLOCK_ENTRY FYTT_BLOCK_ENTRY 5 | # SCALAR value='item 1' style=PLAIN FYTT_SCALAR value='item 1' style=PLAIN 6 | # BLOCK_END FYTT_BLOCK_END 7 | # STREAM_END FYTT_STREAM_END 8 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/block2.yaml: -------------------------------------------------------------------------------- 1 | - item 1 2 | - item 2 3 | # STREAM_START 4 | # BLOCK_SEQUENCE_START 5 | # BLOCK_ENTRY 6 | # SCALAR value='item 1' style=PLAIN 7 | # BLOCK_ENTRY 8 | # SCALAR value='item 2' style=PLAIN 9 | # BLOCK_END 10 | # STREAM_END 11 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/block3.yaml: -------------------------------------------------------------------------------- 1 | one: one-value 2 | two: two-value 3 | three: three-value 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/block4.yaml: -------------------------------------------------------------------------------- 1 | test: | 2 | 3 | foo 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/block6.yaml: -------------------------------------------------------------------------------- 1 | --- |+ 2 | ab 3 | 4 | 5 | ... 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/block7.yaml: -------------------------------------------------------------------------------- 1 | block-scalar: | 2 | Test 3 | 12 4 | testing 5 | FOO 6 | ... 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/blocked.yaml: -------------------------------------------------------------------------------- 1 | |- 2 | ab 3 | 4 | ... 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/blockind.yaml: -------------------------------------------------------------------------------- 1 | sequence: 2 | - one 3 | - two 4 | mapping: 5 | ? sky 6 | : blue 7 | sea : green 8 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c1.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | foo # comment 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c10.yaml: -------------------------------------------------------------------------------- 1 | # root comment 2 | 3 | # top comment of A 4 | - A # right comment of A 5 | # bottom comment of A 6 | 7 | # top comment of B 8 | - B # right comment of B 9 | # bottom comment of B 10 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c11.yaml: -------------------------------------------------------------------------------- 1 | [ 2 | # top comment of A 3 | A, # right comment of A 4 | # bottom comment of A 5 | 6 | # top comment of A 7 | B, # right comment of A 8 | # bottom comment of A 9 | ] 10 | 11 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c12.yaml: -------------------------------------------------------------------------------- 1 | key: # key-comment 2 | value # value-comment 3 | key2: 4 | key3: value 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c13.yaml: -------------------------------------------------------------------------------- 1 | foo: bar # comment 2 | { foo: bar }: # comment2 3 | baz 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c2.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # top comment 3 | foo # right comment 4 | # bottom comment 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c3.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | foo: bar # comment 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c4.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | { 3 | foo: bar, # comment 4 | baz: frooz 5 | } 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c5.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | { 3 | foo: bar, # comment 4 | # top comment 5 | baz: frooz # last comment 6 | } 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c6.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | [ 3 | foo, # comment 4 | bar 5 | ] 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c7.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | [ 3 | [ foo, bar ], # comment 4 | baz 5 | ] 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c8.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | { 3 | foo: bar, # foo:bar comment 4 | baz: frooz, # baz:frooz comment 5 | whee: yikes # whee: yikes comment 6 | } 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/c9.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # 1 3 | # top foo:bar comment 4 | # 2 5 | foo: bar # foo:bar comment 6 | # continue foo:bar comment 7 | 8 | # 3 9 | # top baz:frooz comment 10 | # 4 11 | # break 12 | baz: frooz # baz:frooz comment 13 | 14 | # top whee comment 15 | whee: # whee: comment 16 | level: # level: comment 17 | 1: level-1 # level-1 comment 18 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/compact1.yaml: -------------------------------------------------------------------------------- 1 | - # Empty 2 | - | 3 | block node 4 | - - one # Compact 5 | - - two # sequence 6 | - - one: two # Compact mapping 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/compactblockmap.yaml: -------------------------------------------------------------------------------- 1 | ? a: b 2 | : c: d 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/complexkey.yaml: -------------------------------------------------------------------------------- 1 | ? complex : value 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/complexkey2.yaml: -------------------------------------------------------------------------------- 1 | { ? complex: value } 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/complexkey3.yaml: -------------------------------------------------------------------------------- 1 | { 2 | ? complex key: value 3 | } 4 | # STREAM_START FYTT_STREAM_START 5 | # FLOW_MAPPING_START FYTT_FLOW_MAPPING_START 6 | # KEY FYTT_KEY 7 | # SCALAR value='complex key' style=PLAIN FYTT_KEY 8 | # VALUE FYTT_SCALAR value='complex key' style=PLAIN 9 | # SCALAR value='value' style=PLAIN FYTT_VALUE 10 | # FLOW_MAPPING_END FYTT_SCALAR value='value' style=PLAIN 11 | # STREAM_END FYTT_FLOW_MAPPING_END 12 | # FYTT_STREAM_END 13 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/complexkey4.yaml: -------------------------------------------------------------------------------- 1 | [ ? complex: value ] 2 | # STREAM_START FYTT_STREAM_START 3 | # FLOW_SEQUENCE_START FYTT_FLOW_SEQUENCE_START 4 | # KEY FYTT_KEY 5 | # SCALAR value='complex key' style=PLAIN FYTT_KEY 6 | # VALUE FYTT_SCALAR value='complex key' style=PLAIN 7 | # SCALAR value='value' style=PLAIN FYTT_VALUE 8 | # FLOW_SEQUENCE_END FYTT_SCALAR value='value' style=PLAIN 9 | # STREAM_END FYTT_FLOW_SEQUENCE_END 10 | # FYTT_STREAM_END 11 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/complexkey5.yaml: -------------------------------------------------------------------------------- 1 | { ? { complex: 2 }: value } 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/complexkey6.yaml: -------------------------------------------------------------------------------- 1 | ? complex 2 | : value 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/complexkey7.yaml: -------------------------------------------------------------------------------- 1 | - ? complex : value 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/complexkey8.yaml: -------------------------------------------------------------------------------- 1 | [ ]: foo 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/complexkey9.yaml: -------------------------------------------------------------------------------- 1 | ? a: b 2 | c: d 3 | : e 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/docstartend.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | foo 3 | ... 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/dqscalar.yaml: -------------------------------------------------------------------------------- 1 | - "quoted" 2 | - "quoted\nescaped new line" 3 | - "quoted 4 | explicit new line" 5 | - "" 6 | - " 7 | " 8 | - " pre-spaces" 9 | - "post-spaces " 10 | - "key": value 11 | - "key\nnewline": value 12 | - "\r\"\\foo" 13 | - "\x20" 14 | - "testing \0null" 15 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/dqzero.yaml: -------------------------------------------------------------------------------- 1 | "zero\0zero" 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/emptydoc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/emptykey.yaml: -------------------------------------------------------------------------------- 1 | - [ YAML : separate ] 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/emptystream.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/outfoxx/PotentCodables/1f46aa4840e27fcbbcf1ec7a238fcfaadd739abb/Sources/Cfyaml/test/emitter-examples/emptystream.yaml -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/flow.yaml: -------------------------------------------------------------------------------- 1 | a: 2 | b: 3 | - c 4 | - d 5 | - e 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/flow1.yaml: -------------------------------------------------------------------------------- 1 | a: 2 | b: [ c, 3 | d, 4 | e ] 5 | 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/flow2.yaml: -------------------------------------------------------------------------------- 1 | a: 2 | b: [ c, 3 | d, 4 | e, [ f, g, h, i, j 5 | k, l, m, n, o 6 | ] 7 | ] 8 | 9 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/fold.yaml: -------------------------------------------------------------------------------- 1 | fold: > 2 | 1 2 3 | 3 4 | 4 5 | fold2: > 6 | 1 2 7 | 3 # comment 8 | 4 9 | fold3: > 10 | 1 2 11 | 3 12 | 4 13 | fold4: > 14 | 1 2 15 | 16 | 3 17 | 4 18 | fold5: > 19 | 1 20 | 21 | 2 22 | fold6: > 23 | 1 2 24 | 3 25 | 4 26 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/fold2.yaml: -------------------------------------------------------------------------------- 1 | fold: > 2 | 1 2 3 | 3 4 4 | 5 5 | 6 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/fold3.yaml: -------------------------------------------------------------------------------- 1 | fold4: > 2 | 1 2 3 | 4 | 3 5 | 4 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/fold4.yaml: -------------------------------------------------------------------------------- 1 | fold: > 2 | 1 3 | 4 | 2 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/fold5.yaml: -------------------------------------------------------------------------------- 1 | fold3: > 2 | 1 2 3 | 3 4 | 4 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/folded.yaml: -------------------------------------------------------------------------------- 1 | clip: > 2 | This is a single clipped line 3 | keep: >+ 4 | This is a single kept line 5 | strip: >- 6 | This is a single stripped line 7 | clip2: > 8 | These are two 9 | clipped lines 10 | keep2: >+ 11 | These are two 12 | kept lines 13 | strip2: >- 14 | These are two 15 | striped lines 16 | clip3: > 17 | These are two 18 | clipped lines with trailing line breaks 19 | 20 | 21 | 22 | keep3: >+ 23 | These are two 24 | kept lines with trailing line breaks 25 | 26 | 27 | 28 | strip3: >- 29 | These are two 30 | striped lines with trailing line breaks 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/folded2.yaml: -------------------------------------------------------------------------------- 1 | "folded 2 | to a space, 3 | 4 | to a line feed, or \ 5 | \ non-content" 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/folding.yaml: -------------------------------------------------------------------------------- 1 | > 2 | foo 3 | 4 | bar 5 | 6 | baz 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/global-tag.yaml: -------------------------------------------------------------------------------- 1 | %TAG ! tag:clarkevans.com,2002: 2 | --- !shape 3 | # Use the ! handle for presenting 4 | # tag:clarkevans.com,2002:circle 5 | - !circle 6 | center: &ORIGIN {x: 73, y: 129} 7 | radius: 7 8 | - !line 9 | start: *ORIGIN 10 | finish: { x: 89, y: 102 } 11 | - !label 12 | start: *ORIGIN 13 | color: 0xFFEEBB 14 | text: Pretty vector drawing. 15 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/invoice.yaml: -------------------------------------------------------------------------------- 1 | invoice: 34843 2 | date : !!str 2001-01-23 3 | bill-to: &id001 4 | given : Chris 5 | family : Dumars 6 | address: 7 | lines: | 8 | 458 Walkman Dr. 9 | Suite #292 10 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/json.yaml: -------------------------------------------------------------------------------- 1 | {"key": ["value", 3]} 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/keyflow.yaml: -------------------------------------------------------------------------------- 1 | { 2 | a: b, 3 | c: { d: e }, 4 | { f: g }: h, 5 | } 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/keykey.yaml: -------------------------------------------------------------------------------- 1 | top1: 2 | key1 : value1 3 | "top2": value2 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/keykey2.yaml: -------------------------------------------------------------------------------- 1 | { }: value 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/line.yaml: -------------------------------------------------------------------------------- 1 | text: | 2 | a 3 | 4 | b 5 | 6 | c 7 | 8 | d 9 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/literal.yaml: -------------------------------------------------------------------------------- 1 | clip: | 2 | This is a single clipped line 3 | keep: |+ 4 | This is a single kept line 5 | strip: |- 6 | This is a single stripped line 7 | clip2: | 8 | These are two 9 | clipped lines 10 | keep2: |+ 11 | These are two 12 | kept lines 13 | strip2: |- 14 | These are two 15 | striped lines 16 | clip3: | 17 | These are two 18 | clipped lines with trailing line breaks 19 | 20 | 21 | 22 | keep3: |+ 23 | These are two 24 | kept lines with trailing line breaks 25 | 26 | 27 | 28 | strip3: |- 29 | These are two 30 | striped lines with trailing line breaks 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/literal1.yaml: -------------------------------------------------------------------------------- 1 | a: | 2 | literal 3 | ... 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/literal2.yaml: -------------------------------------------------------------------------------- 1 | | 2 | 3 | 4 | literal 5 | 6 | 7 | text 8 | 9 | # Comment 10 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/literal3.yaml: -------------------------------------------------------------------------------- 1 | --- | 2 | foo 3 | bar 4 | ... 5 | foo 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/literal4.yaml: -------------------------------------------------------------------------------- 1 | keep3: |+ 2 | These are two 3 | kept lines with trailing line breaks 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/mapping.yaml: -------------------------------------------------------------------------------- 1 | key: value 2 | other-key: other-value 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/mergekeyspec.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - &CENTER { x: 1, y: 2 } 3 | - &LEFT { x: 0, y: 2 } 4 | - &BIG { r: 10 } 5 | - &SMALL { r: 1 } 6 | 7 | # All the following maps are equal: 8 | 9 | - # Explicit keys 10 | x: 1 11 | y: 2 12 | r: 10 13 | label: center/big 14 | 15 | - # Merge one map 16 | << : *CENTER 17 | r: 10 18 | label: center/big 19 | 20 | - # Merge multiple maps 21 | << : [ *CENTER, *BIG ] 22 | label: center/big 23 | 24 | - # Override 25 | << : [ *BIG, *LEFT, *SMALL ] 26 | x: 1 27 | label: center/big 28 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/multi-document.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | First 4 | ... 5 | %YAML 1.2 6 | --- 7 | Second 8 | ... 9 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/multiline-quoted-key.yaml: -------------------------------------------------------------------------------- 1 | { "foo 2 | bar" : 20 } 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/multiline-simple-key.yaml: -------------------------------------------------------------------------------- 1 | { foo 2 | bar : 20 } 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/nodeprop.yaml: -------------------------------------------------------------------------------- 1 | !!str &a1 "foo": 2 | !!str bar 3 | &a2 baz : *a1 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/nodeprop2.yaml: -------------------------------------------------------------------------------- 1 | "foo": 2 | bar 3 | &a2 baz : fuzz 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/numbers-flow.yaml: -------------------------------------------------------------------------------- 1 | - 100 2 | - 12.5 3 | - -130 4 | - 1.3e9 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/numbers.yaml: -------------------------------------------------------------------------------- 1 | [100, 12.5, -130, 1.3e+9] 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/plain-scalars-with-commas.yaml: -------------------------------------------------------------------------------- 1 | - Aa, 2 | Bb, C, 3 | D 4 | - Eee, 5 | F, Gg, 6 | E 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/plainlines.yaml: -------------------------------------------------------------------------------- 1 | 1st non-empty 2 | 3 | 2nd non-empty 4 | 3rd non-empty 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/plainscalar.yaml: -------------------------------------------------------------------------------- 1 | - plain 2 | - plain with spaces 3 | - plain with 4 | breaks and stuff 5 | - plain which should break at some point since it is somewhat longer than usual. nice weather eh... 6 | - plain with breaks 7 | 8 | and 9 | 10 | gaps 11 | - various two space stuff 12 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/quoted.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | " 3 | foo 4 | 5 | bar 6 | 7 | baz 8 | " 9 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/quotedbackslash.yaml: -------------------------------------------------------------------------------- 1 | "\ 2 | 123\ 3 | 456\ 4 | 789" 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scalar-multiline.yaml: -------------------------------------------------------------------------------- 1 | comment: 2 | Deliver here, but if not 3 | possible deliver there. 4 | 5 | 6 | Tatta! 7 | 8 | 9 | 10 | comment-2: 11 | " Deliver here, but if not 12 | possible deliver there. 13 | 14 | 15 | Tatta! " 16 | 17 | comment-3: 18 | ' Deliver here, but if not 19 | possible deliver there. 20 | 21 | 22 | Tatta! ' 23 | 24 | comment-4: 25 | Deliver here, but if not 26 | possible deliver there. 27 | 28 | 29 | Tatta! 30 | 31 | 32 | comment-5: 33 | "" 34 | 35 | comment-6: " 36 | " 37 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scalar-singlequoted.yaml: -------------------------------------------------------------------------------- 1 | simple: 'simple' 2 | multiline: 'multi line 3 | singled quoted scalar' 4 | multiline2: 'multi line 5 | singled quoted scalar 6 | 7 | with a newline ' 8 | comment-3: 9 | ' Deliver here, but if not 10 | possible deliver there. 11 | 12 | 13 | Tatta! ' 14 | 15 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scalar-space.yaml: -------------------------------------------------------------------------------- 1 | z: " 2 | " 3 | aa: foo 4 | bar 5 | a: " 6 | 7 | 8 | " 9 | b: "" 10 | c: 11 | 12 | b 13 | d: " 14 | " 15 | e: " 16 | 17 | " 18 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scalar-space1.yaml: -------------------------------------------------------------------------------- 1 | 0: " 2 | " 3 | a: " 4 | 5 | 6 | " 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scalars.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | plain-simple : plain-simple 3 | plain: This is a plain scalar # alright 4 | key with spaces-1 : scalar with spaces too 5 | key with spaces-2: scalar with spaces too 2 6 | key with spaces-3 : scalar with spaces too 3# comment 7 | key with spaces-4 : scalar with spaces too 4 # comment 8 | 9 | single-quoted: 'This is a single quoted scalar' 10 | single-quoted-escaped: 'This is a single quoted scalar with ''escapes''' 11 | double-quoted: "This is a double quoted scalar" 12 | double-quoted-escaped: "This is a double quoted\tscalar\nwith escapes" 13 | double-quoted-escaped2: "This is a double quoted\tscalar\nwith \x20 escapes" 14 | literal: | 15 | This is a literal scalar # comments included 16 | literal2: | 17 | This is a literal scalar 2 18 | More than one line 19 | Indentation 20 | Indeed 21 | folded: > 22 | This is a folded 23 | scalar 24 | ... 25 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scalars2.yaml: -------------------------------------------------------------------------------- 1 | key spaces: | 2 | Normal indent 3 | One more indent 4 | Back to normal 5 | folded : > 6 | Folding is easy to do 7 | Indenting too 8 | Roses are blue 9 | foo: bar 10 | another-fold: >- 11 | fold 12 | 1 13 | 2 14 | 3 15 | yet-another-fold: >+ 16 | another-fold 17 | 11 18 | 12 19 | 13 20 | more-fold: > 21 | more-fold 22 | 21 23 | 22 24 | 23 25 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-1.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG ! !foo 3 | %TAG !yaml! tag:yaml.org,2002: 4 | --- 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-10.yaml: -------------------------------------------------------------------------------- 1 | { 2 | a simple key: a value, # Note that the KEY token is produced. 3 | ? a complex key: another value, 4 | } 5 | # STREAM_START FYTT_STREAM_START 6 | # FLOW_MAPPING_START FYTT_FLOW_MAPPING_START 7 | # KEY FYTT_KEY 8 | # SCALAR value='a simple key' style=PLAIN FYTT_SCALAR value='a simple key' style=PLAIN 9 | # VALUE FYTT_VALUE 10 | # SCALAR value='a value' style=PLAIN FYTT_SCALAR value='a value' style=PLAIN 11 | # FLOW_ENTRY FYTT_FLOW_ENTRY 12 | # KEY FYTT_KEY 13 | # SCALAR value='a complex key' style=PLAIN FYTT_SCALAR value='a complex key' style=PLAIN 14 | # VALUE FYTT_VALUE 15 | # SCALAR value='another value' style=PLAIN FYTT_SCALAR value='another value' style=PLAIN 16 | # FLOW_ENTRY FYTT_FLOW_ENTRY 17 | # FLOW_MAPPING_END FYTT_FLOW_MAPPING_END 18 | # STREAM_END FYTT_STREAM_END 19 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-11.yaml: -------------------------------------------------------------------------------- 1 | - item 1 2 | - item 2 3 | - 4 | - item 3.1 5 | - item 3.2 6 | - 7 | key 1: value 1 8 | key 2: value 2 9 | # STREAM_START 10 | # BLOCK_SEQUENCE_START 11 | # BLOCK_ENTRY 12 | # SCALAR value='item 1' style=PLAIN 13 | # BLOCK_ENTRY 14 | # SCALAR value='item 2' style=PLAIN 15 | # BLOCK_ENTRY 16 | # BLOCK_SEQUENCE_START 17 | # BLOCK_ENTRY 18 | # SCALAR value='item 3.1' style=PLAIN 19 | # BLOCK_ENTRY 20 | # SCALAR value='item 3.2' style=PLAIN 21 | # BLOCK_END 22 | # BLOCK_ENTRY 23 | # BLOCK_MAPPING_START 24 | # KEY 25 | # SCALAR value='key 1' style=PLAIN 26 | # VALUE 27 | # SCALAR value='value 1' style=PLAIN 28 | # KEY 29 | # SCALAR value='key 2' style=PLAIN 30 | # VALUE 31 | # SCALAR value='value 2' style=PLAIN 32 | # BLOCK_END 33 | # BLOCK_END 34 | # STREAM_END 35 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-12.yaml: -------------------------------------------------------------------------------- 1 | a simple key: a value # The KEY token is produced here. 2 | ? a complex key 3 | : another value 4 | a mapping: 5 | key 1: value 1 6 | key 2: value 2 7 | a sequence: 8 | - item 1 9 | - item 2 10 | # STREAM-START(utf-8) 11 | # BLOCK-MAPPING-START 12 | # KEY 13 | # SCALAR("a simple key",plain) 14 | # VALUE 15 | # SCALAR("a value",plain) 16 | # KEY 17 | # SCALAR("a complex key",plain) 18 | # VALUE 19 | # SCALAR("another value",plain) 20 | # KEY 21 | # SCALAR("a mapping",plain) 22 | # BLOCK-MAPPING-START 23 | # KEY 24 | # SCALAR("key 1",plain) 25 | # VALUE 26 | # SCALAR("value 1",plain) 27 | # KEY 28 | # SCALAR("key 2",plain) 29 | # VALUE 30 | # SCALAR("value 2",plain) 31 | # BLOCK-END 32 | # KEY 33 | # SCALAR("a sequence",plain) 34 | # VALUE 35 | # BLOCK-SEQUENCE-START 36 | # BLOCK-ENTRY 37 | # SCALAR("item 1",plain) 38 | # BLOCK-ENTRY 39 | # SCALAR("item 2",plain) 40 | # BLOCK-END 41 | # BLOCK-END 42 | # STREAM-END 43 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-13.yaml: -------------------------------------------------------------------------------- 1 | key: 2 | - item 1 # BLOCK-SEQUENCE-START is NOT produced here. 3 | - item 2 4 | # STREAM-START(utf-8) 5 | # BLOCK-MAPPING-START 6 | # KEY 7 | # SCALAR("key",plain) 8 | # VALUE 9 | # BLOCK-ENTRY 10 | # SCALAR("item 1",plain) 11 | # BLOCK-ENTRY 12 | # SCALAR("item 2",plain) 13 | # BLOCK-END 14 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-2.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | ... 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-3.yaml: -------------------------------------------------------------------------------- 1 | 'a scalar' 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-4.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 'a scalar' 3 | ... 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-5.yaml: -------------------------------------------------------------------------------- 1 | 'a scalar' 2 | --- 3 | 'another scalar' 4 | --- 5 | 'yet another scalar' 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-6.yaml: -------------------------------------------------------------------------------- 1 | &A [ *A ] 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-7.yaml: -------------------------------------------------------------------------------- 1 | !!float "3.14" # A good approximation. 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-8-2.yaml: -------------------------------------------------------------------------------- 1 | --- # Implicit empty plain scalars do not produce tokens. 2 | --- a plain scalar 3 | --- 'a single-quoted scalar' 4 | --- "a double-quoted scalar" 5 | --- |- 6 | a literal scalar (|-) 7 | 8 | test 9 | 10 | 11 | --- >- 12 | a folded (>-) 13 | scalar 14 | 15 | test 16 | 17 | 18 | 19 | --- | 20 | a literal scalar (|) 21 | --- > 22 | a folded (>) 23 | scalar 24 | --- |+ 25 | a literal scalar (|+) 26 | --- >+ 27 | a folded (>+) 28 | scalar 29 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-8.yaml: -------------------------------------------------------------------------------- 1 | --- # Implicit empty plain scalars do not produce tokens. 2 | --- a plain scalar 3 | --- 'a single-quoted scalar' 4 | --- "a double-quoted scalar" 5 | --- |- 6 | a literal scalar 7 | --- >- 8 | a folded 9 | scalar 10 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/scanner-c-9.yaml: -------------------------------------------------------------------------------- 1 | [item 1, item 2, item 3] 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/seq.yaml: -------------------------------------------------------------------------------- 1 | # Outside flow collection: 2 | - ::vector 3 | - ": - ()" 4 | - Up, up, and away! 5 | - -123 6 | - http://example.com/foo#bar 7 | # Inside flow collection: 8 | - [ ::vector ] 9 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/seq1.yaml: -------------------------------------------------------------------------------- 1 | - 1 2 | - 2 3 | - 3 4 | - key: 5 | - value1 6 | - value 2 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/seq2.yaml: -------------------------------------------------------------------------------- 1 | - [ YAML : separate ] 2 | - [ : empty key entry ] 3 | - [ {JSON: like}:adjacent ] 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/seq3.yaml: -------------------------------------------------------------------------------- 1 | # - [ YAML : separate ] 2 | - [ "" : empty key entry ] 3 | # - [ {JSON: like}:adjacent ] 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/seq4.yaml: -------------------------------------------------------------------------------- 1 | [ : empty ] 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/seq5.yaml: -------------------------------------------------------------------------------- 1 | - : empty 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/seq6.yaml: -------------------------------------------------------------------------------- 1 | key: 2 | - value1 3 | - value 2 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/sets.yaml: -------------------------------------------------------------------------------- 1 | # Sets are represented as a 2 | # Mapping where each key is 3 | # associated with a null value 4 | --- 5 | ? a 6 | ? b 7 | ? c 8 | ? d 9 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simple.yaml: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simple1.yaml: -------------------------------------------------------------------------------- 1 | --- !!str &anchor 2 | foo 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simple2.yaml: -------------------------------------------------------------------------------- 1 | "foobar" 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simpleanchor.yaml: -------------------------------------------------------------------------------- 1 | &anchor key: value 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simpleanchor1.yaml: -------------------------------------------------------------------------------- 1 | a: &anchor b 2 | c: *anchor 3 | d: e 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simpleanchor2.yaml: -------------------------------------------------------------------------------- 1 | a: &anchor [ b, bb, b3, b4 ] 2 | c: *anchor 3 | d: e 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simpleanchor3.yaml: -------------------------------------------------------------------------------- 1 | a: &anchor 2 | - b 3 | - &another bb 4 | - b3 5 | - b4 6 | c: *anchor 7 | d: e 8 | f: *another 9 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simpleanchor4.yaml: -------------------------------------------------------------------------------- 1 | a: &anchor 2 | - b 3 | - &another bb 4 | - b3 5 | - b4 6 | c: 7 | d: 8 | e: *anchor 9 | f: *another 10 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simplefolded.yaml: -------------------------------------------------------------------------------- 1 | > 2 | this is a folded 3 | scalar 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simplekey.yaml: -------------------------------------------------------------------------------- 1 | key : value 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simplekey1.yaml: -------------------------------------------------------------------------------- 1 | { key : value } 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simplekey2.yaml: -------------------------------------------------------------------------------- 1 | root: # level 0 2 | key: # level 1 3 | value # level 2 4 | key2: # level 1 5 | value2 # level 2 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simplekey3.yaml: -------------------------------------------------------------------------------- 1 | { 2 | root: { 3 | key: value 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simplekey4.yaml: -------------------------------------------------------------------------------- 1 | a: b 2 | c: d 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simplekey5.yaml: -------------------------------------------------------------------------------- 1 | key: 2 | value 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simpleliteral.yaml: -------------------------------------------------------------------------------- 1 | | 2 | this is a literal 3 | scalar 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simpleseq.yaml: -------------------------------------------------------------------------------- 1 | - 1 2 | - 2 3 | - 3 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/simpleseq1.yaml: -------------------------------------------------------------------------------- 1 | - 1 2 | - 2 3 | - 3 4 | - 4: 5 | foo 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/singlepairimp.yaml: -------------------------------------------------------------------------------- 1 | - [ YAML : separate ] 2 | - [ ffo : empty key entry ] 3 | - [ {JSON: like}:adjacent ] 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/singlepairimp2.yaml: -------------------------------------------------------------------------------- 1 | [ [ foo ]: bar ] 2 | # [ foo ]: bar 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/sqscalar.yaml: -------------------------------------------------------------------------------- 1 | - 'quoted' 2 | - 'quoted\nescaped new line' 3 | - 'quoted 4 | explicit new line' 5 | - '' 6 | - ' ' 7 | - ' 8 | ' 9 | - ' pre-spaces' 10 | - 'post-spaces ' 11 | - 'key': value 12 | - 'key/newline': value 13 | - 'escaped '' quote' 14 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/sqscalarspace.yaml: -------------------------------------------------------------------------------- 1 | ' 2 | ' 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/strings.yaml: -------------------------------------------------------------------------------- 1 | unquoted: string 2 | literal-block: | 3 | This entire block of text will be the value of the 'literal-block' key, 4 | with line breaks being preserved. 5 | folded: > 6 | This entire block of text will be the value of 'folded', but this 7 | time, all newlines will be replaced with a single space. 8 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/t.yaml: -------------------------------------------------------------------------------- 1 | : a 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/t1.yaml: -------------------------------------------------------------------------------- 1 | x: a 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/t2.yaml: -------------------------------------------------------------------------------- 1 | ? : a 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/t3.yaml: -------------------------------------------------------------------------------- 1 | ? x : a 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/t4.yaml: -------------------------------------------------------------------------------- 1 | ? x # foo 2 | : a 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/t5.yaml: -------------------------------------------------------------------------------- 1 | { ? : a } 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/tabsmix.yaml: -------------------------------------------------------------------------------- 1 | - > 2 | 3 | detected 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/tagdirective.yaml: -------------------------------------------------------------------------------- 1 | %TAG !yaml! tag:yaml.org,2002: 2 | --- 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/tagesc.yaml: -------------------------------------------------------------------------------- 1 | %TAG !e! tag:example.com,2000:app/ 2 | --- 3 | - !local foo 4 | - !!str bar 5 | - !e!tag%21 baz 6 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/tags-1.yaml: -------------------------------------------------------------------------------- 1 | explicit_string: !!str 0.5 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/tags.yaml: -------------------------------------------------------------------------------- 1 | gif_file: !!binary | 2 | R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5 3 | OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+ 4 | +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC 5 | AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs= 6 | explicit_string: !!str 0.5 7 | python_tag: !!python/complex '1.0+2.0j' 8 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/test.yaml: -------------------------------------------------------------------------------- 1 | - 2 | a: b 3 | c: d 4 | - 5 | e: f 6 | g: h 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/test1.yaml: -------------------------------------------------------------------------------- 1 | aa: 2 | bb: cc 3 | dd: ee 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/test2.yaml: -------------------------------------------------------------------------------- 1 | a: b 2 | c: d 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/u.yaml: -------------------------------------------------------------------------------- 1 | { 2 | foo : !!str, 3 | !!str : bar, 4 | } 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/u1.yaml: -------------------------------------------------------------------------------- 1 | - [ : empty ] 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/u2.yaml: -------------------------------------------------------------------------------- 1 | - { : empty } 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/u3.yaml: -------------------------------------------------------------------------------- 1 | : empty 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/utf8-simple.yaml: -------------------------------------------------------------------------------- 1 | Τιμή ελληνική 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/utf8.yaml: -------------------------------------------------------------------------------- 1 | unqouted: string 2 | literal-block: | 3 | This entire block of text will be the value of the 'literal-block' key, 4 | with line breaks being preserved. 5 | folded: > 6 | This entire block of text will be the value of 'folded', but this 7 | time, all newlines will be replaced with a single space. 8 | key-en: "Τιμή ελληνική" 9 | κλειδί-ελ: "English value" 10 | 11 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/v.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | a: 0 3 | --- 4 | ? b : 1 5 | --- 6 | { c: 2 } 7 | --- 8 | { ? d : e } 9 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/v1.yaml: -------------------------------------------------------------------------------- 1 | ? key : value 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/v2.yaml: -------------------------------------------------------------------------------- 1 | { ? d : e } 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/version.yaml: -------------------------------------------------------------------------------- 1 | # test 2 | %YAML 1.1 3 | --- 4 | # more comments 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/weirdplain.yaml: -------------------------------------------------------------------------------- 1 | this is a:w weird plain 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/ws0.yaml: -------------------------------------------------------------------------------- 1 | --- scalar 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/ws1.yaml: -------------------------------------------------------------------------------- 1 | --- scalar 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/ws2.yaml: -------------------------------------------------------------------------------- 1 | "top1" : 2 | "key1" : &alias1 scalar1 3 | 'top2' : 4 | 'key2' : &alias2 scalar2 5 | top3: &node3 6 | *alias1 : scalar3 7 | top4: 8 | *alias2 : scalar4 9 | top5 : 10 | scalar5 11 | top6: 12 | &anchor6 'key6' : scalar6 13 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/ws3.yaml: -------------------------------------------------------------------------------- 1 | { first: Sammy, last: Sosa }: 2 | # Statistics: 3 | hr: # Home runs 4 | 65 5 | avg: # Average 6 | 0.278 7 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/y.yaml: -------------------------------------------------------------------------------- 1 | a: 2 | ? b 3 | : c 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/yaml-version.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | [1, 2, 3] 4 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/yy.yaml: -------------------------------------------------------------------------------- 1 | a: 2 | ? b : c 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/emitter-examples/zeroexplicit.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | ? 3 | - a 4 | - b 5 | : 6 | - c 7 | - d 8 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/jsontestsuite.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | count=0 4 | 5 | # count expected to pass 6 | for f in json-test-suite-data/test_parsing/y_*.json; do 7 | count=`expr $count + 1` 8 | done 9 | 10 | # add expected to fail 11 | for f in json-test-suite-data/test_parsing/n_*.json; do 12 | count=`expr $count + 1` 13 | done 14 | 15 | # add implementation defined 16 | for f in json-test-suite-data/test_parsing/i_*.json; do 17 | count=`expr $count + 1` 18 | done 19 | 20 | # output plan 21 | echo 1..$count 22 | 23 | i=0 24 | 25 | # expected to pass 26 | for f in json-test-suite-data/test_parsing/y_*.json; do 27 | 28 | i=`expr $i + 1` 29 | tf=`basename $f` 30 | 31 | ${TOP_BUILDDIR}/src/fy-tool --testsuite --streaming "$f" >/dev/null 32 | if [ $? -eq 0 ]; then 33 | res="ok" 34 | else 35 | res="not ok" 36 | fi 37 | 38 | echo "$res $i - $tf" 39 | done 40 | 41 | # expected to fail 42 | for f in json-test-suite-data/test_parsing/n_*.json; do 43 | 44 | i=`expr $i + 1` 45 | tf=`basename $f` 46 | 47 | ${TOP_BUILDDIR}/src/fy-tool --testsuite --streaming "$f" >/dev/null 48 | if [ $? -eq 0 ]; then 49 | res="not ok" 50 | else 51 | res="ok" 52 | fi 53 | 54 | echo "$res $i - $tf" 55 | done 56 | 57 | # implementation defined 58 | for f in json-test-suite-data/test_parsing/i_*.json; do 59 | 60 | i=`expr $i + 1` 61 | tf=`basename $f` 62 | 63 | ${TOP_BUILDDIR}/src/fy-tool --testsuite --streaming "$f" >/dev/null 64 | if [ $? -eq 0 ]; then 65 | ires="i-pass" 66 | else 67 | ires="i-fail" 68 | fi 69 | res="ok" 70 | 71 | echo "$res $i - $ires $tf" 72 | done 73 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/libfyaml.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "x$builddir" == "x" ]; then 4 | T=`realpath ./libfyaml-test` 5 | else 6 | T=`realpath ${builddir}/libfyaml-test` 7 | fi 8 | ${T} 9 | exit $? 10 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-env: -------------------------------------------------------------------------------- 1 | # test environment for libfyaml 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0002/===: -------------------------------------------------------------------------------- 1 | Duplicate key (plain scalar) 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0002/in.yaml: -------------------------------------------------------------------------------- 1 | foo: bar 2 | foo: baz 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0002/test.error: -------------------------------------------------------------------------------- 1 | :2:1: error: duplicate key 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0003/===: -------------------------------------------------------------------------------- 1 | Duplicate key (plain scalar, quoted scalar) 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0003/in.yaml: -------------------------------------------------------------------------------- 1 | foo: bar 2 | 'foo': baz 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0003/test.error: -------------------------------------------------------------------------------- 1 | :2:2: error: duplicate key 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0004/===: -------------------------------------------------------------------------------- 1 | Duplicate key (plain scalar, literal scalar) 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0004/in.yaml: -------------------------------------------------------------------------------- 1 | foo: bar 2 | ? |- 3 | foo 4 | : baz 5 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0004/test.error: -------------------------------------------------------------------------------- 1 | :3:1: error: duplicate key 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0005/===: -------------------------------------------------------------------------------- 1 | Duplicate key (sequence) 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0005/in.yaml: -------------------------------------------------------------------------------- 1 | [ foo ]: bar 2 | [ foo ]: baz 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0005/test.error: -------------------------------------------------------------------------------- 1 | :2:1: error: duplicate key 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0006/===: -------------------------------------------------------------------------------- 1 | Duplicate key (simple mapping) 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0006/in.yaml: -------------------------------------------------------------------------------- 1 | { foo: bar }: baz 2 | { foo: bar }: frooz 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0006/test.error: -------------------------------------------------------------------------------- 1 | :2:1: error: duplicate key 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0007/===: -------------------------------------------------------------------------------- 1 | Duplicate key (complex sorted mapping) 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0007/in.yaml: -------------------------------------------------------------------------------- 1 | { a: b, { e: f, g: h}: d}: foo 2 | { { g: h, e: f}: d, a: b}: bar 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0007/test.error: -------------------------------------------------------------------------------- 1 | :2:1: error: duplicate key 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0008/===: -------------------------------------------------------------------------------- 1 | Unknown alias 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0008/in.yaml: -------------------------------------------------------------------------------- 1 | a: *b 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0008/test.error: -------------------------------------------------------------------------------- 1 | :1:5: error: invalid alias 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0009/===: -------------------------------------------------------------------------------- 1 | Invalid merge key (referencing not a mapping) 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0009/in.yaml: -------------------------------------------------------------------------------- 1 | - &FOO foo 2 | - << : *FOO 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0009/test.error: -------------------------------------------------------------------------------- 1 | :2:9: error: invalid merge key value 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0010/===: -------------------------------------------------------------------------------- 1 | Invalid merge key (not an alias, scalar) 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0010/in.yaml: -------------------------------------------------------------------------------- 1 | - << : FOO 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0010/test.error: -------------------------------------------------------------------------------- 1 | :1:8: error: invalid merge key value 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0011/===: -------------------------------------------------------------------------------- 1 | Invalid merge key (not an alias sequence item) 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0011/in.yaml: -------------------------------------------------------------------------------- 1 | - &FOO foo 2 | - << : [ *FOO, bar ] 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/test-errors/0011/test.error: -------------------------------------------------------------------------------- 1 | :2:8: error: invalid merge key value 2 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/testemitter-restreaming.test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ${SRCDIR}/testemitter.test --restreaming 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/testemitter-streaming.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ${SRCDIR}/testemitter.test --streaming 3 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/testemitter.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | EXTRA_DUMP_ARGS="" 4 | 5 | if [ "x$1" == "x--streaming" ]; then 6 | EXTRA_DUMP_ARGS="$EXTRA_DUMP_ARGS --streaming" 7 | elif [ "x$1" == "x--restreaming" ]; then 8 | EXTRA_DUMP_ARGS="$EXTRA_DUMP_ARGS --streaming --recreating" 9 | fi 10 | 11 | count=0 12 | for f in "${SRCDIR}"/emitter-examples/*.yaml; do 13 | count=`expr $count + 1` 14 | done 15 | 16 | # output plan 17 | echo 1..$count 18 | 19 | i=0 20 | for f in "${SRCDIR}"/emitter-examples/*.yaml; do 21 | 22 | i=`expr $i + 1` 23 | tf=`basename $f` 24 | 25 | t1=`mktemp` 26 | t2=`mktemp` 27 | 28 | res="not ok" 29 | 30 | pass_parse=0 31 | ${TOP_BUILDDIR}/src/fy-tool --testsuite --disable-flow-markers "$f" >"$t1" 32 | if [ $? -eq 0 ]; then 33 | ${TOP_BUILDDIR}/src/fy-tool --dump ${EXTRA_DUMP_ARGS} "$f" | \ 34 | ${TOP_BUILDDIR}/src/fy-tool --testsuite --disable-flow-markers - >"$t2" 35 | if [ $? -eq 0 ]; then 36 | pass_parse=1 37 | fi 38 | fi 39 | 40 | # all errors test are expected to fail 41 | if [ "$pass_parse" == "1" ]; then 42 | diff -u "$t1" "$t2" 43 | if [ $? -eq 0 ]; then 44 | res="ok" 45 | else 46 | res="not ok" 47 | fi 48 | else 49 | res="not ok" 50 | fi 51 | 52 | rm -f "$t1" "$t2" 53 | 54 | echo "$res $i $tf" 55 | done 56 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/testerrors.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | count=0 4 | for dir in "${SRCDIR}"/test-errors/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do 5 | count=`expr $count + 1` 6 | done 7 | 8 | # output plan 9 | echo 1..$count 10 | 11 | i=0 12 | for dir in "${SRCDIR}"/test-errors/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do 13 | 14 | i=`expr $i + 1` 15 | desctxt=`cat 2>/dev/null "$dir/==="` 16 | tdir=`basename $dir` 17 | 18 | t=`mktemp` 19 | 20 | res="not ok" 21 | 22 | pass_yaml=0 23 | ${TOP_BUILDDIR}/src/fy-tool --dump -r "$dir/in.yaml" >"$t" 2>&1 24 | if [ $? -eq 0 ]; then 25 | pass_yaml=1 26 | fi 27 | 28 | errmsg=`cat "$t" | head -n1 | sed -e 's/^[^:]*//'` 29 | echo "errmsg: $errmsg" 30 | 31 | # replace with error message 32 | echo "$errmsg" >"$t" 33 | 34 | # all errors test are expected to fail 35 | if [ "$pass_yaml" == "0" ]; then 36 | res="ok" 37 | 38 | # diff is pointless under valgrind 39 | if [ "x$USE_VALGRIND" == "x" ]; then 40 | diff_err=0 41 | diff -u "$dir/test.error" "$t" 42 | if [ $? -eq 0 ]; then 43 | res="ok" 44 | else 45 | res="not ok" 46 | fi 47 | fi 48 | else 49 | res="not ok" 50 | fi 51 | 52 | rm -f "$t" 53 | 54 | echo "$res $i $tdir - $desctxt" 55 | done 56 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/testsuite-evstream.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | count=0 4 | for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do 5 | for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do 6 | # there must be a test there 7 | if [ ! -e "$tst/===" ]; then 8 | continue 9 | fi 10 | # skip tests that are expected to fail 11 | if [ -e "$tst/error" ]; then 12 | continue 13 | fi 14 | count=`expr $count + 1` 15 | done 16 | done 17 | 18 | # output plan 19 | echo 1..$count 20 | 21 | skiplist="2JQS" 22 | xfaillist="" 23 | 24 | i=0 25 | for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do 26 | 27 | for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do 28 | 29 | # there must be a test there 30 | if [ ! -e "$tst/===" ]; then 31 | continue 32 | fi 33 | 34 | # skip tests that are expected to fail 35 | if [ -e "$tst/error" ]; then 36 | continue 37 | fi 38 | 39 | i=`expr $i + 1` 40 | 41 | # strip trailing / 42 | t=${tst%/} 43 | # remove test-suite-data/ 44 | test_subtest_id=`echo $t | cut -d/ -f2-` 45 | test_id=`echo $test_subtest_id | cut -d/ -f1` 46 | subtest_id=`echo $test_subtest_id | cut -s -d/ -f2` 47 | 48 | desctxt=`cat 2>/dev/null "$tst/==="` 49 | 50 | t=`mktemp` 51 | 52 | directive="" 53 | for skip in $skiplist; do 54 | if [ "$test_subtest_id" == "$skip" ]; then 55 | directive=" # skip: duplicate keys in testcase; cannot load as document" 56 | break 57 | fi 58 | done 59 | 60 | res="ok" 61 | if [ "x$directive" == "x" ]; then 62 | res="not ok" 63 | # run the test using document-event-stream 64 | ${TOP_BUILDDIR}/src/fy-tool --testsuite --document-event-stream "$tst/in.yaml" >"$t" 65 | if [ $? -eq 0 ]; then 66 | diff -u "$tst/test.event" "$t" 67 | if [ $? -eq 0 ]; then 68 | res="ok" 69 | else 70 | res="not ok" 71 | fi 72 | else 73 | res="not ok" 74 | fi 75 | 76 | rm -f "$t" 77 | 78 | for xfail in $xfaillist; do 79 | if [ "$test_subtest_id" == "$xfail" ]; then 80 | directive=" # TODO: known failure." 81 | break 82 | fi 83 | done 84 | fi 85 | 86 | echo "$res $i $test_subtest_id - $desctxt$directive" 87 | done 88 | done 89 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/testsuite-json.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | count=0 4 | for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do 5 | for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do 6 | # there must be a test there 7 | if [ ! -e "$tst/===" ]; then 8 | continue 9 | fi 10 | # ignore tests which are expected to fail 11 | if [ -e "$tst/error" ]; then 12 | continue 13 | fi 14 | # a json file must be there 15 | if [ ! -e "$tst/in.json" ]; then 16 | continue 17 | fi 18 | count=`expr $count + 1` 19 | done 20 | done 21 | 22 | # output plan 23 | echo 1..$count 24 | 25 | skiplist="C4HZ" 26 | xfaillist="" 27 | 28 | i=0 29 | for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do 30 | 31 | for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do 32 | 33 | # ignore tests which are expected to fail 34 | if [ -e "$tst/error" ]; then 35 | continue 36 | fi 37 | # a json file must be there 38 | if [ ! -e "$tst/in.json" ]; then 39 | continue 40 | fi 41 | 42 | i=`expr $i + 1` 43 | 44 | # strip trailing / 45 | t=${tst%/} 46 | # remove test-suite-data/ 47 | test_subtest_id=`echo $t | cut -d/ -f2-` 48 | test_id=`echo $test_subtest_id | cut -d/ -f1` 49 | subtest_id=`echo $test_subtest_id | cut -s -d/ -f2` 50 | 51 | desctxt=`cat 2>/dev/null "$tst/==="` 52 | 53 | directive="" 54 | for skip in $skiplist; do 55 | if [ "$test_subtest_id" == "$skip" ]; then 56 | directive="# SKIP: does not apply to libfyaml" 57 | break 58 | fi 59 | done 60 | 61 | res="ok" 62 | 63 | if [ "x$directive" == "x" ]; then 64 | t1=`mktemp` 65 | t2=`mktemp` 66 | 67 | # output yaml in json format 68 | ${TOP_BUILDDIR}/src/fy-tool --dump --strip-labels --strip-tags --strip-doc -r -mjson "$tst/in.yaml" | "${JQ}" --sort-keys . >"$t1" 69 | 70 | # do the same with the json input (canonicalize) 71 | cat "$tst/in.json" | "${JQ}" --sort-keys . > "$t2" 72 | 73 | diff -u "$t1" "$t2" 74 | if [ $? -eq 0 ]; then 75 | res="ok" 76 | else 77 | res="not ok" 78 | fi 79 | 80 | rm -f "$t1" "$t2" 81 | 82 | for xfail in $xfaillist; do 83 | if [ "$test_subtest_id" == "$xfail" ]; then 84 | directive=" # TODO: known failure." 85 | break 86 | fi 87 | done 88 | fi 89 | 90 | echo "$res $i $test_subtest_id - $desctxt (JSON)$directive" 91 | done 92 | done 93 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/testsuite-resolution.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | count=0 4 | for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do 5 | for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do 6 | # there must be a test there 7 | if [ ! -e "$tst/===" ]; then 8 | continue 9 | fi 10 | # skip tests that are expected to fail 11 | if [ -e "$tst/error" ]; then 12 | continue 13 | fi 14 | # there must be an alias in the test 15 | grep -q '\*[A-Za-z]' "$tst/in.yaml" 16 | if [ $? -ne 0 ]; then 17 | continue 18 | fi 19 | count=`expr $count + 1` 20 | done 21 | done 22 | 23 | # output plan 24 | echo 1..$count 25 | 26 | # X38W has duplicate keys after resolution 27 | skiplist="2JQS X38W" 28 | xfaillist="" 29 | 30 | i=0 31 | for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do 32 | 33 | for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do 34 | 35 | # there must be a test there 36 | if [ ! -e "$tst/===" ]; then 37 | continue 38 | fi 39 | 40 | # skip tests that are expected to fail 41 | if [ -e "$tst/error" ]; then 42 | continue 43 | fi 44 | 45 | # there must be an alias in the test 46 | grep -q '\*[A-Za-z]' "$tst/in.yaml" 47 | if [ $? -ne 0 ]; then 48 | continue 49 | fi 50 | 51 | i=`expr $i + 1` 52 | 53 | # strip trailing / 54 | t=${tst%/} 55 | # remove test-suite-data/ 56 | test_subtest_id=`echo $t | cut -d/ -f2-` 57 | test_id=`echo $test_subtest_id | cut -d/ -f1` 58 | subtest_id=`echo $test_subtest_id | cut -s -d/ -f2` 59 | 60 | desctxt=`cat 2>/dev/null "$tst/==="` 61 | 62 | t1=`mktemp` 63 | t2=`mktemp` 64 | 65 | directive="" 66 | for skip in $skiplist; do 67 | if [ "$test_subtest_id" == "$skip" ]; then 68 | directive=" # skip: duplicate keys in testcase; cannot load as document" 69 | break 70 | fi 71 | done 72 | 73 | res="ok" 74 | if [ "x$directive" == "x" ]; then 75 | res="not ok" 76 | 77 | ${TOP_BUILDDIR}/src/fy-tool --dump --resolve "$tst/in.yaml" | ${TOP_BUILDDIR}/src/fy-tool --testsuite --disable-flow-markers - >"$t1" 78 | ${TOP_BUILDDIR}/src/fy-tool --dump --resolve --streaming "$tst/in.yaml" | ${TOP_BUILDDIR}/src/fy-tool --testsuite --disable-flow-markers - >"$t2" 79 | 80 | diff -u "$t1" "$t2" 81 | if [ $? -eq 0 ]; then 82 | res="ok" 83 | else 84 | res="not ok" 85 | fi 86 | 87 | rm -f "$t1" "$t2" 88 | 89 | for xfail in $xfaillist; do 90 | if [ "$test_subtest_id" == "$xfail" ]; then 91 | directive=" # TODO: known failure." 92 | break 93 | fi 94 | done 95 | fi 96 | 97 | echo "$res $i $test_subtest_id - $desctxt$directive" 98 | done 99 | done 100 | -------------------------------------------------------------------------------- /Sources/Cfyaml/test/testsuite.test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | count=0 4 | for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do 5 | for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do 6 | # there must be a test there 7 | if [ ! -e "$tst/===" ]; then 8 | continue 9 | fi 10 | count=`expr $count + 1` 11 | done 12 | done 13 | 14 | # output plan 15 | echo 1..$count 16 | 17 | skiplist="" 18 | xfaillist="" 19 | 20 | i=0 21 | for basetst in test-suite-data/[A-Z0-9][A-Z0-9][A-Z0-9][A-Z0-9]/; do 22 | 23 | for tst in ${basetst} ${basetst}[0-9][0-9]/ ${basetst}[0-9][0-9][0-9]/; do 24 | 25 | # there must be a test there 26 | if [ ! -e "$tst/===" ]; then 27 | continue 28 | fi 29 | 30 | i=`expr $i + 1` 31 | 32 | # strip trailing / 33 | t=${tst%/} 34 | # remove test-suite-data/ 35 | test_subtest_id=`echo $t | cut -d/ -f2-` 36 | test_id=`echo $test_subtest_id | cut -d/ -f1` 37 | subtest_id=`echo $test_subtest_id | cut -s -d/ -f2` 38 | 39 | desctxt=`cat 2>/dev/null "$tst/==="` 40 | 41 | t=`mktemp` 42 | 43 | directive="" 44 | for skip in $skiplist; do 45 | if [ "$test_subtest_id" == "$skip" ]; then 46 | directive=" # SKIP" 47 | break 48 | fi 49 | done 50 | 51 | res="ok" 52 | if [ "x$directive" == "x" ]; then 53 | res="not ok" 54 | 55 | pass_yaml=0 56 | ${TOP_BUILDDIR}/src/fy-tool --testsuite "$tst/in.yaml" >"$t" 57 | if [ $? -eq 0 ]; then 58 | pass_yaml=1 59 | fi 60 | 61 | if [ -e "$tst/error" ]; then 62 | # test is expected to fail 63 | if [ $pass_yaml == "0" ]; then 64 | res="ok" 65 | else 66 | res="not ok" 67 | fi 68 | else 69 | # test is expected to pass 70 | if [ $pass_yaml == "1" ]; then 71 | diff_yaml=0 72 | # diff -u "$tst/test.event" "$t" | sed -e 's/^/# /' 73 | diff -u "$tst/test.event" "$t" 74 | if [ $? -eq 0 ]; then 75 | res="ok" 76 | else 77 | res="not ok" 78 | fi 79 | else 80 | res="not ok" 81 | fi 82 | fi 83 | 84 | rm -f "$t" 85 | 86 | for xfail in $xfaillist; do 87 | if [ "$test_subtest_id" == "$xfail" ]; then 88 | directive=" # TODO: known failure." 89 | break 90 | fi 91 | done 92 | fi 93 | 94 | echo "$res $i $test_subtest_id - $desctxt$directive" 95 | done 96 | done 97 | -------------------------------------------------------------------------------- /Sources/CfyamlPatches/apply.sh: -------------------------------------------------------------------------------- 1 | 2 | FYAML_VER=$1 3 | PATCH_DIR="${PWD}/Sources/CfyamlPatches/v${FYAML_VER}" 4 | 5 | echo "Applying patches for version '${FYAML_VER}'" 6 | 7 | if [ -d "${PATCH_DIR}" ]; then 8 | 9 | for PATCH_FILE in "${PATCH_DIR}"/*.patch; do 10 | patch -V none -d "${PWD}/Sources/Cfyaml" -i "${PATCH_FILE}" 11 | done 12 | 13 | else 14 | echo "No patch directory for version ${FYYAML_VER}" 15 | exit 1 16 | fi 17 | -------------------------------------------------------------------------------- /Sources/CfyamlPatches/v0.9/0001-Prepare-for-Swift-package-build.patch: -------------------------------------------------------------------------------- 1 | From c1020b2ae1c8d5d4369e18daa52473f0ab04ed36 Mon Sep 17 00:00:00 2001 2 | From: Kevin Wooten 3 | Date: Sat, 8 Jun 2024 20:02:57 -0700 4 | Subject: [PATCH] Prepare for Swift package build 5 | 6 | --- 7 | config.h | 5 ++++- 8 | 1 file changed, 4 insertions(+), 1 deletion(-) 9 | 10 | diff --git a/config.h b/config.h 11 | index d394425..992bbda 100644 12 | --- a/config.h 13 | +++ b/config.h 14 | @@ -39,7 +39,7 @@ 15 | #define HAVE_LIBCLANG 0 16 | 17 | /* Define to 1 if you have libyaml available */ 18 | -#define HAVE_LIBYAML 1 19 | +#define HAVE_LIBYAML 0 20 | 21 | /* Define to 1 if you have the header file. */ 22 | /* #undef HAVE_MINIX_CONFIG_H */ 23 | @@ -282,3 +282,6 @@ 24 | 25 | /* Define as 'int' if doesn't define. */ 26 | /* #undef uid_t */ 27 | + 28 | +/* Ignore warnings for Swift package build */ 29 | +#pragma clang diagnostic ignored "-Wconversion" 30 | -- 31 | 2.39.3 (Apple Git-146) 32 | 33 | -------------------------------------------------------------------------------- /Sources/CfyamlPatches/v0.9/0003-Fixes-creating-blank-aka-ws-only-scalars-with-emit-e.patch: -------------------------------------------------------------------------------- 1 | From 1dc14fc555ddc537835030b11f9d156f4b6ec8da Mon Sep 17 00:00:00 2001 2 | From: Kevin Wooten 3 | Date: Sat, 8 Jun 2024 17:44:49 -0700 4 | Subject: [PATCH] Fixes creating blank (aka ws only) scalars with emit event 5 | api 6 | 7 | Adds a check in `fy_analyze_scalar_content` for scalars that start or end with whitespace or newlines. When this condition is true, it removes the `FYACF_FLOW_PLAIN` flag, ensuring whitespace-only tokens get output properly. 8 | 9 | Without this check, whitespace-only tokens created with `fy_emit_event_create` (or similar API functions) are output as a double-quoted zero-length string. 10 | --- 11 | src/lib/fy-token.c | 6 ++++++ 12 | 1 file changed, 6 insertions(+) 13 | 14 | diff --git a/src/lib/fy-token.c b/src/lib/fy-token.c 15 | index bfcf27d..35e8c34 100644 16 | --- a/src/lib/fy-token.c 17 | +++ b/src/lib/fy-token.c 18 | @@ -1515,6 +1515,12 @@ unsigned int fy_analyze_scalar_content(const char *data, size_t size, 19 | if (break_run > 1) 20 | flags |= FYACF_TRAILING_LB; 21 | 22 | + if ((flags & FYACF_STARTS_WITH_WS) || 23 | + (flags & FYACF_STARTS_WITH_LB) || 24 | + (flags & FYACF_ENDS_WITH_WS) || 25 | + (flags & FYACF_ENDS_WITH_LB)) 26 | + flags &= ~FYACF_FLOW_PLAIN; 27 | + 28 | return flags; 29 | } 30 | 31 | -- 32 | 2.39.3 (Apple Git-146) 33 | 34 | -------------------------------------------------------------------------------- /Sources/CfyamlPatches/v0.9/0004-Allow-zero-length-scalars-created-with-emit-event-ap.patch: -------------------------------------------------------------------------------- 1 | From 5a97fe656d777e6342cfa3bb459c6e5c27f93e28 Mon Sep 17 00:00:00 2001 2 | From: Kevin Wooten 3 | Date: Sat, 8 Jun 2024 17:47:24 -0700 4 | Subject: [PATCH] =?UTF-8?q?Allow=20zero-length=20scalars=20created=20with?= 5 | =?UTF-8?q?=20emit=20event=20api=20to=20be=20=E2=80=9Cplain=E2=80=9D=20map?= 6 | =?UTF-8?q?ping=20keys?= 7 | MIME-Version: 1.0 8 | Content-Type: text/plain; charset=UTF-8 9 | Content-Transfer-Encoding: 8bit 10 | 11 | In `fy_token_text_analyze`, this adds `FYTTAF_CAN_BE_SIMPLE_KEY` to the flags returned when a zero-length scalar is encountered. 12 | 13 | Additionally, `FYTTAF_CAN_BE_SIMPLE_KEY` was added to the kind of `FYNS_PLAIN` scalars that can be emitted without dobule quoting in `fy_emit_token_scalar_style`. 14 | --- 15 | src/lib/fy-emit.c | 2 +- 16 | src/lib/fy-token.c | 3 +-- 17 | 2 files changed, 2 insertions(+), 3 deletions(-) 18 | 19 | diff --git a/src/lib/fy-emit.c b/src/lib/fy-emit.c 20 | index b9311d2..8074564 100644 21 | --- a/src/lib/fy-emit.c 22 | +++ b/src/lib/fy-emit.c 23 | @@ -1376,7 +1376,7 @@ out: 24 | * - plain in block mode that can't be plain in flow mode 25 | * - special handling for plains on start of line 26 | */ 27 | - if ((flow && !(aflags & FYTTAF_CAN_BE_PLAIN_FLOW) && !is_null_scalar) || 28 | + if ((flow && !(aflags & FYTTAF_CAN_BE_PLAIN_FLOW) && !(aflags & FYTTAF_CAN_BE_SIMPLE_KEY) && !is_null_scalar) || 29 | ((aflags & FYTTAF_QUOTE_AT_0) && indent == 0)) 30 | style = FYNS_DOUBLE_QUOTED; 31 | } 32 | diff --git a/src/lib/fy-token.c b/src/lib/fy-token.c 33 | index 35e8c34..5976c7c 100644 34 | --- a/src/lib/fy-token.c 35 | +++ b/src/lib/fy-token.c 36 | @@ -686,7 +686,7 @@ int fy_token_text_analyze(struct fy_token *fyt) 37 | cn = fy_atom_iter_utf8_get(&iter); 38 | if (cn < 0) { 39 | /* empty? */ 40 | - flags |= FYTTAF_EMPTY | FYTTAF_CAN_BE_DOUBLE_QUOTED | FYTTAF_CAN_BE_UNQUOTED_PATH_KEY; 41 | + flags |= FYTTAF_EMPTY | FYTTAF_CAN_BE_DOUBLE_QUOTED | FYTTAF_CAN_BE_UNQUOTED_PATH_KEY | FYTTAF_CAN_BE_SIMPLE_KEY; 42 | goto out; 43 | } 44 | 45 | @@ -694,7 +694,6 @@ int fy_token_text_analyze(struct fy_token *fyt) 46 | FYTTAF_CAN_BE_SINGLE_QUOTED | 47 | FYTTAF_CAN_BE_DOUBLE_QUOTED | 48 | FYTTAF_CAN_BE_LITERAL | 49 | - FYTTAF_CAN_BE_LITERAL | 50 | FYTTAF_CAN_BE_FOLDED | 51 | FYTTAF_CAN_BE_PLAIN_FLOW | 52 | FYTTAF_CAN_BE_UNQUOTED_PATH_KEY; 53 | -- 54 | 2.39.3 (Apple Git-146) 55 | 56 | -------------------------------------------------------------------------------- /Sources/CfyamlPatches/v0.9/0005-Allow-plain-scalars-created-via-emit-event-apis-to-i.patch: -------------------------------------------------------------------------------- 1 | From 8c045ede2a15c6e1a8802b2d10e3b125495cf1f6 Mon Sep 17 00:00:00 2001 2 | From: Kevin Wooten 3 | Date: Sat, 8 Jun 2024 17:55:21 -0700 4 | Subject: [PATCH] =?UTF-8?q?Allow=20=E2=80=9Cplain=E2=80=9D=20scalars,=20cr?= 5 | =?UTF-8?q?eated=20via=20emit=20event=20apis,=20to=20include=20newlines?= 6 | MIME-Version: 1.0 7 | Content-Type: text/plain; charset=UTF-8 8 | Content-Transfer-Encoding: 8bit 9 | 10 | Removes special handling for “simple” or `FYACF_FLOW_PLAIN` inputs in `fy_input_from_data_setup`. 11 | 12 | Without this, a “plain” scalar created with the string value `first\nsecond third` will be output as `first second third`. 13 | --- 14 | src/lib/fy-input.c | 16 ++++------------ 15 | 1 file changed, 4 insertions(+), 12 deletions(-) 16 | 17 | diff --git a/src/lib/fy-input.c b/src/lib/fy-input.c 18 | index cc29ae8..47bbd20 100644 19 | --- a/src/lib/fy-input.c 20 | +++ b/src/lib/fy-input.c 21 | @@ -128,18 +128,10 @@ static void fy_input_from_data_setup(struct fy_input *fyi, 22 | handle->end_mark.input_pos = size; 23 | handle->end_mark.line = 0; 24 | handle->end_mark.column = fy_utf8_count(data, size); 25 | - /* if it's plain, all is good */ 26 | - if (simple || (aflags & FYACF_FLOW_PLAIN)) { 27 | - handle->storage_hint = size; /* maximum */ 28 | - handle->storage_hint_valid = false; 29 | - handle->direct_output = !!(aflags & FYACF_JSON_ESCAPE); 30 | - handle->style = FYAS_PLAIN; 31 | - } else { 32 | - handle->storage_hint = 0; /* just calculate */ 33 | - handle->storage_hint_valid = false; 34 | - handle->direct_output = false; 35 | - handle->style = FYAS_DOUBLE_QUOTED_MANUAL; 36 | - } 37 | + handle->storage_hint = 0; /* just calculate */ 38 | + handle->storage_hint_valid = false; 39 | + handle->direct_output = false; 40 | + handle->style = FYAS_DOUBLE_QUOTED_MANUAL; 41 | handle->empty = !!(aflags & FYACF_EMPTY); 42 | handle->has_lb = !!(aflags & FYACF_LB); 43 | handle->has_ws = !!(aflags & FYACF_WS); 44 | -- 45 | 2.39.3 (Apple Git-146) 46 | 47 | -------------------------------------------------------------------------------- /Sources/CfyamlPatches/v0.9/0006-Allow-prefix-only-tags-to-pass-fy_tag_scan.patch: -------------------------------------------------------------------------------- 1 | From daa7ad61d26776b15053a01cf53e0494235ba4f5 Mon Sep 17 00:00:00 2001 2 | From: Kevin Wooten 3 | Date: Sat, 8 Jun 2024 18:01:05 -0700 4 | Subject: [PATCH] Allow prefix only tags to pass `fy_tag_scan`. 5 | MIME-Version: 1.0 6 | Content-Type: text/plain; charset=UTF-8 7 | Content-Transfer-Encoding: 8bit 8 | 9 | Allows tags like `!` to pass scanning. This is required to pass the emitter tests when the events are passed through the emit event apis. 10 | 11 | In `fy_tag_scan` it replaces the test for `handle_length <= 0`, with just less than zero. 12 | 13 | This change is validated by the fact that further down in `fy_tag_scan` there is a check for `handle_length == 0’, meaning it is expets zero-length handles and handles them properly. 14 | --- 15 | src/util/fy-utils.c | 5 ++++- 16 | 1 file changed, 4 insertions(+), 1 deletion(-) 17 | 18 | diff --git a/src/util/fy-utils.c b/src/util/fy-utils.c 19 | index 6b45f15..8a372d8 100644 20 | --- a/src/util/fy-utils.c 21 | +++ b/src/util/fy-utils.c 22 | @@ -295,6 +295,9 @@ int fy_tag_handle_length(const char *data, size_t len) 23 | s += w; 24 | 25 | c = fy_utf8_get(s, e - s, &w); 26 | + if (c == -1) 27 | + return len; 28 | + 29 | if (fy_is_ws(c)) 30 | return s - data; 31 | /* if first character is !, empty handle */ 32 | @@ -364,7 +367,7 @@ int fy_tag_scan(const char *data, size_t len, struct fy_tag_scan_info *info) 33 | /* either !suffix or !handle!suffix */ 34 | /* we scan back to back, and split handle/suffix */ 35 | handle_length = fy_tag_handle_length(s, e - s); 36 | - if (handle_length <= 0) 37 | + if (handle_length < 0) 38 | return -1; 39 | s += handle_length; 40 | } 41 | -- 42 | 2.39.3 (Apple Git-146) 43 | 44 | -------------------------------------------------------------------------------- /Sources/CfyamlPatches/v0.9/0007-Force-doc-end-marker-when-pretty-emit-mode-forces-a-.patch: -------------------------------------------------------------------------------- 1 | From 67c48fedc8be92088a63f4812922c2cbb3736082 Mon Sep 17 00:00:00 2001 2 | From: Kevin Wooten 3 | Date: Sun, 9 Jun 2024 09:37:42 -0700 4 | Subject: [PATCH] =?UTF-8?q?Force=20doc=20end=20marker=20when=20=E2=80=9Cpr?= 5 | =?UTF-8?q?etty=E2=80=9D=20emit=20mode=20forces=20a=20doc=20start=20marker?= 6 | MIME-Version: 1.0 7 | Content-Type: text/plain; charset=UTF-8 8 | Content-Transfer-Encoding: 8bit 9 | 10 | When emitting with pretty mode enabled, and a single scalar root object is output, it forces a document start marker to be output. This change tracks when a doc start marker is forced and forces a doc end marker to match. 11 | 12 | This change only affects pretty mode because this is the only time when a doc start marked is forced out (even when it is requested to be implicit). 13 | --- 14 | src/lib/fy-docstate.h | 1 + 15 | src/lib/fy-emit.c | 8 ++++++-- 16 | 2 files changed, 7 insertions(+), 2 deletions(-) 17 | 18 | diff --git a/src/lib/fy-docstate.h b/src/lib/fy-docstate.h 19 | index 380c5f0..eb8df53 100644 20 | --- a/src/lib/fy-docstate.h 21 | +++ b/src/lib/fy-docstate.h 22 | @@ -33,6 +33,7 @@ struct fy_document_state { 23 | bool tags_explicit : 1; 24 | bool start_implicit : 1; 25 | bool end_implicit : 1; 26 | + bool started_explicit : 1; 27 | bool json_mode : 1; 28 | struct fy_mark start_mark; 29 | struct fy_mark end_mark; 30 | diff --git a/src/lib/fy-emit.c b/src/lib/fy-emit.c 31 | index 8074564..0cf56c9 100644 32 | --- a/src/lib/fy-emit.c 33 | +++ b/src/lib/fy-emit.c 34 | @@ -1912,7 +1912,9 @@ int fy_emit_common_document_end(struct fy_emitter *emit, bool override_state, bo 35 | fyds = emit->fyds; 36 | 37 | implicit = fyds->end_implicit; 38 | - if (override_state) 39 | + if (fyds->started_explicit) 40 | + implicit = false; 41 | + else if (override_state) 42 | implicit = implicit_override; 43 | 44 | dem = ((dem_flags == FYECF_DOC_END_MARK_AUTO && !implicit) || 45 | @@ -2975,8 +2977,10 @@ static int fy_emit_streaming_node(struct fy_emitter *emit, struct fy_parser *fyp 46 | case FYET_SCALAR: 47 | /* if we're pretty and at column 0 (meaning it's a single scalar document) output --- */ 48 | if ((emit->s_flags & DDNF_ROOT) && fy_emit_is_pretty_mode(emit) && !emit->column && 49 | - !fy_emit_is_flow_mode(emit) && !(emit->s_flags & DDNF_FLOW)) 50 | + !fy_emit_is_flow_mode(emit) && !(emit->s_flags & DDNF_FLOW)) { 51 | fy_emit_document_start_indicator(emit); 52 | + emit->fyds->started_explicit = true; 53 | + } 54 | fy_emit_common_node_preamble(emit, fye->scalar.anchor, fye->scalar.tag, emit->s_flags, emit->s_indent); 55 | style = fye->scalar.value ? 56 | fy_node_style_from_scalar_style(fye->scalar.value->scalar.style) : 57 | -- 58 | 2.39.3 (Apple Git-146) 59 | 60 | -------------------------------------------------------------------------------- /Sources/CfyamlPatches/v0.9/0008-Emit-doc-start-marker-on-its-own-line-for-single-sca.patch: -------------------------------------------------------------------------------- 1 | From 28fc397e5a1cb5333c7e7afbf2795f2f984c2aa8 Mon Sep 17 00:00:00 2001 2 | From: Kevin Wooten 3 | Date: Sun, 9 Jun 2024 10:54:58 -0700 4 | Subject: [PATCH] Emit doc start marker on its own line for single scalar 5 | documents 6 | MIME-Version: 1.0 7 | Content-Type: text/plain; charset=UTF-8 8 | Content-Transfer-Encoding: 8bit 9 | 10 | When outputting a single scalar as the root of a document, this ensures it’s output on its own line instead of letting some scalar values continue on the same line. 11 | --- 12 | src/lib/fy-emit.c | 3 +-- 13 | 1 file changed, 1 insertion(+), 2 deletions(-) 14 | 15 | diff --git a/src/lib/fy-emit.c b/src/lib/fy-emit.c 16 | index 0cf56c9..6bc226f 100644 17 | --- a/src/lib/fy-emit.c 18 | +++ b/src/lib/fy-emit.c 19 | @@ -663,8 +663,7 @@ void fy_emit_common_node_preamble(struct fy_emitter *emit, 20 | } 21 | 22 | /* content for root always starts on a new line */ 23 | - if ((flags & DDNF_ROOT) && emit->column != 0 && 24 | - !(emit->flags & FYEF_HAD_DOCUMENT_START)) { 25 | + if ((flags & DDNF_ROOT) && emit->column != 0) { 26 | fy_emit_putc(emit, fyewt_linebreak, '\n'); 27 | emit->flags = FYEF_WHITESPACE | FYEF_INDENTATION; 28 | } 29 | -- 30 | 2.39.3 (Apple Git-146) 31 | 32 | -------------------------------------------------------------------------------- /Sources/PotentASN1/ASN1Serialization.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ASN1Serialization.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | /// ASN.1 encoded data reading/writing. 15 | /// 16 | public enum ASN1Serialization { 17 | 18 | /// ASN.1 Data Errors 19 | public enum Error: Swift.Error { 20 | /// Unexpectedly encounted end of data. 21 | case unexpectedEOF 22 | /// Invalid or unsupported string. 23 | case invalidStringEncoding 24 | /// Invalid characters for string. 25 | case invalidStringCharacters 26 | /// Unsupported non-constructed collection 27 | case nonConstructedCollection 28 | /// Incorrectly formatted UTC time. 29 | case invalidUTCTime 30 | /// Incorrectly formatted generalized time. 31 | case invalidGeneralizedTime 32 | /// Unsupported REAL type. 33 | case unsupportedReal 34 | /// Encoded value length could not be stored or exceeds available data. 35 | case lengthOverflow 36 | /// Number of fields in OID is invalid 37 | case invalidObjectIdentifierLength 38 | /// Tagged item was encoded incorrectly 39 | case invalidTaggedItem 40 | } 41 | 42 | /// Read ASN.1/DER encoded data as a collection of ``ASN1`` values. 43 | public static func asn1(fromDER data: Data) throws -> [ASN1] { 44 | return try ASN1DERReader.parse(data: data) 45 | } 46 | 47 | /// Write ``ASN1`` value as ASN.1/DER encoded data. 48 | public static func der(from value: ASN1) throws -> Data { 49 | return try ASN1DERWriter.write(value) 50 | } 51 | 52 | /// Write collection of ``ASN1`` values as ASN.1/DER encoded data. 53 | public static func der(from values: [ASN1]) throws -> Data { 54 | return try ASN1DERWriter.write(values) 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Sources/PotentASN1/AnyTime.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnyTime.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | import PotentCodables 13 | 14 | 15 | /// Allows encoding _any_ ASN.1 time value while allowing control of the 16 | /// specific ASN.1 tag. 17 | /// 18 | public struct AnyTime: Equatable, Hashable, Codable { 19 | 20 | /// Kind of ASN.1 time. 21 | /// 22 | /// Controls the specific ASN.1 tag used in encoded form. 23 | public enum Kind: Int, Equatable, Hashable, Codable { 24 | /// 25 | case utc 26 | /// Time in `YYYYMMDDHH[MM[SS[.fff]]]` format with optional time zone. 27 | /// 28 | /// The optional time can be specified as UTC ('Z') or an offset 29 | /// (`+-HHMM`). Without a time zone the time is considered local. 30 | case generalized 31 | } 32 | 33 | 34 | /// Specifies the exact ``Kind-swift.enum`` of time. 35 | /// 36 | /// When encoding, selects the specific kind when the schema allows 37 | /// for multiple kinds of times. 38 | /// 39 | /// When decoding, reports the specific kind of time that was decoded. 40 | /// 41 | public var kind: Kind? 42 | /// String value 43 | public var zonedDate: ZonedDate 44 | 45 | /// Initialize with a ``PotentCodables/ZonedDate`` and explicit ASN.1 kind. 46 | public init(_ zonedDate: ZonedDate, kind: Kind? = nil) { 47 | self.kind = kind 48 | self.zonedDate = zonedDate 49 | } 50 | 51 | /// Initialize with a date, time zone and explicit ASN.1 kind. 52 | public init(date: Date, timeZone: TimeZone, kind: Kind? = nil) { 53 | self.kind = kind 54 | zonedDate = ZonedDate(date: date, timeZone: timeZone) 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Sources/PotentASN1/BigInts.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BigInts.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import BigInt 12 | import Foundation 13 | 14 | 15 | public extension BigUInt { 16 | 17 | /// Initializes an integer from the provided `Data` in ASN.1 DER format. 18 | /// 19 | /// - Parameter data: Base-256 representation, in network (big-endian) byte order. 20 | /// 21 | init(derEncoded data: Data) { 22 | self.init(data) 23 | } 24 | 25 | /// Encodes the integer to `Data` in ASN.1 DER format. 26 | /// 27 | /// - Returns: Base-256 representation, in network (big-endian) byte order. 28 | /// 29 | func derEncoded() -> Data { serialize() } 30 | 31 | } 32 | 33 | public extension BigInt { 34 | 35 | /// Initializes an integer from the provided `Data` in ASN.1 DER format. 36 | /// 37 | /// - Parameter data: Two's compliment, base-256 representation, in network (big-endian) byte order. 38 | /// 39 | init(derEncoded data: Data) { 40 | let sign: Sign 41 | let magnitude: BigUInt 42 | if (data[0] & 0x80) == 0x80 { 43 | sign = .minus 44 | magnitude = BigUInt(data.twosCompliment()) 45 | } 46 | else { 47 | sign = .plus 48 | magnitude = BigUInt(data) 49 | } 50 | self.init(sign: sign, magnitude: magnitude) 51 | } 52 | 53 | /// Encodes the integer to `Data` in ASN.1 DER format. 54 | /// 55 | /// - Returns: Two's compliment, base-256 representation, in network (big-endian) byte order. 56 | /// 57 | func derEncoded() -> Data { 58 | var bytes = magnitude.serialize() 59 | if bytes.isEmpty || (bytes[0] & 0x80) == 0x80 { 60 | // Make room for sign 61 | bytes.insert(0, at: 0) 62 | } 63 | if sign == .plus { 64 | return bytes 65 | } 66 | var twos = bytes.twosCompliment() 67 | // Compact 68 | while twos.canRemoveLeadingByte() { 69 | twos.remove(at: 0) 70 | } 71 | return twos 72 | } 73 | 74 | } 75 | 76 | private extension Data { 77 | 78 | func canRemoveLeadingByte() -> Bool { 79 | count > 1 && ((self[0] == 0xff && self[1] & 0x80 == 0x80) || (self[0] == 0x00 && self[1] & 0x80 == 0x00)) 80 | } 81 | 82 | /// Two's compliment of _big endian_ integer 83 | func twosCompliment() -> Data { 84 | var data = self 85 | var increment = true 86 | for index in stride(from: data.count - 1, through: 0, by: -1) { 87 | if increment { 88 | (data[index], increment) = (~data[index]).addingReportingOverflow(1) 89 | } 90 | else { 91 | data[index] = ~data[index] 92 | } 93 | } 94 | return data 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /Sources/PotentASN1/ObjectIdentifier.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectIdentifier.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | import PotentCodables 13 | 14 | 15 | /// ASN.1 `OBJECT IDENTIFIER` value (aka `OID`). 16 | /// 17 | public struct ObjectIdentifier: Equatable, Hashable { 18 | 19 | public var fields: [UInt64] 20 | 21 | public init(_ fields: [UInt64]) { 22 | self.fields = fields 23 | } 24 | 25 | public init?(_ string: String) { 26 | var fields = [UInt64]() 27 | for num in string.split(separator: ".") { 28 | guard let field = UInt64(num) else { return nil } 29 | fields.append(field) 30 | } 31 | self.fields = fields 32 | } 33 | 34 | public var asn1: ASN1 { 35 | return .objectIdentifier(fields) 36 | } 37 | 38 | } 39 | 40 | public typealias OID = ObjectIdentifier 41 | 42 | 43 | extension ObjectIdentifier: CustomStringConvertible { 44 | 45 | public var description: String { 46 | return fields.map { "\($0)" }.joined(separator: ".") 47 | } 48 | 49 | } 50 | 51 | extension ObjectIdentifier: Codable { 52 | 53 | public init(from decoder: Decoder) throws { 54 | let container = try decoder.singleValueContainer() 55 | fields = Self(try container.decode(String.self))?.fields ?? [] 56 | } 57 | 58 | public func encode(to encoder: Encoder) throws { 59 | var container = encoder.singleValueContainer() 60 | try container.encode("\(self)") 61 | } 62 | 63 | } 64 | 65 | extension ObjectIdentifier: ExpressibleByArrayLiteral, ExpressibleByStringLiteral { 66 | 67 | public init(arrayLiteral elements: UInt64...) { 68 | fields = elements 69 | } 70 | 71 | public init(stringLiteral value: String) { 72 | guard let oid = Self(value) else { 73 | fatalError("Invalid OBJECT IDENTIFIER field: \(value)") 74 | } 75 | self = oid 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /Sources/PotentASN1/SchemaSpecified.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SchemaSpecified.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | /// Adopt to announce a type's ability to provide 15 | /// a standalone ASN.1 schema. 16 | /// 17 | /// Adopting ``SchemaSpecified``allows using the static utility 18 | /// functions ``ASN1Encoder/encode(_:)`` and ``ASN1Decoder/decode(_:from:)`` 19 | /// without having to explicitly provide a schema. 20 | /// 21 | /// ``SchemaSpecified`` also provides the default ``SchemaSpecified/encoded()`` 22 | /// function for easy encoding of values to `Data`. 23 | /// 24 | public protocol SchemaSpecified { 25 | 26 | /// The associated ASN.1 schema for this type 27 | static var asn1Schema: Schema { get } 28 | 29 | } 30 | 31 | public extension SchemaSpecified where Self: Encodable { 32 | 33 | /// Encode the value in ASN.1/DER format. 34 | /// 35 | /// - Returns: The ASN.1 encoded data for this value. 36 | func encoded() throws -> Data { 37 | return try ASN1Encoder.encode(self) 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Sources/PotentASN1/Tagged.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Tagged.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | /// Adopting ``Tagged`` allows customization of a 15 | /// type's ASN.1 encoded value. 16 | /// 17 | /// When encoding a value supporting adopting this protocol 18 | /// the ``ASN1Encoder`` will call ``encode(schema:)`` to 19 | /// retrieve the ``ASN1`` value it should ultimately encode. 20 | /// 21 | /// During decoding ``ASN1Decoder`` calls ``init(tag:value:)`` 22 | /// with the tag and value it decoded. The initializer implementation 23 | /// can further process the provided value if needed. 24 | /// 25 | public protocol Tagged { 26 | 27 | var tag: ASN1.AnyTag { get } 28 | var value: Any? { get } 29 | 30 | /// Encode the value according to the provided schema. 31 | func encode(schema: Schema) throws -> ASN1 32 | 33 | /// Decoded tag and value. 34 | init?(tag: ASN1.AnyTag, value: Any?) 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Sources/PotentASN1/TaggedValue.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Tagged.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | /// ASN.1 encoded data with tag describing its contents. 15 | /// 16 | public struct TaggedValue: Codable, Equatable, Hashable { 17 | public var tag: UInt8 18 | public var data: Data 19 | 20 | public init(tag: UInt8, data: Data) { 21 | self.tag = tag 22 | self.data = data 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Sources/PotentCodables/AnyCodingKey.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnyCodingKey.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | public struct AnyCodingKey: CodingKey, Equatable, Hashable { 12 | 13 | enum Error: Swift.Error { 14 | case unsupportedKeyValue(Any) 15 | } 16 | 17 | public var stringValue: String 18 | public var intValue: Int? 19 | 20 | public init(stringValue: String, intValue: Int?) { 21 | self.stringValue = stringValue 22 | self.intValue = intValue 23 | } 24 | 25 | public init(stringValue: String) { 26 | self.init(stringValue: stringValue, intValue: nil) 27 | } 28 | 29 | public init(intValue: Int) { 30 | self.init(stringValue: "\(intValue)", intValue: intValue) 31 | } 32 | 33 | public init(index: Int) { 34 | self.init(intValue: index) 35 | } 36 | 37 | public init(_ base: Key) { 38 | if let index = base.intValue { 39 | self.init(intValue: index) 40 | } 41 | else { 42 | self.init(stringValue: base.stringValue) 43 | } 44 | } 45 | 46 | // swiftlint:disable:next force_unwrapping 47 | public func key() throws -> K { 48 | if let intValue = self.intValue { 49 | guard let key = K(intValue: intValue) else { 50 | throw Error.unsupportedKeyValue(intValue) 51 | } 52 | return key 53 | } 54 | else { 55 | guard let key = K(stringValue: stringValue) else { 56 | throw Error.unsupportedKeyValue(stringValue) 57 | } 58 | return key 59 | } 60 | } 61 | 62 | internal static let `super` = AnyCodingKey(stringValue: "super") 63 | 64 | } 65 | 66 | extension AnyCodingKey: ExpressibleByStringLiteral, ExpressibleByIntegerLiteral { 67 | public init(stringLiteral value: String) { 68 | stringValue = value 69 | } 70 | 71 | public init(integerLiteral value: Int) { 72 | intValue = value 73 | stringValue = "\(value)" 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Sources/PotentCodables/EncoderSupport.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EncoderSupport.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | /// All encoders support encoding to their native values. 15 | /// 16 | public protocol EncodesToTree { 17 | 18 | associatedtype Value: PotentCodables.Value 19 | 20 | /// Encodes the value to a native value. 21 | /// 22 | /// - Parameters: 23 | /// - value: Value to encode 24 | /// - Returns: Encoded value tree. 25 | /// 26 | func encodeTree(_ value: T) throws -> Value 27 | 28 | } 29 | 30 | /// Encoders that target binary formats support encoding to data. 31 | /// 32 | public protocol EncodesToData: EncodesToTree { 33 | 34 | /// Encodes the value to binary data. 35 | /// 36 | /// - Parameters: 37 | /// - value: Value to encode 38 | /// - Returns: Encoded binary data. 39 | /// 40 | func encode(_ value: T) throws -> Data 41 | 42 | } 43 | 44 | /// Encoders that target text formats support encoding to strings 45 | /// and encoding to data using a default string encoding. 46 | /// 47 | public protocol EncodesToString: EncodesToData { 48 | 49 | /// Encodes the encodable `value` to a string. 50 | /// 51 | /// - Parameters: 52 | /// - value: Value to encode 53 | /// - Returns: Encoded text. 54 | /// 55 | func encodeString(_ value: T) throws -> String 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Sources/PotentCodables/Errors.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CodableErrors.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | public extension DecodingError { 15 | /// Returns a `.typeMismatch` error describing the expected type. 16 | /// 17 | /// - parameter path: The path of `CodingKey`s taken to decode a value of this type. 18 | /// - parameter expectation: The type expected to be encountered. 19 | /// - parameter reality: The value that was encountered instead of the expected type. 20 | /// - returns: A `DecodingError` with the appropriate path and debug description. 21 | static func typeMismatch(at path: [CodingKey], expectation: Any.Type, reality: Any) -> DecodingError { 22 | let description = "Expected to decode \(expectation) but found \(typeDescription(of: reality)) instead." 23 | return .typeMismatch(expectation, Context(codingPath: path, debugDescription: description)) 24 | } 25 | 26 | /// Returns a description of the type of `value` appropriate for an error message. 27 | /// 28 | /// - parameter value: The value whose type to describe. 29 | /// - returns: A string describing `value`. 30 | /// - precondition: `value` is one of the types below. 31 | static func typeDescription(of value: Any) -> String { 32 | if value is NSNull { 33 | return "a null value" 34 | } 35 | else if value is NSNumber { 36 | return "a number" 37 | } 38 | else if value is String { 39 | return "a string/data" 40 | } 41 | else if value is [Any] { 42 | return "an array" 43 | } 44 | else if value is [String: Any] { 45 | return "a dictionary" 46 | } 47 | else { 48 | return "\(type(of: value))" 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Sources/PotentCodables/Float16.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Float16.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | #if arch(x86_64) && (os(macOS) || os(Linux) || targetEnvironment(macCatalyst)) 12 | 13 | import Float16 14 | 15 | 16 | /// Float16 shim for intel architectures 17 | public typealias Float16 = float16 18 | 19 | 20 | extension Float16: Codable { 21 | 22 | public init(from decoder: Decoder) throws { 23 | let container = try decoder.singleValueContainer() 24 | self.init(try container.decode(Float.self)) 25 | } 26 | 27 | public func encode(to encoder: Encoder) throws { 28 | var container = encoder.singleValueContainer() 29 | try container.encode(Float(self)) 30 | } 31 | 32 | } 33 | 34 | extension Float16: LosslessStringConvertible { 35 | 36 | public init?(_ description: String) { 37 | guard let float = Float(description) else { 38 | return nil 39 | } 40 | self.init(float) 41 | } 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/Data Formats/ASN1/ASN1 ReadingWriting.md: -------------------------------------------------------------------------------- 1 | # Reading and Writing ASN.1 2 | 3 | Reading and writing ASN.1 encoded data to/from ``PotentASN1/ASN1`` tree values. 4 | 5 | ## Overview 6 | 7 | ``PotentASN1/ASN1Serialization`` can read ASN.1 DER encoded data into ``PotentASN1/ASN1`` tree values and write 8 | ``PotentASN1/ASN1`` tree values to ASN.1 DER encoded data. 9 | 10 | > Note: PotentASN1 only supports the `DER` encoding format. 11 | 12 | ### Reading ASN.1 13 | 14 | ```swift 15 | import PotentASN1 16 | 17 | let asn1Value = ASN1Serialization.asn1(fromDER: derData) 18 | ``` 19 | 20 | ### Writing ASN.1 21 | 22 | ``PotentASN1/ASN1Serialization`` can be used to write ``PotentASN1/ASN1`` values as ASN.1 encoded data values. 23 | 24 | ```swift 25 | import PotentASN1 26 | 27 | let derData = ASN1Serialization.der(from: .sequence([.utf8String("Hello ASN.1"), .integer(5)])) 28 | print(derData.base64EncodedString()) 29 | ``` 30 | 31 | ### ASN1 Tree Values 32 | 33 | ``PotentASN1/ASN1`` values can be manually queried for it's value or values. 34 | 35 | ```swift 36 | if let string = asn1Value.utf8StringValue { 37 | print(string) 38 | } 39 | 40 | if let sequence = asn1Value.sequenceValue { 41 | sequence.forEach { print($0) } 42 | } 43 | // Alternatively, sequence values can use subscripting 44 | print(asn1Value[0]) 45 | ``` 46 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/Data Formats/ASN1/ASN1 SchemaEncodingDecoding.md: -------------------------------------------------------------------------------- 1 | # Schema based Encoding and Decoding 2 | 3 | Use ASN.1 schemas to encode and decode to or from Swift structs and classes. 4 | 5 | ## Overview 6 | 7 | ASN.1 is a position based format and lacks encoded field names for it's values; instead ASN.1 provides field names 8 | and formats via ASN.1 schema notation. 9 | 10 | To allow mapping ASN.1 data to Swift structures and classes, ``PotentASN1/ASN1Encoder`` and ``PotentASN1/ASN1Encoder`` 11 | require a provided ``PotentASN1/Schema`` to direct the encoding and/or decoding of Swift types. 12 | 13 | For example, the following is the schema for RFC-5280's `Certificate`: 14 | ```swift 15 | import PotentASN1 16 | 17 | let certificateSchema: Schema = 18 | .sequence([ 19 | "tbsCertificate": TBSCertificateSchema, 20 | "signatureAlgorithm": SignatureAlgorithmSchema, 21 | "signatureValue": .bitString, 22 | ]) 23 | ``` 24 | > Note: The above example `certificateSchema` references `TBSCertificateSchema` and `SignatureAlgorithmSchema` that 25 | are not provided here. The [Shield](https://github.com/outfoxx/Shield) Swift package provides complete support for 26 | reading and writing PKCS types and the schemas it defines can be examined to see complete, complex ASN.1 schema 27 | examples. 28 | 29 | Using the `certificateSchema` schema a DER encoded certificate can be decoded using an ``PotentASN1/ASN1Decoder``. 30 | ```swift 31 | import PotentASN1 32 | 33 | struct Certificate { 34 | var tbsCertificate: TBSCertificate // defined elsewhere 35 | var signatureAlgorithm: SignatureAlgorithm // defined elsewhere 36 | var signatureValue: BitString 37 | } 38 | 39 | let certificate = ASN1Decoder(schema: certificateSchema).decode(Certificate.self, from: certificateData) 40 | ``` 41 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/Data Formats/ASN1/PotentASN1.md: -------------------------------------------------------------------------------- 1 | # ``PotentASN1`` 2 | 3 | Reading and writing ASN.1 encoded data, as well as schema oriented support for encoding and decoding. 4 | 5 | ## Overview 6 | 7 | PotentASN1 provides a conformant implementation for reading and writing 8 | [ASN.1](https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One) encoded data. Additionally, encoding and decoding 9 | via Swift's `Codable` framework is provided using schemas. 10 | 11 | ## Topics 12 | 13 | ### Basics 14 | 15 | - 16 | - 17 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/Data Formats/CBOR/CBOR Serialization.md: -------------------------------------------------------------------------------- 1 | # Reading and Writing CBOR 2 | 3 | Reading and writing CBOR encoded data to/from ``PotentCBOR/CBOR`` tree values. 4 | 5 | ## Overview 6 | 7 | ### Reading CBOR 8 | 9 | ``PotentCBOR/CBORSerialization`` can read CBOR encoded data into ``PotentCBOR/CBOR`` tree values. 10 | 11 | ```swift 12 | import PotentCBOR 13 | 14 | let cbor1Value = CBORSerialization.cbor(from: cborData) 15 | ``` 16 | 17 | ### Writing CBOR 18 | 19 | ``PotentCBOR/CBORSerialization`` can be used to write ``PotentCBOR/CBOR`` values as CBOR 20 | encoded data. 21 | 22 | ```swift 23 | import PotentCBOR 24 | 25 | let cborData = CBORSerialization.data(from: .array([.utf8String("Hello CBOR"), .boolean(true)])) 26 | print(cborData.base64EncodedString()) 27 | ``` 28 | 29 | ### Tree Values 30 | 31 | ``PotentCBOR/CBOR`` tree values can be manually queried for their value or values. 32 | 33 | ```swift 34 | if let string = cborValue.utf8StringValue { 35 | print(string) 36 | } 37 | 38 | if let array = cborValue.arrayValue { 39 | array.forEach { print($0) } 40 | } 41 | // Alternatively, array values can use subscripting 42 | print(cbor1Value[0]) 43 | 44 | if let map = cborValue.mapValue { 45 | map.forEach { (key, value) in print("\(key) = \(value)") } 46 | } 47 | // Alternatively, map values can use subscripting or dynamic member lookup 48 | print(cborValue["myField"]) 49 | print(cborValue.myField) 50 | ``` 51 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/Data Formats/CBOR/PotentCBOR.md: -------------------------------------------------------------------------------- 1 | # ``PotentCBOR`` 2 | 3 | Complete support for Concise Binary Object Representation encoded data in pure Swift. 4 | 5 | ## Overview 6 | 7 | PotentCBOR provides a conformant implementation for reading and writing [CBOR](https://cbor.io) encoded data as well 8 | as complete support from encoding and decoding via Swift's `Codable` framework. 9 | 10 | ## Topics 11 | 12 | ### Codable 13 | 14 | - 15 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/Data Formats/JSON/PotentJSON.md: -------------------------------------------------------------------------------- 1 | # ``PotentJSON`` 2 | 3 | Enhanced, drop-in replacement for Foundation's JSON support in pure Swift. 4 | 5 | ## Overview 6 | 7 | PotentJSON is a conformat implementation of [JSON](https://tools.ietf.org/html/rfc8259) that offers significant 8 | enhancements to what representations can be encoded to or decoded from (e.g. to/from Strings and to/from native 9 | value trees). Additionally, PotentJSON's implementation of ``PotentJSON/JSONEncoder`` and ``PotentJSON/JSONDecoder`` 10 | work well with ``PotentCodables/AnyValue`` to encode/decode freeform data values. 11 | 12 | ## Topics 13 | 14 | ### Group 15 | 16 | - ``Symbol`` 17 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/Data Formats/YAML/PotentYAML.md: -------------------------------------------------------------------------------- 1 | # ``PotentYAML`` 2 | 3 | YAML 1.2 support for both YAML & JSON in a single framework. 4 | 5 | ## Overview 6 | 7 | PotentYAML provides a conformant [YAML 1.2](https://yaml.org/spec/1.2./) implementation implemented via 8 | [libfyaml](https://github.com/pantoniou/libfyaml). YAML 1.2 is defined as a superset of JSON which allows 9 | users to read & write both YAML & JSON content using this single implementation. 10 | 11 | Just like all PotentCodables provide data formats, PotentYAML offers enhanced capabilities over standard 12 | encoders/decoders like serializing to/from Strings and native value trees. 13 | 14 | ## Topics 15 | 16 | ### Group 17 | 18 | - ``Symbol`` 19 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/General/Combine.md: -------------------------------------------------------------------------------- 1 | # Combine 2 | 3 | Integration with Combine Framework. 4 | 5 | ## Overview 6 | 7 | When used on Apple platforms where the Combine framework is available, all the encoders conform to Combine's 8 | `TopLevelEncoder` and all decoders conform to its `TopLevelDecoder`. 9 | 10 | In addition to providing compatibility with Swift's Combine framework these protocols are an easy way to allow 11 | interchanging support for data formats or frameworks without rewriting code. 12 | 13 | Using `TopLevelDecoder` instead of a specific framework decoder would allow your code to work with whatever framework 14 | you need. 15 | 16 | Given the following generic function 17 | ```swift 18 | 19 | func decodeFromNetwork(url: URL, decoder: D) async throws -> T where D.Input == Data { 20 | let (data, _) = try await URLSession.shared.data(from: url) 21 | return try decoder.decode(T.self, from: data) 22 | } 23 | 24 | ``` 25 | 26 | You can then use any PotentCodables data format decoder to decode values from the network request. 27 | ```swift 28 | import PotentCBOR 29 | 30 | let engine: Engine = decodeFromNetwork(URL(string: "https://example.com/engine/1.cbor"), CBOR.Decoder.default) 31 | ``` 32 | ```swift 33 | import PotentYAML 34 | 35 | let engine: Engine = decodeFromNetwork(URL(string: "https://example.com/engine/1.yaml"), YAML.Decoder.default) 36 | ``` 37 | 38 | Additionally `decodeFromNetwork` can be called with any conforming decoder from other frameworks, like 39 | Foundation's `JSONDecoder`. 40 | 41 | ```swift 42 | import Foundation 43 | 44 | let engine: Engine = decodeFromNetwork(URL(string: "https://example.com/engine/1.json"), JSONDecoder()) 45 | ``` 46 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/General/Data Formats.md: -------------------------------------------------------------------------------- 1 | # Data Formats 2 | 3 | All data formats provided by PotentCodables 4 | 5 | ## Overview 6 | 7 | - term : YAML 1.2 support for handling YAML and JSON. 8 | - term : Advanced JSON support in pure Swift. 9 | - term : RFC 8949 Concise Binary Object Representation support. 10 | - term : ASN.1 support with schema based encoding/decoding. 11 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/General/TreeValues.md: -------------------------------------------------------------------------------- 1 | # Tree Values 2 | 3 | What are "tree values"? 4 | 5 | ## Overview 6 | 7 | Each decoder has an in memory representation known as the "tree" value. The great thing about tree values is that they 8 | hold the values in their exact serialized representation. For example, `JSON` tree values store numbers as a 9 | specialized ``PotentJSON/JSON/Number`` that stores the exact number value as a string along with a number of other 10 | properties for helping the conversion of strings to integer or floating point numbers. Accessing this 11 | ``PotentJSON/JSON/Number`` and reading the exact decimal value serialized in JSON is available from tree values. 12 | 13 | The decoders support accessing the tree value using specializations of the protocol 14 | ``PotentCodables/TreeValueDecodingContainer`` which extends the `SingleValueDecodingContainer` protocol. 15 | 16 | Decoding ``PotentJSON/JSON`` values using the ``PotentCodables/TreeValueDecodingContainer`` as follows: 17 | ```swift 18 | func init(from decoder: Decoder) throws { 19 | let treeContainer = try decoder.singleValuedContainer() as! TreeValueDecodingContainer 20 | self.jsonValue = try treeContainer.decodeTreeValue() as! JSON 21 | } 22 | ``` 23 | 24 | Each tree value has the ability to "unwrap" itself (using it's `unwrapped` property) into it's the best available 25 | standard Swift type, returned as an `Any`. As an example, unwrappingthe the JSON value `123.456` result in a Swift 26 | `Double`. 27 | 28 | Tree values are returned as an `Any` to allow easy support any possible tree value. For this reason the 29 | ``PotentCodables/TreeValueDecodingContainer`` has a convenience method to access the unwrapped tree value without 30 | excessive casting. 31 | 32 | Decoding unwrapped ``PotentJSON/JSON`` values using the ``PotentCodables/TreeValueDecodingContainer`` as follows: 33 | ```swift 34 | func init(from decoder: Decoder) throws { 35 | let treeContainer = try decoder.singleValuedContainer() as! TreeValueDecodingContainer 36 | self.value = try treeContainer.decodeUnwrappedValue() 37 | } 38 | ``` 39 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/General/Using AnyValue.md: -------------------------------------------------------------------------------- 1 | # Using AnyValue 2 | 3 | Decode and encode "any" structured value using ``PotentCodables/AnyValue`` 4 | 5 | ## Overview 6 | 7 | Sometimes it is necessary to decode values of any type or that can take on any structure; unfortunately Swift's 8 | `Codable` is not well suited for this purpose. PotentCodables provides ``PotentCodables/AnyValue`` to fill the gap. 9 | 10 | Using ``PotentCodables/AnyValue`` is simple, just use it wherever you would normally use an `Any`. Since 11 | ``PotentCodables/AnyValue`` supports `Codable` everything else works as normal including Swift's automatic codable 12 | generation. 13 | ```swift 14 | struct Account : Codable { 15 | let name: String 16 | let data: AnyValue // `data` can store and scalar or complex value 17 | let dataDict: [String: AnyValue] // `dataDict` is required to be a dictionary of name to any values 18 | let dataArray: [AnyValue] // `dataArray` is required to be an array of any values 19 | } 20 | ``` 21 | 22 | The example `Account` struct above has a `data` property that can take on any value supported by the codable system. 23 | 24 | For example when decoding from JSON, any value or tree of values (including _null_, _bool_, _string_, _number_, 25 | _arrray_ or _object_) could be saved in the `data` property. Encoding the same `Account` value back to JSON will produce 26 | equivalent serialized JSON regardless of the contents of the `data` field. 27 | 28 | ``PotentCodables/AnyValue`` has lots of features to make building and using them natural in Swift, like "dynamic member 29 | lookup" to access fields of a ``PotentCodables/AnyValue/dictionary(_:)``. See the documentation for complete details. 30 | 31 | ### Performance 32 | Although ``PotentCodables/AnyValue`` is compatible with any conformant `Codable` encoder or decoder, PotentCodables 33 | decoders specifically have shortcuts to decode the proper values in a more performant fashion and should be used when 34 | possible. 35 | -------------------------------------------------------------------------------- /Sources/PotentCodables/PotentCodables.docc/PotentCodables.md: -------------------------------------------------------------------------------- 1 | # ``PotentCodables`` 2 | 3 | A potent set of implementations and extensions to the Swift `Codable` system 4 | 5 | ## Overview 6 | 7 | ## Topics 8 | 9 | ### Usage 10 | 11 | - 12 | - 13 | - 14 | - 15 | 16 | ### Advanced 17 | 18 | - 19 | - 20 | - 21 | - 22 | 23 | ### Other 24 | 25 | - 26 | -------------------------------------------------------------------------------- /Sources/PotentCodables/Regexes.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Pattern.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2019 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | import Regex 13 | 14 | 15 | extension Regex: ExpressibleByStringLiteral { 16 | 17 | public init(stringLiteral value: StaticString) { 18 | self.init(value) 19 | } 20 | 21 | } 22 | 23 | extension Regex { 24 | 25 | public static func anyOf(_ regexes: Regex...) -> Regex { 26 | do { 27 | return try Regex(string: regexes.map { "(\($0.description))" }.joined(separator: "|")) 28 | } 29 | catch { 30 | preconditionFailure("unexpected error creating regex from joined set: \(error)") 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Sources/PotentCodables/TimeZone.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TimeZone.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | public extension TimeZone { 14 | 15 | static let utc = TimeZone(identifier: "UTC").unsafelyUnwrapped 16 | 17 | static func timeZone(from date: String) -> TimeZone? { 18 | guard let offset = offset(from: date) else { 19 | return nil 20 | } 21 | if offset == 0 { 22 | return utc 23 | } 24 | return TimeZone(secondsFromGMT: offset) 25 | } 26 | 27 | static func offset(from date: String) -> Int? { 28 | guard let start = date.firstIndex(of: "+") ?? date.firstIndex(of: "-") ?? date.firstIndex(of: "Z") else { 29 | return nil 30 | } 31 | guard date[start...] != "Z" else { 32 | return 0 33 | } 34 | 35 | let sign = date[start] == "+" ? 1 : -1 36 | func build(seconds: Int) -> Int? { 37 | return seconds * sign 38 | } 39 | 40 | let timeZone = date[date.index(after: start) ..< date.endIndex] 41 | 42 | if timeZone.count == 2 { // assume HH 43 | if let hour = Int(timeZone) { 44 | return build(seconds: hour * 3600) 45 | } 46 | } 47 | else if timeZone.count == 4 { // assume HHMM 48 | if let hour = Int(timeZone.dropLast(2)), let min = Int(timeZone.dropFirst(2)) { 49 | return build(seconds: (hour * 60 + min) * 60) 50 | } 51 | } 52 | else if timeZone.count == 5 { // assime HH:MM 53 | if let hour = Int(timeZone.dropLast(3)), let min = Int(timeZone.dropFirst(3)) { 54 | return build(seconds: (hour * 60 + min) * 60) 55 | } 56 | } 57 | else if timeZone.count == 6 { // assume HHMMSS 58 | if let hour = Int(timeZone.dropLast(4)), 59 | let min = Int(timeZone.dropFirst(2).dropLast(2)), 60 | let sec = Int(timeZone.dropFirst(4)) { 61 | return build(seconds: (hour * 60 + min) * 60 + sec) 62 | } 63 | } 64 | else if timeZone.count == 8 { // assime HH:MM:SS 65 | if let hour = Int(timeZone.dropLast(6)), 66 | let min = Int(timeZone.dropFirst(3).dropLast(3)), 67 | let sec = Int(timeZone.dropFirst(6)) { 68 | return build(seconds: (hour * 60 + min) * 60 + sec) 69 | } 70 | } 71 | 72 | return nil 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /Sources/PotentCodables/TopLevel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TopLevel.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | #if canImport(Combine) 14 | 15 | @_exported import protocol Combine.TopLevelDecoder 16 | @_exported import protocol Combine.TopLevelEncoder 17 | 18 | #else 19 | 20 | public protocol TopLevelDecoder { 21 | 22 | /// The type this decoder accepts. 23 | associatedtype Input 24 | 25 | /// Decodes an instance of the indicated type. 26 | func decode(_ type: T.Type, from: Self.Input) throws -> T where T: Decodable 27 | } 28 | 29 | /// A type that defines methods for encoding. 30 | public protocol TopLevelEncoder { 31 | 32 | /// The type this encoder produces. 33 | associatedtype Output 34 | 35 | /// Encodes an instance of the indicated type. 36 | /// 37 | /// - Parameter value: The instance to encode. 38 | func encode(_ value: T) throws -> Self.Output where T: Encodable 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Sources/PotentCodables/TreeValueDecodingContainer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TreeValueDecodingContainer.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | public protocol TreeValueDecodingContainer: SingleValueDecodingContainer { 15 | 16 | func decodeUnwrappedValue() -> Any? 17 | 18 | func decodeTreeValue() -> Any? 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/PotentCodables/Value.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Value.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | /// `Value`s are the intermediary representation that 15 | /// allows querying the structure in memory, decoding 16 | /// it to a compatible `Decodable` type, or serializing 17 | /// it to `Data` 18 | public protocol Value: Hashable { 19 | 20 | var isNull: Bool { get } 21 | 22 | var unwrapped: Any? { get } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Sources/PotentJSON/Errors.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Errors.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | internal extension EncodingError { 15 | /// Returns a `.invalidValue` error describing the given invalid floating-point value. 16 | /// 17 | /// 18 | /// - parameter value: The value that was invalid to encode. 19 | /// - parameter path: The path of `CodingKey`s taken to encode this value. 20 | /// - returns: An `EncodingError` with the appropriate path and debug description. 21 | static func invalidFloatingPointValue(_ value: T, at codingPath: [CodingKey]) -> EncodingError { 22 | let valueDescription: String 23 | if value == T.infinity { 24 | valueDescription = "\(T.self).infinity" 25 | } 26 | else if value == -T.infinity { 27 | valueDescription = "-\(T.self).infinity" 28 | } 29 | else { 30 | valueDescription = "\(T.self).nan" 31 | } 32 | 33 | let debugDescription = 34 | """ 35 | Unable to encode \(valueDescription) directly in JSON. \ 36 | Use NonConformingFloatEncodingStrategy.convertToString to specify how the value should be encoded. 37 | """ 38 | return .invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: debugDescription)) 39 | } 40 | 41 | /// Returns a `.invalidValue` error describing the given invalid floating-point value. 42 | /// 43 | /// 44 | /// - parameter value: The value that was invalid to encode. 45 | /// - parameter path: The path of `CodingKey`s taken to encode this value. 46 | /// - returns: An `EncodingError` with the appropriate path and debug description. 47 | static func invalidFloatingPointValue(_ value: Decimal, at codingPath: [CodingKey]) -> EncodingError { 48 | let valueDescription: String 49 | if value.isInfinite, value.sign == .plus { 50 | valueDescription = "\(Decimal.self).infinity" 51 | } 52 | else if value.isInfinite, value.sign == .minus { 53 | valueDescription = "-\(Decimal.self).infinity" 54 | } 55 | else { 56 | valueDescription = "\(Decimal.self).nan" 57 | } 58 | 59 | let debugDescription = 60 | """ 61 | Unable to encode \(valueDescription) directly in JSON. \ 62 | Use NonConformingFloatEncodingStrategy.convertToString to specify how the value should be encoded. 63 | """ 64 | return .invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: debugDescription)) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Sources/PotentYAML/Errors.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Errors.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | internal extension EncodingError { 15 | /// Returns a `.invalidValue` error describing the given invalid floating-point value. 16 | /// 17 | /// 18 | /// - parameter value: The value that was invalid to encode. 19 | /// - parameter path: The path of `CodingKey`s taken to encode this value. 20 | /// - returns: An `EncodingError` with the appropriate path and debug description. 21 | static func invalidFloatingPointValue(_ value: T, at codingPath: [CodingKey]) -> EncodingError { 22 | let valueDescription: String 23 | if value == T.infinity { 24 | valueDescription = "\(T.self).infinity" 25 | } 26 | else if value == -T.infinity { 27 | valueDescription = "-\(T.self).infinity" 28 | } 29 | else { 30 | valueDescription = "\(T.self).nan" 31 | } 32 | 33 | let debugDescription = 34 | """ 35 | Unable to encode \(valueDescription) directly in YAML. \ 36 | Use NonConformingFloatEncodingStrategy.convertToString to specify how the value should be encoded. 37 | """ 38 | return .invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: debugDescription)) 39 | } 40 | 41 | /// Returns a `.invalidValue` error describing the given invalid floating-point value. 42 | /// 43 | /// 44 | /// - parameter value: The value that was invalid to encode. 45 | /// - parameter path: The path of `CodingKey`s taken to encode this value. 46 | /// - returns: An `EncodingError` with the appropriate path and debug description. 47 | static func invalidFloatingPointValue(_ value: Decimal, at codingPath: [CodingKey]) -> EncodingError { 48 | let valueDescription: String 49 | if value.isInfinite, value.sign == .plus { 50 | valueDescription = "\(Decimal.self).infinity" 51 | } 52 | else if value.isInfinite, value.sign == .minus { 53 | valueDescription = "-\(Decimal.self).infinity" 54 | } 55 | else { 56 | valueDescription = "\(Decimal.self).nan" 57 | } 58 | 59 | let debugDescription = 60 | """ 61 | Unable to encode \(valueDescription) directly in YAML. \ 62 | Use NonConformingFloatEncodingStrategy.convertToString to specify how the value should be encoded. 63 | """ 64 | return .invalidValue(value, EncodingError.Context(codingPath: codingPath, debugDescription: debugDescription)) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Sources/PotentYAML/YAMLSchema.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YAMLSchema.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2019 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | 14 | public protocol YAMLSchema { 15 | 16 | func isNull(_ string: String) -> Bool 17 | 18 | func isBool(_ string: String) -> Bool 19 | func isTrue(_ string: String) -> Bool 20 | func isFalse(_ string: String) -> Bool 21 | 22 | func isInt(_ string: String) -> Bool 23 | 24 | func isFloat(_ string: String) -> Bool 25 | func isNumber(_ string: String) -> Bool 26 | func isInfinity(_ string: String) -> Bool 27 | func isNaN(_ string: String) -> Bool 28 | 29 | func requiresQuotes(for string: String) -> Bool 30 | 31 | } 32 | 33 | public enum YAMLSchemas { 34 | } 35 | -------------------------------------------------------------------------------- /Sources/PotentYAML/YAMLSchemaCore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YAMLSchemaCore.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2019 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | import PotentCodables 13 | import Regex 14 | 15 | 16 | extension YAMLSchema where Self == YAMLSchemas.Core { 17 | 18 | public static var core: Self { .instance } 19 | } 20 | 21 | extension YAMLSchemas { 22 | 23 | public enum Core: YAMLSchema { 24 | case instance 25 | 26 | static let nullRegex: Regex = #"^((null)|(Null)|(NULL)|(~)|(^$))$"# 27 | 28 | static let boolRegex: Regex = .anyOf(trueRegex, falseRegex) 29 | static let trueRegex: Regex = #"^((true)|(True)|(TRUE))$"# 30 | static let falseRegex: Regex = #"^((false)|(False)|(FALSE))$"# 31 | 32 | static let int8Regex: Regex = #"^(0o[0-7]+)$"# 33 | static let int10Regex: Regex = #"^([-+]?[0-9]+)$"# 34 | static let int16Regex: Regex = #"^(0x[0-9a-fA-F]+)$"# 35 | static let intRegex: Regex = .anyOf(int8Regex, int10Regex, int16Regex) 36 | 37 | static let numRegex: Regex = #"^([-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?)$"# 38 | static let infRegex: Regex = #"^([-+]?((\.inf)|(\.Inf)|(\.INF)))$"# 39 | static let nanRegex: Regex = #"^((\.nan)|(\.NaN)|(\.NAN))$"# 40 | static let floatRegex: Regex = .anyOf(numRegex, infRegex, nanRegex) 41 | 42 | public func isNull(_ string: String) -> Bool { Self.nullRegex.matches(string) } 43 | 44 | public func isBool(_ string: String) -> Bool { Self.boolRegex.matches(string) } 45 | public func isTrue(_ string: String) -> Bool { Self.trueRegex.matches(string) } 46 | public func isFalse(_ string: String) -> Bool { Self.falseRegex.matches(string) } 47 | 48 | public func isInt(_ string: String) -> Bool { Self.intRegex.matches(string) } 49 | 50 | public func isFloat(_ string: String) -> Bool { Self.floatRegex.matches(string) } 51 | public func isNumber(_ string: String) -> Bool { Self.numRegex.matches(string) } 52 | public func isInfinity(_ string: String) -> Bool { Self.infRegex.matches(string) } 53 | public func isNaN(_ string: String) -> Bool { Self.nanRegex.matches(string) } 54 | 55 | public func requiresQuotes(for string: String) -> Bool { 56 | isNull(string) || isBool(string) || isInt(string) || isFloat(string) 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /Tests/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | 2 | disabled_rules: 3 | - function_body_length 4 | - type_body_length 5 | - identifier_name 6 | - trailing_comma 7 | 8 | file_length: 9 | - 3000 10 | -------------------------------------------------------------------------------- /Tests/ASN1AnyStringTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ASN1AnyStringTests.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | import PotentASN1 13 | import XCTest 14 | 15 | 16 | class ASN1AnyStringTests: XCTestCase { 17 | 18 | func testInit() { 19 | 20 | let val0 = AnyString("test", kind: .utf8) 21 | XCTAssertEqual(val0.storage, "test") 22 | XCTAssertEqual(val0.kind, .utf8) 23 | 24 | let val1: AnyString = "test" 25 | XCTAssertEqual(val1.storage, "test") 26 | XCTAssertNil(val1.kind) 27 | 28 | let val2 = AnyString(String("test")) 29 | XCTAssertEqual(val2.storage, "test") 30 | XCTAssertNil(val2.kind) 31 | 32 | let val3 = "test".withCString { AnyString(cString: $0) } 33 | XCTAssertEqual(val3.storage, "test") 34 | XCTAssertNil(val3.kind) 35 | } 36 | 37 | func testCodable() { 38 | 39 | XCTAssertEqual(try JSONEncoder().encode(AnyString("test")), #""test""#.data(using: .utf8)) 40 | XCTAssertEqual(try JSONDecoder().decode(AnyString.self, from: #""test""#.data(using: .utf8)!), AnyString("test")) 41 | } 42 | 43 | func testUppercased() { 44 | XCTAssertEqual(AnyString("test").uppercased(), "TEST") 45 | } 46 | 47 | func testLowercased() { 48 | XCTAssertEqual(AnyString("TEST").lowercased(), "test") 49 | } 50 | 51 | func testUTF8() { 52 | XCTAssertEqual(Array(AnyString("test").utf8), Array("test".utf8)) 53 | } 54 | 55 | func testUTF16() { 56 | XCTAssertEqual(Array(AnyString("test").utf16), Array("test".utf16)) 57 | } 58 | 59 | func testUnicodeScalars() { 60 | XCTAssertEqual(Array(AnyString("test").unicodeScalars), Array("test".unicodeScalars)) 61 | } 62 | 63 | func testCString() { 64 | 65 | XCTAssertEqual(AnyString("test").withCString { String(cString: $0) }, "test") 66 | } 67 | 68 | func testIndices() { 69 | 70 | let str = AnyString("test") 71 | XCTAssertEqual(str[str.startIndex], "t") 72 | XCTAssertEqual(str[str.startIndex.. Bool { 18 | if case DecodingError.typeMismatch(_, _) = error { 19 | return true 20 | } 21 | else { 22 | return false 23 | } 24 | } 25 | XCTAssertTrue(check(), file: file, line: line) 26 | } 27 | 28 | public func AssertDecodingDataCorrupted(_ error: Error, file: StaticString = #file, line: UInt = #line) { 29 | func check() -> Bool { 30 | if case DecodingError.dataCorrupted = error { 31 | return true 32 | } 33 | else { 34 | return false 35 | } 36 | } 37 | XCTAssertTrue(check(), file: file, line: line) 38 | } 39 | 40 | public func AssertDecodingKeyNotFound(_ error: Error, file: StaticString = #file, line: UInt = #line) { 41 | func check() -> Bool { 42 | if case DecodingError.keyNotFound = error { 43 | return true 44 | } 45 | else { 46 | return false 47 | } 48 | } 49 | XCTAssertTrue(check(), file: file, line: line) 50 | } 51 | 52 | public func AssertDecodingValueNotFound(_ error: Error, file: StaticString = #file, line: UInt = #line) { 53 | func check() -> Bool { 54 | if case DecodingError.valueNotFound = error { 55 | return true 56 | } 57 | else { 58 | return false 59 | } 60 | } 61 | XCTAssertTrue(check(), file: file, line: line) 62 | } 63 | 64 | public func AssertEncodingInvalidValue(_ error: Error, file: StaticString = #file, line: UInt = #line) { 65 | func check() -> Bool { 66 | if case EncodingError.invalidValue = error { 67 | return true 68 | } 69 | else { 70 | return false 71 | } 72 | } 73 | XCTAssertTrue(check(), file: file, line: line) 74 | } 75 | 76 | public func AssertJSONErrorInvalidData(_ error: Error, file: StaticString = #file, line: UInt = #line) { 77 | func check() -> Bool { 78 | if case JSONReader.Error.invalidData = error { 79 | return true 80 | } 81 | else { 82 | return false 83 | } 84 | } 85 | XCTAssertTrue(check(), file: file, line: line) 86 | } 87 | -------------------------------------------------------------------------------- /Tests/Datas.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Datas.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | extension Data { 14 | 15 | func hexEncodedString() -> String { 16 | return reduce("") {$0 + String(format: "%02x", $1)} 17 | } 18 | 19 | init(hexEncoded: String) { 20 | 21 | let chars = Array(hexEncoded.utf8) 22 | 23 | var bytes = [UInt8]() 24 | bytes.reserveCapacity(chars.count / 2) 25 | 26 | let map: [UInt8] = [ 27 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 01234567 28 | 0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89:;<=>? 29 | 0x00, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x00, // @ABCDEFG 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // HIJKLMNO 31 | ] 32 | 33 | for i in stride(from: 0, to: chars.count, by: 2) { 34 | let index1 = Int(chars[i] & 0x1F ^ 0x10) 35 | let index2 = Int(chars[i + 1] & 0x1F ^ 0x10) 36 | bytes.append(map[index1] << 4 | map[index2]) 37 | } 38 | 39 | self.init(bytes) 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Tests/Dates.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Dates.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | 13 | extension Date { 14 | 15 | var truncatedToSecs: Date { 16 | Date(timeIntervalSinceReferenceDate: timeIntervalSinceReferenceDate.rounded()) 17 | } 18 | 19 | var truncatedToMillisecs: Date { 20 | Date(timeIntervalSinceReferenceDate: millisecondsFromReferenceDate) 21 | } 22 | 23 | var millisecondsFromReferenceDate: TimeInterval { 24 | return (timeIntervalSinceReferenceDate * 1000.0).rounded() / 1000.0 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Tests/JSONOrderTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JSONOrderTests.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import BigInt 12 | import Foundation 13 | import PotentCodables 14 | import PotentJSON 15 | import XCTest 16 | 17 | 18 | class JSONOrderTests: XCTestCase { 19 | 20 | func testObjectKeySerializationExplicitOrder() throws { 21 | 22 | let json = try JSONSerialization.string(from: [ 23 | "c": 1, 24 | "a": 2, 25 | "b": 3, 26 | ]) 27 | 28 | XCTAssertEqual(json, #"{"c":1,"a":2,"b":3}"#) 29 | } 30 | 31 | func testObjectKeySerializationSortedOrder() throws { 32 | 33 | let json = try JSONSerialization.string(from: [ 34 | "c": 1, 35 | "a": 2, 36 | "b": 3, 37 | ], options: .sortedKeys) 38 | 39 | XCTAssertEqual(json, #"{"a":2,"b":3,"c":1}"#) 40 | } 41 | 42 | func testObjectKeyDeserializationOrder() throws { 43 | 44 | let object: JSON = [ 45 | "c": 1, 46 | "a": 2, 47 | "b": 3, 48 | ] 49 | 50 | XCTAssertEqual(object, try JSONSerialization.json(from: #"{"c":1,"a":2,"b":3}"#)) 51 | } 52 | 53 | func testDescriptionOrder() throws { 54 | 55 | let json: JSON = [ 56 | "c": 1, 57 | "a": 2, 58 | "b": 3, 59 | ] 60 | 61 | XCTAssertEqual( 62 | json.description, 63 | """ 64 | { 65 | "c" : 1, 66 | "a" : 2, 67 | "b" : 3 68 | } 69 | """ 70 | ) 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /Tests/JSONWriterTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JSONWriterTests.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | @testable import PotentJSON 13 | import XCTest 14 | 15 | 16 | class JSONWriterTests: XCTestCase { 17 | 18 | func testEscapesQuotes() throws { 19 | 20 | let json = try JSONSerialization.string(from: .string(#""test""#), options: [.escapeSlashes]) 21 | XCTAssertEqual(json, #""\"test\"""#) 22 | } 23 | 24 | func testEscapesForwardSlashes() throws { 25 | 26 | let json = try JSONSerialization.string(from: .string("http://example.com/some/thing"), options: [.escapeSlashes]) 27 | XCTAssertEqual(json, #""http:\/\/example.com\/some\/thing""#) 28 | } 29 | 30 | func testEscapesBackwardSlashes() throws { 31 | 32 | let json = try JSONSerialization.string(from: .string(#"c:\a\file"#), options: [.escapeSlashes]) 33 | XCTAssertEqual(json, #""c:\\a\\file""#) 34 | } 35 | 36 | func testEscapesBackspace() throws { 37 | 38 | let json = try JSONSerialization.string(from: .string("\u{08}"), options: [.escapeSlashes]) 39 | XCTAssertEqual(json, #""\b""#) 40 | } 41 | 42 | func testEscapesFormFeed() throws { 43 | 44 | let json = try JSONSerialization.string(from: .string("\u{0c}"), options: [.escapeSlashes]) 45 | XCTAssertEqual(json, #""\f""#) 46 | } 47 | 48 | func testEscapesNewLine() throws { 49 | 50 | let json = try JSONSerialization.string(from: .string("\n"), options: [.escapeSlashes]) 51 | XCTAssertEqual(json, #""\n""#) 52 | } 53 | 54 | func testEscapesCarriageReturn() throws { 55 | 56 | let json = try JSONSerialization.string(from: .string("\r"), options: [.escapeSlashes]) 57 | XCTAssertEqual(json, #""\r""#) 58 | } 59 | 60 | func testEscapesTab() throws { 61 | 62 | let json = try JSONSerialization.string(from: .string("\t"), options: [.escapeSlashes]) 63 | XCTAssertEqual(json, #""\t""#) 64 | } 65 | 66 | func testEscapesUnicodeFormatInLongForm() throws { 67 | 68 | let json = try JSONSerialization.string(from: .string("\u{0}"), options: [.escapeSlashes]) 69 | XCTAssertEqual(json, #""\u0000""#) 70 | 71 | let json2 = try JSONSerialization.string(from: .string("\u{10}"), options: [.escapeSlashes]) 72 | XCTAssertEqual(json2, #""\u0010""#) 73 | } 74 | 75 | func testRewritesIntegerFloats() throws { 76 | 77 | let json = try JSONSerialization.string(from: .number("100.0"), options: [.escapeSlashes]) 78 | XCTAssertEqual(json, #"100"#) 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /Tests/YAMLErrorTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YAMLErrorTests.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2019 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import Foundation 12 | import PotentYAML 13 | import XCTest 14 | 15 | 16 | /// Tests covering *fixed* errors in libfyaml or its usage. 17 | /// 18 | class YAMLErrorTests: XCTestCase { 19 | 20 | public func testEmitNumberInPlainString() throws { 21 | 22 | let scalarYaml1: YAML = "1924." 23 | XCTAssertEqual( 24 | try YAMLSerialization.string(from: scalarYaml1), 25 | #""" 26 | "1924." 27 | 28 | """# 29 | ) 30 | } 31 | 32 | public func testSimpleScalarNotOnDocMarkerLinePretty() throws { 33 | 34 | let scalarYaml1: YAML = "simple" 35 | XCTAssertEqual( 36 | try YAMLSerialization.string(from: scalarYaml1, options: [.pretty]), 37 | #""" 38 | --- 39 | simple 40 | ... 41 | 42 | """# 43 | ) 44 | } 45 | 46 | public func testSimpleScalarNotOnDocMarkerLineExplicit() throws { 47 | 48 | let scalarYaml1: YAML = "simple" 49 | XCTAssertEqual( 50 | try YAMLSerialization.string(from: scalarYaml1, options: [.explictDocumentMarkers]), 51 | #""" 52 | --- 53 | simple 54 | ... 55 | 56 | """# 57 | ) 58 | } 59 | 60 | public func testSimpleScalarNoDocMarkers() throws { 61 | 62 | let scalarYaml1: YAML = "simple" 63 | XCTAssertEqual( 64 | try YAMLSerialization.string(from: scalarYaml1, options: []), 65 | #""" 66 | simple 67 | 68 | """# 69 | ) 70 | } 71 | 72 | public func testOutputWhitespaceOnlyString() throws { 73 | 74 | let scalarYaml1: YAML = .string(.init(repeating: " ", count: 1)) 75 | XCTAssertEqual( 76 | try YAMLSerialization.string(from: scalarYaml1), 77 | #""" 78 | " " 79 | 80 | """# 81 | ) 82 | 83 | let scalarYaml2: YAML = .string(.init(repeating: " ", count: 2)) 84 | XCTAssertEqual( 85 | try YAMLSerialization.string(from: scalarYaml2), 86 | #""" 87 | " " 88 | 89 | """# 90 | ) 91 | 92 | let scalarYaml3: YAML = .string(.init(repeating: " ", count: 3)) 93 | XCTAssertEqual( 94 | try YAMLSerialization.string(from: scalarYaml3), 95 | #""" 96 | " " 97 | 98 | """# 99 | ) 100 | 101 | let scalarYaml9: YAML = .string(.init(repeating: " ", count: 9)) 102 | XCTAssertEqual( 103 | try YAMLSerialization.string(from: scalarYaml9), 104 | #""" 105 | " " 106 | 107 | """# 108 | ) 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /Tests/YAMLOrderTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YAMLOrderTests.swift 3 | // PotentCodables 4 | // 5 | // Copyright © 2021 Outfox, inc. 6 | // 7 | // 8 | // Distributed under the MIT License, See LICENSE for details. 9 | // 10 | 11 | import BigInt 12 | import Foundation 13 | import PotentCodables 14 | import PotentYAML 15 | import XCTest 16 | 17 | 18 | class YAMLOrderTests: XCTestCase { 19 | 20 | func testObjectKeySerializationExplicitOrder() throws { 21 | 22 | let yaml = try YAMLSerialization.string(from: [ 23 | "c": 1, 24 | "a": 2, 25 | "b": 3, 26 | ]) 27 | 28 | XCTAssertEqual( 29 | yaml.description, 30 | """ 31 | c: 1 32 | a: 2 33 | b: 3 34 | 35 | """ 36 | ) 37 | } 38 | 39 | func testObjectKeySerializationSortedOrder() throws { 40 | 41 | let yaml = try YAMLSerialization.string(from: [ 42 | "c": 1, 43 | "a": 2, 44 | "b": 3, 45 | ], options: .sortedKeys) 46 | 47 | XCTAssertEqual( 48 | yaml.description, 49 | """ 50 | a: 2 51 | b: 3 52 | c: 1 53 | 54 | """ 55 | ) 56 | } 57 | 58 | func testObjectKeyDeserializationOrder() throws { 59 | 60 | let mapping: YAML = [ 61 | "c": 1, 62 | "a": 2, 63 | "b": 3, 64 | ] 65 | 66 | XCTAssertEqual( 67 | mapping, 68 | try YAMLSerialization.yaml(from: 69 | """ 70 | --- 71 | c: 1 72 | a: 2 73 | b: 3 74 | ... 75 | 76 | """ 77 | ) 78 | ) 79 | } 80 | 81 | func testDescriptionOrder() throws { 82 | 83 | let yaml: YAML = [ 84 | "c": 1, 85 | "a": 2, 86 | "b": 3, 87 | ] 88 | 89 | XCTAssertEqual( 90 | yaml.description, 91 | """ 92 | {c: 1, a: 2, b: 3} 93 | """ 94 | ) 95 | } 96 | 97 | } 98 | --------------------------------------------------------------------------------