From 8ac1da6b07fabe61c2b9475e70d8662b1468513c Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 10 Apr 2025 10:36:59 -0400 Subject: [PATCH] Upgrade Sourcemeta Core to the latest version Signed-off-by: Juan Cruz Viotti --- DEPENDENCIES | 2 +- config.cmake.in | 2 +- src/compiler/compiler.cc | 7 +- src/compiler/mapper/enum_8_bit.h | 7 +- src/compiler/mapper/enum_8_bit_top_level.h | 7 +- src/compiler/mapper/enum_arbitrary.h | 7 +- src/compiler/mapper/enum_singleton.h | 7 +- src/compiler/mapper/integer_bounded_8_bit.h | 9 +- .../integer_bounded_greater_than_8_bit.h | 7 +- .../mapper/integer_bounded_multiplier_8_bit.h | 11 +- ...er_bounded_multiplier_greater_than_8_bit.h | 9 +- src/compiler/mapper/integer_lower_bound.h | 7 +- .../mapper/integer_lower_bound_multiplier.h | 9 +- src/compiler/mapper/integer_unbound.h | 5 +- .../mapper/integer_unbound_multiplier.h | 7 +- src/compiler/mapper/integer_upper_bound.h | 7 +- .../mapper/integer_upper_bound_multiplier.h | 9 +- src/compiler/mapper/number_arbitrary.h | 5 +- .../circleciblank/schema-less/canonical.json | 9 +- .../circlecimatrix/schema-less/canonical.json | 9 +- .../e2e/commitlint/schema-less/canonical.json | 9 +- .../schema-less/canonical.json | 9 +- test/e2e/epr/schema-less/canonical.json | 9 +- test/e2e/eslintrc/schema-less/canonical.json | 9 +- test/e2e/esmrc/schema-less/canonical.json | 9 +- test/e2e/geojson/schema-less/canonical.json | 9 +- .../schema-less/canonical.json | 9 +- .../githubworkflow/schema-less/canonical.json | 9 +- .../schema-less/canonical.json | 9 +- .../schema-less/canonical.json | 9 +- .../schema-less/canonical.json | 9 +- test/e2e/jsonesort/schema-less/canonical.json | 9 +- test/e2e/jsonfeed/schema-less/canonical.json | 9 +- .../e2e/jsonresume/schema-less/canonical.json | 9 +- .../schema-less/canonical.json | 9 +- .../netcoreproject/schema-less/canonical.json | 9 +- .../e2e/nightwatch/schema-less/canonical.json | 9 +- .../openweathermap/schema-less/canonical.json | 9 +- .../schema-less/canonical.json | 9 +- test/e2e/ox-test/schema-less/canonical.json | 9 +- .../packagejson/schema-less/canonical.json | 9 +- .../schema-less/canonical.json | 9 +- .../schema-less/canonical.json | 9 +- .../schema-less/canonical.json | 9 +- .../tslintbasic/schema-less/canonical.json | 9 +- .../tslintextend/schema-less/canonical.json | 9 +- .../tslintmulti/schema-less/canonical.json | 9 +- vendor/core/cmake/FindBoostRegex.cmake | 14 +- vendor/core/cmake/common/defaults.cmake | 40 +++- vendor/core/config.cmake.in | 1 + .../core/json/include/sourcemeta/core/json.h | 3 +- .../json/include/sourcemeta/core/json_error.h | 32 ++- .../json/include/sourcemeta/core/json_hash.h | 7 +- .../include/sourcemeta/core/json_object.h | 23 ++ .../json/include/sourcemeta/core/json_value.h | 19 ++ vendor/core/src/core/json/json.cc | 15 +- vendor/core/src/core/json/json_value.cc | 7 + vendor/core/src/core/json/parser.h | 2 +- vendor/core/src/core/json/stringify.h | 67 +++++- .../core/src/core/jsonpointer/CMakeLists.txt | 4 +- .../include/sourcemeta/core/jsonpointer.h | 4 - .../sourcemeta/core/jsonpointer_proxy.h | 142 ----------- .../sourcemeta/core/jsonpointer_template.h | 146 ++++++++++- vendor/core/src/core/jsonpointer/stringify.h | 16 ++ vendor/core/src/core/jsonschema/bundle.cc | 2 +- vendor/core/src/core/jsonschema/frame.cc | 226 +++++++++++++++++- .../include/sourcemeta/core/jsonschema.h | 22 ++ .../sourcemeta/core/jsonschema_frame.h | 10 + .../sourcemeta/core/jsonschema_resolver.h | 12 +- .../sourcemeta/core/jsonschema_transform.h | 15 +- .../sourcemeta/core/jsonschema_types.h | 39 ++- vendor/core/src/core/jsonschema/jsonschema.cc | 19 +- .../src/core/jsonschema/official_walker.cc | 151 ++++++------ .../core/src/core/jsonschema/transformer.cc | 20 +- vendor/core/src/core/jsonschema/walker.cc | 118 ++++++++- .../regex/include/sourcemeta/core/regex.h | 27 ++- .../core/uri/include/sourcemeta/core/uri.h | 6 +- vendor/core/src/core/uri/uri.cc | 19 +- .../core/yaml/include/sourcemeta/core/yaml.h | 20 ++ vendor/core/src/core/yaml/yaml.cc | 28 ++- .../alterschema/antipattern/const_with_type.h | 4 +- .../antipattern/duplicate_enum_values.h | 6 +- .../antipattern/duplicate_required_values.h | 6 +- .../alterschema/antipattern/enum_with_type.h | 4 +- .../exclusive_maximum_number_and_maximum.h | 9 +- .../exclusive_minimum_number_and_minimum.h | 9 +- .../alterschema/desugar/boolean_true.h | 4 +- .../alterschema/desugar/const_as_enum.h | 10 +- .../exclusive_maximum_integer_to_maximum.h | 16 +- .../exclusive_minimum_integer_to_minimum.h | 16 +- .../desugar/type_array_to_any_of_2020_12.h | 12 +- .../desugar/type_boolean_as_enum.h | 6 +- .../alterschema/desugar/type_null_as_enum.h | 6 +- .../max_contains_covered_by_max_items.h | 4 +- .../implicit/min_items_given_min_contains.h | 14 +- .../alterschema/implicit/min_items_implicit.h | 4 +- .../implicit/min_length_implicit.h | 4 +- .../min_properties_covered_by_required.h | 7 +- .../implicit/min_properties_implicit.h | 12 +- .../implicit/multiple_of_implicit.h | 4 +- .../implicit/properties_implicit.h | 4 +- .../implicit/type_union_implicit.h | 4 +- .../redundant/additional_properties_default.h | 4 +- .../redundant/content_schema_default.h | 4 +- .../redundant/dependencies_default.h | 4 +- .../redundant/dependent_required_default.h | 4 +- .../redundant/items_array_default.h | 4 +- .../redundant/items_schema_default.h | 4 +- .../redundant/pattern_properties_default.h | 4 +- .../redundant/properties_default.h | 4 +- .../redundant/unevaluated_items_default.h | 4 +- .../unevaluated_properties_default.h | 4 +- .../redundant/unsatisfiable_max_contains.h | 4 +- .../redundant/unsatisfiable_min_properties.h | 4 +- .../dependencies_property_tautology.h | 17 +- .../simplify/dependent_required_tautology.h | 18 +- .../simplify/equal_numeric_bounds_to_enum.h | 12 +- .../simplify/maximum_real_for_integer.h | 6 +- .../simplify/minimum_real_for_integer.h | 6 +- .../alterschema/simplify/single_type_array.h | 6 +- .../content_media_type_without_encoding.h | 4 +- .../content_schema_without_media_type.h | 4 +- ...op_non_array_keywords_applicator_2019_09.h | 4 +- ...op_non_array_keywords_applicator_2020_12.h | 4 +- .../drop_non_array_keywords_content_2019_09.h | 4 +- .../drop_non_array_keywords_content_2020_12.h | 4 +- .../drop_non_array_keywords_draft0.h | 4 +- .../drop_non_array_keywords_draft1.h | 4 +- .../drop_non_array_keywords_draft2.h | 4 +- .../drop_non_array_keywords_draft3.h | 4 +- .../drop_non_array_keywords_draft4.h | 4 +- .../drop_non_array_keywords_draft6.h | 4 +- .../drop_non_array_keywords_draft7.h | 4 +- .../drop_non_array_keywords_format_2019_09.h | 4 +- .../drop_non_array_keywords_format_2020_12.h | 4 +- ...p_non_array_keywords_unevaluated_2020_12.h | 4 +- ...op_non_array_keywords_validation_2019_09.h | 4 +- ...op_non_array_keywords_validation_2020_12.h | 4 +- ..._non_boolean_keywords_applicator_2019_09.h | 4 +- ..._non_boolean_keywords_applicator_2020_12.h | 4 +- ...rop_non_boolean_keywords_content_2019_09.h | 4 +- ...rop_non_boolean_keywords_content_2020_12.h | 4 +- .../drop_non_boolean_keywords_draft0.h | 4 +- .../drop_non_boolean_keywords_draft1.h | 4 +- .../drop_non_boolean_keywords_draft2.h | 4 +- .../drop_non_boolean_keywords_draft3.h | 4 +- .../drop_non_boolean_keywords_draft4.h | 4 +- .../drop_non_boolean_keywords_draft6.h | 4 +- .../drop_non_boolean_keywords_draft7.h | 4 +- ...drop_non_boolean_keywords_format_2019_09.h | 4 +- ...drop_non_boolean_keywords_format_2020_12.h | 4 +- ...non_boolean_keywords_unevaluated_2020_12.h | 4 +- ..._non_boolean_keywords_validation_2019_09.h | 4 +- ..._non_boolean_keywords_validation_2020_12.h | 4 +- ...rop_non_null_keywords_applicator_2019_09.h | 4 +- ...rop_non_null_keywords_applicator_2020_12.h | 4 +- .../drop_non_null_keywords_content_2019_09.h | 4 +- .../drop_non_null_keywords_content_2020_12.h | 4 +- .../drop_non_null_keywords_draft0.h | 4 +- .../drop_non_null_keywords_draft1.h | 4 +- .../drop_non_null_keywords_draft2.h | 4 +- .../drop_non_null_keywords_draft3.h | 4 +- .../drop_non_null_keywords_draft4.h | 4 +- .../drop_non_null_keywords_draft6.h | 4 +- .../drop_non_null_keywords_draft7.h | 4 +- .../drop_non_null_keywords_format_2019_09.h | 4 +- .../drop_non_null_keywords_format_2020_12.h | 4 +- ...op_non_null_keywords_unevaluated_2020_12.h | 4 +- ...rop_non_null_keywords_validation_2019_09.h | 4 +- ...rop_non_null_keywords_validation_2020_12.h | 4 +- ..._non_numeric_keywords_applicator_2019_09.h | 4 +- ..._non_numeric_keywords_applicator_2020_12.h | 4 +- ...rop_non_numeric_keywords_content_2019_09.h | 4 +- ...rop_non_numeric_keywords_content_2020_12.h | 4 +- .../drop_non_numeric_keywords_draft0.h | 4 +- .../drop_non_numeric_keywords_draft1.h | 4 +- .../drop_non_numeric_keywords_draft2.h | 4 +- .../drop_non_numeric_keywords_draft3.h | 4 +- .../drop_non_numeric_keywords_draft4.h | 4 +- .../drop_non_numeric_keywords_draft6.h | 4 +- .../drop_non_numeric_keywords_draft7.h | 4 +- ...drop_non_numeric_keywords_format_2019_09.h | 4 +- ...drop_non_numeric_keywords_format_2020_12.h | 4 +- ...non_numeric_keywords_unevaluated_2020_12.h | 4 +- ..._non_numeric_keywords_validation_2019_09.h | 4 +- ..._non_numeric_keywords_validation_2020_12.h | 4 +- ...p_non_object_keywords_applicator_2019_09.h | 4 +- ...p_non_object_keywords_applicator_2020_12.h | 4 +- ...drop_non_object_keywords_content_2019_09.h | 4 +- ...drop_non_object_keywords_content_2020_12.h | 4 +- .../drop_non_object_keywords_draft0.h | 4 +- .../drop_non_object_keywords_draft1.h | 4 +- .../drop_non_object_keywords_draft2.h | 4 +- .../drop_non_object_keywords_draft3.h | 4 +- .../drop_non_object_keywords_draft4.h | 4 +- .../drop_non_object_keywords_draft6.h | 4 +- .../drop_non_object_keywords_draft7.h | 4 +- .../drop_non_object_keywords_format_2019_09.h | 4 +- .../drop_non_object_keywords_format_2020_12.h | 4 +- ..._non_object_keywords_unevaluated_2020_12.h | 4 +- ...p_non_object_keywords_validation_2019_09.h | 4 +- ...p_non_object_keywords_validation_2020_12.h | 4 +- ...p_non_string_keywords_applicator_2019_09.h | 4 +- ...p_non_string_keywords_applicator_2020_12.h | 4 +- .../drop_non_string_keywords_draft0.h | 4 +- .../drop_non_string_keywords_draft1.h | 4 +- .../drop_non_string_keywords_draft2.h | 4 +- .../drop_non_string_keywords_draft3.h | 4 +- .../drop_non_string_keywords_draft4.h | 4 +- .../drop_non_string_keywords_draft6.h | 4 +- .../drop_non_string_keywords_draft7.h | 4 +- ..._non_string_keywords_unevaluated_2020_12.h | 4 +- ...p_non_string_keywords_validation_2019_09.h | 4 +- ...p_non_string_keywords_validation_2020_12.h | 4 +- .../superfluous/duplicate_allof_branches.h | 6 +- .../superfluous/duplicate_anyof_branches.h | 6 +- .../alterschema/superfluous/else_without_if.h | 4 +- .../superfluous/if_without_then_else.h | 4 +- .../max_contains_without_contains.h | 4 +- .../min_contains_without_contains.h | 4 +- .../alterschema/superfluous/then_without_if.h | 4 +- .../alterschema/syntax_sugar/enum_to_const.h | 7 +- 222 files changed, 1388 insertions(+), 966 deletions(-) delete mode 100644 vendor/core/src/core/jsonpointer/include/sourcemeta/core/jsonpointer_proxy.h diff --git a/DEPENDENCIES b/DEPENDENCIES index 4a673edf6..8099c7a5a 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,3 +1,3 @@ vendorpull https://github.com/sourcemeta/vendorpull 70342aaf458e6cb80baeb5b718901075fc42ede6 -core https://github.com/sourcemeta/core 918a17d1e4f82a12334bf99d67ffef4e77fd6722 +core https://github.com/sourcemeta/core bf0868140c6adc6e58bc3be074ea9ed9ed1efd05 bootstrap https://github.com/twbs/bootstrap 1a6fdfae6be09b09eaced8f0e442ca6f7680a61e diff --git a/config.cmake.in b/config.cmake.in index 395486e67..3c1b903cc 100644 --- a/config.cmake.in +++ b/config.cmake.in @@ -10,7 +10,7 @@ if(NOT JSONBINPACK_COMPONENTS) endif() include(CMakeFindDependencyMacro) -find_dependency(Core COMPONENTS uri json jsonpointer jsonschema alterschema) +find_dependency(Core COMPONENTS regex uri json jsonpointer jsonschema alterschema) foreach(component ${JSONBINPACK_COMPONENTS}) if(component STREQUAL "numeric") diff --git a/src/compiler/compiler.cc b/src/compiler/compiler.cc index e26f66d46..20b2d2df7 100644 --- a/src/compiler/compiler.cc +++ b/src/compiler/compiler.cc @@ -27,10 +27,10 @@ auto canonicalize(sourcemeta::core::JSON &schema, sourcemeta::core::empty_pointer, default_dialect); } -auto make_encoding(sourcemeta::core::PointerProxy &document, +auto make_encoding(sourcemeta::core::JSON &document, const std::string &encoding, const sourcemeta::core::JSON &options) -> void { - document.replace(sourcemeta::core::JSON::make_object()); + document.into_object(); document.assign("$schema", sourcemeta::core::JSON{ENCODING_V1}); document.assign("binpackEncoding", sourcemeta::core::JSON{encoding}); document.assign("binpackOptions", options); @@ -87,8 +87,7 @@ auto compile(sourcemeta::core::JSON &schema, // The "any" encoding is always the last resort const auto dialect{sourcemeta::core::dialect(schema)}; if (!dialect.has_value() || dialect.value() != ENCODING_V1) { - sourcemeta::core::PointerProxy transformer{schema}; - make_encoding(transformer, "ANY_PACKED_TYPE_TAG_BYTE_PREFIX", + make_encoding(schema, "ANY_PACKED_TYPE_TAG_BYTE_PREFIX", sourcemeta::core::JSON::make_object()); } } diff --git a/src/compiler/mapper/enum_8_bit.h b/src/compiler/mapper/enum_8_bit.h index e35fea936..fc8401777 100644 --- a/src/compiler/mapper/enum_8_bit.h +++ b/src/compiler/mapper/enum_8_bit.h @@ -16,10 +16,9 @@ class Enum8Bit final : public sourcemeta::core::SchemaTransformRule { is_byte(schema.at("enum").size() - 1); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { + auto transform(sourcemeta::core::JSON &schema) const -> void override { auto options = sourcemeta::core::JSON::make_object(); - options.assign("choices", transformer.value().at("enum")); - make_encoding(transformer, "BYTE_CHOICE_INDEX", options); + options.assign("choices", schema.at("enum")); + make_encoding(schema, "BYTE_CHOICE_INDEX", options); } }; diff --git a/src/compiler/mapper/enum_8_bit_top_level.h b/src/compiler/mapper/enum_8_bit_top_level.h index eba7ac6f0..091289a35 100644 --- a/src/compiler/mapper/enum_8_bit_top_level.h +++ b/src/compiler/mapper/enum_8_bit_top_level.h @@ -16,10 +16,9 @@ class Enum8BitTopLevel final : public sourcemeta::core::SchemaTransformRule { is_byte(schema.at("enum").size() - 1); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { + auto transform(sourcemeta::core::JSON &schema) const -> void override { auto options = sourcemeta::core::JSON::make_object(); - options.assign("choices", transformer.value().at("enum")); - make_encoding(transformer, "TOP_LEVEL_BYTE_CHOICE_INDEX", options); + options.assign("choices", schema.at("enum")); + make_encoding(schema, "TOP_LEVEL_BYTE_CHOICE_INDEX", options); } }; diff --git a/src/compiler/mapper/enum_arbitrary.h b/src/compiler/mapper/enum_arbitrary.h index 9cd354bfa..8d66993da 100644 --- a/src/compiler/mapper/enum_arbitrary.h +++ b/src/compiler/mapper/enum_arbitrary.h @@ -17,10 +17,9 @@ class EnumArbitrary final : public sourcemeta::core::SchemaTransformRule { !is_byte(schema.at("enum").size() - 1); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { + auto transform(sourcemeta::core::JSON &schema) const -> void override { auto options = sourcemeta::core::JSON::make_object(); - options.assign("choices", transformer.value().at("enum")); - make_encoding(transformer, "LARGE_CHOICE_INDEX", options); + options.assign("choices", schema.at("enum")); + make_encoding(schema, "LARGE_CHOICE_INDEX", options); } }; diff --git a/src/compiler/mapper/enum_singleton.h b/src/compiler/mapper/enum_singleton.h index e91bc0bf3..ce0627c3c 100644 --- a/src/compiler/mapper/enum_singleton.h +++ b/src/compiler/mapper/enum_singleton.h @@ -15,10 +15,9 @@ class EnumSingleton final : public sourcemeta::core::SchemaTransformRule { schema.at("enum").size() == 1; } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { + auto transform(sourcemeta::core::JSON &schema) const -> void override { auto options = sourcemeta::core::JSON::make_object(); - options.assign("value", transformer.value().at("enum").at(0)); - make_encoding(transformer, "CONST_NONE", options); + options.assign("value", schema.at("enum").at(0)); + make_encoding(schema, "CONST_NONE", options); } }; diff --git a/src/compiler/mapper/integer_bounded_8_bit.h b/src/compiler/mapper/integer_bounded_8_bit.h index bef1d3125..5d8a55d93 100644 --- a/src/compiler/mapper/integer_bounded_8_bit.h +++ b/src/compiler/mapper/integer_bounded_8_bit.h @@ -19,14 +19,13 @@ class IntegerBounded8Bit final : public sourcemeta::core::SchemaTransformRule { !schema.defines("multipleOf"); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { - auto minimum = transformer.value().at("minimum"); - auto maximum = transformer.value().at("maximum"); + auto transform(sourcemeta::core::JSON &schema) const -> void override { + auto minimum = schema.at("minimum"); + auto maximum = schema.at("maximum"); auto options = sourcemeta::core::JSON::make_object(); options.assign("minimum", std::move(minimum)); options.assign("maximum", std::move(maximum)); options.assign("multiplier", sourcemeta::core::JSON{1}); - make_encoding(transformer, "BOUNDED_MULTIPLE_8BITS_ENUM_FIXED", options); + make_encoding(schema, "BOUNDED_MULTIPLE_8BITS_ENUM_FIXED", options); } }; diff --git a/src/compiler/mapper/integer_bounded_greater_than_8_bit.h b/src/compiler/mapper/integer_bounded_greater_than_8_bit.h index 5231772cb..be96e0f85 100644 --- a/src/compiler/mapper/integer_bounded_greater_than_8_bit.h +++ b/src/compiler/mapper/integer_bounded_greater_than_8_bit.h @@ -21,12 +21,11 @@ class IntegerBoundedGreaterThan8Bit final !schema.defines("multipleOf"); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { - auto minimum = transformer.value().at("minimum"); + auto transform(sourcemeta::core::JSON &schema) const -> void override { + auto minimum = schema.at("minimum"); auto options = sourcemeta::core::JSON::make_object(); options.assign("minimum", std::move(minimum)); options.assign("multiplier", sourcemeta::core::JSON{1}); - make_encoding(transformer, "FLOOR_MULTIPLE_ENUM_VARINT", options); + make_encoding(schema, "FLOOR_MULTIPLE_ENUM_VARINT", options); } }; diff --git a/src/compiler/mapper/integer_bounded_multiplier_8_bit.h b/src/compiler/mapper/integer_bounded_multiplier_8_bit.h index 7179b4e6c..3ee9782cb 100644 --- a/src/compiler/mapper/integer_bounded_multiplier_8_bit.h +++ b/src/compiler/mapper/integer_bounded_multiplier_8_bit.h @@ -26,16 +26,15 @@ class IntegerBoundedMultiplier8Bit final schema.at("multipleOf").to_integer())); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { - auto minimum = transformer.value().at("minimum"); - auto maximum = transformer.value().at("maximum"); - auto multiplier = transformer.value().at("multipleOf"); + auto transform(sourcemeta::core::JSON &schema) const -> void override { + auto minimum = schema.at("minimum"); + auto maximum = schema.at("maximum"); + auto multiplier = schema.at("multipleOf"); auto options = sourcemeta::core::JSON::make_object(); options.assign("minimum", std::move(minimum)); options.assign("maximum", std::move(maximum)); options.assign("multiplier", std::move(multiplier)); - make_encoding(transformer, "BOUNDED_MULTIPLE_8BITS_ENUM_FIXED", options); + make_encoding(schema, "BOUNDED_MULTIPLE_8BITS_ENUM_FIXED", options); } }; diff --git a/src/compiler/mapper/integer_bounded_multiplier_greater_than_8_bit.h b/src/compiler/mapper/integer_bounded_multiplier_greater_than_8_bit.h index f33de9a0a..96f14c37c 100644 --- a/src/compiler/mapper/integer_bounded_multiplier_greater_than_8_bit.h +++ b/src/compiler/mapper/integer_bounded_multiplier_greater_than_8_bit.h @@ -26,13 +26,12 @@ class IntegerBoundedMultiplierGreaterThan8Bit final schema.at("multipleOf").to_integer())); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { - auto minimum = transformer.value().at("minimum"); - auto multiplier = transformer.value().at("multipleOf"); + auto transform(sourcemeta::core::JSON &schema) const -> void override { + auto minimum = schema.at("minimum"); + auto multiplier = schema.at("multipleOf"); auto options = sourcemeta::core::JSON::make_object(); options.assign("minimum", std::move(minimum)); options.assign("multiplier", std::move(multiplier)); - make_encoding(transformer, "FLOOR_MULTIPLE_ENUM_VARINT", options); + make_encoding(schema, "FLOOR_MULTIPLE_ENUM_VARINT", options); } }; diff --git a/src/compiler/mapper/integer_lower_bound.h b/src/compiler/mapper/integer_lower_bound.h index f433b6860..cf23edcb5 100644 --- a/src/compiler/mapper/integer_lower_bound.h +++ b/src/compiler/mapper/integer_lower_bound.h @@ -17,12 +17,11 @@ class IntegerLowerBound final : public sourcemeta::core::SchemaTransformRule { !schema.defines("multipleOf"); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { - auto minimum = transformer.value().at("minimum"); + auto transform(sourcemeta::core::JSON &schema) const -> void override { + auto minimum = schema.at("minimum"); auto options = sourcemeta::core::JSON::make_object(); options.assign("minimum", std::move(minimum)); options.assign("multiplier", sourcemeta::core::JSON{1}); - make_encoding(transformer, "FLOOR_MULTIPLE_ENUM_VARINT", options); + make_encoding(schema, "FLOOR_MULTIPLE_ENUM_VARINT", options); } }; diff --git a/src/compiler/mapper/integer_lower_bound_multiplier.h b/src/compiler/mapper/integer_lower_bound_multiplier.h index d0ac8af61..81dacbdaa 100644 --- a/src/compiler/mapper/integer_lower_bound_multiplier.h +++ b/src/compiler/mapper/integer_lower_bound_multiplier.h @@ -19,13 +19,12 @@ class IntegerLowerBoundMultiplier final schema.defines("multipleOf") && schema.at("multipleOf").is_integer(); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { - auto minimum = transformer.value().at("minimum"); - auto multiplier = transformer.value().at("multipleOf"); + auto transform(sourcemeta::core::JSON &schema) const -> void override { + auto minimum = schema.at("minimum"); + auto multiplier = schema.at("multipleOf"); auto options = sourcemeta::core::JSON::make_object(); options.assign("minimum", std::move(minimum)); options.assign("multiplier", std::move(multiplier)); - make_encoding(transformer, "FLOOR_MULTIPLE_ENUM_VARINT", options); + make_encoding(schema, "FLOOR_MULTIPLE_ENUM_VARINT", options); } }; diff --git a/src/compiler/mapper/integer_unbound.h b/src/compiler/mapper/integer_unbound.h index 067b3066a..dd4c8d2db 100644 --- a/src/compiler/mapper/integer_unbound.h +++ b/src/compiler/mapper/integer_unbound.h @@ -17,10 +17,9 @@ class IntegerUnbound final : public sourcemeta::core::SchemaTransformRule { !schema.defines("multipleOf"); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { + auto transform(sourcemeta::core::JSON &schema) const -> void override { auto options = sourcemeta::core::JSON::make_object(); options.assign("multiplier", sourcemeta::core::JSON{1}); - make_encoding(transformer, "ARBITRARY_MULTIPLE_ZIGZAG_VARINT", options); + make_encoding(schema, "ARBITRARY_MULTIPLE_ZIGZAG_VARINT", options); } }; diff --git a/src/compiler/mapper/integer_unbound_multiplier.h b/src/compiler/mapper/integer_unbound_multiplier.h index ca0bc6e4a..63b97069b 100644 --- a/src/compiler/mapper/integer_unbound_multiplier.h +++ b/src/compiler/mapper/integer_unbound_multiplier.h @@ -19,11 +19,10 @@ class IntegerUnboundMultiplier final schema.defines("multipleOf") && schema.at("multipleOf").is_integer(); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { - auto multiplier = transformer.value().at("multipleOf"); + auto transform(sourcemeta::core::JSON &schema) const -> void override { + auto multiplier = schema.at("multipleOf"); auto options = sourcemeta::core::JSON::make_object(); options.assign("multiplier", std::move(multiplier)); - make_encoding(transformer, "ARBITRARY_MULTIPLE_ZIGZAG_VARINT", options); + make_encoding(schema, "ARBITRARY_MULTIPLE_ZIGZAG_VARINT", options); } }; diff --git a/src/compiler/mapper/integer_upper_bound.h b/src/compiler/mapper/integer_upper_bound.h index db37c9492..c770bf828 100644 --- a/src/compiler/mapper/integer_upper_bound.h +++ b/src/compiler/mapper/integer_upper_bound.h @@ -17,12 +17,11 @@ class IntegerUpperBound final : public sourcemeta::core::SchemaTransformRule { !schema.defines("multipleOf"); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { - auto maximum = transformer.value().at("maximum"); + auto transform(sourcemeta::core::JSON &schema) const -> void override { + auto maximum = schema.at("maximum"); auto options = sourcemeta::core::JSON::make_object(); options.assign("maximum", std::move(maximum)); options.assign("multiplier", sourcemeta::core::JSON{1}); - make_encoding(transformer, "ROOF_MULTIPLE_MIRROR_ENUM_VARINT", options); + make_encoding(schema, "ROOF_MULTIPLE_MIRROR_ENUM_VARINT", options); } }; diff --git a/src/compiler/mapper/integer_upper_bound_multiplier.h b/src/compiler/mapper/integer_upper_bound_multiplier.h index 891cef3f2..6c8b87484 100644 --- a/src/compiler/mapper/integer_upper_bound_multiplier.h +++ b/src/compiler/mapper/integer_upper_bound_multiplier.h @@ -19,13 +19,12 @@ class IntegerUpperBoundMultiplier final schema.defines("multipleOf") && schema.at("multipleOf").is_integer(); } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { - auto maximum = transformer.value().at("maximum"); - auto multiplier = transformer.value().at("multipleOf"); + auto transform(sourcemeta::core::JSON &schema) const -> void override { + auto maximum = schema.at("maximum"); + auto multiplier = schema.at("multipleOf"); auto options = sourcemeta::core::JSON::make_object(); options.assign("maximum", std::move(maximum)); options.assign("multiplier", std::move(multiplier)); - make_encoding(transformer, "ROOF_MULTIPLE_MIRROR_ENUM_VARINT", options); + make_encoding(schema, "ROOF_MULTIPLE_MIRROR_ENUM_VARINT", options); } }; diff --git a/src/compiler/mapper/number_arbitrary.h b/src/compiler/mapper/number_arbitrary.h index 3aef96f24..3b159f215 100644 --- a/src/compiler/mapper/number_arbitrary.h +++ b/src/compiler/mapper/number_arbitrary.h @@ -14,9 +14,8 @@ class NumberArbitrary final : public sourcemeta::core::SchemaTransformRule { schema.defines("type") && schema.at("type").to_string() == "number"; } - auto transform(sourcemeta::core::PointerProxy &transformer) const - -> void override { - make_encoding(transformer, "DOUBLE_VARINT_TUPLE", + auto transform(sourcemeta::core::JSON &schema) const -> void override { + make_encoding(schema, "DOUBLE_VARINT_TUPLE", sourcemeta::core::JSON::make_object()); } }; diff --git a/test/e2e/circleciblank/schema-less/canonical.json b/test/e2e/circleciblank/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/circleciblank/schema-less/canonical.json +++ b/test/e2e/circleciblank/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/circlecimatrix/schema-less/canonical.json b/test/e2e/circlecimatrix/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/circlecimatrix/schema-less/canonical.json +++ b/test/e2e/circlecimatrix/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/commitlint/schema-less/canonical.json b/test/e2e/commitlint/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/commitlint/schema-less/canonical.json +++ b/test/e2e/commitlint/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/commitlintbasic/schema-less/canonical.json b/test/e2e/commitlintbasic/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/commitlintbasic/schema-less/canonical.json +++ b/test/e2e/commitlintbasic/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/epr/schema-less/canonical.json b/test/e2e/epr/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/epr/schema-less/canonical.json +++ b/test/e2e/epr/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/eslintrc/schema-less/canonical.json b/test/e2e/eslintrc/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/eslintrc/schema-less/canonical.json +++ b/test/e2e/eslintrc/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/esmrc/schema-less/canonical.json b/test/e2e/esmrc/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/esmrc/schema-less/canonical.json +++ b/test/e2e/esmrc/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/geojson/schema-less/canonical.json b/test/e2e/geojson/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/geojson/schema-less/canonical.json +++ b/test/e2e/geojson/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/githubfundingblank/schema-less/canonical.json b/test/e2e/githubfundingblank/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/githubfundingblank/schema-less/canonical.json +++ b/test/e2e/githubfundingblank/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/githubworkflow/schema-less/canonical.json b/test/e2e/githubworkflow/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/githubworkflow/schema-less/canonical.json +++ b/test/e2e/githubworkflow/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/gruntcontribclean/schema-less/canonical.json b/test/e2e/gruntcontribclean/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/gruntcontribclean/schema-less/canonical.json +++ b/test/e2e/gruntcontribclean/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/imageoptimizerwebjob/schema-less/canonical.json b/test/e2e/imageoptimizerwebjob/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/imageoptimizerwebjob/schema-less/canonical.json +++ b/test/e2e/imageoptimizerwebjob/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/jsonereversesort/schema-less/canonical.json b/test/e2e/jsonereversesort/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/jsonereversesort/schema-less/canonical.json +++ b/test/e2e/jsonereversesort/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/jsonesort/schema-less/canonical.json b/test/e2e/jsonesort/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/jsonesort/schema-less/canonical.json +++ b/test/e2e/jsonesort/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/jsonfeed/schema-less/canonical.json b/test/e2e/jsonfeed/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/jsonfeed/schema-less/canonical.json +++ b/test/e2e/jsonfeed/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/jsonresume/schema-less/canonical.json b/test/e2e/jsonresume/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/jsonresume/schema-less/canonical.json +++ b/test/e2e/jsonresume/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/mixed-bounded-object/schema-less/canonical.json b/test/e2e/mixed-bounded-object/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/mixed-bounded-object/schema-less/canonical.json +++ b/test/e2e/mixed-bounded-object/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/netcoreproject/schema-less/canonical.json b/test/e2e/netcoreproject/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/netcoreproject/schema-less/canonical.json +++ b/test/e2e/netcoreproject/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/nightwatch/schema-less/canonical.json b/test/e2e/nightwatch/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/nightwatch/schema-less/canonical.json +++ b/test/e2e/nightwatch/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/openweathermap/schema-less/canonical.json b/test/e2e/openweathermap/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/openweathermap/schema-less/canonical.json +++ b/test/e2e/openweathermap/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/openweatherroadrisk/schema-less/canonical.json b/test/e2e/openweatherroadrisk/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/openweatherroadrisk/schema-less/canonical.json +++ b/test/e2e/openweatherroadrisk/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/ox-test/schema-less/canonical.json b/test/e2e/ox-test/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/ox-test/schema-less/canonical.json +++ b/test/e2e/ox-test/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/packagejson/schema-less/canonical.json b/test/e2e/packagejson/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/packagejson/schema-less/canonical.json +++ b/test/e2e/packagejson/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/packagejsonlintrc/schema-less/canonical.json b/test/e2e/packagejsonlintrc/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/packagejsonlintrc/schema-less/canonical.json +++ b/test/e2e/packagejsonlintrc/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/sapcloudsdkpipeline/schema-less/canonical.json b/test/e2e/sapcloudsdkpipeline/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/sapcloudsdkpipeline/schema-less/canonical.json +++ b/test/e2e/sapcloudsdkpipeline/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/travisnotifications/schema-less/canonical.json b/test/e2e/travisnotifications/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/travisnotifications/schema-less/canonical.json +++ b/test/e2e/travisnotifications/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/tslintbasic/schema-less/canonical.json b/test/e2e/tslintbasic/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/tslintbasic/schema-less/canonical.json +++ b/test/e2e/tslintbasic/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/tslintextend/schema-less/canonical.json b/test/e2e/tslintextend/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/tslintextend/schema-less/canonical.json +++ b/test/e2e/tslintextend/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/test/e2e/tslintmulti/schema-less/canonical.json b/test/e2e/tslintmulti/schema-less/canonical.json index d300c4c4d..6fb943814 100644 --- a/test/e2e/tslintmulti/schema-less/canonical.json +++ b/test/e2e/tslintmulti/schema-less/canonical.json @@ -1,15 +1,10 @@ { "anyOf": [ { - "enum": [ - null - ] + "enum": [ null ] }, { - "enum": [ - false, - true - ] + "enum": [ false, true ] }, { "type": "object", diff --git a/vendor/core/cmake/FindBoostRegex.cmake b/vendor/core/cmake/FindBoostRegex.cmake index 727061847..ad2369666 100644 --- a/vendor/core/cmake/FindBoostRegex.cmake +++ b/vendor/core/cmake/FindBoostRegex.cmake @@ -151,9 +151,9 @@ if(NOT BoostRegex_FOUND) install(TARGETS boost_regex EXPORT boost_regex PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost" - COMPONENT sourcemeta_core + COMPONENT sourcemeta_core_dev PRIVATE_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost" - COMPONENT sourcemeta_core + COMPONENT sourcemeta_core_dev RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT sourcemeta_core LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" @@ -163,19 +163,19 @@ if(NOT BoostRegex_FOUND) COMPONENT sourcemeta_core_dev) install(FILES ${BOOST_REGEX_PRIVATE_HEADERS_REGEX} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost/regex" - COMPONENT sourcemeta_core) + COMPONENT sourcemeta_core_dev) install(FILES ${BOOST_REGEX_PRIVATE_HEADERS_REGEX_CONFIG} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost/regex/config" - COMPONENT sourcemeta_core) + COMPONENT sourcemeta_core_dev) install(FILES ${BOOST_REGEX_PRIVATE_HEADERS_REGEX_PENDING} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost/regex/pending" - COMPONENT sourcemeta_core) + COMPONENT sourcemeta_core_dev) install(FILES ${BOOST_REGEX_PRIVATE_HEADERS_REGEX_V4} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost/regex/v4" - COMPONENT sourcemeta_core) + COMPONENT sourcemeta_core_dev) install(FILES ${BOOST_REGEX_PRIVATE_HEADERS_REGEX_V5} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/boost/regex/v5" - COMPONENT sourcemeta_core) + COMPONENT sourcemeta_core_dev) install(EXPORT boost_regex DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/boostregex" COMPONENT sourcemeta_core_dev) diff --git a/vendor/core/cmake/common/defaults.cmake b/vendor/core/cmake/common/defaults.cmake index 437d101ea..929d1fafa 100644 --- a/vendor/core/cmake/common/defaults.cmake +++ b/vendor/core/cmake/common/defaults.cmake @@ -41,6 +41,17 @@ endif() # It is very useful for IDE integration, linting, etc set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +# CMake typically defaults to -O2 for RelWithDebInfo, which can +# result in slight differences when comparing to Release when +# profiling or analysing the resulting assembly +# See https://stackoverflow.com/a/59314670 +if(SOURCEMETA_COMPILER_LLVM OR SOURCEMETA_COMPILER_GCC) + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g" CACHE STRING "Optimization level for RelWithDebInfo (C)" FORCE) + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g" CACHE STRING "Optimization level for RelWithDebInfo (C++)" FORCE) + set(CMAKE_OBJC_FLAGS_RELWITHDEBINFO "-O3 -g" CACHE STRING "Optimization level for RelWithDebInfo (Objective-C)" FORCE) + set(CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO "-O3 -g" CACHE STRING "Optimization level for RelWithDebInfo (Objective-C++)" FORCE) +endif() + # Prevent DT_RPATH/DT_RUNPATH problem # This problem is not present on Apple platforms. # See https://www.youtube.com/watch?v=m0DwB4OvDXk @@ -79,19 +90,24 @@ endif() # - https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html # - https://llvm.org/docs/FatLTO.html -if(SOURCEMETA_COMPILER_GCC AND CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT BUILD_SHARED_LIBS) - message(STATUS "Enabling Fat LTO") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -ffat-lto-objects") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto") -endif() +# Note we don't enable LTO on RelWithDebInfo, as it breaks debugging symbols +# on at least AppleClang, making stepping through source code impossible. -# TODO: Make this work on Linux on LLVM -if(SOURCEMETA_COMPILER_LLVM AND CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT BUILD_SHARED_LIBS AND APPLE) - message(STATUS "Enabling Fat LTO") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=full") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto=full") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto=full") +if(CMAKE_BUILD_TYPE STREQUAL "Release") + if(SOURCEMETA_COMPILER_GCC AND NOT BUILD_SHARED_LIBS) + message(STATUS "Enabling Fat LTO") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -ffat-lto-objects") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto") + endif() + + # TODO: Make this work on Linux on LLVM + if(SOURCEMETA_COMPILER_LLVM AND NOT BUILD_SHARED_LIBS AND APPLE) + message(STATUS "Enabling Fat LTO") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=full") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto=full") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto=full") + endif() endif() # Attempt to enable SIMD (SSE/AVX/NEON) diff --git a/vendor/core/config.cmake.in b/vendor/core/config.cmake.in index b3e66e633..4cc3ee4dd 100644 --- a/vendor/core/config.cmake.in +++ b/vendor/core/config.cmake.in @@ -30,6 +30,7 @@ foreach(component ${SOURCEMETA_CORE_COMPONENTS}) include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonl.cmake") elseif(component STREQUAL "jsonpointer") find_dependency(uriparser) + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_regex.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_uri.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_json.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonpointer.cmake") diff --git a/vendor/core/src/core/json/include/sourcemeta/core/json.h b/vendor/core/src/core/json/include/sourcemeta/core/json.h index c901afb00..7ab734044 100644 --- a/vendor/core/src/core/json/include/sourcemeta/core/json.h +++ b/vendor/core/src/core/json/include/sourcemeta/core/json.h @@ -127,7 +127,8 @@ auto parse_json(const std::basic_string &input, /// /// If parsing fails, sourcemeta::core::JSONParseError will be thrown. SOURCEMETA_CORE_JSON_EXPORT -auto read_json(const std::filesystem::path &path) -> JSON; +auto read_json(const std::filesystem::path &path, + const JSON::ParseCallback &callback = nullptr) -> JSON; // TODO: Move this function to a system integration component, as it // is not JSON specific diff --git a/vendor/core/src/core/json/include/sourcemeta/core/json_error.h b/vendor/core/src/core/json/include/sourcemeta/core/json_error.h index 2eef13e3c..0fe1e3c6f 100644 --- a/vendor/core/src/core/json/include/sourcemeta/core/json_error.h +++ b/vendor/core/src/core/json/include/sourcemeta/core/json_error.h @@ -26,8 +26,13 @@ class SOURCEMETA_CORE_JSON_EXPORT JSONParseError : public std::exception { JSONParseError(const std::uint64_t line, const std::uint64_t column) : line_{line}, column_{column} {} + /// Create a parsing error with a custom error + JSONParseError(const std::uint64_t line, const std::uint64_t column, + std::string message) + : line_{line}, column_{column}, message_{std::move(message)} {} + [[nodiscard]] auto what() const noexcept -> const char * override { - return "Failed to parse the JSON document"; + return this->message_.c_str(); } /// Get the line number of the error @@ -41,6 +46,21 @@ class SOURCEMETA_CORE_JSON_EXPORT JSONParseError : public std::exception { private: std::uint64_t line_; std::uint64_t column_; + std::string message_{"Failed to parse the JSON document"}; +}; + +/// @ingroup json +/// This class represents a numeric integer limit parsing error +class SOURCEMETA_CORE_JSON_EXPORT JSONParseIntegerLimitError + : public JSONParseError { +public: + /// Create a parsing error + JSONParseIntegerLimitError(const std::uint64_t line, + const std::uint64_t column) + : JSONParseError{ + line, column, + "The JSON value is not representable by the IETF RFC 8259 " + "interoperable signed integer range"} {} }; /// @ingroup json @@ -49,15 +69,17 @@ class SOURCEMETA_CORE_JSON_EXPORT JSONFileParseError : public JSONParseError { public: /// Create a file parsing error JSONFileParseError(const std::filesystem::path &path, - const std::uint64_t line, const std::uint64_t column) - : JSONParseError{line, column}, path_{path} {} + const std::uint64_t line, const std::uint64_t column, + std::string message) + : JSONParseError{line, column, std::move(message)}, path_{path} {} /// Create a file parsing error from a parse error JSONFileParseError(const std::filesystem::path &path, const JSONParseError &parent) - : JSONParseError{parent.line(), parent.column()}, path_{path} {} + : JSONParseError{parent.line(), parent.column(), parent.what()}, + path_{path} {} - /// Get the fiel path of the error + /// Get the file path of the error [[nodiscard]] auto path() const noexcept -> const std::filesystem::path { return path_; } diff --git a/vendor/core/src/core/json/include/sourcemeta/core/json_hash.h b/vendor/core/src/core/json/include/sourcemeta/core/json_hash.h index 87d79fd33..14bfe9b35 100644 --- a/vendor/core/src/core/json/include/sourcemeta/core/json_hash.h +++ b/vendor/core/src/core/json/include/sourcemeta/core/json_hash.h @@ -126,10 +126,11 @@ template struct PropertyHashJSON { // This case is specifically designed to be constant with regards to // string length, and to exploit the fact that most JSON objects don't // have a lot of entries, so hash collision is not as common - return {(size + static_cast(value.front()) + + return {1 + + (size + static_cast(value.front()) + static_cast(value.back())) % - // Make sure the property hash can never exceed 8 bits - 256}; + // Make sure the property hash can never exceed 8 bits + 255}; } } diff --git a/vendor/core/src/core/json/include/sourcemeta/core/json_object.h b/vendor/core/src/core/json/include/sourcemeta/core/json_object.h index a068e715b..7885fbdd0 100644 --- a/vendor/core/src/core/json/include/sourcemeta/core/json_object.h +++ b/vendor/core/src/core/json/include/sourcemeta/core/json_object.h @@ -234,6 +234,29 @@ template class FlatMap { return this->data[index]; } + auto rename(const key_type &key, const hash_type key_hash, key_type &&to, + const hash_type to_hash) -> void { + this->erase(to, to_hash); + + if (this->hasher.is_perfect(key_hash)) { + for (auto &entry : this->data) { + if (entry.hash == key_hash) { + entry.first = std::move(to); + entry.hash = to_hash; + break; + } + } + } else { + for (auto &entry : this->data) { + if (entry.hash == key_hash && entry.first == key) { + entry.first = std::move(to); + entry.hash = to_hash; + break; + } + } + } + } + auto erase(const key_type &key, const hash_type key_hash) -> size_type { const auto current_size{this->size()}; diff --git a/vendor/core/src/core/json/include/sourcemeta/core/json_value.h b/vendor/core/src/core/json/include/sourcemeta/core/json_value.h index d597be6a8..96b36dbc5 100644 --- a/vendor/core/src/core/json/include/sourcemeta/core/json_value.h +++ b/vendor/core/src/core/json/include/sourcemeta/core/json_value.h @@ -1461,6 +1461,25 @@ class SOURCEMETA_CORE_JSON_EXPORT JSON { * Transform operations */ + /// This method moves a JSON property value from one property name to another, + /// potentially deleting the destination property name if it already exists. + /// For example: + /// + /// ```cpp + /// #include + /// #include + /// + /// sourcemeta::core::JSON document = + /// sourcemeta::core::parse_json("{ \"foo\": true }"); + /// document.rename("foo", "bar"); + /// + /// assert(!document.defines("foo")); + /// assert(document.defines("bar")); + /// assert(document.at("bar").is_boolean()); + /// assert(document.at("bar").to_boolean()); + /// ``` + auto rename(const JSON::String &key, JSON::String &&to) -> void; + /// This method sets a value to another JSON value by copying it. For example, /// the member of a JSON document can be transformed from a boolean to an /// integer as follows: diff --git a/vendor/core/src/core/json/json.cc b/vendor/core/src/core/json/json.cc index ed50f604e..49ab56aff 100644 --- a/vendor/core/src/core/json/json.cc +++ b/vendor/core/src/core/json/json.cc @@ -43,17 +43,26 @@ auto read_file(const std::filesystem::path &path) std::make_error_code(std::errc::is_a_directory)); } - std::ifstream stream{std::filesystem::canonical(path)}; + std::ifstream stream{ + // On Linux, FIFO files (like /dev/fd/XX due to process substitution) + // cannot be + // made canonical + // See https://github.com/sourcemeta/jsonschema/issues/252 + std::filesystem::is_fifo(path) ? path : std::filesystem::canonical(path)}; stream.exceptions(std::ifstream::failbit | std::ifstream::badbit); assert(!stream.fail()); assert(stream.is_open()); return stream; } -auto read_json(const std::filesystem::path &path) -> JSON { +auto read_json(const std::filesystem::path &path, + const JSON::ParseCallback &callback) -> JSON { auto stream{read_file(path)}; try { - return parse_json(stream); + return parse_json(stream, callback); + } catch (const JSONParseIntegerLimitError &error) { + // For producing better error messages + throw JSONFileParseError(path, error); } catch (const JSONParseError &error) { // For producing better error messages throw JSONFileParseError(path, error); diff --git a/vendor/core/src/core/json/json_value.cc b/vendor/core/src/core/json/json_value.cc index 5ab9bed36..2ae9ca170 100644 --- a/vendor/core/src/core/json/json_value.cc +++ b/vendor/core/src/core/json/json_value.cc @@ -839,6 +839,13 @@ auto JSON::clear_except(std::initializer_list keys) -> void { this->clear_except(keys.begin(), keys.end()); } +auto JSON::rename(const JSON::String &key, JSON::String &&to) -> void { + assert(this->is_object()); + auto &object{this->data_object}; + object.data.rename(key, object.data.hash(key), std::move(to), + object.data.hash(to)); +} + auto JSON::into(const JSON &other) -> void { this->operator=(other); } auto JSON::into(JSON &&other) noexcept -> void { diff --git a/vendor/core/src/core/json/parser.h b/vendor/core/src/core/json/parser.h index c656c5c82..5119b7efd 100644 --- a/vendor/core/src/core/json/parser.h +++ b/vendor/core/src/core/json/parser.h @@ -293,7 +293,7 @@ auto parse_number_integer(const std::uint64_t line, const std::uint64_t column, try { return std::stoll(string); } catch (const std::out_of_range &) { - throw JSONParseError(line, column); + throw JSONParseIntegerLimitError(line, column); } } diff --git a/vendor/core/src/core/json/stringify.h b/vendor/core/src/core/json/stringify.h index fa60df746..161310516 100644 --- a/vendor/core/src/core/json/stringify.h +++ b/vendor/core/src/core/json/stringify.h @@ -13,11 +13,13 @@ #include // std::to_string namespace sourcemeta::core::internal { +constexpr auto LINE_WIDTH{80}; +constexpr auto INDENTATION_MULTIPLIER{2}; template auto indent(std::basic_ostream &stream, const std::size_t indentation) -> void { - constexpr auto multiplier{2}; - for (std::size_t index{0}; index < indentation * multiplier; index++) { + for (std::size_t index{0}; index < indentation * INDENTATION_MULTIPLIER; + index++) { stream.put(internal::token_whitespace_space); } } @@ -454,9 +456,44 @@ template