aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler/php_generator_helpers.h
diff options
context:
space:
mode:
authorGravatar Michael Bausor <michaelbausor@google.com>2017-06-16 15:59:12 -0700
committerGravatar Michael Bausor <michaelbausor@google.com>2017-06-16 15:59:12 -0700
commit0d8b988fbb7d4546675ff3417f2ec27edf5ef70a (patch)
treede9f0d1088561a6df457be3a464a81c4dd05fb02 /src/compiler/php_generator_helpers.h
parent3c3838050eaac83003c39f9228c4f8e2679d645d (diff)
Update PHP protoc plugin generation
- Use docblocks instead of single line comments - Escape '*/' - Indent 4 spaces to match protobuf - Use single line namespace to match protobuf
Diffstat (limited to 'src/compiler/php_generator_helpers.h')
-rw-r--r--src/compiler/php_generator_helpers.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/compiler/php_generator_helpers.h b/src/compiler/php_generator_helpers.h
index 8e35809357..8f59b90d04 100644
--- a/src/compiler/php_generator_helpers.h
+++ b/src/compiler/php_generator_helpers.h
@@ -39,12 +39,25 @@ inline grpc::string GetPHPServiceFilename(
return oss.str() + "/" + service->name() + "Client.php";
}
+// ReplaceAll replaces all instances of search with replace in s.
+inline grpc::string ReplaceAll(grpc::string s, const grpc::string &search,
+ const grpc::string &replace) {
+ size_t pos = 0;
+ while ((pos = s.find(search, pos)) != grpc::string::npos) {
+ s.replace(pos, search.length(), replace);
+ pos += replace.length();
+ }
+ return s;
+}
+
// Get leading or trailing comments in a string. Comment lines start with "// ".
// Leading detached comments are put in in front of leading comments.
template <typename DescriptorType>
inline grpc::string GetPHPComments(const DescriptorType *desc,
grpc::string prefix) {
- return grpc_generator::GetPrefixedComments(desc, true, prefix);
+ return ReplaceAll(grpc_generator::GetPrefixedComments(desc, true, prefix),
+ "*/",
+ "&#42;/");
}
} // namespace grpc_php_generator