Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
core https://github.com/sourcemeta/core 0836d83873a0328b5a1a25848f29bdb8253734c0
core https://github.com/sourcemeta/core 90d0082e6c61ed5f6f3106db4105c7822cc41838
bootstrap https://github.com/twbs/bootstrap 1a6fdfae6be09b09eaced8f0e442ca6f7680a61e
8 changes: 4 additions & 4 deletions src/compiler/include/sourcemeta/jsonbinpack/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace sourcemeta::jsonbinpack {
/// })JSON")};
///
/// sourcemeta::jsonbinpack::compile(
/// schema, sourcemeta::core::schema_official_walker,
/// sourcemeta::core::schema_official_resolver);
/// schema, sourcemeta::core::schema_walker,
/// sourcemeta::core::schema_resolver);
///
/// sourcemeta::core::prettify(schema, std::cout);
/// std::cout << std::endl;
Expand Down Expand Up @@ -73,8 +73,8 @@ auto compile(sourcemeta::core::JSON &schema,
/// })JSON")};
///
/// sourcemeta::jsonbinpack::canonicalize(
/// schema, sourcemeta::core::schema_official_walker,
/// sourcemeta::core::schema_official_resolver);
/// schema, sourcemeta::core::schema_walker,
/// sourcemeta::core::schema_resolver);
///
/// sourcemeta::core::prettify(schema, std::cout);
/// std::cout << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/include/sourcemeta/jsonbinpack/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SOURCEMETA_JSONBINPACK_RUNTIME_EXPORT EncodingError
}

private:
const sourcemeta::core::JSON::String message_;
sourcemeta::core::JSON::String message_;
};

#if defined(_MSC_VER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ namespace sourcemeta::jsonbinpack {

class SOURCEMETA_JSONBINPACK_RUNTIME_EXPORT Cache {
public:
enum class Type { Standalone, PrefixLengthVarintPlusOne };
enum class Type : std::uint8_t { Standalone, PrefixLengthVarintPlusOne };
auto record(const sourcemeta::core::JSON::String &value,
const std::uint64_t offset, const Type type) -> void;
auto find(const sourcemeta::core::JSON::String &value, const Type type) const
[[nodiscard]] auto find(const sourcemeta::core::JSON::String &value,
const Type type) const
-> std::optional<std::uint64_t>;

#ifndef DOXYGEN
Expand Down
70 changes: 35 additions & 35 deletions src/runtime/include/sourcemeta/jsonbinpack/runtime_encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ using Encoding = std::variant<
// clang-format on
struct BOUNDED_MULTIPLE_8BITS_ENUM_FIXED {
/// The inclusive minimum value
const std::int64_t minimum;
std::int64_t minimum;
/// The inclusive maximum value
const std::int64_t maximum;
std::int64_t maximum;
/// The multiplier value
const std::uint64_t multiplier;
std::uint64_t multiplier;
};

// clang-format off
Expand Down Expand Up @@ -133,9 +133,9 @@ struct BOUNDED_MULTIPLE_8BITS_ENUM_FIXED {
// clang-format on
struct FLOOR_MULTIPLE_ENUM_VARINT {
/// The inclusive minimum value
const std::int64_t minimum;
std::int64_t minimum;
/// The multiplier value
const std::uint64_t multiplier;
std::uint64_t multiplier;
};

// clang-format off
Expand Down Expand Up @@ -171,9 +171,9 @@ struct FLOOR_MULTIPLE_ENUM_VARINT {
// clang-format on
struct ROOF_MULTIPLE_MIRROR_ENUM_VARINT {
/// The inclusive maximum value
const std::int64_t maximum;
std::int64_t maximum;
/// The multiplier value
const std::uint64_t multiplier;
std::uint64_t multiplier;
};

// clang-format off
Expand Down Expand Up @@ -206,7 +206,7 @@ struct ROOF_MULTIPLE_MIRROR_ENUM_VARINT {
// clang-format on
struct ARBITRARY_MULTIPLE_ZIGZAG_VARINT {
/// The multiplier value
const std::uint64_t multiplier;
std::uint64_t multiplier;
};

/// @}
Expand Down Expand Up @@ -302,7 +302,7 @@ struct DOUBLE_VARINT_TUPLE {};
// clang-format on
struct BYTE_CHOICE_INDEX {
/// The set of choice values
const std::vector<sourcemeta::core::JSON> choices;
std::vector<sourcemeta::core::JSON> choices;
};

// clang-format off
Expand Down Expand Up @@ -336,7 +336,7 @@ struct BYTE_CHOICE_INDEX {
// clang-format on
struct LARGE_CHOICE_INDEX {
/// The set of choice values
const std::vector<sourcemeta::core::JSON> choices;
std::vector<sourcemeta::core::JSON> choices;
};

// clang-format off
Expand Down Expand Up @@ -375,7 +375,7 @@ struct LARGE_CHOICE_INDEX {
// clang-format on
struct TOP_LEVEL_BYTE_CHOICE_INDEX {
/// The set of choice values
const std::vector<sourcemeta::core::JSON> choices;
std::vector<sourcemeta::core::JSON> choices;
};

// clang-format off
Expand All @@ -397,7 +397,7 @@ struct TOP_LEVEL_BYTE_CHOICE_INDEX {
// clang-format on
struct CONST_NONE {
/// The constant value
const sourcemeta::core::JSON value;
sourcemeta::core::JSON value;
};

// TODO: Write brief description
Expand Down Expand Up @@ -490,7 +490,7 @@ static_assert(SUBTYPE_LONG_STRING_BASE_EXPONENT_10 == 10);
// clang-format on
struct UTF8_STRING_NO_LENGTH {
/// The string UTF-8 byte-length
const std::uint64_t size;
std::uint64_t size;
};

// clang-format off
Expand Down Expand Up @@ -544,7 +544,7 @@ struct UTF8_STRING_NO_LENGTH {
// clang-format on
struct FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED {
/// The inclusive minimum string UTF-8 byte-length
const std::uint64_t minimum;
std::uint64_t minimum;
};

// clang-format off
Expand Down Expand Up @@ -598,7 +598,7 @@ struct FLOOR_VARINT_PREFIX_UTF8_STRING_SHARED {
// clang-format on
struct ROOF_VARINT_PREFIX_UTF8_STRING_SHARED {
/// The inclusive maximum string UTF-8 byte-length
const std::uint64_t maximum;
std::uint64_t maximum;
};

// clang-format off
Expand Down Expand Up @@ -658,9 +658,9 @@ struct ROOF_VARINT_PREFIX_UTF8_STRING_SHARED {
// clang-format on
struct BOUNDED_8BIT_PREFIX_UTF8_STRING_SHARED {
/// The inclusive minimum string UTF-8 byte-length
const std::uint64_t minimum;
std::uint64_t minimum;
/// The inclusive maximum string UTF-8 byte-length
const std::uint64_t maximum;
std::uint64_t maximum;
};

// clang-format off
Expand Down Expand Up @@ -789,11 +789,11 @@ struct PREFIX_VARINT_LENGTH_STRING_SHARED {};
// clang-format on
struct FIXED_TYPED_ARRAY {
/// The array length
const std::uint64_t size;
std::uint64_t size;
/// Element encoding
const std::shared_ptr<Encoding> encoding;
std::shared_ptr<Encoding> encoding;
/// Positional encodings
const std::vector<Encoding> prefix_encodings;
std::vector<Encoding> prefix_encodings;
};

// clang-format off
Expand Down Expand Up @@ -838,13 +838,13 @@ struct FIXED_TYPED_ARRAY {
// clang-format on
struct BOUNDED_8BITS_TYPED_ARRAY {
/// The minimum length of the array
const std::uint64_t minimum;
std::uint64_t minimum;
/// The maximum length of the array
const std::uint64_t maximum;
std::uint64_t maximum;
/// Element encoding
const std::shared_ptr<Encoding> encoding;
std::shared_ptr<Encoding> encoding;
/// Positional encodings
const std::vector<Encoding> prefix_encodings;
std::vector<Encoding> prefix_encodings;
};

// clang-format off
Expand Down Expand Up @@ -886,11 +886,11 @@ struct BOUNDED_8BITS_TYPED_ARRAY {
// clang-format on
struct FLOOR_TYPED_ARRAY {
/// The minimum length of the array
const std::uint64_t minimum;
std::uint64_t minimum;
/// Element encoding
const std::shared_ptr<Encoding> encoding;
std::shared_ptr<Encoding> encoding;
/// Positional encodings
const std::vector<Encoding> prefix_encodings;
std::vector<Encoding> prefix_encodings;
};

// clang-format off
Expand Down Expand Up @@ -931,11 +931,11 @@ struct FLOOR_TYPED_ARRAY {
// clang-format on
struct ROOF_TYPED_ARRAY {
/// The maximum length of the array
const std::uint64_t maximum;
std::uint64_t maximum;
/// Element encoding
const std::shared_ptr<Encoding> encoding;
std::shared_ptr<Encoding> encoding;
/// Positional encodings
const std::vector<Encoding> prefix_encodings;
std::vector<Encoding> prefix_encodings;
};

/// @}
Expand Down Expand Up @@ -988,11 +988,11 @@ struct ROOF_TYPED_ARRAY {
// clang-format on
struct FIXED_TYPED_ARBITRARY_OBJECT {
/// The object size
const std::uint64_t size;
std::uint64_t size;
/// Key encoding
const std::shared_ptr<Encoding> key_encoding;
std::shared_ptr<Encoding> key_encoding;
/// Value encoding
const std::shared_ptr<Encoding> encoding;
std::shared_ptr<Encoding> encoding;
};

// clang-format off
Expand Down Expand Up @@ -1034,9 +1034,9 @@ struct FIXED_TYPED_ARBITRARY_OBJECT {
// clang-format on
struct VARINT_TYPED_ARBITRARY_OBJECT {
/// Key encoding
const std::shared_ptr<Encoding> key_encoding;
std::shared_ptr<Encoding> key_encoding;
/// Value encoding
const std::shared_ptr<Encoding> encoding;
std::shared_ptr<Encoding> encoding;
};

/// @}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SOURCEMETA_JSONBINPACK_RUNTIME_EXPORT InputStream {
InputStream(const InputStream &) = delete;
auto operator=(const InputStream &) -> InputStream & = delete;

auto position() const noexcept -> std::uint64_t;
[[nodiscard]] auto position() const noexcept -> std::uint64_t;
auto seek(const std::uint64_t offset) -> void;
// Seek backwards given a relative offset
auto rewind(const std::uint64_t relative_offset, const std::uint64_t position)
Expand All @@ -33,7 +33,7 @@ class SOURCEMETA_JSONBINPACK_RUNTIME_EXPORT InputStream {
auto get_word() -> std::uint16_t;
auto get_varint() -> std::uint64_t;
auto get_varint_zigzag() -> std::int64_t;
auto has_more_data() const noexcept -> bool;
[[nodiscard]] auto has_more_data() const noexcept -> bool;
auto get_string_utf8(const std::uint64_t length)
-> sourcemeta::core::JSON::String;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SOURCEMETA_JSONBINPACK_RUNTIME_EXPORT OutputStream {
OutputStream(const OutputStream &) = delete;
auto operator=(const OutputStream &) -> OutputStream & = delete;

auto position() const noexcept -> std::uint64_t;
[[nodiscard]] auto position() const noexcept -> std::uint64_t;
auto put_byte(const std::uint8_t byte) -> void;
auto put_bytes(const std::uint16_t bytes) -> void;
auto put_varint(const std::uint64_t value) -> void;
Expand Down
12 changes: 7 additions & 5 deletions src/runtime/loader_v1_any.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ auto BYTE_CHOICE_INDEX(const sourcemeta::core::JSON &options) -> Encoding {
assert(choices.is_array());
const auto &array{choices.as_array()};
std::vector<sourcemeta::core::JSON> elements{array.cbegin(), array.cend()};
return sourcemeta::jsonbinpack::BYTE_CHOICE_INDEX({std::move(elements)});
return sourcemeta::jsonbinpack::BYTE_CHOICE_INDEX{.choices =
std::move(elements)};
}

auto LARGE_CHOICE_INDEX(const sourcemeta::core::JSON &options) -> Encoding {
Expand All @@ -26,7 +27,8 @@ auto LARGE_CHOICE_INDEX(const sourcemeta::core::JSON &options) -> Encoding {
assert(choices.is_array());
const auto &array{choices.as_array()};
std::vector<sourcemeta::core::JSON> elements{array.cbegin(), array.cend()};
return sourcemeta::jsonbinpack::LARGE_CHOICE_INDEX({std::move(elements)});
return sourcemeta::jsonbinpack::LARGE_CHOICE_INDEX{.choices =
std::move(elements)};
}

auto TOP_LEVEL_BYTE_CHOICE_INDEX(const sourcemeta::core::JSON &options)
Expand All @@ -36,13 +38,13 @@ auto TOP_LEVEL_BYTE_CHOICE_INDEX(const sourcemeta::core::JSON &options)
assert(choices.is_array());
const auto &array{choices.as_array()};
std::vector<sourcemeta::core::JSON> elements{array.cbegin(), array.cend()};
return sourcemeta::jsonbinpack::TOP_LEVEL_BYTE_CHOICE_INDEX(
{std::move(elements)});
return sourcemeta::jsonbinpack::TOP_LEVEL_BYTE_CHOICE_INDEX{
.choices = std::move(elements)};
}

auto CONST_NONE(const sourcemeta::core::JSON &options) -> Encoding {
assert(options.defines("value"));
return sourcemeta::jsonbinpack::CONST_NONE({options.at("value")});
return sourcemeta::jsonbinpack::CONST_NONE{.value = options.at("value")};
}

auto ANY_PACKED_TYPE_TAG_BYTE_PREFIX(const sourcemeta::core::JSON &)
Expand Down
22 changes: 13 additions & 9 deletions src/runtime/loader_v1_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ auto FIXED_TYPED_ARRAY(const sourcemeta::core::JSON &options) -> Encoding {
[](const auto &element) { return load(element); });
assert(encodings.size() == prefix_encodings.size());
return sourcemeta::jsonbinpack::FIXED_TYPED_ARRAY{
static_cast<std::uint64_t>(size.to_integer()),
std::make_shared<Encoding>(load(array_encoding)), std::move(encodings)};
.size = static_cast<std::uint64_t>(size.to_integer()),
.encoding = std::make_shared<Encoding>(load(array_encoding)),
.prefix_encodings = std::move(encodings)};
}

auto BOUNDED_8BITS_TYPED_ARRAY(const sourcemeta::core::JSON &options)
Expand All @@ -59,9 +60,10 @@ auto BOUNDED_8BITS_TYPED_ARRAY(const sourcemeta::core::JSON &options)
[](const auto &element) { return load(element); });
assert(encodings.size() == prefix_encodings.size());
return sourcemeta::jsonbinpack::BOUNDED_8BITS_TYPED_ARRAY{
static_cast<std::uint64_t>(minimum.to_integer()),
static_cast<std::uint64_t>(maximum.to_integer()),
std::make_shared<Encoding>(load(array_encoding)), std::move(encodings)};
.minimum = static_cast<std::uint64_t>(minimum.to_integer()),
.maximum = static_cast<std::uint64_t>(maximum.to_integer()),
.encoding = std::make_shared<Encoding>(load(array_encoding)),
.prefix_encodings = std::move(encodings)};
}

auto FLOOR_TYPED_ARRAY(const sourcemeta::core::JSON &options) -> Encoding {
Expand All @@ -82,8 +84,9 @@ auto FLOOR_TYPED_ARRAY(const sourcemeta::core::JSON &options) -> Encoding {
[](const auto &element) { return load(element); });
assert(encodings.size() == prefix_encodings.size());
return sourcemeta::jsonbinpack::FLOOR_TYPED_ARRAY{
static_cast<std::uint64_t>(minimum.to_integer()),
std::make_shared<Encoding>(load(array_encoding)), std::move(encodings)};
.minimum = static_cast<std::uint64_t>(minimum.to_integer()),
.encoding = std::make_shared<Encoding>(load(array_encoding)),
.prefix_encodings = std::move(encodings)};
}

auto ROOF_TYPED_ARRAY(const sourcemeta::core::JSON &options) -> Encoding {
Expand All @@ -104,8 +107,9 @@ auto ROOF_TYPED_ARRAY(const sourcemeta::core::JSON &options) -> Encoding {
[](const auto &element) { return load(element); });
assert(encodings.size() == prefix_encodings.size());
return sourcemeta::jsonbinpack::ROOF_TYPED_ARRAY{
static_cast<std::uint64_t>(maximum.to_integer()),
std::make_shared<Encoding>(load(array_encoding)), std::move(encodings)};
.maximum = static_cast<std::uint64_t>(maximum.to_integer()),
.encoding = std::make_shared<Encoding>(load(array_encoding)),
.prefix_encodings = std::move(encodings)};
}

} // namespace sourcemeta::jsonbinpack::v1
Expand Down
Loading