[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:
Derek Bailey
2019-11-07 12:22:54 -08:00
committed by Wouter van Oortmerssen
parent e837d5a296
commit f0f0efe7b8
36 changed files with 3157 additions and 3294 deletions

View File

@@ -142,8 +142,8 @@ bool Print<const void *>(const void *val, Type type, int indent,
FLATBUFFERS_ASSERT(prev_val);
auto union_type_byte = *prev_val; // Always a uint8_t.
if (vector_index >= 0) {
auto type_vec = reinterpret_cast<const Vector<uint8_t> *>(prev_val +
ReadScalar<uoffset_t>(prev_val));
auto type_vec = reinterpret_cast<const Vector<uint8_t> *>(
prev_val + ReadScalar<uoffset_t>(prev_val));
union_type_byte = type_vec->Get(static_cast<uoffset_t>(vector_index));
}
auto enum_val = type.enum_def->ReverseLookup(union_type_byte, true);
@@ -205,9 +205,7 @@ bool Print<const void *>(const void *val, Type type, int indent,
// clang-format on
return true;
}
default:
FLATBUFFERS_ASSERT(0);
return false;
default: FLATBUFFERS_ASSERT(0); return false;
}
}
@@ -287,7 +285,7 @@ static bool GenStruct(const StructDef &struct_def, const Table *table,
text += ":";
text += " ";
switch (fd.value.type.base_type) {
// clang-format off
// clang-format off
#define FLATBUFFERS_TD(ENUM, IDLTYPE, \
CTYPE, JTYPE, GTYPE, NTYPE, PTYPE, RTYPE, KTYPE) \
case BASE_TYPE_ ## ENUM: \
@@ -310,7 +308,7 @@ static bool GenStruct(const StructDef &struct_def, const Table *table,
return false;
}
break;
// clang-format on
// clang-format on
}
// Track prev val for use with union types.
if (struct_def.fixed) {
@@ -330,15 +328,11 @@ static bool GenStruct(const StructDef &struct_def, const Table *table,
bool GenerateTextFromTable(const Parser &parser, const void *table,
const std::string &table_name, std::string *_text) {
auto struct_def = parser.LookupStruct(table_name);
if (struct_def == nullptr) {
return false;
}
if (struct_def == nullptr) { return false; }
auto &text = *_text;
text.reserve(1024); // Reduce amount of inevitable reallocs.
auto root = static_cast<const Table *>(table);
if (!GenStruct(*struct_def, root, 0, parser.opts, &text)) {
return false;
}
if (!GenStruct(*struct_def, root, 0, parser.opts, &text)) { return false; }
text += NewLine(parser.opts);
return true;
}
@@ -348,9 +342,9 @@ bool GenerateText(const Parser &parser, const void *flatbuffer,
std::string *_text) {
std::string &text = *_text;
FLATBUFFERS_ASSERT(parser.root_struct_def_); // call SetRootType()
text.reserve(1024); // Reduce amount of inevitable reallocs.
auto root = parser.opts.size_prefixed ?
GetSizePrefixedRoot<Table>(flatbuffer) : GetRoot<Table>(flatbuffer);
text.reserve(1024); // Reduce amount of inevitable reallocs.
auto root = parser.opts.size_prefixed ? GetSizePrefixedRoot<Table>(flatbuffer)
: GetRoot<Table>(flatbuffer);
if (!GenStruct(*parser.root_struct_def_, root, 0, parser.opts, _text)) {
return false;
}