Skip to content

Commit a129169

Browse files
committed
remove flatbuffers from public API and old file_logger
1 parent 26366ac commit a129169

File tree

10 files changed

+99
-5456
lines changed

10 files changed

+99
-5456
lines changed

include/behaviortree_cpp/flatbuffers/base.h renamed to 3rdparty/flatbuffers/base.h

Lines changed: 94 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <cstdlib>
3333
#include <cstring>
3434

35-
#if defined(ARDUINO) && !defined(ARDUINOSTL_M_H)
35+
#if defined(ARDUINO) && !defined(ARDUINOSTL_M_H) && defined(__AVR__)
3636
#include <utility.h>
3737
#else
3838
#include <utility>
@@ -43,17 +43,14 @@
4343
#include <vector>
4444
#include <set>
4545
#include <algorithm>
46+
#include <limits>
4647
#include <iterator>
4748
#include <memory>
4849

4950
#if defined(__unix__) && !defined(FLATBUFFERS_LOCALE_INDEPENDENT)
5051
#include <unistd.h>
5152
#endif
5253

53-
#ifdef _STLPORT_VERSION
54-
#define FLATBUFFERS_CPP98_STL
55-
#endif
56-
5754
#ifdef __ANDROID__
5855
#include <android/api-level.h>
5956
#endif
@@ -142,9 +139,9 @@
142139
#endif
143140
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
144141

145-
#define FLATBUFFERS_VERSION_MAJOR 1
146-
#define FLATBUFFERS_VERSION_MINOR 12
147-
#define FLATBUFFERS_VERSION_REVISION 0
142+
#define FLATBUFFERS_VERSION_MAJOR 24
143+
#define FLATBUFFERS_VERSION_MINOR 3
144+
#define FLATBUFFERS_VERSION_REVISION 25
148145
#define FLATBUFFERS_STRING_EXPAND(X) #X
149146
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
150147
namespace flatbuffers {
@@ -158,7 +155,7 @@ namespace flatbuffers {
158155
#define FLATBUFFERS_FINAL_CLASS final
159156
#define FLATBUFFERS_OVERRIDE override
160157
#define FLATBUFFERS_EXPLICIT_CPP11 explicit
161-
#define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : flatbuffers::voffset_t
158+
#define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : ::flatbuffers::voffset_t
162159
#else
163160
#define FLATBUFFERS_FINAL_CLASS
164161
#define FLATBUFFERS_OVERRIDE
@@ -237,16 +234,26 @@ namespace flatbuffers {
237234
}
238235
#define FLATBUFFERS_HAS_STRING_VIEW 1
239236
// Check for absl::string_view
240-
#elif __has_include("absl/strings/string_view.h")
241-
#include "absl/strings/string_view.h"
242-
namespace flatbuffers {
243-
typedef absl::string_view string_view;
244-
}
245-
#define FLATBUFFERS_HAS_STRING_VIEW 1
237+
#elif __has_include("absl/strings/string_view.h") && \
238+
__has_include("absl/base/config.h") && \
239+
(__cplusplus >= 201411)
240+
#include "absl/base/config.h"
241+
#if !defined(ABSL_USES_STD_STRING_VIEW)
242+
#include "absl/strings/string_view.h"
243+
namespace flatbuffers {
244+
typedef absl::string_view string_view;
245+
}
246+
#define FLATBUFFERS_HAS_STRING_VIEW 1
247+
#endif
246248
#endif
247249
#endif // __has_include
248250
#endif // !FLATBUFFERS_HAS_STRING_VIEW
249251

252+
#ifndef FLATBUFFERS_GENERAL_HEAP_ALLOC_OK
253+
// Allow heap allocations to be used
254+
#define FLATBUFFERS_GENERAL_HEAP_ALLOC_OK 1
255+
#endif // !FLATBUFFERS_GENERAL_HEAP_ALLOC_OK
256+
250257
#ifndef FLATBUFFERS_HAS_NEW_STRTOD
251258
// Modern (C++11) strtod and strtof functions are available for use.
252259
// 1) nan/inf strings as argument of strtod;
@@ -259,37 +266,42 @@ namespace flatbuffers {
259266
#endif // !FLATBUFFERS_HAS_NEW_STRTOD
260267

261268
#ifndef FLATBUFFERS_LOCALE_INDEPENDENT
262-
// Enable locale independent functions {strtof_l, strtod_l,strtoll_l, strtoull_l}.
263-
#if ((defined(_MSC_VER) && _MSC_VER >= 1800) || \
264-
(defined(_XOPEN_VERSION) && (_XOPEN_VERSION>=700)) && (!defined(__ANDROID_API__) || (defined(__ANDROID_API__) && (__ANDROID_API__>=21))))
269+
// Enable locale independent functions {strtof_l, strtod_l,strtoll_l,
270+
// strtoull_l}.
271+
#if (defined(_MSC_VER) && _MSC_VER >= 1800) || \
272+
(defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \
273+
(defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \
274+
(!defined(__Fuchsia__) && !defined(__ANDROID_API__))
265275
#define FLATBUFFERS_LOCALE_INDEPENDENT 1
266276
#else
267277
#define FLATBUFFERS_LOCALE_INDEPENDENT 0
268278
#endif
269279
#endif // !FLATBUFFERS_LOCALE_INDEPENDENT
270280

271281
// Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
272-
// - __supress_ubsan__("undefined")
273-
// - __supress_ubsan__("signed-integer-overflow")
282+
// - FLATBUFFERS_SUPPRESS_UBSAN("undefined")
283+
// - FLATBUFFERS_SUPPRESS_UBSAN("signed-integer-overflow")
274284
#if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
275-
#define __supress_ubsan__(type) __attribute__((no_sanitize(type)))
285+
#define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize(type)))
276286
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
277-
#define __supress_ubsan__(type) __attribute__((no_sanitize_undefined))
287+
#define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize_undefined))
278288
#else
279-
#define __supress_ubsan__(type)
289+
#define FLATBUFFERS_SUPPRESS_UBSAN(type)
280290
#endif
281291

282-
// This is constexpr function used for checking compile-time constants.
283-
// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
284-
template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
285-
return !!t;
292+
namespace flatbuffers {
293+
// This is constexpr function used for checking compile-time constants.
294+
// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
295+
template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
296+
return !!t;
297+
}
286298
}
287299

288300
// Enable C++ attribute [[]] if std:c++17 or higher.
289301
#if ((__cplusplus >= 201703L) \
290302
|| (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)))
291303
// All attributes unknown to an implementation are ignored without causing an error.
292-
#define FLATBUFFERS_ATTRIBUTE(attr) [[attr]]
304+
#define FLATBUFFERS_ATTRIBUTE(attr) attr
293305

294306
#define FLATBUFFERS_FALLTHROUGH() [[fallthrough]]
295307
#else
@@ -314,9 +326,11 @@ namespace flatbuffers {
314326
// Also, using a consistent offset type maintains compatibility of serialized
315327
// offset values between 32bit and 64bit systems.
316328
typedef uint32_t uoffset_t;
329+
typedef uint64_t uoffset64_t;
317330

318331
// Signed offsets for references that can go in both directions.
319332
typedef int32_t soffset_t;
333+
typedef int64_t soffset64_t;
320334

321335
// Offset/index used in v-tables, can be changed to uint8_t in
322336
// format forks to save a bit of space if desired.
@@ -325,18 +339,30 @@ typedef uint16_t voffset_t;
325339
typedef uintmax_t largest_scalar_t;
326340

327341
// In 32bits, this evaluates to 2GB - 1
328-
#define FLATBUFFERS_MAX_BUFFER_SIZE ((1ULL << (sizeof(::flatbuffers::soffset_t) * 8 - 1)) - 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()
344+
345+
// The minimum size buffer that can be a valid flatbuffer.
346+
// Includes the offset to the root table (uoffset_t), the offset to the vtable
347+
// of the root table (soffset_t), the size of the vtable (uint16_t), and the
348+
// 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)
329351

330352
// We support aligning the contents of buffers up to this size.
331-
#define FLATBUFFERS_MAX_ALIGNMENT 16
353+
#ifndef FLATBUFFERS_MAX_ALIGNMENT
354+
#define FLATBUFFERS_MAX_ALIGNMENT 32
355+
#endif
356+
357+
/// @brief The length of a FlatBuffer file header.
358+
static const size_t kFileIdentifierLength = 4;
332359

333360
inline bool VerifyAlignmentRequirements(size_t align, size_t min_align = 1) {
334361
return (min_align <= align) && (align <= (FLATBUFFERS_MAX_ALIGNMENT)) &&
335362
(align & (align - 1)) == 0; // must be power of 2
336363
}
337364

338365
#if defined(_MSC_VER)
339-
#pragma warning(disable: 4351) // C4351: new behavior: elements of array ... will be default initialized
340366
#pragma warning(push)
341367
#pragma warning(disable: 4127) // C4127: conditional expression is constant
342368
#endif
@@ -397,7 +423,7 @@ template<typename T> T EndianScalar(T t) {
397423

398424
template<typename T>
399425
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
400-
__supress_ubsan__("alignment")
426+
FLATBUFFERS_SUPPRESS_UBSAN("alignment")
401427
T ReadScalar(const void *p) {
402428
return EndianScalar(*reinterpret_cast<const T *>(p));
403429
}
@@ -411,13 +437,13 @@ T ReadScalar(const void *p) {
411437

412438
template<typename T>
413439
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
414-
__supress_ubsan__("alignment")
440+
FLATBUFFERS_SUPPRESS_UBSAN("alignment")
415441
void WriteScalar(void *p, T t) {
416442
*reinterpret_cast<T *>(p) = EndianScalar(t);
417443
}
418444

419445
template<typename T> struct Offset;
420-
template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
446+
template<typename T> FLATBUFFERS_SUPPRESS_UBSAN("alignment") void WriteScalar(void *p, Offset<T> t) {
421447
*reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
422448
}
423449

@@ -428,10 +454,43 @@ template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Of
428454
// Computes how many bytes you'd have to pad to be able to write an
429455
// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
430456
// memory).
431-
__supress_ubsan__("unsigned-integer-overflow")
457+
FLATBUFFERS_SUPPRESS_UBSAN("unsigned-integer-overflow")
432458
inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) {
433459
return ((~buf_size) + 1) & (scalar_size - 1);
434460
}
435461

462+
// Generic 'operator==' with conditional specialisations.
463+
// T e - new value of a scalar field.
464+
// T def - default of scalar (is known at compile-time).
465+
template<typename T> inline bool IsTheSameAs(T e, T def) { return e == def; }
466+
467+
#if defined(FLATBUFFERS_NAN_DEFAULTS) && \
468+
defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
469+
// Like `operator==(e, def)` with weak NaN if T=(float|double).
470+
template<typename T> inline bool IsFloatTheSameAs(T e, T def) {
471+
return (e == def) || ((def != def) && (e != e));
472+
}
473+
template<> inline bool IsTheSameAs<float>(float e, float def) {
474+
return IsFloatTheSameAs(e, def);
475+
}
476+
template<> inline bool IsTheSameAs<double>(double e, double def) {
477+
return IsFloatTheSameAs(e, def);
478+
}
479+
#endif
480+
481+
// Check 'v' is out of closed range [low; high].
482+
// Workaround for GCC warning [-Werror=type-limits]:
483+
// comparison is always true due to limited range of data type.
484+
template<typename T>
485+
inline bool IsOutRange(const T &v, const T &low, const T &high) {
486+
return (v < low) || (high < v);
487+
}
488+
489+
// Check 'v' is in closed range [low; high].
490+
template<typename T>
491+
inline bool IsInRange(const T &v, const T &low, const T &high) {
492+
return !IsOutRange(v, low, high);
493+
}
494+
436495
} // namespace flatbuffers
437496
#endif // FLATBUFFERS_BASE_H_

0 commit comments

Comments
 (0)