Back to home page

EIC code displayed by LXR

 
 

    


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

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_JAVA_MESSAGE_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
0014 
0015 #include <memory>
0016 #include <string>
0017 #include <vector>
0018 
0019 #include "google/protobuf/compiler/java/generator_factory.h"
0020 #include "google/protobuf/compiler/java/full/field_generator.h"
0021 #include "google/protobuf/descriptor.h"
0022 
0023 namespace google {
0024 namespace protobuf {
0025 namespace compiler {
0026 namespace java {
0027 class Context;            // context.h
0028 class ClassNameResolver;  // name_resolver.h
0029 }  // namespace java
0030 }  // namespace compiler
0031 namespace io {
0032 class Printer;  // printer.h
0033 }
0034 }  // namespace protobuf
0035 }  // namespace google
0036 
0037 namespace google {
0038 namespace protobuf {
0039 namespace compiler {
0040 namespace java {
0041 
0042 class ImmutableMessageGenerator : public MessageGenerator {
0043  public:
0044   ImmutableMessageGenerator(const Descriptor* descriptor, Context* context);
0045   ImmutableMessageGenerator(const ImmutableMessageGenerator&) = delete;
0046   ImmutableMessageGenerator& operator=(const ImmutableMessageGenerator&) =
0047       delete;
0048   ~ImmutableMessageGenerator() override;
0049 
0050   void Generate(io::Printer* printer) override;
0051   void GenerateInterface(io::Printer* printer) override;
0052   void GenerateExtensionRegistrationCode(io::Printer* printer) override;
0053   void GenerateStaticVariables(io::Printer* printer,
0054                                int* bytecode_estimate) override;
0055 
0056   // Returns an estimate of the number of bytes the printed code will compile to
0057   int GenerateStaticVariableInitializers(io::Printer* printer) override;
0058   void GenerateKotlinDsl(io::Printer* printer) const override;
0059   void GenerateKotlinMembers(io::Printer* printer) const override;
0060   void GenerateTopLevelKotlinMembers(io::Printer* printer) const override;
0061 
0062  private:
0063   void GenerateFieldAccessorTable(io::Printer* printer, int* bytecode_estimate);
0064 
0065   // Returns an estimate of the number of bytes the printed code will compile to
0066   int GenerateFieldAccessorTableInitializer(io::Printer* printer);
0067 
0068   void GenerateMessageSerializationMethods(io::Printer* printer);
0069   void GenerateParseFromMethods(io::Printer* printer);
0070 
0071   void GenerateBuilder(io::Printer* printer);
0072   void GenerateIsInitialized(io::Printer* printer);
0073   void GenerateDescriptorMethods(io::Printer* printer);
0074   void GenerateInitializers(io::Printer* printer);
0075   void GenerateEqualsAndHashCode(io::Printer* printer);
0076   void GenerateParser(io::Printer* printer);
0077   void GenerateParsingConstructor(io::Printer* printer);
0078   void GenerateMutableCopy(io::Printer* printer);
0079   void GenerateKotlinExtensions(io::Printer* printer) const;
0080   void GenerateKotlinOrNull(io::Printer* printer) const;
0081   void GenerateAnyMethods(io::Printer* printer);
0082 
0083   Context* context_;
0084   ClassNameResolver* name_resolver_;
0085   FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
0086 };
0087 
0088 }  // namespace java
0089 }  // namespace compiler
0090 }  // namespace protobuf
0091 }  // namespace google
0092 
0093 #endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__