mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
[C++] Refactor to conform to Google C++ style guide (#5608)
* Automatic refractor of C++ headers to Google C++ style guide * Automatic refractor of C++ source to Google C++ style guide * Automatic refractor of C++ tests to Google C++ style guide * Fixed clang-format issues by running clang-format twice to correct itself. Kotlin was missing clang-format on after turning it off, so it was changed,
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
e837d5a296
commit
f0f0efe7b8
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "flatbuffers/reflection.h"
|
||||
|
||||
#include "flatbuffers/util.h"
|
||||
|
||||
// Helper functionality for reflection.
|
||||
@@ -431,8 +432,8 @@ Offset<const Table *> CopyTable(FlatBufferBuilder &fbb,
|
||||
break;
|
||||
}
|
||||
}
|
||||
FLATBUFFERS_FALLTHROUGH(); // fall thru
|
||||
default: { // Scalars and structs.
|
||||
FLATBUFFERS_FALLTHROUGH(); // fall thru
|
||||
default: { // Scalars and structs.
|
||||
auto element_size = GetTypeSize(element_base_type);
|
||||
if (elemobjectdef && elemobjectdef->is_struct())
|
||||
element_size = elemobjectdef->bytesize();
|
||||
@@ -466,7 +467,7 @@ Offset<const Table *> CopyTable(FlatBufferBuilder &fbb,
|
||||
break;
|
||||
}
|
||||
}
|
||||
FLATBUFFERS_FALLTHROUGH(); // fall thru
|
||||
FLATBUFFERS_FALLTHROUGH(); // fall thru
|
||||
case reflection::Union:
|
||||
case reflection::String:
|
||||
case reflection::Vector:
|
||||
@@ -495,9 +496,8 @@ bool VerifyStruct(flatbuffers::Verifier &v,
|
||||
auto offset = parent_table.GetOptionalFieldOffset(field_offset);
|
||||
if (required && !offset) { return false; }
|
||||
|
||||
return !offset ||
|
||||
v.Verify(reinterpret_cast<const uint8_t *>(&parent_table), offset,
|
||||
obj.bytesize());
|
||||
return !offset || v.Verify(reinterpret_cast<const uint8_t *>(&parent_table),
|
||||
offset, obj.bytesize());
|
||||
}
|
||||
|
||||
bool VerifyVectorOfStructs(flatbuffers::Verifier &v,
|
||||
@@ -535,9 +535,8 @@ bool VerifyUnion(flatbuffers::Verifier &v, const reflection::Schema &schema,
|
||||
}
|
||||
case reflection::String:
|
||||
return v.VerifyString(
|
||||
reinterpret_cast<const flatbuffers::String *>(elem));
|
||||
default:
|
||||
return false;
|
||||
reinterpret_cast<const flatbuffers::String *>(elem));
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,27 +596,24 @@ bool VerifyVector(flatbuffers::Verifier &v, const reflection::Schema &schema,
|
||||
}
|
||||
}
|
||||
case reflection::Union: {
|
||||
auto vec = flatbuffers::GetFieldV<flatbuffers::Offset<uint8_t>>(table,
|
||||
vec_field);
|
||||
auto vec = flatbuffers::GetFieldV<flatbuffers::Offset<uint8_t>>(
|
||||
table, vec_field);
|
||||
if (!v.VerifyVector(vec)) return false;
|
||||
if (!vec) return true;
|
||||
auto type_vec = table.GetPointer<Vector<uint8_t> *>
|
||||
(vec_field.offset() - sizeof(voffset_t));
|
||||
auto type_vec = table.GetPointer<Vector<uint8_t> *>(vec_field.offset() -
|
||||
sizeof(voffset_t));
|
||||
if (!v.VerifyVector(type_vec)) return false;
|
||||
for (uoffset_t j = 0; j < vec->size(); j++) {
|
||||
// get union type from the prev field
|
||||
auto utype = type_vec->Get(j);
|
||||
auto elem = vec->Get(j);
|
||||
if (!VerifyUnion(v, schema, utype, elem, vec_field))
|
||||
return false;
|
||||
if (!VerifyUnion(v, schema, utype, elem, vec_field)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case reflection::Vector:
|
||||
case reflection::None:
|
||||
default:
|
||||
FLATBUFFERS_ASSERT(false);
|
||||
return false;
|
||||
default: FLATBUFFERS_ASSERT(false); return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,8 +659,7 @@ bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema,
|
||||
}
|
||||
break;
|
||||
case reflection::Vector:
|
||||
if (!VerifyVector(v, schema, *table, *field_def))
|
||||
return false;
|
||||
if (!VerifyVector(v, schema, *table, *field_def)) return false;
|
||||
break;
|
||||
case reflection::Obj: {
|
||||
auto child_obj = schema.objects()->Get(field_def->type()->index());
|
||||
@@ -687,15 +682,11 @@ bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema,
|
||||
voffset_t utype_offset = field_def->offset() - sizeof(voffset_t);
|
||||
auto utype = table->GetField<uint8_t>(utype_offset, 0);
|
||||
auto uval = reinterpret_cast<const uint8_t *>(
|
||||
flatbuffers::GetFieldT(*table, *field_def));
|
||||
if (!VerifyUnion(v, schema, utype, uval, *field_def)) {
|
||||
return false;
|
||||
}
|
||||
flatbuffers::GetFieldT(*table, *field_def));
|
||||
if (!VerifyUnion(v, schema, utype, uval, *field_def)) { return false; }
|
||||
break;
|
||||
}
|
||||
default:
|
||||
FLATBUFFERS_ASSERT(false);
|
||||
break;
|
||||
default: FLATBUFFERS_ASSERT(false); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user