diff --git a/src/idl_gen_grpc.cpp b/src/idl_gen_grpc.cpp index 5bd0b0362..52926821d 100644 --- a/src/idl_gen_grpc.cpp +++ b/src/idl_gen_grpc.cpp @@ -154,6 +154,9 @@ class FlatBufPrinter : public grpc_generator::Printer { } void Print(const char *s) { + if (s == nullptr || std::strlen(s) == 0) { + return; + } // Add this string, but for each part separated by \n, add indentation. for (;;) { // Current indentation. diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs index 516b764ef..78871d504 100644 Binary files a/tests/monster_test.bfbs and b/tests/monster_test.bfbs differ diff --git a/tests/monster_test.grpc.fb.h b/tests/monster_test.grpc.fb.h index a838e5323..d55eb227d 100644 --- a/tests/monster_test.grpc.fb.h +++ b/tests/monster_test.grpc.fb.h @@ -36,17 +36,17 @@ class MonsterStorage final { class StubInterface { public: virtual ~StubInterface() {} - virtual ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::BufferRef& request, flatbuffers::BufferRef* response) = 0; + virtual ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::BufferRef& request, flatbuffers::BufferRef* response) = 0; std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::BufferRef& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef>>(AsyncStoreRaw(context, request, cq)); } - std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::BufferRef>> Retrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef& request) { + std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::BufferRef>> Retrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef& request) { return std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::BufferRef>>(RetrieveRaw(context, request)); } std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::BufferRef>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef& request, ::grpc::CompletionQueue* cq, void* tag) { return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::BufferRef>>(AsyncRetrieveRaw(context, request, cq, tag)); } - private: + private: virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientReaderInterface< flatbuffers::BufferRef>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef& request) = 0; virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::BufferRef>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef& request, ::grpc::CompletionQueue* cq, void* tag) = 0; @@ -79,9 +79,9 @@ class MonsterStorage final { public: Service(); virtual ~Service(); - virtual ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::BufferRef* request, flatbuffers::BufferRef* response); - virtual ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef* request, ::grpc::ServerWriter< flatbuffers::BufferRef>* writer); - }; + virtual ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::BufferRef* request, flatbuffers::BufferRef* response); + virtual ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef* request, ::grpc::ServerWriter< flatbuffers::BufferRef>* writer); + }; template class WithAsyncMethod_Store : public BaseClass { private: