mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-08 06:05:17 +00:00
Use the Google Style for clang-format without exceptions (#8706)
This reduces the friction when merging from github and google repos by using the exact same clang style guide. MARKDOWN=true
This commit is contained in:
@@ -40,18 +40,22 @@
|
||||
#include "idl_gen_text.h"
|
||||
#include "idl_gen_ts.h"
|
||||
|
||||
static const char *g_program_name = nullptr;
|
||||
static const char* g_program_name = nullptr;
|
||||
|
||||
static void Warn(const flatbuffers::FlatCompiler *flatc,
|
||||
const std::string &warn, bool show_exe_name) {
|
||||
static void Warn(const flatbuffers::FlatCompiler* flatc,
|
||||
const std::string& warn, bool show_exe_name) {
|
||||
(void)flatc;
|
||||
if (show_exe_name) { printf("%s: ", g_program_name); }
|
||||
if (show_exe_name) {
|
||||
printf("%s: ", g_program_name);
|
||||
}
|
||||
fprintf(stderr, "\nwarning:\n %s\n\n", warn.c_str());
|
||||
}
|
||||
|
||||
static void Error(const flatbuffers::FlatCompiler *flatc,
|
||||
const std::string &err, bool usage, bool show_exe_name) {
|
||||
if (show_exe_name) { printf("%s: ", g_program_name); }
|
||||
static void Error(const flatbuffers::FlatCompiler* flatc,
|
||||
const std::string& err, bool usage, bool show_exe_name) {
|
||||
if (show_exe_name) {
|
||||
printf("%s: ", g_program_name);
|
||||
}
|
||||
if (usage && flatc) {
|
||||
fprintf(stderr, "%s\n", flatc->GetShortUsageString(g_program_name).c_str());
|
||||
}
|
||||
@@ -60,16 +64,16 @@ static void Error(const flatbuffers::FlatCompiler *flatc,
|
||||
}
|
||||
|
||||
namespace flatbuffers {
|
||||
void LogCompilerWarn(const std::string &warn) {
|
||||
Warn(static_cast<const flatbuffers::FlatCompiler *>(nullptr), warn, true);
|
||||
void LogCompilerWarn(const std::string& warn) {
|
||||
Warn(static_cast<const flatbuffers::FlatCompiler*>(nullptr), warn, true);
|
||||
}
|
||||
void LogCompilerError(const std::string &err) {
|
||||
Error(static_cast<const flatbuffers::FlatCompiler *>(nullptr), err, false,
|
||||
void LogCompilerError(const std::string& err) {
|
||||
Error(static_cast<const flatbuffers::FlatCompiler*>(nullptr), err, false,
|
||||
true);
|
||||
}
|
||||
} // namespace flatbuffers
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
int main(int argc, const char* argv[]) {
|
||||
const std::string flatbuffers_version(flatbuffers::FLATBUFFERS_VERSION());
|
||||
|
||||
g_program_name = argv[0];
|
||||
@@ -83,100 +87,101 @@ int main(int argc, const char *argv[]) {
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{
|
||||
"b", "binary", "",
|
||||
"Generate wire format binaries for any data definitions" },
|
||||
"Generate wire format binaries for any data definitions"},
|
||||
flatbuffers::NewBinaryCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "c", "cpp", "",
|
||||
"Generate C++ headers for tables/structs" },
|
||||
flatbuffers::FlatCOption{"c", "cpp", "",
|
||||
"Generate C++ headers for tables/structs"},
|
||||
flatbuffers::NewCppCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "n", "csharp", "",
|
||||
"Generate C# classes for tables/structs" },
|
||||
flatbuffers::FlatCOption{"n", "csharp", "",
|
||||
"Generate C# classes for tables/structs"},
|
||||
flatbuffers::NewCSharpCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "d", "dart", "",
|
||||
"Generate Dart classes for tables/structs" },
|
||||
flatbuffers::FlatCOption{"d", "dart", "",
|
||||
"Generate Dart classes for tables/structs"},
|
||||
flatbuffers::NewDartCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "", "proto", "",
|
||||
"Input is a .proto, translate to .fbs" },
|
||||
flatbuffers::FlatCOption{"", "proto", "",
|
||||
"Input is a .proto, translate to .fbs"},
|
||||
flatbuffers::NewFBSCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "g", "go", "",
|
||||
"Generate Go files for tables/structs" },
|
||||
flatbuffers::FlatCOption{"g", "go", "",
|
||||
"Generate Go files for tables/structs"},
|
||||
flatbuffers::NewGoCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "j", "java", "",
|
||||
"Generate Java classes for tables/structs" },
|
||||
flatbuffers::FlatCOption{"j", "java", "",
|
||||
"Generate Java classes for tables/structs"},
|
||||
flatbuffers::NewJavaCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "", "jsonschema", "", "Generate Json schema" },
|
||||
flatbuffers::FlatCOption{"", "jsonschema", "", "Generate Json schema"},
|
||||
flatbuffers::NewJsonSchemaCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "", "kotlin", "",
|
||||
"Generate Kotlin classes for tables/structs" },
|
||||
flatbuffers::FlatCOption{"", "kotlin", "",
|
||||
"Generate Kotlin classes for tables/structs"},
|
||||
flatbuffers::NewKotlinCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "", "kotlin-kmp", "",
|
||||
"Generate Kotlin multiplatform classes for tables/structs" },
|
||||
flatbuffers::FlatCOption{
|
||||
"", "kotlin-kmp", "",
|
||||
"Generate Kotlin multiplatform classes for tables/structs"},
|
||||
flatbuffers::NewKotlinKMPCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "", "lobster", "",
|
||||
"Generate Lobster files for tables/structs" },
|
||||
flatbuffers::FlatCOption{"", "lobster", "",
|
||||
"Generate Lobster files for tables/structs"},
|
||||
flatbuffers::NewLobsterCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "l", "lua", "",
|
||||
"Generate Lua files for tables/structs" },
|
||||
flatbuffers::FlatCOption{"l", "lua", "",
|
||||
"Generate Lua files for tables/structs"},
|
||||
flatbuffers::NewLuaBfbsGenerator(flatbuffers_version));
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "", "nim", "",
|
||||
"Generate Nim files for tables/structs" },
|
||||
flatbuffers::FlatCOption{"", "nim", "",
|
||||
"Generate Nim files for tables/structs"},
|
||||
flatbuffers::NewNimBfbsGenerator(flatbuffers_version));
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "p", "python", "",
|
||||
"Generate Python files for tables/structs" },
|
||||
flatbuffers::FlatCOption{"p", "python", "",
|
||||
"Generate Python files for tables/structs"},
|
||||
flatbuffers::NewPythonCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "", "php", "",
|
||||
"Generate PHP files for tables/structs" },
|
||||
flatbuffers::FlatCOption{"", "php", "",
|
||||
"Generate PHP files for tables/structs"},
|
||||
flatbuffers::NewPhpCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "r", "rust", "",
|
||||
"Generate Rust files for tables/structs" },
|
||||
flatbuffers::FlatCOption{"r", "rust", "",
|
||||
"Generate Rust files for tables/structs"},
|
||||
flatbuffers::NewRustCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{
|
||||
"t", "json", "", "Generate text output for any data definitions" },
|
||||
flatbuffers::FlatCOption{"t", "json", "",
|
||||
"Generate text output for any data definitions"},
|
||||
flatbuffers::NewTextCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "", "swift", "",
|
||||
"Generate Swift files for tables/structs" },
|
||||
flatbuffers::FlatCOption{"", "swift", "",
|
||||
"Generate Swift files for tables/structs"},
|
||||
flatbuffers::NewSwiftCodeGenerator());
|
||||
|
||||
flatc.RegisterCodeGenerator(
|
||||
flatbuffers::FlatCOption{ "T", "ts", "",
|
||||
"Generate TypeScript code for tables/structs" },
|
||||
flatbuffers::FlatCOption{"T", "ts", "",
|
||||
"Generate TypeScript code for tables/structs"},
|
||||
flatbuffers::NewTsCodeGenerator());
|
||||
|
||||
// Create the FlatC options by parsing the command line arguments.
|
||||
const flatbuffers::FlatCOptions &options =
|
||||
const flatbuffers::FlatCOptions& options =
|
||||
flatc.ParseFromCommandLineArguments(argc, argv);
|
||||
|
||||
// Compile with the extracted FlatC options.
|
||||
|
||||
Reference in New Issue
Block a user