@@ -49,6 +49,8 @@ class struct_code_generator : public google::protobuf::compiler::CodeGenerator {
49
49
50
50
auto output = context->Open (filename);
51
51
52
+ std::string package_name = file->package ();
53
+
52
54
bool enable_optional = false ;
53
55
bool enable_inherit = false ;
54
56
@@ -65,10 +67,21 @@ class struct_code_generator : public google::protobuf::compiler::CodeGenerator {
65
67
66
68
std::vector<struct_tokenizer> proto_module_info;
67
69
std::vector<struct_enum> proto_enum_info;
70
+
68
71
for (int i = 0 ; i < file->message_type_count (); ++i) {
69
72
// struct name
70
73
const google::protobuf::Descriptor* descriptor = file->message_type (i);
71
74
75
+ for (int k = 0 ; k < descriptor->nested_type_count (); ++k) {
76
+ struct_tokenizer tokenizer_nested;
77
+ tokenizer_nested.clear ();
78
+
79
+ const google::protobuf::Descriptor* nested_type =
80
+ descriptor->nested_type (k);
81
+ tokenizer_nested.tokenizer (nested_type);
82
+ proto_module_info.emplace_back (tokenizer_nested);
83
+ }
84
+
72
85
struct_enum enum_token;
73
86
enum_token.clear ();
74
87
enum_token.get_enum_fields (descriptor);
@@ -80,7 +93,7 @@ class struct_code_generator : public google::protobuf::compiler::CodeGenerator {
80
93
proto_module_info.emplace_back (tokenizer);
81
94
}
82
95
83
- std::string struct_header = code_generate_header ();
96
+ std::string struct_header = code_generate_header (package_name );
84
97
write_to_output (zero_copy_output, (const void *)struct_header.c_str (),
85
98
struct_header.size ());
86
99
@@ -122,6 +135,10 @@ class struct_code_generator : public google::protobuf::compiler::CodeGenerator {
122
135
write_to_output (zero_copy_output, (const void *)struct_macro_str.c_str (),
123
136
struct_macro_str.size ());
124
137
}
138
+ std::string namespace_last_part = " " ;
139
+ namespace_last_part = code_generate_last_part ();
140
+ write_to_output (zero_copy_output, (const void *)namespace_last_part.c_str (),
141
+ namespace_last_part.size ());
125
142
126
143
delete zero_copy_output;
127
144
return true ;
0 commit comments