You've already forked macports-ports
mirror of
https://github.com/macports/macports-ports.git
synced 2026-07-12 18:20:25 -07:00
fda1149169
a header-only C++ library for working with SigMF metadata
47 lines
2.4 KiB
Diff
47 lines
2.4 KiB
Diff
diff --git src/lib/flatbuffers_json_visitor.cpp src/lib/flatbuffers_json_visitor.cpp
|
|
index 85d5880..c30ccef 100644
|
|
--- src/lib/flatbuffers_json_visitor.cpp
|
|
+++ src/lib/flatbuffers_json_visitor.cpp
|
|
@@ -64,6 +64,14 @@ json_vector_to_chararray(flatbuffers::FlatBufferBuilder &fbb, const json &jvec,
|
|
}
|
|
}
|
|
|
|
+inline bool is_type_vector(const flatbuffers::TypeCode &tc) {
|
|
+#if FLATBUFFERS_VERSION_MAJOR >= 2
|
|
+ return tc.is_repeating;
|
|
+#else
|
|
+ return tc.is_vector;
|
|
+#endif
|
|
+}
|
|
+
|
|
/**
|
|
* Iterate through a typetable-- I'll be honest here. This is kind of bullshit. We need to create all of
|
|
* the types like Strings, Lists, Vectors, and other flatbuffer types before we create our table. I'm not
|
|
@@ -84,7 +92,7 @@ void IterateType(const flatbuffers::TypeTable *type_table, FromSigMFVisitor *vis
|
|
for (size_t i = 0; i < type_table->num_elems; i++) {
|
|
auto type_code = type_table->type_codes[i];
|
|
auto type = static_cast<flatbuffers::ElementaryType>(type_code.base_type);
|
|
- auto is_vector = type_code.is_vector != 0;
|
|
+ auto is_vector = is_type_vector(type_code);
|
|
auto ref_idx = type_code.sequence_ref;
|
|
const flatbuffers::TypeTable *ref = nullptr;
|
|
if (ref_idx >= 0) { ref = type_table->type_refs[ref_idx](); }
|
|
@@ -144,7 +152,7 @@ void IterateType(const flatbuffers::TypeTable *type_table, FromSigMFVisitor *vis
|
|
for (size_t i = 0; i < type_table->num_elems; i++) {
|
|
auto type_code = type_table->type_codes[i];
|
|
auto type = static_cast<flatbuffers::ElementaryType>(type_code.base_type);
|
|
- auto is_vector = type_code.is_vector != 0;
|
|
+ auto is_vector = is_type_vector(type_code);
|
|
auto ref_idx = type_code.sequence_ref;
|
|
const flatbuffers::TypeTable *ref = nullptr;
|
|
if (ref_idx >= 0) { ref = type_table->type_refs[ref_idx](); }
|
|
@@ -352,7 +360,7 @@ FlatBufferToJson(const uint8_t *buffer_root, const flatbuffers::TypeTable *typet
|
|
// Gather all of the underlying info about this element in table
|
|
auto type_code = typetable->type_codes[i];
|
|
auto type = static_cast<flatbuffers::ElementaryType>(type_code.base_type);
|
|
- auto is_vector = type_code.is_vector != 0;
|
|
+ auto is_vector = is_type_vector(type_code);
|
|
auto ref_idx = type_code.sequence_ref;
|
|
const flatbuffers::TypeTable *ref = nullptr;
|
|
if (ref_idx >= 0) { ref = typetable->type_refs[ref_idx](); }
|