aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/python
diff options
context:
space:
mode:
authorKrishna <krishna.nm86@gmail.com>2014-12-10 20:39:34 +0100
committerKrishna <krishna.nm86@gmail.com>2014-12-10 20:39:34 +0100
commita761f061f4cc0e50324261cc1eb12526ae8783e3 (patch)
tree7a9dce2151b0ea3ea51a08e195d04adf12eab164 /src/google/protobuf/compiler/python
parent77931993f4fbb6f7e46327934e1f65c2b4f247eb (diff)
downloadprotobuf-a761f061f4cc0e50324261cc1eb12526ae8783e3.tar.gz
protobuf-a761f061f4cc0e50324261cc1eb12526ae8783e3.tar.bz2
protobuf-a761f061f4cc0e50324261cc1eb12526ae8783e3.zip
Source code refactoring. Extracted common functionality in cpp_helpers.cc and python/python_generator.cc
Diffstat (limited to 'src/google/protobuf/compiler/python')
-rw-r--r--src/google/protobuf/compiler/python/python_generator.cc28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc
index e6faf7ef..508cab0d 100644
--- a/src/google/protobuf/compiler/python/python_generator.cc
+++ b/src/google/protobuf/compiler/python/python_generator.cc
@@ -580,11 +580,9 @@ void Generator::PrintServiceDescriptor(
printer_->Print("])\n\n");
}
-void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const {
- // Print the service.
- printer_->Print("$class_name$ = service_reflection.GeneratedServiceType("
- "'$class_name$', (_service.Service,), dict(\n",
- "class_name", descriptor.name());
+
+void Generator::PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descriptor, string keyandmodule) {
+ printer_->Print(keyandmodule,"class_name", descriptor.name());
printer_->Indent();
printer_->Print(
"$descriptor_key$ = $descriptor_name$,\n",
@@ -597,22 +595,12 @@ void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const {
printer_->Outdent();
}
+void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const {
+ Generator::PrintDescriptorKeyAndModuleName(descriptor, "$class_name$_Stub = service_reflection.GeneratedServiceStubType('$class_name$_Stub', ($class_name$,), dict(\n");
+}
+
void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const {
- // Print the service stub.
- printer_->Print("$class_name$_Stub = "
- "service_reflection.GeneratedServiceStubType("
- "'$class_name$_Stub', ($class_name$,), dict(\n",
- "class_name", descriptor.name());
- printer_->Indent();
- printer_->Print(
- "$descriptor_key$ = $descriptor_name$,\n",
- "descriptor_key", kDescriptorKey,
- "descriptor_name", ModuleLevelServiceDescriptorName(descriptor));
- printer_->Print(
- "__module__ = '$module_name$'\n",
- "module_name", ModuleName(file_->name()));
- printer_->Print("))\n\n");
- printer_->Outdent();
+ Generator::PrintDescriptorKeyAndModuleName(descriptor, "$class_name$ = service_reflection.GeneratedServiceType('$class_name$', (_service.Service,), dict(\n");
}
// Prints statement assigning ModuleLevelDescriptorName(message_descriptor)