-
Notifications
You must be signed in to change notification settings - Fork 7
Upgrade Core to aa314809fdb59ed6fcb1b10b3087f32eebf708c5
#912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02 | ||
| core https://github.com/sourcemeta/core 3ea3a54756071232ca017b96bc15f17d8b5be370 | ||
| blaze https://github.com/sourcemeta/blaze 0ff98cb5e537f571bdf04f0d59a031a0d8634e07 | ||
| core https://github.com/sourcemeta/core aa314809fdb59ed6fcb1b10b3087f32eebf708c5 | ||
| blaze https://github.com/sourcemeta/blaze 5554d3106d7920b28b852e929f0a31d7805effe1 | ||
| bootstrap https://github.com/twbs/bootstrap 1a6fdfae6be09b09eaced8f0e442ca6f7680a61e |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,25 +2,14 @@ | |
|
|
||
| #include <sourcemeta/core/numeric.h> | ||
|
|
||
| #include "varint.h" | ||
|
|
||
| #include <cassert> // assert | ||
| #include <ios> // std::ios_base | ||
| #include <cstddef> // std::size_t | ||
| #include <cstdint> // std::uint8_t, std::uint64_t, std::int64_t | ||
|
|
||
| namespace sourcemeta::jsonbinpack { | ||
|
|
||
| InputStream::InputStream(Stream &input) : stream{input} { | ||
| this->stream.exceptions(std::ios_base::badbit | std::ios_base::failbit | | ||
| std::ios_base::eofbit); | ||
| } | ||
|
|
||
| auto InputStream::position() const noexcept -> std::uint64_t { | ||
| return static_cast<std::uint64_t>(this->stream.tellg()); | ||
| } | ||
|
|
||
| auto InputStream::seek(const std::uint64_t offset) -> void { | ||
| this->stream.seekg(static_cast<std::streamoff>(offset)); | ||
| } | ||
| InputStream::InputStream(Stream &input) | ||
| : sourcemeta::core::BinaryReader{input} {} | ||
|
|
||
| auto InputStream::rewind(const std::uint64_t relative_offset, | ||
| const std::uint64_t position) -> std::uint64_t { | ||
|
|
@@ -32,33 +21,33 @@ auto InputStream::rewind(const std::uint64_t relative_offset, | |
| return current; | ||
| } | ||
|
|
||
| auto InputStream::get_byte() -> std::uint8_t { | ||
| return static_cast<std::uint8_t>(this->stream.get()); | ||
| } | ||
|
|
||
| auto InputStream::get_word() -> std::uint16_t { | ||
| std::uint16_t word; | ||
| this->stream.read(reinterpret_cast<char *>(&word), sizeof word); | ||
| return word; | ||
| } | ||
|
|
||
| auto InputStream::get_varint() -> std::uint64_t { | ||
| return varint_decode(this->stream); | ||
| } | ||
| constexpr std::uint8_t LEAST_SIGNIFICANT_BITS{0b01111111}; | ||
| constexpr std::uint8_t MOST_SIGNIFICANT_BIT{0b10000000}; | ||
| constexpr std::uint8_t SHIFT{7}; | ||
| std::uint64_t result{0}; | ||
| std::size_t cursor{0}; | ||
| while (true) { | ||
| const std::uint8_t byte{this->get_byte()}; | ||
| const std::uint64_t value{ | ||
| static_cast<std::uint64_t>(byte & LEAST_SIGNIFICANT_BITS)}; | ||
| #ifndef NDEBUG | ||
| const std::uint64_t current = result; | ||
| #endif | ||
| result += static_cast<std::uint64_t>(value << SHIFT * cursor); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Severity: medium 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| // Try to catch potential overflows from the above addition | ||
| assert(result >= current); | ||
| cursor += 1; | ||
| if ((byte & MOST_SIGNIFICANT_BIT) == 0) { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| auto InputStream::get_varint_zigzag() -> std::int64_t { | ||
| const std::uint64_t value = varint_decode(this->stream); | ||
| return sourcemeta::core::zigzag_decode(value); | ||
| return result; | ||
| } | ||
|
|
||
| auto InputStream::has_more_data() const noexcept -> bool { | ||
| // A way to check if the stream is empty without using `.peek()`, | ||
| // which throws given we set exceptions on the EOF bit. | ||
| // However, `in_avail()` works on characters and will return zero | ||
| // if all that's remaining is 0x00 (null), so we need to handle | ||
| // that case separately. | ||
| return this->stream.rdbuf()->in_avail() > 0 || | ||
| this->stream.rdbuf()->sgetc() == '\0'; | ||
| auto InputStream::get_varint_zigzag() -> std::int64_t { | ||
| return sourcemeta::core::zigzag_decode(this->get_varint()); | ||
| } | ||
|
|
||
| auto InputStream::get_string_utf8(const std::uint64_t length) | ||
|
|
||
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Runtime now links against
sourcemeta::core::io, butconfig.cmake.instill callsfind_dependency(Core COMPONENTS ...)withoutio, which can break consumers usingfind_package(JSONBinPack). Consider adding the Coreiocomponent there to match the runtime target’s transitive requirements.Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.