Initial check-in for message oneof.

changes/00/217000/1
Jisi Liu 10 years ago
parent 33222b5a02
commit 7794a98ff4
  1. 1
      src/google/protobuf/compiler/javanano/javanano_field.cc
  2. 16
      src/google/protobuf/compiler/javanano/javanano_message_field.cc
  3. 14
      src/google/protobuf/compiler/javanano/javanano_message_field.h

@ -111,6 +111,7 @@ FieldGenerator* FieldGeneratorMap::MakeGenerator(const FieldDescriptor* field,
} else if (field->containing_oneof()) {
switch (java_type) {
case JAVATYPE_MESSAGE:
return new MessageOneofFieldGenerator(field, params);
case JAVATYPE_ENUM:
default:
return new PrimitiveOneofFieldGenerator(field, params);

@ -146,12 +146,22 @@ GenerateHashCodeCode(io::Printer* printer) const {
"result = 31 * result +\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(const FieldDescriptor* descriptor, const Params& params)
: FieldGenerator(params), descriptor_(descriptor) {
RepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(
const FieldDescriptor* descriptor, const Params& params)
: FieldGenerator(params), descriptor_(descriptor) {
SetMessageVariables(params, descriptor, &variables_);
}

@ -66,6 +66,20 @@ class MessageFieldGenerator : public FieldGenerator {
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 {
public:
explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,

Loading…
Cancel
Save