...

Source file src/github.com/gogo/protobuf/test/enumdecl_all/enumdeclall.pb.go

Documentation: github.com/gogo/protobuf/test/enumdecl_all

     1  // Code generated by protoc-gen-gogo. DO NOT EDIT.
     2  // source: enumdeclall.proto
     3  
     4  package enumdeclall
     5  
     6  import (
     7  	bytes "bytes"
     8  	fmt "fmt"
     9  	_ "github.com/gogo/protobuf/gogoproto"
    10  	proto "github.com/gogo/protobuf/proto"
    11  	io "io"
    12  	math "math"
    13  	math_bits "math/bits"
    14  )
    15  
    16  // Reference imports to suppress errors if they are not otherwise used.
    17  var _ = proto.Marshal
    18  var _ = fmt.Errorf
    19  var _ = math.Inf
    20  
    21  // This is a compile-time assertion to ensure that this generated file
    22  // is compatible with the proto package it is being compiled against.
    23  // A compilation error at this line likely means your copy of the
    24  // proto package needs to be updated.
    25  const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
    26  
    27  var MyEnum_name = map[int32]string{
    28  	0: "A",
    29  	1: "B",
    30  }
    31  
    32  var MyEnum_value = map[string]int32{
    33  	"A": 0,
    34  	"B": 1,
    35  }
    36  
    37  func (x MyEnum) String() string {
    38  	return proto.EnumName(MyEnum_name, int32(x))
    39  }
    40  
    41  func (MyEnum) EnumDescriptor() ([]byte, []int) {
    42  	return fileDescriptor_d9b5f61a7b003e8e, []int{0}
    43  }
    44  
    45  type MyOtherEnum int32
    46  
    47  const (
    48  	C MyOtherEnum = 0
    49  	D MyOtherEnum = 1
    50  )
    51  
    52  var MyOtherEnum_name = map[int32]string{
    53  	0: "C",
    54  	1: "D",
    55  }
    56  
    57  var MyOtherEnum_value = map[string]int32{
    58  	"C": 0,
    59  	"D": 1,
    60  }
    61  
    62  func (x MyOtherEnum) String() string {
    63  	return proto.EnumName(MyOtherEnum_name, int32(x))
    64  }
    65  
    66  func (MyOtherEnum) EnumDescriptor() ([]byte, []int) {
    67  	return fileDescriptor_d9b5f61a7b003e8e, []int{1}
    68  }
    69  
    70  type Message struct {
    71  	EnumeratedField      MyEnum      `protobuf:"varint,1,opt,name=enumerated_field,json=enumeratedField,proto3,enum=enumdeclall.MyEnum" json:"enumerated_field,omitempty"`
    72  	OtherenumeratedField MyOtherEnum `protobuf:"varint,2,opt,name=otherenumerated_field,json=otherenumeratedField,proto3,enum=enumdeclall.MyOtherEnum" json:"otherenumerated_field,omitempty"`
    73  	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
    74  	XXX_unrecognized     []byte      `json:"-"`
    75  	XXX_sizecache        int32       `json:"-"`
    76  }
    77  
    78  func (m *Message) Reset()         { *m = Message{} }
    79  func (m *Message) String() string { return proto.CompactTextString(m) }
    80  func (*Message) ProtoMessage()    {}
    81  func (*Message) Descriptor() ([]byte, []int) {
    82  	return fileDescriptor_d9b5f61a7b003e8e, []int{0}
    83  }
    84  func (m *Message) XXX_Unmarshal(b []byte) error {
    85  	return m.Unmarshal(b)
    86  }
    87  func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
    88  	if deterministic {
    89  		return xxx_messageInfo_Message.Marshal(b, m, deterministic)
    90  	} else {
    91  		b = b[:cap(b)]
    92  		n, err := m.MarshalToSizedBuffer(b)
    93  		if err != nil {
    94  			return nil, err
    95  		}
    96  		return b[:n], nil
    97  	}
    98  }
    99  func (m *Message) XXX_Merge(src proto.Message) {
   100  	xxx_messageInfo_Message.Merge(m, src)
   101  }
   102  func (m *Message) XXX_Size() int {
   103  	return m.Size()
   104  }
   105  func (m *Message) XXX_DiscardUnknown() {
   106  	xxx_messageInfo_Message.DiscardUnknown(m)
   107  }
   108  
   109  var xxx_messageInfo_Message proto.InternalMessageInfo
   110  
   111  func (m *Message) GetEnumeratedField() MyEnum {
   112  	if m != nil {
   113  		return m.EnumeratedField
   114  	}
   115  	return A
   116  }
   117  
   118  func (m *Message) GetOtherenumeratedField() MyOtherEnum {
   119  	if m != nil {
   120  		return m.OtherenumeratedField
   121  	}
   122  	return C
   123  }
   124  
   125  func init() {
   126  	proto.RegisterEnum("enumdeclall.MyEnum", MyEnum_name, MyEnum_value)
   127  	proto.RegisterEnum("enumdeclall.MyOtherEnum", MyOtherEnum_name, MyOtherEnum_value)
   128  	proto.RegisterType((*Message)(nil), "enumdeclall.Message")
   129  }
   130  
   131  func init() { proto.RegisterFile("enumdeclall.proto", fileDescriptor_d9b5f61a7b003e8e) }
   132  
   133  var fileDescriptor_d9b5f61a7b003e8e = []byte{
   134  	// 260 bytes of a gzipped FileDescriptorProto
   135  	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4c, 0xcd, 0x2b, 0xcd,
   136  	0x4d, 0x49, 0x4d, 0xce, 0x49, 0xcc, 0xc9, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x46,
   137  	0x12, 0x92, 0xd2, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf,
   138  	0x4f, 0xcf, 0xd7, 0x07, 0xab, 0x49, 0x2a, 0x4d, 0x03, 0xf3, 0xc0, 0x1c, 0x30, 0x0b, 0xa2, 0x57,
   139  	0x69, 0x06, 0x23, 0x17, 0xbb, 0x6f, 0x6a, 0x71, 0x71, 0x62, 0x7a, 0xaa, 0x90, 0x1d, 0x97, 0x00,
   140  	0xc8, 0xa4, 0xd4, 0xa2, 0xc4, 0x92, 0xd4, 0x94, 0xf8, 0xb4, 0xcc, 0xd4, 0x9c, 0x14, 0x09, 0x46,
   141  	0x05, 0x46, 0x0d, 0x3e, 0x23, 0x61, 0x3d, 0x64, 0x5b, 0x7d, 0x2b, 0x5d, 0xf3, 0x4a, 0x73, 0x83,
   142  	0xf8, 0x11, 0x8a, 0xdd, 0x40, 0x6a, 0x85, 0x7c, 0xb9, 0x44, 0xf3, 0x4b, 0x32, 0x52, 0x8b, 0x30,
   143  	0x0c, 0x61, 0x02, 0x1b, 0x22, 0x81, 0x66, 0x88, 0x3f, 0x48, 0x2d, 0xd8, 0x24, 0x11, 0x34, 0x6d,
   144  	0x60, 0xe3, 0xb4, 0x64, 0xb8, 0xd8, 0x20, 0x36, 0x09, 0xb1, 0x72, 0x31, 0x3a, 0x0a, 0x30, 0x80,
   145  	0x28, 0x27, 0x01, 0x46, 0x29, 0x96, 0x8e, 0xc5, 0x72, 0x0c, 0x5a, 0xaa, 0x5c, 0xdc, 0x48, 0x46,
   146  	0x80, 0xe4, 0x9c, 0x21, 0x4a, 0x5c, 0x04, 0x18, 0xa5, 0x38, 0x40, 0x4a, 0x0e, 0x2c, 0x91, 0x63,
   147  	0x74, 0xd2, 0x79, 0xf0, 0x50, 0x8e, 0xf1, 0xc7, 0x43, 0x39, 0xc6, 0x15, 0x8f, 0xe4, 0x18, 0x77,
   148  	0x3c, 0x92, 0x63, 0x3c, 0xf0, 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18,
   149  	0x1f, 0x3c, 0x92, 0x63, 0xfc, 0xf1, 0x48, 0x8e, 0xa1, 0xe1, 0xb1, 0x1c, 0xc3, 0x8e, 0xc7, 0x72,
   150  	0x0c, 0x49, 0x6c, 0xe0, 0x40, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x4e, 0x91, 0xd9, 0xaf,
   151  	0x65, 0x01, 0x00, 0x00,
   152  }
   153  
   154  func (this *Message) VerboseEqual(that interface{}) error {
   155  	if that == nil {
   156  		if this == nil {
   157  			return nil
   158  		}
   159  		return fmt.Errorf("that == nil && this != nil")
   160  	}
   161  
   162  	that1, ok := that.(*Message)
   163  	if !ok {
   164  		that2, ok := that.(Message)
   165  		if ok {
   166  			that1 = &that2
   167  		} else {
   168  			return fmt.Errorf("that is not of type *Message")
   169  		}
   170  	}
   171  	if that1 == nil {
   172  		if this == nil {
   173  			return nil
   174  		}
   175  		return fmt.Errorf("that is type *Message but is nil && this != nil")
   176  	} else if this == nil {
   177  		return fmt.Errorf("that is type *Message but is not nil && this == nil")
   178  	}
   179  	if this.EnumeratedField != that1.EnumeratedField {
   180  		return fmt.Errorf("EnumeratedField this(%v) Not Equal that(%v)", this.EnumeratedField, that1.EnumeratedField)
   181  	}
   182  	if this.OtherenumeratedField != that1.OtherenumeratedField {
   183  		return fmt.Errorf("OtherenumeratedField this(%v) Not Equal that(%v)", this.OtherenumeratedField, that1.OtherenumeratedField)
   184  	}
   185  	if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
   186  		return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized)
   187  	}
   188  	return nil
   189  }
   190  func (this *Message) Equal(that interface{}) bool {
   191  	if that == nil {
   192  		return this == nil
   193  	}
   194  
   195  	that1, ok := that.(*Message)
   196  	if !ok {
   197  		that2, ok := that.(Message)
   198  		if ok {
   199  			that1 = &that2
   200  		} else {
   201  			return false
   202  		}
   203  	}
   204  	if that1 == nil {
   205  		return this == nil
   206  	} else if this == nil {
   207  		return false
   208  	}
   209  	if this.EnumeratedField != that1.EnumeratedField {
   210  		return false
   211  	}
   212  	if this.OtherenumeratedField != that1.OtherenumeratedField {
   213  		return false
   214  	}
   215  	if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
   216  		return false
   217  	}
   218  	return true
   219  }
   220  func (m *Message) Marshal() (dAtA []byte, err error) {
   221  	size := m.Size()
   222  	dAtA = make([]byte, size)
   223  	n, err := m.MarshalToSizedBuffer(dAtA[:size])
   224  	if err != nil {
   225  		return nil, err
   226  	}
   227  	return dAtA[:n], nil
   228  }
   229  
   230  func (m *Message) MarshalTo(dAtA []byte) (int, error) {
   231  	size := m.Size()
   232  	return m.MarshalToSizedBuffer(dAtA[:size])
   233  }
   234  
   235  func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) {
   236  	i := len(dAtA)
   237  	_ = i
   238  	var l int
   239  	_ = l
   240  	if m.XXX_unrecognized != nil {
   241  		i -= len(m.XXX_unrecognized)
   242  		copy(dAtA[i:], m.XXX_unrecognized)
   243  	}
   244  	if m.OtherenumeratedField != 0 {
   245  		i = encodeVarintEnumdeclall(dAtA, i, uint64(m.OtherenumeratedField))
   246  		i--
   247  		dAtA[i] = 0x10
   248  	}
   249  	if m.EnumeratedField != 0 {
   250  		i = encodeVarintEnumdeclall(dAtA, i, uint64(m.EnumeratedField))
   251  		i--
   252  		dAtA[i] = 0x8
   253  	}
   254  	return len(dAtA) - i, nil
   255  }
   256  
   257  func encodeVarintEnumdeclall(dAtA []byte, offset int, v uint64) int {
   258  	offset -= sovEnumdeclall(v)
   259  	base := offset
   260  	for v >= 1<<7 {
   261  		dAtA[offset] = uint8(v&0x7f | 0x80)
   262  		v >>= 7
   263  		offset++
   264  	}
   265  	dAtA[offset] = uint8(v)
   266  	return base
   267  }
   268  func NewPopulatedMessage(r randyEnumdeclall, easy bool) *Message {
   269  	this := &Message{}
   270  	this.EnumeratedField = MyEnum([]int32{0, 1}[r.Intn(2)])
   271  	this.OtherenumeratedField = MyOtherEnum([]int32{0, 1}[r.Intn(2)])
   272  	if !easy && r.Intn(10) != 0 {
   273  		this.XXX_unrecognized = randUnrecognizedEnumdeclall(r, 3)
   274  	}
   275  	return this
   276  }
   277  
   278  type randyEnumdeclall interface {
   279  	Float32() float32
   280  	Float64() float64
   281  	Int63() int64
   282  	Int31() int32
   283  	Uint32() uint32
   284  	Intn(n int) int
   285  }
   286  
   287  func randUTF8RuneEnumdeclall(r randyEnumdeclall) rune {
   288  	ru := r.Intn(62)
   289  	if ru < 10 {
   290  		return rune(ru + 48)
   291  	} else if ru < 36 {
   292  		return rune(ru + 55)
   293  	}
   294  	return rune(ru + 61)
   295  }
   296  func randStringEnumdeclall(r randyEnumdeclall) string {
   297  	v1 := r.Intn(100)
   298  	tmps := make([]rune, v1)
   299  	for i := 0; i < v1; i++ {
   300  		tmps[i] = randUTF8RuneEnumdeclall(r)
   301  	}
   302  	return string(tmps)
   303  }
   304  func randUnrecognizedEnumdeclall(r randyEnumdeclall, maxFieldNumber int) (dAtA []byte) {
   305  	l := r.Intn(5)
   306  	for i := 0; i < l; i++ {
   307  		wire := r.Intn(4)
   308  		if wire == 3 {
   309  			wire = 5
   310  		}
   311  		fieldNumber := maxFieldNumber + r.Intn(100)
   312  		dAtA = randFieldEnumdeclall(dAtA, r, fieldNumber, wire)
   313  	}
   314  	return dAtA
   315  }
   316  func randFieldEnumdeclall(dAtA []byte, r randyEnumdeclall, fieldNumber int, wire int) []byte {
   317  	key := uint32(fieldNumber)<<3 | uint32(wire)
   318  	switch wire {
   319  	case 0:
   320  		dAtA = encodeVarintPopulateEnumdeclall(dAtA, uint64(key))
   321  		v2 := r.Int63()
   322  		if r.Intn(2) == 0 {
   323  			v2 *= -1
   324  		}
   325  		dAtA = encodeVarintPopulateEnumdeclall(dAtA, uint64(v2))
   326  	case 1:
   327  		dAtA = encodeVarintPopulateEnumdeclall(dAtA, uint64(key))
   328  		dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
   329  	case 2:
   330  		dAtA = encodeVarintPopulateEnumdeclall(dAtA, uint64(key))
   331  		ll := r.Intn(100)
   332  		dAtA = encodeVarintPopulateEnumdeclall(dAtA, uint64(ll))
   333  		for j := 0; j < ll; j++ {
   334  			dAtA = append(dAtA, byte(r.Intn(256)))
   335  		}
   336  	default:
   337  		dAtA = encodeVarintPopulateEnumdeclall(dAtA, uint64(key))
   338  		dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
   339  	}
   340  	return dAtA
   341  }
   342  func encodeVarintPopulateEnumdeclall(dAtA []byte, v uint64) []byte {
   343  	for v >= 1<<7 {
   344  		dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
   345  		v >>= 7
   346  	}
   347  	dAtA = append(dAtA, uint8(v))
   348  	return dAtA
   349  }
   350  func (m *Message) Size() (n int) {
   351  	if m == nil {
   352  		return 0
   353  	}
   354  	var l int
   355  	_ = l
   356  	if m.EnumeratedField != 0 {
   357  		n += 1 + sovEnumdeclall(uint64(m.EnumeratedField))
   358  	}
   359  	if m.OtherenumeratedField != 0 {
   360  		n += 1 + sovEnumdeclall(uint64(m.OtherenumeratedField))
   361  	}
   362  	if m.XXX_unrecognized != nil {
   363  		n += len(m.XXX_unrecognized)
   364  	}
   365  	return n
   366  }
   367  
   368  func sovEnumdeclall(x uint64) (n int) {
   369  	return (math_bits.Len64(x|1) + 6) / 7
   370  }
   371  func sozEnumdeclall(x uint64) (n int) {
   372  	return sovEnumdeclall(uint64((x << 1) ^ uint64((int64(x) >> 63))))
   373  }
   374  func (m *Message) Unmarshal(dAtA []byte) error {
   375  	l := len(dAtA)
   376  	iNdEx := 0
   377  	for iNdEx < l {
   378  		preIndex := iNdEx
   379  		var wire uint64
   380  		for shift := uint(0); ; shift += 7 {
   381  			if shift >= 64 {
   382  				return ErrIntOverflowEnumdeclall
   383  			}
   384  			if iNdEx >= l {
   385  				return io.ErrUnexpectedEOF
   386  			}
   387  			b := dAtA[iNdEx]
   388  			iNdEx++
   389  			wire |= uint64(b&0x7F) << shift
   390  			if b < 0x80 {
   391  				break
   392  			}
   393  		}
   394  		fieldNum := int32(wire >> 3)
   395  		wireType := int(wire & 0x7)
   396  		if wireType == 4 {
   397  			return fmt.Errorf("proto: Message: wiretype end group for non-group")
   398  		}
   399  		if fieldNum <= 0 {
   400  			return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire)
   401  		}
   402  		switch fieldNum {
   403  		case 1:
   404  			if wireType != 0 {
   405  				return fmt.Errorf("proto: wrong wireType = %d for field EnumeratedField", wireType)
   406  			}
   407  			m.EnumeratedField = 0
   408  			for shift := uint(0); ; shift += 7 {
   409  				if shift >= 64 {
   410  					return ErrIntOverflowEnumdeclall
   411  				}
   412  				if iNdEx >= l {
   413  					return io.ErrUnexpectedEOF
   414  				}
   415  				b := dAtA[iNdEx]
   416  				iNdEx++
   417  				m.EnumeratedField |= MyEnum(b&0x7F) << shift
   418  				if b < 0x80 {
   419  					break
   420  				}
   421  			}
   422  		case 2:
   423  			if wireType != 0 {
   424  				return fmt.Errorf("proto: wrong wireType = %d for field OtherenumeratedField", wireType)
   425  			}
   426  			m.OtherenumeratedField = 0
   427  			for shift := uint(0); ; shift += 7 {
   428  				if shift >= 64 {
   429  					return ErrIntOverflowEnumdeclall
   430  				}
   431  				if iNdEx >= l {
   432  					return io.ErrUnexpectedEOF
   433  				}
   434  				b := dAtA[iNdEx]
   435  				iNdEx++
   436  				m.OtherenumeratedField |= MyOtherEnum(b&0x7F) << shift
   437  				if b < 0x80 {
   438  					break
   439  				}
   440  			}
   441  		default:
   442  			iNdEx = preIndex
   443  			skippy, err := skipEnumdeclall(dAtA[iNdEx:])
   444  			if err != nil {
   445  				return err
   446  			}
   447  			if (skippy < 0) || (iNdEx+skippy) < 0 {
   448  				return ErrInvalidLengthEnumdeclall
   449  			}
   450  			if (iNdEx + skippy) > l {
   451  				return io.ErrUnexpectedEOF
   452  			}
   453  			m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
   454  			iNdEx += skippy
   455  		}
   456  	}
   457  
   458  	if iNdEx > l {
   459  		return io.ErrUnexpectedEOF
   460  	}
   461  	return nil
   462  }
   463  func skipEnumdeclall(dAtA []byte) (n int, err error) {
   464  	l := len(dAtA)
   465  	iNdEx := 0
   466  	depth := 0
   467  	for iNdEx < l {
   468  		var wire uint64
   469  		for shift := uint(0); ; shift += 7 {
   470  			if shift >= 64 {
   471  				return 0, ErrIntOverflowEnumdeclall
   472  			}
   473  			if iNdEx >= l {
   474  				return 0, io.ErrUnexpectedEOF
   475  			}
   476  			b := dAtA[iNdEx]
   477  			iNdEx++
   478  			wire |= (uint64(b) & 0x7F) << shift
   479  			if b < 0x80 {
   480  				break
   481  			}
   482  		}
   483  		wireType := int(wire & 0x7)
   484  		switch wireType {
   485  		case 0:
   486  			for shift := uint(0); ; shift += 7 {
   487  				if shift >= 64 {
   488  					return 0, ErrIntOverflowEnumdeclall
   489  				}
   490  				if iNdEx >= l {
   491  					return 0, io.ErrUnexpectedEOF
   492  				}
   493  				iNdEx++
   494  				if dAtA[iNdEx-1] < 0x80 {
   495  					break
   496  				}
   497  			}
   498  		case 1:
   499  			iNdEx += 8
   500  		case 2:
   501  			var length int
   502  			for shift := uint(0); ; shift += 7 {
   503  				if shift >= 64 {
   504  					return 0, ErrIntOverflowEnumdeclall
   505  				}
   506  				if iNdEx >= l {
   507  					return 0, io.ErrUnexpectedEOF
   508  				}
   509  				b := dAtA[iNdEx]
   510  				iNdEx++
   511  				length |= (int(b) & 0x7F) << shift
   512  				if b < 0x80 {
   513  					break
   514  				}
   515  			}
   516  			if length < 0 {
   517  				return 0, ErrInvalidLengthEnumdeclall
   518  			}
   519  			iNdEx += length
   520  		case 3:
   521  			depth++
   522  		case 4:
   523  			if depth == 0 {
   524  				return 0, ErrUnexpectedEndOfGroupEnumdeclall
   525  			}
   526  			depth--
   527  		case 5:
   528  			iNdEx += 4
   529  		default:
   530  			return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
   531  		}
   532  		if iNdEx < 0 {
   533  			return 0, ErrInvalidLengthEnumdeclall
   534  		}
   535  		if depth == 0 {
   536  			return iNdEx, nil
   537  		}
   538  	}
   539  	return 0, io.ErrUnexpectedEOF
   540  }
   541  
   542  var (
   543  	ErrInvalidLengthEnumdeclall        = fmt.Errorf("proto: negative length found during unmarshaling")
   544  	ErrIntOverflowEnumdeclall          = fmt.Errorf("proto: integer overflow")
   545  	ErrUnexpectedEndOfGroupEnumdeclall = fmt.Errorf("proto: unexpected end of group")
   546  )
   547  

View as plain text