[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

@@ -71,9 +71,7 @@ class DartGenerator : public BaseGenerator {
"// ignore_for_file: unused_import, unused_field, "
"unused_local_variable\n\n";
if (!kv->first.empty()) {
code += "library " + kv->first + ";\n\n";
}
if (!kv->first.empty()) { code += "library " + kv->first + ";\n\n"; }
code += "import 'dart:typed_data' show Uint8List;\n";
code += "import 'package:flat_buffers/flat_buffers.dart' as " + _kFb +
@@ -87,16 +85,20 @@ class DartGenerator : public BaseGenerator {
++kv2) {
if (kv2->first != kv->first) {
code += "import '" +
GeneratedFileName("./", file_name_ + (!kv2->first.empty() ? "_" + kv2->first : "")) +
GeneratedFileName(
"./", file_name_ +
(!kv2->first.empty() ? "_" + kv2->first : "")) +
"' as " + ImportAliasName(kv2->first) + ";\n";
}
}
code += "\n";
code += kv->second;
if (!SaveFile(
GeneratedFileName(path_, file_name_ + (!kv->first.empty() ? "_" + kv->first : "")).c_str(),
code, false)) {
if (!SaveFile(GeneratedFileName(
path_, file_name_ +
(!kv->first.empty() ? "_" + kv->first : ""))
.c_str(),
code, false)) {
return false;
}
}
@@ -117,9 +119,7 @@ class DartGenerator : public BaseGenerator {
}
static std::string BuildNamespaceName(const Namespace &ns) {
if (ns.components.empty()) {
return "";
}
if (ns.components.empty()) { return ""; }
std::stringstream sstream;
std::copy(ns.components.begin(), ns.components.end() - 1,
std::ostream_iterator<std::string>(sstream, "."));
@@ -139,7 +139,8 @@ class DartGenerator : public BaseGenerator {
return ret;
}
void GenIncludeDependencies(std::string* code, const std::string& the_namespace) {
void GenIncludeDependencies(std::string *code,
const std::string &the_namespace) {
for (auto it = parser_.included_files_.begin();
it != parser_.included_files_.end(); ++it) {
if (it->second.empty()) continue;
@@ -147,7 +148,11 @@ class DartGenerator : public BaseGenerator {
auto noext = flatbuffers::StripExtension(it->second);
auto basename = flatbuffers::StripPath(noext);
*code += "import '" + GeneratedFileName("", basename + (the_namespace == "" ? "" : "_" + the_namespace)) + "';\n";
*code +=
"import '" +
GeneratedFileName(
"", basename + (the_namespace == "" ? "" : "_" + the_namespace)) +
"';\n";
}
}
@@ -798,7 +803,8 @@ class DartGenerator : public BaseGenerator {
}
code += "\n : null;\n";
} else if (field.value.type.base_type == BASE_TYPE_STRING) {
code += " = fbBuilder.writeString(_" + MakeCamel(field.name, false) + ");\n";
code += " = fbBuilder.writeString(_" + MakeCamel(field.name, false) +
");\n";
} else {
code += " = _" + MakeCamel(field.name, false) +
"?.getOrCreateOffset(fbBuilder);\n";