@@ -87,25 +87,24 @@ void WriteHeader(const protobuf::FileDescriptor* file, Context& ctx) {
87
87
return ;
88
88
}
89
89
EmitFileWarning (file, ctx);
90
- ctx.EmitLegacy (
91
- R"cc(
92
- #ifndef $0_HPB_PROTO_H_
93
- #define $0_HPB_PROTO_H_
90
+ ctx.Emit ({{ " filename " , ToPreproc (file-> name ())}},
91
+ R"cc(
92
+ #ifndef $filename$_HPB_PROTO_H_
93
+ #define $filename$_HPB_PROTO_H_
94
94
95
95
#include "google/protobuf/hpb/repeated_field.h"
96
96
97
97
#include "absl/status/statusor.h"
98
98
#include "absl/strings/string_view.h"
99
- )cc" ,
100
- ToPreproc (file->name ()));
99
+ )cc" );
101
100
102
101
// Import headers for proto public dependencies.
103
102
for (int i = 0 ; i < file->public_dependency_count (); i++) {
104
103
if (i == 0 ) {
105
104
ctx.Emit (" // Public Imports.\n " );
106
105
}
107
- ctx.EmitLegacy ( " #include \" $0 \"\n " ,
108
- CppHeaderFilename (file-> public_dependency (i)) );
106
+ ctx.Emit ({{ " header " , CppHeaderFilename (file-> public_dependency (i))}} ,
107
+ " #include \" $header$ \"\n " );
109
108
if (i == file->public_dependency_count () - 1 ) {
110
109
ctx.Emit (" \n " );
111
110
}
@@ -146,7 +145,8 @@ void WriteHeader(const protobuf::FileDescriptor* file, Context& ctx) {
146
145
ctx.Emit (" \n #include \" upb/port/undef.inc\"\n\n " );
147
146
// End of "C" section.
148
147
149
- ctx.EmitLegacy (" #endif /* $0_HPB_PROTO_H_ */\n " , ToPreproc (file->name ()));
148
+ ctx.Emit ({{" filename" , ToPreproc (file->name ())}},
149
+ " #endif /* $filename$_HPB_PROTO_H_ */\n " );
150
150
}
151
151
152
152
// Writes a .hpb.cc source file.
@@ -157,24 +157,24 @@ void WriteSource(const protobuf::FileDescriptor* file, Context& ctx) {
157
157
}
158
158
EmitFileWarning (file, ctx);
159
159
160
- ctx.EmitLegacy (
161
- R"cc(
160
+ ctx.Emit ({{ " header " , CppHeaderFilename (file)}},
161
+ R"cc(
162
162
#include <stddef.h>
163
163
#include "absl/log/absl_check.h"
164
164
#include "absl/strings/string_view.h"
165
- #include "$0"
166
- )cc" ,
167
- CppHeaderFilename (file));
165
+ #include "$header$"
166
+ )cc" );
168
167
169
168
for (int i = 0 ; i < file->dependency_count (); i++) {
170
169
if (ctx.options ().strip_feature_includes &&
171
170
compiler::IsKnownFeatureProto (file->dependency (i)->name ())) {
172
171
// Strip feature imports for editions codegen tests.
173
172
continue ;
174
173
}
175
- ctx.EmitLegacy (" #include \" $0\"\n " , CppHeaderFilename (file->dependency (i)));
174
+ ctx.Emit ({{" header" , CppHeaderFilename (file->dependency (i))}},
175
+ " #include \" $header$\"\n " );
176
176
}
177
- ctx.EmitLegacy (" #include \" upb/port/def.inc\"\n " );
177
+ ctx.Emit (" #include \" upb/port/def.inc\"\n " );
178
178
179
179
WrapNamespace (file, ctx, [&]() { WriteMessageImplementations (file, ctx); });
180
180
@@ -217,7 +217,8 @@ void WriteTypedefForwardingHeader(
217
217
void WriteHeaderMessageForwardDecls (const protobuf::FileDescriptor* file,
218
218
Context& ctx) {
219
219
// Import forward-declaration of types defined in this file.
220
- ctx.EmitLegacy (" #include \" $0\"\n " , UpbCFilename (file));
220
+ ctx.Emit ({{" upb_filename" , UpbCFilename (file)}},
221
+ " #include \" $upb_filename$\"\n " );
221
222
WriteForwardDecls (file, ctx);
222
223
// Import forward-declaration of types in dependencies.
223
224
for (int i = 0 ; i < file->dependency_count (); ++i) {
0 commit comments