Commit 060a2096 authored by Krishna's avatar Krishna

Reverted changes to cpp_helpers.cc and made code reviews to python_geenerator.cc

parent 7654f780
...@@ -360,31 +360,21 @@ string FilenameIdentifier(const string& filename) { ...@@ -360,31 +360,21 @@ string FilenameIdentifier(const string& filename) {
return result; return result;
} }
string GlobalSymbolName(const string& filename, string prefix)
{
return prefix + FilenameIdentifier(filename);
}
// Return the name of the AddDescriptors() function for a given file. // Return the name of the AddDescriptors() function for a given file.
string GlobalAddDescriptorsName(const string& filename) string GlobalAddDescriptorsName(const string& filename) {
{ return "protobuf_AddDesc_" + FilenameIdentifier(filename);
return GlobalSymbolName(filename,"protobuf_AddDesc_");
} }
// Return the name of the AssignDescriptors() function for a given file. // Return the name of the AssignDescriptors() function for a given file.
string GlobalAssignDescriptorsName(const string& filename) string GlobalAssignDescriptorsName(const string& filename) {
{ return "protobuf_AssignDesc_" + FilenameIdentifier(filename);
return GlobalSymbolName(filename,"protobuf_AssignDesc_");
} }
// Return the name of the ShutdownFile() function for a given file. // Return the name of the ShutdownFile() function for a given file.
string GlobalShutdownFileName(const string& filename) string GlobalShutdownFileName(const string& filename) {
{ return "protobuf_ShutdownFile_" + FilenameIdentifier(filename);
return GlobalSymbolName(filename,"protobuf_ShutdownFile_");
} }
// Return the qualified C++ name for a file level symbol. // Return the qualified C++ name for a file level symbol.
string QualifiedFileLevelSymbol(const string& package, const string& name) { string QualifiedFileLevelSymbol(const string& package, const string& name) {
if (package.empty()) { if (package.empty()) {
......
...@@ -581,8 +581,7 @@ void Generator::PrintServiceDescriptor( ...@@ -581,8 +581,7 @@ void Generator::PrintServiceDescriptor(
} }
void Generator::PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descriptor, const char* keyandmodule) const { void Generator::PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descriptor) const {
printer_->Print(keyandmodule,"class_name", descriptor.name());
printer_->Indent(); printer_->Indent();
printer_->Print( printer_->Print(
"$descriptor_key$ = $descriptor_name$,\n", "$descriptor_key$ = $descriptor_name$,\n",
...@@ -596,11 +595,20 @@ void Generator::PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descrip ...@@ -596,11 +595,20 @@ void Generator::PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descrip
} }
void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const { void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const {
Generator::PrintDescriptorKeyAndModuleName(descriptor, "$class_name$_Stub = service_reflection.GeneratedServiceStubType('$class_name$_Stub', ($class_name$,), dict(\n"); // Print the service.
printer_->Print("$class_name$ = service_reflection.GeneratedServiceType("
"'$class_name$', (_service.Service,), dict(\n",
"class_name", descriptor.name());
Generator::PrintDescriptorKeyAndModuleName(descriptor);
} }
void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const { void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const {
Generator::PrintDescriptorKeyAndModuleName(descriptor, "$class_name$ = service_reflection.GeneratedServiceType('$class_name$', (_service.Service,), dict(\n"); // Print the service stub.
printer_->Print("$class_name$_Stub = "
"service_reflection.GeneratedServiceStubType("
"'$class_name$_Stub', ($class_name$,), dict(\n",
"class_name", descriptor.name());
Generator::PrintDescriptorKeyAndModuleName(descriptor);
} }
// Prints statement assigning ModuleLevelDescriptorName(message_descriptor) // Prints statement assigning ModuleLevelDescriptorName(message_descriptor)
......
...@@ -127,7 +127,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator { ...@@ -127,7 +127,7 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const; void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const;
void PrintServiceClass(const ServiceDescriptor& descriptor) const; void PrintServiceClass(const ServiceDescriptor& descriptor) const;
void PrintServiceStub(const ServiceDescriptor& descriptor) const; void PrintServiceStub(const ServiceDescriptor& descriptor) const;
void PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descriptor, const char* keyandmodule) const ; void PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descriptor) const ;
void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const; void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const;
string OptionsValue(const string& class_name, string OptionsValue(const string& class_name,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment