diff options
author | Yang Gao <yangg@google.com> | 2015-02-27 14:35:59 -0800 |
---|---|---|
committer | Yang Gao <yangg@google.com> | 2015-02-27 14:35:59 -0800 |
commit | 5c5992554bc564be865a02b63e160b970eb67d7c (patch) | |
tree | 65a9b841262ff869785d3a748469c8b636b192db /src/compiler/python_generator.cc | |
parent | e21da5e897989d570ad6d27aebee1ca53b7a1a94 (diff) | |
parent | 93fa09812464d5100b23a75dd52906c0ca61efec (diff) |
Merge pull request #880 from nicolasnoble/python-codegen
Removing private protobuf header inclusion.
Diffstat (limited to 'src/compiler/python_generator.cc')
-rw-r--r-- | src/compiler/python_generator.cc | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index ae4d65df4c..b8d4aa509b 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -40,20 +40,19 @@ #include <sstream> #include <vector> +#include "src/compiler/generator_helpers.h" #include "src/compiler/python_generator.h" #include <google/protobuf/io/printer.h> #include <google/protobuf/io/zero_copy_stream_impl_lite.h> #include <google/protobuf/descriptor.pb.h> #include <google/protobuf/descriptor.h> -#include <google/protobuf/stubs/strutil.h> +using grpc_generator::StringReplace; +using grpc_generator::StripProto; using google::protobuf::Descriptor; using google::protobuf::FileDescriptor; -using google::protobuf::HasSuffixString; using google::protobuf::MethodDescriptor; using google::protobuf::ServiceDescriptor; -using google::protobuf::StripString; -using google::protobuf::StripSuffixString; using google::protobuf::io::Printer; using google::protobuf::io::StringOutputStream; using std::initializer_list; @@ -197,18 +196,12 @@ bool PrintStub(const ServiceDescriptor* service, return true; } -// TODO(protobuf team): See TODO for `ModuleName`. -string StripProto(const string& filename) { - const char* suffix = HasSuffixString(filename, ".protodevel") - ? ".protodevel" : ".proto"; - return StripSuffixString(filename, suffix); -} // TODO(protobuf team): Export `ModuleName` from protobuf's // `src/google/protobuf/compiler/python/python_generator.cc` file. string ModuleName(const string& filename) { string basename = StripProto(filename); - StripString(&basename, "-", '_'); - StripString(&basename, "/", '.'); + basename = StringReplace(basename, "-", "_"); + basename = StringReplace(basename, "/", "."); return basename + "_pb2"; } |