From b015dfb55a43b73e0e67e29a2e4d4633023bb13a Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Thu, 13 Aug 2015 18:41:29 -0700 Subject: Add ::grpc:: prefix --- src/compiler/objective_c_generator.cc | 33 ++++++++++++++++----------------- src/compiler/objective_c_plugin.cc | 28 ++++++++++++++-------------- 2 files changed, 30 insertions(+), 31 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index 483c6573a8..7948f51861 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -44,7 +44,6 @@ using ::google::protobuf::compiler::objectivec::ClassName; using ::grpc::protobuf::io::Printer; using ::grpc::protobuf::MethodDescriptor; using ::grpc::protobuf::ServiceDescriptor; -using ::grpc::string; using ::std::map; namespace grpc_objective_c_generator { @@ -52,7 +51,7 @@ namespace { void PrintProtoRpcDeclarationAsPragma(Printer *printer, const MethodDescriptor *method, - map vars) { + map<::grpc::string, ::grpc::string> vars) { vars["client_stream"] = method->client_streaming() ? "stream " : ""; vars["server_stream"] = method->server_streaming() ? "stream " : ""; @@ -62,7 +61,7 @@ void PrintProtoRpcDeclarationAsPragma(Printer *printer, } void PrintMethodSignature(Printer *printer, const MethodDescriptor *method, - const map &vars) { + const map<::grpc::string, ::grpc::string> &vars) { // TODO(jcanizales): Print method comments. printer->Print(vars, "- ($return_type$)$method_name$With"); @@ -85,7 +84,7 @@ void PrintMethodSignature(Printer *printer, const MethodDescriptor *method, } void PrintSimpleSignature(Printer *printer, const MethodDescriptor *method, - map vars) { + map<::grpc::string, ::grpc::string> vars) { vars["method_name"] = grpc_generator::LowercaseFirstLetter(vars["method_name"]); vars["return_type"] = "void"; @@ -93,14 +92,14 @@ void PrintSimpleSignature(Printer *printer, const MethodDescriptor *method, } void PrintAdvancedSignature(Printer *printer, const MethodDescriptor *method, - map vars) { + map<::grpc::string, ::grpc::string> vars) { vars["method_name"] = "RPCTo" + vars["method_name"]; vars["return_type"] = "ProtoRPC *"; PrintMethodSignature(printer, method, vars); } -inline map GetMethodVars(const MethodDescriptor *method) { - map res; +inline map<::grpc::string, ::grpc::string> GetMethodVars(const MethodDescriptor *method) { + map<::grpc::string, ::grpc::string> res; res["method_name"] = method->name(); res["request_type"] = method->input_type()->name(); res["response_type"] = method->output_type()->name(); @@ -110,7 +109,7 @@ inline map GetMethodVars(const MethodDescriptor *method) { } void PrintMethodDeclarations(Printer *printer, const MethodDescriptor *method) { - map vars = GetMethodVars(method); + map<::grpc::string, ::grpc::string> vars = GetMethodVars(method); PrintProtoRpcDeclarationAsPragma(printer, method, vars); @@ -121,7 +120,7 @@ void PrintMethodDeclarations(Printer *printer, const MethodDescriptor *method) { } void PrintSimpleImplementation(Printer *printer, const MethodDescriptor *method, - map vars) { + map<::grpc::string, ::grpc::string> vars) { printer->Print("{\n"); printer->Print(vars, " [[self RPCTo$method_name$With"); if (method->client_streaming()) { @@ -139,7 +138,7 @@ void PrintSimpleImplementation(Printer *printer, const MethodDescriptor *method, void PrintAdvancedImplementation(Printer *printer, const MethodDescriptor *method, - map vars) { + map<::grpc::string, ::grpc::string> vars) { printer->Print("{\n"); printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n"); @@ -164,7 +163,7 @@ void PrintAdvancedImplementation(Printer *printer, void PrintMethodImplementations(Printer *printer, const MethodDescriptor *method) { - map vars = GetMethodVars(method); + map<::grpc::string, ::grpc::string> vars = GetMethodVars(method); PrintProtoRpcDeclarationAsPragma(printer, method, vars); @@ -179,14 +178,14 @@ void PrintMethodImplementations(Printer *printer, } // namespace -string GetHeader(const ServiceDescriptor *service) { - string output; +::grpc::string GetHeader(const ServiceDescriptor *service) { + ::grpc::string 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, '$'); - map vars = {{"service_class", ServiceClassName(service)}}; + map<::grpc::string, ::grpc::string> vars = {{"service_class", ServiceClassName(service)}}; printer.Print(vars, "@protocol $service_class$ \n\n"); @@ -209,14 +208,14 @@ string GetHeader(const ServiceDescriptor *service) { return output; } -string GetSource(const ServiceDescriptor *service) { - string output; +::grpc::string GetSource(const ServiceDescriptor *service) { + ::grpc::string 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, '$'); - map vars = {{"service_name", service->name()}, + map<::grpc::string,::grpc::string> vars = {{"service_name", service->name()}, {"service_class", ServiceClassName(service)}, {"package", service->file()->package()}}; diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc index 10f06ad4df..17440358bb 100644 --- a/src/compiler/objective_c_plugin.cc +++ b/src/compiler/objective_c_plugin.cc @@ -39,44 +39,43 @@ #include "src/compiler/objective_c_generator.h" #include "src/compiler/objective_c_generator_helpers.h" -using ::grpc::string; - class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { public: ObjectiveCGrpcGenerator() {} virtual ~ObjectiveCGrpcGenerator() {} virtual bool Generate(const grpc::protobuf::FileDescriptor *file, - const string ¶meter, + const ::grpc::string ¶meter, grpc::protobuf::compiler::GeneratorContext *context, - string *error) const { + ::grpc::string *error) const { if (file->service_count() == 0) { // No services. Do nothing. return true; } - string file_name = grpc_generator::FileNameInUpperCamel(file); - string prefix = file->options().objc_class_prefix(); + ::grpc::string file_name = grpc_generator::FileNameInUpperCamel(file); + ::grpc::string prefix = file->options().objc_class_prefix(); { // Generate .pbrpc.h - string imports = string("#import \"") + file_name + ".pbobjc.h\"\n\n" + ::grpc::string imports = ::grpc::string("#import \"") + file_name + + ".pbobjc.h\"\n\n" "#import \n" "#import \n" "#import \n"; // TODO(jcanizales): Instead forward-declare the input and output types // and import the files in the .pbrpc.m - string proto_imports; + ::grpc::string proto_imports; for (int i = 0; i < file->dependency_count(); i++) { - string header = grpc_objective_c_generator::MessageHeaderName( + ::grpc::string header = grpc_objective_c_generator::MessageHeaderName( file->dependency(i)); - proto_imports += string("#import \"") + header + "\"\n"; + proto_imports += ::grpc::string("#import \"") + header + "\"\n"; } - string declarations; + ::grpc::string declarations; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor *service = file->service(i); declarations += grpc_objective_c_generator::GetHeader(service); @@ -89,11 +88,12 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { { // Generate .pbrpc.m - string imports = string("#import \"") + file_name + ".pbrpc.h\"\n\n" + ::grpc::string imports = ::grpc::string("#import \"") + file_name + + ".pbrpc.h\"\n\n" "#import \n" "#import \n"; - string definitions; + ::grpc::string definitions; for (int i = 0; i < file->service_count(); i++) { const grpc::protobuf::ServiceDescriptor *service = file->service(i); definitions += grpc_objective_c_generator::GetSource(service); @@ -108,7 +108,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { private: // Write the given code into the given file. void Write(grpc::protobuf::compiler::GeneratorContext *context, - const string &filename, const string &code) const { + const ::grpc::string &filename, const ::grpc::string &code) const { std::unique_ptr output( context->Open(filename)); grpc::protobuf::io::CodedOutputStream coded_out(output.get()); -- cgit v1.2.3