|
|
|
@ -238,19 +238,21 @@ void PrintV2Implementation(Printer* printer, const MethodDescriptor* method, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PrintMethodImplementations(Printer* printer, |
|
|
|
|
const MethodDescriptor* method) { |
|
|
|
|
const MethodDescriptor* method, |
|
|
|
|
const Parameters& generator_params) { |
|
|
|
|
map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method); |
|
|
|
|
|
|
|
|
|
PrintProtoRpcDeclarationAsPragma(printer, method, vars); |
|
|
|
|
|
|
|
|
|
// TODO(jcanizales): Print documentation from the method.
|
|
|
|
|
printer->Print("// Deprecated methods.\n"); |
|
|
|
|
PrintSimpleSignature(printer, method, vars); |
|
|
|
|
PrintSimpleImplementation(printer, method, vars); |
|
|
|
|
if (!generator_params.no_v1_compatibility) { |
|
|
|
|
// TODO(jcanizales): Print documentation from the method.
|
|
|
|
|
PrintSimpleSignature(printer, method, vars); |
|
|
|
|
PrintSimpleImplementation(printer, method, vars); |
|
|
|
|
|
|
|
|
|
printer->Print("// Returns a not-yet-started RPC object.\n"); |
|
|
|
|
PrintAdvancedSignature(printer, method, vars); |
|
|
|
|
PrintAdvancedImplementation(printer, method, vars); |
|
|
|
|
printer->Print("// Returns a not-yet-started RPC object.\n"); |
|
|
|
|
PrintAdvancedSignature(printer, method, vars); |
|
|
|
|
PrintAdvancedImplementation(printer, method, vars); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
PrintV2Signature(printer, method, vars); |
|
|
|
|
PrintV2Implementation(printer, method, vars); |
|
|
|
@ -276,9 +278,11 @@ void PrintMethodImplementations(Printer* printer, |
|
|
|
|
return output; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
::grpc::string GetProtocol(const ServiceDescriptor* service) { |
|
|
|
|
::grpc::string GetProtocol(const ServiceDescriptor* service, const Parameters& generator_params) { |
|
|
|
|
::grpc::string output; |
|
|
|
|
|
|
|
|
|
if (generator_params.no_v1_compatibility) return output; |
|
|
|
|
|
|
|
|
|
// Scope the output stream so it closes and finalizes output to the string.
|
|
|
|
|
grpc::protobuf::io::StringOutputStream output_stream(&output); |
|
|
|
|
Printer printer(&output_stream, '$'); |
|
|
|
@ -292,7 +296,7 @@ void PrintMethodImplementations(Printer* printer, |
|
|
|
|
"that have been deprecated. They do not\n" |
|
|
|
|
" * recognize call options provided in the initializer. Using " |
|
|
|
|
"the v2 protocol is recommended.\n" |
|
|
|
|
" */\n"); |
|
|
|
|
" */\n\n"); |
|
|
|
|
printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n"); |
|
|
|
|
for (int i = 0; i < service->method_count(); i++) { |
|
|
|
|
PrintMethodDeclarations(&printer, service->method(i)); |
|
|
|
@ -321,7 +325,7 @@ void PrintMethodImplementations(Printer* printer, |
|
|
|
|
return output; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
::grpc::string GetInterface(const ServiceDescriptor* service) { |
|
|
|
|
::grpc::string GetInterface(const ServiceDescriptor* service, const Parameters& generator_params) { |
|
|
|
|
::grpc::string output; |
|
|
|
|
|
|
|
|
|
// Scope the output stream so it closes and finalizes output to the string.
|
|
|
|
@ -338,7 +342,11 @@ void PrintMethodImplementations(Printer* printer, |
|
|
|
|
" */\n"); |
|
|
|
|
printer.Print(vars, |
|
|
|
|
"@interface $service_class$ :" |
|
|
|
|
" GRPCProtoService<$service_class$, $service_class$2>\n"); |
|
|
|
|
" GRPCProtoService<$service_class$2"); |
|
|
|
|
if (!generator_params.no_v1_compatibility) { |
|
|
|
|
printer.Print(vars, ", $service_class$"); |
|
|
|
|
} |
|
|
|
|
printer.Print(">\n"); |
|
|
|
|
printer.Print( |
|
|
|
|
"- (instancetype)initWithHost:(NSString *)host " |
|
|
|
|
"callOptions:(GRPCCallOptions " |
|
|
|
@ -347,17 +355,19 @@ void PrintMethodImplementations(Printer* printer, |
|
|
|
|
printer.Print( |
|
|
|
|
"+ (instancetype)serviceWithHost:(NSString *)host " |
|
|
|
|
"callOptions:(GRPCCallOptions *_Nullable)callOptions;\n"); |
|
|
|
|
printer.Print( |
|
|
|
|
"// The following methods belong to a set of old APIs that have been " |
|
|
|
|
"deprecated.\n"); |
|
|
|
|
printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); |
|
|
|
|
printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); |
|
|
|
|
if (!generator_params.no_v1_compatibility) { |
|
|
|
|
printer.Print( |
|
|
|
|
"// The following methods belong to a set of old APIs that have been " |
|
|
|
|
"deprecated.\n"); |
|
|
|
|
printer.Print("- (instancetype)initWithHost:(NSString *)host;\n"); |
|
|
|
|
printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); |
|
|
|
|
} |
|
|
|
|
printer.Print("@end\n"); |
|
|
|
|
|
|
|
|
|
return output; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
::grpc::string GetSource(const ServiceDescriptor* service) { |
|
|
|
|
::grpc::string GetSource(const ServiceDescriptor* service, const Parameters& generator_params) { |
|
|
|
|
::grpc::string output; |
|
|
|
|
{ |
|
|
|
|
// Scope the output stream so it closes and finalizes output to the string.
|
|
|
|
@ -381,13 +391,16 @@ void PrintMethodImplementations(Printer* printer, |
|
|
|
|
" packageName:@\"$package$\"\n" |
|
|
|
|
" serviceName:@\"$service_name$\"\n" |
|
|
|
|
" callOptions:callOptions];\n" |
|
|
|
|
"}\n\n" |
|
|
|
|
"- (instancetype)initWithHost:(NSString *)host {\n" |
|
|
|
|
" return [super initWithHost:host\n" |
|
|
|
|
" packageName:@\"$package$\"\n" |
|
|
|
|
" serviceName:@\"$service_name$\"];\n" |
|
|
|
|
"}\n\n" |
|
|
|
|
"#pragma clang diagnostic pop\n\n"); |
|
|
|
|
"}\n\n"); |
|
|
|
|
if (!generator_params.no_v1_compatibility) { |
|
|
|
|
printer.Print(vars, |
|
|
|
|
"- (instancetype)initWithHost:(NSString *)host {\n" |
|
|
|
|
" return [super initWithHost:host\n" |
|
|
|
|
" packageName:@\"$package$\"\n" |
|
|
|
|
" serviceName:@\"$service_name$\"];\n" |
|
|
|
|
"}\n\n"); |
|
|
|
|
} |
|
|
|
|
printer.Print("#pragma clang diagnostic pop\n\n"); |
|
|
|
|
|
|
|
|
|
printer.Print( |
|
|
|
|
"// Override superclass initializer to disallow different" |
|
|
|
@ -404,11 +417,13 @@ void PrintMethodImplementations(Printer* printer, |
|
|
|
|
" return [self initWithHost:host callOptions:callOptions];\n" |
|
|
|
|
"}\n\n"); |
|
|
|
|
|
|
|
|
|
printer.Print("#pragma mark - Class Methods\n\n"); |
|
|
|
|
if (!generator_params.no_v1_compatibility) { |
|
|
|
|
printer.Print("+ (instancetype)serviceWithHost:(NSString *)host {\n" |
|
|
|
|
" return [[self alloc] 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" |
|
|
|
|
"+ (instancetype)serviceWithHost:(NSString *)host " |
|
|
|
|
"callOptions:(GRPCCallOptions *_Nullable)callOptions {\n" |
|
|
|
|
" return [[self alloc] initWithHost:host callOptions:callOptions];\n" |
|
|
|
@ -417,7 +432,7 @@ void PrintMethodImplementations(Printer* printer, |
|
|
|
|
printer.Print("#pragma mark - Method Implementations\n\n"); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < service->method_count(); i++) { |
|
|
|
|
PrintMethodImplementations(&printer, service->method(i)); |
|
|
|
|
PrintMethodImplementations(&printer, service->method(i), generator_params); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
printer.Print("@end\n"); |
|
|
|
|