mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-06 05:36:56 +00:00
replace framework include of flatbuffers (#7079)
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <flatbuffers/util.h>
|
||||
#include "flatbuffers/util.h"
|
||||
#define to_string flatbuffers::NumToString
|
||||
|
||||
// Stringify helpers used solely to cast GRPC_VERSION
|
||||
@@ -35,7 +35,6 @@
|
||||
# define XSTR(s) STR(s)
|
||||
#endif
|
||||
|
||||
|
||||
typedef grpc_generator::Printer Printer;
|
||||
typedef std::map<grpc::string, grpc::string> VARS;
|
||||
typedef grpc_generator::Service ServiceDescriptor;
|
||||
@@ -49,8 +48,7 @@ typedef std::string string;
|
||||
void GenerateImports(grpc_generator::File *file,
|
||||
grpc_generator::Printer *printer, VARS &vars) {
|
||||
vars["filename"] = file->filename();
|
||||
printer->Print(
|
||||
vars,
|
||||
printer->Print(vars,
|
||||
"//Generated by flatc compiler (version $flatc_version$)\n");
|
||||
printer->Print("//If you make any local changes, they will be lost\n");
|
||||
printer->Print(vars, "//source: $filename$.fbs\n\n");
|
||||
@@ -219,9 +217,7 @@ static string GrpcEscapeJavadoc(const string& input) {
|
||||
// Java interprets Unicode escape sequences anywhere!
|
||||
result.append("\");
|
||||
break;
|
||||
default:
|
||||
result.push_back(c);
|
||||
break;
|
||||
default: result.push_back(c); break;
|
||||
}
|
||||
|
||||
prev = c;
|
||||
@@ -241,9 +237,7 @@ static std::vector<string> GrpcGetDocLines(const string& comments) {
|
||||
string escapedComments = GrpcEscapeJavadoc(comments);
|
||||
|
||||
std::vector<string> lines = GrpcSplit(escapedComments, "\n");
|
||||
while (!lines.empty() && lines.back().empty()) {
|
||||
lines.pop_back();
|
||||
}
|
||||
while (!lines.empty() && lines.back().empty()) { lines.pop_back(); }
|
||||
return lines;
|
||||
}
|
||||
return std::vector<string>();
|
||||
@@ -259,9 +253,7 @@ static void GrpcWriteDocCommentBody(Printer* printer, VARS& vars,
|
||||
const std::vector<string> &lines,
|
||||
bool surroundWithPreTag) {
|
||||
if (!lines.empty()) {
|
||||
if (surroundWithPreTag) {
|
||||
printer->Print(" * <pre>\n");
|
||||
}
|
||||
if (surroundWithPreTag) { printer->Print(" * <pre>\n"); }
|
||||
|
||||
for (size_t i = 0; i < lines.size(); i++) {
|
||||
// Most lines should start with a space. Watch out for lines that start
|
||||
@@ -275,9 +267,7 @@ static void GrpcWriteDocCommentBody(Printer* printer, VARS& vars,
|
||||
}
|
||||
}
|
||||
|
||||
if (surroundWithPreTag) {
|
||||
printer->Print(" * </pre>\n");
|
||||
}
|
||||
if (surroundWithPreTag) { printer->Print(" * </pre>\n"); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,10 +295,10 @@ void GrpcWriteMethodDocComment(Printer* printer, VARS& vars,
|
||||
printer->Print(" */\n");
|
||||
}
|
||||
|
||||
//outputs static singleton extractor for type stored in "extr_type" and "extr_type_name" vars
|
||||
// outputs static singleton extractor for type stored in "extr_type" and
|
||||
// "extr_type_name" vars
|
||||
static void PrintTypeExtractor(Printer *p, VARS &vars) {
|
||||
p->Print(
|
||||
vars,
|
||||
p->Print(vars,
|
||||
"private static volatile FlatbuffersUtils.FBExtactor<$extr_type$> "
|
||||
"extractorOf$extr_type_name$;\n"
|
||||
"private static FlatbuffersUtils.FBExtactor<$extr_type$> "
|
||||
@@ -336,7 +326,8 @@ static void PrintMethodFields(Printer* p, VARS& vars,
|
||||
|
||||
// set of names of rpc input- and output- types that were already encountered.
|
||||
// this is needed to avoid duplicating type extractor since it's possible that
|
||||
//the same type is used as an input or output type of more than a single RPC method
|
||||
// the same type is used as an input or output type of more than a single RPC
|
||||
// method
|
||||
std::set<std::string> encounteredTypes;
|
||||
|
||||
for (int i = 0; i < service->method_count(); ++i) {
|
||||
@@ -351,8 +342,10 @@ static void PrintMethodFields(Printer* p, VARS& vars,
|
||||
vars["method_field_name"] = MethodPropertiesFieldName(method.get());
|
||||
vars["method_new_field_name"] = MethodPropertiesGetterName(method.get());
|
||||
vars["method_method_name"] = MethodPropertiesGetterName(method.get());
|
||||
bool client_streaming = method->ClientStreaming() || method->BidiStreaming();
|
||||
bool server_streaming = method->ServerStreaming() || method->BidiStreaming();
|
||||
bool client_streaming =
|
||||
method->ClientStreaming() || method->BidiStreaming();
|
||||
bool server_streaming =
|
||||
method->ServerStreaming() || method->BidiStreaming();
|
||||
if (client_streaming) {
|
||||
if (server_streaming) {
|
||||
vars["method_type"] = "BIDI_STREAMING";
|
||||
@@ -499,9 +492,7 @@ static void PrintStub(Printer* p, VARS& vars, const ServiceDescriptor* service,
|
||||
vars["client_name"] = client_name;
|
||||
|
||||
// Class head
|
||||
if (!interface) {
|
||||
GrpcWriteServiceDocComment(p, vars, service);
|
||||
}
|
||||
if (!interface) { GrpcWriteServiceDocComment(p, vars, service); }
|
||||
if (impl_base) {
|
||||
p->Print(vars,
|
||||
"public static abstract class $abstract_name$ implements "
|
||||
@@ -544,8 +535,10 @@ static void PrintStub(Printer* p, VARS& vars, const ServiceDescriptor* service,
|
||||
vars["output_type"] = JavaClassName(vars, method->get_output_type_name());
|
||||
vars["lower_method_name"] = LowerMethodName(&*method);
|
||||
vars["method_method_name"] = MethodPropertiesGetterName(&*method);
|
||||
bool client_streaming = method->ClientStreaming() || method->BidiStreaming();
|
||||
bool server_streaming = method->ServerStreaming() || method->BidiStreaming();
|
||||
bool client_streaming =
|
||||
method->ClientStreaming() || method->BidiStreaming();
|
||||
bool server_streaming =
|
||||
method->ServerStreaming() || method->BidiStreaming();
|
||||
|
||||
if (call_type == BLOCKING_CALL && client_streaming) {
|
||||
// Blocking client interface with client streaming is not available
|
||||
@@ -561,9 +554,7 @@ static void PrintStub(Printer* p, VARS& vars, const ServiceDescriptor* service,
|
||||
p->Print("\n");
|
||||
// TODO(nmittler): Replace with WriteMethodDocComment once included by the
|
||||
// protobuf distro.
|
||||
if (!interface) {
|
||||
GrpcWriteMethodDocComment(p, vars, &*method);
|
||||
}
|
||||
if (!interface) { GrpcWriteMethodDocComment(p, vars, &*method); }
|
||||
p->Print("public ");
|
||||
switch (call_type) {
|
||||
case BLOCKING_CALL:
|
||||
@@ -628,8 +619,7 @@ static void PrintStub(Printer* p, VARS& vars, const ServiceDescriptor* service,
|
||||
"responseObserver);\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
} else if (!interface) {
|
||||
switch (call_type) {
|
||||
@@ -755,9 +745,7 @@ static void PrintMethodHandlerClass(Printer* p, VARS& vars,
|
||||
|
||||
for (int i = 0; i < service->method_count(); ++i) {
|
||||
auto method = service->method(i);
|
||||
if (method->ClientStreaming() || method->BidiStreaming()) {
|
||||
continue;
|
||||
}
|
||||
if (method->ClientStreaming() || method->BidiStreaming()) { continue; }
|
||||
vars["method_id_name"] = MethodIdFieldName(&*method);
|
||||
vars["lower_method_name"] = LowerMethodName(&*method);
|
||||
vars["input_type"] = JavaClassName(vars, method->get_input_type_name());
|
||||
@@ -789,9 +777,7 @@ static void PrintMethodHandlerClass(Printer* p, VARS& vars,
|
||||
|
||||
for (int i = 0; i < service->method_count(); ++i) {
|
||||
auto method = service->method(i);
|
||||
if (!(method->ClientStreaming() || method->BidiStreaming())) {
|
||||
continue;
|
||||
}
|
||||
if (!(method->ClientStreaming() || method->BidiStreaming())) { continue; }
|
||||
vars["method_id_name"] = MethodIdFieldName(&*method);
|
||||
vars["lower_method_name"] = LowerMethodName(&*method);
|
||||
vars["input_type"] = JavaClassName(vars, method->get_input_type_name());
|
||||
@@ -925,8 +911,10 @@ static void PrintBindServiceMethodBody(Printer* p, VARS& vars,
|
||||
vars["input_type"] = JavaClassName(vars, method->get_input_type_name());
|
||||
vars["output_type"] = JavaClassName(vars, method->get_output_type_name());
|
||||
vars["method_id_name"] = MethodIdFieldName(&*method);
|
||||
bool client_streaming = method->ClientStreaming() || method->BidiStreaming();
|
||||
bool server_streaming = method->ServerStreaming() || method->BidiStreaming();
|
||||
bool client_streaming =
|
||||
method->ClientStreaming() || method->BidiStreaming();
|
||||
bool server_streaming =
|
||||
method->ServerStreaming() || method->BidiStreaming();
|
||||
if (client_streaming) {
|
||||
if (server_streaming) {
|
||||
vars["calls_method"] = "asyncBidiStreamingCall";
|
||||
|
||||
Reference in New Issue
Block a user