Skip to content

Commit a9c286b

Browse files
authored
Update flatbuffers to v24.12.23 (#2288)
1 parent 68e375c commit a9c286b

File tree

26 files changed

+317
-249
lines changed

26 files changed

+317
-249
lines changed

3rdparty/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

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

6868
## {fmt}

3rdparty/flatbuffers/base.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@
140140
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
141141

142142
#define FLATBUFFERS_VERSION_MAJOR 24
143-
#define FLATBUFFERS_VERSION_MINOR 3
144-
#define FLATBUFFERS_VERSION_REVISION 25
143+
#define FLATBUFFERS_VERSION_MINOR 12
144+
#define FLATBUFFERS_VERSION_REVISION 23
145145
#define FLATBUFFERS_STRING_EXPAND(X) #X
146146
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
147147
namespace flatbuffers {
@@ -339,15 +339,15 @@ typedef uint16_t voffset_t;
339339
typedef uintmax_t largest_scalar_t;
340340

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

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

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

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

467474
#if defined(FLATBUFFERS_NAN_DEFAULTS) && \
468475
defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)

3rdparty/flatbuffers/detached_buffer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ class DetachedBuffer {
8080

8181
size_t size() const { return size_; }
8282

83+
uint8_t *begin() { return data(); }
84+
const uint8_t *begin() const { return data(); }
85+
uint8_t *end() { return data() + size(); }
86+
const uint8_t *end() const { return data() + size(); }
87+
8388
// These may change access mode, leave these at end of public section
8489
FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer &other));
8590
FLATBUFFERS_DELETE_FUNC(

3rdparty/flatbuffers/flatbuffer_builder.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ inline voffset_t FieldIndexToOffset(voffset_t field_id) {
4747
2 * sizeof(voffset_t); // Vtable size and Object Size.
4848
size_t offset = fixed_fields + field_id * sizeof(voffset_t);
4949
FLATBUFFERS_ASSERT(offset < std::numeric_limits<voffset_t>::max());
50-
return static_cast<voffset_t>(offset);}
50+
return static_cast<voffset_t>(offset);
51+
}
5152

5253
template<typename T, typename Alloc = std::allocator<T>>
5354
const T *data(const std::vector<T, Alloc> &v) {
@@ -241,7 +242,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
241242
/// called.
242243
uint8_t *ReleaseRaw(size_t &size, size_t &offset) {
243244
Finished();
244-
uint8_t* raw = buf_.release_raw(size, offset);
245+
uint8_t *raw = buf_.release_raw(size, offset);
245246
Clear();
246247
return raw;
247248
}
@@ -561,7 +562,7 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
561562
return CreateString<OffsetT>(str.c_str(), str.length());
562563
}
563564

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

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

14761478
} // namespace flatbuffers

3rdparty/flatbuffers/flexbuffers.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ inline void IndentString(std::string &s, int indent,
367367

368368
template<typename T>
369369
void AppendToString(std::string &s, T &&v, bool keys_quoted, bool indented,
370-
int cur_indent, const char *indent_string) {
370+
int cur_indent, const char *indent_string,
371+
bool natural_utf8) {
371372
s += "[";
372373
s += indented ? "\n" : " ";
373374
for (size_t i = 0; i < v.size(); i++) {
@@ -377,7 +378,7 @@ void AppendToString(std::string &s, T &&v, bool keys_quoted, bool indented,
377378
}
378379
if (indented) IndentString(s, cur_indent, indent_string);
379380
v[i].ToString(true, keys_quoted, s, indented, cur_indent,
380-
indent_string);
381+
indent_string, natural_utf8);
381382
}
382383
if (indented) {
383384
s += "\n";
@@ -567,23 +568,24 @@ class Reference {
567568
// string values at the top level receive "" quotes (inside other values
568569
// they always do). keys_quoted determines if keys are quoted, at any level.
569570
void ToString(bool strings_quoted, bool keys_quoted, std::string &s) const {
570-
ToString(strings_quoted, keys_quoted, s, false, 0, "");
571+
ToString(strings_quoted, keys_quoted, s, false, 0, "", false);
571572
}
572573

573574
// This version additionally allow you to specify if you want indentation.
574575
void ToString(bool strings_quoted, bool keys_quoted, std::string &s,
575-
bool indented, int cur_indent, const char *indent_string) const {
576+
bool indented, int cur_indent, const char *indent_string,
577+
bool natural_utf8 = false) const {
576578
if (type_ == FBT_STRING) {
577579
String str(Indirect(), byte_width_);
578580
if (strings_quoted) {
579-
flatbuffers::EscapeString(str.c_str(), str.length(), &s, true, false);
581+
flatbuffers::EscapeString(str.c_str(), str.length(), &s, true, natural_utf8);
580582
} else {
581583
s.append(str.c_str(), str.length());
582584
}
583585
} else if (IsKey()) {
584586
auto str = AsKey();
585587
if (keys_quoted) {
586-
flatbuffers::EscapeString(str, strlen(str), &s, true, false);
588+
flatbuffers::EscapeString(str, strlen(str), &s, true, natural_utf8);
587589
} else {
588590
s += str;
589591
}
@@ -623,7 +625,8 @@ class Reference {
623625
if (indented) IndentString(s, cur_indent + 1, indent_string);
624626
keys[i].ToString(true, kq, s);
625627
s += ": ";
626-
vals[i].ToString(true, keys_quoted, s, indented, cur_indent + 1, indent_string);
628+
vals[i].ToString(true, keys_quoted, s, indented, cur_indent + 1, indent_string,
629+
natural_utf8);
627630
if (i < keys.size() - 1) {
628631
s += ",";
629632
if (!indented) s += " ";
@@ -635,13 +638,15 @@ class Reference {
635638
s += "}";
636639
} else if (IsVector()) {
637640
AppendToString<Vector>(s, AsVector(), keys_quoted, indented,
638-
cur_indent + 1, indent_string);
641+
cur_indent + 1, indent_string, natural_utf8);
639642
} else if (IsTypedVector()) {
640643
AppendToString<TypedVector>(s, AsTypedVector(), keys_quoted, indented,
641-
cur_indent + 1, indent_string);
644+
cur_indent + 1, indent_string,
645+
natural_utf8);
642646
} else if (IsFixedTypedVector()) {
643647
AppendToString<FixedTypedVector>(s, AsFixedTypedVector(), keys_quoted,
644-
indented, cur_indent + 1, indent_string);
648+
indented, cur_indent + 1, indent_string,
649+
natural_utf8);
645650
} else if (IsBlob()) {
646651
auto blob = AsBlob();
647652
flatbuffers::EscapeString(reinterpret_cast<const char *>(blob.data()),

3rdparty/flatbuffers/stl_emulation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ template<class T, class U>
273273
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& lhs, const Optional<U>& rhs) FLATBUFFERS_NOEXCEPT {
274274
return static_cast<bool>(lhs) != static_cast<bool>(rhs)
275275
? false
276-
: !static_cast<bool>(lhs) ? false : (*lhs == *rhs);
276+
: !static_cast<bool>(lhs) ? true : (*lhs == *rhs);
277277
}
278278
#endif // FLATBUFFERS_USE_STD_OPTIONAL
279279

3rdparty/flatbuffers/vector.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,24 @@ struct VectorIterator {
5656
return data_ == other.data_;
5757
}
5858

59+
bool operator!=(const VectorIterator &other) const {
60+
return data_ != other.data_;
61+
}
62+
5963
bool operator<(const VectorIterator &other) const {
6064
return data_ < other.data_;
6165
}
6266

63-
bool operator!=(const VectorIterator &other) const {
64-
return data_ != other.data_;
67+
bool operator>(const VectorIterator &other) const {
68+
return data_ > other.data_;
69+
}
70+
71+
bool operator<=(const VectorIterator &other) const {
72+
return !(data_ > other.data_);
73+
}
74+
75+
bool operator>=(const VectorIterator &other) const {
76+
return !(data_ < other.data_);
6577
}
6678

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

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

178+
// Returns true if the vector is empty.
179+
//
180+
// This just provides another standardized method that is expected of vectors.
181+
bool empty() const { return size() == 0; }
182+
166183
// Deprecated: use size(). Here for backwards compatibility.
167184
FLATBUFFERS_ATTRIBUTE([[deprecated("use size() instead")]])
168185
SizeT Length() const { return size(); }

0 commit comments

Comments
 (0)