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_PRIMITIVE_FIELD_LITE_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_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 ImmutablePrimitiveFieldLiteGenerator
0041     : public ImmutableFieldLiteGenerator {
0042  public:
0043   explicit ImmutablePrimitiveFieldLiteGenerator(
0044       const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
0045   ImmutablePrimitiveFieldLiteGenerator(
0046       const ImmutablePrimitiveFieldLiteGenerator&) = delete;
0047   ImmutablePrimitiveFieldLiteGenerator& operator=(
0048       const ImmutablePrimitiveFieldLiteGenerator&) = delete;
0049   ~ImmutablePrimitiveFieldLiteGenerator() 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   Context* context_;
0069   ClassNameResolver* name_resolver_;
0070 };
0071 
0072 class ImmutablePrimitiveOneofFieldLiteGenerator
0073     : public ImmutablePrimitiveFieldLiteGenerator {
0074  public:
0075   ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor,
0076                                             int messageBitIndex,
0077                                             Context* context);
0078   ImmutablePrimitiveOneofFieldLiteGenerator(
0079       const ImmutablePrimitiveOneofFieldLiteGenerator&) = delete;
0080   ImmutablePrimitiveOneofFieldLiteGenerator& operator=(
0081       const ImmutablePrimitiveOneofFieldLiteGenerator&) = delete;
0082   ~ImmutablePrimitiveOneofFieldLiteGenerator() override;
0083 
0084   void GenerateMembers(io::Printer* printer) const override;
0085   void GenerateBuilderMembers(io::Printer* printer) const override;
0086 
0087   void GenerateFieldInfo(io::Printer* printer,
0088                          std::vector<uint16_t>* output) const override;
0089 };
0090 
0091 class RepeatedImmutablePrimitiveFieldLiteGenerator
0092     : public ImmutableFieldLiteGenerator {
0093  public:
0094   explicit RepeatedImmutablePrimitiveFieldLiteGenerator(
0095       const FieldDescriptor* descriptor, int messageBitIndex, Context* context);
0096   RepeatedImmutablePrimitiveFieldLiteGenerator(
0097       const RepeatedImmutablePrimitiveFieldLiteGenerator&) = delete;
0098   RepeatedImmutablePrimitiveFieldLiteGenerator& operator=(
0099       const RepeatedImmutablePrimitiveFieldLiteGenerator&) = delete;
0100   ~RepeatedImmutablePrimitiveFieldLiteGenerator() override;
0101 
0102   // implements ImmutableFieldLiteGenerator ------------------------------------
0103   int GetNumBitsForMessage() const override;
0104   void GenerateInterfaceMembers(io::Printer* printer) const override;
0105   void GenerateMembers(io::Printer* printer) const override;
0106   void GenerateBuilderMembers(io::Printer* printer) const override;
0107   void GenerateInitializationCode(io::Printer* printer) const override;
0108   void GenerateFieldInfo(io::Printer* printer,
0109                          std::vector<uint16_t>* output) const override;
0110   void GenerateKotlinDslMembers(io::Printer* printer) const override;
0111 
0112   std::string GetBoxedType() const override;
0113 
0114  private:
0115   const FieldDescriptor* descriptor_;
0116   absl::flat_hash_map<absl::string_view, std::string> variables_;
0117   Context* context_;
0118   ClassNameResolver* name_resolver_;
0119 };
0120 
0121 }  // namespace java
0122 }  // namespace compiler
0123 }  // namespace protobuf
0124 }  // namespace google
0125 
0126 #endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__