@@ -147,7 +147,7 @@ static std::set<std::string> java_keywords = {
147147// - decapitalize the first letter
148148// - remove embedded underscores & capitalize the following letter
149149// Finally, if the result is a reserved java keyword, append an underscore.
150- static std::string MixedLower (const std::string& word) {
150+ static std::string MixedLower (std::string word) {
151151 std::string w;
152152 w += tolower (word[0 ]);
153153 bool after_underscore = false ;
@@ -169,7 +169,7 @@ static std::string MixedLower(const std::string& word) {
169169// - An underscore is inserted where a lower case letter is followed by an
170170// upper case letter.
171171// - All letters are converted to upper case
172- static std::string ToAllUpperCase (const std::string& word) {
172+ static std::string ToAllUpperCase (std::string word) {
173173 std::string w;
174174 for (size_t i = 0 ; i < word.length (); ++i) {
175175 w += toupper (word[i]);
@@ -181,19 +181,19 @@ static std::string ToAllUpperCase(const std::string& word) {
181181}
182182
183183static inline std::string LowerMethodName (const MethodDescriptor* method) {
184- return MixedLower (method->name ());
184+ return MixedLower (std::string ( method->name () ));
185185}
186186
187187static inline std::string MethodPropertiesFieldName (const MethodDescriptor* method) {
188- return " METHOD_" + ToAllUpperCase (method->name ());
188+ return " METHOD_" + ToAllUpperCase (std::string ( method->name () ));
189189}
190190
191191static inline std::string MethodPropertiesGetterName (const MethodDescriptor* method) {
192- return MixedLower (" get_" + method->name () + " _method" );
192+ return MixedLower (" get_" + std::string ( method->name () ) + " _method" );
193193}
194194
195195static inline std::string MethodIdFieldName (const MethodDescriptor* method) {
196- return " METHODID_" + ToAllUpperCase (method->name ());
196+ return " METHODID_" + ToAllUpperCase (std::string ( method->name () ));
197197}
198198
199199static inline std::string MessageFullJavaName (const Descriptor* desc) {
@@ -406,7 +406,7 @@ static void GrpcWriteServiceDocComment(Printer* printer,
406406 StubType type) {
407407 printer->Print (" /**\n " );
408408
409- std::map<std::string, std::string> vars = {{" service" , service->name ()}};
409+ std::map<std::string, std::string> vars = {{" service" , std::string ( service->name () )}};
410410 switch (type) {
411411 case ASYNC_CLIENT_IMPL:
412412 printer->Print (vars, " * A stub to allow clients to do asynchronous rpc calls to service $service$.\n " );
@@ -520,7 +520,8 @@ static void PrintMethodFields(
520520 " .setResponseMarshaller($ProtoUtils$.marshaller(\n "
521521 " $output_type$.getDefaultInstance()))\n " );
522522
523- (*vars)[" proto_method_descriptor_supplier" ] = service->name () + " MethodDescriptorSupplier" ;
523+ (*vars)[" proto_method_descriptor_supplier" ]
524+ = std::string (service->name ()) + " MethodDescriptorSupplier" ;
524525 if (flavor == ProtoFlavor::NORMAL) {
525526 p->Print (
526527 *vars,
@@ -583,7 +584,7 @@ static void PrintStub(
583584 const ServiceDescriptor* service,
584585 std::map<std::string, std::string>* vars,
585586 Printer* p, StubType type) {
586- const std::string service_name = service->name ();
587+ std::string service_name = std::string ( service->name () );
587588 (*vars)[" service_name" ] = service_name;
588589 std::string stub_name = service_name;
589590 std::string stub_base_class_name = " AbstractStub" ;
@@ -887,8 +888,7 @@ static void PrintAbstractClassStub(
887888 const ServiceDescriptor* service,
888889 std::map<std::string, std::string>* vars,
889890 Printer* p) {
890- const std::string service_name = service->name ();
891- (*vars)[" service_name" ] = service_name;
891+ (*vars)[" service_name" ] = service->name ();
892892
893893 GrpcWriteServiceDocComment (p, service, ABSTRACT_CLASS);
894894 if (service->options ().deprecated ()) {
@@ -1022,13 +1022,14 @@ static void PrintGetServiceDescriptorMethod(const ServiceDescriptor* service,
10221022 std::map<std::string, std::string>* vars,
10231023 Printer* p,
10241024 ProtoFlavor flavor) {
1025- (*vars)[" service_name" ] = service->name ();
1025+ std::string service_name = std::string (service->name ());
1026+ (*vars)[" service_name" ] = service_name;
10261027
10271028
10281029 if (flavor == ProtoFlavor::NORMAL) {
1029- (*vars)[" proto_base_descriptor_supplier" ] = service-> name () + " BaseDescriptorSupplier" ;
1030- (*vars)[" proto_file_descriptor_supplier" ] = service-> name () + " FileDescriptorSupplier" ;
1031- (*vars)[" proto_method_descriptor_supplier" ] = service-> name () + " MethodDescriptorSupplier" ;
1030+ (*vars)[" proto_base_descriptor_supplier" ] = service_name + " BaseDescriptorSupplier" ;
1031+ (*vars)[" proto_file_descriptor_supplier" ] = service_name + " FileDescriptorSupplier" ;
1032+ (*vars)[" proto_method_descriptor_supplier" ] = service_name + " MethodDescriptorSupplier" ;
10321033 (*vars)[" proto_class_name" ] = protobuf::compiler::java::ClassName (service->file ());
10331034 p->Print (
10341035 *vars,
@@ -1374,7 +1375,7 @@ std::string ServiceJavaPackage(const FileDescriptor* file) {
13741375}
13751376
13761377std::string ServiceClassName (const ServiceDescriptor* service) {
1377- return service->name () + " Grpc" ;
1378+ return std::string ( service->name () ) + " Grpc" ;
13781379}
13791380
13801381} // namespace java_grpc_generator
0 commit comments