aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/java/java_message.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/compiler/java/java_message.h')
-rw-r--r--src/google/protobuf/compiler/java/java_message.h50
1 files changed, 39 insertions, 11 deletions
diff --git a/src/google/protobuf/compiler/java/java_message.h b/src/google/protobuf/compiler/java/java_message.h
index a30f0202..406910dc 100644
--- a/src/google/protobuf/compiler/java/java_message.h
+++ b/src/google/protobuf/compiler/java/java_message.h
@@ -36,11 +36,17 @@
#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
#include <string>
-#include <google/protobuf/stubs/common.h>
+#include <map>
#include <google/protobuf/compiler/java/java_field.h>
namespace google {
namespace protobuf {
+ namespace compiler {
+ namespace java {
+ class Context; // context.h
+ class ClassNameResolver; // name_resolver.h
+ }
+ }
namespace io {
class Printer; // printer.h
}
@@ -53,26 +59,45 @@ namespace java {
class MessageGenerator {
public:
explicit MessageGenerator(const Descriptor* descriptor);
- ~MessageGenerator();
+ virtual ~MessageGenerator();
// All static variables have to be declared at the top-level of the file
// so that we can control initialization order, which is important for
// DescriptorProto bootstrapping to work.
- void GenerateStaticVariables(io::Printer* printer);
+ virtual void GenerateStaticVariables(io::Printer* printer) = 0;
// Output code which initializes the static variables generated by
// GenerateStaticVariables().
- void GenerateStaticVariableInitializers(io::Printer* printer);
+ virtual void GenerateStaticVariableInitializers(io::Printer* printer) = 0;
// Generate the class itself.
- void Generate(io::Printer* printer);
+ virtual void Generate(io::Printer* printer) = 0;
// Generates the base interface that both the class and its builder implement
- void GenerateInterface(io::Printer* printer);
+ virtual void GenerateInterface(io::Printer* printer) = 0;
// Generate code to register all contained extensions with an
// ExtensionRegistry.
- void GenerateExtensionRegistrationCode(io::Printer* printer);
+ virtual void GenerateExtensionRegistrationCode(io::Printer* printer) = 0;
+
+ protected:
+ const Descriptor* descriptor_;
+
+ private:
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
+};
+
+class ImmutableMessageGenerator : public MessageGenerator {
+ public:
+ explicit ImmutableMessageGenerator(const Descriptor* descriptor,
+ Context* context);
+ virtual ~ImmutableMessageGenerator();
+
+ virtual void Generate(io::Printer* printer);
+ virtual void GenerateInterface(io::Printer* printer);
+ virtual void GenerateExtensionRegistrationCode(io::Printer* printer);
+ virtual void GenerateStaticVariables(io::Printer* printer);
+ virtual void GenerateStaticVariableInitializers(io::Printer* printer);
private:
enum UseMemoization {
@@ -80,6 +105,9 @@ class MessageGenerator {
DONT_MEMOIZE
};
+ void GenerateFieldAccessorTable(io::Printer* printer);
+ void GenerateFieldAccessorTableInitializer(io::Printer* printer);
+
void GenerateMessageSerializationMethods(io::Printer* printer);
void GenerateParseFromMethods(io::Printer* printer);
void GenerateSerializeOneField(io::Printer* printer,
@@ -94,14 +122,14 @@ class MessageGenerator {
void GenerateIsInitialized(io::Printer* printer,
UseMemoization useMemoization);
void GenerateEqualsAndHashCode(io::Printer* printer);
-
void GenerateParser(io::Printer* printer);
void GenerateParsingConstructor(io::Printer* printer);
- const Descriptor* descriptor_;
- FieldGeneratorMap field_generators_;
+ Context* context_;
+ ClassNameResolver* name_resolver_;
+ FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
- GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageGenerator);
};
} // namespace java