OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 // Get code that evaluates to the field's default value. | 141 // Get code that evaluates to the field's default value. |
142 string DefaultValue(const FieldDescriptor* field); | 142 string DefaultValue(const FieldDescriptor* field); |
143 | 143 |
144 // Convert a file name into a valid identifier. | 144 // Convert a file name into a valid identifier. |
145 string FilenameIdentifier(const string& filename); | 145 string FilenameIdentifier(const string& filename); |
146 | 146 |
147 // Return the name of the AddDescriptors() function for a given file. | 147 // Return the name of the AddDescriptors() function for a given file. |
148 string GlobalAddDescriptorsName(const string& filename); | 148 string GlobalAddDescriptorsName(const string& filename); |
149 | 149 |
150 // Return the name of the AssignDescriptors() function for a given file. | 150 // Return the name of the InitDefaults() function for a given file. |
151 string GlobalAssignDescriptorsName(const string& filename); | 151 string GlobalInitDefaultsName(const string& filename); |
| 152 |
| 153 // Return the name of the offset table function for a given file. |
| 154 string GlobalOffsetTableName(const string& filename); |
152 | 155 |
153 // Return the qualified C++ name for a file level symbol. | 156 // Return the qualified C++ name for a file level symbol. |
154 string QualifiedFileLevelSymbol(const string& package, const string& name); | 157 string QualifiedFileLevelSymbol(const string& package, const string& name); |
155 | 158 |
156 // Return the name of the ShutdownFile() function for a given file. | 159 // Return the name of the ShutdownFile() function for a given file. |
157 string GlobalShutdownFileName(const string& filename); | 160 string GlobalShutdownFileName(const string& filename); |
158 | 161 |
159 // Escape C++ trigraphs by escaping question marks to \? | 162 // Escape C++ trigraphs by escaping question marks to \? |
160 string EscapeTrigraphs(const string& to_escape); | 163 string EscapeTrigraphs(const string& to_escape); |
161 | 164 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 // size. | 219 // size. |
217 inline bool HasFastArraySerialization(const FileDescriptor* file, | 220 inline bool HasFastArraySerialization(const FileDescriptor* file, |
218 const Options& options) { | 221 const Options& options) { |
219 return GetOptimizeFor(file, options) == FileOptions::SPEED; | 222 return GetOptimizeFor(file, options) == FileOptions::SPEED; |
220 } | 223 } |
221 | 224 |
222 // Returns whether we have to generate code with static initializers. | 225 // Returns whether we have to generate code with static initializers. |
223 bool StaticInitializersForced(const FileDescriptor* file, | 226 bool StaticInitializersForced(const FileDescriptor* file, |
224 const Options& options); | 227 const Options& options); |
225 | 228 |
226 // Prints 'with_static_init' if static initializers have to be used for the | |
227 // provided file. Otherwise emits both 'with_static_init' and | |
228 // 'without_static_init' using #ifdef. | |
229 void PrintHandlingOptionalStaticInitializers( | |
230 const FileDescriptor* file, const Options& options, io::Printer* printer, | |
231 const char* with_static_init, const char* without_static_init, | |
232 const char* var1 = NULL, const string& val1 = "", const char* var2 = NULL, | |
233 const string& val2 = ""); | |
234 | |
235 void PrintHandlingOptionalStaticInitializers(const map<string, string>& vars, | |
236 const FileDescriptor* file, | |
237 const Options& options, | |
238 io::Printer* printer, | |
239 const char* with_static_init, | |
240 const char* without_static_init); | |
241 | |
242 | 229 |
243 inline bool IsMapEntryMessage(const Descriptor* descriptor) { | 230 inline bool IsMapEntryMessage(const Descriptor* descriptor) { |
244 return descriptor->options().map_entry(); | 231 return descriptor->options().map_entry(); |
245 } | 232 } |
246 | 233 |
247 // Returns true if the field's CPPTYPE is string or message. | 234 // Returns true if the field's CPPTYPE is string or message. |
248 bool IsStringOrMessage(const FieldDescriptor* field); | 235 bool IsStringOrMessage(const FieldDescriptor* field); |
249 | 236 |
250 // For a string field, returns the effective ctype. If the actual ctype is | 237 // For a string field, returns the effective ctype. If the actual ctype is |
251 // not supported, returns the default of STRING. | 238 // not supported, returns the default of STRING. |
(...skipping 23 matching lines...) Expand all Loading... |
275 return SupportsArenas(field->file()); | 262 return SupportsArenas(field->file()); |
276 } | 263 } |
277 | 264 |
278 bool IsAnyMessage(const FileDescriptor* descriptor); | 265 bool IsAnyMessage(const FileDescriptor* descriptor); |
279 bool IsAnyMessage(const Descriptor* descriptor); | 266 bool IsAnyMessage(const Descriptor* descriptor); |
280 | 267 |
281 bool IsWellKnownMessage(const FileDescriptor* descriptor); | 268 bool IsWellKnownMessage(const FileDescriptor* descriptor); |
282 | 269 |
283 void GenerateUtf8CheckCodeForString(const FieldDescriptor* field, | 270 void GenerateUtf8CheckCodeForString(const FieldDescriptor* field, |
284 const Options& options, bool for_parse, | 271 const Options& options, bool for_parse, |
285 const map<string, string>& variables, | 272 const std::map<string, string>& variables, |
286 const char* parameters, | 273 const char* parameters, |
287 io::Printer* printer); | 274 io::Printer* printer); |
288 | 275 |
289 void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field, | 276 void GenerateUtf8CheckCodeForCord(const FieldDescriptor* field, |
290 const Options& options, bool for_parse, | 277 const Options& options, bool for_parse, |
291 const map<string, string>& variables, | 278 const std::map<string, string>& variables, |
292 const char* parameters, io::Printer* printer); | 279 const char* parameters, io::Printer* printer); |
293 | 280 |
294 inline ::google::protobuf::FileOptions_OptimizeMode GetOptimizeFor( | 281 inline ::google::protobuf::FileOptions_OptimizeMode GetOptimizeFor( |
295 const FileDescriptor* file, const Options& options) { | 282 const FileDescriptor* file, const Options& options) { |
296 return options.enforce_lite | 283 return options.enforce_lite |
297 ? FileOptions::LITE_RUNTIME | 284 ? FileOptions::LITE_RUNTIME |
298 : file->options().optimize_for(); | 285 : file->options().optimize_for(); |
299 } | 286 } |
300 | 287 |
301 } // namespace cpp | 288 } // namespace cpp |
302 } // namespace compiler | 289 } // namespace compiler |
303 } // namespace protobuf | 290 } // namespace protobuf |
304 | 291 |
305 } // namespace google | 292 } // namespace google |
306 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__ | 293 #endif // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__ |
OLD | NEW |