aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2016-08-04 11:48:47 -0700
committerGravatar Vijay Pai <vpai@google.com>2016-08-04 11:48:47 -0700
commit5d94118d0d3e11b0333251fec219e4571f6a20e7 (patch)
treec2dc27be0b7e98bd3710a57bcd4581e95e74e863
parentff91dea14999225e5f6c9bcf565f28ee3acce6dd (diff)
clang-format
-rw-r--r--include/grpc++/impl/codegen/fc_unary.h26
-rw-r--r--include/grpc++/impl/codegen/method_handler_impl.h19
-rw-r--r--include/grpc++/impl/codegen/rpc_method.h2
-rw-r--r--include/grpc++/impl/codegen/rpc_service_method.h2
-rw-r--r--include/grpc++/impl/codegen/service_type.h2
-rw-r--r--include/grpc++/impl/codegen/sync_stream.h25
-rw-r--r--src/compiler/cpp_generator.cc45
-rw-r--r--test/cpp/end2end/hybrid_end2end_test.cc22
8 files changed, 81 insertions, 62 deletions
diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h
index 9dbc4024bf..a423f1f0b3 100644
--- a/include/grpc++/impl/codegen/fc_unary.h
+++ b/include/grpc++/impl/codegen/fc_unary.h
@@ -51,28 +51,36 @@ namespace grpc {
/// and exactly 1 Write, in that order, to function correctly.
/// Otherwise, the RPC is in error.
template <class RequestType, class ResponseType>
- class FCUnary GRPC_FINAL : public ServerReaderWriterInterface<ResponseType, RequestType> {
-public:
- FCUnary(Call* call, ServerContext* ctx): ServerReaderWriterInterface<ResponseType,RequestType>(call, ctx) , read_done_(false), write_done_(false) {}
+class FCUnary GRPC_FINAL
+ : public ServerReaderWriterInterface<ResponseType, RequestType> {
+ public:
+ FCUnary(Call* call, ServerContext* ctx)
+ : ServerReaderWriterInterface<ResponseType, RequestType>(call, ctx),
+ read_done_(false),
+ write_done_(false) {}
~FCUnary() {}
- bool Read(RequestType *request) GRPC_OVERRIDE {
+ bool Read(RequestType* request) GRPC_OVERRIDE {
if (read_done_) {
- return false;
+ return false;
}
read_done_ = true;
- return ServerReaderWriterInterface<ResponseType,RequestType>::Read(request);
+ return ServerReaderWriterInterface<ResponseType, RequestType>::Read(
+ request);
}
using WriterInterface<ResponseType>::Write;
- bool Write(const ResponseType& response, const WriteOptions& options) GRPC_OVERRIDE {
+ bool Write(const ResponseType& response,
+ const WriteOptions& options) GRPC_OVERRIDE {
if (write_done_ || !read_done_) {
- return false;
+ return false;
}
write_done_ = true;
- return ServerReaderWriterInterface<ResponseType,RequestType>::Write(response, options);
+ return ServerReaderWriterInterface<ResponseType, RequestType>::Write(
+ response, options);
}
+
private:
bool read_done_;
bool write_done_;
diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h
index 14247b1f03..9c3af53b3a 100644
--- a/include/grpc++/impl/codegen/method_handler_impl.h
+++ b/include/grpc++/impl/codegen/method_handler_impl.h
@@ -207,19 +207,20 @@ class BidiStreamingHandler : public MethodHandler {
// specifically to apply to the flow-controlled implementation of a unary
// method.
/// The argument to the constructor should be a member function already
-/// bound to the appropriate service instance. The declaration gets too complicated
+/// bound to the appropriate service instance. The declaration gets too
+/// complicated
/// otherwise.
template <class ServiceType, class RequestType, class ResponseType>
class FCUnaryMethodHandler : public MethodHandler {
public:
- FCUnaryMethodHandler(std::function<Status(ServerContext*,
- FCUnary<RequestType,ResponseType>*)>
- func)
- : func_(func) {}
+ FCUnaryMethodHandler(
+ std::function<Status(ServerContext*, FCUnary<RequestType, ResponseType>*)>
+ func)
+ : func_(func) {}
void RunHandler(const HandlerParameter& param) GRPC_FINAL {
FCUnary<RequestType, ResponseType> fc_unary(param.call,
- param.server_context);
+ param.server_context);
Status status = func_(param.server_context, &fc_unary);
if (!param.server_context->sent_initial_metadata_) {
// means that the write never happened, which is bad
@@ -230,11 +231,11 @@ class FCUnaryMethodHandler : public MethodHandler {
param.call->cq()->Pluck(&ops);
}
}
+
private:
// Application provided rpc handler function, already bound to its service.
- std::function<Status(ServerContext*,
- FCUnary<RequestType, ResponseType>*)>
- func_;
+ std::function<Status(ServerContext*, FCUnary<RequestType, ResponseType>*)>
+ func_;
};
// Handle unknown method by returning UNIMPLEMENTED error.
diff --git a/include/grpc++/impl/codegen/rpc_method.h b/include/grpc++/impl/codegen/rpc_method.h
index 728ba3e334..b55d755075 100644
--- a/include/grpc++/impl/codegen/rpc_method.h
+++ b/include/grpc++/impl/codegen/rpc_method.h
@@ -47,7 +47,7 @@ class RpcMethod {
CLIENT_STREAMING, // request streaming
SERVER_STREAMING, // response streaming
BIDI_STREAMING,
- FC_UNARY // flow-controlled unary call
+ FC_UNARY // flow-controlled unary call
};
RpcMethod(const char* name, RpcType type)
diff --git a/include/grpc++/impl/codegen/rpc_service_method.h b/include/grpc++/impl/codegen/rpc_service_method.h
index 02da2a2617..52124fba0b 100644
--- a/include/grpc++/impl/codegen/rpc_service_method.h
+++ b/include/grpc++/impl/codegen/rpc_service_method.h
@@ -82,7 +82,7 @@ class RpcServiceMethod : public RpcMethod {
// if MethodHandler is nullptr, then this is an async method
MethodHandler* handler() const { return handler_.get(); }
void ResetHandler() { handler_.reset(); }
- void SetHandler(MethodHandler *handler) { handler_.reset(handler); }
+ void SetHandler(MethodHandler* handler) { handler_.reset(handler); }
private:
void* server_tag_;
diff --git a/include/grpc++/impl/codegen/service_type.h b/include/grpc++/impl/codegen/service_type.h
index c0eeace8a4..dcfc6b01b7 100644
--- a/include/grpc++/impl/codegen/service_type.h
+++ b/include/grpc++/impl/codegen/service_type.h
@@ -149,7 +149,7 @@ class Service {
void MarkMethodFCUnary(int index, MethodHandler* fc_unary_method) {
GPR_CODEGEN_ASSERT(methods_[index] && methods_[index]->handler() &&
- "Cannot mark an async or generic method as FCUnary");
+ "Cannot mark an async or generic method as FCUnary");
methods_[index]->SetMethodType(::grpc::RpcMethod::FC_UNARY);
methods_[index]->SetHandler(fc_unary_method);
}
diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h
index 2e63479961..d9b7e6fec5 100644
--- a/include/grpc++/impl/codegen/sync_stream.h
+++ b/include/grpc++/impl/codegen/sync_stream.h
@@ -71,7 +71,7 @@ class ReaderInterface {
virtual ~ReaderInterface() {}
/// Upper bound on the next message size available for reading on this stream
- virtual bool NextMessageSize(uint32_t *sz) = 0;
+ virtual bool NextMessageSize(uint32_t* sz) = 0;
/// Blocking read a message and parse to \a msg. Returns \a true on success.
/// This is thread-safe with respect to \a Write or \WritesDone methods on
@@ -151,7 +151,7 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface<R> {
cq_.Pluck(&ops); /// status ignored
}
- bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE {
+ bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE {
*sz = call_.max_message_size();
return true;
}
@@ -301,7 +301,7 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> {
cq_.Pluck(&ops); // status ignored
}
- bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE {
+ bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE {
*sz = call_.max_message_size();
return true;
}
@@ -368,7 +368,7 @@ class ServerReader GRPC_FINAL : public ReaderInterface<R> {
call_->cq()->Pluck(&ops);
}
- bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE {
+ bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE {
*sz = call_->max_message_size();
return true;
}
@@ -431,8 +431,9 @@ class ServerWriter GRPC_FINAL : public WriterInterface<W> {
template <class W, class R>
class ServerReaderWriterInterface : public WriterInterface<W>,
public ReaderInterface<R> {
-public:
- ServerReaderWriterInterface(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {}
+ public:
+ ServerReaderWriterInterface(Call* call, ServerContext* ctx)
+ : call_(call), ctx_(ctx) {}
virtual void SendInitialMetadata() {
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
@@ -447,7 +448,7 @@ public:
call_->cq()->Pluck(&ops);
}
- virtual bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE {
+ virtual bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE {
*sz = call_->max_message_size();
return true;
}
@@ -476,15 +477,17 @@ public:
call_->PerformOps(&ops);
return call_->cq()->Pluck(&ops);
}
-private:
+
+ private:
Call* const call_;
ServerContext* const ctx_;
};
template <class W, class R>
-class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface<W,R> {
-public:
- ServerReaderWriter(Call* call, ServerContext* ctx) : ServerReaderWriterInterface<W,R>(call, ctx) {}
+class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface<W, R> {
+ public:
+ ServerReaderWriter(Call* call, ServerContext* ctx)
+ : ServerReaderWriterInterface<W, R>(call, ctx) {}
};
} // namespace grpc
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 29007b5e1d..252a92d971 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -607,8 +607,7 @@ void PrintHeaderServerMethodAsync(Printer *printer, const Method *method,
}
void PrintHeaderServerMethodFCUnary(
- Printer *printer,
- const Method *method,
+ Printer *printer, const Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
@@ -616,24 +615,27 @@ void PrintHeaderServerMethodFCUnary(
if (method->NoStreaming()) {
printer->Print(*vars, "template <class BaseClass>\n");
printer->Print(*vars,
- "class WithFCUnaryMethod_$Method$ : public BaseClass {\n");
+ "class WithFCUnaryMethod_$Method$ : public BaseClass {\n");
printer->Print(
- " private:\n"
- " void BaseClassMustBeDerivedFromService(const Service *service) {}\n");
+ " private:\n"
+ " void BaseClassMustBeDerivedFromService(const Service *service) "
+ "{}\n");
printer->Print(" public:\n");
printer->Indent();
printer->Print(*vars,
- "WithFCUnaryMethod_$Method$() {\n"
- " ::grpc::Service::MarkMethodFCUnary($Idx$,\n"
- " new ::grpc::FCUnaryMethodHandler<Service, "
- "$Request$, "
- "$Response$>("
- "std::bind(&WithFCUnaryMethod_$Method$<BaseClass>::FC$Method$, this, std::placeholders::_1, std::placeholders::_2)));\n"
- "}\n");
+ "WithFCUnaryMethod_$Method$() {\n"
+ " ::grpc::Service::MarkMethodFCUnary($Idx$,\n"
+ " new ::grpc::FCUnaryMethodHandler<Service, "
+ "$Request$, "
+ "$Response$>("
+ "std::bind(&WithFCUnaryMethod_$Method$<BaseClass>::FC$"
+ "Method$, this, std::placeholders::_1, "
+ "std::placeholders::_2)));\n"
+ "}\n");
printer->Print(*vars,
- "~WithFCUnaryMethod_$Method$() GRPC_OVERRIDE {\n"
- " BaseClassMustBeDerivedFromService(this);\n"
- "}\n");
+ "~WithFCUnaryMethod_$Method$() GRPC_OVERRIDE {\n"
+ " BaseClassMustBeDerivedFromService(this);\n"
+ "}\n");
printer->Print(
*vars,
"// disable regular version of this method\n"
@@ -643,12 +645,12 @@ void PrintHeaderServerMethodFCUnary(
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
- printer->Print(
- *vars,
- "// replace default version of this method with FCUnary\n"
- "virtual ::grpc::Status FC$Method$("
- "::grpc::ServerContext* context, ::grpc::FCUnary< $Request$,$Response$>* fc_unary)"
- " = 0;\n");
+ printer->Print(*vars,
+ "// replace default version of this method with FCUnary\n"
+ "virtual ::grpc::Status FC$Method$("
+ "::grpc::ServerContext* context, ::grpc::FCUnary< "
+ "$Request$,$Response$>* fc_unary)"
+ " = 0;\n");
printer->Outdent();
printer->Print(*vars, "};\n");
}
@@ -841,7 +843,6 @@ void PrintHeaderService(Printer *printer, const Service *service,
}
printer->Print(" FCUnaryService;\n");
-
printer->Outdent();
printer->Print("};\n");
printer->Print(service->GetTrailingComments().c_str());
diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc
index a1a964a9d3..1512e99a3c 100644
--- a/test/cpp/end2end/hybrid_end2end_test.cc
+++ b/test/cpp/end2end/hybrid_end2end_test.cc
@@ -199,7 +199,8 @@ class HybridEnd2endTest : public ::testing::Test {
HybridEnd2endTest() {}
void SetUpServer(::grpc::Service* service1, ::grpc::Service* service2,
- AsyncGenericService* generic_service, int max_message_size = 0) {
+ AsyncGenericService* generic_service,
+ int max_message_size = 0) {
int port = grpc_pick_unused_port_or_die();
server_address_ << "localhost:" << port;
@@ -421,9 +422,11 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) {
}
// Add a second service with one sync FCUnary method.
-class FCUnaryDupPkg : public duplicate::EchoTestService::WithFCUnaryMethod_Echo<TestServiceImplDupPkg> {
-public:
- Status FCEcho(ServerContext* context, FCUnary<EchoRequest,EchoResponse>* fc_unary) GRPC_OVERRIDE {
+class FCUnaryDupPkg : public duplicate::EchoTestService::WithFCUnaryMethod_Echo<
+ TestServiceImplDupPkg> {
+ public:
+ Status FCEcho(ServerContext* context,
+ FCUnary<EchoRequest, EchoResponse>* fc_unary) GRPC_OVERRIDE {
EchoRequest req;
EchoResponse resp;
uint32_t next_msg_sz;
@@ -436,7 +439,8 @@ public:
}
};
-TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFCUnaryDupService) {
+TEST_F(HybridEnd2endTest,
+ AsyncRequestStreamResponseStream_SyncFCUnaryDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;
@@ -456,8 +460,9 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFCUnaryDupService
// Add a second service that is fully FCUnary
class FullyFCUnaryDupPkg : public duplicate::EchoTestService::FCUnaryService {
-public:
- Status FCEcho(ServerContext* context, FCUnary<EchoRequest,EchoResponse>* fc_unary) GRPC_OVERRIDE {
+ public:
+ Status FCEcho(ServerContext* context,
+ FCUnary<EchoRequest, EchoResponse>* fc_unary) GRPC_OVERRIDE {
EchoRequest req;
EchoResponse resp;
uint32_t next_msg_sz;
@@ -470,7 +475,8 @@ public:
}
};
-TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFullyFCUnaryDupService) {
+TEST_F(HybridEnd2endTest,
+ AsyncRequestStreamResponseStream_SyncFullyFCUnaryDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<
EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
SType;