Back to home page

EIC code displayed by LXR

 
 

    


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

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_FIELD_LITE_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__
0014 
0015 #include <cstdint>
0016 #include <string>
0017 #include <vector>
0018 
0019 #include "absl/container/flat_hash_map.h"
0020 #include "absl/strings/string_view.h"
0021 #include "google/protobuf/compiler/java/lite/field_generator.h"
0022 #include "google/protobuf/descriptor.h"
0023 
0024 namespace google {
0025 namespace protobuf {
0026 namespace compiler {
0027 namespace java {
0028 class Context;            // context.h
0029 class ClassNameResolver;  // name_resolver.h
0030 }  // namespace java
0031 }  // namespace compiler
0032 }  // namespace protobuf
0033 }  // namespace google
0034 
0035 namespace google {
0036 namespace protobuf {
0037 namespace compiler {
0038 namespace java {
0039 
0040 class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
0041  public:
0042   explicit ImmutableMessageFieldLiteGenerator(const FieldDescriptor* descriptor,
0043                                               int messageBitIndex,
0044                                               Context* context);
0045   ImmutableMessageFieldLiteGenerator(
0046       const ImmutableMessageFieldLiteGenerator&) = delete;
0047   ImmutableMessageFieldLiteGenerator& operator=(
0048       const ImmutableMessageFieldLiteGenerator&) = delete;
0049   ~ImmutableMessageFieldLiteGenerator() override;
0050 
0051   // implements ImmutableFieldLiteGenerator
0052   // ------------------------------------
0053   int GetNumBitsForMessage() const override;
0054   void GenerateInterfaceMembers(io::Printer* printer) const override;
0055   void GenerateMembers(io::Printer* printer) const override;
0056   void GenerateBuilderMembers(io::Printer* printer) const override;
0057   void GenerateInitializationCode(io::Printer* printer) const override;
0058   void GenerateFieldInfo(io::Printer* printer,
0059                          std::vector<uint16_t>* output) const override;
0060   void GenerateKotlinDslMembers(io::Printer* printer) const override;
0061 
0062   std::string GetBoxedType() const override;
0063 
0064  protected:
0065   const FieldDescriptor* descriptor_;
0066   absl::flat_hash_map<absl::string_view, std::string> variables_;
0067   const int messageBitIndex_;
0068   ClassNameResolver* name_resolver_;
0069   Context* context_;
0070 
0071  private:
0072   void GenerateKotlinOrNull(io::Printer* printer) const;
0073 };
0074 
0075 class ImmutableMessageOneofFieldLiteGenerator
0076     : public ImmutableMessageFieldLiteGenerator {
0077  public:
0078   ImmutableMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
0079                                           int messageBitIndex,
0080                                           Context* context);
0081   ImmutableMessageOneofFieldLiteGenerator(
0082       const ImmutableMessageOneofFieldLiteGenerator&) = delete;
0083   ImmutableMessageOneofFieldLiteGenerator& operator=(
0084       const ImmutableMessageOneofFieldLiteGenerator&) = delete;
0085   ~ImmutableMessageOneofFieldLiteGenerator() override;
0086 
0087   void GenerateMembers(io::Printer* printer) const override;
0088   void GenerateBuilderMembers(io::Printer* printer) const override;
0089   void GenerateFieldInfo(io::Printer* printer,
0090                          std::vector<uint16_t>* output) const override;
0091 
0092 };
0093 
0094 class RepeatedImmutableMessageFieldLiteGenerator
0095     : public ImmutableFieldLiteGenerator {
0096  public:
0097   explicit RepeatedImmutableMessageFieldLiteGenerator(
0098       const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
0099   RepeatedImmutableMessageFieldLiteGenerator(
0100       const RepeatedImmutableMessageFieldLiteGenerator&) = delete;
0101   RepeatedImmutableMessageFieldLiteGenerator& operator=(
0102       const RepeatedImmutableMessageFieldLiteGenerator&) = delete;
0103   ~RepeatedImmutableMessageFieldLiteGenerator() override;
0104 
0105   // implements ImmutableFieldLiteGenerator ------------------------------------
0106   int GetNumBitsForMessage() const override;
0107   void GenerateInterfaceMembers(io::Printer* printer) const override;
0108   void GenerateMembers(io::Printer* printer) const override;
0109   void GenerateBuilderMembers(io::Printer* printer) const override;
0110   void GenerateInitializationCode(io::Printer* printer) const override;
0111   void GenerateFieldInfo(io::Printer* printer,
0112                          std::vector<uint16_t>* output) const override;
0113   void GenerateKotlinDslMembers(io::Printer* printer) const override;
0114 
0115   std::string GetBoxedType() const override;
0116 
0117  protected:
0118   const FieldDescriptor* descriptor_;
0119   absl::flat_hash_map<absl::string_view, std::string> variables_;
0120   ClassNameResolver* name_resolver_;
0121   Context* context_;
0122 };
0123 
0124 }  // namespace java
0125 }  // namespace compiler
0126 }  // namespace protobuf
0127 }  // namespace google
0128 
0129 #endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__