Commit 7794a98f authored by Jisi Liu's avatar Jisi Liu

Initial check-in for message oneof.

parent 33222b5a
...@@ -111,6 +111,7 @@ FieldGenerator* FieldGeneratorMap::MakeGenerator(const FieldDescriptor* field, ...@@ -111,6 +111,7 @@ FieldGenerator* FieldGeneratorMap::MakeGenerator(const FieldDescriptor* field,
} else if (field->containing_oneof()) { } else if (field->containing_oneof()) {
switch (java_type) { switch (java_type) {
case JAVATYPE_MESSAGE: case JAVATYPE_MESSAGE:
return new MessageOneofFieldGenerator(field, params);
case JAVATYPE_ENUM: case JAVATYPE_ENUM:
default: default:
return new PrimitiveOneofFieldGenerator(field, params); return new PrimitiveOneofFieldGenerator(field, params);
......
...@@ -146,12 +146,22 @@ GenerateHashCodeCode(io::Printer* printer) const { ...@@ -146,12 +146,22 @@ GenerateHashCodeCode(io::Printer* printer) const {
"result = 31 * result +\n" "result = 31 * result +\n"
" (this.$name$ == null ? 0 : this.$name$.hashCode());\n"); " (this.$name$ == null ? 0 : this.$name$.hashCode());\n");
} }
// ===================================================================
MessageOneofFieldGenerator::MessageOneofFieldGenerator(
const FieldDescriptor* descriptor, const Params& params)
: FieldGenerator(params), descriptor_(descriptor) {
SetMessageVariables(params, descriptor, &variables_);
SetCommonOneofVariables(descriptor, &variables_);
}
MessageOneofFieldGenerator::~MessageOneofFieldGenerator() {}
// =================================================================== // ===================================================================
RepeatedMessageFieldGenerator:: RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, const Params& params) const FieldDescriptor* descriptor, const Params& params)
: FieldGenerator(params), descriptor_(descriptor) { : FieldGenerator(params), descriptor_(descriptor) {
SetMessageVariables(params, descriptor, &variables_); SetMessageVariables(params, descriptor, &variables_);
} }
......
...@@ -66,6 +66,20 @@ class MessageFieldGenerator : public FieldGenerator { ...@@ -66,6 +66,20 @@ class MessageFieldGenerator : public FieldGenerator {
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);
}; };
class MessageOneofFieldGenerator : public FieldGenerator {
public:
explicit MessageOneofFieldGenerator(const FieldDescriptor* descriptor,
const Params& params);
~MessageOneofFieldGenerator();
// implements FieldGenerator ---------------------------------------
private:
const FieldDescriptor* descriptor_;
map<string, string> variables_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);
};
class RepeatedMessageFieldGenerator : public FieldGenerator { class RepeatedMessageFieldGenerator : public FieldGenerator {
public: public:
explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor, explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment