mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-27 12:12:18 +00:00
Audit and fixups for GCC and Clang (#7212)
Added (for compiler versions that support it): -Wmissing-declarations -Wzero-as-null-pointer-constant Then, fixes to problems identified by the extra warnings Tested only on GCC 9.4.0 Adjusted the CPP code generator to output nullptr where appropriate, to satisfy -Wzero-as-null-pointer-constant Added a lot of 'static' declarations in front of functions, to satisfy -Wmissing-declarations, and wrap static function defs in anonymous namespaces. There are advantages to both anonymous namespaces and static, it seems that marking a function as static will not publish the name in the symbol table at all, thus giving the linker less work to do.
This commit is contained in:
@@ -8,23 +8,24 @@
|
||||
namespace grpc_cpp_generator {
|
||||
namespace {
|
||||
|
||||
grpc::string service_header_ext() { return ".grpc.fb.h"; }
|
||||
static grpc::string service_header_ext() { return ".grpc.fb.h"; }
|
||||
|
||||
template<class T> grpc::string as_string(T x) {
|
||||
template<class T>
|
||||
static grpc::string as_string(T x) {
|
||||
std::ostringstream out;
|
||||
out << x;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
inline bool ClientOnlyStreaming(const grpc_generator::Method *method) {
|
||||
static inline bool ClientOnlyStreaming(const grpc_generator::Method *method) {
|
||||
return method->ClientStreaming() && !method->ServerStreaming();
|
||||
}
|
||||
|
||||
inline bool ServerOnlyStreaming(const grpc_generator::Method *method) {
|
||||
static inline bool ServerOnlyStreaming(const grpc_generator::Method *method) {
|
||||
return !method->ClientStreaming() && method->ServerStreaming();
|
||||
}
|
||||
|
||||
grpc::string FilenameIdentifier(const grpc::string &filename) {
|
||||
static grpc::string FilenameIdentifier(const grpc::string &filename) {
|
||||
grpc::string result;
|
||||
for (unsigned i = 0; i < filename.size(); i++) {
|
||||
char c = filename[i];
|
||||
@@ -39,11 +40,11 @@ grpc::string FilenameIdentifier(const grpc::string &filename) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
template<class T, size_t N> T *array_end(T (&array)[N]) { return array + N; }
|
||||
template<class T, size_t N>
|
||||
static T *array_end(T (&array)[N]) { return array + N; }
|
||||
|
||||
void PrintIncludes(grpc_generator::Printer *printer,
|
||||
static void PrintIncludes(grpc_generator::Printer *printer,
|
||||
const std::vector<grpc::string> &headers,
|
||||
const Parameters ¶ms) {
|
||||
std::map<grpc::string, grpc::string> vars;
|
||||
@@ -63,6 +64,8 @@ void PrintIncludes(grpc_generator::Printer *printer,
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
grpc::string GetHeaderPrologue(grpc_generator::File *file,
|
||||
const Parameters ¶ms) {
|
||||
grpc::string output;
|
||||
@@ -137,7 +140,10 @@ grpc::string GetHeaderIncludes(grpc_generator::File *file,
|
||||
return output;
|
||||
}
|
||||
|
||||
void PrintHeaderClientMethodInterfaces(
|
||||
|
||||
namespace {
|
||||
|
||||
static void PrintHeaderClientMethodInterfaces(
|
||||
grpc_generator::Printer *printer, const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars, bool is_public) {
|
||||
(*vars)["Method"] = method->name();
|
||||
@@ -351,7 +357,9 @@ void PrintHeaderClientMethodInterfaces(
|
||||
}
|
||||
}
|
||||
|
||||
void PrintHeaderClientMethod(grpc_generator::Printer *printer,
|
||||
|
||||
|
||||
static void PrintHeaderClientMethod(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars,
|
||||
bool is_public) {
|
||||
@@ -554,7 +562,7 @@ void PrintHeaderClientMethod(grpc_generator::Printer *printer,
|
||||
}
|
||||
}
|
||||
|
||||
void PrintHeaderClientMethodData(grpc_generator::Printer *printer,
|
||||
static void PrintHeaderClientMethodData(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Method"] = method->name();
|
||||
@@ -562,7 +570,7 @@ void PrintHeaderClientMethodData(grpc_generator::Printer *printer,
|
||||
"const ::grpc::internal::RpcMethod rpcmethod_$Method$_;\n");
|
||||
}
|
||||
|
||||
void PrintHeaderServerMethodSync(grpc_generator::Printer *printer,
|
||||
static void PrintHeaderServerMethodSync(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Method"] = method->name();
|
||||
@@ -596,7 +604,7 @@ void PrintHeaderServerMethodSync(grpc_generator::Printer *printer,
|
||||
printer->Print(method->GetTrailingComments("//").c_str());
|
||||
}
|
||||
|
||||
void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
|
||||
static void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Method"] = method->name();
|
||||
@@ -712,7 +720,7 @@ void PrintHeaderServerMethodAsync(grpc_generator::Printer *printer,
|
||||
printer->Print(*vars, "};\n");
|
||||
}
|
||||
|
||||
void PrintHeaderServerMethodStreamedUnary(
|
||||
static void PrintHeaderServerMethodStreamedUnary(
|
||||
grpc_generator::Printer *printer, const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Method"] = method->name();
|
||||
@@ -763,7 +771,7 @@ void PrintHeaderServerMethodStreamedUnary(
|
||||
}
|
||||
}
|
||||
|
||||
void PrintHeaderServerMethodSplitStreaming(
|
||||
static void PrintHeaderServerMethodSplitStreaming(
|
||||
grpc_generator::Printer *printer, const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Method"] = method->name();
|
||||
@@ -816,7 +824,7 @@ void PrintHeaderServerMethodSplitStreaming(
|
||||
}
|
||||
}
|
||||
|
||||
void PrintHeaderServerMethodGeneric(
|
||||
static void PrintHeaderServerMethodGeneric(
|
||||
grpc_generator::Printer *printer, const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Method"] = method->name();
|
||||
@@ -887,7 +895,7 @@ void PrintHeaderServerMethodGeneric(
|
||||
printer->Print(*vars, "};\n");
|
||||
}
|
||||
|
||||
void PrintHeaderService(grpc_generator::Printer *printer,
|
||||
static void PrintHeaderService(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Service *service,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Service"] = service->name();
|
||||
@@ -1058,6 +1066,8 @@ void PrintHeaderService(grpc_generator::Printer *printer,
|
||||
printer->Print(service->GetTrailingComments("//").c_str());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
grpc::string GetHeaderServices(grpc_generator::File *file,
|
||||
const Parameters ¶ms) {
|
||||
grpc::string output;
|
||||
@@ -1176,7 +1186,10 @@ grpc::string GetSourceIncludes(grpc_generator::File *file,
|
||||
return output;
|
||||
}
|
||||
|
||||
void PrintSourceClientMethod(grpc_generator::Printer *printer,
|
||||
|
||||
namespace {
|
||||
|
||||
static void PrintSourceClientMethod(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Method"] = method->name();
|
||||
@@ -1320,7 +1333,7 @@ void PrintSourceClientMethod(grpc_generator::Printer *printer,
|
||||
}
|
||||
}
|
||||
|
||||
void PrintSourceServerMethod(grpc_generator::Printer *printer,
|
||||
static void PrintSourceServerMethod(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Method"] = method->name();
|
||||
@@ -1369,7 +1382,7 @@ void PrintSourceServerMethod(grpc_generator::Printer *printer,
|
||||
}
|
||||
}
|
||||
|
||||
void PrintSourceService(grpc_generator::Printer *printer,
|
||||
static void PrintSourceService(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Service *service,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Service"] = service->name();
|
||||
@@ -1486,6 +1499,8 @@ void PrintSourceService(grpc_generator::Printer *printer,
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
grpc::string GetSourceServices(grpc_generator::File *file,
|
||||
const Parameters ¶ms) {
|
||||
grpc::string output;
|
||||
@@ -1588,7 +1603,10 @@ grpc::string GetMockIncludes(grpc_generator::File *file,
|
||||
return output;
|
||||
}
|
||||
|
||||
void PrintMockClientMethods(grpc_generator::Printer *printer,
|
||||
|
||||
namespace {
|
||||
|
||||
static void PrintMockClientMethods(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Method"] = method->name();
|
||||
@@ -1680,7 +1698,7 @@ void PrintMockClientMethods(grpc_generator::Printer *printer,
|
||||
}
|
||||
}
|
||||
|
||||
void PrintMockService(grpc_generator::Printer *printer,
|
||||
static void PrintMockService(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Service *service,
|
||||
std::map<grpc::string, grpc::string> *vars) {
|
||||
(*vars)["Service"] = service->name();
|
||||
@@ -1696,6 +1714,8 @@ void PrintMockService(grpc_generator::Printer *printer,
|
||||
printer->Print("};\n");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
grpc::string GetMockServices(grpc_generator::File *file,
|
||||
const Parameters ¶ms) {
|
||||
grpc::string output;
|
||||
|
||||
@@ -19,22 +19,23 @@ inline bool ServerOnlyStreaming(const grpc_generator::Method *method) {
|
||||
}
|
||||
|
||||
namespace grpc_go_generator {
|
||||
namespace {
|
||||
|
||||
// Returns string with first letter to lowerCase
|
||||
grpc::string unexportName(grpc::string s) {
|
||||
static grpc::string unexportName(grpc::string s) {
|
||||
if (s.empty()) return s;
|
||||
s[0] = static_cast<char>(std::tolower(s[0]));
|
||||
return s;
|
||||
}
|
||||
|
||||
// Returns string with first letter to uppercase
|
||||
grpc::string exportName(grpc::string s) {
|
||||
static grpc::string exportName(grpc::string s) {
|
||||
if (s.empty()) return s;
|
||||
s[0] = static_cast<char>(std::toupper(s[0]));
|
||||
return s;
|
||||
}
|
||||
|
||||
void GenerateError(grpc_generator::Printer *printer,
|
||||
static void GenerateError(grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> vars,
|
||||
const bool multiple_return = true) {
|
||||
printer->Print(vars, "if $Error_Check$ {\n");
|
||||
@@ -46,7 +47,7 @@ void GenerateError(grpc_generator::Printer *printer,
|
||||
}
|
||||
|
||||
// Generates imports for the service
|
||||
void GenerateImports(grpc_generator::File *file,
|
||||
static void GenerateImports(grpc_generator::File *file,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> vars) {
|
||||
vars["filename"] = file->filename();
|
||||
@@ -66,7 +67,7 @@ void GenerateImports(grpc_generator::File *file,
|
||||
}
|
||||
|
||||
// Generates Server method signature source
|
||||
void GenerateServerMethodSignature(const grpc_generator::Method *method,
|
||||
static void GenerateServerMethodSignature(const grpc_generator::Method *method,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> vars) {
|
||||
vars["Method"] = exportName(method->name());
|
||||
@@ -86,7 +87,7 @@ void GenerateServerMethodSignature(const grpc_generator::Method *method,
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateServerMethod(const grpc_generator::Method *method,
|
||||
static void GenerateServerMethod(const grpc_generator::Method *method,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> vars) {
|
||||
vars["Method"] = exportName(method->name());
|
||||
@@ -204,7 +205,7 @@ void GenerateServerMethod(const grpc_generator::Method *method,
|
||||
}
|
||||
|
||||
// Generates Client method signature source
|
||||
void GenerateClientMethodSignature(const grpc_generator::Method *method,
|
||||
static void GenerateClientMethodSignature(const grpc_generator::Method *method,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> vars) {
|
||||
vars["Method"] = exportName(method->name());
|
||||
@@ -225,7 +226,7 @@ void GenerateClientMethodSignature(const grpc_generator::Method *method,
|
||||
}
|
||||
|
||||
// Generates Client method source
|
||||
void GenerateClientMethod(const grpc_generator::Method *method,
|
||||
static void GenerateClientMethod(const grpc_generator::Method *method,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> vars) {
|
||||
printer->Print(vars, "func (c *$ServiceUnexported$Client) ");
|
||||
@@ -480,6 +481,7 @@ void GenerateService(const grpc_generator::Service *service,
|
||||
printer->Outdent();
|
||||
printer->Print("}\n");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Returns source for the service
|
||||
grpc::string GenerateServiceSource(grpc_generator::File *file,
|
||||
|
||||
@@ -44,8 +44,9 @@ typedef grpc_generator::Method MethodDescriptor;
|
||||
|
||||
namespace grpc_java_generator {
|
||||
typedef std::string string;
|
||||
namespace {
|
||||
// Generates imports for the service
|
||||
void GenerateImports(grpc_generator::File *file,
|
||||
static void GenerateImports(grpc_generator::File *file,
|
||||
grpc_generator::Printer *printer, VARS &vars) {
|
||||
vars["filename"] = file->filename();
|
||||
printer->Print(vars,
|
||||
@@ -287,7 +288,7 @@ static void GrpcWriteServiceDocComment(Printer *printer, VARS &vars,
|
||||
printer->Print(" */\n");
|
||||
}
|
||||
|
||||
void GrpcWriteMethodDocComment(Printer *printer, VARS &vars,
|
||||
static void GrpcWriteMethodDocComment(Printer *printer, VARS &vars,
|
||||
const MethodDescriptor *method) {
|
||||
printer->Print("/**\n");
|
||||
std::vector<string> lines = GrpcGetDocLinesForDescriptor(method);
|
||||
@@ -1029,7 +1030,7 @@ static void PrintService(Printer *p, VARS &vars,
|
||||
p->Print("}\n");
|
||||
}
|
||||
|
||||
void PrintStaticImports(Printer *p) {
|
||||
static void PrintStaticImports(Printer *p) {
|
||||
p->Print(
|
||||
"import java.nio.ByteBuffer;\n"
|
||||
"import static "
|
||||
@@ -1062,7 +1063,7 @@ void PrintStaticImports(Printer *p) {
|
||||
"io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;\n\n");
|
||||
}
|
||||
|
||||
void GenerateService(const grpc_generator::Service *service,
|
||||
static void GenerateService(const grpc_generator::Service *service,
|
||||
grpc_generator::Printer *printer, VARS &vars,
|
||||
bool disable_version) {
|
||||
// All non-generated classes must be referred by fully qualified names to
|
||||
@@ -1097,6 +1098,7 @@ void GenerateService(const grpc_generator::Service *service,
|
||||
|
||||
PrintService(printer, vars, service, disable_version);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
grpc::string GenerateServiceSource(
|
||||
grpc_generator::File *file, const grpc_generator::Service *service,
|
||||
|
||||
@@ -23,8 +23,9 @@
|
||||
#include "src/compiler/python_generator.h"
|
||||
|
||||
namespace grpc_python_generator {
|
||||
namespace {
|
||||
|
||||
grpc::string GenerateMethodType(const grpc_generator::Method *method) {
|
||||
static grpc::string GenerateMethodType(const grpc_generator::Method *method) {
|
||||
|
||||
if (method->NoStreaming())
|
||||
return "unary_unary";
|
||||
@@ -131,6 +132,7 @@ void GenerateRegister(const grpc_generator::Service *service,
|
||||
printer->Outdent();
|
||||
printer->Print("\n");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
grpc::string Generate(grpc_generator::File *file,
|
||||
const grpc_generator::Service *service) {
|
||||
|
||||
@@ -28,8 +28,9 @@
|
||||
#include "src/compiler/swift_generator.h"
|
||||
|
||||
namespace grpc_swift_generator {
|
||||
namespace {
|
||||
|
||||
std::string WrapInNameSpace(const std::vector<std::string> &components,
|
||||
static std::string WrapInNameSpace(const std::vector<std::string> &components,
|
||||
const grpc::string &name) {
|
||||
std::string qualified_name;
|
||||
for (auto it = components.begin(); it != components.end(); ++it)
|
||||
@@ -37,14 +38,14 @@ std::string WrapInNameSpace(const std::vector<std::string> &components,
|
||||
return qualified_name + name;
|
||||
}
|
||||
|
||||
grpc::string GenerateMessage(const std::vector<std::string> &components,
|
||||
static grpc::string GenerateMessage(const std::vector<std::string> &components,
|
||||
const grpc::string &name) {
|
||||
return "Message<" + WrapInNameSpace(components, name) + ">";
|
||||
}
|
||||
|
||||
// MARK: - Client
|
||||
|
||||
void GenerateClientFuncName(const grpc_generator::Method *method,
|
||||
static void GenerateClientFuncName(const grpc_generator::Method *method,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -82,7 +83,7 @@ void GenerateClientFuncName(const grpc_generator::Method *method,
|
||||
" ) -> BidirectionalStreamingCall<$Input$, $Output$>");
|
||||
}
|
||||
|
||||
void GenerateClientFuncBody(const grpc_generator::Method *method,
|
||||
static void GenerateClientFuncBody(const grpc_generator::Method *method,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -372,6 +373,7 @@ void GenerateServerProtocol(const grpc_generator::Service *service,
|
||||
}
|
||||
printer->Print("}");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
grpc::string Generate(grpc_generator::File *file,
|
||||
const grpc_generator::Service *service) {
|
||||
|
||||
@@ -30,8 +30,9 @@
|
||||
#include "src/compiler/schema_interface.h"
|
||||
|
||||
namespace grpc_ts_generator {
|
||||
namespace {
|
||||
|
||||
grpc::string GenerateNamespace(const std::vector<std::string> ns,
|
||||
static grpc::string GenerateNamespace(const std::vector<std::string> ns,
|
||||
const std::string filename,
|
||||
const bool include_separator) {
|
||||
grpc::string path = "";
|
||||
@@ -55,7 +56,7 @@ grpc::string GenerateNamespace(const std::vector<std::string> ns,
|
||||
|
||||
// MARK: - Shared code
|
||||
|
||||
void GenerateImports(const grpc_generator::Service *service,
|
||||
static void GenerateImports(const grpc_generator::Service *service,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary,
|
||||
const bool grpc_var_import) {
|
||||
@@ -104,7 +105,7 @@ void GenerateImports(const grpc_generator::Service *service,
|
||||
|
||||
// MARK: - Generate Main GRPC Code
|
||||
|
||||
void GetStreamType(grpc_generator::Printer *printer,
|
||||
static void GetStreamType(grpc_generator::Printer *printer,
|
||||
const grpc_generator::Method *method,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -116,7 +117,7 @@ void GetStreamType(grpc_generator::Printer *printer,
|
||||
printer->Print(vars, "responseStream: $ServerStreaming$,\n");
|
||||
}
|
||||
|
||||
void GenerateSerializeMethod(grpc_generator::Printer *printer,
|
||||
static void GenerateSerializeMethod(grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
printer->Print(vars, "function serialize_$Type$(buffer_args) {\n");
|
||||
@@ -132,7 +133,7 @@ void GenerateSerializeMethod(grpc_generator::Printer *printer,
|
||||
printer->Print("}\n\n");
|
||||
}
|
||||
|
||||
void GenerateDeserializeMethod(
|
||||
static void GenerateDeserializeMethod(
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -145,7 +146,7 @@ void GenerateDeserializeMethod(
|
||||
printer->Print("}\n\n");
|
||||
}
|
||||
|
||||
void GenerateMethods(const grpc_generator::Service *service,
|
||||
static void GenerateMethods(const grpc_generator::Service *service,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -177,7 +178,7 @@ void GenerateMethods(const grpc_generator::Service *service,
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateService(const grpc_generator::Service *service,
|
||||
static void GenerateService(const grpc_generator::Service *service,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -212,6 +213,8 @@ void GenerateService(const grpc_generator::Service *service,
|
||||
"grpc.makeGenericClientConstructor($NAME$);");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
grpc::string Generate(grpc_generator::File *file,
|
||||
const grpc_generator::Service *service,
|
||||
const grpc::string &filename) {
|
||||
@@ -233,9 +236,11 @@ grpc::string Generate(grpc_generator::File *file,
|
||||
return output;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// MARK: - Generate Interface
|
||||
|
||||
void FillInterface(grpc_generator::Printer *printer,
|
||||
static void FillInterface(grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
printer->Print(vars,
|
||||
@@ -253,7 +258,7 @@ void FillInterface(grpc_generator::Printer *printer,
|
||||
printer->Print("}\n");
|
||||
}
|
||||
|
||||
void GenerateInterfaces(const grpc_generator::Service *service,
|
||||
static void GenerateInterfaces(const grpc_generator::Service *service,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -275,7 +280,7 @@ void GenerateInterfaces(const grpc_generator::Service *service,
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateExportedInterface(
|
||||
static void GenerateExportedInterface(
|
||||
const grpc_generator::Service *service, grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -319,7 +324,7 @@ void GenerateExportedInterface(
|
||||
printer->Print("}\n");
|
||||
}
|
||||
|
||||
void GenerateMainInterface(const grpc_generator::Service *service,
|
||||
static void GenerateMainInterface(const grpc_generator::Service *service,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -344,11 +349,11 @@ void GenerateMainInterface(const grpc_generator::Service *service,
|
||||
GenerateExportedInterface(service, printer, &vars);
|
||||
}
|
||||
|
||||
grpc::string GenerateMetaData() { return "metadata: grpc.Metadata"; }
|
||||
static grpc::string GenerateMetaData() { return "metadata: grpc.Metadata"; }
|
||||
|
||||
grpc::string GenerateOptions() { return "options: Partial<grpc.CallOptions>"; }
|
||||
static grpc::string GenerateOptions() { return "options: Partial<grpc.CallOptions>"; }
|
||||
|
||||
void GenerateUnaryClientInterface(
|
||||
static void GenerateUnaryClientInterface(
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -363,7 +368,7 @@ void GenerateUnaryClientInterface(
|
||||
printer->Print(vars, (main + meta_data + options + callback).c_str());
|
||||
}
|
||||
|
||||
void GenerateClientWriteStreamInterface(
|
||||
static void GenerateClientWriteStreamInterface(
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -380,7 +385,7 @@ void GenerateClientWriteStreamInterface(
|
||||
printer->Print(vars, (main + meta_data + options + callback).c_str());
|
||||
}
|
||||
|
||||
void GenerateClientReadableStreamInterface(
|
||||
static void GenerateClientReadableStreamInterface(
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -392,7 +397,7 @@ void GenerateClientReadableStreamInterface(
|
||||
printer->Print(vars, (main + options + end_function).c_str());
|
||||
}
|
||||
|
||||
void GenerateDepluxStreamInterface(
|
||||
static void GenerateDepluxStreamInterface(
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -408,7 +413,7 @@ void GenerateDepluxStreamInterface(
|
||||
.c_str());
|
||||
}
|
||||
|
||||
void GenerateClientInterface(const grpc_generator::Service *service,
|
||||
static void GenerateClientInterface(const grpc_generator::Service *service,
|
||||
grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -446,7 +451,7 @@ void GenerateClientInterface(const grpc_generator::Service *service,
|
||||
printer->Print("}\n");
|
||||
}
|
||||
|
||||
void GenerateClientClassInterface(
|
||||
static void GenerateClientClassInterface(
|
||||
const grpc_generator::Service *service, grpc_generator::Printer *printer,
|
||||
std::map<grpc::string, grpc::string> *dictonary) {
|
||||
auto vars = *dictonary;
|
||||
@@ -487,6 +492,8 @@ void GenerateClientClassInterface(
|
||||
printer->Outdent();
|
||||
printer->Print("}\n");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
grpc::string GenerateInterface(grpc_generator::File *file,
|
||||
const grpc_generator::Service *service,
|
||||
|
||||
Reference in New Issue
Block a user