|
|
|
@ -100,15 +100,8 @@ std::string TypeName(const google::protobuf::FieldDescriptor* field) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GenerateMessage(const google::protobuf::Descriptor* message, |
|
|
|
|
void GenerateField(const google::protobuf::FieldDescriptor* field, |
|
|
|
|
google::protobuf::io::Printer* printer) { |
|
|
|
|
printer->Print( |
|
|
|
|
"add_message \"$name$\" do\n", |
|
|
|
|
"name", message->full_name()); |
|
|
|
|
printer->Indent(); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < message->field_count(); i++) { |
|
|
|
|
const FieldDescriptor* field = message->field(i); |
|
|
|
|
printer->Print( |
|
|
|
|
"$label$ :$name$, ", |
|
|
|
|
"label", LabelForField(field), |
|
|
|
@ -130,6 +123,41 @@ void GenerateMessage(const google::protobuf::Descriptor* message, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GenerateOneof(const google::protobuf::OneofDescriptor* oneof, |
|
|
|
|
google::protobuf::io::Printer* printer) { |
|
|
|
|
printer->Print( |
|
|
|
|
"oneof :$name$ do\n", |
|
|
|
|
"name", oneof->name()); |
|
|
|
|
printer->Indent(); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < oneof->field_count(); i++) { |
|
|
|
|
const FieldDescriptor* field = oneof->field(i); |
|
|
|
|
GenerateField(field, printer); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
printer->Outdent(); |
|
|
|
|
printer->Print("end\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void GenerateMessage(const google::protobuf::Descriptor* message, |
|
|
|
|
google::protobuf::io::Printer* printer) { |
|
|
|
|
printer->Print( |
|
|
|
|
"add_message \"$name$\" do\n", |
|
|
|
|
"name", message->full_name()); |
|
|
|
|
printer->Indent(); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < message->field_count(); i++) { |
|
|
|
|
const FieldDescriptor* field = message->field(i); |
|
|
|
|
if (!field->containing_oneof()) { |
|
|
|
|
GenerateField(field, printer); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < message->oneof_decl_count(); i++) { |
|
|
|
|
const OneofDescriptor* oneof = message->oneof_decl(i); |
|
|
|
|
GenerateOneof(oneof, printer); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
printer->Outdent(); |
|
|
|
|
printer->Print("end\n"); |
|
|
|
|
|
|
|
|
|