Merge pull request #128 from krishnanm86/master

Source code refactoring. Extracted common functionality in cpp_helpers.c...
pull/134/head
Feng Xiao 10 years ago
commit f473bb9903
  1. 25
      src/google/protobuf/compiler/python/python_generator.cc
  2. 1
      src/google/protobuf/compiler/python/python_generator.h

@ -580,12 +580,8 @@ 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());
printer_->Indent();
void Generator::PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descriptor) const {
printer_->Print(
"$descriptor_key$ = $descriptor_name$,\n",
"descriptor_key", kDescriptorKey,
@ -593,6 +589,15 @@ void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const {
printer_->Print(
"__module__ = '$module_name$'\n",
"module_name", ModuleName(file_->name()));
}
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());
printer_->Indent();
Generator::PrintDescriptorKeyAndModuleName(descriptor);
printer_->Print("))\n\n");
printer_->Outdent();
}
@ -604,13 +609,7 @@ void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const {
"'$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()));
Generator::PrintDescriptorKeyAndModuleName(descriptor);
printer_->Print("))\n\n");
printer_->Outdent();
}

@ -127,6 +127,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const;
void PrintServiceClass(const ServiceDescriptor& descriptor) const;
void PrintServiceStub(const ServiceDescriptor& descriptor) const;
void PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descriptor) const ;
void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const;
string OptionsValue(const string& class_name,

Loading…
Cancel
Save