Merge pull request #15263 from muxi/backport-15262

Backport 15262: Provide protocol for initializer of generated messages
pull/15367/head v1.12.0-pre1
Muxi Yan 7 years ago committed by GitHub
commit dbb941b3ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/compiler/objective_c_generator.cc

@ -222,7 +222,8 @@ void PrintMethodImplementations(Printer* printer,
map< ::grpc::string, ::grpc::string> vars = { map< ::grpc::string, ::grpc::string> vars = {
{"service_class", ServiceClassName(service)}}; {"service_class", ServiceClassName(service)}};
printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n"); printer.Print(
vars, "@protocol $service_class$ <NSObject, GRPCProtoServiceInit>\n\n");
for (int i = 0; i < service->method_count(); i++) { for (int i = 0; i < service->method_count(); i++) {
PrintMethodDeclarations(&printer, service->method(i)); PrintMethodDeclarations(&printer, service->method(i));
} }
@ -248,7 +249,7 @@ void PrintMethodImplementations(Printer* printer,
" */\n"); " */\n");
printer.Print(vars, printer.Print(vars,
"@interface $service_class$ :" "@interface $service_class$ :"
" GRPCProtoService<$service_class$, GRPCProtoServiceInit>\n"); " GRPCProtoService<$service_class$>\n");
printer.Print( printer.Print(
"- (instancetype)initWithHost:(NSString *)host" "- (instancetype)initWithHost:(NSString *)host"
" NS_DESIGNATED_INITIALIZER;\n"); " NS_DESIGNATED_INITIALIZER;\n");

Loading…
Cancel
Save