summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLawrence Chan <llchan@users.noreply.github.com>2017-05-12 16:36:35 -0500
committerWouter van Oortmerssen <aardappel@gmail.com>2017-05-12 14:36:35 -0700
commit6a7ec85e83be45efd7ddc4f6a7a34ca099e9f6e7 (patch)
tree3c596b662b30d45ec90526257f4daae3b574f77c
parent81ecc98e023f85fe003a27e920e78b34db8a0087 (diff)
downloadflatbuffers-6a7ec85e83be45efd7ddc4f6a7a34ca099e9f6e7.tar.gz
flatbuffers-6a7ec85e83be45efd7ddc4f6a7a34ca099e9f6e7.tar.bz2
flatbuffers-6a7ec85e83be45efd7ddc4f6a7a34ca099e9f6e7.zip
[C++] Fix code gen indentation when empty Print (#4313)
* Fix C++ code gen indentation when empty Print * Also commit modified tests/monster_test.bfbs
-rw-r--r--src/idl_gen_grpc.cpp3
-rw-r--r--tests/monster_test.bfbsbin4320 -> 4288 bytes
-rw-r--r--tests/monster_test.grpc.fb.h12
3 files changed, 9 insertions, 6 deletions
diff --git a/src/idl_gen_grpc.cpp b/src/idl_gen_grpc.cpp
index 5bd0b036..52926821 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 516b764e..78871d50 100644
--- a/tests/monster_test.bfbs
+++ b/tests/monster_test.bfbs
Binary files differ
diff --git a/tests/monster_test.grpc.fb.h b/tests/monster_test.grpc.fb.h
index a838e532..d55eb227 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<Monster>& request, flatbuffers::BufferRef<Stat>* response) = 0;
+ virtual ::grpc::Status Store(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, flatbuffers::BufferRef<Stat>* response) = 0;
std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Stat>>> AsyncStore(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) {
return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Stat>>>(AsyncStoreRaw(context, request, cq));
}
- std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::BufferRef<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request) {
+ std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::BufferRef<Monster>>> Retrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request) {
return std::unique_ptr< ::grpc::ClientReaderInterface< flatbuffers::BufferRef<Monster>>>(RetrieveRaw(context, request));
}
std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::BufferRef<Monster>>> AsyncRetrieve(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request, ::grpc::CompletionQueue* cq, void* tag) {
return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< flatbuffers::BufferRef<Monster>>>(AsyncRetrieveRaw(context, request, cq, tag));
}
- private:
+ private:
virtual ::grpc::ClientAsyncResponseReaderInterface< flatbuffers::BufferRef<Stat>>* AsyncStoreRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Monster>& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientReaderInterface< flatbuffers::BufferRef<Monster>>* RetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& request) = 0;
virtual ::grpc::ClientAsyncReaderInterface< flatbuffers::BufferRef<Monster>>* AsyncRetrieveRaw(::grpc::ClientContext* context, const flatbuffers::BufferRef<Stat>& 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<Monster>* request, flatbuffers::BufferRef<Stat>* response);
- virtual ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef<Stat>* request, ::grpc::ServerWriter< flatbuffers::BufferRef<Monster>>* writer);
- };
+ virtual ::grpc::Status Store(::grpc::ServerContext* context, const flatbuffers::BufferRef<Monster>* request, flatbuffers::BufferRef<Stat>* response);
+ virtual ::grpc::Status Retrieve(::grpc::ServerContext* context, const flatbuffers::BufferRef<Stat>* request, ::grpc::ServerWriter< flatbuffers::BufferRef<Monster>>* writer);
+ };
template <class BaseClass>
class WithAsyncMethod_Store : public BaseClass {
private: