Skip to content

Commit

Permalink
Update flatbuffers to v24.12.23 (#2288)
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 authored Dec 25, 2024
1 parent 68e375c commit a9c286b
Show file tree
Hide file tree
Showing 26 changed files with 317 additions and 249 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

## flatbuffers
- [![Upstream](https://img.shields.io/github/v/release/google/flatbuffers?label=Upstream)](https://github.com/google/flatbuffers)
- Version: 24.3.25
- Version: 24.12.23
- License: Apache-2.0

## {fmt}
Expand Down
19 changes: 13 additions & 6 deletions 3rdparty/flatbuffers/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)

#define FLATBUFFERS_VERSION_MAJOR 24
#define FLATBUFFERS_VERSION_MINOR 3
#define FLATBUFFERS_VERSION_REVISION 25
#define FLATBUFFERS_VERSION_MINOR 12
#define FLATBUFFERS_VERSION_REVISION 23
#define FLATBUFFERS_STRING_EXPAND(X) #X
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
namespace flatbuffers {
Expand Down Expand Up @@ -339,15 +339,15 @@ typedef uint16_t voffset_t;
typedef uintmax_t largest_scalar_t;

// In 32bits, this evaluates to 2GB - 1
#define FLATBUFFERS_MAX_BUFFER_SIZE std::numeric_limits<::flatbuffers::soffset_t>::max()
#define FLATBUFFERS_MAX_64_BUFFER_SIZE std::numeric_limits<::flatbuffers::soffset64_t>::max()
#define FLATBUFFERS_MAX_BUFFER_SIZE (std::numeric_limits<::flatbuffers::soffset_t>::max)()
#define FLATBUFFERS_MAX_64_BUFFER_SIZE (std::numeric_limits<::flatbuffers::soffset64_t>::max)()

// The minimum size buffer that can be a valid flatbuffer.
// Includes the offset to the root table (uoffset_t), the offset to the vtable
// of the root table (soffset_t), the size of the vtable (uint16_t), and the
// size of the referring table (uint16_t).
#define FLATBUFFERS_MIN_BUFFER_SIZE sizeof(uoffset_t) + sizeof(soffset_t) + \
sizeof(uint16_t) + sizeof(uint16_t)
#define FLATBUFFERS_MIN_BUFFER_SIZE sizeof(::flatbuffers::uoffset_t) + \
sizeof(::flatbuffers::soffset_t) + sizeof(uint16_t) + sizeof(uint16_t)

// We support aligning the contents of buffers up to this size.
#ifndef FLATBUFFERS_MAX_ALIGNMENT
Expand Down Expand Up @@ -459,10 +459,17 @@ inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) {
return ((~buf_size) + 1) & (scalar_size - 1);
}

#if !defined(_MSC_VER)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
// Generic 'operator==' with conditional specialisations.
// T e - new value of a scalar field.
// T def - default of scalar (is known at compile-time).
template<typename T> inline bool IsTheSameAs(T e, T def) { return e == def; }
#if !defined(_MSC_VER)
#pragma GCC diagnostic pop
#endif

#if defined(FLATBUFFERS_NAN_DEFAULTS) && \
defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
Expand Down
5 changes: 5 additions & 0 deletions 3rdparty/flatbuffers/detached_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class DetachedBuffer {

size_t size() const { return size_; }

uint8_t *begin() { return data(); }
const uint8_t *begin() const { return data(); }
uint8_t *end() { return data() + size(); }
const uint8_t *end() const { return data() + size(); }

// These may change access mode, leave these at end of public section
FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer &other));
FLATBUFFERS_DELETE_FUNC(
Expand Down
12 changes: 7 additions & 5 deletions 3rdparty/flatbuffers/flatbuffer_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ inline voffset_t FieldIndexToOffset(voffset_t field_id) {
2 * sizeof(voffset_t); // Vtable size and Object Size.
size_t offset = fixed_fields + field_id * sizeof(voffset_t);
FLATBUFFERS_ASSERT(offset < std::numeric_limits<voffset_t>::max());
return static_cast<voffset_t>(offset);}
return static_cast<voffset_t>(offset);
}

template<typename T, typename Alloc = std::allocator<T>>
const T *data(const std::vector<T, Alloc> &v) {
Expand Down Expand Up @@ -241,7 +242,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
/// called.
uint8_t *ReleaseRaw(size_t &size, size_t &offset) {
Finished();
uint8_t* raw = buf_.release_raw(size, offset);
uint8_t *raw = buf_.release_raw(size, offset);
Clear();
return raw;
}
Expand Down Expand Up @@ -561,7 +562,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
return CreateString<OffsetT>(str.c_str(), str.length());
}

// clang-format off
// clang-format off
#ifdef FLATBUFFERS_HAS_STRING_VIEW
/// @brief Store a string in the buffer, which can contain any binary data.
/// @param[in] str A const string_view to copy in to the buffer.
Expand Down Expand Up @@ -743,7 +744,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
AssertScalarT<T>();
StartVector<T, OffsetT, LenT>(len);
if (len > 0) {
// clang-format off
// clang-format off
#if FLATBUFFERS_LITTLEENDIAN
PushBytes(reinterpret_cast<const uint8_t *>(v), len * sizeof(T));
#else
Expand Down Expand Up @@ -1470,7 +1471,8 @@ T *GetMutableTemporaryPointer(FlatBufferBuilder &fbb, Offset<T> offset) {

template<typename T>
const T *GetTemporaryPointer(const FlatBufferBuilder &fbb, Offset<T> offset) {
return GetMutableTemporaryPointer<T>(fbb, offset);
return reinterpret_cast<const T *>(fbb.GetCurrentBufferPointer() +
fbb.GetSize() - offset.o);
}

} // namespace flatbuffers
Expand Down
25 changes: 15 additions & 10 deletions 3rdparty/flatbuffers/flexbuffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ inline void IndentString(std::string &s, int indent,

template<typename T>
void AppendToString(std::string &s, T &&v, bool keys_quoted, bool indented,
int cur_indent, const char *indent_string) {
int cur_indent, const char *indent_string,
bool natural_utf8) {
s += "[";
s += indented ? "\n" : " ";
for (size_t i = 0; i < v.size(); i++) {
Expand All @@ -377,7 +378,7 @@ void AppendToString(std::string &s, T &&v, bool keys_quoted, bool indented,
}
if (indented) IndentString(s, cur_indent, indent_string);
v[i].ToString(true, keys_quoted, s, indented, cur_indent,
indent_string);
indent_string, natural_utf8);
}
if (indented) {
s += "\n";
Expand Down Expand Up @@ -567,23 +568,24 @@ class Reference {
// string values at the top level receive "" quotes (inside other values
// they always do). keys_quoted determines if keys are quoted, at any level.
void ToString(bool strings_quoted, bool keys_quoted, std::string &s) const {
ToString(strings_quoted, keys_quoted, s, false, 0, "");
ToString(strings_quoted, keys_quoted, s, false, 0, "", false);
}

// This version additionally allow you to specify if you want indentation.
void ToString(bool strings_quoted, bool keys_quoted, std::string &s,
bool indented, int cur_indent, const char *indent_string) const {
bool indented, int cur_indent, const char *indent_string,
bool natural_utf8 = false) const {
if (type_ == FBT_STRING) {
String str(Indirect(), byte_width_);
if (strings_quoted) {
flatbuffers::EscapeString(str.c_str(), str.length(), &s, true, false);
flatbuffers::EscapeString(str.c_str(), str.length(), &s, true, natural_utf8);
} else {
s.append(str.c_str(), str.length());
}
} else if (IsKey()) {
auto str = AsKey();
if (keys_quoted) {
flatbuffers::EscapeString(str, strlen(str), &s, true, false);
flatbuffers::EscapeString(str, strlen(str), &s, true, natural_utf8);
} else {
s += str;
}
Expand Down Expand Up @@ -623,7 +625,8 @@ class Reference {
if (indented) IndentString(s, cur_indent + 1, indent_string);
keys[i].ToString(true, kq, s);
s += ": ";
vals[i].ToString(true, keys_quoted, s, indented, cur_indent + 1, indent_string);
vals[i].ToString(true, keys_quoted, s, indented, cur_indent + 1, indent_string,
natural_utf8);
if (i < keys.size() - 1) {
s += ",";
if (!indented) s += " ";
Expand All @@ -635,13 +638,15 @@ class Reference {
s += "}";
} else if (IsVector()) {
AppendToString<Vector>(s, AsVector(), keys_quoted, indented,
cur_indent + 1, indent_string);
cur_indent + 1, indent_string, natural_utf8);
} else if (IsTypedVector()) {
AppendToString<TypedVector>(s, AsTypedVector(), keys_quoted, indented,
cur_indent + 1, indent_string);
cur_indent + 1, indent_string,
natural_utf8);
} else if (IsFixedTypedVector()) {
AppendToString<FixedTypedVector>(s, AsFixedTypedVector(), keys_quoted,
indented, cur_indent + 1, indent_string);
indented, cur_indent + 1, indent_string,
natural_utf8);
} else if (IsBlob()) {
auto blob = AsBlob();
flatbuffers::EscapeString(reinterpret_cast<const char *>(blob.data()),
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/flatbuffers/stl_emulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ template<class T, class U>
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& lhs, const Optional<U>& rhs) FLATBUFFERS_NOEXCEPT {
return static_cast<bool>(lhs) != static_cast<bool>(rhs)
? false
: !static_cast<bool>(lhs) ? false : (*lhs == *rhs);
: !static_cast<bool>(lhs) ? true : (*lhs == *rhs);
}
#endif // FLATBUFFERS_USE_STD_OPTIONAL

Expand Down
21 changes: 19 additions & 2 deletions 3rdparty/flatbuffers/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,24 @@ struct VectorIterator {
return data_ == other.data_;
}

bool operator!=(const VectorIterator &other) const {
return data_ != other.data_;
}

bool operator<(const VectorIterator &other) const {
return data_ < other.data_;
}

bool operator!=(const VectorIterator &other) const {
return data_ != other.data_;
bool operator>(const VectorIterator &other) const {
return data_ > other.data_;
}

bool operator<=(const VectorIterator &other) const {
return !(data_ > other.data_);
}

bool operator>=(const VectorIterator &other) const {
return !(data_ < other.data_);
}

difference_type operator-(const VectorIterator &other) const {
Expand Down Expand Up @@ -163,6 +175,11 @@ template<typename T, typename SizeT = uoffset_t> class Vector {

SizeT size() const { return EndianScalar(length_); }

// Returns true if the vector is empty.
//
// This just provides another standardized method that is expected of vectors.
bool empty() const { return size() == 0; }

// Deprecated: use size(). Here for backwards compatibility.
FLATBUFFERS_ATTRIBUTE([[deprecated("use size() instead")]])
SizeT Length() const { return size(); }
Expand Down
Loading

0 comments on commit a9c286b

Please sign in to comment.