Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:11:56

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 // Author: kenton@google.com (Kenton Varda)
0009 //  Based on original Protocol Buffers design by
0010 //  Sanjay Ghemawat, Jeff Dean, and others.
0011 
0012 #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__
0014 
0015 #include <string>
0016 
0017 #include "absl/container/flat_hash_map.h"
0018 #include "google/protobuf/compiler/cpp/helpers.h"
0019 #include "google/protobuf/compiler/cpp/options.h"
0020 #include "google/protobuf/port.h"
0021 
0022 // Must be included last.
0023 #include "google/protobuf/port_def.inc"
0024 
0025 namespace google {
0026 namespace protobuf {
0027 class FieldDescriptor;  // descriptor.h
0028 namespace io {
0029 class Printer;  // printer.h
0030 }
0031 }  // namespace protobuf
0032 }  // namespace google
0033 
0034 namespace google {
0035 namespace protobuf {
0036 namespace compiler {
0037 namespace cpp {
0038 
0039 class MessageSCCAnalyzer;
0040 
0041 // Generates code for an extension, which may be within the scope of some
0042 // message or may be at file scope.  This is much simpler than FieldGenerator
0043 // since extensions are just simple identifiers with interesting types.
0044 class PROTOC_EXPORT ExtensionGenerator {
0045  public:
0046   // See generator.cc for the meaning of dllexport_decl.
0047   explicit ExtensionGenerator(const FieldDescriptor* descriptor,
0048                               const Options& options,
0049                               MessageSCCAnalyzer* scc_analyzer);
0050   ExtensionGenerator(const ExtensionGenerator&) = delete;
0051   ExtensionGenerator& operator=(const ExtensionGenerator&) = delete;
0052   ~ExtensionGenerator();
0053 
0054   // Header stuff.
0055   void GenerateDeclaration(io::Printer* p) const;
0056 
0057   // Source file stuff.
0058   void GenerateDefinition(io::Printer* p);
0059 
0060   // Extension registration can happen at different priority levels depending on
0061   // the features used.
0062   //
0063   // For Weak Descriptor messages, we must use a two phase approach where we
0064   // first register all the extensions that are fully linked in, and then we
0065   // register the rest. To do that, we register the linked in extensions on
0066   // priority 101 and the rest as priority 102.
0067   // For extensions that are missing prototypes we need to create the prototypes
0068   // before we can register them, but for that we need to successfully parse
0069   // its descriptors, which might require other extensions to be registered
0070   // first. All extensions required for descriptor parsing will be fully linked
0071   // in and registered in the first phase.
0072   void GenerateRegistration(io::Printer* p, InitPriority priority);
0073   bool WillGenerateRegistration(InitPriority priority);
0074 
0075   bool IsScoped() const;
0076 
0077  private:
0078   const FieldDescriptor* descriptor_;
0079   std::string type_traits_;
0080   Options options_;
0081   MessageSCCAnalyzer* scc_analyzer_;
0082 
0083   absl::flat_hash_map<absl::string_view, std::string> variables_;
0084 };
0085 
0086 }  // namespace cpp
0087 }  // namespace compiler
0088 }  // namespace protobuf
0089 }  // namespace google
0090 
0091 #include "google/protobuf/port_undef.inc"
0092 
0093 #endif  // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__