Run clang-format

pull/14490/head
Muxi Yan 7 years ago
parent a7ad717d0a
commit 3d35c54620
  1. 31
      src/compiler/objective_c_generator.cc
  2. 9
      src/compiler/objective_c_generator_helpers.h
  3. 39
      src/compiler/objective_c_plugin.cc

@ -249,8 +249,9 @@ void PrintMethodImplementations(Printer* printer,
printer.Print(vars,
"@interface $service_class$ :"
" GRPCProtoService<$service_class$>\n");
printer.Print("- (instancetype)initWithHost:(NSString *)host"
" NS_DESIGNATED_INITIALIZER;\n");
printer.Print(
"- (instancetype)initWithHost:(NSString *)host"
" NS_DESIGNATED_INITIALIZER;\n");
printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n");
printer.Print("@end\n");
@ -279,18 +280,20 @@ void PrintMethodImplementations(Printer* printer,
" return self;\n"
"}\n\n");
printer.Print("// Override superclass initializer to disallow different"
" package and service names.\n"
"- (instancetype)initWithHost:(NSString *)host\n"
" packageName:(NSString *)packageName\n"
" serviceName:(NSString *)serviceName {\n"
" return [self initWithHost:host];\n"
"}\n\n");
printer.Print("#pragma mark - Class Methods\n\n"
"+ (instancetype)serviceWithHost:(NSString *)host {\n"
" return [[self alloc] initWithHost:host];\n"
"}\n\n");
printer.Print(
"// Override superclass initializer to disallow different"
" package and service names.\n"
"- (instancetype)initWithHost:(NSString *)host\n"
" packageName:(NSString *)packageName\n"
" serviceName:(NSString *)serviceName {\n"
" return [self initWithHost:host];\n"
"}\n\n");
printer.Print(
"#pragma mark - Class Methods\n\n"
"+ (instancetype)serviceWithHost:(NSString *)host {\n"
" return [[self alloc] initWithHost:host];\n"
"}\n\n");
printer.Print("#pragma mark - Method Implementations\n\n");

@ -41,18 +41,17 @@ inline string ServiceClassName(const ServiceDescriptor* service) {
return prefix + service->name();
}
inline ::grpc::string LocalImport(const ::grpc::string &import) {
inline ::grpc::string LocalImport(const ::grpc::string& import) {
return ::grpc::string("#import \"" + import + "\"\n");
}
inline ::grpc::string SystemImport(const ::grpc::string &import) {
inline ::grpc::string SystemImport(const ::grpc::string& import) {
return ::grpc::string("#import <" + import + ">\n");
}
inline ::grpc::string PreprocConditional(::grpc::string symbol, bool invert) {
return invert
? "!defined(" + symbol + ") || !" + symbol
: "defined(" + symbol + ") && " + symbol;
return invert ? "!defined(" + symbol + ") || !" + symbol
: "defined(" + symbol + ") && " + symbol;
}
inline ::grpc::string PreprocIf(const ::grpc::string& symbol,

@ -37,8 +37,7 @@ using ::grpc_objective_c_generator::SystemImport;
namespace {
inline ::grpc::string ImportProtoHeaders(
const grpc::protobuf::FileDescriptor* dep,
const char *indent) {
const grpc::protobuf::FileDescriptor* dep, const char* indent) {
::grpc::string header = grpc_objective_c_generator::MessageHeaderName(dep);
if (!IsProtobufLibraryBundledProtoFile(dep)) {
@ -58,13 +57,13 @@ inline ::grpc::string ImportProtoHeaders(
indent + LocalImport(header));
}
} // namespace
class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
public:
ObjectiveCGrpcGenerator() {}
virtual ~ObjectiveCGrpcGenerator() {}
public:
virtual bool Generate(const grpc::protobuf::FileDescriptor* file,
const ::grpc::string& parameter,
@ -89,11 +88,10 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
::grpc::string imports = LocalImport(file_name + ".pbobjc.h");
::grpc::string system_imports =
SystemImport("ProtoRPC/ProtoService.h") +
SystemImport("ProtoRPC/ProtoRPC.h") +
SystemImport("RxLibrary/GRXWriteable.h") +
SystemImport("RxLibrary/GRXWriter.h");
::grpc::string system_imports = SystemImport("ProtoRPC/ProtoService.h") +
SystemImport("ProtoRPC/ProtoRPC.h") +
SystemImport("RxLibrary/GRXWriteable.h") +
SystemImport("RxLibrary/GRXWriter.h");
::grpc::string forward_declarations = "@class GRPCProtoCall;\n\n";
@ -119,24 +117,21 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
Write(context, file_name + ".pbrpc.h",
PreprocIfNot(kForwardDeclare, imports) + "\n" +
PreprocIfNot(kProtocolOnly, system_imports) + "\n" +
PreprocIfElse(kForwardDeclare, class_declarations,
class_imports) + "\n" +
forward_declarations + "\n" +
kNonNullBegin + "\n" +
protocols + "\n" +
PreprocIfNot(kProtocolOnly, interfaces) + "\n" +
kNonNullEnd + "\n");
PreprocIfNot(kProtocolOnly, system_imports) + "\n" +
PreprocIfElse(kForwardDeclare, class_declarations,
class_imports) +
"\n" + forward_declarations + "\n" + kNonNullBegin + "\n" +
protocols + "\n" + PreprocIfNot(kProtocolOnly, interfaces) +
"\n" + kNonNullEnd + "\n");
}
{
// Generate .pbrpc.m
::grpc::string imports =
LocalImport(file_name + ".pbrpc.h") +
LocalImport(file_name + ".pbobjc.h") +
SystemImport("ProtoRPC/ProtoRPC.h") +
SystemImport("RxLibrary/GRXWriter+Immediate.h");
::grpc::string imports = LocalImport(file_name + ".pbrpc.h") +
LocalImport(file_name + ".pbobjc.h") +
SystemImport("ProtoRPC/ProtoRPC.h") +
SystemImport("RxLibrary/GRXWriter+Immediate.h");
::grpc::string class_imports;
for (int i = 0; i < file->dependency_count(); i++) {
@ -151,7 +146,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
Write(context, file_name + ".pbrpc.m",
PreprocIfNot(kProtocolOnly,
imports + "\n" + class_imports + "\n" + definitions));
imports + "\n" + class_imports + "\n" + definitions));
}
return true;

Loading…
Cancel
Save