Adding another enum and field usage just to see what it looks like

This commit is contained in:
Dan Buch 2012-05-07 22:31:40 -04:00
parent af3b05be3d
commit 438aa1db17
5 changed files with 374 additions and 56 deletions

View File

@ -27,6 +27,7 @@ const ::google::protobuf::EnumDescriptor* Person_PhoneType_descriptor_ = NULL;
const ::google::protobuf::Descriptor* AddressBook_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
AddressBook_reflection_ = NULL;
const ::google::protobuf::EnumDescriptor* Gender_descriptor_ = NULL;
} // namespace
@ -38,10 +39,11 @@ void protobuf_AssignDesc_addressbook_2eproto() {
"addressbook.proto");
GOOGLE_CHECK(file != NULL);
Person_descriptor_ = file->message_type(0);
static const int Person_offsets_[4] = {
static const int Person_offsets_[5] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Person, name_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Person, id_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Person, email_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Person, type_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Person, phone_),
};
Person_reflection_ =
@ -87,6 +89,7 @@ void protobuf_AssignDesc_addressbook_2eproto() {
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(AddressBook));
Gender_descriptor_ = file->enum_type(0);
}
namespace {
@ -125,14 +128,16 @@ void protobuf_AddDesc_addressbook_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
"\n\021addressbook.proto\022\010tutorial\"\332\001\n\006Person"
"\n\021addressbook.proto\022\010tutorial\"\200\002\n\006Person"
"\022\014\n\004name\030\001 \002(\t\022\n\n\002id\030\002 \002(\005\022\r\n\005email\030\003 \001("
"\t\022+\n\005phone\030\004 \003(\0132\034.tutorial.Person.Phone"
"Number\032M\n\013PhoneNumber\022\016\n\006number\030\001 \002(\t\022.\n"
"\004type\030\002 \001(\0162\032.tutorial.Person.PhoneType:"
"\004HOME\"+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001"
"\022\010\n\004WORK\020\002\"/\n\013AddressBook\022 \n\006person\030\001 \003("
"\0132\020.tutorial.Person", 299);
"\t\022$\n\004type\030\004 \001(\0162\020.tutorial.Gender:\004NONE\022"
"+\n\005phone\030\005 \003(\0132\034.tutorial.Person.PhoneNu"
"mber\032M\n\013PhoneNumber\022\016\n\006number\030\001 \002(\t\022.\n\004t"
"ype\030\002 \001(\0162\032.tutorial.Person.PhoneType:\004H"
"OME\"+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001\022\010"
"\n\004WORK\020\002\"/\n\013AddressBook\022 \n\006person\030\001 \003(\0132"
"\020.tutorial.Person*3\n\006Gender\022\010\n\004NONE\020\000\022\010\n"
"\004MALE\020\001\022\n\n\006FEMALE\020\002\022\t\n\005OTHER\020\003", 390);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"addressbook.proto", &protobuf_RegisterTypes);
Person::default_instance_ = new Person();
@ -151,6 +156,22 @@ struct StaticDescriptorInitializer_addressbook_2eproto {
}
} static_descriptor_initializer_addressbook_2eproto_;
const ::google::protobuf::EnumDescriptor* Gender_descriptor() {
protobuf_AssignDescriptorsOnce();
return Gender_descriptor_;
}
bool Gender_IsValid(int value) {
switch(value) {
case 0:
case 1:
case 2:
case 3:
return true;
default:
return false;
}
}
// ===================================================================
@ -452,6 +473,7 @@ void Person_PhoneNumber::Swap(Person_PhoneNumber* other) {
const int Person::kNameFieldNumber;
const int Person::kIdFieldNumber;
const int Person::kEmailFieldNumber;
const int Person::kTypeFieldNumber;
const int Person::kPhoneFieldNumber;
#endif // !_MSC_VER
@ -474,6 +496,7 @@ void Person::SharedCtor() {
name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
id_ = 0;
email_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
type_ = 0;
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
@ -525,6 +548,7 @@ void Person::Clear() {
email_->clear();
}
}
type_ = 0;
}
phone_.Clear();
::memset(_has_bits_, 0, sizeof(_has_bits_));
@ -582,12 +606,33 @@ bool Person::MergePartialFromCodedStream(
} else {
goto handle_uninterpreted;
}
if (input->ExpectTag(34)) goto parse_phone;
if (input->ExpectTag(32)) goto parse_type;
break;
}
// repeated .tutorial.Person.PhoneNumber phone = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
case 4: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
parse_type:
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
if (tutorial::Gender_IsValid(value)) {
set_type(static_cast< tutorial::Gender >(value));
} else {
mutable_unknown_fields()->AddVarint(4, value);
}
} else {
goto handle_uninterpreted;
}
if (input->ExpectTag(42)) goto parse_phone;
break;
}
// repeated .tutorial.Person.PhoneNumber phone = 5;
case 5: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
parse_phone:
@ -596,7 +641,7 @@ bool Person::MergePartialFromCodedStream(
} else {
goto handle_uninterpreted;
}
if (input->ExpectTag(34)) goto parse_phone;
if (input->ExpectTag(42)) goto parse_phone;
if (input->ExpectAtEnd()) return true;
break;
}
@ -642,10 +687,16 @@ void Person::SerializeWithCachedSizes(
3, this->email(), output);
}
// repeated .tutorial.Person.PhoneNumber phone = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
if (has_type()) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
4, this->type(), output);
}
// repeated .tutorial.Person.PhoneNumber phone = 5;
for (int i = 0; i < this->phone_size(); i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
4, this->phone(i), output);
5, this->phone(i), output);
}
if (!unknown_fields().empty()) {
@ -681,11 +732,17 @@ void Person::SerializeWithCachedSizes(
3, this->email(), target);
}
// repeated .tutorial.Person.PhoneNumber phone = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
if (has_type()) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
4, this->type(), target);
}
// repeated .tutorial.Person.PhoneNumber phone = 5;
for (int i = 0; i < this->phone_size(); i++) {
target = ::google::protobuf::internal::WireFormatLite::
WriteMessageNoVirtualToArray(
4, this->phone(i), target);
5, this->phone(i), target);
}
if (!unknown_fields().empty()) {
@ -720,8 +777,14 @@ int Person::ByteSize() const {
this->email());
}
// optional .tutorial.Gender type = 4 [default = NONE];
if (has_type()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->type());
}
}
// repeated .tutorial.Person.PhoneNumber phone = 4;
// repeated .tutorial.Person.PhoneNumber phone = 5;
total_size += 1 * this->phone_size();
for (int i = 0; i < this->phone_size(); i++) {
total_size +=
@ -765,6 +828,9 @@ void Person::MergeFrom(const Person& from) {
if (from.has_email()) {
set_email(from.email());
}
if (from.has_type()) {
set_type(from.type());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
@ -795,6 +861,7 @@ void Person::Swap(Person* other) {
std::swap(name_, other->name_);
std::swap(id_, other->id_);
std::swap(email_, other->email_);
std::swap(type_, other->type_);
phone_.Swap(&other->phone_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);

View File

@ -56,6 +56,27 @@ inline bool Person_PhoneType_Parse(
return ::google::protobuf::internal::ParseNamedEnum<Person_PhoneType>(
Person_PhoneType_descriptor(), name, value);
}
enum Gender {
NONE = 0,
MALE = 1,
FEMALE = 2,
OTHER = 3
};
bool Gender_IsValid(int value);
const Gender Gender_MIN = NONE;
const Gender Gender_MAX = OTHER;
const int Gender_ARRAYSIZE = Gender_MAX + 1;
const ::google::protobuf::EnumDescriptor* Gender_descriptor();
inline const ::std::string& Gender_Name(Gender value) {
return ::google::protobuf::internal::NameOfEnum(
Gender_descriptor(), value);
}
inline bool Gender_Parse(
const ::std::string& name, Gender* value) {
return ::google::protobuf::internal::ParseNamedEnum<Gender>(
Gender_descriptor(), name, value);
}
// ===================================================================
class Person_PhoneNumber : public ::google::protobuf::Message {
@ -264,10 +285,17 @@ class Person : public ::google::protobuf::Message {
inline ::std::string* mutable_email();
inline ::std::string* release_email();
// repeated .tutorial.Person.PhoneNumber phone = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
inline bool has_type() const;
inline void clear_type();
static const int kTypeFieldNumber = 4;
inline tutorial::Gender type() const;
inline void set_type(tutorial::Gender value);
// repeated .tutorial.Person.PhoneNumber phone = 5;
inline int phone_size() const;
inline void clear_phone();
static const int kPhoneFieldNumber = 4;
static const int kPhoneFieldNumber = 5;
inline const ::tutorial::Person_PhoneNumber& phone(int index) const;
inline ::tutorial::Person_PhoneNumber* mutable_phone(int index);
inline ::tutorial::Person_PhoneNumber* add_phone();
@ -284,16 +312,19 @@ class Person : public ::google::protobuf::Message {
inline void clear_has_id();
inline void set_has_email();
inline void clear_has_email();
inline void set_has_type();
inline void clear_has_type();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::std::string* name_;
::std::string* email_;
::google::protobuf::RepeatedPtrField< ::tutorial::Person_PhoneNumber > phone_;
::google::protobuf::int32 id_;
int type_;
::google::protobuf::RepeatedPtrField< ::tutorial::Person_PhoneNumber > phone_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
::google::protobuf::uint32 _has_bits_[(5 + 31) / 32];
friend void protobuf_AddDesc_addressbook_2eproto();
friend void protobuf_AssignDesc_addressbook_2eproto();
@ -617,7 +648,30 @@ inline ::std::string* Person::release_email() {
}
}
// repeated .tutorial.Person.PhoneNumber phone = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
inline bool Person::has_type() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}
inline void Person::set_has_type() {
_has_bits_[0] |= 0x00000008u;
}
inline void Person::clear_has_type() {
_has_bits_[0] &= ~0x00000008u;
}
inline void Person::clear_type() {
type_ = 0;
clear_has_type();
}
inline tutorial::Gender Person::type() const {
return static_cast< tutorial::Gender >(type_);
}
inline void Person::set_type(tutorial::Gender value) {
GOOGLE_DCHECK(tutorial::Gender_IsValid(value));
set_has_type();
type_ = value;
}
// repeated .tutorial.Person.PhoneNumber phone = 5;
inline int Person::phone_size() const {
return phone_.size();
}
@ -684,6 +738,10 @@ template <>
inline const EnumDescriptor* GetEnumDescriptor< ::tutorial::Person_PhoneType>() {
return ::tutorial::Person_PhoneType_descriptor();
}
template <>
inline const EnumDescriptor* GetEnumDescriptor< tutorial::Gender>() {
return tutorial::Gender_descriptor();
}
} // namespace google
} // namespace protobuf

View File

@ -8,6 +8,81 @@ public final class Addressbook {
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
}
public enum Gender
implements com.google.protobuf.ProtocolMessageEnum {
NONE(0, 0),
MALE(1, 1),
FEMALE(2, 2),
OTHER(3, 3),
;
public static final int NONE_VALUE = 0;
public static final int MALE_VALUE = 1;
public static final int FEMALE_VALUE = 2;
public static final int OTHER_VALUE = 3;
public final int getNumber() { return value; }
public static Gender valueOf(int value) {
switch (value) {
case 0: return NONE;
case 1: return MALE;
case 2: return FEMALE;
case 3: return OTHER;
default: return null;
}
}
public static com.google.protobuf.Internal.EnumLiteMap<Gender>
internalGetValueMap() {
return internalValueMap;
}
private static com.google.protobuf.Internal.EnumLiteMap<Gender>
internalValueMap =
new com.google.protobuf.Internal.EnumLiteMap<Gender>() {
public Gender findValueByNumber(int number) {
return Gender.valueOf(number);
}
};
public final com.google.protobuf.Descriptors.EnumValueDescriptor
getValueDescriptor() {
return getDescriptor().getValues().get(index);
}
public final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptorForType() {
return getDescriptor();
}
public static final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptor() {
return tutorial.Addressbook.getDescriptor().getEnumTypes().get(0);
}
private static final Gender[] VALUES = {
NONE, MALE, FEMALE, OTHER,
};
public static Gender valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
if (desc.getType() != getDescriptor()) {
throw new java.lang.IllegalArgumentException(
"EnumValueDescriptor is not for this type.");
}
return VALUES[desc.getIndex()];
}
private final int index;
private final int value;
private Gender(int index, int value) {
this.index = index;
this.value = value;
}
// @@protoc_insertion_point(enum_scope:tutorial.Gender)
}
public interface PersonOrBuilder
extends com.google.protobuf.MessageOrBuilder {
@ -23,7 +98,11 @@ public final class Addressbook {
boolean hasEmail();
String getEmail();
// repeated .tutorial.Person.PhoneNumber phone = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
boolean hasType();
tutorial.Addressbook.Gender getType();
// repeated .tutorial.Person.PhoneNumber phone = 5;
java.util.List<tutorial.Addressbook.Person.PhoneNumber>
getPhoneList();
tutorial.Addressbook.Person.PhoneNumber getPhone(int index);
@ -657,8 +736,18 @@ public final class Addressbook {
}
}
// repeated .tutorial.Person.PhoneNumber phone = 4;
public static final int PHONE_FIELD_NUMBER = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
public static final int TYPE_FIELD_NUMBER = 4;
private tutorial.Addressbook.Gender type_;
public boolean hasType() {
return ((bitField0_ & 0x00000008) == 0x00000008);
}
public tutorial.Addressbook.Gender getType() {
return type_;
}
// repeated .tutorial.Person.PhoneNumber phone = 5;
public static final int PHONE_FIELD_NUMBER = 5;
private java.util.List<tutorial.Addressbook.Person.PhoneNumber> phone_;
public java.util.List<tutorial.Addressbook.Person.PhoneNumber> getPhoneList() {
return phone_;
@ -682,6 +771,7 @@ public final class Addressbook {
name_ = "";
id_ = 0;
email_ = "";
type_ = tutorial.Addressbook.Gender.NONE;
phone_ = java.util.Collections.emptyList();
}
private byte memoizedIsInitialized = -1;
@ -719,8 +809,11 @@ public final class Addressbook {
if (((bitField0_ & 0x00000004) == 0x00000004)) {
output.writeBytes(3, getEmailBytes());
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeEnum(4, type_.getNumber());
}
for (int i = 0; i < phone_.size(); i++) {
output.writeMessage(4, phone_.get(i));
output.writeMessage(5, phone_.get(i));
}
getUnknownFields().writeTo(output);
}
@ -743,9 +836,13 @@ public final class Addressbook {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(3, getEmailBytes());
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += com.google.protobuf.CodedOutputStream
.computeEnumSize(4, type_.getNumber());
}
for (int i = 0; i < phone_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(4, phone_.get(i));
.computeMessageSize(5, phone_.get(i));
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@ -878,9 +975,11 @@ public final class Addressbook {
bitField0_ = (bitField0_ & ~0x00000002);
email_ = "";
bitField0_ = (bitField0_ & ~0x00000004);
type_ = tutorial.Addressbook.Gender.NONE;
bitField0_ = (bitField0_ & ~0x00000008);
if (phoneBuilder_ == null) {
phone_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
} else {
phoneBuilder_.clear();
}
@ -934,10 +1033,14 @@ public final class Addressbook {
to_bitField0_ |= 0x00000004;
}
result.email_ = email_;
if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
to_bitField0_ |= 0x00000008;
}
result.type_ = type_;
if (phoneBuilder_ == null) {
if (((bitField0_ & 0x00000008) == 0x00000008)) {
if (((bitField0_ & 0x00000010) == 0x00000010)) {
phone_ = java.util.Collections.unmodifiableList(phone_);
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
}
result.phone_ = phone_;
} else {
@ -968,11 +1071,14 @@ public final class Addressbook {
if (other.hasEmail()) {
setEmail(other.getEmail());
}
if (other.hasType()) {
setType(other.getType());
}
if (phoneBuilder_ == null) {
if (!other.phone_.isEmpty()) {
if (phone_.isEmpty()) {
phone_ = other.phone_;
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
} else {
ensurePhoneIsMutable();
phone_.addAll(other.phone_);
@ -985,7 +1091,7 @@ public final class Addressbook {
phoneBuilder_.dispose();
phoneBuilder_ = null;
phone_ = other.phone_;
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
phoneBuilder_ =
com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
getPhoneFieldBuilder() : null;
@ -1054,7 +1160,18 @@ public final class Addressbook {
email_ = input.readBytes();
break;
}
case 34: {
case 32: {
int rawValue = input.readEnum();
tutorial.Addressbook.Gender value = tutorial.Addressbook.Gender.valueOf(rawValue);
if (value == null) {
unknownFields.mergeVarintField(4, rawValue);
} else {
bitField0_ |= 0x00000008;
type_ = value;
}
break;
}
case 42: {
tutorial.Addressbook.Person.PhoneNumber.Builder subBuilder = tutorial.Addressbook.Person.PhoneNumber.newBuilder();
input.readMessage(subBuilder, extensionRegistry);
addPhone(subBuilder.buildPartial());
@ -1159,13 +1276,37 @@ public final class Addressbook {
onChanged();
}
// repeated .tutorial.Person.PhoneNumber phone = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
private tutorial.Addressbook.Gender type_ = tutorial.Addressbook.Gender.NONE;
public boolean hasType() {
return ((bitField0_ & 0x00000008) == 0x00000008);
}
public tutorial.Addressbook.Gender getType() {
return type_;
}
public Builder setType(tutorial.Addressbook.Gender value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000008;
type_ = value;
onChanged();
return this;
}
public Builder clearType() {
bitField0_ = (bitField0_ & ~0x00000008);
type_ = tutorial.Addressbook.Gender.NONE;
onChanged();
return this;
}
// repeated .tutorial.Person.PhoneNumber phone = 5;
private java.util.List<tutorial.Addressbook.Person.PhoneNumber> phone_ =
java.util.Collections.emptyList();
private void ensurePhoneIsMutable() {
if (!((bitField0_ & 0x00000008) == 0x00000008)) {
if (!((bitField0_ & 0x00000010) == 0x00000010)) {
phone_ = new java.util.ArrayList<tutorial.Addressbook.Person.PhoneNumber>(phone_);
bitField0_ |= 0x00000008;
bitField0_ |= 0x00000010;
}
}
@ -1281,7 +1422,7 @@ public final class Addressbook {
public Builder clearPhone() {
if (phoneBuilder_ == null) {
phone_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
onChanged();
} else {
phoneBuilder_.clear();
@ -1337,7 +1478,7 @@ public final class Addressbook {
phoneBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
tutorial.Addressbook.Person.PhoneNumber, tutorial.Addressbook.Person.PhoneNumber.Builder, tutorial.Addressbook.Person.PhoneNumberOrBuilder>(
phone_,
((bitField0_ & 0x00000008) == 0x00000008),
((bitField0_ & 0x00000010) == 0x00000010),
getParentForChildren(),
isClean());
phone_ = null;
@ -1943,14 +2084,16 @@ public final class Addressbook {
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\021addressbook.proto\022\010tutorial\"\332\001\n\006Person" +
"\n\021addressbook.proto\022\010tutorial\"\200\002\n\006Person" +
"\022\014\n\004name\030\001 \002(\t\022\n\n\002id\030\002 \002(\005\022\r\n\005email\030\003 \001(" +
"\t\022+\n\005phone\030\004 \003(\0132\034.tutorial.Person.Phone" +
"Number\032M\n\013PhoneNumber\022\016\n\006number\030\001 \002(\t\022.\n" +
"\004type\030\002 \001(\0162\032.tutorial.Person.PhoneType:" +
"\004HOME\"+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001" +
"\022\010\n\004WORK\020\002\"/\n\013AddressBook\022 \n\006person\030\001 \003(" +
"\0132\020.tutorial.Person"
"\t\022$\n\004type\030\004 \001(\0162\020.tutorial.Gender:\004NONE\022" +
"+\n\005phone\030\005 \003(\0132\034.tutorial.Person.PhoneNu" +
"mber\032M\n\013PhoneNumber\022\016\n\006number\030\001 \002(\t\022.\n\004t" +
"ype\030\002 \001(\0162\032.tutorial.Person.PhoneType:\004H" +
"OME\"+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001\022\010" +
"\n\004WORK\020\002\"/\n\013AddressBook\022 \n\006person\030\001 \003(\0132" +
"\020.tutorial.Person*3\n\006Gender\022\010\n\004NONE\020\000\022\010\n" +
"\004MALE\020\001\022\n\n\006FEMALE\020\002\022\t\n\005OTHER\020\003"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@ -1962,7 +2105,7 @@ public final class Addressbook {
internal_static_tutorial_Person_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_tutorial_Person_descriptor,
new java.lang.String[] { "Name", "Id", "Email", "Phone", },
new java.lang.String[] { "Name", "Id", "Email", "Type", "Phone", },
tutorial.Addressbook.Person.class,
tutorial.Addressbook.Person.Builder.class);
internal_static_tutorial_Person_PhoneNumber_descriptor =

View File

@ -11,8 +11,42 @@ from google.protobuf import descriptor_pb2
DESCRIPTOR = descriptor.FileDescriptor(
name='addressbook.proto',
package='tutorial',
serialized_pb='\n\x11\x61\x64\x64ressbook.proto\x12\x08tutorial\"\xda\x01\n\x06Person\x12\x0c\n\x04name\x18\x01 \x02(\t\x12\n\n\x02id\x18\x02 \x02(\x05\x12\r\n\x05\x65mail\x18\x03 \x01(\t\x12+\n\x05phone\x18\x04 \x03(\x0b\x32\x1c.tutorial.Person.PhoneNumber\x1aM\n\x0bPhoneNumber\x12\x0e\n\x06number\x18\x01 \x02(\t\x12.\n\x04type\x18\x02 \x01(\x0e\x32\x1a.tutorial.Person.PhoneType:\x04HOME\"+\n\tPhoneType\x12\n\n\x06MOBILE\x10\x00\x12\x08\n\x04HOME\x10\x01\x12\x08\n\x04WORK\x10\x02\"/\n\x0b\x41\x64\x64ressBook\x12 \n\x06person\x18\x01 \x03(\x0b\x32\x10.tutorial.Person')
serialized_pb='\n\x11\x61\x64\x64ressbook.proto\x12\x08tutorial\"\x80\x02\n\x06Person\x12\x0c\n\x04name\x18\x01 \x02(\t\x12\n\n\x02id\x18\x02 \x02(\x05\x12\r\n\x05\x65mail\x18\x03 \x01(\t\x12$\n\x04type\x18\x04 \x01(\x0e\x32\x10.tutorial.Gender:\x04NONE\x12+\n\x05phone\x18\x05 \x03(\x0b\x32\x1c.tutorial.Person.PhoneNumber\x1aM\n\x0bPhoneNumber\x12\x0e\n\x06number\x18\x01 \x02(\t\x12.\n\x04type\x18\x02 \x01(\x0e\x32\x1a.tutorial.Person.PhoneType:\x04HOME\"+\n\tPhoneType\x12\n\n\x06MOBILE\x10\x00\x12\x08\n\x04HOME\x10\x01\x12\x08\n\x04WORK\x10\x02\"/\n\x0b\x41\x64\x64ressBook\x12 \n\x06person\x18\x01 \x03(\x0b\x32\x10.tutorial.Person*3\n\x06Gender\x12\x08\n\x04NONE\x10\x00\x12\x08\n\x04MALE\x10\x01\x12\n\n\x06\x46\x45MALE\x10\x02\x12\t\n\x05OTHER\x10\x03')
_GENDER = descriptor.EnumDescriptor(
name='Gender',
full_name='tutorial.Gender',
filename=None,
file=DESCRIPTOR,
values=[
descriptor.EnumValueDescriptor(
name='NONE', index=0, number=0,
options=None,
type=None),
descriptor.EnumValueDescriptor(
name='MALE', index=1, number=1,
options=None,
type=None),
descriptor.EnumValueDescriptor(
name='FEMALE', index=2, number=2,
options=None,
type=None),
descriptor.EnumValueDescriptor(
name='OTHER', index=3, number=3,
options=None,
type=None),
],
containing_type=None,
options=None,
serialized_start=339,
serialized_end=390,
)
NONE = 0
MALE = 1
FEMALE = 2
OTHER = 3
_PERSON_PHONETYPE = descriptor.EnumDescriptor(
@ -36,8 +70,8 @@ _PERSON_PHONETYPE = descriptor.EnumDescriptor(
],
containing_type=None,
options=None,
serialized_start=207,
serialized_end=250,
serialized_start=245,
serialized_end=288,
)
@ -71,8 +105,8 @@ _PERSON_PHONENUMBER = descriptor.Descriptor(
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=128,
serialized_end=205,
serialized_start=166,
serialized_end=243,
)
_PERSON = descriptor.Descriptor(
@ -104,8 +138,15 @@ _PERSON = descriptor.Descriptor(
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='phone', full_name='tutorial.Person.phone', index=3,
number=4, type=11, cpp_type=10, label=3,
name='type', full_name='tutorial.Person.type', index=3,
number=4, type=14, cpp_type=8, label=1,
has_default_value=True, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='phone', full_name='tutorial.Person.phone', index=4,
number=5, type=11, cpp_type=10, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
@ -121,7 +162,7 @@ _PERSON = descriptor.Descriptor(
is_extendable=False,
extension_ranges=[],
serialized_start=32,
serialized_end=250,
serialized_end=288,
)
@ -148,12 +189,13 @@ _ADDRESSBOOK = descriptor.Descriptor(
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=252,
serialized_end=299,
serialized_start=290,
serialized_end=337,
)
_PERSON_PHONENUMBER.fields_by_name['type'].enum_type = _PERSON_PHONETYPE
_PERSON_PHONENUMBER.containing_type = _PERSON;
_PERSON.fields_by_name['type'].enum_type = _GENDER
_PERSON.fields_by_name['phone'].message_type = _PERSON_PHONENUMBER
_PERSON_PHONETYPE.containing_type = _PERSON;
_ADDRESSBOOK.fields_by_name['person'].message_type = _PERSON

View File

@ -1,9 +1,17 @@
package tutorial;
enum Gender {
NONE = 0;
MALE = 1;
FEMALE = 2;
OTHER = 3;
}
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
optional Gender type = 4 [default = NONE];
enum PhoneType {
MOBILE = 0;
@ -16,7 +24,7 @@ message Person {
optional PhoneType type = 2 [default = HOME];
}
repeated PhoneNumber phone = 4;
repeated PhoneNumber phone = 5;
}
message AddressBook {