mirror of
				https://github.com/redhat-developer/odo.git
				synced 2025-10-19 03:06:19 +03:00 
			
		
		
		
	glide.yaml replace github.com/kr/pty with github.com/creack/pty (#2783)
This commit is contained in:
		
							
								
								
									
										25
									
								
								glide.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										25
									
								
								glide.lock
									
									
									
										generated
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| hash: fc7706bbd5add40db1d34034d794abc8a892b9fb357d30d75f568bf1ba07f527 | ||||
| updated: 2020-03-13T17:01:49.595596-04:00 | ||||
| hash: 50333e5c7bd72e64e86a1ebee079f97232af5304746d341a47b38ea64e0db48d | ||||
| updated: 2020-03-31T11:38:10.907323+02:00 | ||||
| imports: | ||||
| - name: cloud.google.com/go | ||||
|   version: 3b1ae45394a234c385be014e9a488f2bb6eef821 | ||||
| @@ -40,8 +40,6 @@ imports: | ||||
|   version: d76c121f76a5fc8a462dc64594aea72fe18e1178 | ||||
|   subpackages: | ||||
|   - errdefs | ||||
| - name: github.com/creack/pty | ||||
|   version: 8ab47f72e8547a066b4ea926f4523775bc1a0ec2 | ||||
| - name: github.com/davecgh/go-spew | ||||
|   version: d8f796af33cc11cb798c1aaeb27a4ebc5099927d | ||||
|   subpackages: | ||||
| @@ -123,7 +121,7 @@ imports: | ||||
|   - util/runes | ||||
|   - util/strings | ||||
| - name: github.com/gogo/protobuf | ||||
|   version: 5628607bb4c51c3157aacc3a50f0ab707582b805 | ||||
|   version: c0656edd0d9eab7c66d1eb0c568f9039345796f7 | ||||
|   subpackages: | ||||
|   - proto | ||||
|   - sortkeys | ||||
| @@ -144,7 +142,7 @@ imports: | ||||
| - name: github.com/google/btree | ||||
|   version: 479b5e81b0a93ec038d201b0b33d17db599531d3 | ||||
| - name: github.com/google/gofuzz | ||||
|   version: 1868c06f7fd92d7b8635996f597f048d5ab709aa | ||||
|   version: 44d81051d367757e1c7c6a5a86423ece9afcf63c | ||||
| - name: github.com/google/uuid | ||||
|   version: 8c31c18f31ede9fc8eae72290a7e7a8064e9b3e3 | ||||
| - name: github.com/googleapis/gnostic | ||||
| @@ -177,7 +175,7 @@ imports: | ||||
| - name: github.com/hinshun/vt10x | ||||
|   version: d55458df857cfff952e4bf72ce1b567c5a4e141c | ||||
| - name: github.com/hpcloud/tail | ||||
|   version: a1dbeea552b7c8df4b542c66073e393de198a800 | ||||
|   version: a30252cb686a21eb2d0b98132633053ec2f7f1e5 | ||||
|   subpackages: | ||||
|   - ratelimiter | ||||
|   - util | ||||
| @@ -192,7 +190,8 @@ imports: | ||||
| - name: github.com/kballard/go-shellquote | ||||
|   version: 95032a82bc518f77982ea72343cc1ade730072f0 | ||||
| - name: github.com/kr/pty | ||||
|   version: 24b51915630e1d9d3c6adf15a3a96796bbc3cd43 | ||||
|   version: 3a6a957789163cacdfe0e291617a1c8e80612c11 | ||||
|   repo: https://github.com/creack/pty | ||||
| - name: github.com/kubernetes-incubator/service-catalog | ||||
|   version: 49e5cc4f90c6794d490eea4256061797223d9564 | ||||
|   subpackages: | ||||
| @@ -226,7 +225,7 @@ imports: | ||||
| - name: github.com/mattn/go-isatty | ||||
|   version: cb30d6282491c185f77d9bec5d25de1bb61a06bc | ||||
| - name: github.com/mattn/go-runewidth | ||||
|   version: 588506649b41f3e5b80a725a9bea447106b4f0d3 | ||||
|   version: 14e809f6d78fcf9f48ff9b70981472b64c05f754 | ||||
| - name: github.com/matttproud/golang_protobuf_extensions | ||||
|   version: c12348ce28de40eed0136aa2b644d0ee0650e56c | ||||
|   subpackages: | ||||
| @@ -573,14 +572,14 @@ imports: | ||||
|   subpackages: | ||||
|   - core | ||||
|   - terminal | ||||
| - name: gopkg.in/fsnotify/fsnotify.v1 | ||||
|   version: 45d7d09e39ef4ac08d493309fa031790c15bfe8a | ||||
| - name: gopkg.in/fsnotify.v1 | ||||
|   version: 7be54206639f256967dd82fa767397ba5f8f48f5 | ||||
| - name: gopkg.in/inf.v0 | ||||
|   version: d2d2541c53f18d2a059457998ce2876cc8e67cbf | ||||
|   version: 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4 | ||||
| - name: gopkg.in/tomb.v1 | ||||
|   version: c131134a1947e9afd9cecfe11f4c6dff0732ae58 | ||||
| - name: gopkg.in/yaml.v2 | ||||
|   version: 53403b58ad1b561927d19068c655246f2db79d48 | ||||
|   version: f221b8435cfb71e54062f6c6e99e9ade30b124d5 | ||||
| - name: k8s.io/api | ||||
|   version: b18e97b54e4005d2ff259a96a0b5d06f11779b9d | ||||
|   repo: https://github.com/openshift/kubernetes-api.git | ||||
|   | ||||
| @@ -27,6 +27,9 @@ import: | ||||
| - package: k8s.io/api | ||||
|   version: origin-4.1-kubernetes-1.13.4 | ||||
|   repo: https://github.com/openshift/kubernetes-api.git | ||||
| - package: github.com/kr/pty | ||||
|   version: v1.1.9 | ||||
|   repo: https://github.com/creack/pty | ||||
| - package: github.com/onsi/gomega | ||||
|   version: v1.9.0 | ||||
| - package: github.com/onsi/ginkgo | ||||
|   | ||||
| @@ -1,5 +1,3 @@ | ||||
| // +build !windows | ||||
|  | ||||
| package ui | ||||
|  | ||||
| import ( | ||||
|   | ||||
| @@ -1,5 +1,3 @@ | ||||
| // +build !windows | ||||
|  | ||||
| package testingutil | ||||
|  | ||||
| import ( | ||||
|   | ||||
							
								
								
									
										274
									
								
								vendor/github.com/Microsoft/go-winio/ea.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										274
									
								
								vendor/github.com/Microsoft/go-winio/ea.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,137 +1,137 @@ | ||||
| package winio | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"encoding/binary" | ||||
| 	"errors" | ||||
| ) | ||||
|  | ||||
| type fileFullEaInformation struct { | ||||
| 	NextEntryOffset uint32 | ||||
| 	Flags           uint8 | ||||
| 	NameLength      uint8 | ||||
| 	ValueLength     uint16 | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	fileFullEaInformationSize = binary.Size(&fileFullEaInformation{}) | ||||
|  | ||||
| 	errInvalidEaBuffer = errors.New("invalid extended attribute buffer") | ||||
| 	errEaNameTooLarge  = errors.New("extended attribute name too large") | ||||
| 	errEaValueTooLarge = errors.New("extended attribute value too large") | ||||
| ) | ||||
|  | ||||
| // ExtendedAttribute represents a single Windows EA. | ||||
| type ExtendedAttribute struct { | ||||
| 	Name  string | ||||
| 	Value []byte | ||||
| 	Flags uint8 | ||||
| } | ||||
|  | ||||
| func parseEa(b []byte) (ea ExtendedAttribute, nb []byte, err error) { | ||||
| 	var info fileFullEaInformation | ||||
| 	err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &info) | ||||
| 	if err != nil { | ||||
| 		err = errInvalidEaBuffer | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	nameOffset := fileFullEaInformationSize | ||||
| 	nameLen := int(info.NameLength) | ||||
| 	valueOffset := nameOffset + int(info.NameLength) + 1 | ||||
| 	valueLen := int(info.ValueLength) | ||||
| 	nextOffset := int(info.NextEntryOffset) | ||||
| 	if valueLen+valueOffset > len(b) || nextOffset < 0 || nextOffset > len(b) { | ||||
| 		err = errInvalidEaBuffer | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	ea.Name = string(b[nameOffset : nameOffset+nameLen]) | ||||
| 	ea.Value = b[valueOffset : valueOffset+valueLen] | ||||
| 	ea.Flags = info.Flags | ||||
| 	if info.NextEntryOffset != 0 { | ||||
| 		nb = b[info.NextEntryOffset:] | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // DecodeExtendedAttributes decodes a list of EAs from a FILE_FULL_EA_INFORMATION | ||||
| // buffer retrieved from BackupRead, ZwQueryEaFile, etc. | ||||
| func DecodeExtendedAttributes(b []byte) (eas []ExtendedAttribute, err error) { | ||||
| 	for len(b) != 0 { | ||||
| 		ea, nb, err := parseEa(b) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
|  | ||||
| 		eas = append(eas, ea) | ||||
| 		b = nb | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func writeEa(buf *bytes.Buffer, ea *ExtendedAttribute, last bool) error { | ||||
| 	if int(uint8(len(ea.Name))) != len(ea.Name) { | ||||
| 		return errEaNameTooLarge | ||||
| 	} | ||||
| 	if int(uint16(len(ea.Value))) != len(ea.Value) { | ||||
| 		return errEaValueTooLarge | ||||
| 	} | ||||
| 	entrySize := uint32(fileFullEaInformationSize + len(ea.Name) + 1 + len(ea.Value)) | ||||
| 	withPadding := (entrySize + 3) &^ 3 | ||||
| 	nextOffset := uint32(0) | ||||
| 	if !last { | ||||
| 		nextOffset = withPadding | ||||
| 	} | ||||
| 	info := fileFullEaInformation{ | ||||
| 		NextEntryOffset: nextOffset, | ||||
| 		Flags:           ea.Flags, | ||||
| 		NameLength:      uint8(len(ea.Name)), | ||||
| 		ValueLength:     uint16(len(ea.Value)), | ||||
| 	} | ||||
|  | ||||
| 	err := binary.Write(buf, binary.LittleEndian, &info) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	_, err = buf.Write([]byte(ea.Name)) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	err = buf.WriteByte(0) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	_, err = buf.Write(ea.Value) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	_, err = buf.Write([]byte{0, 0, 0}[0 : withPadding-entrySize]) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // EncodeExtendedAttributes encodes a list of EAs into a FILE_FULL_EA_INFORMATION | ||||
| // buffer for use with BackupWrite, ZwSetEaFile, etc. | ||||
| func EncodeExtendedAttributes(eas []ExtendedAttribute) ([]byte, error) { | ||||
| 	var buf bytes.Buffer | ||||
| 	for i := range eas { | ||||
| 		last := false | ||||
| 		if i == len(eas)-1 { | ||||
| 			last = true | ||||
| 		} | ||||
|  | ||||
| 		err := writeEa(&buf, &eas[i], last) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return buf.Bytes(), nil | ||||
| } | ||||
| package winio | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"encoding/binary" | ||||
| 	"errors" | ||||
| ) | ||||
|  | ||||
| type fileFullEaInformation struct { | ||||
| 	NextEntryOffset uint32 | ||||
| 	Flags           uint8 | ||||
| 	NameLength      uint8 | ||||
| 	ValueLength     uint16 | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	fileFullEaInformationSize = binary.Size(&fileFullEaInformation{}) | ||||
|  | ||||
| 	errInvalidEaBuffer = errors.New("invalid extended attribute buffer") | ||||
| 	errEaNameTooLarge  = errors.New("extended attribute name too large") | ||||
| 	errEaValueTooLarge = errors.New("extended attribute value too large") | ||||
| ) | ||||
|  | ||||
| // ExtendedAttribute represents a single Windows EA. | ||||
| type ExtendedAttribute struct { | ||||
| 	Name  string | ||||
| 	Value []byte | ||||
| 	Flags uint8 | ||||
| } | ||||
|  | ||||
| func parseEa(b []byte) (ea ExtendedAttribute, nb []byte, err error) { | ||||
| 	var info fileFullEaInformation | ||||
| 	err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &info) | ||||
| 	if err != nil { | ||||
| 		err = errInvalidEaBuffer | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	nameOffset := fileFullEaInformationSize | ||||
| 	nameLen := int(info.NameLength) | ||||
| 	valueOffset := nameOffset + int(info.NameLength) + 1 | ||||
| 	valueLen := int(info.ValueLength) | ||||
| 	nextOffset := int(info.NextEntryOffset) | ||||
| 	if valueLen+valueOffset > len(b) || nextOffset < 0 || nextOffset > len(b) { | ||||
| 		err = errInvalidEaBuffer | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	ea.Name = string(b[nameOffset : nameOffset+nameLen]) | ||||
| 	ea.Value = b[valueOffset : valueOffset+valueLen] | ||||
| 	ea.Flags = info.Flags | ||||
| 	if info.NextEntryOffset != 0 { | ||||
| 		nb = b[info.NextEntryOffset:] | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // DecodeExtendedAttributes decodes a list of EAs from a FILE_FULL_EA_INFORMATION | ||||
| // buffer retrieved from BackupRead, ZwQueryEaFile, etc. | ||||
| func DecodeExtendedAttributes(b []byte) (eas []ExtendedAttribute, err error) { | ||||
| 	for len(b) != 0 { | ||||
| 		ea, nb, err := parseEa(b) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
|  | ||||
| 		eas = append(eas, ea) | ||||
| 		b = nb | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func writeEa(buf *bytes.Buffer, ea *ExtendedAttribute, last bool) error { | ||||
| 	if int(uint8(len(ea.Name))) != len(ea.Name) { | ||||
| 		return errEaNameTooLarge | ||||
| 	} | ||||
| 	if int(uint16(len(ea.Value))) != len(ea.Value) { | ||||
| 		return errEaValueTooLarge | ||||
| 	} | ||||
| 	entrySize := uint32(fileFullEaInformationSize + len(ea.Name) + 1 + len(ea.Value)) | ||||
| 	withPadding := (entrySize + 3) &^ 3 | ||||
| 	nextOffset := uint32(0) | ||||
| 	if !last { | ||||
| 		nextOffset = withPadding | ||||
| 	} | ||||
| 	info := fileFullEaInformation{ | ||||
| 		NextEntryOffset: nextOffset, | ||||
| 		Flags:           ea.Flags, | ||||
| 		NameLength:      uint8(len(ea.Name)), | ||||
| 		ValueLength:     uint16(len(ea.Value)), | ||||
| 	} | ||||
|  | ||||
| 	err := binary.Write(buf, binary.LittleEndian, &info) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	_, err = buf.Write([]byte(ea.Name)) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	err = buf.WriteByte(0) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	_, err = buf.Write(ea.Value) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	_, err = buf.Write([]byte{0, 0, 0}[0 : withPadding-entrySize]) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // EncodeExtendedAttributes encodes a list of EAs into a FILE_FULL_EA_INFORMATION | ||||
| // buffer for use with BackupWrite, ZwSetEaFile, etc. | ||||
| func EncodeExtendedAttributes(eas []ExtendedAttribute) ([]byte, error) { | ||||
| 	var buf bytes.Buffer | ||||
| 	for i := range eas { | ||||
| 		last := false | ||||
| 		if i == len(eas)-1 { | ||||
| 			last = true | ||||
| 		} | ||||
|  | ||||
| 		err := writeEa(&buf, &eas[i], last) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return buf.Bytes(), nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										178
									
								
								vendor/github.com/Microsoft/go-winio/ea_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										178
									
								
								vendor/github.com/Microsoft/go-winio/ea_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,89 +1,89 @@ | ||||
| package winio | ||||
|  | ||||
| import ( | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 	"reflect" | ||||
| 	"syscall" | ||||
| 	"testing" | ||||
| 	"unsafe" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	testEas = []ExtendedAttribute{ | ||||
| 		{Name: "foo", Value: []byte("bar")}, | ||||
| 		{Name: "fizz", Value: []byte("buzz")}, | ||||
| 	} | ||||
|  | ||||
| 	testEasEncoded   = []byte{16, 0, 0, 0, 0, 3, 3, 0, 102, 111, 111, 0, 98, 97, 114, 0, 0, 0, 0, 0, 0, 4, 4, 0, 102, 105, 122, 122, 0, 98, 117, 122, 122, 0, 0, 0} | ||||
| 	testEasNotPadded = testEasEncoded[0 : len(testEasEncoded)-3] | ||||
| 	testEasTruncated = testEasEncoded[0:20] | ||||
| ) | ||||
|  | ||||
| func Test_RoundTripEas(t *testing.T) { | ||||
| 	b, err := EncodeExtendedAttributes(testEas) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if !reflect.DeepEqual(testEasEncoded, b) { | ||||
| 		t.Fatalf("encoded mismatch %v %v", testEasEncoded, b) | ||||
| 	} | ||||
| 	eas, err := DecodeExtendedAttributes(b) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if !reflect.DeepEqual(testEas, eas) { | ||||
| 		t.Fatalf("mismatch %+v %+v", testEas, eas) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func Test_EasDontNeedPaddingAtEnd(t *testing.T) { | ||||
| 	eas, err := DecodeExtendedAttributes(testEasNotPadded) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if !reflect.DeepEqual(testEas, eas) { | ||||
| 		t.Fatalf("mismatch %+v %+v", testEas, eas) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func Test_TruncatedEasFailCorrectly(t *testing.T) { | ||||
| 	_, err := DecodeExtendedAttributes(testEasTruncated) | ||||
| 	if err == nil { | ||||
| 		t.Fatal("expected error") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func Test_NilEasEncodeAndDecodeAsNil(t *testing.T) { | ||||
| 	b, err := EncodeExtendedAttributes(nil) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if len(b) != 0 { | ||||
| 		t.Fatal("expected empty") | ||||
| 	} | ||||
| 	eas, err := DecodeExtendedAttributes(nil) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if len(eas) != 0 { | ||||
| 		t.Fatal("expected empty") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Test_SetFileEa makes sure that the test buffer is actually parsable by NtSetEaFile. | ||||
| func Test_SetFileEa(t *testing.T) { | ||||
| 	f, err := ioutil.TempFile("", "winio") | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	defer os.Remove(f.Name()) | ||||
| 	defer f.Close() | ||||
| 	ntdll := syscall.MustLoadDLL("ntdll.dll") | ||||
| 	ntSetEaFile := ntdll.MustFindProc("NtSetEaFile") | ||||
| 	var iosb [2]uintptr | ||||
| 	r, _, _ := ntSetEaFile.Call(f.Fd(), uintptr(unsafe.Pointer(&iosb[0])), uintptr(unsafe.Pointer(&testEasEncoded[0])), uintptr(len(testEasEncoded))) | ||||
| 	if r != 0 { | ||||
| 		t.Fatalf("NtSetEaFile failed with %08x", r) | ||||
| 	} | ||||
| } | ||||
| package winio | ||||
|  | ||||
| import ( | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 	"reflect" | ||||
| 	"syscall" | ||||
| 	"testing" | ||||
| 	"unsafe" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	testEas = []ExtendedAttribute{ | ||||
| 		{Name: "foo", Value: []byte("bar")}, | ||||
| 		{Name: "fizz", Value: []byte("buzz")}, | ||||
| 	} | ||||
|  | ||||
| 	testEasEncoded   = []byte{16, 0, 0, 0, 0, 3, 3, 0, 102, 111, 111, 0, 98, 97, 114, 0, 0, 0, 0, 0, 0, 4, 4, 0, 102, 105, 122, 122, 0, 98, 117, 122, 122, 0, 0, 0} | ||||
| 	testEasNotPadded = testEasEncoded[0 : len(testEasEncoded)-3] | ||||
| 	testEasTruncated = testEasEncoded[0:20] | ||||
| ) | ||||
|  | ||||
| func Test_RoundTripEas(t *testing.T) { | ||||
| 	b, err := EncodeExtendedAttributes(testEas) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if !reflect.DeepEqual(testEasEncoded, b) { | ||||
| 		t.Fatalf("encoded mismatch %v %v", testEasEncoded, b) | ||||
| 	} | ||||
| 	eas, err := DecodeExtendedAttributes(b) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if !reflect.DeepEqual(testEas, eas) { | ||||
| 		t.Fatalf("mismatch %+v %+v", testEas, eas) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func Test_EasDontNeedPaddingAtEnd(t *testing.T) { | ||||
| 	eas, err := DecodeExtendedAttributes(testEasNotPadded) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if !reflect.DeepEqual(testEas, eas) { | ||||
| 		t.Fatalf("mismatch %+v %+v", testEas, eas) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func Test_TruncatedEasFailCorrectly(t *testing.T) { | ||||
| 	_, err := DecodeExtendedAttributes(testEasTruncated) | ||||
| 	if err == nil { | ||||
| 		t.Fatal("expected error") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func Test_NilEasEncodeAndDecodeAsNil(t *testing.T) { | ||||
| 	b, err := EncodeExtendedAttributes(nil) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if len(b) != 0 { | ||||
| 		t.Fatal("expected empty") | ||||
| 	} | ||||
| 	eas, err := DecodeExtendedAttributes(nil) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if len(eas) != 0 { | ||||
| 		t.Fatal("expected empty") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Test_SetFileEa makes sure that the test buffer is actually parsable by NtSetEaFile. | ||||
| func Test_SetFileEa(t *testing.T) { | ||||
| 	f, err := ioutil.TempFile("", "winio") | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	defer os.Remove(f.Name()) | ||||
| 	defer f.Close() | ||||
| 	ntdll := syscall.MustLoadDLL("ntdll.dll") | ||||
| 	ntSetEaFile := ntdll.MustFindProc("NtSetEaFile") | ||||
| 	var iosb [2]uintptr | ||||
| 	r, _, _ := ntSetEaFile.Call(f.Fd(), uintptr(unsafe.Pointer(&iosb[0])), uintptr(unsafe.Pointer(&testEasEncoded[0])), uintptr(len(testEasEncoded))) | ||||
| 	if r != 0 { | ||||
| 		t.Fatalf("NtSetEaFile failed with %08x", r) | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										1802
									
								
								vendor/github.com/Microsoft/go-winio/vhd/mksyscall_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1802
									
								
								vendor/github.com/Microsoft/go-winio/vhd/mksyscall_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										164
									
								
								vendor/github.com/Microsoft/go-winio/vhd/vhd.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										164
									
								
								vendor/github.com/Microsoft/go-winio/vhd/vhd.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,82 +1,82 @@ | ||||
| // +build windows | ||||
|  | ||||
| package vhd | ||||
|  | ||||
| import "syscall" | ||||
|  | ||||
| //go:generate go run mksyscall_windows.go -output zvhd.go vhd.go | ||||
|  | ||||
| //sys createVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) [failretval != 0] = VirtDisk.CreateVirtualDisk | ||||
|  | ||||
| type virtualStorageType struct { | ||||
| 	DeviceID uint32 | ||||
| 	VendorID [16]byte | ||||
| } | ||||
|  | ||||
| const virtualDiskAccessNONE uint32 = 0 | ||||
| const virtualDiskAccessATTACHRO uint32 = 65536 | ||||
| const virtualDiskAccessATTACHRW uint32 = 131072 | ||||
| const virtualDiskAccessDETACH uint32 = 262144 | ||||
| const virtualDiskAccessGETINFO uint32 = 524288 | ||||
| const virtualDiskAccessCREATE uint32 = 1048576 | ||||
| const virtualDiskAccessMETAOPS uint32 = 2097152 | ||||
| const virtualDiskAccessREAD uint32 = 851968 | ||||
| const virtualDiskAccessALL uint32 = 4128768 | ||||
| const virtualDiskAccessWRITABLE uint32 = 3276800 | ||||
|  | ||||
| const createVirtualDiskFlagNone uint32 = 0 | ||||
| const createVirtualDiskFlagFullPhysicalAllocation uint32 = 1 | ||||
| const createVirtualDiskFlagPreventWritesToSourceDisk uint32 = 2 | ||||
| const createVirtualDiskFlagDoNotCopyMetadataFromParent uint32 = 4 | ||||
|  | ||||
| type version2 struct { | ||||
| 	UniqueID                 [16]byte // GUID | ||||
| 	MaximumSize              uint64 | ||||
| 	BlockSizeInBytes         uint32 | ||||
| 	SectorSizeInBytes        uint32 | ||||
| 	ParentPath               *uint16 // string | ||||
| 	SourcePath               *uint16 // string | ||||
| 	OpenFlags                uint32 | ||||
| 	ParentVirtualStorageType virtualStorageType | ||||
| 	SourceVirtualStorageType virtualStorageType | ||||
| 	ResiliencyGUID           [16]byte // GUID | ||||
| } | ||||
|  | ||||
| type createVirtualDiskParameters struct { | ||||
| 	Version  uint32 // Must always be set to 2 | ||||
| 	Version2 version2 | ||||
| } | ||||
|  | ||||
| // CreateVhdx will create a simple vhdx file at the given path using default values. | ||||
| func CreateVhdx(path string, maxSizeInGb, blockSizeInMb uint32) error { | ||||
| 	var defaultType virtualStorageType | ||||
|  | ||||
| 	parameters := createVirtualDiskParameters{ | ||||
| 		Version: 2, | ||||
| 		Version2: version2{ | ||||
| 			MaximumSize:      uint64(maxSizeInGb) * 1024 * 1024 * 1024, | ||||
| 			BlockSizeInBytes: blockSizeInMb * 1024 * 1024, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	var handle syscall.Handle | ||||
|  | ||||
| 	if err := createVirtualDisk( | ||||
| 		&defaultType, | ||||
| 		path, | ||||
| 		virtualDiskAccessNONE, | ||||
| 		nil, | ||||
| 		createVirtualDiskFlagNone, | ||||
| 		0, | ||||
| 		¶meters, | ||||
| 		nil, | ||||
| 		&handle); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if err := syscall.CloseHandle(handle); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
| // +build windows | ||||
|  | ||||
| package vhd | ||||
|  | ||||
| import "syscall" | ||||
|  | ||||
| //go:generate go run mksyscall_windows.go -output zvhd.go vhd.go | ||||
|  | ||||
| //sys createVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) [failretval != 0] = VirtDisk.CreateVirtualDisk | ||||
|  | ||||
| type virtualStorageType struct { | ||||
| 	DeviceID uint32 | ||||
| 	VendorID [16]byte | ||||
| } | ||||
|  | ||||
| const virtualDiskAccessNONE uint32 = 0 | ||||
| const virtualDiskAccessATTACHRO uint32 = 65536 | ||||
| const virtualDiskAccessATTACHRW uint32 = 131072 | ||||
| const virtualDiskAccessDETACH uint32 = 262144 | ||||
| const virtualDiskAccessGETINFO uint32 = 524288 | ||||
| const virtualDiskAccessCREATE uint32 = 1048576 | ||||
| const virtualDiskAccessMETAOPS uint32 = 2097152 | ||||
| const virtualDiskAccessREAD uint32 = 851968 | ||||
| const virtualDiskAccessALL uint32 = 4128768 | ||||
| const virtualDiskAccessWRITABLE uint32 = 3276800 | ||||
|  | ||||
| const createVirtualDiskFlagNone uint32 = 0 | ||||
| const createVirtualDiskFlagFullPhysicalAllocation uint32 = 1 | ||||
| const createVirtualDiskFlagPreventWritesToSourceDisk uint32 = 2 | ||||
| const createVirtualDiskFlagDoNotCopyMetadataFromParent uint32 = 4 | ||||
|  | ||||
| type version2 struct { | ||||
| 	UniqueID                 [16]byte // GUID | ||||
| 	MaximumSize              uint64 | ||||
| 	BlockSizeInBytes         uint32 | ||||
| 	SectorSizeInBytes        uint32 | ||||
| 	ParentPath               *uint16 // string | ||||
| 	SourcePath               *uint16 // string | ||||
| 	OpenFlags                uint32 | ||||
| 	ParentVirtualStorageType virtualStorageType | ||||
| 	SourceVirtualStorageType virtualStorageType | ||||
| 	ResiliencyGUID           [16]byte // GUID | ||||
| } | ||||
|  | ||||
| type createVirtualDiskParameters struct { | ||||
| 	Version  uint32 // Must always be set to 2 | ||||
| 	Version2 version2 | ||||
| } | ||||
|  | ||||
| // CreateVhdx will create a simple vhdx file at the given path using default values. | ||||
| func CreateVhdx(path string, maxSizeInGb, blockSizeInMb uint32) error { | ||||
| 	var defaultType virtualStorageType | ||||
|  | ||||
| 	parameters := createVirtualDiskParameters{ | ||||
| 		Version: 2, | ||||
| 		Version2: version2{ | ||||
| 			MaximumSize:      uint64(maxSizeInGb) * 1024 * 1024 * 1024, | ||||
| 			BlockSizeInBytes: blockSizeInMb * 1024 * 1024, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	var handle syscall.Handle | ||||
|  | ||||
| 	if err := createVirtualDisk( | ||||
| 		&defaultType, | ||||
| 		path, | ||||
| 		virtualDiskAccessNONE, | ||||
| 		nil, | ||||
| 		createVirtualDiskFlagNone, | ||||
| 		0, | ||||
| 		¶meters, | ||||
| 		nil, | ||||
| 		&handle); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if err := syscall.CloseHandle(handle); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/creack/pty/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/creack/pty/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,4 +0,0 @@ | ||||
| [568].out | ||||
| _go* | ||||
| _test* | ||||
| _obj | ||||
							
								
								
									
										23
									
								
								vendor/github.com/creack/pty/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/creack/pty/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,23 +0,0 @@ | ||||
| Copyright (c) 2011 Keith Rarick | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person | ||||
| obtaining a copy of this software and associated | ||||
| documentation files (the "Software"), to deal in the | ||||
| Software without restriction, including without limitation | ||||
| the rights to use, copy, modify, merge, publish, distribute, | ||||
| sublicense, and/or sell copies of the Software, and to | ||||
| permit persons to whom the Software is furnished to do so, | ||||
| subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall | ||||
| be included in all copies or substantial portions of the | ||||
| Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY | ||||
| KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||||
| WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||
| PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS | ||||
| OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||||
| OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||||
| OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||||
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
							
								
								
									
										100
									
								
								vendor/github.com/creack/pty/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										100
									
								
								vendor/github.com/creack/pty/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,100 +0,0 @@ | ||||
| # pty | ||||
|  | ||||
| Pty is a Go package for using unix pseudo-terminals. | ||||
|  | ||||
| ## Install | ||||
|  | ||||
|     go get github.com/creack/pty | ||||
|  | ||||
| ## Example | ||||
|  | ||||
| ### Command | ||||
|  | ||||
| ```go | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"github.com/creack/pty" | ||||
| 	"io" | ||||
| 	"os" | ||||
| 	"os/exec" | ||||
| ) | ||||
|  | ||||
| func main() { | ||||
| 	c := exec.Command("grep", "--color=auto", "bar") | ||||
| 	f, err := pty.Start(c) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
|  | ||||
| 	go func() { | ||||
| 		f.Write([]byte("foo\n")) | ||||
| 		f.Write([]byte("bar\n")) | ||||
| 		f.Write([]byte("baz\n")) | ||||
| 		f.Write([]byte{4}) // EOT | ||||
| 	}() | ||||
| 	io.Copy(os.Stdout, f) | ||||
| } | ||||
| ``` | ||||
|  | ||||
| ### Shell | ||||
|  | ||||
| ```go | ||||
| package main | ||||
|  | ||||
| import ( | ||||
|         "io" | ||||
|         "log" | ||||
|         "os" | ||||
|         "os/exec" | ||||
|         "os/signal" | ||||
|         "syscall" | ||||
|  | ||||
|         "github.com/creack/pty" | ||||
|         "golang.org/x/crypto/ssh/terminal" | ||||
| ) | ||||
|  | ||||
| func test() error { | ||||
|         // Create arbitrary command. | ||||
|         c := exec.Command("bash") | ||||
|  | ||||
|         // Start the command with a pty. | ||||
|         ptmx, err := pty.Start(c) | ||||
|         if err != nil { | ||||
|                 return err | ||||
|         } | ||||
|         // Make sure to close the pty at the end. | ||||
|         defer func() { _ = ptmx.Close() }() // Best effort. | ||||
|  | ||||
|         // Handle pty size. | ||||
|         ch := make(chan os.Signal, 1) | ||||
|         signal.Notify(ch, syscall.SIGWINCH) | ||||
|         go func() { | ||||
|                 for range ch { | ||||
|                         if err := pty.InheritSize(os.Stdin, ptmx); err != nil { | ||||
|                                 log.Printf("error resizing pty: %s", err) | ||||
|                         } | ||||
|                 } | ||||
|         }() | ||||
|         ch <- syscall.SIGWINCH // Initial resize. | ||||
|  | ||||
|         // Set stdin in raw mode. | ||||
|         oldState, err := terminal.MakeRaw(int(os.Stdin.Fd())) | ||||
|         if err != nil { | ||||
|                 panic(err) | ||||
|         } | ||||
|         defer func() { _ = terminal.Restore(int(os.Stdin.Fd()), oldState) }() // Best effort. | ||||
|  | ||||
|         // Copy stdin to the pty and the pty to stdout. | ||||
|         go func() { _, _ = io.Copy(ptmx, os.Stdin) }() | ||||
|         _, _ = io.Copy(os.Stdout, ptmx) | ||||
|  | ||||
|         return nil | ||||
| } | ||||
|  | ||||
| func main() { | ||||
|         if err := test(); err != nil { | ||||
|                 log.Fatal(err) | ||||
|         } | ||||
| } | ||||
| ``` | ||||
							
								
								
									
										4
									
								
								vendor/github.com/creack/pty/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/creack/pty/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,4 +0,0 @@ | ||||
| module github.com/creack/pty | ||||
|  | ||||
| go 1.13 | ||||
|  | ||||
							
								
								
									
										13
									
								
								vendor/github.com/creack/pty/ztypes_freebsd_arm64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								vendor/github.com/creack/pty/ztypes_freebsd_arm64.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,13 +0,0 @@ | ||||
| // Code generated by cmd/cgo -godefs; DO NOT EDIT. | ||||
| // cgo -godefs types_freebsd.go | ||||
|  | ||||
| package pty | ||||
|  | ||||
| const ( | ||||
| 	_C_SPECNAMELEN = 0xff | ||||
| ) | ||||
|  | ||||
| type fiodgnameArg struct { | ||||
| 	Len int32 | ||||
| 	Buf *byte | ||||
| } | ||||
							
								
								
									
										46
									
								
								vendor/github.com/gogo/protobuf/.github/workflows/ci-workflow.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								vendor/github.com/gogo/protobuf/.github/workflows/ci-workflow.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,46 +0,0 @@ | ||||
| name: Continuous Integration | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - ghworkflow | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - master | ||||
|  | ||||
| jobs: | ||||
|   build_and_test: | ||||
|     name: go ${{ matrix.go_version }} - pb-${{ matrix.protobuf_version }} | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       matrix: | ||||
|         go_version: [1.12.x, 1.11.x] | ||||
|         protobuf_version: [3.9.1, 3.0.2, 2.6.1] | ||||
|       fail-fast: false | ||||
|     steps: | ||||
|       - name: Checkout branch | ||||
|         uses: actions/checkout@v1 | ||||
|         with: | ||||
|           path: gopath/src/github.com/gogo/protobuf | ||||
|           fetch-depth: 5 | ||||
|  | ||||
|       - name: Setup go | ||||
|         uses: actions/setup-go@v1 | ||||
|         with: | ||||
|           go-version: ${{ matrix.go_version }} | ||||
|  | ||||
|       - name: Setup protoc | ||||
|         env: | ||||
|           PROTOBUF_VERSION: ${{ matrix.protobuf_version }} | ||||
|         run: ./install-protobuf.sh | ||||
|  | ||||
|       - name: Protoc version | ||||
|         run: PATH=$HOME/bin:$PATH protoc --version | ||||
|       - name: env | ||||
|         run: env && go env && pwd | ||||
|  | ||||
|       - name: Build server all | ||||
|         run: GOPATH=/home/runner/work/protobuf/gopath GOBIN=$GOPATH/bin PATH=$HOME/bin:$GOBIN:$PATH make buildserverall | ||||
|  | ||||
|       - name: Diff check | ||||
|         if: matrix.protobuf_version == '3.9.1' && matrix.go_version == '1.12.x' | ||||
|         run: (! git status --porcelain | read || (git status; git diff; exit 1)) | ||||
							
								
								
									
										3
									
								
								vendor/github.com/gogo/protobuf/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/gogo/protobuf/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,6 +1,3 @@ | ||||
| ._* | ||||
| *.js | ||||
| *.js.map | ||||
|  | ||||
| # Conformance test output and transient files. | ||||
| conformance/failing_tests.txt | ||||
							
								
								
									
										18
									
								
								vendor/github.com/gogo/protobuf/.travis.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								vendor/github.com/gogo/protobuf/.travis.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,22 +1,24 @@ | ||||
| apt: | ||||
|   update: true | ||||
|  | ||||
| env: | ||||
|   - PROTOBUF_VERSION=2.6.1 | ||||
|   - PROTOBUF_VERSION=3.0.2 | ||||
|   - PROTOBUF_VERSION=3.9.1 | ||||
|   - PROTOBUF_VERSION=3.2.0 | ||||
|  | ||||
| before_install: | ||||
|   - HOME=/home/travis ./install-protobuf.sh | ||||
|   - ./install-protobuf.sh | ||||
|   - PATH=/home/travis/bin:$PATH protoc --version | ||||
|  | ||||
| script: | ||||
|   - PATH=/home/travis/bin:$PATH make buildserverall | ||||
|   - echo $TRAVIS_GO_VERSION | ||||
|   - if [[ "$PROTOBUF_VERSION" == "3.9.1" ]] && [[ "$TRAVIS_GO_VERSION" == "1.12.x" ]]; then ! git status --porcelain | read || (git status; git diff; exit 1); fi | ||||
|   - if [ "$TRAVIS_GO_VERSION" == 1.8 ] && [[ "$PROTOBUF_VERSION" == 3.2.0 ]]; then ! git status --porcelain | read || (git status; git diff; exit 1); fi | ||||
|  | ||||
| language: go | ||||
|  | ||||
| go: | ||||
|   - 1.11.x | ||||
|   - 1.12.x | ||||
|   - 1.6.3 | ||||
|   - 1.7.1 | ||||
|   - 1.8 | ||||
|  | ||||
| matrix: | ||||
|   allow_failures: | ||||
|     - go: 1.6.3 | ||||
|   | ||||
							
								
								
									
										1
									
								
								vendor/github.com/gogo/protobuf/AUTHORS
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/github.com/gogo/protobuf/AUTHORS
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -10,6 +10,5 @@ | ||||
|  | ||||
| # Please keep the list sorted. | ||||
|  | ||||
| Sendgrid, Inc | ||||
| Vastech SA (PTY) LTD | ||||
| Walter Schulze <awalterschulze@gmail.com> | ||||
|   | ||||
							
								
								
									
										5
									
								
								vendor/github.com/gogo/protobuf/CONTRIBUTORS
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/github.com/gogo/protobuf/CONTRIBUTORS
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,5 +1,4 @@ | ||||
| Anton Povarov <anton.povarov@gmail.com> | ||||
| Brian Goff <cpuguy83@gmail.com> | ||||
| Clayton Coleman <ccoleman@redhat.com> | ||||
| Denis Smirnov <denis.smirnov.91@gmail.com> | ||||
| DongYun Kang <ceram1000@gmail.com> | ||||
| @@ -11,13 +10,9 @@ John Shahid <jvshahid@gmail.com> | ||||
| John Tuley <john@tuley.org> | ||||
| Laurent <laurent@adyoulike.com> | ||||
| Patrick Lee <patrick@dropbox.com> | ||||
| Peter Edge <peter.edge@gmail.com> | ||||
| Roger Johansson <rogeralsing@gmail.com> | ||||
| Sam Nguyen <sam.nguyen@sendgrid.com> | ||||
| Sergio Arbeo <serabe@gmail.com> | ||||
| Stephen J Day <stephen.day@docker.com> | ||||
| Tamir Duberstein <tamird@gmail.com> | ||||
| Todd Eisenberger <teisenberger@dropbox.com> | ||||
| Tormod Erevik Lea <tormodlea@gmail.com> | ||||
| Vyacheslav Kim <kane@sendgrid.com> | ||||
| Walter Schulze <awalterschulze@gmail.com> | ||||
|   | ||||
							
								
								
									
										5
									
								
								vendor/github.com/gogo/protobuf/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/github.com/gogo/protobuf/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,7 +1,8 @@ | ||||
| Copyright (c) 2013, The GoGo Authors. All rights reserved. | ||||
|  | ||||
| Protocol Buffers for Go with Gadgets | ||||
|  | ||||
| Copyright (c) 2013, The GoGo Authors. All rights reserved. | ||||
| http://github.com/gogo/protobuf | ||||
|  | ||||
| Go support for Protocol Buffers - Google's data interchange format | ||||
|  | ||||
| Copyright 2010 The Go Authors.  All rights reserved. | ||||
|   | ||||
							
								
								
									
										63
									
								
								vendor/github.com/gogo/protobuf/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										63
									
								
								vendor/github.com/gogo/protobuf/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -27,18 +27,12 @@ | ||||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| GO_VERSION:=$(shell go version) | ||||
| BENCHLIST?=all | ||||
|  | ||||
| # Skip known issues from purego tests | ||||
| # https://github.com/gogo/protobuf/issues/447 | ||||
| # https://github.com/gogo/protobuf/issues/448 | ||||
| SKIPISSUE:="/jsonpb|/test/casttype/|/test/oneof/combos/" | ||||
|  | ||||
| .PHONY: nuke regenerate tests clean install gofmt vet contributors | ||||
|  | ||||
| all: clean install regenerate install tests errcheck vet | ||||
|  | ||||
| buildserverall: clean install regenerate install tests vet js purego | ||||
| buildserverall: clean install regenerate install tests vet js | ||||
|  | ||||
| install: | ||||
| 	go install ./proto | ||||
| @@ -58,19 +52,20 @@ clean: | ||||
| 	go clean ./... | ||||
|  | ||||
| nuke: | ||||
| 	go clean -i -cache ./... | ||||
| 	go clean -i ./... | ||||
|  | ||||
| gofmt: | ||||
| 	gofmt -l -s -w . | ||||
|  | ||||
| regenerate: | ||||
| 	make -C protoc-gen-gogo regenerate | ||||
| 	make -C protoc-gen-gogo/descriptor regenerate | ||||
| 	make -C protoc-gen-gogo/plugin regenerate | ||||
| 	make -C protoc-gen-gogo/testdata regenerate | ||||
| 	make -C gogoproto regenerate | ||||
| 	make -C proto/test_proto regenerate | ||||
| 	make -C proto/proto3_proto regenerate | ||||
| 	make -C proto/testdata regenerate | ||||
| 	make -C jsonpb/jsonpb_test_proto regenerate | ||||
| 	make -C conformance regenerate | ||||
| 	make -C protobuf regenerate | ||||
| 	make -C _conformance regenerate | ||||
| 	make -C types regenerate | ||||
| 	make -C test regenerate | ||||
| 	make -C test/example regenerate | ||||
| 	make -C test/unrecognized regenerate | ||||
| @@ -88,12 +83,10 @@ regenerate: | ||||
| 	make -C test/oneof regenerate | ||||
| 	make -C test/oneof3 regenerate | ||||
| 	make -C test/theproto3 regenerate | ||||
| 	make -C test/mapdefaults regenerate | ||||
| 	make -C test/mapsproto2 regenerate | ||||
| 	make -C test/issue42order regenerate | ||||
| 	make -C proto generate-test-pbs | ||||
| 	make -C test/importdedup regenerate | ||||
| 	make -C test/importduplicate regenerate | ||||
| 	make -C test/custombytesnonstruct regenerate | ||||
| 	make -C test/required regenerate | ||||
| 	make -C test/casttype regenerate | ||||
| @@ -116,42 +109,18 @@ regenerate: | ||||
| 	make -C test/issue260 regenerate | ||||
| 	make -C test/issue261 regenerate | ||||
| 	make -C test/issue262 regenerate | ||||
| 	make -C test/issue312 regenerate | ||||
| 	make -C test/enumdecl regenerate | ||||
| 	make -C test/typedecl_all regenerate | ||||
| 	make -C test/enumdecl_all regenerate | ||||
| 	make -C test/int64support regenerate | ||||
| 	make -C test/issue322 regenerate | ||||
| 	make -C test/issue330 regenerate | ||||
| 	make -C test/importcustom-issue389 regenerate | ||||
| 	make -C test/merge regenerate | ||||
| 	make -C test/cachedsize regenerate | ||||
| 	make -C test/deterministic regenerate | ||||
| 	make -C test/issue438 regenerate | ||||
| 	make -C test/issue444 regenerate | ||||
| 	make -C test/issue449 regenerate | ||||
| 	make -C test/xxxfields regenerate | ||||
| 	make -C test/issue435 regenerate | ||||
| 	make -C test/issue411 regenerate | ||||
| 	make -C test/issue498 regenerate | ||||
| 	make -C test/issue503 regenerate | ||||
| 	make -C test/issue530 regenerate | ||||
| 	make -C test/issue617 regenerate | ||||
| 	make -C test/issue620 regenerate | ||||
| 	make -C test/protobuffer regenerate | ||||
| 	make -C test/issue630 regenerate | ||||
|  | ||||
| 	make gofmt | ||||
|  | ||||
| tests: | ||||
| 	go build ./test/enumprefix | ||||
| 	go test ./... | ||||
| 	(cd test/stdtypes && make test) | ||||
|  | ||||
| vet: | ||||
| 	go get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow | ||||
| 	go vet ./... | ||||
| 	go vet -vettool=$(shell which shadow) ./... | ||||
| 	go tool vet --shadow . | ||||
|  | ||||
| errcheck: | ||||
| 	go get github.com/kisielk/errcheck | ||||
| @@ -163,29 +132,23 @@ drone: | ||||
|  | ||||
| testall: | ||||
| 	go get -u github.com/golang/protobuf/proto | ||||
| 	make -C protoc-gen-gogo test | ||||
| 	make -C protoc-gen-gogo/testdata test | ||||
| 	make -C vanity/test test | ||||
| 	make -C test/registration test | ||||
| 	make -C conformance test | ||||
| 	make -C test/issue427 test | ||||
| 	make tests | ||||
|  | ||||
| bench: | ||||
| 	go get golang.org/x/tools/cmd/benchcmp | ||||
| 	(cd test/mixbench && go build .) | ||||
| 	./test/mixbench/mixbench -benchlist "${BENCHLIST}" | ||||
| 	(cd test/mixbench && ./mixbench) | ||||
|  | ||||
| contributors: | ||||
| 	git log --format='%aN <%aE>' | sort -fu > CONTRIBUTORS | ||||
|  | ||||
| js: | ||||
| ifeq (go1.12, $(findstring go1.12, $(GO_VERSION))) | ||||
| 	go get -u github.com/gopherjs/gopherjs | ||||
| ifeq (go1.8, $(findstring go1.8, $(GO_VERSION))) | ||||
| 	go get github.com/gopherjs/gopherjs | ||||
| 	gopherjs build github.com/gogo/protobuf/protoc-gen-gogo | ||||
| endif | ||||
|  | ||||
| purego: | ||||
| 	go test -tags purego $$(go list ./... | grep -Ev $(SKIPISSUE)) | ||||
|  | ||||
| update: | ||||
| 	(cd protobuf && make update) | ||||
|   | ||||
							
								
								
									
										100
									
								
								vendor/github.com/gogo/protobuf/README
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										100
									
								
								vendor/github.com/gogo/protobuf/README
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,18 +1,13 @@ | ||||
| Protocol Buffers for Go with Gadgets | ||||
|  | ||||
| GoGoProtobuf http://github.com/gogo/protobuf extends | ||||
| GoGoProtobuf http://github.com/gogo/protobuf extends  | ||||
| GoProtobuf http://github.com/golang/protobuf | ||||
|  | ||||
| Copyright (c) 2013, The GoGo Authors. All rights reserved. | ||||
|  | ||||
|  | ||||
| # Go support for Protocol Buffers | ||||
|  | ||||
| Google's data interchange format. | ||||
| Copyright 2010 The Go Authors. | ||||
| https://github.com/golang/protobuf | ||||
|  | ||||
| This package and the code it generates requires at least Go 1.6. | ||||
| This package and the code it generates requires at least Go 1.4. | ||||
|  | ||||
| This software implements Go bindings for protocol buffers.  For | ||||
| information about protocol buffers themselves, see | ||||
| @@ -29,19 +24,11 @@ To use this software, you must: | ||||
| 	https://golang.org/doc/install | ||||
|   for details or, if you are using gccgo, follow the instructions at | ||||
| 	https://golang.org/doc/install/gccgo | ||||
| - Grab the code from the repository and install the `proto` package. | ||||
|   The simplest way is to run `go get -u github.com/golang/protobuf/protoc-gen-go`. | ||||
|   The compiler plugin, `protoc-gen-go`, will be installed in `$GOPATH/bin` | ||||
|   unless `$GOBIN` is set. It must be in your `$PATH` for the protocol | ||||
|   compiler, `protoc`, to find it. | ||||
| - If you need a particular version of `protoc-gen-go` (e.g., to match your | ||||
|   `proto` package version), one option is | ||||
|   ```shell | ||||
|   GIT_TAG="v1.2.0" # change as needed | ||||
|   go get -d -u github.com/golang/protobuf/protoc-gen-go | ||||
|   git -C "$(go env GOPATH)"/src/github.com/golang/protobuf checkout $GIT_TAG | ||||
|   go install github.com/golang/protobuf/protoc-gen-go | ||||
|   ``` | ||||
| - Grab the code from the repository and install the proto package. | ||||
|   The simplest way is to run `go get -u github.com/golang/protobuf/{proto,protoc-gen-go}`. | ||||
|   The compiler plugin, protoc-gen-go, will be installed in $GOBIN, | ||||
|   defaulting to $GOPATH/bin.  It must be in your $PATH for the protocol | ||||
|   compiler, protoc, to find it. | ||||
|  | ||||
| This software has two parts: a 'protocol compiler plugin' that | ||||
| generates Go source files that, once compiled, can access and manage | ||||
| @@ -71,45 +58,6 @@ parameter set to the directory you want to output the Go code to. | ||||
| The generated files will be suffixed .pb.go.  See the Test code below | ||||
| for an example using such a file. | ||||
|  | ||||
| ## Packages and input paths ## | ||||
|  | ||||
| The protocol buffer language has a concept of "packages" which does not | ||||
| correspond well to the Go notion of packages. In generated Go code, | ||||
| each source `.proto` file is associated with a single Go package. The | ||||
| name and import path for this package is specified with the `go_package` | ||||
| proto option: | ||||
|  | ||||
| 	option go_package = "github.com/gogo/protobuf/types"; | ||||
|  | ||||
| The protocol buffer compiler will attempt to derive a package name and | ||||
| import path if a `go_package` option is not present, but it is | ||||
| best to always specify one explicitly. | ||||
|  | ||||
| There is a one-to-one relationship between source `.proto` files and | ||||
| generated `.pb.go` files, but any number of `.pb.go` files may be | ||||
| contained in the same Go package. | ||||
|  | ||||
| The output name of a generated file is produced by replacing the | ||||
| `.proto` suffix with `.pb.go` (e.g., `foo.proto` produces `foo.pb.go`). | ||||
| However, the output directory is selected in one of two ways.  Let | ||||
| us say we have `inputs/x.proto` with a `go_package` option of | ||||
| `github.com/golang/protobuf/p`. The corresponding output file may | ||||
| be: | ||||
|  | ||||
| - Relative to the import path: | ||||
|  | ||||
| 	protoc --gogo_out=. inputs/x.proto | ||||
| 	# writes ./github.com/gogo/protobuf/p/x.pb.go | ||||
|  | ||||
|   (This can work well with `--gogo_out=$GOPATH`.) | ||||
|  | ||||
| - Relative to the input file: | ||||
|  | ||||
| 	protoc --gogo_out=paths=source_relative:. inputs/x.proto | ||||
| 	# generate ./inputs/x.pb.go | ||||
|  | ||||
| ## Generated code ## | ||||
|  | ||||
| The package comment for the proto library contains text describing | ||||
| the interface provided in Go for protocol buffers. Here is an edited | ||||
| version. | ||||
| @@ -170,20 +118,23 @@ for a protocol buffer variable v: | ||||
| When the .proto file specifies `syntax="proto3"`, there are some differences: | ||||
|  | ||||
|   - Non-repeated fields of non-message type are values instead of pointers. | ||||
|   - Getters are only generated for message and oneof fields. | ||||
|   - Enum types do not get an Enum method. | ||||
|  | ||||
| Consider file test.proto, containing | ||||
|  | ||||
| ```proto | ||||
| 	syntax = "proto2"; | ||||
| 	package example; | ||||
|  | ||||
| 	 | ||||
| 	enum FOO { X = 17; }; | ||||
|  | ||||
| 	 | ||||
| 	message Test { | ||||
| 	  required string label = 1; | ||||
| 	  optional int32 type = 2 [default=77]; | ||||
| 	  repeated int64 reps = 3; | ||||
| 	  optional group OptionalGroup = 4 { | ||||
| 	    required string RequiredField = 5; | ||||
| 	  } | ||||
| 	} | ||||
| ``` | ||||
|  | ||||
| @@ -200,10 +151,13 @@ To create and play with a Test object from the example package, | ||||
| 	) | ||||
|  | ||||
| 	func main() { | ||||
| 		test := &example.Test{ | ||||
| 		test := &example.Test { | ||||
| 			Label: proto.String("hello"), | ||||
| 			Type:  proto.Int32(17), | ||||
| 			Reps:  []int64{1, 2, 3}, | ||||
| 			Optionalgroup: &example.Test_OptionalGroup { | ||||
| 				RequiredField: proto.String("good bye"), | ||||
| 			}, | ||||
| 		} | ||||
| 		data, err := proto.Marshal(test) | ||||
| 		if err != nil { | ||||
| @@ -231,23 +185,19 @@ parameter list separated from the output directory by a colon: | ||||
|  | ||||
| 	protoc --gogo_out=plugins=grpc,import_path=mypackage:. *.proto | ||||
|  | ||||
| - `paths=(import | source_relative)` - specifies how the paths of | ||||
|   generated files are structured. See the "Packages and imports paths" | ||||
|   section above. The default is `import`. | ||||
|  | ||||
| - `import_prefix=xxx` - a prefix that is added onto the beginning of | ||||
|   all imports. Useful for things like generating protos in a | ||||
|   subdirectory, or regenerating vendored protobufs in-place. | ||||
| - `import_path=foo/bar` - used as the package if no input files | ||||
|   declare `go_package`. If it contains slashes, everything up to the | ||||
|   rightmost slash is ignored. | ||||
| - `plugins=plugin1+plugin2` - specifies the list of sub-plugins to | ||||
|   load. The only plugin in this repo is `grpc`. | ||||
| - `Mfoo/bar.proto=quux/shme` - declares that foo/bar.proto is | ||||
|   associated with Go package quux/shme.  This is subject to the | ||||
|   import_prefix parameter. | ||||
|  | ||||
| The following parameters are deprecated and should not be used: | ||||
|  | ||||
| - `import_prefix=xxx` - a prefix that is added onto the beginning of | ||||
|   all imports. | ||||
| - `import_path=foo/bar` - used as the package if no input files | ||||
|   declare `go_package`. If it contains slashes, everything up to the | ||||
|   rightmost slash is ignored. | ||||
|  | ||||
| ## gRPC Support ## | ||||
|  | ||||
| If a proto file specifies RPC services, protoc-gen-go can be instructed to | ||||
| @@ -301,6 +251,8 @@ generated code and declare a new package-level constant whose name incorporates | ||||
| the latest version number.  Removing a compatibility constant is considered a | ||||
| breaking change and would be subject to the announcement policy stated above. | ||||
|  | ||||
| ## Plugins ## | ||||
|  | ||||
| The `protoc-gen-go/generator` package exposes a plugin interface, | ||||
| which is used by the gRPC code generation. This interface is not | ||||
| supported and is subject to incompatible changes without notice. | ||||
|   | ||||
							
								
								
									
										68
									
								
								vendor/github.com/gogo/protobuf/Readme.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										68
									
								
								vendor/github.com/gogo/protobuf/Readme.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,7 +1,6 @@ | ||||
| # Protocol Buffers for Go with Gadgets | ||||
|  | ||||
| [](https://travis-ci.org/gogo/protobuf) | ||||
| [](http://godoc.org/github.com/gogo/protobuf) | ||||
|  | ||||
| gogoprotobuf is a fork of <a href="https://github.com/golang/protobuf">golang/protobuf</a> with extra code generation features. | ||||
|  | ||||
| @@ -17,18 +16,6 @@ This code generation is used to achieve: | ||||
| Keeping track of how up to date gogoprotobuf is relative to golang/protobuf is done in this | ||||
| <a href="https://github.com/gogo/protobuf/issues/191">issue</a> | ||||
|  | ||||
| ## Release v1.3.0 | ||||
|  | ||||
| The project has updated to release v1.3.0. Check out the release notes <a href="https://github.com/gogo/protobuf/releases/tag/v1.3.0">here</a>. | ||||
|  | ||||
| With this new release comes a new internal library version. This means any newly generated *pb.go files generated with the v1.3.0 library will not be compatible with the old library version (v1.2.1). However, current *pb.go files (generated with v1.2.1) should still work with the new library. | ||||
|  | ||||
| Please make sure you manage your dependencies correctly when upgrading your project. If you are still using v1.2.1 and you update your dependencies, one of which could include a new *pb.go (generated with v1.3.0), you could get a compile time error. | ||||
|  | ||||
| Our upstream repo, golang/protobuf, also had to go through this process in order to update their library version. | ||||
| Here is a link explaining <a href="https://github.com/golang/protobuf/issues/763#issuecomment-442434870">hermetic builds</a>. | ||||
|  | ||||
|  | ||||
| ## Users | ||||
|  | ||||
| These projects use gogoprotobuf: | ||||
| @@ -51,32 +38,15 @@ These projects use gogoprotobuf: | ||||
|   - <a href="https://github.com/docker/swarmkit">docker swarmkit</a> - <a href="https://github.com/docker/swarmkit/blob/63600e01af3b8da2a0ed1c9fa6e1ae4299d75edb/api/objects.proto">sample proto file</a> | ||||
|   - <a href="https://nats.io/">nats.io</a> - <a href="https://github.com/nats-io/go-nats-streaming/blob/master/pb/protocol.proto">go-nats-streaming</a> | ||||
|   - <a href="https://github.com/pingcap/tidb">tidb</a> - Communication between <a href="https://github.com/pingcap/tipb/blob/master/generate-go.sh#L4">tidb</a> and <a href="https://github.com/pingcap/kvproto/blob/master/generate_go.sh#L3">tikv</a> | ||||
|   - <a href="https://github.com/AsynkronIT/protoactor-go">protoactor-go</a> - <a href="https://github.com/AsynkronIT/protoactor-go/blob/master/protobuf/protoc-gen-protoactor/main.go">vanity command</a> that also generates actors from service definitions | ||||
|   - <a href="https://containerd.io/">containerd</a> - <a href="https://github.com/containerd/containerd/tree/master/cmd/protoc-gen-gogoctrd">vanity command with custom field names</a> that conforms to the golang convention. | ||||
|   - <a href="https://github.com/heroiclabs/nakama">nakama</a> | ||||
|   - <a href="https://github.com/src-d/proteus">proteus</a> | ||||
|   - <a href="https://github.com/go-graphite">carbonzipper stack</a> | ||||
|   - <a href="https://sendgrid.com/">sendgrid</a> | ||||
|   - <a href="https://github.com/zero-os/0-stor">zero-os/0-stor</a> | ||||
|   - <a href="https://github.com/spacemeshos/go-spacemesh">go-spacemesh</a> | ||||
|   - <a href="https://github.com/weaveworks/cortex">cortex</a> - <a href="https://github.com/weaveworks/cortex/blob/fee02a59729d3771ef888f7bf0fd050e1197c56e/pkg/ingester/client/cortex.proto">sample proto file</a> | ||||
|   - <a href="http://skywalking.apache.org/">Apache SkyWalking APM</a> - Istio telemetry receiver based on Mixer bypass protocol | ||||
|   - <a href="https://github.com/hyperledger/burrow">Hyperledger Burrow</a> - a permissioned DLT framework | ||||
|   - <a href="https://github.com/iov-one/weave">IOV Weave</a> - a blockchain framework - <a href="https://github.com/iov-one/weave/tree/23f9856f1e316f93cb3d45d92c4c6a0c4810f6bf/spec/gogo">sample proto files</a> | ||||
|   - <a href="https://github.com/AsynkronIT/protoactor-go">protoactor-go</a> - <a href="https://github.com/AsynkronIT/protoactor-go/blob/dev/protobuf/protoc-gen-protoactor/main.go">vanity command</a> that also generates actors from service definitions | ||||
|  | ||||
| Please let us know if you are using gogoprotobuf by posting on our <a href="https://groups.google.com/forum/#!topic/gogoprotobuf/Brw76BxmFpQ">GoogleGroup</a>. | ||||
| Please lets us know if you are using gogoprotobuf by posting on our <a href="https://groups.google.com/forum/#!topic/gogoprotobuf/Brw76BxmFpQ">GoogleGroup</a>. | ||||
|  | ||||
| ### Mentioned | ||||
|  | ||||
|   - <a href="http://www.slideshare.net/albertstrasheim/serialization-in-go">Cloudflare - go serialization talk - Albert Strasheim</a> | ||||
|   - <a href="https://youtu.be/4xB46Xl9O9Q?t=557">GopherCon 2014 Writing High Performance Databases in Go by Ben Johnson</a> | ||||
|   - <a href="http://gophercon.sourcegraph.com/post/83747547505/writing-a-high-performance-database-in-go">gophercon</a> | ||||
|   - <a href="https://github.com/alecthomas/go_serialization_benchmarks">alecthomas' go serialization benchmarks</a> | ||||
|   - <a href="http://agniva.me/go/2017/11/18/gogoproto.html">Go faster with gogoproto - Agniva De Sarker</a> | ||||
|   - <a href="https://www.youtube.com/watch?v=CY9T020HLP8">Evolution of protobuf (Gource Visualization) - Landon Wilkins</a> | ||||
|   - <a href="https://fosdem.org/2018/schedule/event/gopherjs/">Creating GopherJS Apps with gRPC-Web - Johan Brandhorst</a> | ||||
|   - <a href="https://jbrandhorst.com/post/gogoproto/">So you want to use GoGo Protobuf - Johan Brandhorst</a> | ||||
|   - <a href="https://jbrandhorst.com/post/grpc-errors/">Advanced gRPC Error Usage - Johan Brandhorst</a> | ||||
|   - <a href="https://www.udemy.com/grpc-golang/?couponCode=GITHUB10">gRPC Golang Course on Udemy - Stephane Maarek</a> | ||||
|  | ||||
| ## Getting Started | ||||
|  | ||||
| @@ -89,11 +59,10 @@ After that you can choose: | ||||
|  | ||||
| ### Installation | ||||
|  | ||||
| To install it, you must first have Go (at least version 1.6.3 or 1.9 if you are using gRPC) installed (see [http://golang.org/doc/install](http://golang.org/doc/install)). | ||||
| Latest patch versions of 1.10 and 1.11 are continuously tested. | ||||
| To install it, you must first have Go (at least version 1.6.3) installed (see [http://golang.org/doc/install](http://golang.org/doc/install)).  Go 1.7.1 and 1.8 are continuously tested. | ||||
|  | ||||
| Next, install the standard protocol buffer implementation from [https://github.com/google/protobuf](https://github.com/google/protobuf). | ||||
| Most versions from 2.3.1 should not give any problems, but 2.6.1, 3.0.2 and 3.6.1 are continuously tested. | ||||
| Most versions from 2.3.1 should not give any problems, but 2.6.1, 3.0.2 and 3.2.0 are continuously tested. | ||||
|  | ||||
| ### Speed | ||||
|  | ||||
| @@ -124,23 +93,7 @@ Installing any of these binaries is easy.  Simply run: | ||||
|     go get github.com/gogo/protobuf/{binary} | ||||
|     go get github.com/gogo/protobuf/gogoproto | ||||
|  | ||||
| These binaries allow you to use gogoprotobuf [extensions](https://github.com/gogo/protobuf/blob/master/extensions.md). You can also use your own binary. | ||||
|  | ||||
| To generate the code, you also need to set the include path properly. | ||||
|  | ||||
|     protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf/protobuf --{binary}_out=. myproto.proto | ||||
|  | ||||
| To use proto files from "google/protobuf" you need to add additional args to protoc. | ||||
|  | ||||
|     protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf/protobuf --{binary}_out=\ | ||||
|     Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\ | ||||
|     Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\ | ||||
|     Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,\ | ||||
|     Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\ | ||||
|     Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types:. \ | ||||
|     myproto.proto | ||||
|  | ||||
| Note that in the protoc command, {binary} does not contain the initial prefix of "protoc-gen". | ||||
| These binaries allow you to using gogoprotobuf [extensions](https://github.com/gogo/protobuf/blob/master/extensions.md). | ||||
|  | ||||
| ### Most Speed and most customization | ||||
|  | ||||
| @@ -162,12 +115,3 @@ It works the same as golang/protobuf, simply specify the plugin. | ||||
| Here is an example using gofast: | ||||
|  | ||||
|     protoc --gofast_out=plugins=grpc:. my.proto | ||||
|  | ||||
| See [https://github.com/gogo/grpc-example](https://github.com/gogo/grpc-example) for an example of using gRPC with gogoprotobuf and the wider grpc-ecosystem. | ||||
|  | ||||
|  | ||||
| ## License | ||||
| This software is licensed under the 3-Clause BSD License | ||||
| ("BSD License 2.0", "Revised BSD License", "New BSD License", or "Modified BSD License"). | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -29,25 +29,6 @@ | ||||
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | ||||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | ||||
| 
 | ||||
| PROTOBUF_ROOT=$(HOME)/src/protobuf | ||||
| 
 | ||||
| all: | ||||
| 	@echo To run the tests in this directory, acquire the main protobuf | ||||
| 	@echo distribution from: | ||||
| 	@echo | ||||
| 	@echo '   https://github.com/google/protobuf' | ||||
| 	@echo | ||||
| 	@echo Build the test runner with: | ||||
| 	@echo | ||||
| 	@echo '   cd conformance && make conformance-test-runner' | ||||
| 	@echo | ||||
| 	@echo And run the tests in this directory with: | ||||
| 	@echo | ||||
| 	@echo '   make test PROTOBUF_ROOT=<protobuf distribution>' | ||||
| 
 | ||||
| test: | ||||
| 	./test.sh $(PROTOBUF_ROOT) | ||||
| 
 | ||||
| regenerate: | ||||
| 	protoc-min-version --version="3.0.0" --proto_path=$(GOPATH)/src:$(GOPATH)/src/github.com/gogo/protobuf/protobuf:. --gogo_out=\
 | ||||
| 	Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\
 | ||||
| @@ -56,4 +37,4 @@ regenerate: | ||||
| 	Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
 | ||||
| 	Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,\
 | ||||
| 	Mgoogle/protobuf/field_mask.proto=github.com/gogo/protobuf/types\
 | ||||
| 	:. ./internal/conformance_proto/conformance.proto | ||||
| 	:. conformance_proto/conformance.proto | ||||
| @@ -39,7 +39,7 @@ import ( | ||||
| 	"io" | ||||
| 	"os" | ||||
| 
 | ||||
| 	pb "github.com/gogo/protobuf/conformance/internal/conformance_proto" | ||||
| 	pb "github.com/gogo/protobuf/_conformance/conformance_proto" | ||||
| 	"github.com/gogo/protobuf/jsonpb" | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
| ) | ||||
| @@ -101,6 +101,13 @@ func handle(req *pb.ConformanceRequest) *pb.ConformanceResponse { | ||||
| 		err = proto.Unmarshal(p.ProtobufPayload, &msg) | ||||
| 	case *pb.ConformanceRequest_JsonPayload: | ||||
| 		err = jsonpb.UnmarshalString(p.JsonPayload, &msg) | ||||
| 		if err != nil && err.Error() == "unmarshaling Any not supported yet" { | ||||
| 			return &pb.ConformanceResponse{ | ||||
| 				Result: &pb.ConformanceResponse_Skipped{ | ||||
| 					Skipped: err.Error(), | ||||
| 				}, | ||||
| 			} | ||||
| 		} | ||||
| 	default: | ||||
| 		return &pb.ConformanceResponse{ | ||||
| 			Result: &pb.ConformanceResponse_RuntimeError{ | ||||
							
								
								
									
										1890
									
								
								vendor/github.com/gogo/protobuf/_conformance/conformance_proto/conformance.pb.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1890
									
								
								vendor/github.com/gogo/protobuf/_conformance/conformance_proto/conformance.pb.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -210,6 +210,11 @@ message TestAllTypes { | ||||
|     NestedMessage oneof_nested_message = 112; | ||||
|     string oneof_string = 113; | ||||
|     bytes oneof_bytes = 114; | ||||
|     bool oneof_bool = 115; | ||||
|     uint64 oneof_uint64 = 116; | ||||
|     float oneof_float = 117; | ||||
|     double oneof_double = 118; | ||||
|     NestedEnum oneof_enum = 119; | ||||
|   } | ||||
| 
 | ||||
|   // Well-known types | ||||
| @@ -248,6 +253,7 @@ message TestAllTypes { | ||||
|   repeated google.protobuf.Value repeated_value = 316; | ||||
| 
 | ||||
|   // Test field-name-to-JSON-name convention. | ||||
|   // (protobuf says names can be any valid C/C++ identifier.) | ||||
|   int32 fieldname1 = 401; | ||||
|   int32 field_name2 = 402; | ||||
|   int32 _field_name3 = 403; | ||||
| @@ -260,6 +266,12 @@ message TestAllTypes { | ||||
|   int32 Field_Name10 = 410; | ||||
|   int32 FIELD_NAME11 = 411; | ||||
|   int32 FIELD_name12 = 412; | ||||
|   int32 __field_name13 = 413; | ||||
|   int32 __Field_name14 = 414; | ||||
|   int32 field__name15 = 415; | ||||
|   int32 field__Name16 = 416; | ||||
|   int32 field_name17__ = 417; | ||||
|   int32 Field_name18__ = 418; | ||||
| } | ||||
| 
 | ||||
| message ForeignMessage { | ||||
							
								
								
									
										4
									
								
								vendor/github.com/gogo/protobuf/conformance/conformance.sh
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/gogo/protobuf/conformance/conformance.sh
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,4 +0,0 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| cd $(dirname $0) | ||||
| exec go run conformance.go $* | ||||
							
								
								
									
										1561
									
								
								vendor/github.com/gogo/protobuf/conformance/internal/conformance_proto/conformance.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1561
									
								
								vendor/github.com/gogo/protobuf/conformance/internal/conformance_proto/conformance.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										26
									
								
								vendor/github.com/gogo/protobuf/conformance/test.sh
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								vendor/github.com/gogo/protobuf/conformance/test.sh
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,26 +0,0 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| PROTOBUF_ROOT=$1 | ||||
| CONFORMANCE_ROOT=$1/conformance | ||||
| CONFORMANCE_TEST_RUNNER=$CONFORMANCE_ROOT/conformance-test-runner | ||||
|  | ||||
| cd $(dirname $0) | ||||
|  | ||||
| if [[ $PROTOBUF_ROOT == "" ]]; then | ||||
|   echo "usage: test.sh <protobuf-root>" >/dev/stderr | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| if [[ ! -x $CONFORMANCE_TEST_RUNNER ]]; then | ||||
|   echo "SKIP: conformance test runner not installed" >/dev/stderr | ||||
|   exit 0 | ||||
| fi | ||||
|  | ||||
| a=$CONFORMANCE_ROOT/conformance.proto | ||||
| b=internal/conformance_proto/conformance.proto | ||||
| if [[ $(diff $a $b) != "" ]]; then | ||||
|   cp $a $b | ||||
|   echo "WARNING: conformance.proto is out of date" >/dev/stderr | ||||
| fi | ||||
|  | ||||
| $CONFORMANCE_TEST_RUNNER --failure_list failure_list_go.txt ./conformance.sh | ||||
							
								
								
									
										3
									
								
								vendor/github.com/gogo/protobuf/custom_types.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/gogo/protobuf/custom_types.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -41,7 +41,6 @@ signatures. Assuming the custom type is called `T`: | ||||
| func (t T) Marshal() ([]byte, error) {} | ||||
| func (t *T) MarshalTo(data []byte) (n int, err error) {} | ||||
| func (t *T) Unmarshal(data []byte) error {} | ||||
| func (t *T) Size() int {} | ||||
|  | ||||
| func (t T) MarshalJSON() ([]byte, error) {} | ||||
| func (t *T) UnmarshalJSON(data []byte) error {} | ||||
| @@ -67,5 +66,3 @@ Issues with customtype include: | ||||
|   * <a href="https://github.com/gogo/protobuf/issues/125">Using a proto message as a customtype is not allowed.</a> | ||||
|   * <a href="https://github.com/gogo/protobuf/issues/200">cusomtype of type map can not UnmarshalText</a> | ||||
|   * <a href="https://github.com/gogo/protobuf/issues/201">customtype of type struct cannot jsonpb unmarshal</a> | ||||
|   * <a href="https://github.com/gogo/protobuf/issues/477">Customtype field does not get a generated 'getter' method</a> | ||||
|   * <a href="https://github.com/gogo/protobuf/issues/478">Repeated customtype fields generate slices without pointer to the custom type </a> | ||||
|   | ||||
							
								
								
									
										23
									
								
								vendor/github.com/gogo/protobuf/extensions.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/gogo/protobuf/extensions.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,8 +20,8 @@ See [BenchComparison](https://github.com/gogo/protobuf/blob/master/bench.md) for | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/size">sizer</a></td><td>Message</td><td>bool</td><td>if true, a Size method is generated for the specific message</td><td>false</td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/unmarshal">unmarshaler</a></td><td> Message </td><td> bool </td><td> if true, an Unmarshal method is generated for the specific message </td><td> false</td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/size">protosizer</a></td><td>Message</td><td>bool</td><td>if true, a ProtoSize method is generated for the specific message</td><td>false</td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/marshalto"> unsafe_marshaler</a> (deprecated) </td><td> Message </td><td> bool </td><td> if true, a Marshal and MarshalTo method is generated. </td><td> false</td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/unmarshal">unsafe_unmarshaler</a> (deprecated) </td><td> Message </td><td> bool </td><td> if true, an Unmarshal method is generated. </td><td> false</td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/marshalto"> unsafe_marshaler</a> </td><td> Message </td><td> bool </td><td> if true, a Marshal and MarshalTo method is generated for the specific message. The generated code uses the unsafe package and is not compatible with big endian CPUs. </td><td> false</td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/unmarshal">unsafe_unmarshaler</a></td><td> Message </td><td> bool </td><td> if true, an Unmarshal method is generated for the specific message. The generated code uses the unsafe package and is not compatible with big endian CPUs. </td><td> false</td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/marshalto">stable_marshaler</a></td><td> Message </td><td> bool </td><td> if true, a Marshal and MarshalTo method is generated for the specific message, but unlike marshaler the output is guaranteed to be deterministic, at the sacrifice of some speed</td><td> false </td></tr> | ||||
| <tr><td>typedecl (beta)</td><td> Message </td><td> bool </td><td> if false, type declaration of the message is excluded from the generated output. Requires the marshaler and unmarshaler to be generated.</td><td> true </td></tr> | ||||
| </table> | ||||
| @@ -50,9 +50,9 @@ You might also find that basic structs that started their life as part of an API | ||||
| <tr><td><a href="https://github.com/gogo/protobuf/blob/master/test/types/types.proto">stdduration</a></td><td> Duration Field </td><td> bool </td><td>Changes the Well Known Duration Type to time.Duration</td><td>Duration</td></tr> | ||||
| </table> | ||||
|  | ||||
| `Warning about nullable: according to the Protocol Buffer specification, you should be able to tell whether a field is set or unset. With the option nullable=false this feature is lost, since your non-nullable fields will always be set.` | ||||
| `Warning about nullable: according to the Protocol Buffer specification, you should be able to tell whether a field is set or unset. With the option nullable=false this feature is lost, since your non-nullable fields will always be set.`  | ||||
|  | ||||
| # Goprotobuf Compatibility | ||||
| # Goprotobuf Compatibility  | ||||
|  | ||||
| Gogoprotobuf is compatible with Goprotobuf, because it is compatible with protocol buffers (see the section on tests below). | ||||
|  | ||||
| @@ -69,10 +69,6 @@ The enumprefix, getters and stringer extensions can be used to remove some of th | ||||
| <tr><td> goproto_enum_stringer (experimental) </td><td> Enum </td><td> bool </td><td> if false, the enum is generated without the default string method, this is useful for rather using enum_stringer </td><td> true </td></tr> | ||||
| <tr><td> goproto_extensions_map (beta) </td><td> Message </td><td> bool </td><td> if false, the extensions field is generated as type []byte instead of type map[int32]proto.Extension </td><td> true </td></tr> | ||||
| <tr><td> goproto_unrecognized (beta) </td><td> Message </td><td> bool </td><td>if false, XXX_unrecognized field is not generated. This is useful to reduce GC pressure at the cost of losing information about unrecognized fields. </td><td> true </td></tr> | ||||
| <tr><td> goproto_unkeyed (alpha) </td><td> Message </td><td> bool </td><td>if false, XXX_unkeyed field is not generated. </td><td> true </td></tr> | ||||
| <tr><td> goproto_sizecache (alpha) </td><td> Message </td><td> bool </td><td>if false, XXX_sizecache field is not generated. </td><td> true </td></tr> | ||||
| <tr><td> goproto_registration (beta) </td><td> File </td><td> bool </td><td>if true, the generated files will register all messages and types against both gogo/protobuf and golang/protobuf. This is necessary when using third-party packages which read registrations from golang/protobuf (such as the grpc-gateway). </td><td> false </td></tr> | ||||
| <tr><td> message_name </td><td> Message </td><td> bool </td><td>if true, a `XXX_MessageName()` method is generated that returns the message's name.  This is useful for grpc-gateway compatibility.</td><td> false </td></tr> | ||||
| </table> | ||||
|  | ||||
| # Less Typing | ||||
| @@ -84,7 +80,7 @@ Helper methods, functions and interfaces can be generated by triggering certain | ||||
| <table> | ||||
| <tr><td><b>Name</b></td><td><b>Option</b></td><td><b>Type</b></td><td><b>Description</b></td><td><b>Default</b></td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/gostring">gostring</a></td><td> Message </td><td> bool </td><td> if true, a `GoString` method is generated. This returns a string representing valid go code to reproduce the current state of the struct. </td><td> false </td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/union"> onlyone</a> </td><td> Message </td><td> bool </td><td> if true, all fields must be nullable and only one of the fields may be set, like a union. Two methods are generated: `GetValue() interface{}` and `SetValue(v interface{}) (set bool)`. These provide easier interaction with a union. </td><td> false </td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/union"> onlyone</a> (deprecated) </td><td> Message </td><td> bool </td><td> if true, all fields must be nullable and only one of the fields may be set, like a union. Two methods are generated: `GetValue() interface{}` and `SetValue(v interface{}) (set bool)`. These provide easier interaction with a union. </td><td> false </td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/equal"> equal</a></td><td> Message </td><td> bool </td><td> if true, an Equal method is generated </td><td> false </td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/compare"> compare</a></td><td> Message </td><td> bool </td><td> if true, a Compare method is generated.  This is very useful for quickly implementing sort on a list of protobuf structs </td><td> false </td></tr> | ||||
| <tr><td><a href="http://godoc.org/github.com/gogo/protobuf/plugin/equal"> verbose_equal</a> </td><td> Message </td><td> bool </td><td> if true, a verbose equal method is generated for the message. This returns an error which describes the exact element which is not equal to the exact element in the other struct. </td><td> false </td></tr> | ||||
| @@ -100,7 +96,7 @@ Issues with Compare include: | ||||
|   * <a href="https://github.com/gogo/protobuf/issues/230">Not all Well Known Types are supported yet</a> | ||||
|   * <a href="https://github.com/gogo/protobuf/issues/231">Maps are not supported</a> | ||||
|  | ||||
| # Peace of Mind | ||||
| #Peace of Mind | ||||
|  | ||||
| Test and Benchmark generation is done with the following extensions: | ||||
|  | ||||
| @@ -120,7 +116,7 @@ Other serialization formats like xml and json typically use reflect to marshal a | ||||
|  | ||||
| <a href="https://groups.google.com/forum/#!topic/gogoprotobuf/xmFnqAS6MIc">Here is a longer explanation of jsontag and moretags</a> | ||||
|  | ||||
| # File Options | ||||
| # File Options  | ||||
|  | ||||
| Each of the boolean message and enum extensions also have a file extension: | ||||
|  | ||||
| @@ -137,8 +133,6 @@ Each of the boolean message and enum extensions also have a file extension: | ||||
|   * `goproto_enum_stringer_all` | ||||
|   * `goproto_extensions_map_all` | ||||
|   * `goproto_unrecognized_all` | ||||
|   * `goproto_unkeyed_all` | ||||
|   * `goproto_sizecache_all` | ||||
|   * `gostring_all` | ||||
|   * `onlyone_all` | ||||
|   * `equal_all` | ||||
| @@ -153,13 +147,12 @@ Each of the boolean message and enum extensions also have a file extension: | ||||
|   * `benchgen_all` | ||||
|   * `enumdecl_all` | ||||
|   * `typedecl_all` | ||||
|   * `messagename_all` | ||||
|  | ||||
| Each of these are the same as their Message Option counterparts, except they apply to all messages in the file.  Their Message option counterparts can also be used to overwrite their effect. | ||||
|  | ||||
| # Tests | ||||
|  | ||||
|   * The normal barrage of tests are run with: `make tests` | ||||
|   * The normal barrage of tests are run with: `make tests`  | ||||
|   * A few weird tests: `make testall` | ||||
|   * Tests for compatibility with [golang/protobuf](https://github.com/golang/protobuf) are handled by a different project [harmonytests](https://github.com/gogo/harmonytests), since it requires goprotobuf. | ||||
|   * Cross version tests are made with [Travis CI](https://travis-ci.org/gogo/protobuf). | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/github.com/gogo/protobuf/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/gogo/protobuf/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,6 +0,0 @@ | ||||
| module github.com/gogo/protobuf | ||||
|  | ||||
| require ( | ||||
| 	github.com/kisielk/errcheck v1.2.0 // indirect | ||||
| 	github.com/kisielk/gotool v1.0.0 // indirect | ||||
| ) | ||||
							
								
								
									
										10
									
								
								vendor/github.com/gogo/protobuf/go.sum
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/gogo/protobuf/go.sum
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,10 +0,0 @@ | ||||
| github.com/kisielk/errcheck v1.1.0 h1:ZqfnKyx9KGpRcW04j5nnPDgRgoXUeLh2YFBeFzphcA0= | ||||
| github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= | ||||
| github.com/kisielk/errcheck v1.2.0 h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E= | ||||
| github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= | ||||
| github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= | ||||
| github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | ||||
| golang.org/x/tools v0.0.0-20180221164845-07fd8470d635 h1:2eB4G6bDQDeP69ZXbOKC00S2Kf6TIiRS+DzfKsKeQU0= | ||||
| golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563 h1:NIou6eNFigscvKJmsbyez16S2cIS6idossORlFtSt2E= | ||||
| golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
							
								
								
									
										2
									
								
								vendor/github.com/gogo/protobuf/gogoproto/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/gogo/protobuf/gogoproto/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -28,7 +28,7 @@ | ||||
|  | ||||
| regenerate: | ||||
| 	go install github.com/gogo/protobuf/protoc-gen-gogo | ||||
| 	protoc --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:../../../../ --proto_path=../../../../:../protobuf/:. *.proto | ||||
| 	protoc --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:. --proto_path=../../../../:../protobuf/:. *.proto | ||||
|  | ||||
| restore: | ||||
| 	cp gogo.pb.golden gogo.pb.go | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/gogo/protobuf/gogoproto/doc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/gogo/protobuf/gogoproto/doc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -162,7 +162,7 @@ The most complete way to see examples is to look at | ||||
| 	github.com/gogo/protobuf/test/thetest.proto | ||||
|  | ||||
| Gogoprototest is a seperate project, | ||||
| because we want to keep gogoprotobuf independent of goprotobuf, | ||||
| because we want to keep gogoprotobuf independant of goprotobuf, | ||||
| but we still want to test it thoroughly. | ||||
|  | ||||
| */ | ||||
|   | ||||
							
								
								
									
										480
									
								
								vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										480
									
								
								vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,14 +1,21 @@ | ||||
| // Code generated by protoc-gen-gogo. DO NOT EDIT. | ||||
| // Code generated by protoc-gen-gogo. | ||||
| // source: gogo.proto | ||||
| // DO NOT EDIT! | ||||
|  | ||||
| /* | ||||
| Package gogoproto is a generated protocol buffer package. | ||||
|  | ||||
| It is generated from these files: | ||||
| 	gogo.proto | ||||
|  | ||||
| It has these top-level messages: | ||||
| */ | ||||
| package gogoproto | ||||
|  | ||||
| import ( | ||||
| 	fmt "fmt" | ||||
| 	proto "github.com/gogo/protobuf/proto" | ||||
| 	descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" | ||||
| 	math "math" | ||||
| ) | ||||
| import proto "github.com/gogo/protobuf/proto" | ||||
| import fmt "fmt" | ||||
| import math "math" | ||||
| import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" | ||||
|  | ||||
| // Reference imports to suppress errors if they are not otherwise used. | ||||
| var _ = proto.Marshal | ||||
| @@ -19,46 +26,46 @@ var _ = math.Inf | ||||
| // is compatible with the proto package it is being compiled against. | ||||
| // A compilation error at this line likely means your copy of the | ||||
| // proto package needs to be updated. | ||||
| const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package | ||||
| const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package | ||||
|  | ||||
| var E_GoprotoEnumPrefix = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.EnumOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.EnumOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         62001, | ||||
| 	Name:          "gogoproto.goproto_enum_prefix", | ||||
| 	Tag:           "varint,62001,opt,name=goproto_enum_prefix", | ||||
| 	Tag:           "varint,62001,opt,name=goproto_enum_prefix,json=goprotoEnumPrefix", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoEnumStringer = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.EnumOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.EnumOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         62021, | ||||
| 	Name:          "gogoproto.goproto_enum_stringer", | ||||
| 	Tag:           "varint,62021,opt,name=goproto_enum_stringer", | ||||
| 	Tag:           "varint,62021,opt,name=goproto_enum_stringer,json=goprotoEnumStringer", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_EnumStringer = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.EnumOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.EnumOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         62022, | ||||
| 	Name:          "gogoproto.enum_stringer", | ||||
| 	Tag:           "varint,62022,opt,name=enum_stringer", | ||||
| 	Tag:           "varint,62022,opt,name=enum_stringer,json=enumStringer", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_EnumCustomname = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.EnumOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.EnumOptions)(nil), | ||||
| 	ExtensionType: (*string)(nil), | ||||
| 	Field:         62023, | ||||
| 	Name:          "gogoproto.enum_customname", | ||||
| 	Tag:           "bytes,62023,opt,name=enum_customname", | ||||
| 	Tag:           "bytes,62023,opt,name=enum_customname,json=enumCustomname", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_Enumdecl = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.EnumOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.EnumOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         62024, | ||||
| 	Name:          "gogoproto.enumdecl", | ||||
| @@ -67,331 +74,304 @@ var E_Enumdecl = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_EnumvalueCustomname = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.EnumValueOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.EnumValueOptions)(nil), | ||||
| 	ExtensionType: (*string)(nil), | ||||
| 	Field:         66001, | ||||
| 	Name:          "gogoproto.enumvalue_customname", | ||||
| 	Tag:           "bytes,66001,opt,name=enumvalue_customname", | ||||
| 	Tag:           "bytes,66001,opt,name=enumvalue_customname,json=enumvalueCustomname", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoGettersAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63001, | ||||
| 	Name:          "gogoproto.goproto_getters_all", | ||||
| 	Tag:           "varint,63001,opt,name=goproto_getters_all", | ||||
| 	Tag:           "varint,63001,opt,name=goproto_getters_all,json=goprotoGettersAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoEnumPrefixAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63002, | ||||
| 	Name:          "gogoproto.goproto_enum_prefix_all", | ||||
| 	Tag:           "varint,63002,opt,name=goproto_enum_prefix_all", | ||||
| 	Tag:           "varint,63002,opt,name=goproto_enum_prefix_all,json=goprotoEnumPrefixAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoStringerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63003, | ||||
| 	Name:          "gogoproto.goproto_stringer_all", | ||||
| 	Tag:           "varint,63003,opt,name=goproto_stringer_all", | ||||
| 	Tag:           "varint,63003,opt,name=goproto_stringer_all,json=goprotoStringerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_VerboseEqualAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63004, | ||||
| 	Name:          "gogoproto.verbose_equal_all", | ||||
| 	Tag:           "varint,63004,opt,name=verbose_equal_all", | ||||
| 	Tag:           "varint,63004,opt,name=verbose_equal_all,json=verboseEqualAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_FaceAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63005, | ||||
| 	Name:          "gogoproto.face_all", | ||||
| 	Tag:           "varint,63005,opt,name=face_all", | ||||
| 	Tag:           "varint,63005,opt,name=face_all,json=faceAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GostringAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63006, | ||||
| 	Name:          "gogoproto.gostring_all", | ||||
| 	Tag:           "varint,63006,opt,name=gostring_all", | ||||
| 	Tag:           "varint,63006,opt,name=gostring_all,json=gostringAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_PopulateAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63007, | ||||
| 	Name:          "gogoproto.populate_all", | ||||
| 	Tag:           "varint,63007,opt,name=populate_all", | ||||
| 	Tag:           "varint,63007,opt,name=populate_all,json=populateAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_StringerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63008, | ||||
| 	Name:          "gogoproto.stringer_all", | ||||
| 	Tag:           "varint,63008,opt,name=stringer_all", | ||||
| 	Tag:           "varint,63008,opt,name=stringer_all,json=stringerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_OnlyoneAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63009, | ||||
| 	Name:          "gogoproto.onlyone_all", | ||||
| 	Tag:           "varint,63009,opt,name=onlyone_all", | ||||
| 	Tag:           "varint,63009,opt,name=onlyone_all,json=onlyoneAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_EqualAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63013, | ||||
| 	Name:          "gogoproto.equal_all", | ||||
| 	Tag:           "varint,63013,opt,name=equal_all", | ||||
| 	Tag:           "varint,63013,opt,name=equal_all,json=equalAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_DescriptionAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63014, | ||||
| 	Name:          "gogoproto.description_all", | ||||
| 	Tag:           "varint,63014,opt,name=description_all", | ||||
| 	Tag:           "varint,63014,opt,name=description_all,json=descriptionAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_TestgenAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63015, | ||||
| 	Name:          "gogoproto.testgen_all", | ||||
| 	Tag:           "varint,63015,opt,name=testgen_all", | ||||
| 	Tag:           "varint,63015,opt,name=testgen_all,json=testgenAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_BenchgenAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63016, | ||||
| 	Name:          "gogoproto.benchgen_all", | ||||
| 	Tag:           "varint,63016,opt,name=benchgen_all", | ||||
| 	Tag:           "varint,63016,opt,name=benchgen_all,json=benchgenAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_MarshalerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63017, | ||||
| 	Name:          "gogoproto.marshaler_all", | ||||
| 	Tag:           "varint,63017,opt,name=marshaler_all", | ||||
| 	Tag:           "varint,63017,opt,name=marshaler_all,json=marshalerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_UnmarshalerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63018, | ||||
| 	Name:          "gogoproto.unmarshaler_all", | ||||
| 	Tag:           "varint,63018,opt,name=unmarshaler_all", | ||||
| 	Tag:           "varint,63018,opt,name=unmarshaler_all,json=unmarshalerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_StableMarshalerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63019, | ||||
| 	Name:          "gogoproto.stable_marshaler_all", | ||||
| 	Tag:           "varint,63019,opt,name=stable_marshaler_all", | ||||
| 	Tag:           "varint,63019,opt,name=stable_marshaler_all,json=stableMarshalerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_SizerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63020, | ||||
| 	Name:          "gogoproto.sizer_all", | ||||
| 	Tag:           "varint,63020,opt,name=sizer_all", | ||||
| 	Tag:           "varint,63020,opt,name=sizer_all,json=sizerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoEnumStringerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63021, | ||||
| 	Name:          "gogoproto.goproto_enum_stringer_all", | ||||
| 	Tag:           "varint,63021,opt,name=goproto_enum_stringer_all", | ||||
| 	Tag:           "varint,63021,opt,name=goproto_enum_stringer_all,json=goprotoEnumStringerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_EnumStringerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63022, | ||||
| 	Name:          "gogoproto.enum_stringer_all", | ||||
| 	Tag:           "varint,63022,opt,name=enum_stringer_all", | ||||
| 	Tag:           "varint,63022,opt,name=enum_stringer_all,json=enumStringerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_UnsafeMarshalerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63023, | ||||
| 	Name:          "gogoproto.unsafe_marshaler_all", | ||||
| 	Tag:           "varint,63023,opt,name=unsafe_marshaler_all", | ||||
| 	Tag:           "varint,63023,opt,name=unsafe_marshaler_all,json=unsafeMarshalerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_UnsafeUnmarshalerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63024, | ||||
| 	Name:          "gogoproto.unsafe_unmarshaler_all", | ||||
| 	Tag:           "varint,63024,opt,name=unsafe_unmarshaler_all", | ||||
| 	Tag:           "varint,63024,opt,name=unsafe_unmarshaler_all,json=unsafeUnmarshalerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoExtensionsMapAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63025, | ||||
| 	Name:          "gogoproto.goproto_extensions_map_all", | ||||
| 	Tag:           "varint,63025,opt,name=goproto_extensions_map_all", | ||||
| 	Tag:           "varint,63025,opt,name=goproto_extensions_map_all,json=goprotoExtensionsMapAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoUnrecognizedAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63026, | ||||
| 	Name:          "gogoproto.goproto_unrecognized_all", | ||||
| 	Tag:           "varint,63026,opt,name=goproto_unrecognized_all", | ||||
| 	Tag:           "varint,63026,opt,name=goproto_unrecognized_all,json=goprotoUnrecognizedAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GogoprotoImport = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63027, | ||||
| 	Name:          "gogoproto.gogoproto_import", | ||||
| 	Tag:           "varint,63027,opt,name=gogoproto_import", | ||||
| 	Tag:           "varint,63027,opt,name=gogoproto_import,json=gogoprotoImport", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_ProtosizerAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63028, | ||||
| 	Name:          "gogoproto.protosizer_all", | ||||
| 	Tag:           "varint,63028,opt,name=protosizer_all", | ||||
| 	Tag:           "varint,63028,opt,name=protosizer_all,json=protosizerAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_CompareAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63029, | ||||
| 	Name:          "gogoproto.compare_all", | ||||
| 	Tag:           "varint,63029,opt,name=compare_all", | ||||
| 	Tag:           "varint,63029,opt,name=compare_all,json=compareAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_TypedeclAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63030, | ||||
| 	Name:          "gogoproto.typedecl_all", | ||||
| 	Tag:           "varint,63030,opt,name=typedecl_all", | ||||
| 	Tag:           "varint,63030,opt,name=typedecl_all,json=typedeclAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_EnumdeclAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63031, | ||||
| 	Name:          "gogoproto.enumdecl_all", | ||||
| 	Tag:           "varint,63031,opt,name=enumdecl_all", | ||||
| 	Tag:           "varint,63031,opt,name=enumdecl_all,json=enumdeclAll", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoRegistration = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63032, | ||||
| 	Name:          "gogoproto.goproto_registration", | ||||
| 	Tag:           "varint,63032,opt,name=goproto_registration", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_MessagenameAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63033, | ||||
| 	Name:          "gogoproto.messagename_all", | ||||
| 	Tag:           "varint,63033,opt,name=messagename_all", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoSizecacheAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63034, | ||||
| 	Name:          "gogoproto.goproto_sizecache_all", | ||||
| 	Tag:           "varint,63034,opt,name=goproto_sizecache_all", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoUnkeyedAll = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FileOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         63035, | ||||
| 	Name:          "gogoproto.goproto_unkeyed_all", | ||||
| 	Tag:           "varint,63035,opt,name=goproto_unkeyed_all", | ||||
| 	Tag:           "varint,63032,opt,name=goproto_registration,json=goprotoRegistration", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoGetters = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64001, | ||||
| 	Name:          "gogoproto.goproto_getters", | ||||
| 	Tag:           "varint,64001,opt,name=goproto_getters", | ||||
| 	Tag:           "varint,64001,opt,name=goproto_getters,json=goprotoGetters", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoStringer = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64003, | ||||
| 	Name:          "gogoproto.goproto_stringer", | ||||
| 	Tag:           "varint,64003,opt,name=goproto_stringer", | ||||
| 	Tag:           "varint,64003,opt,name=goproto_stringer,json=goprotoStringer", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_VerboseEqual = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64004, | ||||
| 	Name:          "gogoproto.verbose_equal", | ||||
| 	Tag:           "varint,64004,opt,name=verbose_equal", | ||||
| 	Tag:           "varint,64004,opt,name=verbose_equal,json=verboseEqual", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_Face = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64005, | ||||
| 	Name:          "gogoproto.face", | ||||
| @@ -400,7 +380,7 @@ var E_Face = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Gostring = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64006, | ||||
| 	Name:          "gogoproto.gostring", | ||||
| @@ -409,7 +389,7 @@ var E_Gostring = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Populate = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64007, | ||||
| 	Name:          "gogoproto.populate", | ||||
| @@ -418,7 +398,7 @@ var E_Populate = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Stringer = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         67008, | ||||
| 	Name:          "gogoproto.stringer", | ||||
| @@ -427,7 +407,7 @@ var E_Stringer = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Onlyone = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64009, | ||||
| 	Name:          "gogoproto.onlyone", | ||||
| @@ -436,7 +416,7 @@ var E_Onlyone = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Equal = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64013, | ||||
| 	Name:          "gogoproto.equal", | ||||
| @@ -445,7 +425,7 @@ var E_Equal = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Description = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64014, | ||||
| 	Name:          "gogoproto.description", | ||||
| @@ -454,7 +434,7 @@ var E_Description = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Testgen = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64015, | ||||
| 	Name:          "gogoproto.testgen", | ||||
| @@ -463,7 +443,7 @@ var E_Testgen = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Benchgen = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64016, | ||||
| 	Name:          "gogoproto.benchgen", | ||||
| @@ -472,7 +452,7 @@ var E_Benchgen = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Marshaler = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64017, | ||||
| 	Name:          "gogoproto.marshaler", | ||||
| @@ -481,7 +461,7 @@ var E_Marshaler = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Unmarshaler = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64018, | ||||
| 	Name:          "gogoproto.unmarshaler", | ||||
| @@ -490,16 +470,16 @@ var E_Unmarshaler = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_StableMarshaler = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64019, | ||||
| 	Name:          "gogoproto.stable_marshaler", | ||||
| 	Tag:           "varint,64019,opt,name=stable_marshaler", | ||||
| 	Tag:           "varint,64019,opt,name=stable_marshaler,json=stableMarshaler", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_Sizer = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64020, | ||||
| 	Name:          "gogoproto.sizer", | ||||
| @@ -508,43 +488,43 @@ var E_Sizer = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_UnsafeMarshaler = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64023, | ||||
| 	Name:          "gogoproto.unsafe_marshaler", | ||||
| 	Tag:           "varint,64023,opt,name=unsafe_marshaler", | ||||
| 	Tag:           "varint,64023,opt,name=unsafe_marshaler,json=unsafeMarshaler", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_UnsafeUnmarshaler = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64024, | ||||
| 	Name:          "gogoproto.unsafe_unmarshaler", | ||||
| 	Tag:           "varint,64024,opt,name=unsafe_unmarshaler", | ||||
| 	Tag:           "varint,64024,opt,name=unsafe_unmarshaler,json=unsafeUnmarshaler", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoExtensionsMap = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64025, | ||||
| 	Name:          "gogoproto.goproto_extensions_map", | ||||
| 	Tag:           "varint,64025,opt,name=goproto_extensions_map", | ||||
| 	Tag:           "varint,64025,opt,name=goproto_extensions_map,json=goprotoExtensionsMap", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoUnrecognized = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64026, | ||||
| 	Name:          "gogoproto.goproto_unrecognized", | ||||
| 	Tag:           "varint,64026,opt,name=goproto_unrecognized", | ||||
| 	Tag:           "varint,64026,opt,name=goproto_unrecognized,json=goprotoUnrecognized", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_Protosizer = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64028, | ||||
| 	Name:          "gogoproto.protosizer", | ||||
| @@ -553,7 +533,7 @@ var E_Protosizer = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Compare = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64029, | ||||
| 	Name:          "gogoproto.compare", | ||||
| @@ -562,7 +542,7 @@ var E_Compare = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Typedecl = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64030, | ||||
| 	Name:          "gogoproto.typedecl", | ||||
| @@ -570,35 +550,8 @@ var E_Typedecl = &proto.ExtensionDesc{ | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_Messagename = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64033, | ||||
| 	Name:          "gogoproto.messagename", | ||||
| 	Tag:           "varint,64033,opt,name=messagename", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoSizecache = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64034, | ||||
| 	Name:          "gogoproto.goproto_sizecache", | ||||
| 	Tag:           "varint,64034,opt,name=goproto_sizecache", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_GoprotoUnkeyed = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.MessageOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         64035, | ||||
| 	Name:          "gogoproto.goproto_unkeyed", | ||||
| 	Tag:           "varint,64035,opt,name=goproto_unkeyed", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_Nullable = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         65001, | ||||
| 	Name:          "gogoproto.nullable", | ||||
| @@ -607,7 +560,7 @@ var E_Nullable = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Embed = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         65002, | ||||
| 	Name:          "gogoproto.embed", | ||||
| @@ -616,7 +569,7 @@ var E_Embed = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Customtype = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*string)(nil), | ||||
| 	Field:         65003, | ||||
| 	Name:          "gogoproto.customtype", | ||||
| @@ -625,7 +578,7 @@ var E_Customtype = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Customname = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*string)(nil), | ||||
| 	Field:         65004, | ||||
| 	Name:          "gogoproto.customname", | ||||
| @@ -634,7 +587,7 @@ var E_Customname = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Jsontag = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*string)(nil), | ||||
| 	Field:         65005, | ||||
| 	Name:          "gogoproto.jsontag", | ||||
| @@ -643,7 +596,7 @@ var E_Jsontag = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Moretags = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*string)(nil), | ||||
| 	Field:         65006, | ||||
| 	Name:          "gogoproto.moretags", | ||||
| @@ -652,7 +605,7 @@ var E_Moretags = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Casttype = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*string)(nil), | ||||
| 	Field:         65007, | ||||
| 	Name:          "gogoproto.casttype", | ||||
| @@ -661,7 +614,7 @@ var E_Casttype = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Castkey = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*string)(nil), | ||||
| 	Field:         65008, | ||||
| 	Name:          "gogoproto.castkey", | ||||
| @@ -670,7 +623,7 @@ var E_Castkey = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Castvalue = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*string)(nil), | ||||
| 	Field:         65009, | ||||
| 	Name:          "gogoproto.castvalue", | ||||
| @@ -679,7 +632,7 @@ var E_Castvalue = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Stdtime = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         65010, | ||||
| 	Name:          "gogoproto.stdtime", | ||||
| @@ -688,7 +641,7 @@ var E_Stdtime = &proto.ExtensionDesc{ | ||||
| } | ||||
|  | ||||
| var E_Stdduration = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtendedType:  (*google_protobuf.FieldOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         65011, | ||||
| 	Name:          "gogoproto.stdduration", | ||||
| @@ -696,15 +649,6 @@ var E_Stdduration = &proto.ExtensionDesc{ | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| var E_Wktpointer = &proto.ExtensionDesc{ | ||||
| 	ExtendedType:  (*descriptor.FieldOptions)(nil), | ||||
| 	ExtensionType: (*bool)(nil), | ||||
| 	Field:         65012, | ||||
| 	Name:          "gogoproto.wktpointer", | ||||
| 	Tag:           "varint,65012,opt,name=wktpointer", | ||||
| 	Filename:      "gogo.proto", | ||||
| } | ||||
|  | ||||
| func init() { | ||||
| 	proto.RegisterExtension(E_GoprotoEnumPrefix) | ||||
| 	proto.RegisterExtension(E_GoprotoEnumStringer) | ||||
| @@ -741,9 +685,6 @@ func init() { | ||||
| 	proto.RegisterExtension(E_TypedeclAll) | ||||
| 	proto.RegisterExtension(E_EnumdeclAll) | ||||
| 	proto.RegisterExtension(E_GoprotoRegistration) | ||||
| 	proto.RegisterExtension(E_MessagenameAll) | ||||
| 	proto.RegisterExtension(E_GoprotoSizecacheAll) | ||||
| 	proto.RegisterExtension(E_GoprotoUnkeyedAll) | ||||
| 	proto.RegisterExtension(E_GoprotoGetters) | ||||
| 	proto.RegisterExtension(E_GoprotoStringer) | ||||
| 	proto.RegisterExtension(E_VerboseEqual) | ||||
| @@ -767,9 +708,6 @@ func init() { | ||||
| 	proto.RegisterExtension(E_Protosizer) | ||||
| 	proto.RegisterExtension(E_Compare) | ||||
| 	proto.RegisterExtension(E_Typedecl) | ||||
| 	proto.RegisterExtension(E_Messagename) | ||||
| 	proto.RegisterExtension(E_GoprotoSizecache) | ||||
| 	proto.RegisterExtension(E_GoprotoUnkeyed) | ||||
| 	proto.RegisterExtension(E_Nullable) | ||||
| 	proto.RegisterExtension(E_Embed) | ||||
| 	proto.RegisterExtension(E_Customtype) | ||||
| @@ -781,94 +719,86 @@ func init() { | ||||
| 	proto.RegisterExtension(E_Castvalue) | ||||
| 	proto.RegisterExtension(E_Stdtime) | ||||
| 	proto.RegisterExtension(E_Stdduration) | ||||
| 	proto.RegisterExtension(E_Wktpointer) | ||||
| } | ||||
|  | ||||
| func init() { proto.RegisterFile("gogo.proto", fileDescriptor_592445b5231bc2b9) } | ||||
| func init() { proto.RegisterFile("gogo.proto", fileDescriptorGogo) } | ||||
|  | ||||
| var fileDescriptor_592445b5231bc2b9 = []byte{ | ||||
| 	// 1328 bytes of a gzipped FileDescriptorProto | ||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x98, 0x49, 0x6f, 0x1c, 0x45, | ||||
| 	0x14, 0x80, 0x85, 0x48, 0x64, 0x4f, 0x79, 0x8b, 0xc7, 0xc6, 0x84, 0x08, 0x44, 0xe0, 0xc4, 0xc9, | ||||
| 	0x3e, 0x45, 0x28, 0x65, 0x45, 0x96, 0x63, 0x39, 0x56, 0x10, 0x0e, 0xc6, 0x89, 0xc3, 0x76, 0x18, | ||||
| 	0xf5, 0xf4, 0x94, 0xdb, 0x8d, 0xbb, 0xbb, 0x9a, 0xee, 0xea, 0x10, 0xe7, 0x86, 0xc2, 0x22, 0x84, | ||||
| 	0xd8, 0x91, 0x20, 0x21, 0x09, 0x04, 0xc4, 0xbe, 0x86, 0x7d, 0xb9, 0x70, 0x61, 0xb9, 0xf2, 0x1f, | ||||
| 	0xb8, 0x00, 0x66, 0xf7, 0xcd, 0x17, 0xf4, 0xba, 0xdf, 0xeb, 0xa9, 0x69, 0x8f, 0x54, 0x35, 0xb7, | ||||
| 	0xf6, 0xb8, 0xbe, 0x6f, 0xaa, 0xdf, 0xeb, 0x7a, 0xef, 0x4d, 0x33, 0xe6, 0x49, 0x4f, 0x4e, 0xc6, | ||||
| 	0x89, 0x54, 0xb2, 0x5e, 0x83, 0xeb, 0xfc, 0x72, 0xdf, 0x7e, 0x4f, 0x4a, 0x2f, 0x10, 0x53, 0xf9, | ||||
| 	0x5f, 0xcd, 0x6c, 0x75, 0xaa, 0x25, 0x52, 0x37, 0xf1, 0x63, 0x25, 0x93, 0x62, 0x31, 0x3f, 0xc6, | ||||
| 	0xc6, 0x70, 0x71, 0x43, 0x44, 0x59, 0xd8, 0x88, 0x13, 0xb1, 0xea, 0x9f, 0xae, 0x5f, 0x3f, 0x59, | ||||
| 	0x90, 0x93, 0x44, 0x4e, 0xce, 0x47, 0x59, 0x78, 0x47, 0xac, 0x7c, 0x19, 0xa5, 0x7b, 0xaf, 0xfc, | ||||
| 	0x72, 0xf5, 0xfe, 0xab, 0x6e, 0xe9, 0x5f, 0x1e, 0x45, 0x14, 0xfe, 0xb7, 0x94, 0x83, 0x7c, 0x99, | ||||
| 	0x5d, 0xd3, 0xe1, 0x4b, 0x55, 0xe2, 0x47, 0x9e, 0x48, 0x0c, 0xc6, 0xef, 0xd1, 0x38, 0xa6, 0x19, | ||||
| 	0x8f, 0x23, 0xca, 0xe7, 0xd8, 0x50, 0x2f, 0xae, 0x1f, 0xd0, 0x35, 0x28, 0x74, 0xc9, 0x02, 0x1b, | ||||
| 	0xc9, 0x25, 0x6e, 0x96, 0x2a, 0x19, 0x46, 0x4e, 0x28, 0x0c, 0x9a, 0x1f, 0x73, 0x4d, 0x6d, 0x79, | ||||
| 	0x18, 0xb0, 0xb9, 0x92, 0xe2, 0x9c, 0xf5, 0xc3, 0x27, 0x2d, 0xe1, 0x06, 0x06, 0xc3, 0x4f, 0xb8, | ||||
| 	0x91, 0x72, 0x3d, 0x3f, 0xc9, 0xc6, 0xe1, 0xfa, 0x94, 0x13, 0x64, 0x42, 0xdf, 0xc9, 0x4d, 0x5d, | ||||
| 	0x3d, 0x27, 0x61, 0x19, 0xc9, 0x7e, 0x3e, 0xbb, 0x2b, 0xdf, 0xce, 0x58, 0x29, 0xd0, 0xf6, 0xa4, | ||||
| 	0x65, 0xd1, 0x13, 0x4a, 0x89, 0x24, 0x6d, 0x38, 0x41, 0xb7, 0xed, 0x1d, 0xf1, 0x83, 0xd2, 0x78, | ||||
| 	0x6e, 0xb3, 0x33, 0x8b, 0x0b, 0x05, 0x39, 0x1b, 0x04, 0x7c, 0x85, 0x5d, 0xdb, 0xe5, 0xa9, 0xb0, | ||||
| 	0x70, 0x9e, 0x47, 0xe7, 0xf8, 0x8e, 0x27, 0x03, 0xb4, 0x4b, 0x8c, 0x3e, 0x2f, 0x73, 0x69, 0xe1, | ||||
| 	0x7c, 0x19, 0x9d, 0x75, 0x64, 0x29, 0xa5, 0x60, 0xbc, 0x8d, 0x8d, 0x9e, 0x12, 0x49, 0x53, 0xa6, | ||||
| 	0xa2, 0x21, 0x1e, 0xc8, 0x9c, 0xc0, 0x42, 0x77, 0x01, 0x75, 0x23, 0x08, 0xce, 0x03, 0x07, 0xae, | ||||
| 	0x83, 0xac, 0x7f, 0xd5, 0x71, 0x85, 0x85, 0xe2, 0x22, 0x2a, 0xfa, 0x60, 0x3d, 0xa0, 0xb3, 0x6c, | ||||
| 	0xd0, 0x93, 0xc5, 0x2d, 0x59, 0xe0, 0x97, 0x10, 0x1f, 0x20, 0x06, 0x15, 0xb1, 0x8c, 0xb3, 0xc0, | ||||
| 	0x51, 0x36, 0x3b, 0x78, 0x85, 0x14, 0xc4, 0xa0, 0xa2, 0x87, 0xb0, 0xbe, 0x4a, 0x8a, 0x54, 0x8b, | ||||
| 	0xe7, 0x0c, 0x1b, 0x90, 0x51, 0xb0, 0x21, 0x23, 0x9b, 0x4d, 0x5c, 0x46, 0x03, 0x43, 0x04, 0x04, | ||||
| 	0xd3, 0xac, 0x66, 0x9b, 0x88, 0x37, 0x36, 0xe9, 0x78, 0x50, 0x06, 0x16, 0xd8, 0x08, 0x15, 0x28, | ||||
| 	0x5f, 0x46, 0x16, 0x8a, 0x37, 0x51, 0x31, 0xac, 0x61, 0x78, 0x1b, 0x4a, 0xa4, 0xca, 0x13, 0x36, | ||||
| 	0x92, 0xb7, 0xe8, 0x36, 0x10, 0xc1, 0x50, 0x36, 0x45, 0xe4, 0xae, 0xd9, 0x19, 0xde, 0xa6, 0x50, | ||||
| 	0x12, 0x03, 0x8a, 0x39, 0x36, 0x14, 0x3a, 0x49, 0xba, 0xe6, 0x04, 0x56, 0xe9, 0x78, 0x07, 0x1d, | ||||
| 	0x83, 0x25, 0x84, 0x11, 0xc9, 0xa2, 0x5e, 0x34, 0xef, 0x52, 0x44, 0x34, 0x0c, 0x8f, 0x5e, 0xaa, | ||||
| 	0x9c, 0x66, 0x20, 0x1a, 0xbd, 0xd8, 0xde, 0xa3, 0xa3, 0x57, 0xb0, 0x8b, 0xba, 0x71, 0x9a, 0xd5, | ||||
| 	0x52, 0xff, 0x8c, 0x95, 0xe6, 0x7d, 0xca, 0x74, 0x0e, 0x00, 0x7c, 0x0f, 0xbb, 0xae, 0x6b, 0x9b, | ||||
| 	0xb0, 0x90, 0x7d, 0x80, 0xb2, 0x89, 0x2e, 0xad, 0x02, 0x4b, 0x42, 0xaf, 0xca, 0x0f, 0xa9, 0x24, | ||||
| 	0x88, 0x8a, 0x6b, 0x89, 0x8d, 0x67, 0x51, 0xea, 0xac, 0xf6, 0x16, 0xb5, 0x8f, 0x28, 0x6a, 0x05, | ||||
| 	0xdb, 0x11, 0xb5, 0x13, 0x6c, 0x02, 0x8d, 0xbd, 0xe5, 0xf5, 0x63, 0x2a, 0xac, 0x05, 0xbd, 0xd2, | ||||
| 	0x99, 0xdd, 0xfb, 0xd8, 0xbe, 0x32, 0x9c, 0xa7, 0x95, 0x88, 0x52, 0x60, 0x1a, 0xa1, 0x13, 0x5b, | ||||
| 	0x98, 0xaf, 0xa0, 0x99, 0x2a, 0xfe, 0x7c, 0x29, 0x58, 0x74, 0x62, 0x90, 0xdf, 0xcd, 0xf6, 0x92, | ||||
| 	0x3c, 0x8b, 0x12, 0xe1, 0x4a, 0x2f, 0xf2, 0xcf, 0x88, 0x96, 0x85, 0xfa, 0x93, 0x4a, 0xaa, 0x56, | ||||
| 	0x34, 0x1c, 0xcc, 0x47, 0xd9, 0x9e, 0x72, 0x56, 0x69, 0xf8, 0x61, 0x2c, 0x13, 0x65, 0x30, 0x7e, | ||||
| 	0x4a, 0x99, 0x2a, 0xb9, 0xa3, 0x39, 0xc6, 0xe7, 0xd9, 0x70, 0xfe, 0xa7, 0xed, 0x23, 0xf9, 0x19, | ||||
| 	0x8a, 0x86, 0xda, 0x14, 0x16, 0x0e, 0x57, 0x86, 0xb1, 0x93, 0xd8, 0xd4, 0xbf, 0xcf, 0xa9, 0x70, | ||||
| 	0x20, 0x82, 0x85, 0x43, 0x6d, 0xc4, 0x02, 0xba, 0xbd, 0x85, 0xe1, 0x0b, 0x2a, 0x1c, 0xc4, 0xa0, | ||||
| 	0x82, 0x06, 0x06, 0x0b, 0xc5, 0x97, 0xa4, 0x20, 0x06, 0x14, 0x77, 0xb6, 0x1b, 0x6d, 0x22, 0x3c, | ||||
| 	0x3f, 0x55, 0x89, 0x03, 0xab, 0x0d, 0xaa, 0xaf, 0x36, 0x3b, 0x87, 0xb0, 0x65, 0x0d, 0x85, 0x4a, | ||||
| 	0x14, 0x8a, 0x34, 0x75, 0x3c, 0x01, 0x13, 0x87, 0xc5, 0xc6, 0xbe, 0xa6, 0x4a, 0xa4, 0x61, 0xb0, | ||||
| 	0x37, 0x6d, 0x42, 0x84, 0xb0, 0xbb, 0x8e, 0xbb, 0x66, 0xa3, 0xfb, 0xa6, 0xb2, 0xb9, 0xe3, 0xc4, | ||||
| 	0x82, 0x53, 0x9b, 0x7f, 0xb2, 0x68, 0x5d, 0x6c, 0x58, 0x3d, 0x9d, 0xdf, 0x56, 0xe6, 0x9f, 0x95, | ||||
| 	0x82, 0x2c, 0x6a, 0xc8, 0x48, 0x65, 0x9e, 0xaa, 0xdf, 0xb8, 0xc3, 0xb5, 0x58, 0xdc, 0x17, 0xe9, | ||||
| 	0x1e, 0xda, 0xc2, 0xfb, 0xed, 0x1c, 0xa7, 0xf8, 0xed, 0xf0, 0x90, 0x77, 0x0e, 0x3d, 0x66, 0xd9, | ||||
| 	0xd9, 0xad, 0xf2, 0x39, 0xef, 0x98, 0x79, 0xf8, 0x11, 0x36, 0xd4, 0x31, 0xf0, 0x98, 0x55, 0x0f, | ||||
| 	0xa3, 0x6a, 0x50, 0x9f, 0x77, 0xf8, 0x01, 0xb6, 0x0b, 0x86, 0x17, 0x33, 0xfe, 0x08, 0xe2, 0xf9, | ||||
| 	0x72, 0x7e, 0x88, 0xf5, 0xd3, 0xd0, 0x62, 0x46, 0x1f, 0x45, 0xb4, 0x44, 0x00, 0xa7, 0x81, 0xc5, | ||||
| 	0x8c, 0x3f, 0x46, 0x38, 0x21, 0x80, 0xdb, 0x87, 0xf0, 0xbb, 0x27, 0x76, 0x61, 0xd3, 0xa1, 0xd8, | ||||
| 	0x4d, 0xb3, 0x3e, 0x9c, 0x54, 0xcc, 0xf4, 0xe3, 0xf8, 0xe5, 0x44, 0xf0, 0x5b, 0xd9, 0x6e, 0xcb, | ||||
| 	0x80, 0x3f, 0x89, 0x68, 0xb1, 0x9e, 0xcf, 0xb1, 0x01, 0x6d, 0x3a, 0x31, 0xe3, 0x4f, 0x21, 0xae, | ||||
| 	0x53, 0xb0, 0x75, 0x9c, 0x4e, 0xcc, 0x82, 0xa7, 0x69, 0xeb, 0x48, 0x40, 0xd8, 0x68, 0x30, 0x31, | ||||
| 	0xd3, 0xcf, 0x50, 0xd4, 0x09, 0xe1, 0x33, 0xac, 0x56, 0x36, 0x1b, 0x33, 0xff, 0x2c, 0xf2, 0x6d, | ||||
| 	0x06, 0x22, 0xa0, 0x35, 0x3b, 0xb3, 0xe2, 0x39, 0x8a, 0x80, 0x46, 0xc1, 0x31, 0xaa, 0x0e, 0x30, | ||||
| 	0x66, 0xd3, 0xf3, 0x74, 0x8c, 0x2a, 0xf3, 0x0b, 0x64, 0x33, 0xaf, 0xf9, 0x66, 0xc5, 0x0b, 0x94, | ||||
| 	0xcd, 0x7c, 0x3d, 0x6c, 0xa3, 0x3a, 0x11, 0x98, 0x1d, 0x2f, 0xd2, 0x36, 0x2a, 0x03, 0x01, 0x5f, | ||||
| 	0x62, 0xf5, 0x9d, 0xd3, 0x80, 0xd9, 0xf7, 0x12, 0xfa, 0x46, 0x77, 0x0c, 0x03, 0xfc, 0x2e, 0x36, | ||||
| 	0xd1, 0x7d, 0x12, 0x30, 0x5b, 0xcf, 0x6d, 0x55, 0x7e, 0xbb, 0xe9, 0x83, 0x00, 0x3f, 0xd1, 0x6e, | ||||
| 	0x29, 0xfa, 0x14, 0x60, 0xd6, 0x9e, 0xdf, 0xea, 0x2c, 0xdc, 0xfa, 0x10, 0xc0, 0x67, 0x19, 0x6b, | ||||
| 	0x37, 0x60, 0xb3, 0xeb, 0x02, 0xba, 0x34, 0x08, 0x8e, 0x06, 0xf6, 0x5f, 0x33, 0x7f, 0x91, 0x8e, | ||||
| 	0x06, 0x12, 0x70, 0x34, 0xa8, 0xf5, 0x9a, 0xe9, 0x4b, 0x74, 0x34, 0x08, 0x81, 0x27, 0x5b, 0xeb, | ||||
| 	0x6e, 0x66, 0xc3, 0x65, 0x7a, 0xb2, 0x35, 0x8a, 0x1f, 0x63, 0xa3, 0x3b, 0x1a, 0xa2, 0x59, 0xf5, | ||||
| 	0x1a, 0xaa, 0xf6, 0x54, 0xfb, 0xa1, 0xde, 0xbc, 0xb0, 0x19, 0x9a, 0x6d, 0xaf, 0x57, 0x9a, 0x17, | ||||
| 	0xf6, 0x42, 0x3e, 0xcd, 0xfa, 0xa3, 0x2c, 0x08, 0xe0, 0xf0, 0xd4, 0x6f, 0xe8, 0xd2, 0x4d, 0x45, | ||||
| 	0xd0, 0x22, 0xc5, 0xaf, 0xdb, 0x18, 0x1d, 0x02, 0xf8, 0x01, 0xb6, 0x5b, 0x84, 0x4d, 0xd1, 0x32, | ||||
| 	0x91, 0xbf, 0x6d, 0x53, 0xc1, 0x84, 0xd5, 0x7c, 0x86, 0xb1, 0xe2, 0xd5, 0x08, 0x84, 0xd9, 0xc4, | ||||
| 	0xfe, 0xbe, 0x5d, 0xbc, 0xa5, 0xd1, 0x90, 0xb6, 0x20, 0x4f, 0x8a, 0x41, 0xb0, 0xd9, 0x29, 0xc8, | ||||
| 	0x33, 0x72, 0x90, 0xf5, 0xdd, 0x9f, 0xca, 0x48, 0x39, 0x9e, 0x89, 0xfe, 0x03, 0x69, 0x5a, 0x0f, | ||||
| 	0x01, 0x0b, 0x65, 0x22, 0x94, 0xe3, 0xa5, 0x26, 0xf6, 0x4f, 0x64, 0x4b, 0x00, 0x60, 0xd7, 0x49, | ||||
| 	0x95, 0xcd, 0x7d, 0xff, 0x45, 0x30, 0x01, 0xb0, 0x69, 0xb8, 0x5e, 0x17, 0x1b, 0x26, 0xf6, 0x6f, | ||||
| 	0xda, 0x34, 0xae, 0xe7, 0x87, 0x58, 0x0d, 0x2e, 0xf3, 0xb7, 0x4a, 0x26, 0xf8, 0x1f, 0x84, 0xdb, | ||||
| 	0x04, 0x7c, 0x73, 0xaa, 0x5a, 0xca, 0x37, 0x07, 0xfb, 0x5f, 0xcc, 0x34, 0xad, 0xe7, 0xb3, 0x6c, | ||||
| 	0x20, 0x55, 0xad, 0x56, 0x86, 0xf3, 0xa9, 0x01, 0xff, 0x6f, 0xbb, 0x7c, 0x65, 0x51, 0x32, 0x90, | ||||
| 	0xed, 0x07, 0xd7, 0x55, 0x2c, 0xfd, 0x48, 0x89, 0xc4, 0x64, 0xd8, 0x42, 0x83, 0x86, 0x1c, 0x9e, | ||||
| 	0x67, 0x63, 0xae, 0x0c, 0xab, 0xdc, 0x61, 0xb6, 0x20, 0x17, 0xe4, 0x52, 0x5e, 0x67, 0xee, 0xbd, | ||||
| 	0xd9, 0xf3, 0xd5, 0x5a, 0xd6, 0x9c, 0x74, 0x65, 0x38, 0x05, 0xbf, 0x3c, 0xda, 0x2f, 0x54, 0xcb, | ||||
| 	0xdf, 0x21, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xaf, 0x70, 0x4e, 0x83, 0x15, 0x00, 0x00, | ||||
| var fileDescriptorGogo = []byte{ | ||||
| 	// 1201 bytes of a gzipped FileDescriptorProto | ||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x98, 0xcb, 0x6f, 0x1c, 0x45, | ||||
| 	0x13, 0xc0, 0xf5, 0xe9, 0x73, 0x64, 0x6f, 0xf9, 0x85, 0xd7, 0xc6, 0x84, 0x08, 0x44, 0x72, 0xe3, | ||||
| 	0xe4, 0x9c, 0x22, 0x94, 0xb6, 0x22, 0xcb, 0xb1, 0x1c, 0x2b, 0x11, 0x06, 0x63, 0xe2, 0x00, 0xe2, | ||||
| 	0xb0, 0x9a, 0xdd, 0x6d, 0x4f, 0x06, 0x66, 0xa6, 0x87, 0x99, 0x9e, 0x28, 0xce, 0x0d, 0x85, 0x87, | ||||
| 	0x10, 0xe2, 0x8d, 0x04, 0x09, 0x49, 0x80, 0x03, 0xef, 0x67, 0x78, 0x1f, 0xb9, 0xf0, 0xb8, 0xf2, | ||||
| 	0x3f, 0x70, 0x01, 0xcc, 0xdb, 0x37, 0x5f, 0x50, 0xcd, 0x56, 0xcd, 0xf6, 0xac, 0x57, 0xea, 0xde, | ||||
| 	0xdb, 0xec, 0xba, 0x7f, 0xbf, 0xad, 0xa9, 0x9a, 0xae, 0xea, 0x31, 0x80, 0xaf, 0x7c, 0x35, 0x97, | ||||
| 	0xa4, 0x4a, 0xab, 0x7a, 0x0d, 0xaf, 0x8b, 0xcb, 0x03, 0x07, 0x7d, 0xa5, 0xfc, 0x50, 0x1e, 0x2e, | ||||
| 	0x3e, 0x35, 0xf3, 0xcd, 0xc3, 0x6d, 0x99, 0xb5, 0xd2, 0x20, 0xd1, 0x2a, 0xed, 0x2c, 0x16, 0x77, | ||||
| 	0xc1, 0x34, 0x2d, 0x6e, 0xc8, 0x38, 0x8f, 0x1a, 0x49, 0x2a, 0x37, 0x83, 0xf3, 0xf5, 0x5b, 0xe6, | ||||
| 	0x3a, 0xe4, 0x1c, 0x93, 0x73, 0xcb, 0x71, 0x1e, 0xdd, 0x9d, 0xe8, 0x40, 0xc5, 0xd9, 0xfe, 0xeb, | ||||
| 	0x3f, 0xff, 0xff, 0xe0, 0xff, 0x6e, 0x1f, 0x59, 0x9f, 0x22, 0x14, 0xff, 0xb6, 0x56, 0x80, 0x62, | ||||
| 	0x1d, 0x6e, 0xac, 0xf8, 0x32, 0x9d, 0x06, 0xb1, 0x2f, 0x53, 0x8b, 0xf1, 0x3b, 0x32, 0x4e, 0x1b, | ||||
| 	0xc6, 0x7b, 0x09, 0x15, 0x4b, 0x30, 0x3e, 0x88, 0xeb, 0x7b, 0x72, 0x8d, 0x49, 0x53, 0xb2, 0x02, | ||||
| 	0x93, 0x85, 0xa4, 0x95, 0x67, 0x5a, 0x45, 0xb1, 0x17, 0x49, 0x8b, 0xe6, 0x87, 0x42, 0x53, 0x5b, | ||||
| 	0x9f, 0x40, 0x6c, 0xa9, 0xa4, 0x84, 0x80, 0x11, 0xfc, 0xa6, 0x2d, 0x5b, 0xa1, 0xc5, 0xf0, 0x23, | ||||
| 	0x05, 0x52, 0xae, 0x17, 0x67, 0x60, 0x06, 0xaf, 0xcf, 0x79, 0x61, 0x2e, 0xcd, 0x48, 0x0e, 0xf5, | ||||
| 	0xf5, 0x9c, 0xc1, 0x65, 0x2c, 0xfb, 0xe9, 0xe2, 0x50, 0x11, 0xce, 0x74, 0x29, 0x30, 0x62, 0x32, | ||||
| 	0xaa, 0xe8, 0x4b, 0xad, 0x65, 0x9a, 0x35, 0xbc, 0xb0, 0x5f, 0x78, 0x27, 0x82, 0xb0, 0x34, 0x5e, | ||||
| 	0xda, 0xae, 0x56, 0x71, 0xa5, 0x43, 0x2e, 0x86, 0xa1, 0xd8, 0x80, 0x9b, 0xfa, 0x3c, 0x15, 0x0e, | ||||
| 	0xce, 0xcb, 0xe4, 0x9c, 0xd9, 0xf3, 0x64, 0xa0, 0x76, 0x0d, 0xf8, 0xfb, 0xb2, 0x96, 0x0e, 0xce, | ||||
| 	0xd7, 0xc8, 0x59, 0x27, 0x96, 0x4b, 0x8a, 0xc6, 0x53, 0x30, 0x75, 0x4e, 0xa6, 0x4d, 0x95, 0xc9, | ||||
| 	0x86, 0x7c, 0x24, 0xf7, 0x42, 0x07, 0xdd, 0x15, 0xd2, 0x4d, 0x12, 0xb8, 0x8c, 0x1c, 0xba, 0x8e, | ||||
| 	0xc2, 0xc8, 0xa6, 0xd7, 0x92, 0x0e, 0x8a, 0xab, 0xa4, 0x18, 0xc6, 0xf5, 0x88, 0x2e, 0xc2, 0x98, | ||||
| 	0xaf, 0x3a, 0xb7, 0xe4, 0x80, 0x5f, 0x23, 0x7c, 0x94, 0x19, 0x52, 0x24, 0x2a, 0xc9, 0x43, 0x4f, | ||||
| 	0xbb, 0x44, 0xf0, 0x3a, 0x2b, 0x98, 0x21, 0xc5, 0x00, 0x69, 0x7d, 0x83, 0x15, 0x99, 0x91, 0xcf, | ||||
| 	0x05, 0x18, 0x55, 0x71, 0xb8, 0xa5, 0x62, 0x97, 0x20, 0xde, 0x24, 0x03, 0x10, 0x82, 0x82, 0x79, | ||||
| 	0xa8, 0xb9, 0x16, 0xe2, 0xad, 0x6d, 0xde, 0x1e, 0x5c, 0x81, 0x15, 0x98, 0xe4, 0x06, 0x15, 0xa8, | ||||
| 	0xd8, 0x41, 0xf1, 0x36, 0x29, 0x26, 0x0c, 0x8c, 0x6e, 0x43, 0xcb, 0x4c, 0xfb, 0xd2, 0x45, 0xf2, | ||||
| 	0x0e, 0xdf, 0x06, 0x21, 0x94, 0xca, 0xa6, 0x8c, 0x5b, 0x67, 0xdd, 0x0c, 0xef, 0x72, 0x2a, 0x99, | ||||
| 	0x41, 0xc5, 0x12, 0x8c, 0x47, 0x5e, 0x9a, 0x9d, 0xf5, 0x42, 0xa7, 0x72, 0xbc, 0x47, 0x8e, 0xb1, | ||||
| 	0x12, 0xa2, 0x8c, 0xe4, 0xf1, 0x20, 0x9a, 0xf7, 0x39, 0x23, 0x06, 0x46, 0x5b, 0x2f, 0xd3, 0x5e, | ||||
| 	0x33, 0x94, 0x8d, 0x41, 0x6c, 0x1f, 0xf0, 0xd6, 0xeb, 0xb0, 0xab, 0xa6, 0x71, 0x1e, 0x6a, 0x59, | ||||
| 	0x70, 0xc1, 0x49, 0xf3, 0x21, 0x57, 0xba, 0x00, 0x10, 0x7e, 0x00, 0x6e, 0xee, 0x3b, 0x26, 0x1c, | ||||
| 	0x64, 0x1f, 0x91, 0x6c, 0xb6, 0xcf, 0xa8, 0xa0, 0x96, 0x30, 0xa8, 0xf2, 0x63, 0x6e, 0x09, 0xb2, | ||||
| 	0xc7, 0xb5, 0x06, 0x33, 0x79, 0x9c, 0x79, 0x9b, 0x83, 0x65, 0xed, 0x13, 0xce, 0x5a, 0x87, 0xad, | ||||
| 	0x64, 0xed, 0x34, 0xcc, 0x92, 0x71, 0xb0, 0xba, 0x7e, 0xca, 0x8d, 0xb5, 0x43, 0x6f, 0x54, 0xab, | ||||
| 	0xfb, 0x20, 0x1c, 0x28, 0xd3, 0x79, 0x5e, 0xcb, 0x38, 0x43, 0xa6, 0x11, 0x79, 0x89, 0x83, 0xf9, | ||||
| 	0x3a, 0x99, 0xb9, 0xe3, 0x2f, 0x97, 0x82, 0x55, 0x2f, 0x41, 0xf9, 0xfd, 0xb0, 0x9f, 0xe5, 0x79, | ||||
| 	0x9c, 0xca, 0x96, 0xf2, 0xe3, 0xe0, 0x82, 0x6c, 0x3b, 0xa8, 0x3f, 0xeb, 0x29, 0xd5, 0x86, 0x81, | ||||
| 	0xa3, 0xf9, 0x24, 0xdc, 0x50, 0x9e, 0x55, 0x1a, 0x41, 0x94, 0xa8, 0x54, 0x5b, 0x8c, 0x9f, 0x73, | ||||
| 	0xa5, 0x4a, 0xee, 0x64, 0x81, 0x89, 0x65, 0x98, 0x28, 0x3e, 0xba, 0x3e, 0x92, 0x5f, 0x90, 0x68, | ||||
| 	0xbc, 0x4b, 0x51, 0xe3, 0x68, 0xa9, 0x28, 0xf1, 0x52, 0x97, 0xfe, 0xf7, 0x25, 0x37, 0x0e, 0x42, | ||||
| 	0xa8, 0x71, 0xe8, 0xad, 0x44, 0xe2, 0xb4, 0x77, 0x30, 0x7c, 0xc5, 0x8d, 0x83, 0x19, 0x52, 0xf0, | ||||
| 	0x81, 0xc1, 0x41, 0xf1, 0x35, 0x2b, 0x98, 0x41, 0xc5, 0x3d, 0xdd, 0x41, 0x9b, 0x4a, 0x3f, 0xc8, | ||||
| 	0x74, 0xea, 0xe1, 0x6a, 0x8b, 0xea, 0x9b, 0xed, 0xea, 0x21, 0x6c, 0xdd, 0x40, 0xc5, 0x29, 0x98, | ||||
| 	0xec, 0x39, 0x62, 0xd4, 0x6f, 0xdb, 0x63, 0x5b, 0x95, 0x59, 0xe6, 0xf9, 0xa5, 0xf0, 0xd1, 0x1d, | ||||
| 	0x6a, 0x46, 0xd5, 0x13, 0x86, 0xb8, 0x13, 0xeb, 0x5e, 0x3d, 0x07, 0xd8, 0x65, 0x17, 0x77, 0xca, | ||||
| 	0xd2, 0x57, 0x8e, 0x01, 0xe2, 0x04, 0x8c, 0x57, 0xce, 0x00, 0x76, 0xd5, 0x63, 0xa4, 0x1a, 0x33, | ||||
| 	0x8f, 0x00, 0xe2, 0x08, 0x0c, 0xe1, 0x3c, 0xb7, 0xe3, 0x8f, 0x13, 0x5e, 0x2c, 0x17, 0xc7, 0x60, | ||||
| 	0x84, 0xe7, 0xb8, 0x1d, 0x7d, 0x82, 0xd0, 0x12, 0x41, 0x9c, 0x67, 0xb8, 0x1d, 0x7f, 0x92, 0x71, | ||||
| 	0x46, 0x10, 0x77, 0x4f, 0xe1, 0xb7, 0x4f, 0x0f, 0x51, 0x1f, 0xe6, 0xdc, 0xcd, 0xc3, 0x30, 0x0d, | ||||
| 	0x6f, 0x3b, 0xfd, 0x14, 0xfd, 0x38, 0x13, 0xe2, 0x0e, 0xd8, 0xe7, 0x98, 0xf0, 0x67, 0x08, 0xed, | ||||
| 	0xac, 0x17, 0x4b, 0x30, 0x6a, 0x0c, 0x6c, 0x3b, 0xfe, 0x2c, 0xe1, 0x26, 0x85, 0xa1, 0xd3, 0xc0, | ||||
| 	0xb6, 0x0b, 0x9e, 0xe3, 0xd0, 0x89, 0xc0, 0xb4, 0xf1, 0xac, 0xb6, 0xd3, 0xcf, 0x73, 0xd6, 0x19, | ||||
| 	0x11, 0x0b, 0x50, 0x2b, 0xfb, 0xaf, 0x9d, 0x7f, 0x81, 0xf8, 0x2e, 0x83, 0x19, 0x30, 0xfa, 0xbf, | ||||
| 	0x5d, 0xf1, 0x22, 0x67, 0xc0, 0xa0, 0x70, 0x1b, 0xf5, 0xce, 0x74, 0xbb, 0xe9, 0x25, 0xde, 0x46, | ||||
| 	0x3d, 0x23, 0x1d, 0xab, 0x59, 0xb4, 0x41, 0xbb, 0xe2, 0x65, 0xae, 0x66, 0xb1, 0x1e, 0xc3, 0xe8, | ||||
| 	0x1d, 0x92, 0x76, 0xc7, 0x2b, 0x1c, 0x46, 0xcf, 0x8c, 0x14, 0x6b, 0x50, 0xdf, 0x3b, 0x20, 0xed, | ||||
| 	0xbe, 0x57, 0xc9, 0x37, 0xb5, 0x67, 0x3e, 0x8a, 0xfb, 0x60, 0xb6, 0xff, 0x70, 0xb4, 0x5b, 0x2f, | ||||
| 	0xed, 0xf4, 0xbc, 0xce, 0x98, 0xb3, 0x51, 0x9c, 0xee, 0x76, 0x59, 0x73, 0x30, 0xda, 0xb5, 0x97, | ||||
| 	0x77, 0xaa, 0x8d, 0xd6, 0x9c, 0x8b, 0x62, 0x11, 0xa0, 0x3b, 0x93, 0xec, 0xae, 0x2b, 0xe4, 0x32, | ||||
| 	0x20, 0xdc, 0x1a, 0x34, 0x92, 0xec, 0xfc, 0x55, 0xde, 0x1a, 0x44, 0xe0, 0xd6, 0xe0, 0x69, 0x64, | ||||
| 	0xa7, 0xaf, 0xf1, 0xd6, 0x60, 0x44, 0xcc, 0xc3, 0x48, 0x9c, 0x87, 0x21, 0x3e, 0x5b, 0xf5, 0x5b, | ||||
| 	0xfb, 0x8c, 0x1b, 0x19, 0xb6, 0x19, 0xfe, 0x65, 0x97, 0x60, 0x06, 0xc4, 0x11, 0xd8, 0x27, 0xa3, | ||||
| 	0xa6, 0x6c, 0xdb, 0xc8, 0x5f, 0x77, 0xb9, 0x9f, 0xe0, 0x6a, 0xb1, 0x00, 0xd0, 0x79, 0x99, 0xc6, | ||||
| 	0x28, 0x6c, 0xec, 0x6f, 0xbb, 0x9d, 0xf7, 0x7a, 0x03, 0xe9, 0x0a, 0x8a, 0xb7, 0x71, 0x8b, 0x60, | ||||
| 	0xbb, 0x2a, 0x28, 0x5e, 0xc0, 0x8f, 0xc2, 0xf0, 0x43, 0x99, 0x8a, 0xb5, 0xe7, 0xdb, 0xe8, 0xdf, | ||||
| 	0x89, 0xe6, 0xf5, 0x98, 0xb0, 0x48, 0xa5, 0x52, 0x7b, 0x7e, 0x66, 0x63, 0xff, 0x20, 0xb6, 0x04, | ||||
| 	0x10, 0x6e, 0x79, 0x99, 0x76, 0xb9, 0xef, 0x3f, 0x19, 0x66, 0x00, 0x83, 0xc6, 0xeb, 0x87, 0xe5, | ||||
| 	0x96, 0x8d, 0xfd, 0x8b, 0x83, 0xa6, 0xf5, 0xe2, 0x18, 0xd4, 0xf0, 0xb2, 0xf8, 0x3f, 0x84, 0x0d, | ||||
| 	0xfe, 0x9b, 0xe0, 0x2e, 0x81, 0xbf, 0x9c, 0xe9, 0xb6, 0x0e, 0xec, 0xc9, 0xfe, 0x87, 0x2a, 0xcd, | ||||
| 	0xeb, 0xc5, 0x22, 0x8c, 0x66, 0xba, 0xdd, 0xce, 0xe9, 0x44, 0x63, 0xc1, 0xff, 0xdd, 0x2d, 0x5f, | ||||
| 	0x72, 0x4b, 0xe6, 0xf8, 0x21, 0x98, 0x6e, 0xa9, 0xa8, 0x17, 0x3c, 0x0e, 0x2b, 0x6a, 0x45, 0xad, | ||||
| 	0x15, 0xbb, 0xe8, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0a, 0x9c, 0xec, 0xd8, 0x50, 0x13, 0x00, | ||||
| 	0x00, | ||||
| } | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/github.com/gogo/protobuf/gogoproto/gogo.proto
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/github.com/gogo/protobuf/gogoproto/gogo.proto
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -33,7 +33,6 @@ import "google/protobuf/descriptor.proto"; | ||||
|  | ||||
| option java_package = "com.google.protobuf"; | ||||
| option java_outer_classname = "GoGoProtos"; | ||||
| option go_package = "github.com/gogo/protobuf/gogoproto"; | ||||
|  | ||||
| extend google.protobuf.EnumOptions { | ||||
| 	optional bool goproto_enum_prefix = 62001; | ||||
| @@ -83,10 +82,6 @@ extend google.protobuf.FileOptions { | ||||
|     optional bool enumdecl_all = 63031; | ||||
|  | ||||
| 	optional bool goproto_registration = 63032; | ||||
| 	optional bool messagename_all = 63033; | ||||
|  | ||||
| 	optional bool goproto_sizecache_all = 63034; | ||||
| 	optional bool goproto_unkeyed_all = 63035; | ||||
| } | ||||
|  | ||||
| extend google.protobuf.MessageOptions { | ||||
| @@ -119,11 +114,6 @@ extend google.protobuf.MessageOptions { | ||||
| 	optional bool compare = 64029; | ||||
|  | ||||
| 	optional bool typedecl = 64030; | ||||
|  | ||||
| 	optional bool messagename = 64033; | ||||
|  | ||||
| 	optional bool goproto_sizecache = 64034; | ||||
| 	optional bool goproto_unkeyed = 64035; | ||||
| } | ||||
|  | ||||
| extend google.protobuf.FieldOptions { | ||||
| @@ -139,6 +129,4 @@ extend google.protobuf.FieldOptions { | ||||
|  | ||||
| 	optional bool stdtime = 65010; | ||||
| 	optional bool stdduration = 65011; | ||||
| 	optional bool wktpointer = 65012; | ||||
|  | ||||
| } | ||||
|   | ||||
							
								
								
									
										64
									
								
								vendor/github.com/gogo/protobuf/gogoproto/helper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										64
									
								
								vendor/github.com/gogo/protobuf/gogoproto/helper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -47,55 +47,6 @@ func IsStdDuration(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Stdduration, false) | ||||
| } | ||||
|  | ||||
| func IsStdDouble(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.DoubleValue" | ||||
| } | ||||
|  | ||||
| func IsStdFloat(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.FloatValue" | ||||
| } | ||||
|  | ||||
| func IsStdInt64(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.Int64Value" | ||||
| } | ||||
|  | ||||
| func IsStdUInt64(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.UInt64Value" | ||||
| } | ||||
|  | ||||
| func IsStdInt32(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.Int32Value" | ||||
| } | ||||
|  | ||||
| func IsStdUInt32(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.UInt32Value" | ||||
| } | ||||
|  | ||||
| func IsStdBool(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.BoolValue" | ||||
| } | ||||
|  | ||||
| func IsStdString(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.StringValue" | ||||
| } | ||||
|  | ||||
| func IsStdBytes(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.BytesValue" | ||||
| } | ||||
|  | ||||
| func IsStdType(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return (IsStdTime(field) || IsStdDuration(field) || | ||||
| 		IsStdDouble(field) || IsStdFloat(field) || | ||||
| 		IsStdInt64(field) || IsStdUInt64(field) || | ||||
| 		IsStdInt32(field) || IsStdUInt32(field) || | ||||
| 		IsStdBool(field) || | ||||
| 		IsStdString(field) || IsStdBytes(field)) | ||||
| } | ||||
|  | ||||
| func IsWktPtr(field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(field.Options, E_Wktpointer, false) | ||||
| } | ||||
|  | ||||
| func NeedsNilCheck(proto3 bool, field *google_protobuf.FieldDescriptorProto) bool { | ||||
| 	nullable := IsNullable(field) | ||||
| 	if field.IsMessage() || IsCustomType(field) { | ||||
| @@ -383,6 +334,9 @@ func HasExtensionsMap(file *google_protobuf.FileDescriptorProto, message *google | ||||
| } | ||||
|  | ||||
| func HasUnrecognized(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool { | ||||
| 	if IsProto3(file) { | ||||
| 		return false | ||||
| 	} | ||||
| 	return proto.GetBoolExtension(message.Options, E_GoprotoUnrecognized, proto.GetBoolExtension(file.Options, E_GoprotoUnrecognizedAll, true)) | ||||
| } | ||||
|  | ||||
| @@ -401,15 +355,3 @@ func HasCompare(file *google_protobuf.FileDescriptorProto, message *google_proto | ||||
| func RegistersGolangProto(file *google_protobuf.FileDescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(file.Options, E_GoprotoRegistration, false) | ||||
| } | ||||
|  | ||||
| func HasMessageName(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(message.Options, E_Messagename, proto.GetBoolExtension(file.Options, E_MessagenameAll, false)) | ||||
| } | ||||
|  | ||||
| func HasSizecache(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(message.Options, E_GoprotoSizecache, proto.GetBoolExtension(file.Options, E_GoprotoSizecacheAll, true)) | ||||
| } | ||||
|  | ||||
| func HasUnkeyed(file *google_protobuf.FileDescriptorProto, message *google_protobuf.DescriptorProto) bool { | ||||
| 	return proto.GetBoolExtension(message.Options, E_GoprotoUnkeyed, proto.GetBoolExtension(file.Options, E_GoprotoUnkeyedAll, true)) | ||||
| } | ||||
|   | ||||
							
								
								
									
										19
									
								
								vendor/github.com/gogo/protobuf/install-protobuf.sh
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/gogo/protobuf/install-protobuf.sh
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -7,22 +7,23 @@ die() { | ||||
|     exit 1 | ||||
| } | ||||
|  | ||||
| cd ${HOME} | ||||
|  | ||||
| case "$PROTOBUF_VERSION" in | ||||
| 2*) | ||||
|     basename=protobuf-$PROTOBUF_VERSION | ||||
|     wget https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/$basename.tar.gz | ||||
|     tar xzf $basename.tar.gz | ||||
|     cd protobuf-$PROTOBUF_VERSION | ||||
|     ./configure --prefix=${HOME} && make -j2 && make install | ||||
|     ;; | ||||
| 3*) | ||||
|     basename=protoc-$PROTOBUF_VERSION-linux-x86_64 | ||||
|     wget https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/$basename.zip | ||||
|     unzip $basename.zip | ||||
|     basename=protobuf-cpp-$PROTOBUF_VERSION | ||||
|     ;; | ||||
| *) | ||||
|     die "unknown protobuf version: $PROTOBUF_VERSION" | ||||
|     ;; | ||||
| esac | ||||
|  | ||||
| cd /home/travis | ||||
|  | ||||
| wget https://github.com/google/protobuf/releases/download/v$PROTOBUF_VERSION/$basename.tar.gz | ||||
| tar xzf $basename.tar.gz | ||||
|  | ||||
| cd protobuf-$PROTOBUF_VERSION | ||||
|  | ||||
| ./configure --prefix=/home/travis && make -j2 && make install | ||||
|   | ||||
							
								
								
									
										68
									
								
								vendor/github.com/gogo/protobuf/io/uint32.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										68
									
								
								vendor/github.com/gogo/protobuf/io/uint32.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -30,68 +30,56 @@ package io | ||||
|  | ||||
| import ( | ||||
| 	"encoding/binary" | ||||
| 	"io" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
| 	"io" | ||||
| ) | ||||
|  | ||||
| const uint32BinaryLen = 4 | ||||
|  | ||||
| func NewUint32DelimitedWriter(w io.Writer, byteOrder binary.ByteOrder) WriteCloser { | ||||
| 	return &uint32Writer{w, byteOrder, nil, make([]byte, uint32BinaryLen)} | ||||
| 	return &uint32Writer{w, byteOrder, nil} | ||||
| } | ||||
|  | ||||
| func NewSizeUint32DelimitedWriter(w io.Writer, byteOrder binary.ByteOrder, size int) WriteCloser { | ||||
| 	return &uint32Writer{w, byteOrder, make([]byte, size), make([]byte, uint32BinaryLen)} | ||||
| 	return &uint32Writer{w, byteOrder, make([]byte, size)} | ||||
| } | ||||
|  | ||||
| type uint32Writer struct { | ||||
| 	w         io.Writer | ||||
| 	byteOrder binary.ByteOrder | ||||
| 	buffer    []byte | ||||
| 	lenBuf    []byte | ||||
| } | ||||
|  | ||||
| func (this *uint32Writer) writeFallback(msg proto.Message) error { | ||||
| 	data, err := proto.Marshal(msg) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| func (this *uint32Writer) WriteMsg(msg proto.Message) (err error) { | ||||
| 	var data []byte | ||||
| 	if m, ok := msg.(marshaler); ok { | ||||
| 		n, ok := getSize(m) | ||||
| 		if !ok { | ||||
| 			data, err = proto.Marshal(msg) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		} | ||||
| 		if n >= len(this.buffer) { | ||||
| 			this.buffer = make([]byte, n) | ||||
| 		} | ||||
| 		_, err = m.MarshalTo(this.buffer) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		data = this.buffer[:n] | ||||
| 	} else { | ||||
| 		data, err = proto.Marshal(msg) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	length := uint32(len(data)) | ||||
| 	this.byteOrder.PutUint32(this.lenBuf, length) | ||||
| 	if _, err = this.w.Write(this.lenBuf); err != nil { | ||||
| 	if err = binary.Write(this.w, this.byteOrder, &length); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	_, err = this.w.Write(data) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| func (this *uint32Writer) WriteMsg(msg proto.Message) error { | ||||
| 	m, ok := msg.(marshaler) | ||||
| 	if !ok { | ||||
| 		return this.writeFallback(msg) | ||||
| 	} | ||||
|  | ||||
| 	n, ok := getSize(m) | ||||
| 	if !ok { | ||||
| 		return this.writeFallback(msg) | ||||
| 	} | ||||
|  | ||||
| 	size := n + uint32BinaryLen | ||||
| 	if size > len(this.buffer) { | ||||
| 		this.buffer = make([]byte, size) | ||||
| 	} | ||||
|  | ||||
| 	this.byteOrder.PutUint32(this.buffer, uint32(n)) | ||||
| 	if _, err := m.MarshalTo(this.buffer[uint32BinaryLen:]); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	_, err := this.w.Write(this.buffer[:size]) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| func (this *uint32Writer) Close() error { | ||||
| 	if closer, ok := this.w.(io.Closer); ok { | ||||
| 		return closer.Close() | ||||
| @@ -120,7 +108,7 @@ func (this *uint32Reader) ReadMsg(msg proto.Message) error { | ||||
| 	if length < 0 || length > this.maxSize { | ||||
| 		return io.ErrShortBuffer | ||||
| 	} | ||||
| 	if length > len(this.buf) { | ||||
| 	if length >= len(this.buf) { | ||||
| 		this.buf = make([]byte, length) | ||||
| 	} | ||||
| 	_, err := io.ReadFull(this.r, this.buf[:length]) | ||||
|   | ||||
							
								
								
									
										73
									
								
								vendor/github.com/gogo/protobuf/io/uint32_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										73
									
								
								vendor/github.com/gogo/protobuf/io/uint32_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,73 +0,0 @@ | ||||
| package io_test | ||||
|  | ||||
| import ( | ||||
| 	"encoding/binary" | ||||
| 	"io/ioutil" | ||||
| 	"math/rand" | ||||
| 	"reflect" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/test" | ||||
| 	example "github.com/gogo/protobuf/test/example" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/io" | ||||
| ) | ||||
|  | ||||
| func BenchmarkUint32DelimWriterMarshaller(b *testing.B) { | ||||
| 	w := io.NewUint32DelimitedWriter(ioutil.Discard, binary.BigEndian) | ||||
| 	r := rand.New(rand.NewSource(time.Now().UnixNano())) | ||||
| 	msg := example.NewPopulatedA(r, true) | ||||
|  | ||||
| 	for i := 0; i < b.N; i++ { | ||||
| 		if err := w.WriteMsg(msg); err != nil { | ||||
| 			b.Fatal(err) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func BenchmarkUint32DelimWriterFallback(b *testing.B) { | ||||
| 	w := io.NewUint32DelimitedWriter(ioutil.Discard, binary.BigEndian) | ||||
| 	r := rand.New(rand.NewSource(time.Now().UnixNano())) | ||||
| 	msg := test.NewPopulatedNinOptNative(r, true) | ||||
|  | ||||
| 	for i := 0; i < b.N; i++ { | ||||
| 		if err := w.WriteMsg(msg); err != nil { | ||||
| 			b.Fatal(err) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Writing the same size messaged twice should not cause another | ||||
| // reader buffer allocation | ||||
| func TestUint32SameSizeNoAlloc(t *testing.T) { | ||||
| 	buf := newBuffer() | ||||
| 	writer := io.NewUint32DelimitedWriter(buf, binary.LittleEndian) | ||||
| 	reader := io.NewUint32DelimitedReader(buf, binary.LittleEndian, 1024*1024) | ||||
|  | ||||
| 	err := writer.WriteMsg(&test.NinOptNative{Field15: []byte("numbercatinvention")}) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	err = writer.WriteMsg(&test.NinOptNative{Field15: []byte("fastenselectionsky")}) | ||||
| 	if err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if err := writer.Close(); err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
|  | ||||
| 	msg := &test.NinOptNative{} | ||||
| 	if err := reader.ReadMsg(msg); err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	firstRead := reflect.ValueOf(reader).Elem().FieldByName("buf").Pointer() | ||||
| 	if err := reader.ReadMsg(msg); err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	secondRead := reflect.ValueOf(reader).Elem().FieldByName("buf").Pointer() | ||||
|  | ||||
| 	if firstRead != secondRead { | ||||
| 		t.Fatalf("reader buf byte slice pointer did not stay the same after second same size read (%d != %d).", firstRead, secondRead) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										29
									
								
								vendor/github.com/gogo/protobuf/io/varint.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										29
									
								
								vendor/github.com/gogo/protobuf/io/varint.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -42,7 +42,7 @@ var ( | ||||
| ) | ||||
|  | ||||
| func NewDelimitedWriter(w io.Writer) WriteCloser { | ||||
| 	return &varintWriter{w, make([]byte, binary.MaxVarintLen64), nil} | ||||
| 	return &varintWriter{w, make([]byte, 10), nil} | ||||
| } | ||||
|  | ||||
| type varintWriter struct { | ||||
| @@ -55,24 +55,25 @@ func (this *varintWriter) WriteMsg(msg proto.Message) (err error) { | ||||
| 	var data []byte | ||||
| 	if m, ok := msg.(marshaler); ok { | ||||
| 		n, ok := getSize(m) | ||||
| 		if ok { | ||||
| 			if n+binary.MaxVarintLen64 >= len(this.buffer) { | ||||
| 				this.buffer = make([]byte, n+binary.MaxVarintLen64) | ||||
| 			} | ||||
| 			lenOff := binary.PutUvarint(this.buffer, uint64(n)) | ||||
| 			_, err = m.MarshalTo(this.buffer[lenOff:]) | ||||
| 		if !ok { | ||||
| 			data, err = proto.Marshal(msg) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 			_, err = this.w.Write(this.buffer[:lenOff+n]) | ||||
| 		} | ||||
| 		if n >= len(this.buffer) { | ||||
| 			this.buffer = make([]byte, n) | ||||
| 		} | ||||
| 		_, err = m.MarshalTo(this.buffer) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		data = this.buffer[:n] | ||||
| 	} else { | ||||
| 		data, err = proto.Marshal(msg) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// fallback | ||||
| 	data, err = proto.Marshal(msg) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	length := uint64(len(data)) | ||||
| 	n := binary.PutUvarint(this.lenBuf, length) | ||||
|   | ||||
							
								
								
									
										638
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										638
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -44,7 +44,6 @@ import ( | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"math" | ||||
| 	"reflect" | ||||
| 	"sort" | ||||
| 	"strconv" | ||||
| @@ -55,9 +54,6 @@ import ( | ||||
| 	"github.com/gogo/protobuf/types" | ||||
| ) | ||||
|  | ||||
| const secondInNanos = int64(time.Second / time.Nanosecond) | ||||
| const maxSecondsInDuration = 315576000000 | ||||
|  | ||||
| // Marshaler is a configurable object for converting between | ||||
| // protocol buffer objects and a JSON representation for them. | ||||
| type Marshaler struct { | ||||
| @@ -75,65 +71,10 @@ type Marshaler struct { | ||||
|  | ||||
| 	// Whether to use the original (.proto) name for fields. | ||||
| 	OrigName bool | ||||
|  | ||||
| 	// A custom URL resolver to use when marshaling Any messages to JSON. | ||||
| 	// If unset, the default resolution strategy is to extract the | ||||
| 	// fully-qualified type name from the type URL and pass that to | ||||
| 	// proto.MessageType(string). | ||||
| 	AnyResolver AnyResolver | ||||
| } | ||||
|  | ||||
| // AnyResolver takes a type URL, present in an Any message, and resolves it into | ||||
| // an instance of the associated message. | ||||
| type AnyResolver interface { | ||||
| 	Resolve(typeUrl string) (proto.Message, error) | ||||
| } | ||||
|  | ||||
| func defaultResolveAny(typeUrl string) (proto.Message, error) { | ||||
| 	// Only the part of typeUrl after the last slash is relevant. | ||||
| 	mname := typeUrl | ||||
| 	if slash := strings.LastIndex(mname, "/"); slash >= 0 { | ||||
| 		mname = mname[slash+1:] | ||||
| 	} | ||||
| 	mt := proto.MessageType(mname) | ||||
| 	if mt == nil { | ||||
| 		return nil, fmt.Errorf("unknown message type %q", mname) | ||||
| 	} | ||||
| 	return reflect.New(mt.Elem()).Interface().(proto.Message), nil | ||||
| } | ||||
|  | ||||
| // JSONPBMarshaler is implemented by protobuf messages that customize the | ||||
| // way they are marshaled to JSON. Messages that implement this should | ||||
| // also implement JSONPBUnmarshaler so that the custom format can be | ||||
| // parsed. | ||||
| // | ||||
| // The JSON marshaling must follow the proto to JSON specification: | ||||
| //	https://developers.google.com/protocol-buffers/docs/proto3#json | ||||
| type JSONPBMarshaler interface { | ||||
| 	MarshalJSONPB(*Marshaler) ([]byte, error) | ||||
| } | ||||
|  | ||||
| // JSONPBUnmarshaler is implemented by protobuf messages that customize | ||||
| // the way they are unmarshaled from JSON. Messages that implement this | ||||
| // should also implement JSONPBMarshaler so that the custom format can be | ||||
| // produced. | ||||
| // | ||||
| // The JSON unmarshaling must follow the JSON to proto specification: | ||||
| //	https://developers.google.com/protocol-buffers/docs/proto3#json | ||||
| type JSONPBUnmarshaler interface { | ||||
| 	UnmarshalJSONPB(*Unmarshaler, []byte) error | ||||
| } | ||||
|  | ||||
| // Marshal marshals a protocol buffer into JSON. | ||||
| func (m *Marshaler) Marshal(out io.Writer, pb proto.Message) error { | ||||
| 	v := reflect.ValueOf(pb) | ||||
| 	if pb == nil || (v.Kind() == reflect.Ptr && v.IsNil()) { | ||||
| 		return errors.New("Marshal called with nil") | ||||
| 	} | ||||
| 	// Check for unset required fields first. | ||||
| 	if err := checkRequiredFields(pb); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	writer := &errWriter{writer: out} | ||||
| 	return m.marshalObject(writer, pb, "", "") | ||||
| } | ||||
| @@ -149,12 +90,6 @@ func (m *Marshaler) MarshalToString(pb proto.Message) (string, error) { | ||||
|  | ||||
| type int32Slice []int32 | ||||
|  | ||||
| var nonFinite = map[string]float64{ | ||||
| 	`"NaN"`:       math.NaN(), | ||||
| 	`"Infinity"`:  math.Inf(1), | ||||
| 	`"-Infinity"`: math.Inf(-1), | ||||
| } | ||||
|  | ||||
| // For sorting extensions ids to ensure stable output. | ||||
| func (s int32Slice) Len() int           { return len(s) } | ||||
| func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] } | ||||
| @@ -164,43 +99,8 @@ type isWkt interface { | ||||
| 	XXX_WellKnownType() string | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	wktType     = reflect.TypeOf((*isWkt)(nil)).Elem() | ||||
| 	messageType = reflect.TypeOf((*proto.Message)(nil)).Elem() | ||||
| ) | ||||
|  | ||||
| // marshalObject writes a struct to the Writer. | ||||
| func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeURL string) error { | ||||
| 	if jsm, ok := v.(JSONPBMarshaler); ok { | ||||
| 		b, err := jsm.MarshalJSONPB(m) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		if typeURL != "" { | ||||
| 			// we are marshaling this object to an Any type | ||||
| 			var js map[string]*json.RawMessage | ||||
| 			if err = json.Unmarshal(b, &js); err != nil { | ||||
| 				return fmt.Errorf("type %T produced invalid JSON: %v", v, err) | ||||
| 			} | ||||
| 			turl, err := json.Marshal(typeURL) | ||||
| 			if err != nil { | ||||
| 				return fmt.Errorf("failed to marshal type URL %q to JSON: %v", typeURL, err) | ||||
| 			} | ||||
| 			js["@type"] = (*json.RawMessage)(&turl) | ||||
| 			if m.Indent != "" { | ||||
| 				b, err = json.MarshalIndent(js, indent, m.Indent) | ||||
| 			} else { | ||||
| 				b, err = json.Marshal(js) | ||||
| 			} | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		out.write(string(b)) | ||||
| 		return out.err | ||||
| 	} | ||||
|  | ||||
| 	s := reflect.ValueOf(v).Elem() | ||||
|  | ||||
| 	// Handle well-known types. | ||||
| @@ -216,50 +116,30 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU | ||||
| 			// Any is a bit more involved. | ||||
| 			return m.marshalAny(out, v, indent) | ||||
| 		case "Duration": | ||||
| 			// "Generated output always contains 3, 6, or 9 fractional digits, | ||||
| 			//  depending on required precision." | ||||
| 			s, ns := s.Field(0).Int(), s.Field(1).Int() | ||||
| 			if s < -maxSecondsInDuration || s > maxSecondsInDuration { | ||||
| 				return fmt.Errorf("seconds out of range %v", s) | ||||
| 			} | ||||
| 			if ns <= -secondInNanos || ns >= secondInNanos { | ||||
| 				return fmt.Errorf("ns out of range (%v, %v)", -secondInNanos, secondInNanos) | ||||
| 			} | ||||
| 			if (s > 0 && ns < 0) || (s < 0 && ns > 0) { | ||||
| 				return errors.New("signs of seconds and nanos do not match") | ||||
| 			} | ||||
| 			// Generated output always contains 0, 3, 6, or 9 fractional digits, | ||||
| 			// depending on required precision, followed by the suffix "s". | ||||
| 			f := "%d.%09d" | ||||
| 			if ns < 0 { | ||||
| 				ns = -ns | ||||
| 				if s == 0 { | ||||
| 					f = "-%d.%09d" | ||||
| 				} | ||||
| 			} | ||||
| 			x := fmt.Sprintf(f, s, ns) | ||||
| 			d := time.Duration(s)*time.Second + time.Duration(ns)*time.Nanosecond | ||||
| 			x := fmt.Sprintf("%.9f", d.Seconds()) | ||||
| 			x = strings.TrimSuffix(x, "000") | ||||
| 			x = strings.TrimSuffix(x, "000") | ||||
| 			x = strings.TrimSuffix(x, ".000") | ||||
| 			out.write(`"`) | ||||
| 			out.write(x) | ||||
| 			out.write(`s"`) | ||||
| 			return out.err | ||||
| 		case "Struct", "ListValue": | ||||
| 			// Let marshalValue handle the `Struct.fields` map or the `ListValue.values` slice. | ||||
| 		case "Struct": | ||||
| 			// Let marshalValue handle the `fields` map. | ||||
| 			// TODO: pass the correct Properties if needed. | ||||
| 			return m.marshalValue(out, &proto.Properties{}, s.Field(0), indent) | ||||
| 		case "Timestamp": | ||||
| 			// "RFC 3339, where generated output will always be Z-normalized | ||||
| 			//  and uses 0, 3, 6 or 9 fractional digits." | ||||
| 			//  and uses 3, 6 or 9 fractional digits." | ||||
| 			s, ns := s.Field(0).Int(), s.Field(1).Int() | ||||
| 			if ns < 0 || ns >= secondInNanos { | ||||
| 				return fmt.Errorf("ns out of range [0, %v)", secondInNanos) | ||||
| 			} | ||||
| 			t := time.Unix(s, ns).UTC() | ||||
| 			// time.RFC3339Nano isn't exactly right (we need to get 3/6/9 fractional digits). | ||||
| 			x := t.Format("2006-01-02T15:04:05.000000000") | ||||
| 			x = strings.TrimSuffix(x, "000") | ||||
| 			x = strings.TrimSuffix(x, "000") | ||||
| 			x = strings.TrimSuffix(x, ".000") | ||||
| 			out.write(`"`) | ||||
| 			out.write(x) | ||||
| 			out.write(`Z"`) | ||||
| @@ -299,14 +179,9 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		//this is not a protobuf field | ||||
| 		if valueField.Tag.Get("protobuf") == "" && valueField.Tag.Get("protobuf_oneof") == "" { | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		// IsNil will panic on most value kinds. | ||||
| 		switch value.Kind() { | ||||
| 		case reflect.Chan, reflect.Func, reflect.Interface: | ||||
| 		case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: | ||||
| 			if value.IsNil() { | ||||
| 				continue | ||||
| 			} | ||||
| @@ -334,10 +209,6 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU | ||||
| 				if value.Len() == 0 { | ||||
| 					continue | ||||
| 				} | ||||
| 			case reflect.Map, reflect.Ptr, reflect.Slice: | ||||
| 				if value.IsNil() { | ||||
| 					continue | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| @@ -353,9 +224,9 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU | ||||
| 			m.writeSep(out) | ||||
| 		} | ||||
| 		// If the map value is a cast type, it may not implement proto.Message, therefore | ||||
| 		// allow the struct tag to declare the underlying message type. Change the property | ||||
| 		// of the child types, use CustomType as a passer. CastType currently property is | ||||
| 		// not used in json encoding. | ||||
| 		// allow the struct tag to declare the underlying message type. Instead of changing | ||||
| 		// the signatures of the child types (and because prop.mvalue is not public), use | ||||
| 		// CustomType as a passer. | ||||
| 		if value.Kind() == reflect.Map { | ||||
| 			if tag := valueField.Tag.Get("protobuf"); tag != "" { | ||||
| 				for _, v := range strings.Split(tag, ",") { | ||||
| @@ -363,7 +234,7 @@ func (m *Marshaler) marshalObject(out *errWriter, v proto.Message, indent, typeU | ||||
| 						continue | ||||
| 					} | ||||
| 					v = strings.TrimPrefix(v, "castvaluetype=") | ||||
| 					prop.MapValProp.CustomType = v | ||||
| 					prop.CustomType = v | ||||
| 					break | ||||
| 				} | ||||
| 			} | ||||
| @@ -436,17 +307,16 @@ func (m *Marshaler) marshalAny(out *errWriter, any proto.Message, indent string) | ||||
| 	turl := v.Field(0).String() | ||||
| 	val := v.Field(1).Bytes() | ||||
|  | ||||
| 	var msg proto.Message | ||||
| 	var err error | ||||
| 	if m.AnyResolver != nil { | ||||
| 		msg, err = m.AnyResolver.Resolve(turl) | ||||
| 	} else { | ||||
| 		msg, err = defaultResolveAny(turl) | ||||
| 	// Only the part of type_url after the last slash is relevant. | ||||
| 	mname := turl | ||||
| 	if slash := strings.LastIndex(mname, "/"); slash >= 0 { | ||||
| 		mname = mname[slash+1:] | ||||
| 	} | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	mt := proto.MessageType(mname) | ||||
| 	if mt == nil { | ||||
| 		return fmt.Errorf("unknown message type %q", mname) | ||||
| 	} | ||||
|  | ||||
| 	msg := reflect.New(mt.Elem()).Interface().(proto.Message) | ||||
| 	if err := proto.Unmarshal(val, msg); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -521,12 +391,6 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle | ||||
|  | ||||
| 	v = reflect.Indirect(v) | ||||
|  | ||||
| 	// Handle nil pointer | ||||
| 	if v.Kind() == reflect.Invalid { | ||||
| 		out.write("null") | ||||
| 		return out.err | ||||
| 	} | ||||
|  | ||||
| 	// Handle repeated elements. | ||||
| 	if v.Kind() == reflect.Slice && v.Type().Elem().Kind() != reflect.Uint8 { | ||||
| 		out.write("[") | ||||
| @@ -556,8 +420,7 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle | ||||
|  | ||||
| 	// Handle well-known types. | ||||
| 	// Most are handled up in marshalObject (because 99% are messages). | ||||
| 	if v.Type().Implements(wktType) { | ||||
| 		wkt := v.Interface().(isWkt) | ||||
| 	if wkt, ok := v.Interface().(isWkt); ok { | ||||
| 		switch wkt.XXX_WellKnownType() { | ||||
| 		case "NullValue": | ||||
| 			out.write("null") | ||||
| @@ -674,7 +537,6 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle | ||||
| 				out.write(m.Indent) | ||||
| 			} | ||||
|  | ||||
| 			// TODO handle map key prop properly | ||||
| 			b, err := json.Marshal(k.Interface()) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| @@ -696,11 +558,7 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle | ||||
| 				out.write(` `) | ||||
| 			} | ||||
|  | ||||
| 			vprop := prop | ||||
| 			if prop != nil && prop.MapValProp != nil { | ||||
| 				vprop = prop.MapValProp | ||||
| 			} | ||||
| 			if err := m.marshalValue(out, vprop, v.MapIndex(k), indent+m.Indent); err != nil { | ||||
| 			if err := m.marshalValue(out, prop, v.MapIndex(k), indent+m.Indent); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		} | ||||
| @@ -713,24 +571,6 @@ func (m *Marshaler) marshalValue(out *errWriter, prop *proto.Properties, v refle | ||||
| 		return out.err | ||||
| 	} | ||||
|  | ||||
| 	// Handle non-finite floats, e.g. NaN, Infinity and -Infinity. | ||||
| 	if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 { | ||||
| 		f := v.Float() | ||||
| 		var sval string | ||||
| 		switch { | ||||
| 		case math.IsInf(f, 1): | ||||
| 			sval = `"Infinity"` | ||||
| 		case math.IsInf(f, -1): | ||||
| 			sval = `"-Infinity"` | ||||
| 		case math.IsNaN(f): | ||||
| 			sval = `"NaN"` | ||||
| 		} | ||||
| 		if sval != "" { | ||||
| 			out.write(sval) | ||||
| 			return out.err | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Default handling defers to the encoding/json library. | ||||
| 	b, err := json.Marshal(v.Interface()) | ||||
| 	if err != nil { | ||||
| @@ -753,12 +593,6 @@ type Unmarshaler struct { | ||||
| 	// Whether to allow messages to contain unknown fields, as opposed to | ||||
| 	// failing to unmarshal. | ||||
| 	AllowUnknownFields bool | ||||
|  | ||||
| 	// A custom URL resolver to use when unmarshaling Any messages from JSON. | ||||
| 	// If unset, the default resolution strategy is to extract the | ||||
| 	// fully-qualified type name from the type URL and pass that to | ||||
| 	// proto.MessageType(string). | ||||
| 	AnyResolver AnyResolver | ||||
| } | ||||
|  | ||||
| // UnmarshalNext unmarshals the next protocol buffer from a JSON object stream. | ||||
| @@ -769,10 +603,7 @@ func (u *Unmarshaler) UnmarshalNext(dec *json.Decoder, pb proto.Message) error { | ||||
| 	if err := dec.Decode(&inputValue); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	if err := u.unmarshalValue(reflect.ValueOf(pb).Elem(), inputValue, nil); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	return checkRequiredFields(pb) | ||||
| 	return u.unmarshalValue(reflect.ValueOf(pb).Elem(), inputValue, nil) | ||||
| } | ||||
|  | ||||
| // Unmarshal unmarshals a JSON object stream into a protocol | ||||
| @@ -811,97 +642,38 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe | ||||
|  | ||||
| 	// Allocate memory for pointer fields. | ||||
| 	if targetType.Kind() == reflect.Ptr { | ||||
| 		// If input value is "null" and target is a pointer type, then the field should be treated as not set | ||||
| 		// UNLESS the target is structpb.Value, in which case it should be set to structpb.NullValue. | ||||
| 		_, isJSONPBUnmarshaler := target.Interface().(JSONPBUnmarshaler) | ||||
| 		if string(inputValue) == "null" && targetType != reflect.TypeOf(&types.Value{}) && !isJSONPBUnmarshaler { | ||||
| 			return nil | ||||
| 		} | ||||
| 		target.Set(reflect.New(targetType.Elem())) | ||||
|  | ||||
| 		return u.unmarshalValue(target.Elem(), inputValue, prop) | ||||
| 	} | ||||
|  | ||||
| 	if jsu, ok := target.Addr().Interface().(JSONPBUnmarshaler); ok { | ||||
| 		return jsu.UnmarshalJSONPB(u, []byte(inputValue)) | ||||
| 	} | ||||
|  | ||||
| 	// Handle well-known types that are not pointers. | ||||
| 	if w, ok := target.Addr().Interface().(isWkt); ok { | ||||
| 		switch w.XXX_WellKnownType() { | ||||
| 	// Handle well-known types. | ||||
| 	if wkt, ok := target.Addr().Interface().(isWkt); ok { | ||||
| 		switch wkt.XXX_WellKnownType() { | ||||
| 		case "DoubleValue", "FloatValue", "Int64Value", "UInt64Value", | ||||
| 			"Int32Value", "UInt32Value", "BoolValue", "StringValue", "BytesValue": | ||||
| 			// "Wrappers use the same representation in JSON | ||||
| 			//  as the wrapped primitive type, except that null is allowed." | ||||
| 			// encoding/json will turn JSON `null` into Go `nil`, | ||||
| 			// so we don't have to do any extra work. | ||||
| 			return u.unmarshalValue(target.Field(0), inputValue, prop) | ||||
| 		case "Any": | ||||
| 			// Use json.RawMessage pointer type instead of value to support pre-1.8 version. | ||||
| 			// 1.8 changed RawMessage.MarshalJSON from pointer type to value type, see | ||||
| 			// https://github.com/golang/go/issues/14493 | ||||
| 			var jsonFields map[string]*json.RawMessage | ||||
| 			if err := json.Unmarshal(inputValue, &jsonFields); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
|  | ||||
| 			val, ok := jsonFields["@type"] | ||||
| 			if !ok || val == nil { | ||||
| 				return errors.New("Any JSON doesn't have '@type'") | ||||
| 			} | ||||
|  | ||||
| 			var turl string | ||||
| 			if err := json.Unmarshal([]byte(*val), &turl); err != nil { | ||||
| 				return fmt.Errorf("can't unmarshal Any's '@type': %q", *val) | ||||
| 			} | ||||
| 			target.Field(0).SetString(turl) | ||||
|  | ||||
| 			var m proto.Message | ||||
| 			var err error | ||||
| 			if u.AnyResolver != nil { | ||||
| 				m, err = u.AnyResolver.Resolve(turl) | ||||
| 			} else { | ||||
| 				m, err = defaultResolveAny(turl) | ||||
| 			} | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
|  | ||||
| 			if _, ok := m.(isWkt); ok { | ||||
| 				val, ok := jsonFields["value"] | ||||
| 				if !ok { | ||||
| 					return errors.New("Any JSON doesn't have 'value'") | ||||
| 				} | ||||
|  | ||||
| 				if err = u.unmarshalValue(reflect.ValueOf(m).Elem(), *val, nil); err != nil { | ||||
| 					return fmt.Errorf("can't unmarshal Any nested proto %T: %v", m, err) | ||||
| 				} | ||||
| 			} else { | ||||
| 				delete(jsonFields, "@type") | ||||
| 				nestedProto, uerr := json.Marshal(jsonFields) | ||||
| 				if uerr != nil { | ||||
| 					return fmt.Errorf("can't generate JSON for Any's nested proto to be unmarshaled: %v", uerr) | ||||
| 				} | ||||
|  | ||||
| 				if err = u.unmarshalValue(reflect.ValueOf(m).Elem(), nestedProto, nil); err != nil { | ||||
| 					return fmt.Errorf("can't unmarshal Any nested proto %T: %v", m, err) | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			b, err := proto.Marshal(m) | ||||
| 			if err != nil { | ||||
| 				return fmt.Errorf("can't marshal proto %T into Any.Value: %v", m, err) | ||||
| 			} | ||||
| 			target.Field(1).SetBytes(b) | ||||
|  | ||||
| 			return nil | ||||
| 			return fmt.Errorf("unmarshaling Any not supported yet") | ||||
| 		case "Duration": | ||||
| 			unq, err := unquote(string(inputValue)) | ||||
| 			ivStr := string(inputValue) | ||||
| 			if ivStr == "null" { | ||||
| 				target.Field(0).SetInt(0) | ||||
| 				target.Field(1).SetInt(0) | ||||
| 				return nil | ||||
| 			} | ||||
|  | ||||
| 			unq, err := strconv.Unquote(ivStr) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
|  | ||||
| 			d, err := time.ParseDuration(unq) | ||||
| 			if err != nil { | ||||
| 				return fmt.Errorf("bad Duration: %v", err) | ||||
| 			} | ||||
|  | ||||
| 			ns := d.Nanoseconds() | ||||
| 			s := ns / 1e9 | ||||
| 			ns %= 1e9 | ||||
| @@ -909,68 +681,24 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe | ||||
| 			target.Field(1).SetInt(ns) | ||||
| 			return nil | ||||
| 		case "Timestamp": | ||||
| 			unq, err := unquote(string(inputValue)) | ||||
| 			ivStr := string(inputValue) | ||||
| 			if ivStr == "null" { | ||||
| 				target.Field(0).SetInt(0) | ||||
| 				target.Field(1).SetInt(0) | ||||
| 				return nil | ||||
| 			} | ||||
|  | ||||
| 			unq, err := strconv.Unquote(ivStr) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
|  | ||||
| 			t, err := time.Parse(time.RFC3339Nano, unq) | ||||
| 			if err != nil { | ||||
| 				return fmt.Errorf("bad Timestamp: %v", err) | ||||
| 			} | ||||
|  | ||||
| 			target.Field(0).SetInt(t.Unix()) | ||||
| 			target.Field(0).SetInt(int64(t.Unix())) | ||||
| 			target.Field(1).SetInt(int64(t.Nanosecond())) | ||||
| 			return nil | ||||
| 		case "Struct": | ||||
| 			var m map[string]json.RawMessage | ||||
| 			if err := json.Unmarshal(inputValue, &m); err != nil { | ||||
| 				return fmt.Errorf("bad StructValue: %v", err) | ||||
| 			} | ||||
| 			target.Field(0).Set(reflect.ValueOf(map[string]*types.Value{})) | ||||
| 			for k, jv := range m { | ||||
| 				pv := &types.Value{} | ||||
| 				if err := u.unmarshalValue(reflect.ValueOf(pv).Elem(), jv, prop); err != nil { | ||||
| 					return fmt.Errorf("bad value in StructValue for key %q: %v", k, err) | ||||
| 				} | ||||
| 				target.Field(0).SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(pv)) | ||||
| 			} | ||||
| 			return nil | ||||
| 		case "ListValue": | ||||
| 			var s []json.RawMessage | ||||
| 			if err := json.Unmarshal(inputValue, &s); err != nil { | ||||
| 				return fmt.Errorf("bad ListValue: %v", err) | ||||
| 			} | ||||
|  | ||||
| 			target.Field(0).Set(reflect.ValueOf(make([]*types.Value, len(s)))) | ||||
| 			for i, sv := range s { | ||||
| 				if err := u.unmarshalValue(target.Field(0).Index(i), sv, prop); err != nil { | ||||
| 					return err | ||||
| 				} | ||||
| 			} | ||||
| 			return nil | ||||
| 		case "Value": | ||||
| 			ivStr := string(inputValue) | ||||
| 			if ivStr == "null" { | ||||
| 				target.Field(0).Set(reflect.ValueOf(&types.Value_NullValue{})) | ||||
| 			} else if v, err := strconv.ParseFloat(ivStr, 0); err == nil { | ||||
| 				target.Field(0).Set(reflect.ValueOf(&types.Value_NumberValue{NumberValue: v})) | ||||
| 			} else if v, err := unquote(ivStr); err == nil { | ||||
| 				target.Field(0).Set(reflect.ValueOf(&types.Value_StringValue{StringValue: v})) | ||||
| 			} else if v, err := strconv.ParseBool(ivStr); err == nil { | ||||
| 				target.Field(0).Set(reflect.ValueOf(&types.Value_BoolValue{BoolValue: v})) | ||||
| 			} else if err := json.Unmarshal(inputValue, &[]json.RawMessage{}); err == nil { | ||||
| 				lv := &types.ListValue{} | ||||
| 				target.Field(0).Set(reflect.ValueOf(&types.Value_ListValue{ListValue: lv})) | ||||
| 				return u.unmarshalValue(reflect.ValueOf(lv).Elem(), inputValue, prop) | ||||
| 			} else if err := json.Unmarshal(inputValue, &map[string]json.RawMessage{}); err == nil { | ||||
| 				sv := &types.Struct{} | ||||
| 				target.Field(0).Set(reflect.ValueOf(&types.Value_StructValue{StructValue: sv})) | ||||
| 				return u.unmarshalValue(reflect.ValueOf(sv).Elem(), inputValue, prop) | ||||
| 			} else { | ||||
| 				return fmt.Errorf("unrecognized type for Value %q", ivStr) | ||||
| 			} | ||||
| 			return nil | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -1017,23 +745,20 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe | ||||
| 			target.Set(reflect.New(targetType.Elem())) | ||||
| 			target = target.Elem() | ||||
| 		} | ||||
| 		if targetType.Kind() != reflect.Int32 { | ||||
| 			return fmt.Errorf("invalid target %q for enum %s", targetType.Kind(), prop.Enum) | ||||
| 		} | ||||
| 		target.SetInt(int64(n)) | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	if prop != nil && len(prop.CustomType) > 0 && target.CanAddr() { | ||||
| 		if m, ok := target.Addr().Interface().(interface { | ||||
| 			UnmarshalJSON([]byte) error | ||||
| 		}); ok { | ||||
| 			return json.Unmarshal(inputValue, m) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Handle nested messages. | ||||
| 	if targetType.Kind() == reflect.Struct { | ||||
| 		if target.CanAddr() { | ||||
| 			if m, ok := target.Addr().Interface().(interface { | ||||
| 				UnmarshalJSON([]byte) error | ||||
| 			}); ok { | ||||
| 				return json.Unmarshal(inputValue, m) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		var jsonFields map[string]json.RawMessage | ||||
| 		if err := json.Unmarshal(inputValue, &jsonFields); err != nil { | ||||
| 			return err | ||||
| @@ -1090,26 +815,6 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		// Handle proto2 extensions. | ||||
| 		if len(jsonFields) > 0 { | ||||
| 			if ep, ok := target.Addr().Interface().(proto.Message); ok { | ||||
| 				for _, ext := range proto.RegisteredExtensions(ep) { | ||||
| 					name := fmt.Sprintf("[%s]", ext.Name) | ||||
| 					raw, ok := jsonFields[name] | ||||
| 					if !ok { | ||||
| 						continue | ||||
| 					} | ||||
| 					delete(jsonFields, name) | ||||
| 					nv := reflect.New(reflect.TypeOf(ext.ExtensionType).Elem()) | ||||
| 					if err := u.unmarshalValue(nv.Elem(), raw, nil); err != nil { | ||||
| 						return err | ||||
| 					} | ||||
| 					if err := proto.SetExtension(ep, ext, nv.Interface()); err != nil { | ||||
| 						return err | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		if !u.AllowUnknownFields && len(jsonFields) > 0 { | ||||
| 			// Pick any field to be the scapegoat. | ||||
| 			var f string | ||||
| @@ -1153,13 +858,11 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe | ||||
| 		if err := json.Unmarshal(inputValue, &slc); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		if slc != nil { | ||||
| 			l := len(slc) | ||||
| 			target.Set(reflect.MakeSlice(targetType, l, l)) | ||||
| 			for i := 0; i < l; i++ { | ||||
| 				if err := u.unmarshalValue(target.Index(i), slc[i], prop); err != nil { | ||||
| 					return err | ||||
| 				} | ||||
| 		len := len(slc) | ||||
| 		target.Set(reflect.MakeSlice(targetType, len, len)) | ||||
| 		for i := 0; i < len; i++ { | ||||
| 			if err := u.unmarshalValue(target.Index(i), slc[i], prop); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		} | ||||
| 		return nil | ||||
| @@ -1171,58 +874,44 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe | ||||
| 		if err := json.Unmarshal(inputValue, &mp); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		if mp != nil { | ||||
| 			target.Set(reflect.MakeMap(targetType)) | ||||
| 			for ks, raw := range mp { | ||||
| 				// Unmarshal map key. The core json library already decoded the key into a | ||||
| 				// string, so we handle that specially. Other types were quoted post-serialization. | ||||
| 				var k reflect.Value | ||||
| 				if targetType.Key().Kind() == reflect.String { | ||||
| 					k = reflect.ValueOf(ks) | ||||
| 				} else { | ||||
| 					k = reflect.New(targetType.Key()).Elem() | ||||
| 					var kprop *proto.Properties | ||||
| 					if prop != nil && prop.MapKeyProp != nil { | ||||
| 						kprop = prop.MapKeyProp | ||||
| 					} | ||||
| 					if err := u.unmarshalValue(k, json.RawMessage(ks), kprop); err != nil { | ||||
| 						return err | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				if !k.Type().AssignableTo(targetType.Key()) { | ||||
| 					k = k.Convert(targetType.Key()) | ||||
| 				} | ||||
|  | ||||
| 				// Unmarshal map value. | ||||
| 				v := reflect.New(targetType.Elem()).Elem() | ||||
| 				var vprop *proto.Properties | ||||
| 				if prop != nil && prop.MapValProp != nil { | ||||
| 					vprop = prop.MapValProp | ||||
| 				} | ||||
| 				if err := u.unmarshalValue(v, raw, vprop); err != nil { | ||||
| 		target.Set(reflect.MakeMap(targetType)) | ||||
| 		var keyprop, valprop *proto.Properties | ||||
| 		if prop != nil { | ||||
| 			// These could still be nil if the protobuf metadata is broken somehow. | ||||
| 			// TODO: This won't work because the fields are unexported. | ||||
| 			// We should probably just reparse them. | ||||
| 			//keyprop, valprop = prop.mkeyprop, prop.mvalprop | ||||
| 		} | ||||
| 		for ks, raw := range mp { | ||||
| 			// Unmarshal map key. The core json library already decoded the key into a | ||||
| 			// string, so we handle that specially. Other types were quoted post-serialization. | ||||
| 			var k reflect.Value | ||||
| 			if targetType.Key().Kind() == reflect.String { | ||||
| 				k = reflect.ValueOf(ks) | ||||
| 			} else { | ||||
| 				k = reflect.New(targetType.Key()).Elem() | ||||
| 				if err := u.unmarshalValue(k, json.RawMessage(ks), keyprop); err != nil { | ||||
| 					return err | ||||
| 				} | ||||
| 				target.SetMapIndex(k, v) | ||||
| 			} | ||||
|  | ||||
| 			if !k.Type().AssignableTo(targetType.Key()) { | ||||
| 				k = k.Convert(targetType.Key()) | ||||
| 			} | ||||
|  | ||||
| 			// Unmarshal map value. | ||||
| 			v := reflect.New(targetType.Elem()).Elem() | ||||
| 			if err := u.unmarshalValue(v, raw, valprop); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 			target.SetMapIndex(k, v) | ||||
| 		} | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	// Non-finite numbers can be encoded as strings. | ||||
| 	isFloat := targetType.Kind() == reflect.Float32 || targetType.Kind() == reflect.Float64 | ||||
| 	if isFloat { | ||||
| 		if num, ok := nonFinite[string(inputValue)]; ok { | ||||
| 			target.SetFloat(num) | ||||
| 			return nil | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// integers & floats can be encoded as strings. In this case we drop | ||||
| 	// 64-bit integers can be encoded as strings. In this case we drop | ||||
| 	// the quotes and proceed as normal. | ||||
| 	isNum := targetType.Kind() == reflect.Int64 || targetType.Kind() == reflect.Uint64 || | ||||
| 		targetType.Kind() == reflect.Int32 || targetType.Kind() == reflect.Uint32 || | ||||
| 		targetType.Kind() == reflect.Float32 || targetType.Kind() == reflect.Float64 | ||||
| 	isNum := targetType.Kind() == reflect.Int64 || targetType.Kind() == reflect.Uint64 | ||||
| 	if isNum && strings.HasPrefix(string(inputValue), `"`) { | ||||
| 		inputValue = inputValue[1 : len(inputValue)-1] | ||||
| 	} | ||||
| @@ -1231,12 +920,6 @@ func (u *Unmarshaler) unmarshalValue(target reflect.Value, inputValue json.RawMe | ||||
| 	return json.Unmarshal(inputValue, target.Addr().Interface()) | ||||
| } | ||||
|  | ||||
| func unquote(s string) (string, error) { | ||||
| 	var ret string | ||||
| 	err := json.Unmarshal([]byte(s), &ret) | ||||
| 	return ret, err | ||||
| } | ||||
|  | ||||
| // jsonProperties returns parsed proto.Properties for the field and corrects JSONName attribute. | ||||
| func jsonProperties(f reflect.StructField, origName bool) *proto.Properties { | ||||
| 	var prop proto.Properties | ||||
| @@ -1286,8 +969,6 @@ func (s mapKeys) Swap(i, j int) { s[i], s[j] = s[j], s[i] } | ||||
| func (s mapKeys) Less(i, j int) bool { | ||||
| 	if k := s[i].Kind(); k == s[j].Kind() { | ||||
| 		switch k { | ||||
| 		case reflect.String: | ||||
| 			return s[i].String() < s[j].String() | ||||
| 		case reflect.Int32, reflect.Int64: | ||||
| 			return s[i].Int() < s[j].Int() | ||||
| 		case reflect.Uint32, reflect.Uint64: | ||||
| @@ -1296,140 +977,3 @@ func (s mapKeys) Less(i, j int) bool { | ||||
| 	} | ||||
| 	return fmt.Sprint(s[i].Interface()) < fmt.Sprint(s[j].Interface()) | ||||
| } | ||||
|  | ||||
| // checkRequiredFields returns an error if any required field in the given proto message is not set. | ||||
| // This function is used by both Marshal and Unmarshal.  While required fields only exist in a | ||||
| // proto2 message, a proto3 message can contain proto2 message(s). | ||||
| func checkRequiredFields(pb proto.Message) error { | ||||
| 	// Most well-known type messages do not contain required fields.  The "Any" type may contain | ||||
| 	// a message that has required fields. | ||||
| 	// | ||||
| 	// When an Any message is being marshaled, the code will invoked proto.Unmarshal on Any.Value | ||||
| 	// field in order to transform that into JSON, and that should have returned an error if a | ||||
| 	// required field is not set in the embedded message. | ||||
| 	// | ||||
| 	// When an Any message is being unmarshaled, the code will have invoked proto.Marshal on the | ||||
| 	// embedded message to store the serialized message in Any.Value field, and that should have | ||||
| 	// returned an error if a required field is not set. | ||||
| 	if _, ok := pb.(isWkt); ok { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	v := reflect.ValueOf(pb) | ||||
| 	// Skip message if it is not a struct pointer. | ||||
| 	if v.Kind() != reflect.Ptr { | ||||
| 		return nil | ||||
| 	} | ||||
| 	v = v.Elem() | ||||
| 	if v.Kind() != reflect.Struct { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	for i := 0; i < v.NumField(); i++ { | ||||
| 		field := v.Field(i) | ||||
| 		sfield := v.Type().Field(i) | ||||
|  | ||||
| 		if sfield.PkgPath != "" { | ||||
| 			// blank PkgPath means the field is exported; skip if not exported | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		if strings.HasPrefix(sfield.Name, "XXX_") { | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		// Oneof field is an interface implemented by wrapper structs containing the actual oneof | ||||
| 		// field, i.e. an interface containing &T{real_value}. | ||||
| 		if sfield.Tag.Get("protobuf_oneof") != "" { | ||||
| 			if field.Kind() != reflect.Interface { | ||||
| 				continue | ||||
| 			} | ||||
| 			v := field.Elem() | ||||
| 			if v.Kind() != reflect.Ptr || v.IsNil() { | ||||
| 				continue | ||||
| 			} | ||||
| 			v = v.Elem() | ||||
| 			if v.Kind() != reflect.Struct || v.NumField() < 1 { | ||||
| 				continue | ||||
| 			} | ||||
| 			field = v.Field(0) | ||||
| 			sfield = v.Type().Field(0) | ||||
| 		} | ||||
|  | ||||
| 		protoTag := sfield.Tag.Get("protobuf") | ||||
| 		if protoTag == "" { | ||||
| 			continue | ||||
| 		} | ||||
| 		var prop proto.Properties | ||||
| 		prop.Init(sfield.Type, sfield.Name, protoTag, &sfield) | ||||
|  | ||||
| 		switch field.Kind() { | ||||
| 		case reflect.Map: | ||||
| 			if field.IsNil() { | ||||
| 				continue | ||||
| 			} | ||||
| 			// Check each map value. | ||||
| 			keys := field.MapKeys() | ||||
| 			for _, k := range keys { | ||||
| 				v := field.MapIndex(k) | ||||
| 				if err := checkRequiredFieldsInValue(v); err != nil { | ||||
| 					return err | ||||
| 				} | ||||
| 			} | ||||
| 		case reflect.Slice: | ||||
| 			// Handle non-repeated type, e.g. bytes. | ||||
| 			if !prop.Repeated { | ||||
| 				if prop.Required && field.IsNil() { | ||||
| 					return fmt.Errorf("required field %q is not set", prop.Name) | ||||
| 				} | ||||
| 				continue | ||||
| 			} | ||||
|  | ||||
| 			// Handle repeated type. | ||||
| 			if field.IsNil() { | ||||
| 				continue | ||||
| 			} | ||||
| 			// Check each slice item. | ||||
| 			for i := 0; i < field.Len(); i++ { | ||||
| 				v := field.Index(i) | ||||
| 				if err := checkRequiredFieldsInValue(v); err != nil { | ||||
| 					return err | ||||
| 				} | ||||
| 			} | ||||
| 		case reflect.Ptr: | ||||
| 			if field.IsNil() { | ||||
| 				if prop.Required { | ||||
| 					return fmt.Errorf("required field %q is not set", prop.Name) | ||||
| 				} | ||||
| 				continue | ||||
| 			} | ||||
| 			if err := checkRequiredFieldsInValue(field); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Handle proto2 extensions. | ||||
| 	for _, ext := range proto.RegisteredExtensions(pb) { | ||||
| 		if !proto.HasExtension(pb, ext) { | ||||
| 			continue | ||||
| 		} | ||||
| 		ep, err := proto.GetExtension(pb, ext) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		err = checkRequiredFieldsInValue(reflect.ValueOf(ep)) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func checkRequiredFieldsInValue(v reflect.Value) error { | ||||
| 	if v.Type().Implements(messageType) { | ||||
| 		return checkRequiredFields(v.Interface().(proto.Message)) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										735
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										735
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -35,7 +35,6 @@ import ( | ||||
| 	"bytes" | ||||
| 	"encoding/json" | ||||
| 	"io" | ||||
| 	"math" | ||||
| 	"reflect" | ||||
| 	"strings" | ||||
| 	"testing" | ||||
| @@ -55,114 +54,44 @@ var ( | ||||
|  | ||||
| 	simpleObject = &pb.Simple{ | ||||
| 		OInt32:     proto.Int32(-32), | ||||
| 		OInt32Str:  proto.Int32(-32), | ||||
| 		OInt64:     proto.Int64(-6400000000), | ||||
| 		OInt64Str:  proto.Int64(-6400000000), | ||||
| 		OUint32:    proto.Uint32(32), | ||||
| 		OUint32Str: proto.Uint32(32), | ||||
| 		OUint64:    proto.Uint64(6400000000), | ||||
| 		OUint64Str: proto.Uint64(6400000000), | ||||
| 		OSint32:    proto.Int32(-13), | ||||
| 		OSint32Str: proto.Int32(-13), | ||||
| 		OSint64:    proto.Int64(-2600000000), | ||||
| 		OSint64Str: proto.Int64(-2600000000), | ||||
| 		OFloat:     proto.Float32(3.14), | ||||
| 		OFloatStr:  proto.Float32(3.14), | ||||
| 		ODouble:    proto.Float64(6.02214179e23), | ||||
| 		ODoubleStr: proto.Float64(6.02214179e23), | ||||
| 		OBool:      proto.Bool(true), | ||||
| 		OString:    proto.String("hello \"there\""), | ||||
| 		OBytes:     []byte("beep boop"), | ||||
| 		OCastBytes: pb.Bytes("wow"), | ||||
| 	} | ||||
|  | ||||
| 	simpleObjectInputJSON = `{` + | ||||
| 	simpleObjectJSON = `{` + | ||||
| 		`"oBool":true,` + | ||||
| 		`"oInt32":-32,` + | ||||
| 		`"oInt32Str":"-32",` + | ||||
| 		`"oInt64":-6400000000,` + | ||||
| 		`"oInt64Str":"-6400000000",` + | ||||
| 		`"oUint32":32,` + | ||||
| 		`"oUint32Str":"32",` + | ||||
| 		`"oUint64":6400000000,` + | ||||
| 		`"oUint64Str":"6400000000",` + | ||||
| 		`"oSint32":-13,` + | ||||
| 		`"oSint32Str":"-13",` + | ||||
| 		`"oSint64":-2600000000,` + | ||||
| 		`"oSint64Str":"-2600000000",` + | ||||
| 		`"oFloat":3.14,` + | ||||
| 		`"oFloatStr":"3.14",` + | ||||
| 		`"oDouble":6.02214179e+23,` + | ||||
| 		`"oDoubleStr":"6.02214179e+23",` + | ||||
| 		`"oString":"hello \"there\"",` + | ||||
| 		`"oBytes":"YmVlcCBib29w",` + | ||||
| 		`"oCastBytes":"d293"` + | ||||
| 		`}` | ||||
|  | ||||
| 	simpleObjectOutputJSON = `{` + | ||||
| 		`"oBool":true,` + | ||||
| 		`"oInt32":-32,` + | ||||
| 		`"oInt32Str":-32,` + | ||||
| 		`"oInt64":"-6400000000",` + | ||||
| 		`"oInt64Str":"-6400000000",` + | ||||
| 		`"oUint32":32,` + | ||||
| 		`"oUint32Str":32,` + | ||||
| 		`"oUint64":"6400000000",` + | ||||
| 		`"oUint64Str":"6400000000",` + | ||||
| 		`"oSint32":-13,` + | ||||
| 		`"oSint32Str":-13,` + | ||||
| 		`"oSint64":"-2600000000",` + | ||||
| 		`"oSint64Str":"-2600000000",` + | ||||
| 		`"oFloat":3.14,` + | ||||
| 		`"oFloatStr":3.14,` + | ||||
| 		`"oDouble":6.02214179e+23,` + | ||||
| 		`"oDoubleStr":6.02214179e+23,` + | ||||
| 		`"oString":"hello \"there\"",` + | ||||
| 		`"oBytes":"YmVlcCBib29w",` + | ||||
| 		`"oCastBytes":"d293"` + | ||||
| 		`}` | ||||
|  | ||||
| 	simpleObjectInputPrettyJSON = `{ | ||||
| 	simpleObjectPrettyJSON = `{ | ||||
|   "oBool": true, | ||||
|   "oInt32": -32, | ||||
|   "oInt32Str": "-32", | ||||
|   "oInt64": -6400000000, | ||||
|   "oInt64Str": "-6400000000", | ||||
|   "oUint32": 32, | ||||
|   "oUint32Str": "32", | ||||
|   "oUint64": 6400000000, | ||||
|   "oUint64Str": "6400000000", | ||||
|   "oSint32": -13, | ||||
|   "oSint32Str": "-13", | ||||
|   "oSint64": -2600000000, | ||||
|   "oSint64Str": "-2600000000", | ||||
|   "oFloat": 3.14, | ||||
|   "oFloatStr": "3.14", | ||||
|   "oDouble": 6.02214179e+23, | ||||
|   "oDoubleStr": "6.02214179e+23", | ||||
|   "oString": "hello \"there\"", | ||||
|   "oBytes": "YmVlcCBib29w", | ||||
|   "oCastBytes": "d293" | ||||
| }` | ||||
|  | ||||
| 	simpleObjectOutputPrettyJSON = `{ | ||||
|   "oBool": true, | ||||
|   "oInt32": -32, | ||||
|   "oInt32Str": -32, | ||||
|   "oInt64": "-6400000000", | ||||
|   "oInt64Str": "-6400000000", | ||||
|   "oUint32": 32, | ||||
|   "oUint32Str": 32, | ||||
|   "oUint64": "6400000000", | ||||
|   "oUint64Str": "6400000000", | ||||
|   "oSint32": -13, | ||||
|   "oSint32Str": -13, | ||||
|   "oSint64": "-2600000000", | ||||
|   "oSint64Str": "-2600000000", | ||||
|   "oFloat": 3.14, | ||||
|   "oFloatStr": 3.14, | ||||
|   "oDouble": 6.02214179e+23, | ||||
|   "oDoubleStr": 6.02214179e+23, | ||||
|   "oString": "hello \"there\"", | ||||
|   "oBytes": "YmVlcCBib29w", | ||||
|   "oCastBytes": "d293" | ||||
| @@ -363,7 +292,7 @@ var ( | ||||
| 		An: &types.Any{ | ||||
| 			TypeUrl: "type.googleapis.com/google.protobuf.Duration", | ||||
| 			Value: []byte{ | ||||
| 				// &types.Duration{Seconds: 1, Nanos: 212000000 } | ||||
| 				// &durpb.Duration{Seconds: 1, Nanos: 212000000 } | ||||
| 				1 << 3, 1, // seconds | ||||
| 				2 << 3, 0x80, 0xba, 0x8b, 0x65, // nanos | ||||
| 			}, | ||||
| @@ -376,23 +305,6 @@ var ( | ||||
|     "value": "1.212s" | ||||
|   } | ||||
| }` | ||||
|  | ||||
| 	nonFinites = &pb.NonFinites{ | ||||
| 		FNan:  proto.Float32(float32(math.NaN())), | ||||
| 		FPinf: proto.Float32(float32(math.Inf(1))), | ||||
| 		FNinf: proto.Float32(float32(math.Inf(-1))), | ||||
| 		DNan:  proto.Float64(float64(math.NaN())), | ||||
| 		DPinf: proto.Float64(float64(math.Inf(1))), | ||||
| 		DNinf: proto.Float64(float64(math.Inf(-1))), | ||||
| 	} | ||||
| 	nonFinitesJSON = `{` + | ||||
| 		`"fNan":"NaN",` + | ||||
| 		`"fPinf":"Infinity",` + | ||||
| 		`"fNinf":"-Infinity",` + | ||||
| 		`"dNan":"NaN",` + | ||||
| 		`"dPinf":"Infinity",` + | ||||
| 		`"dNinf":"-Infinity"` + | ||||
| 		`}` | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| @@ -410,9 +322,8 @@ var marshalingTests = []struct { | ||||
| 	pb        proto.Message | ||||
| 	json      string | ||||
| }{ | ||||
| 	{"simple flat object", marshaler, simpleObject, simpleObjectOutputJSON}, | ||||
| 	{"simple pretty object", marshalerAllOptions, simpleObject, simpleObjectOutputPrettyJSON}, | ||||
| 	{"non-finite floats fields object", marshaler, nonFinites, nonFinitesJSON}, | ||||
| 	{"simple flat object", marshaler, simpleObject, simpleObjectJSON}, | ||||
| 	{"simple pretty object", marshalerAllOptions, simpleObject, simpleObjectPrettyJSON}, | ||||
| 	{"repeated fields flat object", marshaler, repeatsObject, repeatsObjectJSON}, | ||||
| 	{"repeated fields pretty object", marshalerAllOptions, repeatsObject, repeatsObjectPrettyJSON}, | ||||
| 	{"nested message/enum flat object", marshaler, complexObject, complexObjectJSON}, | ||||
| @@ -437,9 +348,6 @@ var marshalingTests = []struct { | ||||
| 		`{"rFunny":[1,2]}`}, | ||||
| 	{"empty value", marshaler, &pb.Simple3{}, `{}`}, | ||||
| 	{"empty value emitted", Marshaler{EmitDefaults: true}, &pb.Simple3{}, `{"dub":0}`}, | ||||
| 	{"empty repeated emitted", Marshaler{EmitDefaults: true}, &pb.SimpleSlice3{}, `{"slices":[]}`}, | ||||
| 	{"empty map emitted", Marshaler{EmitDefaults: true}, &pb.SimpleMap3{}, `{"stringy":{}}`}, | ||||
| 	{"nested struct null", Marshaler{EmitDefaults: true}, &pb.SimpleNull3{}, `{"simple":null}`}, | ||||
| 	{"map<int64, int32>", marshaler, &pb.Mappy{Nummy: map[int64]int32{1: 2, 3: 4}}, `{"nummy":{"1":2,"3":4}}`}, | ||||
| 	{"map<int64, int32>", marshalerAllOptions, &pb.Mappy{Nummy: map[int64]int32{1: 2, 3: 4}}, nummyPrettyJSON}, | ||||
| 	{"map<string, string>", marshaler, | ||||
| @@ -452,7 +360,8 @@ var marshalingTests = []struct { | ||||
| 	{"map<int64, string>", marshaler, &pb.Mappy{Buggy: map[int64]string{1234: "yup"}}, | ||||
| 		`{"buggy":{"1234":"yup"}}`}, | ||||
| 	{"map<bool, bool>", marshaler, &pb.Mappy{Booly: map[bool]bool{false: true}}, `{"booly":{"false":true}}`}, | ||||
| 	{"map<string, enum>", marshaler, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}, `{"enumy":{"XIV":"ROMAN"}}`}, | ||||
| 	// TODO: This is broken. | ||||
| 	//{"map<string, enum>", marshaler, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}, `{"enumy":{"XIV":"ROMAN"}`}, | ||||
| 	{"map<string, enum as int>", Marshaler{EnumsAsInts: true}, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}, `{"enumy":{"XIV":2}}`}, | ||||
| 	{"map<int32, bool>", marshaler, &pb.Mappy{S32Booly: map[int32]bool{1: true, 3: false, 10: true, 12: false}}, `{"s32booly":{"1":true,"3":false,"10":true,"12":false}}`}, | ||||
| 	{"map<int64, bool>", marshaler, &pb.Mappy{S64Booly: map[int64]bool{1: true, 3: false, 10: true, 12: false}}, `{"s64booly":{"1":true,"3":false,"10":true,"12":false}}`}, | ||||
| @@ -472,51 +381,14 @@ var marshalingTests = []struct { | ||||
| 	{"Any with message and indent", marshalerAllOptions, anySimple, anySimplePrettyJSON}, | ||||
| 	{"Any with WKT", marshaler, anyWellKnown, anyWellKnownJSON}, | ||||
| 	{"Any with WKT and indent", marshalerAllOptions, anyWellKnown, anyWellKnownPrettyJSON}, | ||||
| 	{"Duration empty", marshaler, &types.Duration{}, `"0s"`}, | ||||
| 	{"Duration with secs", marshaler, &types.Duration{Seconds: 3}, `"3s"`}, | ||||
| 	{"Duration with -secs", marshaler, &types.Duration{Seconds: -3}, `"-3s"`}, | ||||
| 	{"Duration with nanos", marshaler, &types.Duration{Nanos: 1e6}, `"0.001s"`}, | ||||
| 	{"Duration with -nanos", marshaler, &types.Duration{Nanos: -1e6}, `"-0.001s"`}, | ||||
| 	{"Duration with large secs", marshaler, &types.Duration{Seconds: 1e10, Nanos: 1}, `"10000000000.000000001s"`}, | ||||
| 	{"Duration with 6-digit nanos", marshaler, &types.Duration{Nanos: 1e4}, `"0.000010s"`}, | ||||
| 	{"Duration with 3-digit nanos", marshaler, &types.Duration{Nanos: 1e6}, `"0.001s"`}, | ||||
| 	{"Duration with -secs -nanos", marshaler, &types.Duration{Seconds: -123, Nanos: -450}, `"-123.000000450s"`}, | ||||
| 	{"Duration max value", marshaler, &types.Duration{Seconds: 315576000000, Nanos: 999999999}, `"315576000000.999999999s"`}, | ||||
| 	{"Duration small negative", marshaler, &types.Duration{Nanos: -1}, `"-0.000000001s"`}, | ||||
| 	{"Duration min value", marshaler, &types.Duration{Seconds: -315576000000, Nanos: -999999999}, `"-315576000000.999999999s"`}, | ||||
| 	{"Duration", marshaler, &pb.KnownTypes{Dur: &types.Duration{Seconds: 3}}, `{"dur":"3.000s"}`}, | ||||
| 	{"Struct", marshaler, &pb.KnownTypes{St: &types.Struct{ | ||||
| 		Fields: map[string]*types.Value{ | ||||
| 			"one": {Kind: &types.Value_StringValue{StringValue: "loneliest number"}}, | ||||
| 			"two": {Kind: &types.Value_NullValue{NullValue: types.NullValue_NULL_VALUE}}, | ||||
| 			"two": {Kind: &types.Value_NullValue{NullValue: types.NULL_VALUE}}, | ||||
| 		}, | ||||
| 	}}, `{"st":{"one":"loneliest number","two":null}}`}, | ||||
| 	{"empty ListValue", marshaler, &pb.KnownTypes{Lv: &types.ListValue{}}, `{"lv":[]}`}, | ||||
| 	{"basic ListValue", marshaler, &pb.KnownTypes{Lv: &types.ListValue{Values: []*types.Value{ | ||||
| 		{Kind: &types.Value_StringValue{StringValue: "x"}}, | ||||
| 		{Kind: &types.Value_NullValue{}}, | ||||
| 		{Kind: &types.Value_NumberValue{NumberValue: 3}}, | ||||
| 		{Kind: &types.Value_BoolValue{BoolValue: true}}, | ||||
| 	}}}, `{"lv":["x",null,3,true]}`}, | ||||
| 	{"Timestamp", marshaler, &pb.KnownTypes{Ts: &types.Timestamp{Seconds: 14e8, Nanos: 21e6}}, `{"ts":"2014-05-13T16:53:20.021Z"}`}, | ||||
| 	{"Timestamp", marshaler, &pb.KnownTypes{Ts: &types.Timestamp{Seconds: 14e8, Nanos: 0}}, `{"ts":"2014-05-13T16:53:20Z"}`}, | ||||
| 	{"number Value", marshaler, &pb.KnownTypes{Val: &types.Value{Kind: &types.Value_NumberValue{NumberValue: 1}}}, `{"val":1}`}, | ||||
| 	{"null Value", marshaler, &pb.KnownTypes{Val: &types.Value{Kind: &types.Value_NullValue{NullValue: types.NullValue_NULL_VALUE}}}, `{"val":null}`}, | ||||
| 	{"string number value", marshaler, &pb.KnownTypes{Val: &types.Value{Kind: &types.Value_StringValue{StringValue: "9223372036854775807"}}}, `{"val":"9223372036854775807"}`}, | ||||
| 	{"list of lists Value", marshaler, &pb.KnownTypes{Val: &types.Value{ | ||||
| 		Kind: &types.Value_ListValue{ListValue: &types.ListValue{ | ||||
| 			Values: []*types.Value{ | ||||
| 				{Kind: &types.Value_StringValue{StringValue: "x"}}, | ||||
| 				{Kind: &types.Value_ListValue{ListValue: &types.ListValue{ | ||||
| 					Values: []*types.Value{ | ||||
| 						{Kind: &types.Value_ListValue{ListValue: &types.ListValue{ | ||||
| 							Values: []*types.Value{{Kind: &types.Value_StringValue{StringValue: "y"}}}, | ||||
| 						}}}, | ||||
| 						{Kind: &types.Value_StringValue{StringValue: "z"}}, | ||||
| 					}, | ||||
| 				}}}, | ||||
| 			}, | ||||
| 		}}, | ||||
| 	}}, `{"val":["x",[["y"],"z"]]}`}, | ||||
| 	{"DoubleValue", marshaler, &pb.KnownTypes{Dbl: &types.DoubleValue{Value: 1.2}}, `{"dbl":1.2}`}, | ||||
| 	{"FloatValue", marshaler, &pb.KnownTypes{Flt: &types.FloatValue{Value: 1.2}}, `{"flt":1.2}`}, | ||||
| 	{"Int64Value", marshaler, &pb.KnownTypes{I64: &types.Int64Value{Value: -3}}, `{"i64":"-3"}`}, | ||||
| @@ -526,8 +398,6 @@ var marshalingTests = []struct { | ||||
| 	{"BoolValue", marshaler, &pb.KnownTypes{Bool: &types.BoolValue{Value: true}}, `{"bool":true}`}, | ||||
| 	{"StringValue", marshaler, &pb.KnownTypes{Str: &types.StringValue{Value: "plush"}}, `{"str":"plush"}`}, | ||||
| 	{"BytesValue", marshaler, &pb.KnownTypes{Bytes: &types.BytesValue{Value: []byte("wow")}}, `{"bytes":"d293"}`}, | ||||
| 	{"required", marshaler, &pb.MsgWithRequired{Str: proto.String("hello")}, `{"str":"hello"}`}, | ||||
| 	{"required bytes", marshaler, &pb.MsgWithRequiredBytes{Byts: []byte{}}, `{"byts":""}`}, | ||||
| } | ||||
|  | ||||
| func TestMarshaling(t *testing.T) { | ||||
| @@ -541,200 +411,14 @@ func TestMarshaling(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestMarshalingNil(t *testing.T) { | ||||
| 	var msg *pb.Simple | ||||
| 	m := &Marshaler{} | ||||
| 	if _, err := m.MarshalToString(msg); err == nil { | ||||
| 		t.Errorf("mashaling nil returned no error") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestMarshalIllegalTime(t *testing.T) { | ||||
| 	tests := []struct { | ||||
| 		pb   proto.Message | ||||
| 		fail bool | ||||
| 	}{ | ||||
| 		{&types.Duration{Seconds: 1, Nanos: 0}, false}, | ||||
| 		{&types.Duration{Seconds: -1, Nanos: 0}, false}, | ||||
| 		{&types.Duration{Seconds: 1, Nanos: -1}, true}, | ||||
| 		{&types.Duration{Seconds: -1, Nanos: 1}, true}, | ||||
| 		{&types.Duration{Seconds: 315576000001}, true}, | ||||
| 		{&types.Duration{Seconds: -315576000001}, true}, | ||||
| 		{&types.Duration{Seconds: 1, Nanos: 1000000000}, true}, | ||||
| 		{&types.Duration{Seconds: -1, Nanos: -1000000000}, true}, | ||||
| 		{&types.Timestamp{Seconds: 1, Nanos: 1}, false}, | ||||
| 		{&types.Timestamp{Seconds: 1, Nanos: -1}, true}, | ||||
| 		{&types.Timestamp{Seconds: 1, Nanos: 1000000000}, true}, | ||||
| 	} | ||||
| 	for _, tt := range tests { | ||||
| 		_, err := marshaler.MarshalToString(tt.pb) | ||||
| 		if err == nil && tt.fail { | ||||
| 			t.Errorf("marshaler.MarshalToString(%v) = _, <nil>; want _, <non-nil>", tt.pb) | ||||
| 		} | ||||
| 		if err != nil && !tt.fail { | ||||
| 			t.Errorf("marshaler.MarshalToString(%v) = _, %v; want _, <nil>", tt.pb, err) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestMarshalJSONPBMarshaler(t *testing.T) { | ||||
| 	rawJson := `{ "foo": "bar", "baz": [0, 1, 2, 3] }` | ||||
| 	msg := dynamicMessage{RawJson: rawJson} | ||||
| 	str, err := new(Marshaler).MarshalToString(&msg) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when marshalling JSONPBMarshaler: %v", err) | ||||
| 	} | ||||
| 	if str != rawJson { | ||||
| 		t.Errorf("marshalling JSON produced incorrect output: got %s, wanted %s", str, rawJson) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestMarshalAnyJSONPBMarshaler(t *testing.T) { | ||||
| 	msg := dynamicMessage{RawJson: `{ "foo": "bar", "baz": [0, 1, 2, 3] }`} | ||||
| 	a, err := types.MarshalAny(&msg) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when marshalling to Any: %v", err) | ||||
| 	} | ||||
| 	str, err := new(Marshaler).MarshalToString(a) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when marshalling Any to JSON: %v", err) | ||||
| 	} | ||||
| 	// after custom marshaling, it's round-tripped through JSON decoding/encoding already, | ||||
| 	// so the keys are sorted, whitespace is compacted, and "@type" key has been added | ||||
| 	expected := `{"@type":"type.googleapis.com/` + dynamicMessageName + `","baz":[0,1,2,3],"foo":"bar"}` | ||||
| 	if str != expected { | ||||
| 		t.Errorf("marshalling JSON produced incorrect output: got %s, wanted %s", str, expected) | ||||
| 	} | ||||
|  | ||||
| 	// Do it again, but this time with indentation: | ||||
|  | ||||
| 	marshaler := Marshaler{Indent: "  "} | ||||
| 	str, err = marshaler.MarshalToString(a) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when marshalling Any to JSON: %v", err) | ||||
| 	} | ||||
| 	// same as expected above, but pretty-printed w/ indentation | ||||
| 	expected = `{ | ||||
|   "@type": "type.googleapis.com/` + dynamicMessageName + `", | ||||
|   "baz": [ | ||||
|     0, | ||||
|     1, | ||||
|     2, | ||||
|     3 | ||||
|   ], | ||||
|   "foo": "bar" | ||||
| }` | ||||
| 	if str != expected { | ||||
| 		t.Errorf("marshalling JSON produced incorrect output: got %s, wanted %s", str, expected) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestMarshalWithCustomValidation(t *testing.T) { | ||||
| 	msg := dynamicMessage{RawJson: `{ "foo": "bar", "baz": [0, 1, 2, 3] }`, Dummy: &dynamicMessage{}} | ||||
|  | ||||
| 	js, err := new(Marshaler).MarshalToString(&msg) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when marshalling to json: %v", err) | ||||
| 	} | ||||
| 	err = Unmarshal(strings.NewReader(js), &msg) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when unmarshalling from json: %v", err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Test marshaling message containing unset required fields should produce error. | ||||
| func TestMarshalUnsetRequiredFields(t *testing.T) { | ||||
| 	msgExt := &pb.Real{} | ||||
| 	proto.SetExtension(msgExt, pb.E_Extm, &pb.MsgWithRequired{}) | ||||
|  | ||||
| 	tests := []struct { | ||||
| 		desc      string | ||||
| 		marshaler *Marshaler | ||||
| 		pb        proto.Message | ||||
| 	}{ | ||||
| 		{ | ||||
| 			desc:      "direct required field", | ||||
| 			marshaler: &Marshaler{}, | ||||
| 			pb:        &pb.MsgWithRequired{}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:      "direct required field + emit defaults", | ||||
| 			marshaler: &Marshaler{EmitDefaults: true}, | ||||
| 			pb:        &pb.MsgWithRequired{}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:      "indirect required field", | ||||
| 			marshaler: &Marshaler{}, | ||||
| 			pb:        &pb.MsgWithIndirectRequired{Subm: &pb.MsgWithRequired{}}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:      "indirect required field + emit defaults", | ||||
| 			marshaler: &Marshaler{EmitDefaults: true}, | ||||
| 			pb:        &pb.MsgWithIndirectRequired{Subm: &pb.MsgWithRequired{}}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:      "direct required wkt field", | ||||
| 			marshaler: &Marshaler{}, | ||||
| 			pb:        &pb.MsgWithRequiredWKT{}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:      "direct required wkt field + emit defaults", | ||||
| 			marshaler: &Marshaler{EmitDefaults: true}, | ||||
| 			pb:        &pb.MsgWithRequiredWKT{}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:      "direct required bytes field", | ||||
| 			marshaler: &Marshaler{}, | ||||
| 			pb:        &pb.MsgWithRequiredBytes{}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:      "required in map value", | ||||
| 			marshaler: &Marshaler{}, | ||||
| 			pb: &pb.MsgWithIndirectRequired{ | ||||
| 				MapField: map[string]*pb.MsgWithRequired{ | ||||
| 					"key": {}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:      "required in repeated item", | ||||
| 			marshaler: &Marshaler{}, | ||||
| 			pb: &pb.MsgWithIndirectRequired{ | ||||
| 				SliceField: []*pb.MsgWithRequired{ | ||||
| 					{Str: proto.String("hello")}, | ||||
| 					{}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:      "required inside oneof", | ||||
| 			marshaler: &Marshaler{}, | ||||
| 			pb: &pb.MsgWithOneof{ | ||||
| 				Union: &pb.MsgWithOneof_MsgWithRequired{MsgWithRequired: &pb.MsgWithRequired{}}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc:      "required inside extension", | ||||
| 			marshaler: &Marshaler{}, | ||||
| 			pb:        msgExt, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	for _, tc := range tests { | ||||
| 		if _, err := tc.marshaler.MarshalToString(tc.pb); err == nil { | ||||
| 			t.Errorf("%s: expecting error in marshaling with unset required fields %+v", tc.desc, tc.pb) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| var unmarshalingTests = []struct { | ||||
| 	desc        string | ||||
| 	unmarshaler Unmarshaler | ||||
| 	json        string | ||||
| 	pb          proto.Message | ||||
| }{ | ||||
| 	{"simple flat object", Unmarshaler{}, simpleObjectInputJSON, simpleObject}, | ||||
| 	{"simple pretty object", Unmarshaler{}, simpleObjectInputPrettyJSON, simpleObject}, | ||||
| 	{"simple flat object", Unmarshaler{}, simpleObjectJSON, simpleObject}, | ||||
| 	{"simple pretty object", Unmarshaler{}, simpleObjectPrettyJSON, simpleObject}, | ||||
| 	{"repeated fields flat object", Unmarshaler{}, repeatsObjectJSON, repeatsObject}, | ||||
| 	{"repeated fields pretty object", Unmarshaler{}, repeatsObjectPrettyJSON, repeatsObject}, | ||||
| 	{"nested message/enum flat object", Unmarshaler{}, complexObjectJSON, complexObject}, | ||||
| @@ -765,18 +449,11 @@ var unmarshalingTests = []struct { | ||||
| 		}}}, | ||||
| 	{"unquoted int64 object", Unmarshaler{}, `{"oInt64":-314}`, &pb.Simple{OInt64: proto.Int64(-314)}}, | ||||
| 	{"unquoted uint64 object", Unmarshaler{}, `{"oUint64":123}`, &pb.Simple{OUint64: proto.Uint64(123)}}, | ||||
| 	{"NaN", Unmarshaler{}, `{"oDouble":"NaN"}`, &pb.Simple{ODouble: proto.Float64(math.NaN())}}, | ||||
| 	{"Inf", Unmarshaler{}, `{"oFloat":"Infinity"}`, &pb.Simple{OFloat: proto.Float32(float32(math.Inf(1)))}}, | ||||
| 	{"-Inf", Unmarshaler{}, `{"oDouble":"-Infinity"}`, &pb.Simple{ODouble: proto.Float64(math.Inf(-1))}}, | ||||
| 	{"map<int64, int32>", Unmarshaler{}, `{"nummy":{"1":2,"3":4}}`, &pb.Mappy{Nummy: map[int64]int32{1: 2, 3: 4}}}, | ||||
| 	{"map<string, string>", Unmarshaler{}, `{"strry":{"\"one\"":"two","three":"four"}}`, &pb.Mappy{Strry: map[string]string{`"one"`: "two", "three": "four"}}}, | ||||
| 	{"map<int32, Object>", Unmarshaler{}, `{"objjy":{"1":{"dub":1}}}`, &pb.Mappy{Objjy: map[int32]*pb.Simple3{1: {Dub: 1}}}}, | ||||
| 	{"proto2 extension", Unmarshaler{}, realNumberJSON, realNumber}, | ||||
| 	// TODO does not work with go version 1.7, but works with go version 1.8 {"Any with message", Unmarshaler{}, anySimpleJSON, anySimple}, | ||||
| 	// TODO does not work with go version 1.7, but works with go version 1.8 {"Any with message and indent", Unmarshaler{}, anySimplePrettyJSON, anySimple}, | ||||
| 	{"Any with WKT", Unmarshaler{}, anyWellKnownJSON, anyWellKnown}, | ||||
| 	{"Any with WKT and indent", Unmarshaler{}, anyWellKnownPrettyJSON, anyWellKnown}, | ||||
| 	{"map<string, enum>", Unmarshaler{}, `{"enumy":{"XIV":"ROMAN"}}`, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}}, | ||||
| 	// TODO: This is broken. | ||||
| 	//{"map<string, enum>", Unmarshaler{}, `{"enumy":{"XIV":"ROMAN"}`, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}}, | ||||
| 	{"map<string, enum as int>", Unmarshaler{}, `{"enumy":{"XIV":2}}`, &pb.Mappy{Enumy: map[string]pb.Numeral{"XIV": pb.Numeral_ROMAN}}}, | ||||
| 	{"oneof", Unmarshaler{}, `{"salary":31000}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Salary{Salary: 31000}}}, | ||||
| 	{"oneof spec name", Unmarshaler{}, `{"Country":"Australia"}`, &pb.MsgWithOneof{Union: &pb.MsgWithOneof_Country{Country: "Australia"}}}, | ||||
| @@ -786,60 +463,11 @@ var unmarshalingTests = []struct { | ||||
| 	{"orig_name input", Unmarshaler{}, `{"o_bool":true}`, &pb.Simple{OBool: proto.Bool(true)}}, | ||||
| 	{"camelName input", Unmarshaler{}, `{"oBool":true}`, &pb.Simple{OBool: proto.Bool(true)}}, | ||||
| 	{"Duration", Unmarshaler{}, `{"dur":"3.000s"}`, &pb.KnownTypes{Dur: &types.Duration{Seconds: 3}}}, | ||||
| 	{"Duration", Unmarshaler{}, `{"dur":"4s"}`, &pb.KnownTypes{Dur: &types.Duration{Seconds: 4}}}, | ||||
| 	{"Duration with unicode", Unmarshaler{}, `{"dur": "3\u0073"}`, &pb.KnownTypes{Dur: &types.Duration{Seconds: 3}}}, | ||||
| 	{"null Duration", Unmarshaler{}, `{"dur":null}`, &pb.KnownTypes{Dur: nil}}, | ||||
| 	{"null Duration", Unmarshaler{}, `{"dur":null}`, &pb.KnownTypes{Dur: &types.Duration{Seconds: 0}}}, | ||||
| 	{"Timestamp", Unmarshaler{}, `{"ts":"2014-05-13T16:53:20.021Z"}`, &pb.KnownTypes{Ts: &types.Timestamp{Seconds: 14e8, Nanos: 21e6}}}, | ||||
| 	{"Timestamp", Unmarshaler{}, `{"ts":"2014-05-13T16:53:20Z"}`, &pb.KnownTypes{Ts: &types.Timestamp{Seconds: 14e8, Nanos: 0}}}, | ||||
| 	{"Timestamp with unicode", Unmarshaler{}, `{"ts": "2014-05-13T16:53:20\u005a"}`, &pb.KnownTypes{Ts: &types.Timestamp{Seconds: 14e8, Nanos: 0}}}, | ||||
| 	{"PreEpochTimestamp", Unmarshaler{}, `{"ts":"1969-12-31T23:59:58.999999995Z"}`, &pb.KnownTypes{Ts: &types.Timestamp{Seconds: -2, Nanos: 999999995}}}, | ||||
| 	{"ZeroTimeTimestamp", Unmarshaler{}, `{"ts":"0001-01-01T00:00:00Z"}`, &pb.KnownTypes{Ts: &types.Timestamp{Seconds: -62135596800, Nanos: 0}}}, | ||||
| 	{"null Timestamp", Unmarshaler{}, `{"ts":null}`, &pb.KnownTypes{Ts: nil}}, | ||||
| 	{"null Struct", Unmarshaler{}, `{"st": null}`, &pb.KnownTypes{St: nil}}, | ||||
| 	{"empty Struct", Unmarshaler{}, `{"st": {}}`, &pb.KnownTypes{St: &types.Struct{}}}, | ||||
| 	{"basic Struct", Unmarshaler{}, `{"st": {"a": "x", "b": null, "c": 3, "d": true}}`, &pb.KnownTypes{St: &types.Struct{Fields: map[string]*types.Value{ | ||||
| 		"a": {Kind: &types.Value_StringValue{StringValue: "x"}}, | ||||
| 		"b": {Kind: &types.Value_NullValue{}}, | ||||
| 		"c": {Kind: &types.Value_NumberValue{NumberValue: 3}}, | ||||
| 		"d": {Kind: &types.Value_BoolValue{BoolValue: true}}, | ||||
| 	}}}}, | ||||
| 	{"nested Struct", Unmarshaler{}, `{"st": {"a": {"b": 1, "c": [{"d": true}, "f"]}}}`, &pb.KnownTypes{St: &types.Struct{Fields: map[string]*types.Value{ | ||||
| 		"a": {Kind: &types.Value_StructValue{StructValue: &types.Struct{Fields: map[string]*types.Value{ | ||||
| 			"b": {Kind: &types.Value_NumberValue{NumberValue: 1}}, | ||||
| 			"c": {Kind: &types.Value_ListValue{ListValue: &types.ListValue{Values: []*types.Value{ | ||||
| 				{Kind: &types.Value_StructValue{StructValue: &types.Struct{Fields: map[string]*types.Value{"d": {Kind: &types.Value_BoolValue{BoolValue: true}}}}}}, | ||||
| 				{Kind: &types.Value_StringValue{StringValue: "f"}}, | ||||
| 			}}}}, | ||||
| 		}}}}, | ||||
| 	}}}}, | ||||
| 	{"null ListValue", Unmarshaler{}, `{"lv": null}`, &pb.KnownTypes{Lv: nil}}, | ||||
| 	{"empty ListValue", Unmarshaler{}, `{"lv": []}`, &pb.KnownTypes{Lv: &types.ListValue{}}}, | ||||
| 	{"basic ListValue", Unmarshaler{}, `{"lv": ["x", null, 3, true]}`, &pb.KnownTypes{Lv: &types.ListValue{Values: []*types.Value{ | ||||
| 		{Kind: &types.Value_StringValue{StringValue: "x"}}, | ||||
| 		{Kind: &types.Value_NullValue{}}, | ||||
| 		{Kind: &types.Value_NumberValue{NumberValue: 3}}, | ||||
| 		{Kind: &types.Value_BoolValue{BoolValue: true}}, | ||||
| 	}}}}, | ||||
| 	{"number Value", Unmarshaler{}, `{"val":1}`, &pb.KnownTypes{Val: &types.Value{Kind: &types.Value_NumberValue{NumberValue: 1}}}}, | ||||
| 	{"null Value", Unmarshaler{}, `{"val":null}`, &pb.KnownTypes{Val: &types.Value{Kind: &types.Value_NullValue{NullValue: types.NullValue_NULL_VALUE}}}}, | ||||
| 	{"bool Value", Unmarshaler{}, `{"val":true}`, &pb.KnownTypes{Val: &types.Value{Kind: &types.Value_BoolValue{BoolValue: true}}}}, | ||||
| 	{"string Value", Unmarshaler{}, `{"val":"x"}`, &pb.KnownTypes{Val: &types.Value{Kind: &types.Value_StringValue{StringValue: "x"}}}}, | ||||
| 	{"string number value", Unmarshaler{}, `{"val":"9223372036854775807"}`, &pb.KnownTypes{Val: &types.Value{Kind: &types.Value_StringValue{StringValue: "9223372036854775807"}}}}, | ||||
| 	{"list of lists Value", Unmarshaler{}, `{"val":["x", [["y"], "z"]]}`, &pb.KnownTypes{Val: &types.Value{ | ||||
| 		Kind: &types.Value_ListValue{ListValue: &types.ListValue{ | ||||
| 			Values: []*types.Value{ | ||||
| 				{Kind: &types.Value_StringValue{StringValue: "x"}}, | ||||
| 				{Kind: &types.Value_ListValue{ListValue: &types.ListValue{ | ||||
| 					Values: []*types.Value{ | ||||
| 						{Kind: &types.Value_ListValue{ListValue: &types.ListValue{ | ||||
| 							Values: []*types.Value{{Kind: &types.Value_StringValue{StringValue: "y"}}}, | ||||
| 						}}}, | ||||
| 						{Kind: &types.Value_StringValue{StringValue: "z"}}, | ||||
| 					}, | ||||
| 				}}}, | ||||
| 			}, | ||||
| 		}}}}}, | ||||
|  | ||||
| 	{"null Timestamp", Unmarshaler{}, `{"ts":null}`, &pb.KnownTypes{Ts: &types.Timestamp{Seconds: 0, Nanos: 0}}}, | ||||
| 	{"DoubleValue", Unmarshaler{}, `{"dbl":1.2}`, &pb.KnownTypes{Dbl: &types.DoubleValue{Value: 1.2}}}, | ||||
| 	{"FloatValue", Unmarshaler{}, `{"flt":1.2}`, &pb.KnownTypes{Flt: &types.FloatValue{Value: 1.2}}}, | ||||
| 	{"Int64Value", Unmarshaler{}, `{"i64":"-3"}`, &pb.KnownTypes{I64: &types.Int64Value{Value: -3}}}, | ||||
| @@ -848,27 +476,9 @@ var unmarshalingTests = []struct { | ||||
| 	{"UInt32Value", Unmarshaler{}, `{"u32":4}`, &pb.KnownTypes{U32: &types.UInt32Value{Value: 4}}}, | ||||
| 	{"BoolValue", Unmarshaler{}, `{"bool":true}`, &pb.KnownTypes{Bool: &types.BoolValue{Value: true}}}, | ||||
| 	{"StringValue", Unmarshaler{}, `{"str":"plush"}`, &pb.KnownTypes{Str: &types.StringValue{Value: "plush"}}}, | ||||
| 	{"StringValue containing escaped character", Unmarshaler{}, `{"str":"a\/b"}`, &pb.KnownTypes{Str: &types.StringValue{Value: "a/b"}}}, | ||||
| 	{"StructValue containing StringValue's", Unmarshaler{}, `{"escaped": "a\/b", "unicode": "\u00004E16\u0000754C"}`, | ||||
| 		&types.Struct{ | ||||
| 			Fields: map[string]*types.Value{ | ||||
| 				"escaped": {Kind: &types.Value_StringValue{StringValue: "a/b"}}, | ||||
| 				"unicode": {Kind: &types.Value_StringValue{StringValue: "\u00004E16\u0000754C"}}, | ||||
| 			}, | ||||
| 		}}, | ||||
| 	{"BytesValue", Unmarshaler{}, `{"bytes":"d293"}`, &pb.KnownTypes{Bytes: &types.BytesValue{Value: []byte("wow")}}}, | ||||
| 	// Ensure that `null` as a value ends up with a nil pointer instead of a [type]Value struct. | ||||
| 	{"null DoubleValue", Unmarshaler{}, `{"dbl":null}`, &pb.KnownTypes{Dbl: nil}}, | ||||
| 	{"null FloatValue", Unmarshaler{}, `{"flt":null}`, &pb.KnownTypes{Flt: nil}}, | ||||
| 	{"null Int64Value", Unmarshaler{}, `{"i64":null}`, &pb.KnownTypes{I64: nil}}, | ||||
| 	{"null UInt64Value", Unmarshaler{}, `{"u64":null}`, &pb.KnownTypes{U64: nil}}, | ||||
| 	{"null Int32Value", Unmarshaler{}, `{"i32":null}`, &pb.KnownTypes{I32: nil}}, | ||||
| 	{"null UInt32Value", Unmarshaler{}, `{"u32":null}`, &pb.KnownTypes{U32: nil}}, | ||||
| 	{"null BoolValue", Unmarshaler{}, `{"bool":null}`, &pb.KnownTypes{Bool: nil}}, | ||||
| 	{"null StringValue", Unmarshaler{}, `{"str":null}`, &pb.KnownTypes{Str: nil}}, | ||||
| 	{"null BytesValue", Unmarshaler{}, `{"bytes":null}`, &pb.KnownTypes{Bytes: nil}}, | ||||
| 	{"required", Unmarshaler{}, `{"str":"hello"}`, &pb.MsgWithRequired{Str: proto.String("hello")}}, | ||||
| 	{"required bytes", Unmarshaler{}, `{"byts": []}`, &pb.MsgWithRequiredBytes{Byts: []byte{}}}, | ||||
| 	// `null` is also a permissible value. Let's just test one. | ||||
| 	{"null DoubleValue", Unmarshaler{}, `{"dbl":null}`, &pb.KnownTypes{Dbl: &types.DoubleValue{}}}, | ||||
| } | ||||
|  | ||||
| func TestUnmarshaling(t *testing.T) { | ||||
| @@ -878,7 +488,7 @@ func TestUnmarshaling(t *testing.T) { | ||||
|  | ||||
| 		err := tt.unmarshaler.Unmarshal(strings.NewReader(tt.json), p) | ||||
| 		if err != nil { | ||||
| 			t.Errorf("unmarshalling %s: %v", tt.desc, err) | ||||
| 			t.Errorf("%s: %v", tt.desc, err) | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| @@ -891,26 +501,6 @@ func TestUnmarshaling(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestUnmarshalNullArray(t *testing.T) { | ||||
| 	var repeats pb.Repeats | ||||
| 	if err := UnmarshalString(`{"rBool":null}`, &repeats); err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if !reflect.DeepEqual(repeats, pb.Repeats{}) { | ||||
| 		t.Errorf("got non-nil fields in [%#v]", repeats) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestUnmarshalNullObject(t *testing.T) { | ||||
| 	var maps pb.Maps | ||||
| 	if err := UnmarshalString(`{"mInt64Str":null}`, &maps); err != nil { | ||||
| 		t.Fatal(err) | ||||
| 	} | ||||
| 	if !reflect.DeepEqual(maps, pb.Maps{}) { | ||||
| 		t.Errorf("got non-nil fields in [%#v]", maps) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestUnmarshalNext(t *testing.T) { | ||||
| 	// We only need to check against a few, not all of them. | ||||
| 	tests := unmarshalingTests[:5] | ||||
| @@ -956,11 +546,6 @@ var unmarshalingShouldError = []struct { | ||||
| 	{"gibberish", "{adskja123;l23=-=", new(pb.Simple)}, | ||||
| 	{"unknown field", `{"unknown": "foo"}`, new(pb.Simple)}, | ||||
| 	{"unknown enum name", `{"hilarity":"DAVE"}`, new(proto3pb.Message)}, | ||||
| 	{"Duration containing invalid character", `{"dur": "3\U0073"}`, &pb.KnownTypes{}}, | ||||
| 	{"Timestamp containing invalid character", `{"ts": "2014-05-13T16:53:20\U005a"}`, &pb.KnownTypes{}}, | ||||
| 	{"StringValue containing invalid character", `{"str": "\U00004E16\U0000754C"}`, &pb.KnownTypes{}}, | ||||
| 	{"StructValue containing invalid character", `{"str": "\U00004E16\U0000754C"}`, &types.Struct{}}, | ||||
| 	{"repeated proto3 enum with non array input", `{"rFunny":"PUNS"}`, &proto3pb.Message{RFunny: []proto3pb.Message_Humour{}}}, | ||||
| } | ||||
|  | ||||
| func TestUnmarshalingBadInput(t *testing.T) { | ||||
| @@ -971,287 +556,3 @@ func TestUnmarshalingBadInput(t *testing.T) { | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type funcResolver func(turl string) (proto.Message, error) | ||||
|  | ||||
| func (fn funcResolver) Resolve(turl string) (proto.Message, error) { | ||||
| 	return fn(turl) | ||||
| } | ||||
|  | ||||
| func TestAnyWithCustomResolver(t *testing.T) { | ||||
| 	var resolvedTypeUrls []string | ||||
| 	resolver := funcResolver(func(turl string) (proto.Message, error) { | ||||
| 		resolvedTypeUrls = append(resolvedTypeUrls, turl) | ||||
| 		return new(pb.Simple), nil | ||||
| 	}) | ||||
| 	msg := &pb.Simple{ | ||||
| 		OBytes:  []byte{1, 2, 3, 4}, | ||||
| 		OBool:   proto.Bool(true), | ||||
| 		OString: proto.String("foobar"), | ||||
| 		OInt64:  proto.Int64(1020304), | ||||
| 	} | ||||
| 	msgBytes, err := proto.Marshal(msg) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when marshaling message: %v", err) | ||||
| 	} | ||||
| 	// make an Any with a type URL that won't resolve w/out custom resolver | ||||
| 	any := &types.Any{ | ||||
| 		TypeUrl: "https://foobar.com/some.random.MessageKind", | ||||
| 		Value:   msgBytes, | ||||
| 	} | ||||
|  | ||||
| 	m := Marshaler{AnyResolver: resolver} | ||||
| 	js, err := m.MarshalToString(any) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when marshaling any to JSON: %v", err) | ||||
| 	} | ||||
| 	if len(resolvedTypeUrls) != 1 { | ||||
| 		t.Errorf("custom resolver was not invoked during marshaling") | ||||
| 	} else if resolvedTypeUrls[0] != "https://foobar.com/some.random.MessageKind" { | ||||
| 		t.Errorf("custom resolver was invoked with wrong URL: got %q, wanted %q", resolvedTypeUrls[0], "https://foobar.com/some.random.MessageKind") | ||||
| 	} | ||||
| 	wanted := `{"@type":"https://foobar.com/some.random.MessageKind","oBool":true,"oInt64":"1020304","oString":"foobar","oBytes":"AQIDBA=="}` | ||||
| 	if js != wanted { | ||||
| 		t.Errorf("marshalling JSON produced incorrect output: got %s, wanted %s", js, wanted) | ||||
| 	} | ||||
|  | ||||
| 	u := Unmarshaler{AnyResolver: resolver} | ||||
| 	roundTrip := &types.Any{} | ||||
| 	err = u.Unmarshal(bytes.NewReader([]byte(js)), roundTrip) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when unmarshaling any from JSON: %v", err) | ||||
| 	} | ||||
| 	if len(resolvedTypeUrls) != 2 { | ||||
| 		t.Errorf("custom resolver was not invoked during marshaling") | ||||
| 	} else if resolvedTypeUrls[1] != "https://foobar.com/some.random.MessageKind" { | ||||
| 		t.Errorf("custom resolver was invoked with wrong URL: got %q, wanted %q", resolvedTypeUrls[1], "https://foobar.com/some.random.MessageKind") | ||||
| 	} | ||||
| 	if !proto.Equal(any, roundTrip) { | ||||
| 		t.Errorf("message contents not set correctly after unmarshalling JSON: got %s, wanted %s", roundTrip, any) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestUnmarshalJSONPBUnmarshaler(t *testing.T) { | ||||
| 	rawJson := `{ "foo": "bar", "baz": [0, 1, 2, 3] }` | ||||
| 	var msg dynamicMessage | ||||
| 	if err := Unmarshal(strings.NewReader(rawJson), &msg); err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when parsing into JSONPBUnmarshaler: %v", err) | ||||
| 	} | ||||
| 	if msg.RawJson != rawJson { | ||||
| 		t.Errorf("message contents not set correctly after unmarshalling JSON: got %s, wanted %s", msg.RawJson, rawJson) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestUnmarshalNullWithJSONPBUnmarshaler(t *testing.T) { | ||||
| 	rawJson := `{"stringField":null}` | ||||
| 	var ptrFieldMsg ptrFieldMessage | ||||
| 	if err := Unmarshal(strings.NewReader(rawJson), &ptrFieldMsg); err != nil { | ||||
| 		t.Errorf("unmarshal error: %v", err) | ||||
| 	} | ||||
|  | ||||
| 	want := ptrFieldMessage{StringField: &stringField{IsSet: true, StringValue: "null"}} | ||||
| 	if !proto.Equal(&ptrFieldMsg, &want) { | ||||
| 		t.Errorf("unmarshal result StringField: got %v, want %v", ptrFieldMsg, want) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestUnmarshalAnyJSONPBUnmarshaler(t *testing.T) { | ||||
| 	rawJson := `{ "@type": "blah.com/` + dynamicMessageName + `", "foo": "bar", "baz": [0, 1, 2, 3] }` | ||||
| 	var got types.Any | ||||
| 	if err := Unmarshal(strings.NewReader(rawJson), &got); err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when parsing into JSONPBUnmarshaler: %v", err) | ||||
| 	} | ||||
|  | ||||
| 	dm := &dynamicMessage{RawJson: `{"baz":[0,1,2,3],"foo":"bar"}`} | ||||
| 	var want types.Any | ||||
| 	if b, err := proto.Marshal(dm); err != nil { | ||||
| 		t.Errorf("an unexpected error occurred when marshaling message: %v", err) | ||||
| 	} else { | ||||
| 		want.TypeUrl = "blah.com/" + dynamicMessageName | ||||
| 		want.Value = b | ||||
| 	} | ||||
|  | ||||
| 	if !proto.Equal(&got, &want) { | ||||
| 		t.Errorf("message contents not set correctly after unmarshalling JSON: got %v, wanted %v", got, want) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| const ( | ||||
| 	dynamicMessageName = "google.protobuf.jsonpb.testing.dynamicMessage" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	// we register the custom type below so that we can use it in Any types | ||||
| 	proto.RegisterType((*dynamicMessage)(nil), dynamicMessageName) | ||||
| } | ||||
|  | ||||
| type ptrFieldMessage struct { | ||||
| 	StringField *stringField `protobuf:"bytes,1,opt,name=stringField"` | ||||
| } | ||||
|  | ||||
| func (m *ptrFieldMessage) Reset() { | ||||
| } | ||||
|  | ||||
| func (m *ptrFieldMessage) String() string { | ||||
| 	return m.StringField.StringValue | ||||
| } | ||||
|  | ||||
| func (m *ptrFieldMessage) ProtoMessage() { | ||||
| } | ||||
|  | ||||
| type stringField struct { | ||||
| 	IsSet       bool   `protobuf:"varint,1,opt,name=isSet"` | ||||
| 	StringValue string `protobuf:"bytes,2,opt,name=stringValue"` | ||||
| } | ||||
|  | ||||
| func (s *stringField) Reset() { | ||||
| } | ||||
|  | ||||
| func (s *stringField) String() string { | ||||
| 	return s.StringValue | ||||
| } | ||||
|  | ||||
| func (s *stringField) ProtoMessage() { | ||||
| } | ||||
|  | ||||
| func (s *stringField) UnmarshalJSONPB(jum *Unmarshaler, js []byte) error { | ||||
| 	s.IsSet = true | ||||
| 	s.StringValue = string(js) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // dynamicMessage implements protobuf.Message but is not a normal generated message type. | ||||
| // It provides implementations of JSONPBMarshaler and JSONPBUnmarshaler for JSON support. | ||||
| type dynamicMessage struct { | ||||
| 	RawJson string `protobuf:"bytes,1,opt,name=rawJson"` | ||||
|  | ||||
| 	// an unexported nested message is present just to ensure that it | ||||
| 	// won't result in a panic (see issue #509) | ||||
| 	Dummy *dynamicMessage `protobuf:"bytes,2,opt,name=dummy"` | ||||
| } | ||||
|  | ||||
| func (m *dynamicMessage) Reset() { | ||||
| 	m.RawJson = "{}" | ||||
| } | ||||
|  | ||||
| func (m *dynamicMessage) String() string { | ||||
| 	return m.RawJson | ||||
| } | ||||
|  | ||||
| func (m *dynamicMessage) ProtoMessage() { | ||||
| } | ||||
|  | ||||
| func (m *dynamicMessage) MarshalJSONPB(jm *Marshaler) ([]byte, error) { | ||||
| 	return []byte(m.RawJson), nil | ||||
| } | ||||
|  | ||||
| func (m *dynamicMessage) UnmarshalJSONPB(jum *Unmarshaler, js []byte) error { | ||||
| 	m.RawJson = string(js) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Test unmarshaling message containing unset required fields should produce error. | ||||
| func TestUnmarshalUnsetRequiredFields(t *testing.T) { | ||||
| 	tests := []struct { | ||||
| 		desc string | ||||
| 		pb   proto.Message | ||||
| 		json string | ||||
| 	}{ | ||||
| 		{ | ||||
| 			desc: "direct required field missing", | ||||
| 			pb:   &pb.MsgWithRequired{}, | ||||
| 			json: `{}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "direct required field set to null", | ||||
| 			pb:   &pb.MsgWithRequired{}, | ||||
| 			json: `{"str": null}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "indirect required field missing", | ||||
| 			pb:   &pb.MsgWithIndirectRequired{}, | ||||
| 			json: `{"subm": {}}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "indirect required field set to null", | ||||
| 			pb:   &pb.MsgWithIndirectRequired{}, | ||||
| 			json: `{"subm": {"str": null}}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "direct required bytes field missing", | ||||
| 			pb:   &pb.MsgWithRequiredBytes{}, | ||||
| 			json: `{}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "direct required bytes field set to null", | ||||
| 			pb:   &pb.MsgWithRequiredBytes{}, | ||||
| 			json: `{"byts": null}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "direct required wkt field missing", | ||||
| 			pb:   &pb.MsgWithRequiredWKT{}, | ||||
| 			json: `{}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "direct required wkt field set to null", | ||||
| 			pb:   &pb.MsgWithRequiredWKT{}, | ||||
| 			json: `{"str": null}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "any containing message with required field set to null", | ||||
| 			pb:   &pb.KnownTypes{}, | ||||
| 			json: `{"an": {"@type": "example.com/jsonpb.MsgWithRequired", "str": null}}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "any containing message with missing required field", | ||||
| 			pb:   &pb.KnownTypes{}, | ||||
| 			json: `{"an": {"@type": "example.com/jsonpb.MsgWithRequired"}}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "missing required in map value", | ||||
| 			pb:   &pb.MsgWithIndirectRequired{}, | ||||
| 			json: `{"map_field": {"a": {}, "b": {"str": "hi"}}}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "required in map value set to null", | ||||
| 			pb:   &pb.MsgWithIndirectRequired{}, | ||||
| 			json: `{"map_field": {"a": {"str": "hello"}, "b": {"str": null}}}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "missing required in slice item", | ||||
| 			pb:   &pb.MsgWithIndirectRequired{}, | ||||
| 			json: `{"slice_field": [{}, {"str": "hi"}]}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "required in slice item set to null", | ||||
| 			pb:   &pb.MsgWithIndirectRequired{}, | ||||
| 			json: `{"slice_field": [{"str": "hello"}, {"str": null}]}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "required inside oneof missing", | ||||
| 			pb:   &pb.MsgWithOneof{}, | ||||
| 			json: `{"msgWithRequired": {}}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "required inside oneof set to null", | ||||
| 			pb:   &pb.MsgWithOneof{}, | ||||
| 			json: `{"msgWithRequired": {"str": null}}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "required field in extension missing", | ||||
| 			pb:   &pb.Real{}, | ||||
| 			json: `{"[jsonpb.extm]":{}}`, | ||||
| 		}, | ||||
| 		{ | ||||
| 			desc: "required field in extension set to null", | ||||
| 			pb:   &pb.Real{}, | ||||
| 			json: `{"[jsonpb.extm]":{"str": null}}`, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	for _, tc := range tests { | ||||
| 		if err := UnmarshalString(tc.json, tc.pb); err == nil { | ||||
| 			t.Errorf("%s: expecting error in unmarshaling with unset required fields %s", tc.desc, tc.json) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										317
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										317
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,13 +1,31 @@ | ||||
| // Code generated by protoc-gen-gogo. DO NOT EDIT. | ||||
| // Code generated by protoc-gen-gogo. | ||||
| // source: more_test_objects.proto | ||||
| // DO NOT EDIT! | ||||
|  | ||||
| /* | ||||
| Package jsonpb is a generated protocol buffer package. | ||||
|  | ||||
| It is generated from these files: | ||||
| 	more_test_objects.proto | ||||
| 	test_objects.proto | ||||
|  | ||||
| It has these top-level messages: | ||||
| 	Simple3 | ||||
| 	Mappy | ||||
| 	Simple | ||||
| 	Repeats | ||||
| 	Widget | ||||
| 	Maps | ||||
| 	MsgWithOneof | ||||
| 	Real | ||||
| 	Complex | ||||
| 	KnownTypes | ||||
| */ | ||||
| package jsonpb | ||||
|  | ||||
| import ( | ||||
| 	fmt "fmt" | ||||
| 	proto "github.com/gogo/protobuf/proto" | ||||
| 	math "math" | ||||
| ) | ||||
| import proto "github.com/gogo/protobuf/proto" | ||||
| import fmt "fmt" | ||||
| import math "math" | ||||
|  | ||||
| // Reference imports to suppress errors if they are not otherwise used. | ||||
| var _ = proto.Marshal | ||||
| @@ -18,7 +36,7 @@ var _ = math.Inf | ||||
| // is compatible with the proto package it is being compiled against. | ||||
| // A compilation error at this line likely means your copy of the | ||||
| // proto package needs to be updated. | ||||
| const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package | ||||
| const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package | ||||
|  | ||||
| type Numeral int32 | ||||
|  | ||||
| @@ -33,7 +51,6 @@ var Numeral_name = map[int32]string{ | ||||
| 	1: "ARABIC", | ||||
| 	2: "ROMAN", | ||||
| } | ||||
|  | ||||
| var Numeral_value = map[string]int32{ | ||||
| 	"UNKNOWN": 0, | ||||
| 	"ARABIC":  1, | ||||
| @@ -43,41 +60,16 @@ var Numeral_value = map[string]int32{ | ||||
| func (x Numeral) String() string { | ||||
| 	return proto.EnumName(Numeral_name, int32(x)) | ||||
| } | ||||
|  | ||||
| func (Numeral) EnumDescriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_e6c135db3023e377, []int{0} | ||||
| } | ||||
| func (Numeral) EnumDescriptor() ([]byte, []int) { return fileDescriptorMoreTestObjects, []int{0} } | ||||
|  | ||||
| type Simple3 struct { | ||||
| 	Dub                  float64  `protobuf:"fixed64,1,opt,name=dub,proto3" json:"dub,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{} `json:"-"` | ||||
| 	XXX_unrecognized     []byte   `json:"-"` | ||||
| 	XXX_sizecache        int32    `json:"-"` | ||||
| 	Dub float64 `protobuf:"fixed64,1,opt,name=dub,proto3" json:"dub,omitempty"` | ||||
| } | ||||
|  | ||||
| func (m *Simple3) Reset()         { *m = Simple3{} } | ||||
| func (m *Simple3) String() string { return proto.CompactTextString(m) } | ||||
| func (*Simple3) ProtoMessage()    {} | ||||
| func (*Simple3) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_e6c135db3023e377, []int{0} | ||||
| } | ||||
| func (m *Simple3) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_Simple3.Unmarshal(m, b) | ||||
| } | ||||
| func (m *Simple3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_Simple3.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *Simple3) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_Simple3.Merge(m, src) | ||||
| } | ||||
| func (m *Simple3) XXX_Size() int { | ||||
| 	return xxx_messageInfo_Simple3.Size(m) | ||||
| } | ||||
| func (m *Simple3) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_Simple3.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_Simple3 proto.InternalMessageInfo | ||||
| func (m *Simple3) Reset()                    { *m = Simple3{} } | ||||
| func (m *Simple3) String() string            { return proto.CompactTextString(m) } | ||||
| func (*Simple3) ProtoMessage()               {} | ||||
| func (*Simple3) Descriptor() ([]byte, []int) { return fileDescriptorMoreTestObjects, []int{0} } | ||||
|  | ||||
| func (m *Simple3) GetDub() float64 { | ||||
| 	if m != nil { | ||||
| @@ -86,159 +78,23 @@ func (m *Simple3) GetDub() float64 { | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| type SimpleSlice3 struct { | ||||
| 	Slices               []string `protobuf:"bytes,1,rep,name=slices,proto3" json:"slices,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{} `json:"-"` | ||||
| 	XXX_unrecognized     []byte   `json:"-"` | ||||
| 	XXX_sizecache        int32    `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *SimpleSlice3) Reset()         { *m = SimpleSlice3{} } | ||||
| func (m *SimpleSlice3) String() string { return proto.CompactTextString(m) } | ||||
| func (*SimpleSlice3) ProtoMessage()    {} | ||||
| func (*SimpleSlice3) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_e6c135db3023e377, []int{1} | ||||
| } | ||||
| func (m *SimpleSlice3) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_SimpleSlice3.Unmarshal(m, b) | ||||
| } | ||||
| func (m *SimpleSlice3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_SimpleSlice3.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *SimpleSlice3) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_SimpleSlice3.Merge(m, src) | ||||
| } | ||||
| func (m *SimpleSlice3) XXX_Size() int { | ||||
| 	return xxx_messageInfo_SimpleSlice3.Size(m) | ||||
| } | ||||
| func (m *SimpleSlice3) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_SimpleSlice3.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_SimpleSlice3 proto.InternalMessageInfo | ||||
|  | ||||
| func (m *SimpleSlice3) GetSlices() []string { | ||||
| 	if m != nil { | ||||
| 		return m.Slices | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| type SimpleMap3 struct { | ||||
| 	Stringy              map[string]string `protobuf:"bytes,1,rep,name=stringy,proto3" json:"stringy,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	XXX_NoUnkeyedLiteral struct{}          `json:"-"` | ||||
| 	XXX_unrecognized     []byte            `json:"-"` | ||||
| 	XXX_sizecache        int32             `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *SimpleMap3) Reset()         { *m = SimpleMap3{} } | ||||
| func (m *SimpleMap3) String() string { return proto.CompactTextString(m) } | ||||
| func (*SimpleMap3) ProtoMessage()    {} | ||||
| func (*SimpleMap3) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_e6c135db3023e377, []int{2} | ||||
| } | ||||
| func (m *SimpleMap3) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_SimpleMap3.Unmarshal(m, b) | ||||
| } | ||||
| func (m *SimpleMap3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_SimpleMap3.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *SimpleMap3) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_SimpleMap3.Merge(m, src) | ||||
| } | ||||
| func (m *SimpleMap3) XXX_Size() int { | ||||
| 	return xxx_messageInfo_SimpleMap3.Size(m) | ||||
| } | ||||
| func (m *SimpleMap3) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_SimpleMap3.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_SimpleMap3 proto.InternalMessageInfo | ||||
|  | ||||
| func (m *SimpleMap3) GetStringy() map[string]string { | ||||
| 	if m != nil { | ||||
| 		return m.Stringy | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| type SimpleNull3 struct { | ||||
| 	Simple               *Simple3 `protobuf:"bytes,1,opt,name=simple,proto3" json:"simple,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{} `json:"-"` | ||||
| 	XXX_unrecognized     []byte   `json:"-"` | ||||
| 	XXX_sizecache        int32    `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *SimpleNull3) Reset()         { *m = SimpleNull3{} } | ||||
| func (m *SimpleNull3) String() string { return proto.CompactTextString(m) } | ||||
| func (*SimpleNull3) ProtoMessage()    {} | ||||
| func (*SimpleNull3) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_e6c135db3023e377, []int{3} | ||||
| } | ||||
| func (m *SimpleNull3) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_SimpleNull3.Unmarshal(m, b) | ||||
| } | ||||
| func (m *SimpleNull3) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_SimpleNull3.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *SimpleNull3) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_SimpleNull3.Merge(m, src) | ||||
| } | ||||
| func (m *SimpleNull3) XXX_Size() int { | ||||
| 	return xxx_messageInfo_SimpleNull3.Size(m) | ||||
| } | ||||
| func (m *SimpleNull3) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_SimpleNull3.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_SimpleNull3 proto.InternalMessageInfo | ||||
|  | ||||
| func (m *SimpleNull3) GetSimple() *Simple3 { | ||||
| 	if m != nil { | ||||
| 		return m.Simple | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| type Mappy struct { | ||||
| 	Nummy                map[int64]int32    `protobuf:"bytes,1,rep,name=nummy,proto3" json:"nummy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	Strry                map[string]string  `protobuf:"bytes,2,rep,name=strry,proto3" json:"strry,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	Objjy                map[int32]*Simple3 `protobuf:"bytes,3,rep,name=objjy,proto3" json:"objjy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	Buggy                map[int64]string   `protobuf:"bytes,4,rep,name=buggy,proto3" json:"buggy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	Booly                map[bool]bool      `protobuf:"bytes,5,rep,name=booly,proto3" json:"booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	Enumy                map[string]Numeral `protobuf:"bytes,6,rep,name=enumy,proto3" json:"enumy,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=jsonpb.Numeral"` | ||||
| 	S32Booly             map[int32]bool     `protobuf:"bytes,7,rep,name=s32booly,proto3" json:"s32booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	S64Booly             map[int64]bool     `protobuf:"bytes,8,rep,name=s64booly,proto3" json:"s64booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	U32Booly             map[uint32]bool    `protobuf:"bytes,9,rep,name=u32booly,proto3" json:"u32booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	U64Booly             map[uint64]bool    `protobuf:"bytes,10,rep,name=u64booly,proto3" json:"u64booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	XXX_NoUnkeyedLiteral struct{}           `json:"-"` | ||||
| 	XXX_unrecognized     []byte             `json:"-"` | ||||
| 	XXX_sizecache        int32              `json:"-"` | ||||
| 	Nummy    map[int64]int32    `protobuf:"bytes,1,rep,name=nummy" json:"nummy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	Strry    map[string]string  `protobuf:"bytes,2,rep,name=strry" json:"strry,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	Objjy    map[int32]*Simple3 `protobuf:"bytes,3,rep,name=objjy" json:"objjy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"` | ||||
| 	Buggy    map[int64]string   `protobuf:"bytes,4,rep,name=buggy" json:"buggy,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	Booly    map[bool]bool      `protobuf:"bytes,5,rep,name=booly" json:"booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	Enumy    map[string]Numeral `protobuf:"bytes,6,rep,name=enumy" json:"enumy,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=jsonpb.Numeral"` | ||||
| 	S32Booly map[int32]bool     `protobuf:"bytes,7,rep,name=s32booly" json:"s32booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	S64Booly map[int64]bool     `protobuf:"bytes,8,rep,name=s64booly" json:"s64booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	U32Booly map[uint32]bool    `protobuf:"bytes,9,rep,name=u32booly" json:"u32booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	U64Booly map[uint64]bool    `protobuf:"bytes,10,rep,name=u64booly" json:"u64booly,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| } | ||||
|  | ||||
| func (m *Mappy) Reset()         { *m = Mappy{} } | ||||
| func (m *Mappy) String() string { return proto.CompactTextString(m) } | ||||
| func (*Mappy) ProtoMessage()    {} | ||||
| func (*Mappy) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_e6c135db3023e377, []int{4} | ||||
| } | ||||
| func (m *Mappy) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_Mappy.Unmarshal(m, b) | ||||
| } | ||||
| func (m *Mappy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_Mappy.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *Mappy) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_Mappy.Merge(m, src) | ||||
| } | ||||
| func (m *Mappy) XXX_Size() int { | ||||
| 	return xxx_messageInfo_Mappy.Size(m) | ||||
| } | ||||
| func (m *Mappy) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_Mappy.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_Mappy proto.InternalMessageInfo | ||||
| func (m *Mappy) Reset()                    { *m = Mappy{} } | ||||
| func (m *Mappy) String() string            { return proto.CompactTextString(m) } | ||||
| func (*Mappy) ProtoMessage()               {} | ||||
| func (*Mappy) Descriptor() ([]byte, []int) { return fileDescriptorMoreTestObjects, []int{1} } | ||||
|  | ||||
| func (m *Mappy) GetNummy() map[int64]int32 { | ||||
| 	if m != nil { | ||||
| @@ -311,60 +167,41 @@ func (m *Mappy) GetU64Booly() map[uint64]bool { | ||||
| } | ||||
|  | ||||
| func init() { | ||||
| 	proto.RegisterEnum("jsonpb.Numeral", Numeral_name, Numeral_value) | ||||
| 	proto.RegisterType((*Simple3)(nil), "jsonpb.Simple3") | ||||
| 	proto.RegisterType((*SimpleSlice3)(nil), "jsonpb.SimpleSlice3") | ||||
| 	proto.RegisterType((*SimpleMap3)(nil), "jsonpb.SimpleMap3") | ||||
| 	proto.RegisterMapType((map[string]string)(nil), "jsonpb.SimpleMap3.StringyEntry") | ||||
| 	proto.RegisterType((*SimpleNull3)(nil), "jsonpb.SimpleNull3") | ||||
| 	proto.RegisterType((*Mappy)(nil), "jsonpb.Mappy") | ||||
| 	proto.RegisterMapType((map[bool]bool)(nil), "jsonpb.Mappy.BoolyEntry") | ||||
| 	proto.RegisterMapType((map[int64]string)(nil), "jsonpb.Mappy.BuggyEntry") | ||||
| 	proto.RegisterMapType((map[string]Numeral)(nil), "jsonpb.Mappy.EnumyEntry") | ||||
| 	proto.RegisterMapType((map[int64]int32)(nil), "jsonpb.Mappy.NummyEntry") | ||||
| 	proto.RegisterMapType((map[int32]*Simple3)(nil), "jsonpb.Mappy.ObjjyEntry") | ||||
| 	proto.RegisterMapType((map[int32]bool)(nil), "jsonpb.Mappy.S32boolyEntry") | ||||
| 	proto.RegisterMapType((map[int64]bool)(nil), "jsonpb.Mappy.S64boolyEntry") | ||||
| 	proto.RegisterMapType((map[string]string)(nil), "jsonpb.Mappy.StrryEntry") | ||||
| 	proto.RegisterMapType((map[uint32]bool)(nil), "jsonpb.Mappy.U32boolyEntry") | ||||
| 	proto.RegisterMapType((map[uint64]bool)(nil), "jsonpb.Mappy.U64boolyEntry") | ||||
| 	proto.RegisterEnum("jsonpb.Numeral", Numeral_name, Numeral_value) | ||||
| } | ||||
|  | ||||
| func init() { proto.RegisterFile("more_test_objects.proto", fileDescriptor_e6c135db3023e377) } | ||||
| func init() { proto.RegisterFile("more_test_objects.proto", fileDescriptorMoreTestObjects) } | ||||
|  | ||||
| var fileDescriptor_e6c135db3023e377 = []byte{ | ||||
| 	// 526 bytes of a gzipped FileDescriptorProto | ||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xdd, 0x6b, 0xdb, 0x3c, | ||||
| 	0x14, 0x87, 0x5f, 0x27, 0xf5, 0xd7, 0x49, 0xfb, 0x2e, 0x88, 0xb1, 0x99, 0xf4, 0x62, 0xc5, 0xb0, | ||||
| 	0xad, 0x0c, 0xe6, 0x8b, 0x78, 0x74, 0x5d, 0x77, 0x95, 0x8e, 0x5e, 0x94, 0x11, 0x07, 0x1c, 0xc2, | ||||
| 	0x2e, 0x4b, 0xdc, 0x99, 0x90, 0xcc, 0x5f, 0xd8, 0xd6, 0xc0, 0xd7, 0xfb, 0xbb, 0x07, 0xe3, 0x48, | ||||
| 	0x72, 0x2d, 0x07, 0x85, 0x6c, 0x77, 0x52, 0x7e, 0xcf, 0xe3, 0x73, 0x24, 0x1d, 0x02, 0x2f, 0xd3, | ||||
| 	0xbc, 0x8c, 0x1f, 0xea, 0xb8, 0xaa, 0x1f, 0xf2, 0x68, 0x17, 0x3f, 0xd6, 0x95, 0x57, 0x94, 0x79, | ||||
| 	0x9d, 0x13, 0x63, 0x57, 0xe5, 0x59, 0x11, 0xb9, 0xe7, 0x60, 0x2e, 0xb7, 0x69, 0x91, 0xc4, 0x3e, | ||||
| 	0x19, 0xc3, 0xf0, 0x3b, 0x8d, 0x1c, 0xed, 0x42, 0xbb, 0xd4, 0x42, 0x5c, 0xba, 0x6f, 0xe0, 0x94, | ||||
| 	0x87, 0xcb, 0x64, 0xfb, 0x18, 0xfb, 0xe4, 0x05, 0x18, 0x15, 0xae, 0x2a, 0x47, 0xbb, 0x18, 0x5e, | ||||
| 	0xda, 0xa1, 0xd8, 0xb9, 0xbf, 0x34, 0x00, 0x0e, 0xce, 0xd7, 0x85, 0x4f, 0x3e, 0x81, 0x59, 0xd5, | ||||
| 	0xe5, 0x36, 0xdb, 0x34, 0x8c, 0x1b, 0x4d, 0x5f, 0x79, 0xbc, 0x9a, 0xd7, 0x41, 0xde, 0x92, 0x13, | ||||
| 	0x77, 0x59, 0x5d, 0x36, 0x61, 0xcb, 0x4f, 0x6e, 0xe0, 0x54, 0x0e, 0xb0, 0xa7, 0x1f, 0x71, 0xc3, | ||||
| 	0x7a, 0xb2, 0x43, 0x5c, 0x92, 0xe7, 0xa0, 0xff, 0x5c, 0x27, 0x34, 0x76, 0x06, 0xec, 0x37, 0xbe, | ||||
| 	0xb9, 0x19, 0x5c, 0x6b, 0xee, 0x15, 0x8c, 0xf8, 0xf7, 0x03, 0x9a, 0x24, 0x3e, 0x79, 0x0b, 0x46, | ||||
| 	0xc5, 0xb6, 0xcc, 0x1e, 0x4d, 0x9f, 0xf5, 0x9b, 0xf0, 0x43, 0x11, 0xbb, 0xbf, 0x2d, 0xd0, 0xe7, | ||||
| 	0xeb, 0xa2, 0x68, 0x88, 0x07, 0x7a, 0x46, 0xd3, 0xb4, 0x6d, 0xdb, 0x69, 0x0d, 0x96, 0x7a, 0x01, | ||||
| 	0x46, 0xbc, 0x5f, 0x8e, 0x21, 0x5f, 0xd5, 0x65, 0xd9, 0x38, 0x03, 0x15, 0xbf, 0xc4, 0x48, 0xf0, | ||||
| 	0x0c, 0x43, 0x3e, 0x8f, 0x76, 0xbb, 0xc6, 0x19, 0xaa, 0xf8, 0x05, 0x46, 0x82, 0x67, 0x18, 0xf2, | ||||
| 	0x11, 0xdd, 0x6c, 0x1a, 0xe7, 0x44, 0xc5, 0xdf, 0x62, 0x24, 0x78, 0x86, 0x31, 0x3e, 0xcf, 0x93, | ||||
| 	0xc6, 0xd1, 0x95, 0x3c, 0x46, 0x2d, 0x8f, 0x6b, 0xe4, 0xe3, 0x8c, 0xa6, 0x8d, 0x63, 0xa8, 0xf8, | ||||
| 	0x3b, 0x8c, 0x04, 0xcf, 0x30, 0xf2, 0x11, 0xac, 0xca, 0x9f, 0xf2, 0x12, 0x26, 0x53, 0xce, 0xf7, | ||||
| 	0x8e, 0x2c, 0x52, 0x6e, 0x3d, 0xc1, 0x4c, 0xbc, 0xfa, 0xc0, 0x45, 0x4b, 0x29, 0x8a, 0xb4, 0x15, | ||||
| 	0xc5, 0x16, 0x45, 0xda, 0x56, 0xb4, 0x55, 0xe2, 0xaa, 0x5f, 0x91, 0x4a, 0x15, 0x69, 0x5b, 0x11, | ||||
| 	0x94, 0x62, 0xbf, 0x62, 0x0b, 0x4f, 0xae, 0x01, 0xba, 0x87, 0x96, 0xe7, 0x6f, 0xa8, 0x98, 0x3f, | ||||
| 	0x5d, 0x9a, 0x3f, 0x34, 0xbb, 0x27, 0xff, 0x97, 0xc9, 0x9d, 0xdc, 0x03, 0x74, 0x8f, 0x2f, 0x9b, | ||||
| 	0x3a, 0x37, 0x5f, 0xcb, 0xa6, 0x62, 0x92, 0xfb, 0x4d, 0x74, 0x73, 0x71, 0xac, 0x7d, 0x7b, 0xdf, | ||||
| 	0x7c, 0xba, 0x10, 0xd9, 0xb4, 0x14, 0xa6, 0xb5, 0xd7, 0x7e, 0x37, 0x2b, 0x8a, 0x83, 0xf7, 0xda, | ||||
| 	0xff, 0xbf, 0x6b, 0x3f, 0xa0, 0x69, 0x5c, 0xae, 0x13, 0xf9, 0x53, 0x9f, 0xe1, 0xac, 0x37, 0x43, | ||||
| 	0x8a, 0xcb, 0x38, 0xdc, 0x07, 0xca, 0xf2, 0xab, 0x1e, 0x3b, 0xfe, 0xbe, 0xbc, 0x3a, 0x54, 0xf9, | ||||
| 	0xec, 0x6f, 0xe4, 0x43, 0x95, 0x4f, 0x8e, 0xc8, 0xef, 0xde, 0x83, 0x29, 0x6e, 0x82, 0x8c, 0xc0, | ||||
| 	0x5c, 0x05, 0x5f, 0x83, 0xc5, 0xb7, 0x60, 0xfc, 0x1f, 0x01, 0x30, 0x66, 0xe1, 0xec, 0xf6, 0xfe, | ||||
| 	0xcb, 0x58, 0x23, 0x36, 0xe8, 0xe1, 0x62, 0x3e, 0x0b, 0xc6, 0x83, 0xc8, 0x60, 0x7f, 0xe0, 0xfe, | ||||
| 	0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x84, 0x34, 0xaf, 0xdb, 0x05, 0x00, 0x00, | ||||
| var fileDescriptorMoreTestObjects = []byte{ | ||||
| 	// 444 bytes of a gzipped FileDescriptorProto | ||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xc1, 0x6b, 0xdb, 0x30, | ||||
| 	0x14, 0x87, 0xe7, 0xa4, 0x4e, 0xec, 0x17, 0xba, 0x19, 0x31, 0x98, 0x58, 0x2f, 0xa1, 0x30, 0x08, | ||||
| 	0x83, 0xf9, 0x90, 0x8c, 0xad, 0x6c, 0xa7, 0x74, 0xf4, 0x50, 0x46, 0x1d, 0x70, 0x09, 0x3b, 0x96, | ||||
| 	0x78, 0x13, 0x65, 0x9e, 0x6d, 0x19, 0xdb, 0x1a, 0xe8, 0x8f, 0x1f, 0x8c, 0x27, 0xcb, 0xb5, 0x6c, | ||||
| 	0x14, 0xd2, 0x9b, 0xcc, 0xef, 0xfb, 0xf2, 0x9e, 0xf4, 0x1e, 0x81, 0x37, 0x39, 0xaf, 0xd8, 0x43, | ||||
| 	0xc3, 0xea, 0xe6, 0x81, 0x27, 0x29, 0xfb, 0xd9, 0xd4, 0x61, 0x59, 0xf1, 0x86, 0x93, 0x59, 0x5a, | ||||
| 	0xf3, 0xa2, 0x4c, 0x2e, 0x2f, 0x60, 0x7e, 0xff, 0x3b, 0x2f, 0x33, 0xb6, 0x21, 0x01, 0x4c, 0x7f, | ||||
| 	0x89, 0x84, 0x3a, 0x4b, 0x67, 0xe5, 0xc4, 0x78, 0xbc, 0xfc, 0xe7, 0x81, 0x7b, 0x77, 0x28, 0x4b, | ||||
| 	0x49, 0x42, 0x70, 0x0b, 0x91, 0xe7, 0x92, 0x3a, 0xcb, 0xe9, 0x6a, 0xb1, 0xa6, 0x61, 0xab, 0x87, | ||||
| 	0x2a, 0x0d, 0x23, 0x8c, 0x6e, 0x8a, 0xa6, 0x92, 0x71, 0x8b, 0x21, 0x5f, 0x37, 0x55, 0x25, 0xe9, | ||||
| 	0xc4, 0xc6, 0xdf, 0x63, 0xa4, 0x79, 0x85, 0x21, 0xcf, 0x93, 0x34, 0x95, 0x74, 0x6a, 0xe3, 0x77, | ||||
| 	0x18, 0x69, 0x5e, 0x61, 0xc8, 0x27, 0xe2, 0xf1, 0x51, 0xd2, 0x33, 0x1b, 0x7f, 0x8d, 0x91, 0xe6, | ||||
| 	0x15, 0xa6, 0x78, 0xce, 0x33, 0x49, 0x5d, 0x2b, 0x8f, 0x51, 0xc7, 0xe3, 0x19, 0x79, 0x56, 0x88, | ||||
| 	0x5c, 0xd2, 0x99, 0x8d, 0xbf, 0xc1, 0x48, 0xf3, 0x0a, 0x23, 0x9f, 0xc1, 0xab, 0x37, 0xeb, 0xb6, | ||||
| 	0xc4, 0x5c, 0x29, 0x17, 0xa3, 0x2b, 0xeb, 0xb4, 0xb5, 0x9e, 0x60, 0x25, 0x7e, 0xfa, 0xd8, 0x8a, | ||||
| 	0x9e, 0x55, 0xd4, 0x69, 0x27, 0xea, 0x4f, 0x14, 0x45, 0x57, 0xd1, 0xb7, 0x89, 0xfb, 0x61, 0x45, | ||||
| 	0x61, 0x54, 0x14, 0x5d, 0x45, 0xb0, 0x8a, 0xc3, 0x8a, 0x1d, 0xfc, 0xf6, 0x0a, 0xa0, 0x1f, 0x34, | ||||
| 	0x6e, 0xcb, 0x1f, 0x26, 0xd5, 0xb6, 0x4c, 0x63, 0x3c, 0x92, 0xd7, 0xe0, 0xfe, 0x3d, 0x64, 0x82, | ||||
| 	0xd1, 0xc9, 0xd2, 0x59, 0xb9, 0x71, 0xfb, 0xf1, 0x65, 0x72, 0xe5, 0xa0, 0xd9, 0x8f, 0xdc, 0x34, | ||||
| 	0x7d, 0x8b, 0xe9, 0x9b, 0xe6, 0x2d, 0x40, 0x3f, 0x7c, 0xd3, 0x74, 0x5b, 0xf3, 0x9d, 0x69, 0x2e, | ||||
| 	0xd6, 0xaf, 0xba, 0x9b, 0xe8, 0x9d, 0x1e, 0x35, 0xd1, 0xef, 0xc5, 0xa9, 0xf6, 0xfd, 0xb1, 0xf9, | ||||
| 	0xf4, 0x20, 0xa6, 0xe9, 0x59, 0x4c, 0x6f, 0xd4, 0x7e, 0xbf, 0x2b, 0x96, 0x8b, 0x0f, 0xda, 0x7f, | ||||
| 	0xd9, 0xb7, 0x1f, 0x89, 0x9c, 0x55, 0x87, 0xcc, 0xfc, 0xa9, 0xaf, 0x70, 0x3e, 0xd8, 0x21, 0xcb, | ||||
| 	0x63, 0x1c, 0xef, 0x03, 0x65, 0x73, 0xaa, 0xa7, 0xae, 0x3f, 0x96, 0xf7, 0xc7, 0x2a, 0x9f, 0x3f, | ||||
| 	0x47, 0x3e, 0x56, 0xf9, 0xec, 0x84, 0xfc, 0xfe, 0x03, 0xcc, 0xf5, 0x4b, 0x90, 0x05, 0xcc, 0xf7, | ||||
| 	0xd1, 0xf7, 0x68, 0xf7, 0x23, 0x0a, 0x5e, 0x10, 0x80, 0xd9, 0x36, 0xde, 0x5e, 0xdf, 0x7e, 0x0b, | ||||
| 	0x1c, 0xe2, 0x83, 0x1b, 0xef, 0xee, 0xb6, 0x51, 0x30, 0x49, 0x66, 0xea, 0xaf, 0x6d, 0xf3, 0x3f, | ||||
| 	0x00, 0x00, 0xff, 0xff, 0xa2, 0x4b, 0xe1, 0x77, 0xf5, 0x04, 0x00, 0x00, | ||||
| } | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/more_test_objects.proto
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -37,18 +37,6 @@ message Simple3 { | ||||
|   double dub = 1; | ||||
| } | ||||
|  | ||||
| message SimpleSlice3 { | ||||
|   repeated string slices = 1; | ||||
| } | ||||
|  | ||||
| message SimpleMap3 { | ||||
|   map<string,string> stringy = 1; | ||||
| } | ||||
|  | ||||
| message SimpleNull3 { | ||||
|   Simple3 simple = 1; | ||||
| } | ||||
|  | ||||
| enum Numeral { | ||||
|   UNKNOWN = 0; | ||||
|   ARABIC = 1; | ||||
|   | ||||
							
								
								
									
										1036
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1036
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/test_objects.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										65
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										65
									
								
								vendor/github.com/gogo/protobuf/jsonpb/jsonpb_test_proto/test_objects.proto
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -45,37 +45,18 @@ import weak "gogoproto/gogo.proto"; | ||||
| message Simple { | ||||
|   optional bool o_bool = 1; | ||||
|   optional int32 o_int32 = 2; | ||||
|   optional int32 o_int32_str = 3; | ||||
|   optional int64 o_int64 = 4; | ||||
|   optional int64 o_int64_str = 5; | ||||
|   optional uint32 o_uint32 = 6; | ||||
|   optional uint32 o_uint32_str = 7; | ||||
|   optional uint64 o_uint64 = 8; | ||||
|   optional uint64 o_uint64_str = 9; | ||||
|   optional sint32 o_sint32 = 10; | ||||
|   optional sint32 o_sint32_str = 11; | ||||
|   optional sint64 o_sint64 = 12; | ||||
|   optional sint64 o_sint64_str = 13; | ||||
|   optional float o_float = 14; | ||||
|   optional float o_float_str = 15; | ||||
|   optional double o_double = 16; | ||||
|   optional double o_double_str = 17; | ||||
|   optional string o_string = 18; | ||||
|   optional bytes o_bytes = 19; | ||||
|   optional bytes o_cast_bytes = 20 [(gogoproto.casttype) = "Bytes"]; | ||||
|   optional int64 o_int64 = 3; | ||||
|   optional uint32 o_uint32 = 4; | ||||
|   optional uint64 o_uint64 = 5; | ||||
|   optional sint32 o_sint32 = 6; | ||||
|   optional sint64 o_sint64 = 7; | ||||
|   optional float o_float = 8; | ||||
|   optional double o_double = 9; | ||||
|   optional string o_string = 10; | ||||
|   optional bytes o_bytes = 11; | ||||
|   optional bytes o_cast_bytes = 12 [(gogoproto.casttype) = "Bytes"]; | ||||
| } | ||||
|  | ||||
| // Test message for holding special non-finites primitives. | ||||
| message NonFinites { | ||||
|     optional float f_nan = 1; | ||||
|     optional float f_pinf = 2; | ||||
|     optional float f_ninf = 3; | ||||
|     optional double d_nan = 4; | ||||
|     optional double d_pinf = 5; | ||||
|     optional double d_ninf = 6; | ||||
| } | ||||
|  | ||||
|  | ||||
| // Test message for holding repeated primitives. | ||||
| message Repeats { | ||||
|   repeated bool r_bool = 1; | ||||
| @@ -119,7 +100,6 @@ message MsgWithOneof { | ||||
|     int64 salary = 2; | ||||
|     string Country = 3; | ||||
|     string home_address = 4; | ||||
|     MsgWithRequired msg_with_required = 5; | ||||
|   } | ||||
| } | ||||
|  | ||||
| @@ -145,8 +125,6 @@ message KnownTypes { | ||||
|   optional google.protobuf.Duration dur = 1; | ||||
|   optional google.protobuf.Struct st = 12; | ||||
|   optional google.protobuf.Timestamp ts = 2; | ||||
|   optional google.protobuf.ListValue lv = 15; | ||||
|   optional google.protobuf.Value val = 16; | ||||
|  | ||||
|   optional google.protobuf.DoubleValue dbl = 3; | ||||
|   optional google.protobuf.FloatValue flt = 4; | ||||
| @@ -158,26 +136,3 @@ message KnownTypes { | ||||
|   optional google.protobuf.StringValue str = 10; | ||||
|   optional google.protobuf.BytesValue bytes = 11; | ||||
| } | ||||
|  | ||||
| // Test messages for marshaling/unmarshaling required fields. | ||||
| message MsgWithRequired { | ||||
|   required string str = 1; | ||||
| } | ||||
|  | ||||
| message MsgWithIndirectRequired { | ||||
|   optional MsgWithRequired subm = 1; | ||||
|   map<string, MsgWithRequired> map_field = 2; | ||||
|   repeated MsgWithRequired slice_field = 3; | ||||
| } | ||||
|  | ||||
| message MsgWithRequiredBytes { | ||||
|   required bytes byts = 1; | ||||
| } | ||||
|  | ||||
| message MsgWithRequiredWKT { | ||||
|   required google.protobuf.StringValue str = 1; | ||||
| } | ||||
|  | ||||
| extend Real { | ||||
|   optional MsgWithRequired extm = 125; | ||||
| } | ||||
|   | ||||
							
								
								
									
										58
									
								
								vendor/github.com/gogo/protobuf/plugin/compare/compare.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										58
									
								
								vendor/github.com/gogo/protobuf/plugin/compare/compare.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -425,65 +425,11 @@ func (p *plugin) generateMessage(file *generator.FileDescriptor, message *genera | ||||
| 			p.In() | ||||
| 			p.P(`return -1`) | ||||
| 			p.Out() | ||||
| 			p.P(`} else {`) | ||||
| 			p.In() | ||||
|  | ||||
| 			// Generate two type switches in order to compare the | ||||
| 			// types of the oneofs. If they are of the same type | ||||
| 			// call Compare, otherwise return 1 or -1. | ||||
| 			p.P(`thisType := -1`) | ||||
| 			p.P(`switch this.`, fieldname, `.(type) {`) | ||||
| 			for i, subfield := range message.Field { | ||||
| 				if *subfield.OneofIndex == *field.OneofIndex { | ||||
| 					ccTypeName := p.OneOfTypeName(message, subfield) | ||||
| 					p.P(`case *`, ccTypeName, `:`) | ||||
| 					p.In() | ||||
| 					p.P(`thisType = `, i) | ||||
| 					p.Out() | ||||
| 				} | ||||
| 			} | ||||
| 			p.P(`default:`) | ||||
| 			p.In() | ||||
| 			p.P(`panic(fmt.Sprintf("compare: unexpected type %T in oneof", this.`, fieldname, `))`) | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
|  | ||||
| 			p.P(`that1Type := -1`) | ||||
| 			p.P(`switch that1.`, fieldname, `.(type) {`) | ||||
| 			for i, subfield := range message.Field { | ||||
| 				if *subfield.OneofIndex == *field.OneofIndex { | ||||
| 					ccTypeName := p.OneOfTypeName(message, subfield) | ||||
| 					p.P(`case *`, ccTypeName, `:`) | ||||
| 					p.In() | ||||
| 					p.P(`that1Type = `, i) | ||||
| 					p.Out() | ||||
| 				} | ||||
| 			} | ||||
| 			p.P(`default:`) | ||||
| 			p.In() | ||||
| 			p.P(`panic(fmt.Sprintf("compare: unexpected type %T in oneof", that1.`, fieldname, `))`) | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
|  | ||||
| 			p.P(`if thisType == that1Type {`) | ||||
| 			p.In() | ||||
| 			p.P(`if c := this.`, fieldname, `.Compare(that1.`, fieldname, `); c != 0 {`) | ||||
| 			p.P(`} else if c := this.`, fieldname, `.Compare(that1.`, fieldname, `); c != 0 {`) | ||||
| 			p.In() | ||||
| 			p.P(`return c`) | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
| 			p.Out() | ||||
| 			p.P(`} else if thisType < that1Type {`) | ||||
| 			p.In() | ||||
| 			p.P(`return -1`) | ||||
| 			p.Out() | ||||
| 			p.P(`} else if thisType > that1Type {`) | ||||
| 			p.In() | ||||
| 			p.P(`return 1`) | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
| 		} else { | ||||
| 			p.generateField(file, message, field) | ||||
| 		} | ||||
| @@ -566,7 +512,7 @@ func (p *plugin) generateMessage(file *generator.FileDescriptor, message *genera | ||||
| 		p.In() | ||||
|  | ||||
| 		p.generateMsgNullAndTypeCheck(ccTypeName) | ||||
| 		vanity.TurnOffNullableForNativeTypes(field) | ||||
| 		vanity.TurnOffNullableForNativeTypesWithoutDefaultsOnly(field) | ||||
| 		p.generateField(file, message, field) | ||||
|  | ||||
| 		p.P(`return 0`) | ||||
|   | ||||
							
								
								
									
										5
									
								
								vendor/github.com/gogo/protobuf/plugin/embedcheck/embedcheck.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/github.com/gogo/protobuf/plugin/embedcheck/embedcheck.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -47,10 +47,9 @@ package embedcheck | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/gogoproto" | ||||
| 	"github.com/gogo/protobuf/protoc-gen-gogo/generator" | ||||
| 	"os" | ||||
| ) | ||||
|  | ||||
| type plugin struct { | ||||
| @@ -164,7 +163,7 @@ func (p *plugin) checkOverwrite(message *generator.Descriptor, enablers map[stri | ||||
| 			desc := p.ObjectNamed(field.GetTypeName()) | ||||
| 			msg := desc.(*generator.Descriptor) | ||||
| 			for errStr, enabled := range enablers { | ||||
| 				if enabled(msg.File().FileDescriptorProto, msg.DescriptorProto) { | ||||
| 				if enabled(msg.File(), msg.DescriptorProto) { | ||||
| 					fmt.Fprintf(os.Stderr, "WARNING: found non-%v %v with embedded %v %v\n", names, ccTypeName, errStr, fieldname) | ||||
| 				} | ||||
| 			} | ||||
|   | ||||
							
								
								
									
										113
									
								
								vendor/github.com/gogo/protobuf/plugin/equal/equal.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										113
									
								
								vendor/github.com/gogo/protobuf/plugin/equal/equal.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -107,7 +107,10 @@ given to the equal plugin, will generate the following code: | ||||
|  | ||||
| 	func (this *B) Equal(that interface{}) bool { | ||||
| 		if that == nil { | ||||
| 			return this == nil | ||||
| 			if this == nil { | ||||
| 				return true | ||||
| 			} | ||||
| 			return false | ||||
| 		} | ||||
|  | ||||
| 		that1, ok := that.(*B) | ||||
| @@ -115,7 +118,10 @@ given to the equal plugin, will generate the following code: | ||||
| 			return false | ||||
| 		} | ||||
| 		if that1 == nil { | ||||
| 			return this == nil | ||||
| 			if this == nil { | ||||
| 				return true | ||||
| 			} | ||||
| 			return false | ||||
| 		} else if this == nil { | ||||
| 			return false | ||||
| 		} | ||||
| @@ -230,15 +236,19 @@ func (p *plugin) generateNullableField(fieldname string, verbose bool) { | ||||
| func (p *plugin) generateMsgNullAndTypeCheck(ccTypeName string, verbose bool) { | ||||
| 	p.P(`if that == nil {`) | ||||
| 	p.In() | ||||
| 	p.P(`if this == nil {`) | ||||
| 	p.In() | ||||
| 	if verbose { | ||||
| 		p.P(`if this == nil {`) | ||||
| 		p.In() | ||||
| 		p.P(`return nil`) | ||||
| 		p.Out() | ||||
| 		p.P(`}`) | ||||
| 	} else { | ||||
| 		p.P(`return true`) | ||||
| 	} | ||||
| 	p.Out() | ||||
| 	p.P(`}`) | ||||
| 	if verbose { | ||||
| 		p.P(`return `, p.fmtPkg.Use(), `.Errorf("that == nil && this != nil")`) | ||||
| 	} else { | ||||
| 		p.P(`return this == nil`) | ||||
| 		p.P(`return false`) | ||||
| 	} | ||||
| 	p.Out() | ||||
| 	p.P(`}`) | ||||
| @@ -264,15 +274,19 @@ func (p *plugin) generateMsgNullAndTypeCheck(ccTypeName string, verbose bool) { | ||||
| 	p.P(`}`) | ||||
| 	p.P(`if that1 == nil {`) | ||||
| 	p.In() | ||||
| 	p.P(`if this == nil {`) | ||||
| 	p.In() | ||||
| 	if verbose { | ||||
| 		p.P(`if this == nil {`) | ||||
| 		p.In() | ||||
| 		p.P(`return nil`) | ||||
| 		p.Out() | ||||
| 		p.P(`}`) | ||||
| 	} else { | ||||
| 		p.P(`return true`) | ||||
| 	} | ||||
| 	p.Out() | ||||
| 	p.P(`}`) | ||||
| 	if verbose { | ||||
| 		p.P(`return `, p.fmtPkg.Use(), `.Errorf("that is type *`, ccTypeName, ` but is nil && this != nil")`) | ||||
| 	} else { | ||||
| 		p.P(`return this == nil`) | ||||
| 		p.P(`return false`) | ||||
| 	} | ||||
| 	p.Out() | ||||
| 	p.P(`} else if this == nil {`) | ||||
| @@ -292,16 +306,7 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato | ||||
| 	repeated := field.IsRepeated() | ||||
| 	ctype := gogoproto.IsCustomType(field) | ||||
| 	nullable := gogoproto.IsNullable(field) | ||||
| 	isNormal := (gogoproto.IsStdDuration(field) || | ||||
| 		gogoproto.IsStdDouble(field) || | ||||
| 		gogoproto.IsStdFloat(field) || | ||||
| 		gogoproto.IsStdInt64(field) || | ||||
| 		gogoproto.IsStdUInt64(field) || | ||||
| 		gogoproto.IsStdInt32(field) || | ||||
| 		gogoproto.IsStdUInt32(field) || | ||||
| 		gogoproto.IsStdBool(field) || | ||||
| 		gogoproto.IsStdString(field)) | ||||
| 	isBytes := gogoproto.IsStdBytes(field) | ||||
| 	isDuration := gogoproto.IsStdDuration(field) | ||||
| 	isTimestamp := gogoproto.IsStdTime(field) | ||||
| 	// oneof := field.OneofIndex != nil | ||||
| 	if !repeated { | ||||
| @@ -331,7 +336,7 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato | ||||
| 			} | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
| 		} else if isNormal { | ||||
| 		} else if isDuration { | ||||
| 			if nullable { | ||||
| 				p.generateNullableField(fieldname, verbose) | ||||
| 			} else { | ||||
| @@ -345,32 +350,6 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato | ||||
| 			} | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
| 		} else if isBytes { | ||||
| 			if nullable { | ||||
| 				p.P(`if that1.`, fieldname, ` == nil {`) | ||||
| 				p.In() | ||||
| 				p.P(`if this.`, fieldname, ` != nil {`) | ||||
| 				p.In() | ||||
| 				if verbose { | ||||
| 					p.P(`return `, p.fmtPkg.Use(), `.Errorf("this.`, fieldname, ` != nil && that1.`, fieldname, ` == nil")`) | ||||
| 				} else { | ||||
| 					p.P(`return false`) | ||||
| 				} | ||||
| 				p.Out() | ||||
| 				p.P(`}`) | ||||
| 				p.Out() | ||||
| 				p.P(`} else if !`, p.bytesPkg.Use(), `.Equal(*this.`, fieldname, `, *that1.`, fieldname, `) {`) | ||||
| 			} else { | ||||
| 				p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `, that1.`, fieldname, `) {`) | ||||
| 			} | ||||
| 			p.In() | ||||
| 			if verbose { | ||||
| 				p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", this.`, fieldname, `, that1.`, fieldname, `)`) | ||||
| 			} else { | ||||
| 				p.P(`return false`) | ||||
| 			} | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
| 		} else { | ||||
| 			if field.IsMessage() || p.IsGroup(field) { | ||||
| 				if nullable { | ||||
| @@ -422,18 +401,12 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato | ||||
| 			} else { | ||||
| 				p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`) | ||||
| 			} | ||||
| 		} else if isNormal { | ||||
| 		} else if isDuration { | ||||
| 			if nullable { | ||||
| 				p.P(`if dthis, dthat := this.`, fieldname, `[i], that1.`, fieldname, `[i]; (dthis != nil && dthat != nil && *dthis != *dthat) || (dthis != nil && dthat == nil) || (dthis == nil && dthat != nil)  {`) | ||||
| 			} else { | ||||
| 				p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`) | ||||
| 			} | ||||
| 		} else if isBytes { | ||||
| 			if nullable { | ||||
| 				p.P(`if !`, p.bytesPkg.Use(), `.Equal(*this.`, fieldname, `[i], *that1.`, fieldname, `[i]) {`) | ||||
| 			} else { | ||||
| 				p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `[i], that1.`, fieldname, `[i]) {`) | ||||
| 			} | ||||
| 		} else { | ||||
| 			if p.IsMap(field) { | ||||
| 				m := p.GoMapType(nil, field) | ||||
| @@ -442,16 +415,6 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato | ||||
| 				nullable, valuegoTyp, valuegoAliasTyp = generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp) | ||||
|  | ||||
| 				mapValue := m.ValueAliasField | ||||
| 				mapValueNormal := (gogoproto.IsStdDuration(mapValue) || | ||||
| 					gogoproto.IsStdDouble(mapValue) || | ||||
| 					gogoproto.IsStdFloat(mapValue) || | ||||
| 					gogoproto.IsStdInt64(mapValue) || | ||||
| 					gogoproto.IsStdUInt64(mapValue) || | ||||
| 					gogoproto.IsStdInt32(mapValue) || | ||||
| 					gogoproto.IsStdUInt32(mapValue) || | ||||
| 					gogoproto.IsStdBool(mapValue) || | ||||
| 					gogoproto.IsStdString(mapValue)) | ||||
| 				mapValueBytes := gogoproto.IsStdBytes(mapValue) | ||||
| 				if mapValue.IsMessage() || p.IsGroup(mapValue) { | ||||
| 					if nullable && valuegoTyp == valuegoAliasTyp { | ||||
| 						p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`) | ||||
| @@ -459,26 +422,14 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato | ||||
| 						// Equal() has a pointer receiver, but map value is a value type | ||||
| 						a := `this.` + fieldname + `[i]` | ||||
| 						b := `that1.` + fieldname + `[i]` | ||||
| 						if !mapValueNormal && !mapValueBytes && valuegoTyp != valuegoAliasTyp { | ||||
| 						if valuegoTyp != valuegoAliasTyp { | ||||
| 							// cast back to the type that has the generated methods on it | ||||
| 							a = `(` + valuegoTyp + `)(` + a + `)` | ||||
| 							b = `(` + valuegoTyp + `)(` + b + `)` | ||||
| 						} | ||||
| 						p.P(`a := `, a) | ||||
| 						p.P(`b := `, b) | ||||
| 						if mapValueNormal { | ||||
| 							if nullable { | ||||
| 								p.P(`if *a != *b {`) | ||||
| 							} else { | ||||
| 								p.P(`if a != b {`) | ||||
| 							} | ||||
| 						} else if mapValueBytes { | ||||
| 							if nullable { | ||||
| 								p.P(`if !`, p.bytesPkg.Use(), `.Equal(*a, *b) {`) | ||||
| 							} else { | ||||
| 								p.P(`if !`, p.bytesPkg.Use(), `.Equal(a, b) {`) | ||||
| 							} | ||||
| 						} else if nullable { | ||||
| 						if nullable { | ||||
| 							p.P(`if !a.Equal(b) {`) | ||||
| 						} else { | ||||
| 							p.P(`if !(&a).Equal(&b) {`) | ||||
| @@ -676,7 +627,7 @@ func (p *plugin) generateMessage(file *generator.FileDescriptor, message *genera | ||||
| 		p.In() | ||||
|  | ||||
| 		p.generateMsgNullAndTypeCheck(ccTypeName, verbose) | ||||
| 		vanity.TurnOffNullableForNativeTypes(field) | ||||
| 		vanity.TurnOffNullableForNativeTypesWithoutDefaultsOnly(field) | ||||
| 		p.generateField(file, message, field, verbose) | ||||
|  | ||||
| 		if verbose { | ||||
|   | ||||
							
								
								
									
										49
									
								
								vendor/github.com/gogo/protobuf/plugin/gostring/gostring.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										49
									
								
								vendor/github.com/gogo/protobuf/plugin/gostring/gostring.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -98,12 +98,11 @@ package gostring | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"github.com/gogo/protobuf/gogoproto" | ||||
| 	"github.com/gogo/protobuf/protoc-gen-gogo/generator" | ||||
| 	"os" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/gogoproto" | ||||
| 	"github.com/gogo/protobuf/protoc-gen-gogo/generator" | ||||
| ) | ||||
|  | ||||
| type gostring struct { | ||||
| @@ -157,7 +156,7 @@ func (p *gostring) Generate(file *generator.FileDescriptor) { | ||||
| 			continue | ||||
| 		} | ||||
| 		p.atleastOne = true | ||||
| 		packageName := file.GoPackageName() | ||||
| 		packageName := file.PackageName() | ||||
|  | ||||
| 		ccTypeName := generator.CamelCaseSlice(message.TypeName()) | ||||
| 		p.P(`func (this *`, ccTypeName, `) GoString() string {`) | ||||
| @@ -225,27 +224,13 @@ func (p *gostring) Generate(file *generator.FileDescriptor) { | ||||
| 				p.P(`s = append(s, "`, fieldname, `: " + `, mapName, `+ ",\n")`) | ||||
| 				p.Out() | ||||
| 				p.P(`}`) | ||||
| 			} else if (field.IsMessage() && !gogoproto.IsCustomType(field) && !gogoproto.IsStdType(field)) || p.IsGroup(field) { | ||||
| 			} else if (field.IsMessage() && !gogoproto.IsCustomType(field) && !gogoproto.IsStdTime(field) && !gogoproto.IsStdDuration(field)) || p.IsGroup(field) { | ||||
| 				if nullable || repeated { | ||||
| 					p.P(`if this.`, fieldname, ` != nil {`) | ||||
| 					p.In() | ||||
| 				} | ||||
| 				if nullable { | ||||
| 				if nullable || repeated { | ||||
| 					p.P(`s = append(s, "`, fieldname, `: " + `, fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `) + ",\n")`) | ||||
| 				} else if repeated { | ||||
| 					if nullable { | ||||
| 						p.P(`s = append(s, "`, fieldname, `: " + `, fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `) + ",\n")`) | ||||
| 					} else { | ||||
| 						goTyp, _ := p.GoType(message, field) | ||||
| 						goTyp = strings.Replace(goTyp, "[]", "", 1) | ||||
| 						p.P("vs := make([]", goTyp, ", len(this.", fieldname, "))") | ||||
| 						p.P("for i := range vs {") | ||||
| 						p.In() | ||||
| 						p.P("vs[i] = this.", fieldname, "[i]") | ||||
| 						p.Out() | ||||
| 						p.P("}") | ||||
| 						p.P(`s = append(s, "`, fieldname, `: " + `, fmtPkg.Use(), `.Sprintf("%#v", vs) + ",\n")`) | ||||
| 					} | ||||
| 				} else { | ||||
| 					p.P(`s = append(s, "`, fieldname, `: " + `, stringsPkg.Use(), `.Replace(this.`, fieldname, `.GoString()`, ",`&`,``,1)", ` + ",\n")`) | ||||
| 				} | ||||
| @@ -261,7 +246,7 @@ func (p *gostring) Generate(file *generator.FileDescriptor) { | ||||
| 				if field.IsEnum() { | ||||
| 					if nullable && !repeated && !proto3 { | ||||
| 						goTyp, _ := p.GoType(message, field) | ||||
| 						p.P(`s = append(s, "`, fieldname, `: " + valueToGoString`, p.localName, `(this.`, fieldname, `,"`, generator.GoTypeToName(goTyp), `"`, `) + ",\n")`) | ||||
| 						p.P(`s = append(s, "`, fieldname, `: " + valueToGoString`, p.localName, `(this.`, fieldname, `,"`, packageName, ".", generator.GoTypeToName(goTyp), `"`, `) + ",\n")`) | ||||
| 					} else { | ||||
| 						p.P(`s = append(s, "`, fieldname, `: " + `, fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `) + ",\n")`) | ||||
| 					} | ||||
| @@ -300,6 +285,7 @@ func (p *gostring) Generate(file *generator.FileDescriptor) { | ||||
| 		} | ||||
|  | ||||
| 		p.P(`s = append(s, "}")`) | ||||
| 		//outStr += strings.Join([]string{" + `}`", `}`, `,", "`, ")"}, "") | ||||
| 		p.P(`return `, stringsPkg.Use(), `.Join(s, "")`) | ||||
| 		p.Out() | ||||
| 		p.P(`}`) | ||||
| @@ -318,15 +304,20 @@ func (p *gostring) Generate(file *generator.FileDescriptor) { | ||||
| 			p.P(`return "nil"`) | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
| 			outFlds := []string{} | ||||
| 			fieldname := p.GetOneOfFieldName(message, field) | ||||
| 			outStr := strings.Join([]string{ | ||||
| 				"s := ", | ||||
| 				stringsPkg.Use(), ".Join([]string{`&", packageName, ".", ccTypeName, "{` + \n", | ||||
| 				"`", fieldname, ":` + ", fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `)`, | ||||
| 				" + `}`", | ||||
| 				`}`, | ||||
| 				`,", "`, | ||||
| 				`)`}, "") | ||||
| 			if field.IsMessage() || p.IsGroup(field) { | ||||
| 				tmp := strings.Join([]string{"`", fieldname, ":` + "}, "") | ||||
| 				tmp += strings.Join([]string{fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, `)`}, "") | ||||
| 				outFlds = append(outFlds, tmp) | ||||
| 			} else { | ||||
| 				tmp := strings.Join([]string{"`", fieldname, ":` + "}, "") | ||||
| 				tmp += strings.Join([]string{fmtPkg.Use(), `.Sprintf("%#v", this.`, fieldname, ")"}, "") | ||||
| 				outFlds = append(outFlds, tmp) | ||||
| 			} | ||||
| 			outStr := strings.Join([]string{"s := ", stringsPkg.Use(), ".Join([]string{`&", packageName, ".", ccTypeName, "{` + \n"}, "") | ||||
| 			outStr += strings.Join(outFlds, ",\n") | ||||
| 			outStr += strings.Join([]string{" + `}`", `}`, `,", "`, ")"}, "") | ||||
| 			p.P(outStr) | ||||
| 			p.P(`return s`) | ||||
| 			p.Out() | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/gogo/protobuf/plugin/gostring/gostringtest.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/gogo/protobuf/plugin/gostring/gostringtest.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -74,7 +74,7 @@ func (p *test) Generate(imports generator.PluginImports, file *generator.FileDes | ||||
| 			p.P(`_, err := `, parserPkg.Use(), `.ParseExpr(s1)`) | ||||
| 			p.P(`if err != nil {`) | ||||
| 			p.In() | ||||
| 			p.P(`t.Fatal(err)`) | ||||
| 			p.P(`panic(err)`) | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
| 			p.Out() | ||||
|   | ||||
							
								
								
									
										1165
									
								
								vendor/github.com/gogo/protobuf/plugin/marshalto/marshalto.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1165
									
								
								vendor/github.com/gogo/protobuf/plugin/marshalto/marshalto.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										66
									
								
								vendor/github.com/gogo/protobuf/plugin/populate/populate.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										66
									
								
								vendor/github.com/gogo/protobuf/plugin/populate/populate.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -182,7 +182,7 @@ func negative(fieldType descriptor.FieldDescriptorProto_Type) bool { | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| func (p *plugin) getFuncName(goTypName string, field *descriptor.FieldDescriptorProto) string { | ||||
| func (p *plugin) getFuncName(goTypName string) string { | ||||
| 	funcName := "NewPopulated" + goTypName | ||||
| 	goTypNames := strings.Split(goTypName, ".") | ||||
| 	if len(goTypNames) == 2 { | ||||
| @@ -190,43 +190,23 @@ func (p *plugin) getFuncName(goTypName string, field *descriptor.FieldDescriptor | ||||
| 	} else if len(goTypNames) != 1 { | ||||
| 		panic(fmt.Errorf("unreachable: too many dots in %v", goTypName)) | ||||
| 	} | ||||
| 	if field != nil { | ||||
| 		switch { | ||||
| 		case gogoproto.IsStdTime(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdTime" | ||||
| 		case gogoproto.IsStdDuration(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdDuration" | ||||
| 		case gogoproto.IsStdDouble(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdDouble" | ||||
| 		case gogoproto.IsStdFloat(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdFloat" | ||||
| 		case gogoproto.IsStdInt64(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdInt64" | ||||
| 		case gogoproto.IsStdUInt64(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdUInt64" | ||||
| 		case gogoproto.IsStdInt32(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdInt32" | ||||
| 		case gogoproto.IsStdUInt32(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdUInt32" | ||||
| 		case gogoproto.IsStdBool(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdBool" | ||||
| 		case gogoproto.IsStdString(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdString" | ||||
| 		case gogoproto.IsStdBytes(field): | ||||
| 			funcName = p.typesPkg.Use() + ".NewPopulatedStdBytes" | ||||
| 		} | ||||
| 	switch funcName { | ||||
| 	case "time.NewPopulatedTime": | ||||
| 		funcName = p.typesPkg.Use() + ".NewPopulatedStdTime" | ||||
| 	case "time.NewPopulatedDuration": | ||||
| 		funcName = p.typesPkg.Use() + ".NewPopulatedStdDuration" | ||||
| 	} | ||||
| 	return funcName | ||||
| } | ||||
|  | ||||
| func (p *plugin) getFuncCall(goTypName string, field *descriptor.FieldDescriptorProto) string { | ||||
| 	funcName := p.getFuncName(goTypName, field) | ||||
| func (p *plugin) getFuncCall(goTypName string) string { | ||||
| 	funcName := p.getFuncName(goTypName) | ||||
| 	funcCall := funcName + "(r, easy)" | ||||
| 	return funcCall | ||||
| } | ||||
|  | ||||
| func (p *plugin) getCustomFuncCall(goTypName string) string { | ||||
| 	funcName := p.getFuncName(goTypName, nil) | ||||
| 	funcName := p.getFuncName(goTypName) | ||||
| 	funcCall := funcName + "(r)" | ||||
| 	return funcCall | ||||
| } | ||||
| @@ -279,13 +259,13 @@ func (p *plugin) GenerateField(file *generator.FileDescriptor, message *generato | ||||
| 		if m.ValueField.IsMessage() || p.IsGroup(field) || | ||||
| 			(m.ValueField.IsBytes() && gogoproto.IsCustomType(field)) { | ||||
| 			s := `this.` + fieldname + `[` + keyval + `] = ` | ||||
| 			if gogoproto.IsStdType(field) { | ||||
| 			if gogoproto.IsStdTime(field) || gogoproto.IsStdDuration(field) { | ||||
| 				valuegoTyp = valuegoAliasTyp | ||||
| 			} | ||||
| 			funcCall := p.getCustomFuncCall(goTypName) | ||||
| 			if !gogoproto.IsCustomType(field) { | ||||
| 				goTypName = generator.GoTypeToName(valuegoTyp) | ||||
| 				funcCall = p.getFuncCall(goTypName, m.ValueAliasField) | ||||
| 				funcCall = p.getFuncCall(goTypName) | ||||
| 			} | ||||
| 			if !nullable { | ||||
| 				funcCall = `*` + funcCall | ||||
| @@ -342,7 +322,7 @@ func (p *plugin) GenerateField(file *generator.FileDescriptor, message *generato | ||||
| 			p.P(`this.`, fieldname, ` = *`, p.varGen.Current()) | ||||
| 		} | ||||
| 	} else if field.IsMessage() || p.IsGroup(field) { | ||||
| 		funcCall := p.getFuncCall(goTypName, field) | ||||
| 		funcCall := p.getFuncCall(goTypName) | ||||
| 		if field.IsRepeated() { | ||||
| 			p.P(p.varGen.Next(), ` := r.Intn(5)`) | ||||
| 			p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`) | ||||
| @@ -463,7 +443,7 @@ func (p *plugin) GenerateField(file *generator.FileDescriptor, message *generato | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (p *plugin) hasLoop(pkg string, field *descriptor.FieldDescriptorProto, visited []*generator.Descriptor, excludes []*generator.Descriptor) *generator.Descriptor { | ||||
| func (p *plugin) hasLoop(field *descriptor.FieldDescriptorProto, visited []*generator.Descriptor, excludes []*generator.Descriptor) *generator.Descriptor { | ||||
| 	if field.IsMessage() || p.IsGroup(field) || p.IsMap(field) { | ||||
| 		var fieldMessage *generator.Descriptor | ||||
| 		if p.IsMap(field) { | ||||
| @@ -487,11 +467,11 @@ func (p *plugin) hasLoop(pkg string, field *descriptor.FieldDescriptorProto, vis | ||||
| 				return fieldMessage | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		pkg := strings.Split(field.GetTypeName(), ".")[1] | ||||
| 		for _, f := range fieldMessage.Field { | ||||
| 			if strings.HasPrefix(f.GetTypeName(), "."+pkg) { | ||||
| 			if strings.HasPrefix(f.GetTypeName(), "."+pkg+".") { | ||||
| 				visited = append(visited, fieldMessage) | ||||
| 				loopTo := p.hasLoop(pkg, f, visited, excludes) | ||||
| 				loopTo := p.hasLoop(f, visited, excludes) | ||||
| 				if loopTo != nil { | ||||
| 					return loopTo | ||||
| 				} | ||||
| @@ -501,13 +481,13 @@ func (p *plugin) hasLoop(pkg string, field *descriptor.FieldDescriptorProto, vis | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (p *plugin) loops(pkg string, field *descriptor.FieldDescriptorProto, message *generator.Descriptor) int { | ||||
| func (p *plugin) loops(field *descriptor.FieldDescriptorProto, message *generator.Descriptor) int { | ||||
| 	//fmt.Fprintf(os.Stderr, "loops %v %v\n", field.GetTypeName(), generator.CamelCaseSlice(message.TypeName())) | ||||
| 	excludes := []*generator.Descriptor{} | ||||
| 	loops := 0 | ||||
| 	for { | ||||
| 		visited := []*generator.Descriptor{} | ||||
| 		loopTo := p.hasLoop(pkg, field, visited, excludes) | ||||
| 		loopTo := p.hasLoop(field, visited, excludes) | ||||
| 		if loopTo == nil { | ||||
| 			break | ||||
| 		} | ||||
| @@ -542,7 +522,7 @@ func (p *plugin) Generate(file *generator.FileDescriptor) { | ||||
| 		loopLevels := make([]int, len(message.Field)) | ||||
| 		maxLoopLevel := 0 | ||||
| 		for i, field := range message.Field { | ||||
| 			loopLevels[i] = p.loops(file.GetPackage(), field, message) | ||||
| 			loopLevels[i] = p.loops(field, message) | ||||
| 			if loopLevels[i] > maxLoopLevel { | ||||
| 				maxLoopLevel = loopLevels[i] | ||||
| 			} | ||||
| @@ -554,7 +534,7 @@ func (p *plugin) Generate(file *generator.FileDescriptor) { | ||||
| 		p.P(`func NewPopulated`, ccTypeName, `(r randy`, p.localName, `, easy bool) *`, ccTypeName, ` {`) | ||||
| 		p.In() | ||||
| 		p.P(`this := &`, ccTypeName, `{}`) | ||||
| 		if gogoproto.IsUnion(message.File().FileDescriptorProto, message.DescriptorProto) && len(message.Field) > 0 { | ||||
| 		if gogoproto.IsUnion(message.File(), message.DescriptorProto) && len(message.Field) > 0 { | ||||
| 			p.P(`fieldNum := r.Intn(`, fmt.Sprintf("%d", ranTotal), `)`) | ||||
| 			p.P(`switch fieldNum {`) | ||||
| 			k := 0 | ||||
| @@ -584,9 +564,9 @@ func (p *plugin) Generate(file *generator.FileDescriptor) { | ||||
| 						p.GenerateField(file, message, field) | ||||
| 					} else { | ||||
| 						if loopLevels[fieldIndex] > 0 { | ||||
| 							p.P(`if r.Intn(5) == 0 {`) | ||||
| 							p.P(`if r.Intn(10) == 0 {`) | ||||
| 						} else { | ||||
| 							p.P(`if r.Intn(5) != 0 {`) | ||||
| 							p.P(`if r.Intn(10) != 0 {`) | ||||
| 						} | ||||
| 						p.In() | ||||
| 						p.GenerateField(file, message, field) | ||||
| @@ -687,7 +667,7 @@ func (p *plugin) Generate(file *generator.FileDescriptor) { | ||||
| 			p.P(`func NewPopulated`, ccTypeName, `(r randy`, p.localName, `, easy bool) *`, ccTypeName, ` {`) | ||||
| 			p.In() | ||||
| 			p.P(`this := &`, ccTypeName, `{}`) | ||||
| 			vanity.TurnOffNullableForNativeTypes(f) | ||||
| 			vanity.TurnOffNullableForNativeTypesWithoutDefaultsOnly(f) | ||||
| 			p.GenerateField(file, message, f) | ||||
| 			p.P(`return this`) | ||||
| 			p.Out() | ||||
|   | ||||
							
								
								
									
										62
									
								
								vendor/github.com/gogo/protobuf/plugin/size/size.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										62
									
								
								vendor/github.com/gogo/protobuf/plugin/size/size.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -69,9 +69,6 @@ The following message: | ||||
| given to the size plugin, will generate the following code: | ||||
|  | ||||
|   func (m *B) Size() (n int) { | ||||
| 	if m == nil { | ||||
| 		return 0 | ||||
| 	} | ||||
| 	var l int | ||||
| 	_ = l | ||||
| 	l = m.A.Size() | ||||
| @@ -141,7 +138,6 @@ type size struct { | ||||
| 	atleastOne bool | ||||
| 	localName  string | ||||
| 	typesPkg   generator.Single | ||||
| 	bitsPkg    generator.Single | ||||
| } | ||||
|  | ||||
| func NewSize() *size { | ||||
| @@ -189,7 +185,14 @@ func keySize(fieldNumber int32, wireType int) int { | ||||
| func (p *size) sizeVarint() { | ||||
| 	p.P(` | ||||
| 	func sov`, p.localName, `(x uint64) (n int) { | ||||
|                 return (`, p.bitsPkg.Use(), `.Len64(x | 1) + 6)/ 7 | ||||
| 		for { | ||||
| 			n++ | ||||
| 			x >>= 7 | ||||
| 			if x == 0 { | ||||
| 				break | ||||
| 			} | ||||
| 		} | ||||
| 		return n | ||||
| 	}`) | ||||
| } | ||||
|  | ||||
| @@ -200,32 +203,18 @@ func (p *size) sizeZigZag() { | ||||
| } | ||||
|  | ||||
| func (p *size) std(field *descriptor.FieldDescriptorProto, name string) (string, bool) { | ||||
| 	ptr := "" | ||||
| 	if gogoproto.IsNullable(field) { | ||||
| 		ptr = "*" | ||||
| 	} | ||||
| 	if gogoproto.IsStdTime(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdTime(` + ptr + name + `)`, true | ||||
| 		if gogoproto.IsNullable(field) { | ||||
| 			return p.typesPkg.Use() + `.SizeOfStdTime(*` + name + `)`, true | ||||
| 		} else { | ||||
| 			return p.typesPkg.Use() + `.SizeOfStdTime(` + name + `)`, true | ||||
| 		} | ||||
| 	} else if gogoproto.IsStdDuration(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdDuration(` + ptr + name + `)`, true | ||||
| 	} else if gogoproto.IsStdDouble(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdDouble(` + ptr + name + `)`, true | ||||
| 	} else if gogoproto.IsStdFloat(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdFloat(` + ptr + name + `)`, true | ||||
| 	} else if gogoproto.IsStdInt64(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdInt64(` + ptr + name + `)`, true | ||||
| 	} else if gogoproto.IsStdUInt64(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdUInt64(` + ptr + name + `)`, true | ||||
| 	} else if gogoproto.IsStdInt32(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdInt32(` + ptr + name + `)`, true | ||||
| 	} else if gogoproto.IsStdUInt32(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdUInt32(` + ptr + name + `)`, true | ||||
| 	} else if gogoproto.IsStdBool(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdBool(` + ptr + name + `)`, true | ||||
| 	} else if gogoproto.IsStdString(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdString(` + ptr + name + `)`, true | ||||
| 	} else if gogoproto.IsStdBytes(field) { | ||||
| 		return p.typesPkg.Use() + `.SizeOfStdBytes(` + ptr + name + `)`, true | ||||
| 		if gogoproto.IsNullable(field) { | ||||
| 			return p.typesPkg.Use() + `.SizeOfStdDuration(*` + name + `)`, true | ||||
| 		} else { | ||||
| 			return p.typesPkg.Use() + `.SizeOfStdDuration(` + name + `)`, true | ||||
| 		} | ||||
| 	} | ||||
| 	return "", false | ||||
| } | ||||
| @@ -455,7 +444,7 @@ func (p *size) generateField(proto3 bool, file *generator.FileDescriptor, messag | ||||
| 				sum = append(sum, strconv.Itoa(valueKeySize)) | ||||
| 				sum = append(sum, `soz`+p.localName+`(uint64(v))`) | ||||
| 			case descriptor.FieldDescriptorProto_TYPE_MESSAGE: | ||||
| 				stdSizeCall, stdOk := p.std(m.ValueAliasField, "v") | ||||
| 				stdSizeCall, stdOk := p.std(field, "v") | ||||
| 				if nullable { | ||||
| 					p.P(`l = 0`) | ||||
| 					p.P(`if v != nil {`) | ||||
| @@ -583,7 +572,6 @@ func (p *size) Generate(file *generator.FileDescriptor) { | ||||
| 	p.localName = generator.FileName(file) | ||||
| 	p.typesPkg = p.NewImport("github.com/gogo/protobuf/types") | ||||
| 	protoPkg := p.NewImport("github.com/gogo/protobuf/proto") | ||||
| 	p.bitsPkg = p.NewImport("math/bits") | ||||
| 	if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) { | ||||
| 		protoPkg = p.NewImport("github.com/golang/protobuf/proto") | ||||
| 	} | ||||
| @@ -607,11 +595,6 @@ func (p *size) Generate(file *generator.FileDescriptor) { | ||||
| 		ccTypeName := generator.CamelCaseSlice(message.TypeName()) | ||||
| 		p.P(`func (m *`, ccTypeName, `) `, sizeName, `() (n int) {`) | ||||
| 		p.In() | ||||
| 		p.P(`if m == nil {`) | ||||
| 		p.In() | ||||
| 		p.P(`return 0`) | ||||
| 		p.Out() | ||||
| 		p.P(`}`) | ||||
| 		p.P(`var l int`) | ||||
| 		p.P(`_ = l`) | ||||
| 		oneofs := make(map[string]struct{}) | ||||
| @@ -667,14 +650,9 @@ func (p *size) Generate(file *generator.FileDescriptor) { | ||||
| 			ccTypeName := p.OneOfTypeName(message, f) | ||||
| 			p.P(`func (m *`, ccTypeName, `) `, sizeName, `() (n int) {`) | ||||
| 			p.In() | ||||
| 			p.P(`if m == nil {`) | ||||
| 			p.In() | ||||
| 			p.P(`return 0`) | ||||
| 			p.Out() | ||||
| 			p.P(`}`) | ||||
| 			p.P(`var l int`) | ||||
| 			p.P(`_ = l`) | ||||
| 			vanity.TurnOffNullableForNativeTypes(f) | ||||
| 			vanity.TurnOffNullableForNativeTypesWithoutDefaultsOnly(f) | ||||
| 			p.generateField(false, file, message, f, sizeName) | ||||
| 			p.P(`return n`) | ||||
| 			p.Out() | ||||
|   | ||||
							
								
								
									
										59
									
								
								vendor/github.com/gogo/protobuf/plugin/stringer/stringer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										59
									
								
								vendor/github.com/gogo/protobuf/plugin/stringer/stringer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -148,47 +148,6 @@ func (p *stringer) Generate(file *generator.FileDescriptor) { | ||||
| 		p.P(`return "nil"`) | ||||
| 		p.Out() | ||||
| 		p.P(`}`) | ||||
| 		for _, field := range message.Field { | ||||
| 			if p.IsMap(field) || !field.IsRepeated() { | ||||
| 				continue | ||||
| 			} | ||||
| 			if (field.IsMessage() && !gogoproto.IsCustomType(field)) || p.IsGroup(field) { | ||||
| 				nullable := gogoproto.IsNullable(field) | ||||
| 				desc := p.ObjectNamed(field.GetTypeName()) | ||||
| 				msgname := p.TypeName(desc) | ||||
| 				msgnames := strings.Split(msgname, ".") | ||||
| 				typeName := msgnames[len(msgnames)-1] | ||||
| 				fieldMessageDesc := file.GetMessage(msgname) | ||||
| 				gogoStringer := false | ||||
| 				if fieldMessageDesc != nil { | ||||
| 					gogoStringer = gogoproto.IsStringer(file.FileDescriptorProto, fieldMessageDesc) | ||||
| 				} | ||||
| 				fieldname := p.GetFieldName(message, field) | ||||
| 				stringfunc := fmtPkg.Use() + `.Sprintf("%v", f)` | ||||
| 				if gogoStringer { | ||||
| 					stringfunc = `f.String()` | ||||
| 				} | ||||
| 				repeatedName := `repeatedStringFor` + fieldname | ||||
| 				if nullable { | ||||
| 					p.P(repeatedName, ` := "[]*`, typeName, `{"`) | ||||
| 				} else { | ||||
| 					p.P(repeatedName, ` := "[]`, typeName, `{"`) | ||||
| 				} | ||||
|  | ||||
| 				p.P(`for _, f := range `, `this.`, fieldname, ` {`) | ||||
| 				p.In() | ||||
| 				if nullable { | ||||
| 					p.P(repeatedName, " += ", stringsPkg.Use(), `.Replace(`, stringfunc, `, "`, typeName, `","`, msgname, `"`, ", 1)", ` + ","`) | ||||
| 				} else if gogoStringer { | ||||
| 					p.P(repeatedName, " += ", stringsPkg.Use(), `.Replace(`, stringsPkg.Use(), `.Replace(`, stringfunc, `, "`, typeName, `","`, msgname, `"`, ", 1),`&`,``,1)", ` + ","`) | ||||
| 				} else { | ||||
| 					p.P(repeatedName, " += ", stringfunc, ` + ","`) | ||||
| 				} | ||||
| 				p.Out() | ||||
| 				p.P(`}`) | ||||
| 				p.P(repeatedName, ` += "}"`) | ||||
| 			} | ||||
| 		} | ||||
| 		for _, field := range message.Field { | ||||
| 			if !p.IsMap(field) { | ||||
| 				continue | ||||
| @@ -249,22 +208,12 @@ func (p *stringer) Generate(file *generator.FileDescriptor) { | ||||
| 				msgname := p.TypeName(desc) | ||||
| 				msgnames := strings.Split(msgname, ".") | ||||
| 				typeName := msgnames[len(msgnames)-1] | ||||
| 				fieldMessageDesc := file.GetMessage(msgname) | ||||
| 				gogoStringer := false | ||||
| 				if fieldMessageDesc != nil { | ||||
| 					gogoStringer = gogoproto.IsStringer(file.FileDescriptorProto, fieldMessageDesc) | ||||
| 				} | ||||
| 				stringfunc := fmtPkg.Use() + `.Sprintf("%v", this.` + fieldname + `)` | ||||
| 				if gogoStringer { | ||||
| 					stringfunc = `this.` + fieldname + `.String()` | ||||
| 				} | ||||
| 				if nullable && !repeated { | ||||
| 					p.P("`", fieldname, ":`", ` + `, stringsPkg.Use(), `.Replace(`, stringfunc, `, "`, typeName, `","`, msgname, `"`, ", 1) + `,", "`,") | ||||
| 				if nullable { | ||||
| 					p.P("`", fieldname, ":`", ` + `, stringsPkg.Use(), `.Replace(`, fmtPkg.Use(), `.Sprintf("%v", this.`, fieldname, `), "`, typeName, `","`, msgname, `"`, ", 1) + `,", "`,") | ||||
| 				} else if repeated { | ||||
| 					repeatedName := `repeatedStringFor` + fieldname | ||||
| 					p.P("`", fieldname, ":`", ` + `, repeatedName, " + `,", "`,") | ||||
| 					p.P("`", fieldname, ":`", ` + `, stringsPkg.Use(), `.Replace(`, stringsPkg.Use(), `.Replace(`, fmtPkg.Use(), `.Sprintf("%v", this.`, fieldname, `), "`, typeName, `","`, msgname, `"`, ", 1),`&`,``,1) + `,", "`,") | ||||
| 				} else { | ||||
| 					p.P("`", fieldname, ":`", ` + `, stringsPkg.Use(), `.Replace(`, stringsPkg.Use(), `.Replace(`, stringfunc, `, "`, typeName, `","`, msgname, `"`, ", 1),`&`,``,1) + `,", "`,") | ||||
| 					p.P("`", fieldname, ":`", ` + `, stringsPkg.Use(), `.Replace(`, stringsPkg.Use(), `.Replace(this.`, fieldname, `.String(), "`, typeName, `","`, msgname, `"`, ", 1),`&`,``,1) + `,", "`,") | ||||
| 				} | ||||
| 			} else { | ||||
| 				if nullable && !repeated && !proto3 { | ||||
|   | ||||
							
								
								
									
										19
									
								
								vendor/github.com/gogo/protobuf/plugin/testgen/testgen.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/gogo/protobuf/plugin/testgen/testgen.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -270,6 +270,7 @@ func (p *testProto) Generate(imports generator.PluginImports, file *generator.Fi | ||||
| 	testingPkg := imports.NewImport("testing") | ||||
| 	randPkg := imports.NewImport("math/rand") | ||||
| 	timePkg := imports.NewImport("time") | ||||
| 	unsafePkg := imports.NewImport("unsafe") | ||||
| 	protoPkg := imports.NewImport("github.com/gogo/protobuf/proto") | ||||
| 	if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) { | ||||
| 		protoPkg = imports.NewImport("github.com/golang/protobuf/proto") | ||||
| @@ -279,11 +280,21 @@ func (p *testProto) Generate(imports generator.PluginImports, file *generator.Fi | ||||
| 		if message.DescriptorProto.GetOptions().GetMapEntry() { | ||||
| 			continue | ||||
| 		} | ||||
| 		hasUnsafe := gogoproto.IsUnsafeMarshaler(file.FileDescriptorProto, message.DescriptorProto) || | ||||
| 			gogoproto.IsUnsafeUnmarshaler(file.FileDescriptorProto, message.DescriptorProto) | ||||
| 		if gogoproto.HasTestGen(file.FileDescriptorProto, message.DescriptorProto) { | ||||
| 			used = true | ||||
|  | ||||
| 			p.P(`func Test`, ccTypeName, `Proto(t *`, testingPkg.Use(), `.T) {`) | ||||
| 			p.In() | ||||
| 			if hasUnsafe { | ||||
| 				p.P(`var bigendian uint32 = 0x01020304`) | ||||
| 				p.P(`if *(*byte)(`, unsafePkg.Use(), `.Pointer(&bigendian)) == 1 {`) | ||||
| 				p.In() | ||||
| 				p.P(`t.Skip("unsafe does not work on big endian architectures")`) | ||||
| 				p.Out() | ||||
| 				p.P(`}`) | ||||
| 			} | ||||
| 			p.P(`seed := `, timePkg.Use(), `.Now().UnixNano()`) | ||||
| 			p.P(`popr := `, randPkg.Use(), `.New(`, randPkg.Use(), `.NewSource(seed))`) | ||||
| 			p.P(`p := NewPopulated`, ccTypeName, `(popr, false)`) | ||||
| @@ -340,6 +351,14 @@ func (p *testProto) Generate(imports generator.PluginImports, file *generator.Fi | ||||
| 			if gogoproto.IsMarshaler(file.FileDescriptorProto, message.DescriptorProto) || gogoproto.IsUnsafeMarshaler(file.FileDescriptorProto, message.DescriptorProto) { | ||||
| 				p.P(`func Test`, ccTypeName, `MarshalTo(t *`, testingPkg.Use(), `.T) {`) | ||||
| 				p.In() | ||||
| 				if hasUnsafe { | ||||
| 					p.P(`var bigendian uint32 = 0x01020304`) | ||||
| 					p.P(`if *(*byte)(`, unsafePkg.Use(), `.Pointer(&bigendian)) == 1 {`) | ||||
| 					p.In() | ||||
| 					p.P(`t.Skip("unsafe does not work on big endian architectures")`) | ||||
| 					p.Out() | ||||
| 					p.P(`}`) | ||||
| 				} | ||||
| 				p.P(`seed := `, timePkg.Use(), `.Now().UnixNano()`) | ||||
| 				p.P(`popr := `, randPkg.Use(), `.New(`, randPkg.Use(), `.NewSource(seed))`) | ||||
| 				p.P(`p := NewPopulated`, ccTypeName, `(popr, false)`) | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/gogo/protobuf/plugin/union/union.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/gogo/protobuf/plugin/union/union.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -184,7 +184,7 @@ func (p *union) Generate(file *generator.FileDescriptor) { | ||||
| 				goTyp, _ := p.GoType(message, field) | ||||
| 				obj := p.ObjectNamed(field.GetTypeName()).(*generator.Descriptor) | ||||
|  | ||||
| 				if gogoproto.IsUnion(obj.File().FileDescriptorProto, obj.DescriptorProto) { | ||||
| 				if gogoproto.IsUnion(obj.File(), obj.DescriptorProto) { | ||||
| 					p.P(`this.`, fieldname, ` = new(`, generator.GoTypeToName(goTyp), `)`) | ||||
| 					p.P(`if set := this.`, fieldname, `.SetValue(value); set {`) | ||||
| 					p.In() | ||||
|   | ||||
							
								
								
									
										904
									
								
								vendor/github.com/gogo/protobuf/plugin/unmarshal/unmarshal.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										904
									
								
								vendor/github.com/gogo/protobuf/plugin/unmarshal/unmarshal.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										4
									
								
								vendor/github.com/gogo/protobuf/proto/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/gogo/protobuf/proto/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -38,6 +38,6 @@ test: install generate-test-pbs | ||||
|  | ||||
| generate-test-pbs: | ||||
| 	make install | ||||
| 	make -C test_proto | ||||
| 	make -C proto3_proto | ||||
| 	make -C testdata | ||||
| 	protoc-min-version --version="3.0.0" --proto_path=.:../../../../:../protobuf --gogo_out=Mtestdata/test.proto=github.com/gogo/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. proto3_proto/proto3.proto | ||||
| 	make | ||||
|   | ||||
							
								
								
									
										651
									
								
								vendor/github.com/gogo/protobuf/proto/all_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										651
									
								
								vendor/github.com/gogo/protobuf/proto/all_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -41,15 +41,11 @@ import ( | ||||
| 	"reflect" | ||||
| 	"runtime/debug" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/jsonpb" | ||||
| 	. "github.com/gogo/protobuf/proto" | ||||
| 	pb3 "github.com/gogo/protobuf/proto/proto3_proto" | ||||
| 	. "github.com/gogo/protobuf/proto/test_proto" | ||||
| 	descriptorpb "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" | ||||
| 	. "github.com/gogo/protobuf/proto/testdata" | ||||
| ) | ||||
|  | ||||
| var globalO *Buffer | ||||
| @@ -118,8 +114,6 @@ func initGoTest(setdefaults bool) *GoTest { | ||||
| 		pb.F_BytesDefaulted = Default_GoTest_F_BytesDefaulted | ||||
| 		pb.F_Sint32Defaulted = Int32(Default_GoTest_F_Sint32Defaulted) | ||||
| 		pb.F_Sint64Defaulted = Int64(Default_GoTest_F_Sint64Defaulted) | ||||
| 		pb.F_Sfixed32Defaulted = Int32(Default_GoTest_F_Sfixed32Defaulted) | ||||
| 		pb.F_Sfixed64Defaulted = Int64(Default_GoTest_F_Sfixed64Defaulted) | ||||
| 	} | ||||
|  | ||||
| 	pb.Kind = GoTest_TIME.Enum() | ||||
| @@ -137,13 +131,135 @@ func initGoTest(setdefaults bool) *GoTest { | ||||
| 	pb.F_BytesRequired = []byte("bytes") | ||||
| 	pb.F_Sint32Required = Int32(-32) | ||||
| 	pb.F_Sint64Required = Int64(-64) | ||||
| 	pb.F_Sfixed32Required = Int32(-32) | ||||
| 	pb.F_Sfixed64Required = Int64(-64) | ||||
| 	pb.Requiredgroup = initGoTest_RequiredGroup() | ||||
|  | ||||
| 	return pb | ||||
| } | ||||
|  | ||||
| func fail(msg string, b *bytes.Buffer, s string, t *testing.T) { | ||||
| 	data := b.Bytes() | ||||
| 	ld := len(data) | ||||
| 	ls := len(s) / 2 | ||||
|  | ||||
| 	fmt.Printf("fail %s ld=%d ls=%d\n", msg, ld, ls) | ||||
|  | ||||
| 	// find the interesting spot - n | ||||
| 	n := ls | ||||
| 	if ld < ls { | ||||
| 		n = ld | ||||
| 	} | ||||
| 	j := 0 | ||||
| 	for i := 0; i < n; i++ { | ||||
| 		bs := hex(s[j])*16 + hex(s[j+1]) | ||||
| 		j += 2 | ||||
| 		if data[i] == bs { | ||||
| 			continue | ||||
| 		} | ||||
| 		n = i | ||||
| 		break | ||||
| 	} | ||||
| 	l := n - 10 | ||||
| 	if l < 0 { | ||||
| 		l = 0 | ||||
| 	} | ||||
| 	h := n + 10 | ||||
|  | ||||
| 	// find the interesting spot - n | ||||
| 	fmt.Printf("is[%d]:", l) | ||||
| 	for i := l; i < h; i++ { | ||||
| 		if i >= ld { | ||||
| 			fmt.Printf(" --") | ||||
| 			continue | ||||
| 		} | ||||
| 		fmt.Printf(" %.2x", data[i]) | ||||
| 	} | ||||
| 	fmt.Printf("\n") | ||||
|  | ||||
| 	fmt.Printf("sb[%d]:", l) | ||||
| 	for i := l; i < h; i++ { | ||||
| 		if i >= ls { | ||||
| 			fmt.Printf(" --") | ||||
| 			continue | ||||
| 		} | ||||
| 		bs := hex(s[j])*16 + hex(s[j+1]) | ||||
| 		j += 2 | ||||
| 		fmt.Printf(" %.2x", bs) | ||||
| 	} | ||||
| 	fmt.Printf("\n") | ||||
|  | ||||
| 	t.Fail() | ||||
|  | ||||
| 	//	t.Errorf("%s: \ngood: %s\nbad: %x", msg, s, b.Bytes()) | ||||
| 	// Print the output in a partially-decoded format; can | ||||
| 	// be helpful when updating the test.  It produces the output | ||||
| 	// that is pasted, with minor edits, into the argument to verify(). | ||||
| 	//	data := b.Bytes() | ||||
| 	//	nesting := 0 | ||||
| 	//	for b.Len() > 0 { | ||||
| 	//		start := len(data) - b.Len() | ||||
| 	//		var u uint64 | ||||
| 	//		u, err := DecodeVarint(b) | ||||
| 	//		if err != nil { | ||||
| 	//			fmt.Printf("decode error on varint:", err) | ||||
| 	//			return | ||||
| 	//		} | ||||
| 	//		wire := u & 0x7 | ||||
| 	//		tag := u >> 3 | ||||
| 	//		switch wire { | ||||
| 	//		case WireVarint: | ||||
| 	//			v, err := DecodeVarint(b) | ||||
| 	//			if err != nil { | ||||
| 	//				fmt.Printf("decode error on varint:", err) | ||||
| 	//				return | ||||
| 	//			} | ||||
| 	//			fmt.Printf("\t\t\"%x\"  // field %d, encoding %d, value %d\n", | ||||
| 	//				data[start:len(data)-b.Len()], tag, wire, v) | ||||
| 	//		case WireFixed32: | ||||
| 	//			v, err := DecodeFixed32(b) | ||||
| 	//			if err != nil { | ||||
| 	//				fmt.Printf("decode error on fixed32:", err) | ||||
| 	//				return | ||||
| 	//			} | ||||
| 	//			fmt.Printf("\t\t\"%x\"  // field %d, encoding %d, value %d\n", | ||||
| 	//				data[start:len(data)-b.Len()], tag, wire, v) | ||||
| 	//		case WireFixed64: | ||||
| 	//			v, err := DecodeFixed64(b) | ||||
| 	//			if err != nil { | ||||
| 	//				fmt.Printf("decode error on fixed64:", err) | ||||
| 	//				return | ||||
| 	//			} | ||||
| 	//			fmt.Printf("\t\t\"%x\"  // field %d, encoding %d, value %d\n", | ||||
| 	//				data[start:len(data)-b.Len()], tag, wire, v) | ||||
| 	//		case WireBytes: | ||||
| 	//			nb, err := DecodeVarint(b) | ||||
| 	//			if err != nil { | ||||
| 	//				fmt.Printf("decode error on bytes:", err) | ||||
| 	//				return | ||||
| 	//			} | ||||
| 	//			after_tag := len(data) - b.Len() | ||||
| 	//			str := make([]byte, nb) | ||||
| 	//			_, err = b.Read(str) | ||||
| 	//			if err != nil { | ||||
| 	//				fmt.Printf("decode error on bytes:", err) | ||||
| 	//				return | ||||
| 	//			} | ||||
| 	//			fmt.Printf("\t\t\"%x\" \"%x\"  // field %d, encoding %d (FIELD)\n", | ||||
| 	//				data[start:after_tag], str, tag, wire) | ||||
| 	//		case WireStartGroup: | ||||
| 	//			nesting++ | ||||
| 	//			fmt.Printf("\t\t\"%x\"\t\t// start group field %d level %d\n", | ||||
| 	//				data[start:len(data)-b.Len()], tag, nesting) | ||||
| 	//		case WireEndGroup: | ||||
| 	//			fmt.Printf("\t\t\"%x\"\t\t// end group field %d level %d\n", | ||||
| 	//				data[start:len(data)-b.Len()], tag, nesting) | ||||
| 	//			nesting-- | ||||
| 	//		default: | ||||
| 	//			fmt.Printf("unrecognized wire type %d\n", wire) | ||||
| 	//			return | ||||
| 	//		} | ||||
| 	//	} | ||||
| } | ||||
|  | ||||
| func hex(c uint8) uint8 { | ||||
| 	if '0' <= c && c <= '9' { | ||||
| 		return c - '0' | ||||
| @@ -366,48 +482,6 @@ func TestMarshalerEncoding(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Ensure that Buffer.Marshal uses O(N) memory for N messages | ||||
| func TestBufferMarshalAllocs(t *testing.T) { | ||||
| 	value := &OtherMessage{Key: Int64(1)} | ||||
| 	msg := &MyMessage{Count: Int32(1), Others: []*OtherMessage{value}} | ||||
|  | ||||
| 	reallocSize := func(t *testing.T, items int, prealloc int) (int64, int64) { | ||||
| 		var b Buffer | ||||
| 		b.SetBuf(make([]byte, 0, prealloc)) | ||||
|  | ||||
| 		var allocSpace int64 | ||||
| 		prevCap := cap(b.Bytes()) | ||||
| 		for i := 0; i < items; i++ { | ||||
| 			err := b.Marshal(msg) | ||||
| 			if err != nil { | ||||
| 				t.Errorf("Marshal err = %q", err) | ||||
| 				break | ||||
| 			} | ||||
| 			if c := cap(b.Bytes()); prevCap != c { | ||||
| 				allocSpace += int64(c) | ||||
| 				prevCap = c | ||||
| 			} | ||||
| 		} | ||||
| 		needSpace := int64(len(b.Bytes())) | ||||
| 		return allocSpace, needSpace | ||||
| 	} | ||||
|  | ||||
| 	for _, prealloc := range []int{0, 100, 10000} { | ||||
| 		for _, items := range []int{1, 2, 5, 10, 20, 50, 100, 200, 500, 1000} { | ||||
| 			runtimeSpace, need := reallocSize(t, items, prealloc) | ||||
| 			totalSpace := int64(prealloc) + runtimeSpace | ||||
|  | ||||
| 			runtimeRatio := float64(runtimeSpace) / float64(need) | ||||
| 			totalRatio := float64(totalSpace) / float64(need) | ||||
|  | ||||
| 			if totalRatio < 1 || runtimeRatio > 4 { | ||||
| 				t.Errorf("needed %dB, allocated %dB total (ratio %.1f), allocated %dB at runtime (ratio %.1f)", | ||||
| 					need, totalSpace, totalRatio, runtimeSpace, runtimeRatio) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Simple tests for bytes | ||||
| func TestBytesPrimitives(t *testing.T) { | ||||
| 	o := old() | ||||
| @@ -445,7 +519,7 @@ func TestRequiredBit(t *testing.T) { | ||||
| 	err := o.Marshal(pb) | ||||
| 	if err == nil { | ||||
| 		t.Error("did not catch missing required fields") | ||||
| 	} else if !strings.Contains(err.Error(), "Kind") { | ||||
| 	} else if strings.Index(err.Error(), "Kind") < 0 { | ||||
| 		t.Error("wrong error type:", err) | ||||
| 	} | ||||
| } | ||||
| @@ -538,9 +612,7 @@ func TestEncodeDecode1(t *testing.T) { | ||||
| 			"b404"+ // field 70, encoding 4, end group | ||||
| 			"aa0605"+"6279746573"+ // field 101, encoding 2, string "bytes" | ||||
| 			"b0063f"+ // field 102, encoding 0, 0x3f zigzag32 | ||||
| 			"b8067f"+ // field 103, encoding 0, 0x7f zigzag64 | ||||
| 			"c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 | ||||
| 			"c906c0ffffffffffffff") // field 105, encoding 1, -64 fixed64 | ||||
| 			"b8067f") // field 103, encoding 0, 0x7f zigzag64 | ||||
| } | ||||
|  | ||||
| // All required fields set, defaults provided. | ||||
| @@ -575,13 +647,9 @@ func TestEncodeDecode2(t *testing.T) { | ||||
| 			"aa0605"+"6279746573"+ // field 101, encoding 2 string "bytes" | ||||
| 			"b0063f"+ // field 102, encoding 0, 0x3f zigzag32 | ||||
| 			"b8067f"+ // field 103, encoding 0, 0x7f zigzag64 | ||||
| 			"c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 | ||||
| 			"c906c0ffffffffffffff"+ // field 105, encoding 1, -64 fixed64 | ||||
| 			"8a1907"+"4269676e6f7365"+ // field 401, encoding 2, string "Bignose" | ||||
| 			"90193f"+ // field 402, encoding 0, value 63 | ||||
| 			"98197f"+ // field 403, encoding 0, value 127 | ||||
| 			"a519e0ffffff"+ // field 404, encoding 5, -32 fixed32 | ||||
| 			"a919c0ffffffffffffff") // field 405, encoding 1, -64 fixed64 | ||||
| 			"98197f") // field 403, encoding 0, value 127 | ||||
|  | ||||
| } | ||||
|  | ||||
| @@ -601,8 +669,6 @@ func TestEncodeDecode3(t *testing.T) { | ||||
| 	pb.F_BytesDefaulted = []byte("Bignose") | ||||
| 	pb.F_Sint32Defaulted = Int32(-32) | ||||
| 	pb.F_Sint64Defaulted = Int64(-64) | ||||
| 	pb.F_Sfixed32Defaulted = Int32(-32) | ||||
| 	pb.F_Sfixed64Defaulted = Int64(-64) | ||||
|  | ||||
| 	overify(t, pb, | ||||
| 		"0807"+ // field 1, encoding 0, value 7 | ||||
| @@ -633,13 +699,9 @@ func TestEncodeDecode3(t *testing.T) { | ||||
| 			"aa0605"+"6279746573"+ // field 101, encoding 2 string "bytes" | ||||
| 			"b0063f"+ // field 102, encoding 0, 0x3f zigzag32 | ||||
| 			"b8067f"+ // field 103, encoding 0, 0x7f zigzag64 | ||||
| 			"c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 | ||||
| 			"c906c0ffffffffffffff"+ // field 105, encoding 1, -64 fixed64 | ||||
| 			"8a1907"+"4269676e6f7365"+ // field 401, encoding 2, string "Bignose" | ||||
| 			"90193f"+ // field 402, encoding 0, value 63 | ||||
| 			"98197f"+ // field 403, encoding 0, value 127 | ||||
| 			"a519e0ffffff"+ // field 404, encoding 5, -32 fixed32 | ||||
| 			"a919c0ffffffffffffff") // field 405, encoding 1, -64 fixed64 | ||||
| 			"98197f") // field 403, encoding 0, value 127 | ||||
|  | ||||
| } | ||||
|  | ||||
| @@ -662,8 +724,6 @@ func TestEncodeDecode4(t *testing.T) { | ||||
| 	pb.F_BytesOptional = []byte("Bignose") | ||||
| 	pb.F_Sint32Optional = Int32(-32) | ||||
| 	pb.F_Sint64Optional = Int64(-64) | ||||
| 	pb.F_Sfixed32Optional = Int32(-32) | ||||
| 	pb.F_Sfixed64Optional = Int64(-64) | ||||
| 	pb.Optionalgroup = initGoTest_OptionalGroup() | ||||
|  | ||||
| 	overify(t, pb, | ||||
| @@ -711,18 +771,12 @@ func TestEncodeDecode4(t *testing.T) { | ||||
| 			"aa0605"+"6279746573"+ // field 101, encoding 2 string "bytes" | ||||
| 			"b0063f"+ // field 102, encoding 0, 0x3f zigzag32 | ||||
| 			"b8067f"+ // field 103, encoding 0, 0x7f zigzag64 | ||||
| 			"c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 | ||||
| 			"c906c0ffffffffffffff"+ // field 105, encoding 1, -64 fixed64 | ||||
| 			"ea1207"+"4269676e6f7365"+ // field 301, encoding 2, string "Bignose" | ||||
| 			"f0123f"+ // field 302, encoding 0, value 63 | ||||
| 			"f8127f"+ // field 303, encoding 0, value 127 | ||||
| 			"8513e0ffffff"+ // field 304, encoding 5, -32 fixed32 | ||||
| 			"8913c0ffffffffffffff"+ // field 305, encoding 1, -64 fixed64 | ||||
| 			"8a1907"+"4269676e6f7365"+ // field 401, encoding 2, string "Bignose" | ||||
| 			"90193f"+ // field 402, encoding 0, value 63 | ||||
| 			"98197f"+ // field 403, encoding 0, value 127 | ||||
| 			"a519e0ffffff"+ // field 404, encoding 5, -32 fixed32 | ||||
| 			"a919c0ffffffffffffff") // field 405, encoding 1, -64 fixed64 | ||||
| 			"98197f") // field 403, encoding 0, value 127 | ||||
|  | ||||
| } | ||||
|  | ||||
| @@ -743,8 +797,6 @@ func TestEncodeDecode5(t *testing.T) { | ||||
| 	pb.F_BytesRepeated = [][]byte{[]byte("big"), []byte("nose")} | ||||
| 	pb.F_Sint32Repeated = []int32{32, -32} | ||||
| 	pb.F_Sint64Repeated = []int64{64, -64} | ||||
| 	pb.F_Sfixed32Repeated = []int32{32, -32} | ||||
| 	pb.F_Sfixed64Repeated = []int64{64, -64} | ||||
| 	pb.Repeatedgroup = []*GoTest_RepeatedGroup{initGoTest_RepeatedGroup(), initGoTest_RepeatedGroup()} | ||||
|  | ||||
| 	overify(t, pb, | ||||
| @@ -804,23 +856,15 @@ func TestEncodeDecode5(t *testing.T) { | ||||
| 			"aa0605"+"6279746573"+ // field 101, encoding 2 string "bytes" | ||||
| 			"b0063f"+ // field 102, encoding 0, 0x3f zigzag32 | ||||
| 			"b8067f"+ // field 103, encoding 0, 0x7f zigzag64 | ||||
| 			"c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 | ||||
| 			"c906c0ffffffffffffff"+ // field 105, encoding 1, -64 fixed64 | ||||
| 			"ca0c03"+"626967"+ // field 201, encoding 2, string "big" | ||||
| 			"ca0c04"+"6e6f7365"+ // field 201, encoding 2, string "nose" | ||||
| 			"d00c40"+ // field 202, encoding 0, value 32 | ||||
| 			"d00c3f"+ // field 202, encoding 0, value -32 | ||||
| 			"d80c8001"+ // field 203, encoding 0, value 64 | ||||
| 			"d80c7f"+ // field 203, encoding 0, value -64 | ||||
| 			"e50c20000000"+ // field 204, encoding 5, 32 fixed32 | ||||
| 			"e50ce0ffffff"+ // field 204, encoding 5, -32 fixed32 | ||||
| 			"e90c4000000000000000"+ // field 205, encoding 1, 64 fixed64 | ||||
| 			"e90cc0ffffffffffffff"+ // field 205, encoding 1, -64 fixed64 | ||||
| 			"8a1907"+"4269676e6f7365"+ // field 401, encoding 2, string "Bignose" | ||||
| 			"90193f"+ // field 402, encoding 0, value 63 | ||||
| 			"98197f"+ // field 403, encoding 0, value 127 | ||||
| 			"a519e0ffffff"+ // field 404, encoding 5, -32 fixed32 | ||||
| 			"a919c0ffffffffffffff") // field 405, encoding 1, -64 fixed64 | ||||
| 			"98197f") // field 403, encoding 0, value 127 | ||||
|  | ||||
| } | ||||
|  | ||||
| @@ -838,8 +882,6 @@ func TestEncodeDecode6(t *testing.T) { | ||||
| 	pb.F_DoubleRepeatedPacked = []float64{64., 65.} | ||||
| 	pb.F_Sint32RepeatedPacked = []int32{32, -32} | ||||
| 	pb.F_Sint64RepeatedPacked = []int64{64, -64} | ||||
| 	pb.F_Sfixed32RepeatedPacked = []int32{32, -32} | ||||
| 	pb.F_Sfixed64RepeatedPacked = []int64{64, -64} | ||||
|  | ||||
| 	overify(t, pb, | ||||
| 		"0807"+ // field 1, encoding 0, value 7 | ||||
| @@ -875,17 +917,10 @@ func TestEncodeDecode6(t *testing.T) { | ||||
| 			"aa0605"+"6279746573"+ // field 101, encoding 2 string "bytes" | ||||
| 			"b0063f"+ // field 102, encoding 0, 0x3f zigzag32 | ||||
| 			"b8067f"+ // field 103, encoding 0, 0x7f zigzag64 | ||||
| 			"c506e0ffffff"+ // field 104, encoding 5, -32 fixed32 | ||||
| 			"c906c0ffffffffffffff"+ // field 105, encoding 1, -64 fixed64 | ||||
| 			"b21f02"+ // field 502, encoding 2, 2 bytes | ||||
| 			"403f"+ // value 32, value -32 | ||||
| 			"ba1f03"+ // field 503, encoding 2, 3 bytes | ||||
| 			"80017f"+ // value 64, value -64 | ||||
| 			"c21f08"+ // field 504, encoding 2, 8 bytes | ||||
| 			"20000000e0ffffff"+ // value 32, value -32 | ||||
| 			"ca1f10"+ // field 505, encoding 2, 16 bytes | ||||
| 			"4000000000000000c0ffffffffffffff") // value 64, value -64 | ||||
|  | ||||
| 			"80017f") // value 64, value -64 | ||||
| } | ||||
|  | ||||
| // Test that we can encode empty bytes fields. | ||||
| @@ -1132,10 +1167,13 @@ func TestBigRepeated(t *testing.T) { | ||||
| 		if pbd.Repeatedgroup[i] == nil { // TODO: more checking? | ||||
| 			t.Error("pbd.Repeatedgroup bad") | ||||
| 		} | ||||
| 		if x := uint64(pbd.F_Sint64Repeated[i]); x != i { | ||||
| 		var x uint64 | ||||
| 		x = uint64(pbd.F_Sint64Repeated[i]) | ||||
| 		if x != i { | ||||
| 			t.Error("pbd.F_Sint64Repeated bad", x, i) | ||||
| 		} | ||||
| 		if x := uint64(pbd.F_Sint32Repeated[i]); x != i { | ||||
| 		x = uint64(pbd.F_Sint32Repeated[i]) | ||||
| 		if x != i { | ||||
| 			t.Error("pbd.F_Sint32Repeated bad", x, i) | ||||
| 		} | ||||
| 		s := fmt.Sprint(i) | ||||
| @@ -1143,31 +1181,39 @@ func TestBigRepeated(t *testing.T) { | ||||
| 		if pbd.F_StringRepeated[i] != s { | ||||
| 			t.Error("pbd.F_Sint32Repeated bad", pbd.F_StringRepeated[i], i) | ||||
| 		} | ||||
| 		if x := uint64(pbd.F_DoubleRepeated[i]); x != i { | ||||
| 		x = uint64(pbd.F_DoubleRepeated[i]) | ||||
| 		if x != i { | ||||
| 			t.Error("pbd.F_DoubleRepeated bad", x, i) | ||||
| 		} | ||||
| 		if x := uint64(pbd.F_FloatRepeated[i]); x != i { | ||||
| 		x = uint64(pbd.F_FloatRepeated[i]) | ||||
| 		if x != i { | ||||
| 			t.Error("pbd.F_FloatRepeated bad", x, i) | ||||
| 		} | ||||
| 		if x := pbd.F_Uint64Repeated[i]; x != i { | ||||
| 		x = pbd.F_Uint64Repeated[i] | ||||
| 		if x != i { | ||||
| 			t.Error("pbd.F_Uint64Repeated bad", x, i) | ||||
| 		} | ||||
| 		if x := uint64(pbd.F_Uint32Repeated[i]); x != i { | ||||
| 		x = uint64(pbd.F_Uint32Repeated[i]) | ||||
| 		if x != i { | ||||
| 			t.Error("pbd.F_Uint32Repeated bad", x, i) | ||||
| 		} | ||||
| 		if x := pbd.F_Fixed64Repeated[i]; x != i { | ||||
| 		x = pbd.F_Fixed64Repeated[i] | ||||
| 		if x != i { | ||||
| 			t.Error("pbd.F_Fixed64Repeated bad", x, i) | ||||
| 		} | ||||
| 		if x := uint64(pbd.F_Fixed32Repeated[i]); x != i { | ||||
| 		x = uint64(pbd.F_Fixed32Repeated[i]) | ||||
| 		if x != i { | ||||
| 			t.Error("pbd.F_Fixed32Repeated bad", x, i) | ||||
| 		} | ||||
| 		if x := uint64(pbd.F_Int64Repeated[i]); x != i { | ||||
| 		x = uint64(pbd.F_Int64Repeated[i]) | ||||
| 		if x != i { | ||||
| 			t.Error("pbd.F_Int64Repeated bad", x, i) | ||||
| 		} | ||||
| 		if x := uint64(pbd.F_Int32Repeated[i]); x != i { | ||||
| 		x = uint64(pbd.F_Int32Repeated[i]) | ||||
| 		if x != i { | ||||
| 			t.Error("pbd.F_Int32Repeated bad", x, i) | ||||
| 		} | ||||
| 		if x := pbd.F_BoolRepeated[i]; x != (i%2 == 0) { | ||||
| 		if pbd.F_BoolRepeated[i] != (i%2 == 0) { | ||||
| 			t.Error("pbd.F_BoolRepeated bad", x, i) | ||||
| 		} | ||||
| 		if pbd.RepeatedField[i] == nil { // TODO: more checking? | ||||
| @@ -1176,25 +1222,21 @@ func TestBigRepeated(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestBadWireTypeUnknown(t *testing.T) { | ||||
| 	var b []byte | ||||
| 	fmt.Sscanf("0a01780d00000000080b101612036161611521000000202c220362626225370000002203636363214200000000000000584d5a036464645900000000000056405d63000000", "%x", &b) | ||||
| // Verify we give a useful message when decoding to the wrong structure type. | ||||
| func TestTypeMismatch(t *testing.T) { | ||||
| 	pb1 := initGoTest(true) | ||||
|  | ||||
| 	m := new(MyMessage) | ||||
| 	if err := Unmarshal(b, m); err != nil { | ||||
| 		t.Errorf("unexpected Unmarshal error: %v", err) | ||||
| 	} | ||||
| 	// Marshal | ||||
| 	o := old() | ||||
| 	o.Marshal(pb1) | ||||
|  | ||||
| 	var unknown []byte | ||||
| 	fmt.Sscanf("0a01780d0000000010161521000000202c2537000000214200000000000000584d5a036464645d63000000", "%x", &unknown) | ||||
| 	if !bytes.Equal(m.XXX_unrecognized, unknown) { | ||||
| 		t.Errorf("unknown bytes mismatch:\ngot  %x\nwant %x", m.XXX_unrecognized, unknown) | ||||
| 	} | ||||
| 	DiscardUnknown(m) | ||||
|  | ||||
| 	want := &MyMessage{Count: Int32(11), Name: String("aaa"), Pet: []string{"bbb", "ccc"}, Bigfloat: Float64(88)} | ||||
| 	if !Equal(m, want) { | ||||
| 		t.Errorf("message mismatch:\ngot  %v\nwant %v", m, want) | ||||
| 	// Now Unmarshal it to the wrong type. | ||||
| 	pb2 := initGoTestField() | ||||
| 	err := o.Unmarshal(pb2) | ||||
| 	if err == nil { | ||||
| 		t.Error("expected error, got no error") | ||||
| 	} else if !strings.Contains(err.Error(), "bad wiretype") { | ||||
| 		t.Error("expected bad wiretype error, got", err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -1289,8 +1331,7 @@ func TestRequiredFieldEnforcement(t *testing.T) { | ||||
| 	err = Unmarshal(buf, pb) | ||||
| 	if err == nil { | ||||
| 		t.Error("unmarshal: expected error, got nil") | ||||
| 	} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Type") && !strings.Contains(err.Error(), "{Unknown}") { | ||||
| 		// TODO: remove unknown cases once we commit to the new unmarshaler. | ||||
| 	} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "{Unknown}") { | ||||
| 		t.Errorf("unmarshal: bad error type: %v", err) | ||||
| 	} | ||||
| } | ||||
| @@ -1307,7 +1348,7 @@ func TestRequiredFieldEnforcementGroups(t *testing.T) { | ||||
| 	buf := []byte{11, 12} | ||||
| 	if err := Unmarshal(buf, pb); err == nil { | ||||
| 		t.Error("unmarshal: expected error, got nil") | ||||
| 	} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Group.Field") && !strings.Contains(err.Error(), "Group.{Unknown}") { | ||||
| 	} else if _, ok := err.(*RequiredNotSetError); !ok || !strings.Contains(err.Error(), "Group.{Unknown}") { | ||||
| 		t.Errorf("unmarshal: bad error type: %v", err) | ||||
| 	} | ||||
| } | ||||
| @@ -1344,7 +1385,18 @@ func (*NNIMessage) Reset()         {} | ||||
| func (*NNIMessage) String() string { return "" } | ||||
| func (*NNIMessage) ProtoMessage()  {} | ||||
|  | ||||
| type NMMessage struct{} | ||||
| // A type that implements the Marshaler interface and is nillable. | ||||
| type nillableMessage struct { | ||||
| 	x uint64 | ||||
| } | ||||
|  | ||||
| func (nm *nillableMessage) Marshal() ([]byte, error) { | ||||
| 	return EncodeVarint(nm.x), nil | ||||
| } | ||||
|  | ||||
| type NMMessage struct { | ||||
| 	nm *nillableMessage | ||||
| } | ||||
|  | ||||
| func (*NMMessage) Reset()         {} | ||||
| func (*NMMessage) String() string { return "" } | ||||
| @@ -1543,14 +1595,6 @@ func TestVarintOverflow(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestBytesWithInvalidLengthInGroup(t *testing.T) { | ||||
| 	// Overflowing a 64-bit length should not be allowed. | ||||
| 	b := []byte{0xbb, 0x30, 0xb2, 0x30, 0xb0, 0xb2, 0x83, 0xf1, 0xb0, 0xb2, 0xef, 0xbf, 0xbd, 0x01} | ||||
| 	if err := Unmarshal(b, new(MyMessage)); err == nil { | ||||
| 		t.Fatalf("Overflowed uint64 length without error") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestUnmarshalFuzz(t *testing.T) { | ||||
| 	const N = 1000 | ||||
| 	seed := time.Now().UnixNano() | ||||
| @@ -1624,28 +1668,6 @@ func TestExtensionMarshalOrder(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestExtensionMapFieldMarshalDeterministic(t *testing.T) { | ||||
| 	m := &MyMessage{Count: Int(123)} | ||||
| 	if err := SetExtension(m, E_Ext_More, &Ext{MapField: map[int32]int32{1: 1, 2: 2, 3: 3, 4: 4}}); err != nil { | ||||
| 		t.Fatalf("SetExtension: %v", err) | ||||
| 	} | ||||
| 	marshal := func(m Message) []byte { | ||||
| 		var b Buffer | ||||
| 		b.SetDeterministic(true) | ||||
| 		if err := b.Marshal(m); err != nil { | ||||
| 			t.Fatalf("Marshal failed: %v", err) | ||||
| 		} | ||||
| 		return b.Bytes() | ||||
| 	} | ||||
|  | ||||
| 	want := marshal(m) | ||||
| 	for i := 0; i < 100; i++ { | ||||
| 		if got := marshal(m); !bytes.Equal(got, want) { | ||||
| 			t.Errorf("Marshal produced inconsistent output with determinism enabled (pass %d).\n got %v\nwant %v", i, got, want) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Many extensions, because small maps might not iterate differently on each iteration. | ||||
| var exts = []*ExtensionDesc{ | ||||
| 	E_X201, | ||||
| @@ -1780,43 +1802,6 @@ func TestUnmarshalMergesMessages(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestUnmarshalMergesGroups(t *testing.T) { | ||||
| 	// If a nested group occurs twice in the input, | ||||
| 	// the fields should be merged when decoding. | ||||
| 	a := &GroupNew{ | ||||
| 		G: &GroupNew_G{ | ||||
| 			X: Int32(7), | ||||
| 			Y: Int32(8), | ||||
| 		}, | ||||
| 	} | ||||
| 	aData, err := Marshal(a) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("Marshal(a): %v", err) | ||||
| 	} | ||||
| 	b := &GroupNew{ | ||||
| 		G: &GroupNew_G{ | ||||
| 			X: Int32(9), | ||||
| 		}, | ||||
| 	} | ||||
| 	bData, err := Marshal(b) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("Marshal(b): %v", err) | ||||
| 	} | ||||
| 	want := &GroupNew{ | ||||
| 		G: &GroupNew_G{ | ||||
| 			X: Int32(9), | ||||
| 			Y: Int32(8), | ||||
| 		}, | ||||
| 	} | ||||
| 	got := new(GroupNew) | ||||
| 	if err := Unmarshal(append(aData, bData...), got); err != nil { | ||||
| 		t.Fatalf("Unmarshal: %v", err) | ||||
| 	} | ||||
| 	if !Equal(got, want) { | ||||
| 		t.Errorf("\n got %v\nwant %v", got, want) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestEncodingSizes(t *testing.T) { | ||||
| 	tests := []struct { | ||||
| 		m Message | ||||
| @@ -1860,9 +1845,7 @@ func TestRequiredNotSetError(t *testing.T) { | ||||
| 		"b404" + // field 70, encoding 4, end group | ||||
| 		"aa0605" + "6279746573" + // field 101, encoding 2, string "bytes" | ||||
| 		"b0063f" + // field 102, encoding 0, 0x3f zigzag32 | ||||
| 		"b8067f" + // field 103, encoding 0, 0x7f zigzag64 | ||||
| 		"c506e0ffffff" + // field 104, encoding 5, -32 fixed32 | ||||
| 		"c906c0ffffffffffffff" // field 105, encoding 1, -64 fixed64 | ||||
| 		"b8067f" // field 103, encoding 0, 0x7f zigzag64 | ||||
|  | ||||
| 	o := old() | ||||
| 	mbytes, err := Marshal(pb) | ||||
| @@ -1871,7 +1854,7 @@ func TestRequiredNotSetError(t *testing.T) { | ||||
| 		o.DebugPrint("", mbytes) | ||||
| 		t.Fatalf("expected = %s", expected) | ||||
| 	} | ||||
| 	if !strings.Contains(err.Error(), "RequiredField.Label") { | ||||
| 	if strings.Index(err.Error(), "RequiredField.Label") < 0 { | ||||
| 		t.Errorf("marshal-1 wrong err msg: %v", err) | ||||
| 	} | ||||
| 	if !equal(mbytes, expected, t) { | ||||
| @@ -1887,7 +1870,7 @@ func TestRequiredNotSetError(t *testing.T) { | ||||
| 		o.DebugPrint("", mbytes) | ||||
| 		t.Fatalf("string = %s", expected) | ||||
| 	} | ||||
| 	if !strings.Contains(err.Error(), "RequiredField.Label") && !strings.Contains(err.Error(), "RequiredField.{Unknown}") { | ||||
| 	if strings.Index(err.Error(), "RequiredField.{Unknown}") < 0 { | ||||
| 		t.Errorf("unmarshal wrong err msg: %v", err) | ||||
| 	} | ||||
| 	mbytes, err = Marshal(pbd) | ||||
| @@ -1896,7 +1879,7 @@ func TestRequiredNotSetError(t *testing.T) { | ||||
| 		o.DebugPrint("", mbytes) | ||||
| 		t.Fatalf("string = %s", expected) | ||||
| 	} | ||||
| 	if !strings.Contains(err.Error(), "RequiredField.Label") { | ||||
| 	if strings.Index(err.Error(), "RequiredField.Label") < 0 { | ||||
| 		t.Errorf("marshal-2 wrong err msg: %v", err) | ||||
| 	} | ||||
| 	if !equal(mbytes, expected, t) { | ||||
| @@ -1905,25 +1888,6 @@ func TestRequiredNotSetError(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestRequiredNotSetErrorWithBadWireTypes(t *testing.T) { | ||||
| 	// Required field expects a varint, and properly found a varint. | ||||
| 	if err := Unmarshal([]byte{0x08, 0x00}, new(GoEnum)); err != nil { | ||||
| 		t.Errorf("Unmarshal = %v, want nil", err) | ||||
| 	} | ||||
| 	// Required field expects a varint, but found a fixed32 instead. | ||||
| 	if err := Unmarshal([]byte{0x0d, 0x00, 0x00, 0x00, 0x00}, new(GoEnum)); err == nil { | ||||
| 		t.Errorf("Unmarshal = nil, want RequiredNotSetError") | ||||
| 	} | ||||
| 	// Required field expects a varint, and found both a varint and fixed32 (ignored). | ||||
| 	m := new(GoEnum) | ||||
| 	if err := Unmarshal([]byte{0x08, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00}, m); err != nil { | ||||
| 		t.Errorf("Unmarshal = %v, want nil", err) | ||||
| 	} | ||||
| 	if !bytes.Equal(m.XXX_unrecognized, []byte{0x0d, 0x00, 0x00, 0x00, 0x00}) { | ||||
| 		t.Errorf("expected fixed32 to appear as unknown bytes: %x", m.XXX_unrecognized) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func fuzzUnmarshal(t *testing.T, data []byte) { | ||||
| 	defer func() { | ||||
| 		if e := recover(); e != nil { | ||||
| @@ -1982,32 +1946,6 @@ func TestMapFieldMarshal(t *testing.T) { | ||||
| 	(new(Buffer)).DebugPrint("Dump of b", b) | ||||
| } | ||||
|  | ||||
| func TestMapFieldDeterministicMarshal(t *testing.T) { | ||||
| 	m := &MessageWithMap{ | ||||
| 		NameMapping: map[int32]string{ | ||||
| 			1: "Rob", | ||||
| 			4: "Ian", | ||||
| 			8: "Dave", | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	marshal := func(m Message) []byte { | ||||
| 		var b Buffer | ||||
| 		b.SetDeterministic(true) | ||||
| 		if err := b.Marshal(m); err != nil { | ||||
| 			t.Fatalf("Marshal failed: %v", err) | ||||
| 		} | ||||
| 		return b.Bytes() | ||||
| 	} | ||||
|  | ||||
| 	want := marshal(m) | ||||
| 	for i := 0; i < 10; i++ { | ||||
| 		if got := marshal(m); !bytes.Equal(got, want) { | ||||
| 			t.Errorf("Marshal produced inconsistent output with determinism enabled (pass %d).\n got %v\nwant %v", i, got, want) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestMapFieldRoundTrips(t *testing.T) { | ||||
| 	m := &MessageWithMap{ | ||||
| 		NameMapping: map[int32]string{ | ||||
| @@ -2032,8 +1970,14 @@ func TestMapFieldRoundTrips(t *testing.T) { | ||||
| 	if err := Unmarshal(b, m2); err != nil { | ||||
| 		t.Fatalf("Unmarshal: %v", err) | ||||
| 	} | ||||
| 	if !Equal(m, m2) { | ||||
| 		t.Errorf("Map did not survive a round trip.\ninitial: %v\n  final: %v", m, m2) | ||||
| 	for _, pair := range [][2]interface{}{ | ||||
| 		{m.NameMapping, m2.NameMapping}, | ||||
| 		{m.MsgMapping, m2.MsgMapping}, | ||||
| 		{m.ByteMapping, m2.ByteMapping}, | ||||
| 	} { | ||||
| 		if !reflect.DeepEqual(pair[0], pair[1]) { | ||||
| 			t.Errorf("Map did not survive a round trip.\ninitial: %v\n  final: %v", pair[0], pair[1]) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -2175,22 +2119,6 @@ func TestOneof(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestOneofNilBytes(t *testing.T) { | ||||
| 	// A oneof with nil byte slice should marshal to tag + 0 (size), with no error. | ||||
| 	m := &Communique{Union: &Communique_Data{Data: nil}} | ||||
| 	b, err := Marshal(m) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("Marshal failed: %v", err) | ||||
| 	} | ||||
| 	want := []byte{ | ||||
| 		7<<3 | 2, // tag 7, wire type 2 | ||||
| 		0,        // size | ||||
| 	} | ||||
| 	if !bytes.Equal(b, want) { | ||||
| 		t.Errorf("Wrong result of Marshal: got %x, want %x", b, want) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestInefficientPackedBool(t *testing.T) { | ||||
| 	// https://github.com/golang/protobuf/issues/76 | ||||
| 	inp := []byte{ | ||||
| @@ -2204,169 +2132,6 @@ func TestInefficientPackedBool(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Make sure pure-reflect-based implementation handles | ||||
| // []int32-[]enum conversion correctly. | ||||
| func TestRepeatedEnum2(t *testing.T) { | ||||
| 	pb := &RepeatedEnum{ | ||||
| 		Color: []RepeatedEnum_Color{RepeatedEnum_RED}, | ||||
| 	} | ||||
| 	b, err := Marshal(pb) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("Marshal failed: %v", err) | ||||
| 	} | ||||
| 	x := new(RepeatedEnum) | ||||
| 	err = Unmarshal(b, x) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("Unmarshal failed: %v", err) | ||||
| 	} | ||||
| 	if !Equal(pb, x) { | ||||
| 		t.Errorf("Incorrect result: want: %v got: %v", pb, x) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // TestConcurrentMarshal makes sure that it is safe to marshal | ||||
| // same message in multiple goroutines concurrently. | ||||
| func TestConcurrentMarshal(t *testing.T) { | ||||
| 	pb := initGoTest(true) | ||||
| 	const N = 100 | ||||
| 	b := make([][]byte, N) | ||||
|  | ||||
| 	var wg sync.WaitGroup | ||||
| 	for i := 0; i < N; i++ { | ||||
| 		wg.Add(1) | ||||
| 		go func(i int) { | ||||
| 			defer wg.Done() | ||||
| 			var err error | ||||
| 			b[i], err = Marshal(pb) | ||||
| 			if err != nil { | ||||
| 				t.Errorf("marshal error: %v", err) | ||||
| 			} | ||||
| 		}(i) | ||||
| 	} | ||||
|  | ||||
| 	wg.Wait() | ||||
| 	for i := 1; i < N; i++ { | ||||
| 		if !bytes.Equal(b[0], b[i]) { | ||||
| 			t.Errorf("concurrent marshal result not same: b[0] = %v, b[%d] = %v", b[0], i, b[i]) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestInvalidUTF8(t *testing.T) { | ||||
| 	const invalidUTF8 = "\xde\xad\xbe\xef\x80\x00\xff" | ||||
| 	tests := []struct { | ||||
| 		label  string | ||||
| 		proto2 Message | ||||
| 		proto3 Message | ||||
| 		want   []byte | ||||
| 	}{{ | ||||
| 		label:  "Scalar", | ||||
| 		proto2: &TestUTF8{Scalar: String(invalidUTF8)}, | ||||
| 		proto3: &pb3.TestUTF8{Scalar: invalidUTF8}, | ||||
| 		want:   []byte{0x0a, 0x07, 0xde, 0xad, 0xbe, 0xef, 0x80, 0x00, 0xff}, | ||||
| 	}, { | ||||
| 		label:  "Vector", | ||||
| 		proto2: &TestUTF8{Vector: []string{invalidUTF8}}, | ||||
| 		proto3: &pb3.TestUTF8{Vector: []string{invalidUTF8}}, | ||||
| 		want:   []byte{0x12, 0x07, 0xde, 0xad, 0xbe, 0xef, 0x80, 0x00, 0xff}, | ||||
| 	}, { | ||||
| 		label:  "Oneof", | ||||
| 		proto2: &TestUTF8{Oneof: &TestUTF8_Field{Field: invalidUTF8}}, | ||||
| 		proto3: &pb3.TestUTF8{Oneof: &pb3.TestUTF8_Field{Field: invalidUTF8}}, | ||||
| 		want:   []byte{0x1a, 0x07, 0xde, 0xad, 0xbe, 0xef, 0x80, 0x00, 0xff}, | ||||
| 	}, { | ||||
| 		label:  "MapKey", | ||||
| 		proto2: &TestUTF8{MapKey: map[string]int64{invalidUTF8: 0}}, | ||||
| 		proto3: &pb3.TestUTF8{MapKey: map[string]int64{invalidUTF8: 0}}, | ||||
| 		want:   []byte{0x22, 0x0b, 0x0a, 0x07, 0xde, 0xad, 0xbe, 0xef, 0x80, 0x00, 0xff, 0x10, 0x00}, | ||||
| 	}, { | ||||
| 		label:  "MapValue", | ||||
| 		proto2: &TestUTF8{MapValue: map[int64]string{0: invalidUTF8}}, | ||||
| 		proto3: &pb3.TestUTF8{MapValue: map[int64]string{0: invalidUTF8}}, | ||||
| 		want:   []byte{0x2a, 0x0b, 0x08, 0x00, 0x12, 0x07, 0xde, 0xad, 0xbe, 0xef, 0x80, 0x00, 0xff}, | ||||
| 	}} | ||||
|  | ||||
| 	for _, tt := range tests { | ||||
| 		// Proto2 should not validate UTF-8. | ||||
| 		b, err := Marshal(tt.proto2) | ||||
| 		if err != nil { | ||||
| 			t.Errorf("Marshal(proto2.%s) = %v, want nil", tt.label, err) | ||||
| 		} | ||||
| 		if !bytes.Equal(b, tt.want) { | ||||
| 			t.Errorf("Marshal(proto2.%s) = %x, want %x", tt.label, b, tt.want) | ||||
| 		} | ||||
|  | ||||
| 		m := Clone(tt.proto2) | ||||
| 		m.Reset() | ||||
| 		if err = Unmarshal(tt.want, m); err != nil { | ||||
| 			t.Errorf("Unmarshal(proto2.%s) = %v, want nil", tt.label, err) | ||||
| 		} | ||||
| 		if !Equal(m, tt.proto2) { | ||||
| 			t.Errorf("proto2.%s: output mismatch:\ngot  %v\nwant %v", tt.label, m, tt.proto2) | ||||
| 		} | ||||
|  | ||||
| 		// Proto3 should validate UTF-8. | ||||
| 		b, err = Marshal(tt.proto3) | ||||
| 		if err == nil { | ||||
| 			t.Errorf("Marshal(proto3.%s) = %v, want non-nil", tt.label, err) | ||||
| 		} | ||||
| 		if !bytes.Equal(b, tt.want) { | ||||
| 			t.Errorf("Marshal(proto3.%s) = %x, want %x", tt.label, b, tt.want) | ||||
| 		} | ||||
|  | ||||
| 		m = Clone(tt.proto3) | ||||
| 		m.Reset() | ||||
| 		err = Unmarshal(tt.want, m) | ||||
| 		if err == nil { | ||||
| 			t.Errorf("Unmarshal(proto3.%s) = %v, want non-nil", tt.label, err) | ||||
| 		} | ||||
| 		if !Equal(m, tt.proto3) { | ||||
| 			t.Errorf("proto3.%s: output mismatch:\ngot  %v\nwant %v", tt.label, m, tt.proto2) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type CustomRawMessage []byte | ||||
|  | ||||
| func (m *CustomRawMessage) Marshal() ([]byte, error) { | ||||
| 	return []byte(*m), nil | ||||
| } | ||||
| func (m *CustomRawMessage) Reset()         { *m = nil } | ||||
| func (m *CustomRawMessage) String() string { return fmt.Sprintf("%x", *m) } | ||||
| func (m *CustomRawMessage) ProtoMessage()  {} | ||||
|  | ||||
| func TestDeterministicErrorOnCustomMarshaler(t *testing.T) { | ||||
| 	in := CustomRawMessage{1, 2, 3} | ||||
| 	var b1 Buffer | ||||
| 	b1.SetDeterministic(true) | ||||
| 	err := b1.Marshal(&in) | ||||
| 	if err == nil || !strings.Contains(err.Error(), "deterministic") { | ||||
| 		t.Fatalf("Marshal error:\ngot  %v\nwant deterministic not supported error", err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestRequired(t *testing.T) { | ||||
| 	// The F_BoolRequired field appears after all of the required fields. | ||||
| 	// It should still be handled even after multiple required field violations. | ||||
| 	m := &GoTest{F_BoolRequired: Bool(true)} | ||||
| 	got, err := Marshal(m) | ||||
| 	if _, ok := err.(*RequiredNotSetError); !ok { | ||||
| 		t.Errorf("Marshal() = %v, want RequiredNotSetError error", err) | ||||
| 	} | ||||
| 	if want := []byte{0x50, 0x01}; !bytes.Equal(got, want) { | ||||
| 		t.Errorf("Marshal() = %x, want %x", got, want) | ||||
| 	} | ||||
|  | ||||
| 	m = new(GoTest) | ||||
| 	err = Unmarshal(got, m) | ||||
| 	if _, ok := err.(*RequiredNotSetError); !ok { | ||||
| 		t.Errorf("Marshal() = %v, want RequiredNotSetError error", err) | ||||
| 	} | ||||
| 	if !m.GetF_BoolRequired() { | ||||
| 		t.Error("m.F_BoolRequired = false, want true") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Benchmarks | ||||
|  | ||||
| func testMsg() *GoTest { | ||||
| @@ -2511,33 +2276,3 @@ func BenchmarkUnmarshalUnrecognizedFields(b *testing.B) { | ||||
| 		p2.Unmarshal(pbd) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // TestRace tests whether there are races among the different marshalers. | ||||
| func TestRace(t *testing.T) { | ||||
| 	m := &descriptorpb.FileDescriptorProto{ | ||||
| 		Options: &descriptorpb.FileOptions{ | ||||
| 			GoPackage: String("path/to/my/package"), | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	wg := &sync.WaitGroup{} | ||||
| 	defer wg.Wait() | ||||
|  | ||||
| 	wg.Add(1) | ||||
| 	go func() { | ||||
| 		defer wg.Done() | ||||
| 		Marshal(m) | ||||
| 	}() | ||||
|  | ||||
| 	wg.Add(1) | ||||
| 	go func() { | ||||
| 		defer wg.Done() | ||||
| 		(&jsonpb.Marshaler{}).MarshalToString(m) | ||||
| 	}() | ||||
|  | ||||
| 	wg.Add(1) | ||||
| 	go func() { | ||||
| 		defer wg.Done() | ||||
| 		_ = m.String() | ||||
| 	}() | ||||
| } | ||||
|   | ||||
							
								
								
									
										18
									
								
								vendor/github.com/gogo/protobuf/proto/any_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								vendor/github.com/gogo/protobuf/proto/any_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -38,7 +38,7 @@ import ( | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
|  | ||||
| 	pb "github.com/gogo/protobuf/proto/proto3_proto" | ||||
| 	testpb "github.com/gogo/protobuf/proto/test_proto" | ||||
| 	testpb "github.com/gogo/protobuf/proto/testdata" | ||||
| 	"github.com/gogo/protobuf/types" | ||||
| ) | ||||
|  | ||||
| @@ -166,33 +166,33 @@ anything: < | ||||
| name: "David" | ||||
| result_count: 47 | ||||
| anything: < | ||||
|   [type.googleapis.com/test_proto.MyMessage]: < | ||||
|   [type.googleapis.com/testdata.MyMessage]: < | ||||
|     count: 47 | ||||
|     name: "David" | ||||
|     [test_proto.Ext.more]: < | ||||
|     [testdata.Ext.more]: < | ||||
|       data: "foo" | ||||
|     > | ||||
|     [test_proto.Ext.text]: "bar" | ||||
|     [testdata.Ext.text]: "bar" | ||||
|   > | ||||
| > | ||||
| many_things: < | ||||
|   [type.googleapis.com/test_proto.MyMessage]: < | ||||
|   [type.googleapis.com/testdata.MyMessage]: < | ||||
|     count: 42 | ||||
|     bikeshed: GREEN | ||||
|     rep_bytes: "roboto" | ||||
|     [test_proto.Ext.more]: < | ||||
|     [testdata.Ext.more]: < | ||||
|       data: "baz" | ||||
|     > | ||||
|   > | ||||
| > | ||||
| many_things: < | ||||
|   [type.googleapis.com/test_proto.MyMessage]: < | ||||
|   [type.googleapis.com/testdata.MyMessage]: < | ||||
|     count: 47 | ||||
|     name: "David" | ||||
|     [test_proto.Ext.more]: < | ||||
|     [testdata.Ext.more]: < | ||||
|       data: "foo" | ||||
|     > | ||||
|     [test_proto.Ext.text]: "bar" | ||||
|     [testdata.Ext.text]: "bar" | ||||
|   > | ||||
| > | ||||
| ` | ||||
|   | ||||
							
								
								
									
										46
									
								
								vendor/github.com/gogo/protobuf/proto/clone.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								vendor/github.com/gogo/protobuf/proto/clone.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -35,39 +35,22 @@ | ||||
| package proto | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"log" | ||||
| 	"reflect" | ||||
| 	"strings" | ||||
| ) | ||||
|  | ||||
| // Clone returns a deep copy of a protocol buffer. | ||||
| func Clone(src Message) Message { | ||||
| 	in := reflect.ValueOf(src) | ||||
| func Clone(pb Message) Message { | ||||
| 	in := reflect.ValueOf(pb) | ||||
| 	if in.IsNil() { | ||||
| 		return src | ||||
| 		return pb | ||||
| 	} | ||||
|  | ||||
| 	out := reflect.New(in.Type().Elem()) | ||||
| 	dst := out.Interface().(Message) | ||||
| 	Merge(dst, src) | ||||
| 	return dst | ||||
| } | ||||
|  | ||||
| // Merger is the interface representing objects that can merge messages of the same type. | ||||
| type Merger interface { | ||||
| 	// Merge merges src into this message. | ||||
| 	// Required and optional fields that are set in src will be set to that value in dst. | ||||
| 	// Elements of repeated fields will be appended. | ||||
| 	// | ||||
| 	// Merge may panic if called with a different argument type than the receiver. | ||||
| 	Merge(src Message) | ||||
| } | ||||
|  | ||||
| // generatedMerger is the custom merge method that generated protos will have. | ||||
| // We must add this method since a generate Merge method will conflict with | ||||
| // many existing protos that have a Merge data field already defined. | ||||
| type generatedMerger interface { | ||||
| 	XXX_Merge(src Message) | ||||
| 	// out is empty so a merge is a deep copy. | ||||
| 	mergeStruct(out.Elem(), in.Elem()) | ||||
| 	return out.Interface().(Message) | ||||
| } | ||||
|  | ||||
| // Merge merges src into dst. | ||||
| @@ -75,24 +58,17 @@ type generatedMerger interface { | ||||
| // Elements of repeated fields will be appended. | ||||
| // Merge panics if src and dst are not the same type, or if dst is nil. | ||||
| func Merge(dst, src Message) { | ||||
| 	if m, ok := dst.(Merger); ok { | ||||
| 		m.Merge(src) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	in := reflect.ValueOf(src) | ||||
| 	out := reflect.ValueOf(dst) | ||||
| 	if out.IsNil() { | ||||
| 		panic("proto: nil destination") | ||||
| 	} | ||||
| 	if in.Type() != out.Type() { | ||||
| 		panic(fmt.Sprintf("proto.Merge(%T, %T) type mismatch", dst, src)) | ||||
| 		// Explicit test prior to mergeStruct so that mistyped nils will fail | ||||
| 		panic("proto: type mismatch") | ||||
| 	} | ||||
| 	if in.IsNil() { | ||||
| 		return // Merge from nil src is a noop | ||||
| 	} | ||||
| 	if m, ok := dst.(generatedMerger); ok { | ||||
| 		m.XXX_Merge(src) | ||||
| 		// Merging nil into non-nil is a quiet no-op | ||||
| 		return | ||||
| 	} | ||||
| 	mergeStruct(out.Elem(), in.Elem()) | ||||
| @@ -113,7 +89,7 @@ func mergeStruct(out, in reflect.Value) { | ||||
| 		bIn := emIn.GetExtensions() | ||||
| 		bOut := emOut.GetExtensions() | ||||
| 		*bOut = append(*bOut, *bIn...) | ||||
| 	} else if emIn, err := extendable(in.Addr().Interface()); err == nil { | ||||
| 	} else if emIn, ok := extendable(in.Addr().Interface()); ok { | ||||
| 		emOut, _ := extendable(out.Addr().Interface()) | ||||
| 		mIn, muIn := emIn.extensionsRead() | ||||
| 		if mIn != nil { | ||||
|   | ||||
							
								
								
									
										119
									
								
								vendor/github.com/gogo/protobuf/proto/clone_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										119
									
								
								vendor/github.com/gogo/protobuf/proto/clone_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -37,7 +37,7 @@ import ( | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
|  | ||||
| 	proto3pb "github.com/gogo/protobuf/proto/proto3_proto" | ||||
| 	pb "github.com/gogo/protobuf/proto/test_proto" | ||||
| 	pb "github.com/gogo/protobuf/proto/testdata" | ||||
| ) | ||||
|  | ||||
| var cloneTestMessage = &pb.MyMessage{ | ||||
| @@ -72,7 +72,7 @@ func init() { | ||||
| func TestClone(t *testing.T) { | ||||
| 	m := proto.Clone(cloneTestMessage).(*pb.MyMessage) | ||||
| 	if !proto.Equal(m, cloneTestMessage) { | ||||
| 		t.Fatalf("Clone(%v) = %v", cloneTestMessage, m) | ||||
| 		t.Errorf("Clone(%v) = %v", cloneTestMessage, m) | ||||
| 	} | ||||
|  | ||||
| 	// Verify it was a deep copy. | ||||
| @@ -256,40 +256,15 @@ var mergeTests = []struct { | ||||
| 			Union: &pb.Communique_Number{Number: 41}, | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ // Oneof nil is the same as not set. | ||||
| 		src:  &pb.Communique{}, | ||||
| 		dst:  &pb.Communique{Union: &pb.Communique_Name{Name: "Bobby Tables"}}, | ||||
| 		want: &pb.Communique{Union: &pb.Communique_Name{Name: "Bobby Tables"}}, | ||||
| 	}, | ||||
| 	// Oneof nil is the same as not set. | ||||
| 	{ | ||||
| 		src:  &pb.Communique{Union: &pb.Communique_Number{Number: 1337}}, | ||||
| 		dst:  &pb.Communique{}, | ||||
| 		want: &pb.Communique{Union: &pb.Communique_Number{Number: 1337}}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		src:  &pb.Communique{Union: &pb.Communique_Col{Col: pb.MyMessage_RED}}, | ||||
| 		dst:  &pb.Communique{}, | ||||
| 		want: &pb.Communique{Union: &pb.Communique_Col{Col: pb.MyMessage_RED}}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		src:  &pb.Communique{Union: &pb.Communique_Data{Data: []byte("hello")}}, | ||||
| 		dst:  &pb.Communique{}, | ||||
| 		want: &pb.Communique{Union: &pb.Communique_Data{Data: []byte("hello")}}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		src:  &pb.Communique{Union: &pb.Communique_Msg{Msg: &pb.Strings{BytesField: []byte{1, 2, 3}}}}, | ||||
| 		dst:  &pb.Communique{}, | ||||
| 		want: &pb.Communique{Union: &pb.Communique_Msg{Msg: &pb.Strings{BytesField: []byte{1, 2, 3}}}}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		src:  &pb.Communique{Union: &pb.Communique_Msg{}}, | ||||
| 		dst:  &pb.Communique{}, | ||||
| 		want: &pb.Communique{Union: &pb.Communique_Msg{}}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		src:  &pb.Communique{Union: &pb.Communique_Msg{Msg: &pb.Strings{StringField: proto.String("123")}}}, | ||||
| 		dst:  &pb.Communique{Union: &pb.Communique_Msg{Msg: &pb.Strings{BytesField: []byte{1, 2, 3}}}}, | ||||
| 		want: &pb.Communique{Union: &pb.Communique_Msg{Msg: &pb.Strings{StringField: proto.String("123"), BytesField: []byte{1, 2, 3}}}}, | ||||
| 		src: &pb.Communique{}, | ||||
| 		dst: &pb.Communique{ | ||||
| 			Union: &pb.Communique_Name{Name: "Bobby Tables"}, | ||||
| 		}, | ||||
| 		want: &pb.Communique{ | ||||
| 			Union: &pb.Communique_Name{Name: "Bobby Tables"}, | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		src: &proto3pb.Message{ | ||||
| @@ -312,86 +287,14 @@ var mergeTests = []struct { | ||||
| 			}, | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		src: &pb.GoTest{ | ||||
| 			F_BoolRepeated:   []bool{}, | ||||
| 			F_Int32Repeated:  []int32{}, | ||||
| 			F_Int64Repeated:  []int64{}, | ||||
| 			F_Uint32Repeated: []uint32{}, | ||||
| 			F_Uint64Repeated: []uint64{}, | ||||
| 			F_FloatRepeated:  []float32{}, | ||||
| 			F_DoubleRepeated: []float64{}, | ||||
| 			F_StringRepeated: []string{}, | ||||
| 			F_BytesRepeated:  [][]byte{}, | ||||
| 		}, | ||||
| 		dst: &pb.GoTest{}, | ||||
| 		want: &pb.GoTest{ | ||||
| 			F_BoolRepeated:   []bool{}, | ||||
| 			F_Int32Repeated:  []int32{}, | ||||
| 			F_Int64Repeated:  []int64{}, | ||||
| 			F_Uint32Repeated: []uint32{}, | ||||
| 			F_Uint64Repeated: []uint64{}, | ||||
| 			F_FloatRepeated:  []float32{}, | ||||
| 			F_DoubleRepeated: []float64{}, | ||||
| 			F_StringRepeated: []string{}, | ||||
| 			F_BytesRepeated:  [][]byte{}, | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		src: &pb.GoTest{}, | ||||
| 		dst: &pb.GoTest{ | ||||
| 			F_BoolRepeated:   []bool{}, | ||||
| 			F_Int32Repeated:  []int32{}, | ||||
| 			F_Int64Repeated:  []int64{}, | ||||
| 			F_Uint32Repeated: []uint32{}, | ||||
| 			F_Uint64Repeated: []uint64{}, | ||||
| 			F_FloatRepeated:  []float32{}, | ||||
| 			F_DoubleRepeated: []float64{}, | ||||
| 			F_StringRepeated: []string{}, | ||||
| 			F_BytesRepeated:  [][]byte{}, | ||||
| 		}, | ||||
| 		want: &pb.GoTest{ | ||||
| 			F_BoolRepeated:   []bool{}, | ||||
| 			F_Int32Repeated:  []int32{}, | ||||
| 			F_Int64Repeated:  []int64{}, | ||||
| 			F_Uint32Repeated: []uint32{}, | ||||
| 			F_Uint64Repeated: []uint64{}, | ||||
| 			F_FloatRepeated:  []float32{}, | ||||
| 			F_DoubleRepeated: []float64{}, | ||||
| 			F_StringRepeated: []string{}, | ||||
| 			F_BytesRepeated:  [][]byte{}, | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		src: &pb.GoTest{ | ||||
| 			F_BytesRepeated: [][]byte{nil, {}, {0}}, | ||||
| 		}, | ||||
| 		dst: &pb.GoTest{}, | ||||
| 		want: &pb.GoTest{ | ||||
| 			F_BytesRepeated: [][]byte{nil, {}, {0}}, | ||||
| 		}, | ||||
| 	}, | ||||
| 	{ | ||||
| 		src: &pb.MyMessage{ | ||||
| 			Others: []*pb.OtherMessage{}, | ||||
| 		}, | ||||
| 		dst: &pb.MyMessage{}, | ||||
| 		want: &pb.MyMessage{ | ||||
| 			Others: []*pb.OtherMessage{}, | ||||
| 		}, | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| func TestMerge(t *testing.T) { | ||||
| 	for _, m := range mergeTests { | ||||
| 		got := proto.Clone(m.dst) | ||||
| 		if !proto.Equal(got, m.dst) { | ||||
| 			t.Errorf("Clone()\ngot  %v\nwant %v", got, m.dst) | ||||
| 			continue | ||||
| 		} | ||||
| 		proto.Merge(got, m.src) | ||||
| 		if !proto.Equal(got, m.want) { | ||||
| 			t.Errorf("Merge(%v, %v)\ngot  %v\nwant %v", m.dst, m.src, got, m.want) | ||||
| 			t.Errorf("Merge(%v, %v)\n got %v\nwant %v\n", m.dst, m.src, got, m.want) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										39
									
								
								vendor/github.com/gogo/protobuf/proto/custom_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										39
									
								
								vendor/github.com/gogo/protobuf/proto/custom_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,39 +0,0 @@ | ||||
| // Protocol Buffers for Go with Gadgets | ||||
| // | ||||
| // Copyright (c) 2018, The GoGo Authors. All rights reserved. | ||||
| // http://github.com/gogo/protobuf | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| // | ||||
| //     * Redistributions of source code must retain the above copyright | ||||
| // notice, this list of conditions and the following disclaimer. | ||||
| //     * Redistributions in binary form must reproduce the above | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| package proto | ||||
|  | ||||
| import "reflect" | ||||
|  | ||||
| type custom interface { | ||||
| 	Marshal() ([]byte, error) | ||||
| 	Unmarshal(data []byte) error | ||||
| 	Size() int | ||||
| } | ||||
|  | ||||
| var customType = reflect.TypeOf((*custom)(nil)).Elem() | ||||
							
								
								
									
										683
									
								
								vendor/github.com/gogo/protobuf/proto/decode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										683
									
								
								vendor/github.com/gogo/protobuf/proto/decode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -39,6 +39,8 @@ import ( | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"os" | ||||
| 	"reflect" | ||||
| ) | ||||
|  | ||||
| // errOverflow is returned when an integer is too large to be represented. | ||||
| @@ -48,6 +50,10 @@ var errOverflow = errors.New("proto: integer overflow") | ||||
| // wire type is encountered. It does not get returned to user code. | ||||
| var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof") | ||||
|  | ||||
| // The fundamental decoders that interpret bytes on the wire. | ||||
| // Those that take integer types all return uint64 and are | ||||
| // therefore of type valueDecoder. | ||||
|  | ||||
| // DecodeVarint reads a varint-encoded integer from the slice. | ||||
| // It returns the integer and the number of bytes consumed, or | ||||
| // zero if there is not enough. | ||||
| @@ -186,6 +192,7 @@ func (p *Buffer) DecodeVarint() (x uint64, err error) { | ||||
| 	if b&0x80 == 0 { | ||||
| 		goto done | ||||
| 	} | ||||
| 	// x -= 0x80 << 63 // Always zero. | ||||
|  | ||||
| 	return 0, errOverflow | ||||
|  | ||||
| @@ -260,6 +267,9 @@ func (p *Buffer) DecodeZigzag32() (x uint64, err error) { | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // These are not ValueDecoders: they produce an array of bytes or a string. | ||||
| // bytes, embedded messages | ||||
|  | ||||
| // DecodeRawBytes reads a count-delimited byte buffer from the Buffer. | ||||
| // This is the format used for the bytes protocol buffer | ||||
| // type and for embedded messages. | ||||
| @@ -301,27 +311,79 @@ func (p *Buffer) DecodeStringBytes() (s string, err error) { | ||||
| 	return string(buf), nil | ||||
| } | ||||
|  | ||||
| // Unmarshaler is the interface representing objects that can | ||||
| // unmarshal themselves.  The argument points to data that may be | ||||
| // overwritten, so implementations should not keep references to the | ||||
| // buffer. | ||||
| // Unmarshal implementations should not clear the receiver. | ||||
| // Any unmarshaled data should be merged into the receiver. | ||||
| // Callers of Unmarshal that do not want to retain existing data | ||||
| // should Reset the receiver before calling Unmarshal. | ||||
| type Unmarshaler interface { | ||||
| 	Unmarshal([]byte) error | ||||
| // Skip the next item in the buffer. Its wire type is decoded and presented as an argument. | ||||
| // If the protocol buffer has extensions, and the field matches, add it as an extension. | ||||
| // Otherwise, if the XXX_unrecognized field exists, append the skipped data there. | ||||
| func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error { | ||||
| 	oi := o.index | ||||
|  | ||||
| 	err := o.skip(t, tag, wire) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if !unrecField.IsValid() { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	ptr := structPointer_Bytes(base, unrecField) | ||||
|  | ||||
| 	// Add the skipped field to struct field | ||||
| 	obuf := o.buf | ||||
|  | ||||
| 	o.buf = *ptr | ||||
| 	o.EncodeVarint(uint64(tag<<3 | wire)) | ||||
| 	*ptr = append(o.buf, obuf[oi:o.index]...) | ||||
|  | ||||
| 	o.buf = obuf | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // newUnmarshaler is the interface representing objects that can | ||||
| // unmarshal themselves. The semantics are identical to Unmarshaler. | ||||
| // | ||||
| // This exists to support protoc-gen-go generated messages. | ||||
| // The proto package will stop type-asserting to this interface in the future. | ||||
| // | ||||
| // DO NOT DEPEND ON THIS. | ||||
| type newUnmarshaler interface { | ||||
| 	XXX_Unmarshal([]byte) error | ||||
| // Skip the next item in the buffer. Its wire type is decoded and presented as an argument. | ||||
| func (o *Buffer) skip(t reflect.Type, tag, wire int) error { | ||||
|  | ||||
| 	var u uint64 | ||||
| 	var err error | ||||
|  | ||||
| 	switch wire { | ||||
| 	case WireVarint: | ||||
| 		_, err = o.DecodeVarint() | ||||
| 	case WireFixed64: | ||||
| 		_, err = o.DecodeFixed64() | ||||
| 	case WireBytes: | ||||
| 		_, err = o.DecodeRawBytes(false) | ||||
| 	case WireFixed32: | ||||
| 		_, err = o.DecodeFixed32() | ||||
| 	case WireStartGroup: | ||||
| 		for { | ||||
| 			u, err = o.DecodeVarint() | ||||
| 			if err != nil { | ||||
| 				break | ||||
| 			} | ||||
| 			fwire := int(u & 0x7) | ||||
| 			if fwire == WireEndGroup { | ||||
| 				break | ||||
| 			} | ||||
| 			ftag := int(u >> 3) | ||||
| 			err = o.skip(t, ftag, fwire) | ||||
| 			if err != nil { | ||||
| 				break | ||||
| 			} | ||||
| 		} | ||||
| 	default: | ||||
| 		err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t) | ||||
| 	} | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // Unmarshaler is the interface representing objects that can | ||||
| // unmarshal themselves.  The method should reset the receiver before | ||||
| // decoding starts.  The argument points to data that may be | ||||
| // overwritten, so implementations should not keep references to the | ||||
| // buffer. | ||||
| type Unmarshaler interface { | ||||
| 	Unmarshal([]byte) error | ||||
| } | ||||
|  | ||||
| // Unmarshal parses the protocol buffer representation in buf and places the | ||||
| @@ -333,13 +395,7 @@ type newUnmarshaler interface { | ||||
| // to preserve and append to existing data. | ||||
| func Unmarshal(buf []byte, pb Message) error { | ||||
| 	pb.Reset() | ||||
| 	if u, ok := pb.(newUnmarshaler); ok { | ||||
| 		return u.XXX_Unmarshal(buf) | ||||
| 	} | ||||
| 	if u, ok := pb.(Unmarshaler); ok { | ||||
| 		return u.Unmarshal(buf) | ||||
| 	} | ||||
| 	return NewBuffer(buf).Unmarshal(pb) | ||||
| 	return UnmarshalMerge(buf, pb) | ||||
| } | ||||
|  | ||||
| // UnmarshalMerge parses the protocol buffer representation in buf and | ||||
| @@ -349,16 +405,8 @@ func Unmarshal(buf []byte, pb Message) error { | ||||
| // UnmarshalMerge merges into existing data in pb. | ||||
| // Most code should use Unmarshal instead. | ||||
| func UnmarshalMerge(buf []byte, pb Message) error { | ||||
| 	if u, ok := pb.(newUnmarshaler); ok { | ||||
| 		return u.XXX_Unmarshal(buf) | ||||
| 	} | ||||
| 	// If the object can unmarshal itself, let it. | ||||
| 	if u, ok := pb.(Unmarshaler); ok { | ||||
| 		// NOTE: The history of proto have unfortunately been inconsistent | ||||
| 		// whether Unmarshaler should or should not implicitly clear itself. | ||||
| 		// Some implementations do, most do not. | ||||
| 		// Thus, calling this here may or may not do what people want. | ||||
| 		// | ||||
| 		// See https://github.com/golang/protobuf/issues/424 | ||||
| 		return u.Unmarshal(buf) | ||||
| 	} | ||||
| 	return NewBuffer(buf).Unmarshal(pb) | ||||
| @@ -374,17 +422,12 @@ func (p *Buffer) DecodeMessage(pb Message) error { | ||||
| } | ||||
|  | ||||
| // DecodeGroup reads a tag-delimited group from the Buffer. | ||||
| // StartGroup tag is already consumed. This function consumes | ||||
| // EndGroup tag. | ||||
| func (p *Buffer) DecodeGroup(pb Message) error { | ||||
| 	b := p.buf[p.index:] | ||||
| 	x, y := findEndGroup(b) | ||||
| 	if x < 0 { | ||||
| 		return io.ErrUnexpectedEOF | ||||
| 	typ, base, err := getbase(pb) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	err := Unmarshal(b[:x], pb) | ||||
| 	p.index += y | ||||
| 	return err | ||||
| 	return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base) | ||||
| } | ||||
|  | ||||
| // Unmarshal parses the protocol buffer representation in the | ||||
| @@ -395,33 +438,541 @@ func (p *Buffer) DecodeGroup(pb Message) error { | ||||
| // Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal. | ||||
| func (p *Buffer) Unmarshal(pb Message) error { | ||||
| 	// If the object can unmarshal itself, let it. | ||||
| 	if u, ok := pb.(newUnmarshaler); ok { | ||||
| 		err := u.XXX_Unmarshal(p.buf[p.index:]) | ||||
| 		p.index = len(p.buf) | ||||
| 		return err | ||||
| 	} | ||||
| 	if u, ok := pb.(Unmarshaler); ok { | ||||
| 		// NOTE: The history of proto have unfortunately been inconsistent | ||||
| 		// whether Unmarshaler should or should not implicitly clear itself. | ||||
| 		// Some implementations do, most do not. | ||||
| 		// Thus, calling this here may or may not do what people want. | ||||
| 		// | ||||
| 		// See https://github.com/golang/protobuf/issues/424 | ||||
| 		err := u.Unmarshal(p.buf[p.index:]) | ||||
| 		p.index = len(p.buf) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	// Slow workaround for messages that aren't Unmarshalers. | ||||
| 	// This includes some hand-coded .pb.go files and | ||||
| 	// bootstrap protos. | ||||
| 	// TODO: fix all of those and then add Unmarshal to | ||||
| 	// the Message interface. Then: | ||||
| 	// The cast above and code below can be deleted. | ||||
| 	// The old unmarshaler can be deleted. | ||||
| 	// Clients can call Unmarshal directly (can already do that, actually). | ||||
| 	var info InternalMessageInfo | ||||
| 	err := info.Unmarshal(pb, p.buf[p.index:]) | ||||
| 	p.index = len(p.buf) | ||||
| 	typ, base, err := getbase(pb) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base) | ||||
|  | ||||
| 	if collectStats { | ||||
| 		stats.Decode++ | ||||
| 	} | ||||
|  | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // unmarshalType does the work of unmarshaling a structure. | ||||
| func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error { | ||||
| 	var state errorState | ||||
| 	required, reqFields := prop.reqCount, uint64(0) | ||||
|  | ||||
| 	var err error | ||||
| 	for err == nil && o.index < len(o.buf) { | ||||
| 		oi := o.index | ||||
| 		var u uint64 | ||||
| 		u, err = o.DecodeVarint() | ||||
| 		if err != nil { | ||||
| 			break | ||||
| 		} | ||||
| 		wire := int(u & 0x7) | ||||
| 		if wire == WireEndGroup { | ||||
| 			if is_group { | ||||
| 				if required > 0 { | ||||
| 					// Not enough information to determine the exact field. | ||||
| 					// (See below.) | ||||
| 					return &RequiredNotSetError{"{Unknown}"} | ||||
| 				} | ||||
| 				return nil // input is satisfied | ||||
| 			} | ||||
| 			return fmt.Errorf("proto: %s: wiretype end group for non-group", st) | ||||
| 		} | ||||
| 		tag := int(u >> 3) | ||||
| 		if tag <= 0 { | ||||
| 			return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire) | ||||
| 		} | ||||
| 		fieldnum, ok := prop.decoderTags.get(tag) | ||||
| 		if !ok { | ||||
| 			// Maybe it's an extension? | ||||
| 			if prop.extendable { | ||||
| 				if e, eok := structPointer_Interface(base, st).(extensionsBytes); eok { | ||||
| 					if isExtensionField(e, int32(tag)) { | ||||
| 						if err = o.skip(st, tag, wire); err == nil { | ||||
| 							ext := e.GetExtensions() | ||||
| 							*ext = append(*ext, o.buf[oi:o.index]...) | ||||
| 						} | ||||
| 						continue | ||||
| 					} | ||||
| 				} else if e, _ := extendable(structPointer_Interface(base, st)); isExtensionField(e, int32(tag)) { | ||||
| 					if err = o.skip(st, tag, wire); err == nil { | ||||
| 						extmap := e.extensionsWrite() | ||||
| 						ext := extmap[int32(tag)] // may be missing | ||||
| 						ext.enc = append(ext.enc, o.buf[oi:o.index]...) | ||||
| 						extmap[int32(tag)] = ext | ||||
| 					} | ||||
| 					continue | ||||
| 				} | ||||
| 			} | ||||
| 			// Maybe it's a oneof? | ||||
| 			if prop.oneofUnmarshaler != nil { | ||||
| 				m := structPointer_Interface(base, st).(Message) | ||||
| 				// First return value indicates whether tag is a oneof field. | ||||
| 				ok, err = prop.oneofUnmarshaler(m, tag, wire, o) | ||||
| 				if err == ErrInternalBadWireType { | ||||
| 					// Map the error to something more descriptive. | ||||
| 					// Do the formatting here to save generated code space. | ||||
| 					err = fmt.Errorf("bad wiretype for oneof field in %T", m) | ||||
| 				} | ||||
| 				if ok { | ||||
| 					continue | ||||
| 				} | ||||
| 			} | ||||
| 			err = o.skipAndSave(st, tag, wire, base, prop.unrecField) | ||||
| 			continue | ||||
| 		} | ||||
| 		p := prop.Prop[fieldnum] | ||||
|  | ||||
| 		if p.dec == nil { | ||||
| 			fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name) | ||||
| 			continue | ||||
| 		} | ||||
| 		dec := p.dec | ||||
| 		if wire != WireStartGroup && wire != p.WireType { | ||||
| 			if wire == WireBytes && p.packedDec != nil { | ||||
| 				// a packable field | ||||
| 				dec = p.packedDec | ||||
| 			} else { | ||||
| 				err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType) | ||||
| 				continue | ||||
| 			} | ||||
| 		} | ||||
| 		decErr := dec(o, p, base) | ||||
| 		if decErr != nil && !state.shouldContinue(decErr, p) { | ||||
| 			err = decErr | ||||
| 		} | ||||
| 		if err == nil && p.Required { | ||||
| 			// Successfully decoded a required field. | ||||
| 			if tag <= 64 { | ||||
| 				// use bitmap for fields 1-64 to catch field reuse. | ||||
| 				var mask uint64 = 1 << uint64(tag-1) | ||||
| 				if reqFields&mask == 0 { | ||||
| 					// new required field | ||||
| 					reqFields |= mask | ||||
| 					required-- | ||||
| 				} | ||||
| 			} else { | ||||
| 				// This is imprecise. It can be fooled by a required field | ||||
| 				// with a tag > 64 that is encoded twice; that's very rare. | ||||
| 				// A fully correct implementation would require allocating | ||||
| 				// a data structure, which we would like to avoid. | ||||
| 				required-- | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if err == nil { | ||||
| 		if is_group { | ||||
| 			return io.ErrUnexpectedEOF | ||||
| 		} | ||||
| 		if state.err != nil { | ||||
| 			return state.err | ||||
| 		} | ||||
| 		if required > 0 { | ||||
| 			// Not enough information to determine the exact field. If we use extra | ||||
| 			// CPU, we could determine the field only if the missing required field | ||||
| 			// has a tag <= 64 and we check reqFields. | ||||
| 			return &RequiredNotSetError{"{Unknown}"} | ||||
| 		} | ||||
| 	} | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // Individual type decoders | ||||
| // For each, | ||||
| //	u is the decoded value, | ||||
| //	v is a pointer to the field (pointer) in the struct | ||||
|  | ||||
| // Sizes of the pools to allocate inside the Buffer. | ||||
| // The goal is modest amortization and allocation | ||||
| // on at least 16-byte boundaries. | ||||
| const ( | ||||
| 	boolPoolSize   = 16 | ||||
| 	uint32PoolSize = 8 | ||||
| 	uint64PoolSize = 4 | ||||
| ) | ||||
|  | ||||
| // Decode a bool. | ||||
| func (o *Buffer) dec_bool(p *Properties, base structPointer) error { | ||||
| 	u, err := p.valDec(o) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	if len(o.bools) == 0 { | ||||
| 		o.bools = make([]bool, boolPoolSize) | ||||
| 	} | ||||
| 	o.bools[0] = u != 0 | ||||
| 	*structPointer_Bool(base, p.field) = &o.bools[0] | ||||
| 	o.bools = o.bools[1:] | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error { | ||||
| 	u, err := p.valDec(o) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	*structPointer_BoolVal(base, p.field) = u != 0 | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode an int32. | ||||
| func (o *Buffer) dec_int32(p *Properties, base structPointer) error { | ||||
| 	u, err := p.valDec(o) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	word32_Set(structPointer_Word32(base, p.field), o, uint32(u)) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error { | ||||
| 	u, err := p.valDec(o) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u)) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode an int64. | ||||
| func (o *Buffer) dec_int64(p *Properties, base structPointer) error { | ||||
| 	u, err := p.valDec(o) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	word64_Set(structPointer_Word64(base, p.field), o, u) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error { | ||||
| 	u, err := p.valDec(o) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	word64Val_Set(structPointer_Word64Val(base, p.field), o, u) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a string. | ||||
| func (o *Buffer) dec_string(p *Properties, base structPointer) error { | ||||
| 	s, err := o.DecodeStringBytes() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	*structPointer_String(base, p.field) = &s | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error { | ||||
| 	s, err := o.DecodeStringBytes() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	*structPointer_StringVal(base, p.field) = s | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a slice of bytes ([]byte). | ||||
| func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error { | ||||
| 	b, err := o.DecodeRawBytes(true) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	*structPointer_Bytes(base, p.field) = b | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a slice of bools ([]bool). | ||||
| func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error { | ||||
| 	u, err := p.valDec(o) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	v := structPointer_BoolSlice(base, p.field) | ||||
| 	*v = append(*v, u != 0) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a slice of bools ([]bool) in packed format. | ||||
| func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error { | ||||
| 	v := structPointer_BoolSlice(base, p.field) | ||||
|  | ||||
| 	nn, err := o.DecodeVarint() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	nb := int(nn) // number of bytes of encoded bools | ||||
| 	fin := o.index + nb | ||||
| 	if fin < o.index { | ||||
| 		return errOverflow | ||||
| 	} | ||||
|  | ||||
| 	y := *v | ||||
| 	for o.index < fin { | ||||
| 		u, err := p.valDec(o) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		y = append(y, u != 0) | ||||
| 	} | ||||
|  | ||||
| 	*v = y | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a slice of int32s ([]int32). | ||||
| func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error { | ||||
| 	u, err := p.valDec(o) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	structPointer_Word32Slice(base, p.field).Append(uint32(u)) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a slice of int32s ([]int32) in packed format. | ||||
| func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error { | ||||
| 	v := structPointer_Word32Slice(base, p.field) | ||||
|  | ||||
| 	nn, err := o.DecodeVarint() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	nb := int(nn) // number of bytes of encoded int32s | ||||
|  | ||||
| 	fin := o.index + nb | ||||
| 	if fin < o.index { | ||||
| 		return errOverflow | ||||
| 	} | ||||
| 	for o.index < fin { | ||||
| 		u, err := p.valDec(o) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		v.Append(uint32(u)) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a slice of int64s ([]int64). | ||||
| func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error { | ||||
| 	u, err := p.valDec(o) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	structPointer_Word64Slice(base, p.field).Append(u) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a slice of int64s ([]int64) in packed format. | ||||
| func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error { | ||||
| 	v := structPointer_Word64Slice(base, p.field) | ||||
|  | ||||
| 	nn, err := o.DecodeVarint() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	nb := int(nn) // number of bytes of encoded int64s | ||||
|  | ||||
| 	fin := o.index + nb | ||||
| 	if fin < o.index { | ||||
| 		return errOverflow | ||||
| 	} | ||||
| 	for o.index < fin { | ||||
| 		u, err := p.valDec(o) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		v.Append(u) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a slice of strings ([]string). | ||||
| func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error { | ||||
| 	s, err := o.DecodeStringBytes() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	v := structPointer_StringSlice(base, p.field) | ||||
| 	*v = append(*v, s) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a slice of slice of bytes ([][]byte). | ||||
| func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error { | ||||
| 	b, err := o.DecodeRawBytes(true) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	v := structPointer_BytesSlice(base, p.field) | ||||
| 	*v = append(*v, b) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a map field. | ||||
| func (o *Buffer) dec_new_map(p *Properties, base structPointer) error { | ||||
| 	raw, err := o.DecodeRawBytes(false) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	oi := o.index       // index at the end of this map entry | ||||
| 	o.index -= len(raw) // move buffer back to start of map entry | ||||
|  | ||||
| 	mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V | ||||
| 	if mptr.Elem().IsNil() { | ||||
| 		mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem())) | ||||
| 	} | ||||
| 	v := mptr.Elem() // map[K]V | ||||
|  | ||||
| 	// Prepare addressable doubly-indirect placeholders for the key and value types. | ||||
| 	// See enc_new_map for why. | ||||
| 	keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K | ||||
| 	keybase := toStructPointer(keyptr.Addr())                  // **K | ||||
|  | ||||
| 	var valbase structPointer | ||||
| 	var valptr reflect.Value | ||||
| 	switch p.mtype.Elem().Kind() { | ||||
| 	case reflect.Slice: | ||||
| 		// []byte | ||||
| 		var dummy []byte | ||||
| 		valptr = reflect.ValueOf(&dummy)  // *[]byte | ||||
| 		valbase = toStructPointer(valptr) // *[]byte | ||||
| 	case reflect.Ptr: | ||||
| 		// message; valptr is **Msg; need to allocate the intermediate pointer | ||||
| 		valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V | ||||
| 		valptr.Set(reflect.New(valptr.Type().Elem())) | ||||
| 		valbase = toStructPointer(valptr) | ||||
| 	default: | ||||
| 		// everything else | ||||
| 		valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V | ||||
| 		valbase = toStructPointer(valptr.Addr())                   // **V | ||||
| 	} | ||||
|  | ||||
| 	// Decode. | ||||
| 	// This parses a restricted wire format, namely the encoding of a message | ||||
| 	// with two fields. See enc_new_map for the format. | ||||
| 	for o.index < oi { | ||||
| 		// tagcode for key and value properties are always a single byte | ||||
| 		// because they have tags 1 and 2. | ||||
| 		tagcode := o.buf[o.index] | ||||
| 		o.index++ | ||||
| 		switch tagcode { | ||||
| 		case p.mkeyprop.tagcode[0]: | ||||
| 			if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		case p.mvalprop.tagcode[0]: | ||||
| 			if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		default: | ||||
| 			// TODO: Should we silently skip this instead? | ||||
| 			return fmt.Errorf("proto: bad map data tag %d", raw[0]) | ||||
| 		} | ||||
| 	} | ||||
| 	keyelem, valelem := keyptr.Elem(), valptr.Elem() | ||||
| 	if !keyelem.IsValid() { | ||||
| 		keyelem = reflect.Zero(p.mtype.Key()) | ||||
| 	} | ||||
| 	if !valelem.IsValid() { | ||||
| 		valelem = reflect.Zero(p.mtype.Elem()) | ||||
| 	} | ||||
|  | ||||
| 	v.SetMapIndex(keyelem, valelem) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a group. | ||||
| func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error { | ||||
| 	bas := structPointer_GetStructPointer(base, p.field) | ||||
| 	if structPointer_IsNil(bas) { | ||||
| 		// allocate new nested message | ||||
| 		bas = toStructPointer(reflect.New(p.stype)) | ||||
| 		structPointer_SetStructPointer(base, p.field, bas) | ||||
| 	} | ||||
| 	return o.unmarshalType(p.stype, p.sprop, true, bas) | ||||
| } | ||||
|  | ||||
| // Decode an embedded message. | ||||
| func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) { | ||||
| 	raw, e := o.DecodeRawBytes(false) | ||||
| 	if e != nil { | ||||
| 		return e | ||||
| 	} | ||||
|  | ||||
| 	bas := structPointer_GetStructPointer(base, p.field) | ||||
| 	if structPointer_IsNil(bas) { | ||||
| 		// allocate new nested message | ||||
| 		bas = toStructPointer(reflect.New(p.stype)) | ||||
| 		structPointer_SetStructPointer(base, p.field, bas) | ||||
| 	} | ||||
|  | ||||
| 	// If the object can unmarshal itself, let it. | ||||
| 	if p.isUnmarshaler { | ||||
| 		iv := structPointer_Interface(bas, p.stype) | ||||
| 		return iv.(Unmarshaler).Unmarshal(raw) | ||||
| 	} | ||||
|  | ||||
| 	obuf := o.buf | ||||
| 	oi := o.index | ||||
| 	o.buf = raw | ||||
| 	o.index = 0 | ||||
|  | ||||
| 	err = o.unmarshalType(p.stype, p.sprop, false, bas) | ||||
| 	o.buf = obuf | ||||
| 	o.index = oi | ||||
|  | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // Decode a slice of embedded messages. | ||||
| func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error { | ||||
| 	return o.dec_slice_struct(p, false, base) | ||||
| } | ||||
|  | ||||
| // Decode a slice of embedded groups. | ||||
| func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error { | ||||
| 	return o.dec_slice_struct(p, true, base) | ||||
| } | ||||
|  | ||||
| // Decode a slice of structs ([]*struct). | ||||
| func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error { | ||||
| 	v := reflect.New(p.stype) | ||||
| 	bas := toStructPointer(v) | ||||
| 	structPointer_StructPointerSlice(base, p.field).Append(bas) | ||||
|  | ||||
| 	if is_group { | ||||
| 		err := o.unmarshalType(p.stype, p.sprop, is_group, bas) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	raw, err := o.DecodeRawBytes(false) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	// If the object can unmarshal itself, let it. | ||||
| 	if p.isUnmarshaler { | ||||
| 		iv := v.Interface() | ||||
| 		return iv.(Unmarshaler).Unmarshal(raw) | ||||
| 	} | ||||
|  | ||||
| 	obuf := o.buf | ||||
| 	oi := o.index | ||||
| 	o.buf = raw | ||||
| 	o.index = 0 | ||||
|  | ||||
| 	err = o.unmarshalType(p.stype, p.sprop, is_group, bas) | ||||
|  | ||||
| 	o.buf = obuf | ||||
| 	o.index = oi | ||||
|  | ||||
| 	return err | ||||
| } | ||||
|   | ||||
							
								
								
									
										172
									
								
								vendor/github.com/gogo/protobuf/proto/decode_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								vendor/github.com/gogo/protobuf/proto/decode_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,172 @@ | ||||
| // Protocol Buffers for Go with Gadgets | ||||
| // | ||||
| // Copyright (c) 2013, The GoGo Authors. All rights reserved. | ||||
| // http://github.com/gogo/protobuf | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| // | ||||
| //     * Redistributions of source code must retain the above copyright | ||||
| // notice, this list of conditions and the following disclaimer. | ||||
| //     * Redistributions in binary form must reproduce the above | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| package proto | ||||
|  | ||||
| import ( | ||||
| 	"reflect" | ||||
| ) | ||||
|  | ||||
| // Decode a reference to a struct pointer. | ||||
| func (o *Buffer) dec_ref_struct_message(p *Properties, base structPointer) (err error) { | ||||
| 	raw, e := o.DecodeRawBytes(false) | ||||
| 	if e != nil { | ||||
| 		return e | ||||
| 	} | ||||
|  | ||||
| 	// If the object can unmarshal itself, let it. | ||||
| 	if p.isUnmarshaler { | ||||
| 		panic("not supported, since this is a pointer receiver") | ||||
| 	} | ||||
|  | ||||
| 	obuf := o.buf | ||||
| 	oi := o.index | ||||
| 	o.buf = raw | ||||
| 	o.index = 0 | ||||
|  | ||||
| 	bas := structPointer_FieldPointer(base, p.field) | ||||
|  | ||||
| 	err = o.unmarshalType(p.stype, p.sprop, false, bas) | ||||
| 	o.buf = obuf | ||||
| 	o.index = oi | ||||
|  | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // Decode a slice of references to struct pointers ([]struct). | ||||
| func (o *Buffer) dec_slice_ref_struct(p *Properties, is_group bool, base structPointer) error { | ||||
| 	newBas := appendStructPointer(base, p.field, p.sstype) | ||||
|  | ||||
| 	if is_group { | ||||
| 		panic("not supported, maybe in future, if requested.") | ||||
| 	} | ||||
|  | ||||
| 	raw, err := o.DecodeRawBytes(false) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	// If the object can unmarshal itself, let it. | ||||
| 	if p.isUnmarshaler { | ||||
| 		panic("not supported, since this is not a pointer receiver.") | ||||
| 	} | ||||
|  | ||||
| 	obuf := o.buf | ||||
| 	oi := o.index | ||||
| 	o.buf = raw | ||||
| 	o.index = 0 | ||||
|  | ||||
| 	err = o.unmarshalType(p.stype, p.sprop, is_group, newBas) | ||||
|  | ||||
| 	o.buf = obuf | ||||
| 	o.index = oi | ||||
|  | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // Decode a slice of references to struct pointers. | ||||
| func (o *Buffer) dec_slice_ref_struct_message(p *Properties, base structPointer) error { | ||||
| 	return o.dec_slice_ref_struct(p, false, base) | ||||
| } | ||||
|  | ||||
| func setPtrCustomType(base structPointer, f field, v interface{}) { | ||||
| 	if v == nil { | ||||
| 		return | ||||
| 	} | ||||
| 	structPointer_SetStructPointer(base, f, toStructPointer(reflect.ValueOf(v))) | ||||
| } | ||||
|  | ||||
| func setCustomType(base structPointer, f field, value interface{}) { | ||||
| 	if value == nil { | ||||
| 		return | ||||
| 	} | ||||
| 	v := reflect.ValueOf(value).Elem() | ||||
| 	t := reflect.TypeOf(value).Elem() | ||||
| 	kind := t.Kind() | ||||
| 	switch kind { | ||||
| 	case reflect.Slice: | ||||
| 		slice := reflect.MakeSlice(t, v.Len(), v.Cap()) | ||||
| 		reflect.Copy(slice, v) | ||||
| 		oldHeader := structPointer_GetSliceHeader(base, f) | ||||
| 		oldHeader.Data = slice.Pointer() | ||||
| 		oldHeader.Len = v.Len() | ||||
| 		oldHeader.Cap = v.Cap() | ||||
| 	default: | ||||
| 		size := reflect.TypeOf(value).Elem().Size() | ||||
| 		structPointer_Copy(toStructPointer(reflect.ValueOf(value)), structPointer_Add(base, f), int(size)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (o *Buffer) dec_custom_bytes(p *Properties, base structPointer) error { | ||||
| 	b, err := o.DecodeRawBytes(true) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	i := reflect.New(p.ctype.Elem()).Interface() | ||||
| 	custom := (i).(Unmarshaler) | ||||
| 	if err := custom.Unmarshal(b); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	setPtrCustomType(base, p.field, custom) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (o *Buffer) dec_custom_ref_bytes(p *Properties, base structPointer) error { | ||||
| 	b, err := o.DecodeRawBytes(true) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	i := reflect.New(p.ctype).Interface() | ||||
| 	custom := (i).(Unmarshaler) | ||||
| 	if err := custom.Unmarshal(b); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	if custom != nil { | ||||
| 		setCustomType(base, p.field, custom) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Decode a slice of bytes ([]byte) into a slice of custom types. | ||||
| func (o *Buffer) dec_custom_slice_bytes(p *Properties, base structPointer) error { | ||||
| 	b, err := o.DecodeRawBytes(true) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	i := reflect.New(p.ctype.Elem()).Interface() | ||||
| 	custom := (i).(Unmarshaler) | ||||
| 	if err := custom.Unmarshal(b); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	newBas := appendStructPointer(base, p.field, p.ctype) | ||||
|  | ||||
| 	var zero field | ||||
| 	setCustomType(newBas, zero, custom) | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										7
									
								
								vendor/github.com/gogo/protobuf/proto/decode_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/gogo/protobuf/proto/decode_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,8 +29,6 @@ | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| // +build go1.7 | ||||
|  | ||||
| package proto_test | ||||
|  | ||||
| import ( | ||||
| @@ -40,7 +38,10 @@ import ( | ||||
| 	tpb "github.com/gogo/protobuf/proto/proto3_proto" | ||||
| ) | ||||
|  | ||||
| var msgBlackhole = new(tpb.Message) | ||||
| var ( | ||||
| 	bytesBlackhole []byte | ||||
| 	msgBlackhole   = new(tpb.Message) | ||||
| ) | ||||
|  | ||||
| // Disabled this Benchmark because it is using features (b.Run) from go1.7 and gogoprotobuf still have compatibility with go1.5 | ||||
| // BenchmarkVarint32ArraySmall shows the performance on an array of small int32 fields (1 and | ||||
|   | ||||
							
								
								
									
										63
									
								
								vendor/github.com/gogo/protobuf/proto/deprecated.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										63
									
								
								vendor/github.com/gogo/protobuf/proto/deprecated.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,63 +0,0 @@ | ||||
| // Go support for Protocol Buffers - Google's data interchange format | ||||
| // | ||||
| // Copyright 2018 The Go Authors.  All rights reserved. | ||||
| // https://github.com/golang/protobuf | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| // | ||||
| //     * Redistributions of source code must retain the above copyright | ||||
| // notice, this list of conditions and the following disclaimer. | ||||
| //     * Redistributions in binary form must reproduce the above | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| //     * Neither the name of Google Inc. nor the names of its | ||||
| // contributors may be used to endorse or promote products derived from | ||||
| // this software without specific prior written permission. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| package proto | ||||
|  | ||||
| import "errors" | ||||
|  | ||||
| // Deprecated: do not use. | ||||
| type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 } | ||||
|  | ||||
| // Deprecated: do not use. | ||||
| func GetStats() Stats { return Stats{} } | ||||
|  | ||||
| // Deprecated: do not use. | ||||
| func MarshalMessageSet(interface{}) ([]byte, error) { | ||||
| 	return nil, errors.New("proto: not implemented") | ||||
| } | ||||
|  | ||||
| // Deprecated: do not use. | ||||
| func UnmarshalMessageSet([]byte, interface{}) error { | ||||
| 	return errors.New("proto: not implemented") | ||||
| } | ||||
|  | ||||
| // Deprecated: do not use. | ||||
| func MarshalMessageSetJSON(interface{}) ([]byte, error) { | ||||
| 	return nil, errors.New("proto: not implemented") | ||||
| } | ||||
|  | ||||
| // Deprecated: do not use. | ||||
| func UnmarshalMessageSetJSON([]byte, interface{}) error { | ||||
| 	return errors.New("proto: not implemented") | ||||
| } | ||||
|  | ||||
| // Deprecated: do not use. | ||||
| func RegisterMessageSetType(Message, int32, string) {} | ||||
							
								
								
									
										350
									
								
								vendor/github.com/gogo/protobuf/proto/discard.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										350
									
								
								vendor/github.com/gogo/protobuf/proto/discard.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,350 +0,0 @@ | ||||
| // Go support for Protocol Buffers - Google's data interchange format | ||||
| // | ||||
| // Copyright 2017 The Go Authors.  All rights reserved. | ||||
| // https://github.com/golang/protobuf | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| // | ||||
| //     * Redistributions of source code must retain the above copyright | ||||
| // notice, this list of conditions and the following disclaimer. | ||||
| //     * Redistributions in binary form must reproduce the above | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| //     * Neither the name of Google Inc. nor the names of its | ||||
| // contributors may be used to endorse or promote products derived from | ||||
| // this software without specific prior written permission. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| package proto | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"reflect" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"sync/atomic" | ||||
| ) | ||||
|  | ||||
| type generatedDiscarder interface { | ||||
| 	XXX_DiscardUnknown() | ||||
| } | ||||
|  | ||||
| // DiscardUnknown recursively discards all unknown fields from this message | ||||
| // and all embedded messages. | ||||
| // | ||||
| // When unmarshaling a message with unrecognized fields, the tags and values | ||||
| // of such fields are preserved in the Message. This allows a later call to | ||||
| // marshal to be able to produce a message that continues to have those | ||||
| // unrecognized fields. To avoid this, DiscardUnknown is used to | ||||
| // explicitly clear the unknown fields after unmarshaling. | ||||
| // | ||||
| // For proto2 messages, the unknown fields of message extensions are only | ||||
| // discarded from messages that have been accessed via GetExtension. | ||||
| func DiscardUnknown(m Message) { | ||||
| 	if m, ok := m.(generatedDiscarder); ok { | ||||
| 		m.XXX_DiscardUnknown() | ||||
| 		return | ||||
| 	} | ||||
| 	// TODO: Dynamically populate a InternalMessageInfo for legacy messages, | ||||
| 	// but the master branch has no implementation for InternalMessageInfo, | ||||
| 	// so it would be more work to replicate that approach. | ||||
| 	discardLegacy(m) | ||||
| } | ||||
|  | ||||
| // DiscardUnknown recursively discards all unknown fields. | ||||
| func (a *InternalMessageInfo) DiscardUnknown(m Message) { | ||||
| 	di := atomicLoadDiscardInfo(&a.discard) | ||||
| 	if di == nil { | ||||
| 		di = getDiscardInfo(reflect.TypeOf(m).Elem()) | ||||
| 		atomicStoreDiscardInfo(&a.discard, di) | ||||
| 	} | ||||
| 	di.discard(toPointer(&m)) | ||||
| } | ||||
|  | ||||
| type discardInfo struct { | ||||
| 	typ reflect.Type | ||||
|  | ||||
| 	initialized int32 // 0: only typ is valid, 1: everything is valid | ||||
| 	lock        sync.Mutex | ||||
|  | ||||
| 	fields       []discardFieldInfo | ||||
| 	unrecognized field | ||||
| } | ||||
|  | ||||
| type discardFieldInfo struct { | ||||
| 	field   field // Offset of field, guaranteed to be valid | ||||
| 	discard func(src pointer) | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	discardInfoMap  = map[reflect.Type]*discardInfo{} | ||||
| 	discardInfoLock sync.Mutex | ||||
| ) | ||||
|  | ||||
| func getDiscardInfo(t reflect.Type) *discardInfo { | ||||
| 	discardInfoLock.Lock() | ||||
| 	defer discardInfoLock.Unlock() | ||||
| 	di := discardInfoMap[t] | ||||
| 	if di == nil { | ||||
| 		di = &discardInfo{typ: t} | ||||
| 		discardInfoMap[t] = di | ||||
| 	} | ||||
| 	return di | ||||
| } | ||||
|  | ||||
| func (di *discardInfo) discard(src pointer) { | ||||
| 	if src.isNil() { | ||||
| 		return // Nothing to do. | ||||
| 	} | ||||
|  | ||||
| 	if atomic.LoadInt32(&di.initialized) == 0 { | ||||
| 		di.computeDiscardInfo() | ||||
| 	} | ||||
|  | ||||
| 	for _, fi := range di.fields { | ||||
| 		sfp := src.offset(fi.field) | ||||
| 		fi.discard(sfp) | ||||
| 	} | ||||
|  | ||||
| 	// For proto2 messages, only discard unknown fields in message extensions | ||||
| 	// that have been accessed via GetExtension. | ||||
| 	if em, err := extendable(src.asPointerTo(di.typ).Interface()); err == nil { | ||||
| 		// Ignore lock since DiscardUnknown is not concurrency safe. | ||||
| 		emm, _ := em.extensionsRead() | ||||
| 		for _, mx := range emm { | ||||
| 			if m, ok := mx.value.(Message); ok { | ||||
| 				DiscardUnknown(m) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if di.unrecognized.IsValid() { | ||||
| 		*src.offset(di.unrecognized).toBytes() = nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (di *discardInfo) computeDiscardInfo() { | ||||
| 	di.lock.Lock() | ||||
| 	defer di.lock.Unlock() | ||||
| 	if di.initialized != 0 { | ||||
| 		return | ||||
| 	} | ||||
| 	t := di.typ | ||||
| 	n := t.NumField() | ||||
|  | ||||
| 	for i := 0; i < n; i++ { | ||||
| 		f := t.Field(i) | ||||
| 		if strings.HasPrefix(f.Name, "XXX_") { | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		dfi := discardFieldInfo{field: toField(&f)} | ||||
| 		tf := f.Type | ||||
|  | ||||
| 		// Unwrap tf to get its most basic type. | ||||
| 		var isPointer, isSlice bool | ||||
| 		if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 { | ||||
| 			isSlice = true | ||||
| 			tf = tf.Elem() | ||||
| 		} | ||||
| 		if tf.Kind() == reflect.Ptr { | ||||
| 			isPointer = true | ||||
| 			tf = tf.Elem() | ||||
| 		} | ||||
| 		if isPointer && isSlice && tf.Kind() != reflect.Struct { | ||||
| 			panic(fmt.Sprintf("%v.%s cannot be a slice of pointers to primitive types", t, f.Name)) | ||||
| 		} | ||||
|  | ||||
| 		switch tf.Kind() { | ||||
| 		case reflect.Struct: | ||||
| 			switch { | ||||
| 			case !isPointer: | ||||
| 				panic(fmt.Sprintf("%v.%s cannot be a direct struct value", t, f.Name)) | ||||
| 			case isSlice: // E.g., []*pb.T | ||||
| 				discardInfo := getDiscardInfo(tf) | ||||
| 				dfi.discard = func(src pointer) { | ||||
| 					sps := src.getPointerSlice() | ||||
| 					for _, sp := range sps { | ||||
| 						if !sp.isNil() { | ||||
| 							discardInfo.discard(sp) | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			default: // E.g., *pb.T | ||||
| 				discardInfo := getDiscardInfo(tf) | ||||
| 				dfi.discard = func(src pointer) { | ||||
| 					sp := src.getPointer() | ||||
| 					if !sp.isNil() { | ||||
| 						discardInfo.discard(sp) | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		case reflect.Map: | ||||
| 			switch { | ||||
| 			case isPointer || isSlice: | ||||
| 				panic(fmt.Sprintf("%v.%s cannot be a pointer to a map or a slice of map values", t, f.Name)) | ||||
| 			default: // E.g., map[K]V | ||||
| 				if tf.Elem().Kind() == reflect.Ptr { // Proto struct (e.g., *T) | ||||
| 					dfi.discard = func(src pointer) { | ||||
| 						sm := src.asPointerTo(tf).Elem() | ||||
| 						if sm.Len() == 0 { | ||||
| 							return | ||||
| 						} | ||||
| 						for _, key := range sm.MapKeys() { | ||||
| 							val := sm.MapIndex(key) | ||||
| 							DiscardUnknown(val.Interface().(Message)) | ||||
| 						} | ||||
| 					} | ||||
| 				} else { | ||||
| 					dfi.discard = func(pointer) {} // Noop | ||||
| 				} | ||||
| 			} | ||||
| 		case reflect.Interface: | ||||
| 			// Must be oneof field. | ||||
| 			switch { | ||||
| 			case isPointer || isSlice: | ||||
| 				panic(fmt.Sprintf("%v.%s cannot be a pointer to a interface or a slice of interface values", t, f.Name)) | ||||
| 			default: // E.g., interface{} | ||||
| 				// TODO: Make this faster? | ||||
| 				dfi.discard = func(src pointer) { | ||||
| 					su := src.asPointerTo(tf).Elem() | ||||
| 					if !su.IsNil() { | ||||
| 						sv := su.Elem().Elem().Field(0) | ||||
| 						if sv.Kind() == reflect.Ptr && sv.IsNil() { | ||||
| 							return | ||||
| 						} | ||||
| 						switch sv.Type().Kind() { | ||||
| 						case reflect.Ptr: // Proto struct (e.g., *T) | ||||
| 							DiscardUnknown(sv.Interface().(Message)) | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		default: | ||||
| 			continue | ||||
| 		} | ||||
| 		di.fields = append(di.fields, dfi) | ||||
| 	} | ||||
|  | ||||
| 	di.unrecognized = invalidField | ||||
| 	if f, ok := t.FieldByName("XXX_unrecognized"); ok { | ||||
| 		if f.Type != reflect.TypeOf([]byte{}) { | ||||
| 			panic("expected XXX_unrecognized to be of type []byte") | ||||
| 		} | ||||
| 		di.unrecognized = toField(&f) | ||||
| 	} | ||||
|  | ||||
| 	atomic.StoreInt32(&di.initialized, 1) | ||||
| } | ||||
|  | ||||
| func discardLegacy(m Message) { | ||||
| 	v := reflect.ValueOf(m) | ||||
| 	if v.Kind() != reflect.Ptr || v.IsNil() { | ||||
| 		return | ||||
| 	} | ||||
| 	v = v.Elem() | ||||
| 	if v.Kind() != reflect.Struct { | ||||
| 		return | ||||
| 	} | ||||
| 	t := v.Type() | ||||
|  | ||||
| 	for i := 0; i < v.NumField(); i++ { | ||||
| 		f := t.Field(i) | ||||
| 		if strings.HasPrefix(f.Name, "XXX_") { | ||||
| 			continue | ||||
| 		} | ||||
| 		vf := v.Field(i) | ||||
| 		tf := f.Type | ||||
|  | ||||
| 		// Unwrap tf to get its most basic type. | ||||
| 		var isPointer, isSlice bool | ||||
| 		if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 { | ||||
| 			isSlice = true | ||||
| 			tf = tf.Elem() | ||||
| 		} | ||||
| 		if tf.Kind() == reflect.Ptr { | ||||
| 			isPointer = true | ||||
| 			tf = tf.Elem() | ||||
| 		} | ||||
| 		if isPointer && isSlice && tf.Kind() != reflect.Struct { | ||||
| 			panic(fmt.Sprintf("%T.%s cannot be a slice of pointers to primitive types", m, f.Name)) | ||||
| 		} | ||||
|  | ||||
| 		switch tf.Kind() { | ||||
| 		case reflect.Struct: | ||||
| 			switch { | ||||
| 			case !isPointer: | ||||
| 				panic(fmt.Sprintf("%T.%s cannot be a direct struct value", m, f.Name)) | ||||
| 			case isSlice: // E.g., []*pb.T | ||||
| 				for j := 0; j < vf.Len(); j++ { | ||||
| 					discardLegacy(vf.Index(j).Interface().(Message)) | ||||
| 				} | ||||
| 			default: // E.g., *pb.T | ||||
| 				discardLegacy(vf.Interface().(Message)) | ||||
| 			} | ||||
| 		case reflect.Map: | ||||
| 			switch { | ||||
| 			case isPointer || isSlice: | ||||
| 				panic(fmt.Sprintf("%T.%s cannot be a pointer to a map or a slice of map values", m, f.Name)) | ||||
| 			default: // E.g., map[K]V | ||||
| 				tv := vf.Type().Elem() | ||||
| 				if tv.Kind() == reflect.Ptr && tv.Implements(protoMessageType) { // Proto struct (e.g., *T) | ||||
| 					for _, key := range vf.MapKeys() { | ||||
| 						val := vf.MapIndex(key) | ||||
| 						discardLegacy(val.Interface().(Message)) | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		case reflect.Interface: | ||||
| 			// Must be oneof field. | ||||
| 			switch { | ||||
| 			case isPointer || isSlice: | ||||
| 				panic(fmt.Sprintf("%T.%s cannot be a pointer to a interface or a slice of interface values", m, f.Name)) | ||||
| 			default: // E.g., test_proto.isCommunique_Union interface | ||||
| 				if !vf.IsNil() && f.Tag.Get("protobuf_oneof") != "" { | ||||
| 					vf = vf.Elem() // E.g., *test_proto.Communique_Msg | ||||
| 					if !vf.IsNil() { | ||||
| 						vf = vf.Elem()   // E.g., test_proto.Communique_Msg | ||||
| 						vf = vf.Field(0) // E.g., Proto struct (e.g., *T) or primitive value | ||||
| 						if vf.Kind() == reflect.Ptr { | ||||
| 							discardLegacy(vf.Interface().(Message)) | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if vf := v.FieldByName("XXX_unrecognized"); vf.IsValid() { | ||||
| 		if vf.Type() != reflect.TypeOf([]byte{}) { | ||||
| 			panic("expected XXX_unrecognized to be of type []byte") | ||||
| 		} | ||||
| 		vf.Set(reflect.ValueOf([]byte(nil))) | ||||
| 	} | ||||
|  | ||||
| 	// For proto2 messages, only discard unknown fields in message extensions | ||||
| 	// that have been accessed via GetExtension. | ||||
| 	if em, err := extendable(m); err == nil { | ||||
| 		// Ignore lock since discardLegacy is not concurrency safe. | ||||
| 		emm, _ := em.extensionsRead() | ||||
| 		for _, mx := range emm { | ||||
| 			if m, ok := mx.value.(Message); ok { | ||||
| 				discardLegacy(m) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										169
									
								
								vendor/github.com/gogo/protobuf/proto/discard_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										169
									
								
								vendor/github.com/gogo/protobuf/proto/discard_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,169 +0,0 @@ | ||||
| // Go support for Protocol Buffers - Google's data interchange format | ||||
| // | ||||
| // Copyright 2017 The Go Authors.  All rights reserved. | ||||
| // https://github.com/golang/protobuf | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| // | ||||
| //     * Redistributions of source code must retain the above copyright | ||||
| // notice, this list of conditions and the following disclaimer. | ||||
| //     * Redistributions in binary form must reproduce the above | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| //     * Neither the name of Google Inc. nor the names of its | ||||
| // contributors may be used to endorse or promote products derived from | ||||
| // this software without specific prior written permission. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| package proto_test | ||||
|  | ||||
| import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
| 	proto3pb "github.com/gogo/protobuf/proto/proto3_proto" | ||||
| 	pb "github.com/gogo/protobuf/proto/test_proto" | ||||
| ) | ||||
|  | ||||
| func TestDiscardUnknown(t *testing.T) { | ||||
| 	tests := []struct { | ||||
| 		desc     string | ||||
| 		in, want proto.Message | ||||
| 	}{{ | ||||
| 		desc: "Nil", | ||||
| 		in:   nil, want: nil, // Should not panic | ||||
| 	}, { | ||||
| 		desc: "NilPtr", | ||||
| 		in:   (*proto3pb.Message)(nil), want: (*proto3pb.Message)(nil), // Should not panic | ||||
| 	}, { | ||||
| 		desc: "Nested", | ||||
| 		in: &proto3pb.Message{ | ||||
| 			Name:             "Aaron", | ||||
| 			Nested:           &proto3pb.Nested{Cute: true, XXX_unrecognized: []byte("blah")}, | ||||
| 			XXX_unrecognized: []byte("blah"), | ||||
| 		}, | ||||
| 		want: &proto3pb.Message{ | ||||
| 			Name:   "Aaron", | ||||
| 			Nested: &proto3pb.Nested{Cute: true}, | ||||
| 		}, | ||||
| 	}, { | ||||
| 		desc: "Slice", | ||||
| 		in: &proto3pb.Message{ | ||||
| 			Name: "Aaron", | ||||
| 			Children: []*proto3pb.Message{ | ||||
| 				{Name: "Sarah", XXX_unrecognized: []byte("blah")}, | ||||
| 				{Name: "Abraham", XXX_unrecognized: []byte("blah")}, | ||||
| 			}, | ||||
| 			XXX_unrecognized: []byte("blah"), | ||||
| 		}, | ||||
| 		want: &proto3pb.Message{ | ||||
| 			Name: "Aaron", | ||||
| 			Children: []*proto3pb.Message{ | ||||
| 				{Name: "Sarah"}, | ||||
| 				{Name: "Abraham"}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	}, { | ||||
| 		desc: "OneOf", | ||||
| 		in: &pb.Communique{ | ||||
| 			Union: &pb.Communique_Msg{Msg: &pb.Strings{ | ||||
| 				StringField:      proto.String("123"), | ||||
| 				XXX_unrecognized: []byte("blah"), | ||||
| 			}}, | ||||
| 			XXX_unrecognized: []byte("blah"), | ||||
| 		}, | ||||
| 		want: &pb.Communique{ | ||||
| 			Union: &pb.Communique_Msg{Msg: &pb.Strings{StringField: proto.String("123")}}, | ||||
| 		}, | ||||
| 	}, { | ||||
| 		desc: "Map", | ||||
| 		in: &pb.MessageWithMap{MsgMapping: map[int64]*pb.FloatingPoint{ | ||||
| 			0x4002: { | ||||
| 				Exact:            proto.Bool(true), | ||||
| 				XXX_unrecognized: []byte("blah"), | ||||
| 			}, | ||||
| 		}}, | ||||
| 		want: &pb.MessageWithMap{MsgMapping: map[int64]*pb.FloatingPoint{ | ||||
| 			0x4002: {Exact: proto.Bool(true)}, | ||||
| 		}}, | ||||
| 	}, { | ||||
| 		desc: "Extension", | ||||
| 		in: func() proto.Message { | ||||
| 			m := &pb.MyMessage{ | ||||
| 				Count: proto.Int32(42), | ||||
| 				Somegroup: &pb.MyMessage_SomeGroup{ | ||||
| 					GroupField:       proto.Int32(6), | ||||
| 					XXX_unrecognized: []byte("blah"), | ||||
| 				}, | ||||
| 				XXX_unrecognized: []byte("blah"), | ||||
| 			} | ||||
| 			proto.SetExtension(m, pb.E_Ext_More, &pb.Ext{ | ||||
| 				Data:             proto.String("extension"), | ||||
| 				XXX_unrecognized: []byte("blah"), | ||||
| 			}) | ||||
| 			return m | ||||
| 		}(), | ||||
| 		want: func() proto.Message { | ||||
| 			m := &pb.MyMessage{ | ||||
| 				Count:     proto.Int32(42), | ||||
| 				Somegroup: &pb.MyMessage_SomeGroup{GroupField: proto.Int32(6)}, | ||||
| 			} | ||||
| 			proto.SetExtension(m, pb.E_Ext_More, &pb.Ext{Data: proto.String("extension")}) | ||||
| 			return m | ||||
| 		}(), | ||||
| 	}} | ||||
|  | ||||
| 	// Test the legacy code path. | ||||
| 	for _, tt := range tests { | ||||
| 		// Clone the input so that we don't alter the original. | ||||
| 		in := tt.in | ||||
| 		if in != nil { | ||||
| 			in = proto.Clone(tt.in) | ||||
| 		} | ||||
|  | ||||
| 		var m LegacyMessage | ||||
| 		m.Message, _ = in.(*proto3pb.Message) | ||||
| 		m.Communique, _ = in.(*pb.Communique) | ||||
| 		m.MessageWithMap, _ = in.(*pb.MessageWithMap) | ||||
| 		m.MyMessage, _ = in.(*pb.MyMessage) | ||||
| 		proto.DiscardUnknown(&m) | ||||
| 		if !proto.Equal(in, tt.want) { | ||||
| 			t.Errorf("test %s/Legacy, expected unknown fields to be discarded\ngot  %v\nwant %v", tt.desc, in, tt.want) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	for _, tt := range tests { | ||||
| 		proto.DiscardUnknown(tt.in) | ||||
| 		if !proto.Equal(tt.in, tt.want) { | ||||
| 			t.Errorf("test %s, expected unknown fields to be discarded\ngot  %v\nwant %v", tt.desc, tt.in, tt.want) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // LegacyMessage is a proto.Message that has several nested messages. | ||||
| // This does not have the XXX_DiscardUnknown method and so forces DiscardUnknown | ||||
| // to use the legacy fallback logic. | ||||
| type LegacyMessage struct { | ||||
| 	Message        *proto3pb.Message | ||||
| 	Communique     *pb.Communique | ||||
| 	MessageWithMap *pb.MessageWithMap | ||||
| 	MyMessage      *pb.MyMessage | ||||
| } | ||||
|  | ||||
| func (m *LegacyMessage) Reset()         { *m = LegacyMessage{} } | ||||
| func (m *LegacyMessage) String() string { return proto.CompactTextString(m) } | ||||
| func (*LegacyMessage) ProtoMessage()    {} | ||||
							
								
								
									
										154
									
								
								vendor/github.com/gogo/protobuf/proto/duration_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										154
									
								
								vendor/github.com/gogo/protobuf/proto/duration_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -47,3 +47,157 @@ func (*duration) String() string { return "duration<string>" } | ||||
| func init() { | ||||
| 	RegisterType((*duration)(nil), "gogo.protobuf.proto.duration") | ||||
| } | ||||
|  | ||||
| func (o *Buffer) decDuration() (time.Duration, error) { | ||||
| 	b, err := o.DecodeRawBytes(true) | ||||
| 	if err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	dproto := &duration{} | ||||
| 	if err := Unmarshal(b, dproto); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return durationFromProto(dproto) | ||||
| } | ||||
|  | ||||
| func (o *Buffer) dec_duration(p *Properties, base structPointer) error { | ||||
| 	d, err := o.decDuration() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	word64_Set(structPointer_Word64(base, p.field), o, uint64(d)) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (o *Buffer) dec_ref_duration(p *Properties, base structPointer) error { | ||||
| 	d, err := o.decDuration() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	word64Val_Set(structPointer_Word64Val(base, p.field), o, uint64(d)) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (o *Buffer) dec_slice_duration(p *Properties, base structPointer) error { | ||||
| 	d, err := o.decDuration() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	newBas := appendStructPointer(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))) | ||||
| 	var zero field | ||||
| 	setPtrCustomType(newBas, zero, &d) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (o *Buffer) dec_slice_ref_duration(p *Properties, base structPointer) error { | ||||
| 	d, err := o.decDuration() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	structPointer_Word64Slice(base, p.field).Append(uint64(d)) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_duration(p *Properties, base structPointer) (n int) { | ||||
| 	structp := structPointer_GetStructPointer(base, p.field) | ||||
| 	if structPointer_IsNil(structp) { | ||||
| 		return 0 | ||||
| 	} | ||||
| 	dur := structPointer_Interface(structp, durationType).(*time.Duration) | ||||
| 	d := durationProto(*dur) | ||||
| 	size := Size(d) | ||||
| 	return size + sizeVarint(uint64(size)) + len(p.tagcode) | ||||
| } | ||||
|  | ||||
| func (o *Buffer) enc_duration(p *Properties, base structPointer) error { | ||||
| 	structp := structPointer_GetStructPointer(base, p.field) | ||||
| 	if structPointer_IsNil(structp) { | ||||
| 		return ErrNil | ||||
| 	} | ||||
| 	dur := structPointer_Interface(structp, durationType).(*time.Duration) | ||||
| 	d := durationProto(*dur) | ||||
| 	data, err := Marshal(d) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	o.buf = append(o.buf, p.tagcode...) | ||||
| 	o.EncodeRawBytes(data) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_ref_duration(p *Properties, base structPointer) (n int) { | ||||
| 	dur := structPointer_InterfaceAt(base, p.field, durationType).(*time.Duration) | ||||
| 	d := durationProto(*dur) | ||||
| 	size := Size(d) | ||||
| 	return size + sizeVarint(uint64(size)) + len(p.tagcode) | ||||
| } | ||||
|  | ||||
| func (o *Buffer) enc_ref_duration(p *Properties, base structPointer) error { | ||||
| 	dur := structPointer_InterfaceAt(base, p.field, durationType).(*time.Duration) | ||||
| 	d := durationProto(*dur) | ||||
| 	data, err := Marshal(d) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	o.buf = append(o.buf, p.tagcode...) | ||||
| 	o.EncodeRawBytes(data) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_slice_duration(p *Properties, base structPointer) (n int) { | ||||
| 	pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))).(*[]*time.Duration) | ||||
| 	durs := *pdurs | ||||
| 	for i := 0; i < len(durs); i++ { | ||||
| 		if durs[i] == nil { | ||||
| 			return 0 | ||||
| 		} | ||||
| 		dproto := durationProto(*durs[i]) | ||||
| 		size := Size(dproto) | ||||
| 		n += len(p.tagcode) + size + sizeVarint(uint64(size)) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (o *Buffer) enc_slice_duration(p *Properties, base structPointer) error { | ||||
| 	pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))).(*[]*time.Duration) | ||||
| 	durs := *pdurs | ||||
| 	for i := 0; i < len(durs); i++ { | ||||
| 		if durs[i] == nil { | ||||
| 			return errRepeatedHasNil | ||||
| 		} | ||||
| 		dproto := durationProto(*durs[i]) | ||||
| 		data, err := Marshal(dproto) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		o.buf = append(o.buf, p.tagcode...) | ||||
| 		o.EncodeRawBytes(data) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_slice_ref_duration(p *Properties, base structPointer) (n int) { | ||||
| 	pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(durationType)).(*[]time.Duration) | ||||
| 	durs := *pdurs | ||||
| 	for i := 0; i < len(durs); i++ { | ||||
| 		dproto := durationProto(durs[i]) | ||||
| 		size := Size(dproto) | ||||
| 		n += len(p.tagcode) + size + sizeVarint(uint64(size)) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (o *Buffer) enc_slice_ref_duration(p *Properties, base structPointer) error { | ||||
| 	pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(durationType)).(*[]time.Duration) | ||||
| 	durs := *pdurs | ||||
| 	for i := 0; i < len(durs); i++ { | ||||
| 		dproto := durationProto(durs[i]) | ||||
| 		data, err := Marshal(dproto) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		o.buf = append(o.buf, p.tagcode...) | ||||
| 		o.EncodeRawBytes(data) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										1207
									
								
								vendor/github.com/gogo/protobuf/proto/encode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1207
									
								
								vendor/github.com/gogo/protobuf/proto/encode.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										317
									
								
								vendor/github.com/gogo/protobuf/proto/encode_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										317
									
								
								vendor/github.com/gogo/protobuf/proto/encode_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -3,6 +3,11 @@ | ||||
| // Copyright (c) 2013, The GoGo Authors. All rights reserved. | ||||
| // http://github.com/gogo/protobuf | ||||
| // | ||||
| // Go support for Protocol Buffers - Google's data interchange format | ||||
| // | ||||
| // Copyright 2010 The Go Authors.  All rights reserved. | ||||
| // http://github.com/golang/protobuf/ | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| @@ -13,6 +18,9 @@ | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| //     * Neither the name of Google Inc. nor the names of its | ||||
| // contributors may be used to endorse or promote products derived from | ||||
| // this software without specific prior written permission. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| @@ -28,6 +36,315 @@ | ||||
|  | ||||
| package proto | ||||
|  | ||||
| import ( | ||||
| 	"reflect" | ||||
| ) | ||||
|  | ||||
| func NewRequiredNotSetError(field string) *RequiredNotSetError { | ||||
| 	return &RequiredNotSetError{field} | ||||
| } | ||||
|  | ||||
| type Sizer interface { | ||||
| 	Size() int | ||||
| } | ||||
|  | ||||
| func (o *Buffer) enc_ext_slice_byte(p *Properties, base structPointer) error { | ||||
| 	s := *structPointer_Bytes(base, p.field) | ||||
| 	if s == nil { | ||||
| 		return ErrNil | ||||
| 	} | ||||
| 	o.buf = append(o.buf, s...) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_ext_slice_byte(p *Properties, base structPointer) (n int) { | ||||
| 	s := *structPointer_Bytes(base, p.field) | ||||
| 	if s == nil { | ||||
| 		return 0 | ||||
| 	} | ||||
| 	n += len(s) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // Encode a reference to bool pointer. | ||||
| func (o *Buffer) enc_ref_bool(p *Properties, base structPointer) error { | ||||
| 	v := *structPointer_BoolVal(base, p.field) | ||||
| 	x := 0 | ||||
| 	if v { | ||||
| 		x = 1 | ||||
| 	} | ||||
| 	o.buf = append(o.buf, p.tagcode...) | ||||
| 	p.valEnc(o, uint64(x)) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_ref_bool(p *Properties, base structPointer) int { | ||||
| 	return len(p.tagcode) + 1 // each bool takes exactly one byte | ||||
| } | ||||
|  | ||||
| // Encode a reference to int32 pointer. | ||||
| func (o *Buffer) enc_ref_int32(p *Properties, base structPointer) error { | ||||
| 	v := structPointer_Word32Val(base, p.field) | ||||
| 	x := int32(word32Val_Get(v)) | ||||
| 	o.buf = append(o.buf, p.tagcode...) | ||||
| 	p.valEnc(o, uint64(x)) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_ref_int32(p *Properties, base structPointer) (n int) { | ||||
| 	v := structPointer_Word32Val(base, p.field) | ||||
| 	x := int32(word32Val_Get(v)) | ||||
| 	n += len(p.tagcode) | ||||
| 	n += p.valSize(uint64(x)) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (o *Buffer) enc_ref_uint32(p *Properties, base structPointer) error { | ||||
| 	v := structPointer_Word32Val(base, p.field) | ||||
| 	x := word32Val_Get(v) | ||||
| 	o.buf = append(o.buf, p.tagcode...) | ||||
| 	p.valEnc(o, uint64(x)) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_ref_uint32(p *Properties, base structPointer) (n int) { | ||||
| 	v := structPointer_Word32Val(base, p.field) | ||||
| 	x := word32Val_Get(v) | ||||
| 	n += len(p.tagcode) | ||||
| 	n += p.valSize(uint64(x)) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // Encode a reference to an int64 pointer. | ||||
| func (o *Buffer) enc_ref_int64(p *Properties, base structPointer) error { | ||||
| 	v := structPointer_Word64Val(base, p.field) | ||||
| 	x := word64Val_Get(v) | ||||
| 	o.buf = append(o.buf, p.tagcode...) | ||||
| 	p.valEnc(o, x) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_ref_int64(p *Properties, base structPointer) (n int) { | ||||
| 	v := structPointer_Word64Val(base, p.field) | ||||
| 	x := word64Val_Get(v) | ||||
| 	n += len(p.tagcode) | ||||
| 	n += p.valSize(x) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // Encode a reference to a string pointer. | ||||
| func (o *Buffer) enc_ref_string(p *Properties, base structPointer) error { | ||||
| 	v := *structPointer_StringVal(base, p.field) | ||||
| 	o.buf = append(o.buf, p.tagcode...) | ||||
| 	o.EncodeStringBytes(v) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_ref_string(p *Properties, base structPointer) (n int) { | ||||
| 	v := *structPointer_StringVal(base, p.field) | ||||
| 	n += len(p.tagcode) | ||||
| 	n += sizeStringBytes(v) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // Encode a reference to a message struct. | ||||
| func (o *Buffer) enc_ref_struct_message(p *Properties, base structPointer) error { | ||||
| 	var state errorState | ||||
| 	structp := structPointer_GetRefStructPointer(base, p.field) | ||||
| 	if structPointer_IsNil(structp) { | ||||
| 		return ErrNil | ||||
| 	} | ||||
|  | ||||
| 	// Can the object marshal itself? | ||||
| 	if p.isMarshaler { | ||||
| 		m := structPointer_Interface(structp, p.stype).(Marshaler) | ||||
| 		data, err := m.Marshal() | ||||
| 		if err != nil && !state.shouldContinue(err, nil) { | ||||
| 			return err | ||||
| 		} | ||||
| 		o.buf = append(o.buf, p.tagcode...) | ||||
| 		o.EncodeRawBytes(data) | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	o.buf = append(o.buf, p.tagcode...) | ||||
| 	return o.enc_len_struct(p.sprop, structp, &state) | ||||
| } | ||||
|  | ||||
| //TODO this is only copied, please fix this | ||||
| func size_ref_struct_message(p *Properties, base structPointer) int { | ||||
| 	structp := structPointer_GetRefStructPointer(base, p.field) | ||||
| 	if structPointer_IsNil(structp) { | ||||
| 		return 0 | ||||
| 	} | ||||
|  | ||||
| 	// Can the object marshal itself? | ||||
| 	if p.isMarshaler { | ||||
| 		m := structPointer_Interface(structp, p.stype).(Marshaler) | ||||
| 		data, _ := m.Marshal() | ||||
| 		n0 := len(p.tagcode) | ||||
| 		n1 := sizeRawBytes(data) | ||||
| 		return n0 + n1 | ||||
| 	} | ||||
|  | ||||
| 	n0 := len(p.tagcode) | ||||
| 	n1 := size_struct(p.sprop, structp) | ||||
| 	n2 := sizeVarint(uint64(n1)) // size of encoded length | ||||
| 	return n0 + n1 + n2 | ||||
| } | ||||
|  | ||||
| // Encode a slice of references to message struct pointers ([]struct). | ||||
| func (o *Buffer) enc_slice_ref_struct_message(p *Properties, base structPointer) error { | ||||
| 	var state errorState | ||||
| 	ss := structPointer_StructRefSlice(base, p.field, p.stype.Size()) | ||||
| 	l := ss.Len() | ||||
| 	for i := 0; i < l; i++ { | ||||
| 		structp := ss.Index(i) | ||||
| 		if structPointer_IsNil(structp) { | ||||
| 			return errRepeatedHasNil | ||||
| 		} | ||||
|  | ||||
| 		// Can the object marshal itself? | ||||
| 		if p.isMarshaler { | ||||
| 			m := structPointer_Interface(structp, p.stype).(Marshaler) | ||||
| 			data, err := m.Marshal() | ||||
| 			if err != nil && !state.shouldContinue(err, nil) { | ||||
| 				return err | ||||
| 			} | ||||
| 			o.buf = append(o.buf, p.tagcode...) | ||||
| 			o.EncodeRawBytes(data) | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		o.buf = append(o.buf, p.tagcode...) | ||||
| 		err := o.enc_len_struct(p.sprop, structp, &state) | ||||
| 		if err != nil && !state.shouldContinue(err, nil) { | ||||
| 			if err == ErrNil { | ||||
| 				return errRepeatedHasNil | ||||
| 			} | ||||
| 			return err | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
| 	return state.err | ||||
| } | ||||
|  | ||||
| //TODO this is only copied, please fix this | ||||
| func size_slice_ref_struct_message(p *Properties, base structPointer) (n int) { | ||||
| 	ss := structPointer_StructRefSlice(base, p.field, p.stype.Size()) | ||||
| 	l := ss.Len() | ||||
| 	n += l * len(p.tagcode) | ||||
| 	for i := 0; i < l; i++ { | ||||
| 		structp := ss.Index(i) | ||||
| 		if structPointer_IsNil(structp) { | ||||
| 			return // return the size up to this point | ||||
| 		} | ||||
|  | ||||
| 		// Can the object marshal itself? | ||||
| 		if p.isMarshaler { | ||||
| 			m := structPointer_Interface(structp, p.stype).(Marshaler) | ||||
| 			data, _ := m.Marshal() | ||||
| 			n += len(p.tagcode) | ||||
| 			n += sizeRawBytes(data) | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		n0 := size_struct(p.sprop, structp) | ||||
| 		n1 := sizeVarint(uint64(n0)) // size of encoded length | ||||
| 		n += n0 + n1 | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (o *Buffer) enc_custom_bytes(p *Properties, base structPointer) error { | ||||
| 	i := structPointer_InterfaceRef(base, p.field, p.ctype) | ||||
| 	if i == nil { | ||||
| 		return ErrNil | ||||
| 	} | ||||
| 	custom := i.(Marshaler) | ||||
| 	data, err := custom.Marshal() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	if data == nil { | ||||
| 		return ErrNil | ||||
| 	} | ||||
| 	o.buf = append(o.buf, p.tagcode...) | ||||
| 	o.EncodeRawBytes(data) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_custom_bytes(p *Properties, base structPointer) (n int) { | ||||
| 	n += len(p.tagcode) | ||||
| 	i := structPointer_InterfaceRef(base, p.field, p.ctype) | ||||
| 	if i == nil { | ||||
| 		return 0 | ||||
| 	} | ||||
| 	custom := i.(Marshaler) | ||||
| 	data, _ := custom.Marshal() | ||||
| 	n += sizeRawBytes(data) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (o *Buffer) enc_custom_ref_bytes(p *Properties, base structPointer) error { | ||||
| 	custom := structPointer_InterfaceAt(base, p.field, p.ctype).(Marshaler) | ||||
| 	data, err := custom.Marshal() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	if data == nil { | ||||
| 		return ErrNil | ||||
| 	} | ||||
| 	o.buf = append(o.buf, p.tagcode...) | ||||
| 	o.EncodeRawBytes(data) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_custom_ref_bytes(p *Properties, base structPointer) (n int) { | ||||
| 	n += len(p.tagcode) | ||||
| 	i := structPointer_InterfaceAt(base, p.field, p.ctype) | ||||
| 	if i == nil { | ||||
| 		return 0 | ||||
| 	} | ||||
| 	custom := i.(Marshaler) | ||||
| 	data, _ := custom.Marshal() | ||||
| 	n += sizeRawBytes(data) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (o *Buffer) enc_custom_slice_bytes(p *Properties, base structPointer) error { | ||||
| 	inter := structPointer_InterfaceRef(base, p.field, p.ctype) | ||||
| 	if inter == nil { | ||||
| 		return ErrNil | ||||
| 	} | ||||
| 	slice := reflect.ValueOf(inter) | ||||
| 	l := slice.Len() | ||||
| 	for i := 0; i < l; i++ { | ||||
| 		v := slice.Index(i) | ||||
| 		custom := v.Interface().(Marshaler) | ||||
| 		data, err := custom.Marshal() | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		o.buf = append(o.buf, p.tagcode...) | ||||
| 		o.EncodeRawBytes(data) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func size_custom_slice_bytes(p *Properties, base structPointer) (n int) { | ||||
| 	inter := structPointer_InterfaceRef(base, p.field, p.ctype) | ||||
| 	if inter == nil { | ||||
| 		return 0 | ||||
| 	} | ||||
| 	slice := reflect.ValueOf(inter) | ||||
| 	l := slice.Len() | ||||
| 	n += l * len(p.tagcode) | ||||
| 	for i := 0; i < l; i++ { | ||||
| 		v := slice.Index(i) | ||||
| 		custom := v.Interface().(Marshaler) | ||||
| 		data, _ := custom.Marshal() | ||||
| 		n += sizeRawBytes(data) | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/gogo/protobuf/proto/encode_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/gogo/protobuf/proto/encode_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,8 +29,6 @@ | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| // +build go1.7 | ||||
|  | ||||
| package proto_test | ||||
|  | ||||
| import ( | ||||
|   | ||||
							
								
								
									
										30
									
								
								vendor/github.com/gogo/protobuf/proto/equal.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										30
									
								
								vendor/github.com/gogo/protobuf/proto/equal.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -109,6 +109,15 @@ func equalStruct(v1, v2 reflect.Value) bool { | ||||
| 				// set/unset mismatch | ||||
| 				return false | ||||
| 			} | ||||
| 			b1, ok := f1.Interface().(raw) | ||||
| 			if ok { | ||||
| 				b2 := f2.Interface().(raw) | ||||
| 				// RawMessage | ||||
| 				if !bytes.Equal(b1.Bytes(), b2.Bytes()) { | ||||
| 					return false | ||||
| 				} | ||||
| 				continue | ||||
| 			} | ||||
| 			f1, f2 = f1.Elem(), f2.Elem() | ||||
| 		} | ||||
| 		if !equalAny(f1, f2, sprop.Prop[i]) { | ||||
| @@ -137,7 +146,11 @@ func equalStruct(v1, v2 reflect.Value) bool { | ||||
|  | ||||
| 	u1 := uf.Bytes() | ||||
| 	u2 := v2.FieldByName("XXX_unrecognized").Bytes() | ||||
| 	return bytes.Equal(u1, u2) | ||||
| 	if !bytes.Equal(u1, u2) { | ||||
| 		return false | ||||
| 	} | ||||
|  | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| // v1 and v2 are known to have the same type. | ||||
| @@ -248,15 +261,6 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool { | ||||
|  | ||||
| 		m1, m2 := e1.value, e2.value | ||||
|  | ||||
| 		if m1 == nil && m2 == nil { | ||||
| 			// Both have only encoded form. | ||||
| 			if bytes.Equal(e1.enc, e2.enc) { | ||||
| 				continue | ||||
| 			} | ||||
| 			// The bytes are different, but the extensions might still be | ||||
| 			// equal. We need to decode them to compare. | ||||
| 		} | ||||
|  | ||||
| 		if m1 != nil && m2 != nil { | ||||
| 			// Both are unencoded. | ||||
| 			if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { | ||||
| @@ -272,12 +276,8 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool { | ||||
| 			desc = m[extNum] | ||||
| 		} | ||||
| 		if desc == nil { | ||||
| 			// If both have only encoded form and the bytes are the same, | ||||
| 			// it is handled above. We get here when the bytes are different. | ||||
| 			// We don't know how to decode it, so just compare them as byte | ||||
| 			// slices. | ||||
| 			log.Printf("proto: don't know how to compare extension %d of %v", extNum, base) | ||||
| 			return false | ||||
| 			continue | ||||
| 		} | ||||
| 		var err error | ||||
| 		if m1 == nil { | ||||
|   | ||||
							
								
								
									
										22
									
								
								vendor/github.com/gogo/protobuf/proto/equal_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								vendor/github.com/gogo/protobuf/proto/equal_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -36,7 +36,7 @@ import ( | ||||
|  | ||||
| 	. "github.com/gogo/protobuf/proto" | ||||
| 	proto3pb "github.com/gogo/protobuf/proto/proto3_proto" | ||||
| 	pb "github.com/gogo/protobuf/proto/test_proto" | ||||
| 	pb "github.com/gogo/protobuf/proto/testdata" | ||||
| ) | ||||
|  | ||||
| // Four identical base messages. | ||||
| @@ -45,9 +45,6 @@ var messageWithoutExtension = &pb.MyMessage{Count: Int32(7)} | ||||
| var messageWithExtension1a = &pb.MyMessage{Count: Int32(7)} | ||||
| var messageWithExtension1b = &pb.MyMessage{Count: Int32(7)} | ||||
| var messageWithExtension2 = &pb.MyMessage{Count: Int32(7)} | ||||
| var messageWithExtension3a = &pb.MyMessage{Count: Int32(7)} | ||||
| var messageWithExtension3b = &pb.MyMessage{Count: Int32(7)} | ||||
| var messageWithExtension3c = &pb.MyMessage{Count: Int32(7)} | ||||
|  | ||||
| // Two messages with non-message extensions. | ||||
| var messageWithInt32Extension1 = &pb.MyMessage{Count: Int32(8)} | ||||
| @@ -86,20 +83,6 @@ func init() { | ||||
| 	if err := SetExtension(messageWithInt32Extension1, pb.E_Ext_Number, Int32(24)); err != nil { | ||||
| 		panic("SetExtension on Int32-2 failed: " + err.Error()) | ||||
| 	} | ||||
|  | ||||
| 	// messageWithExtension3{a,b,c} has unregistered extension. | ||||
| 	if RegisteredExtensions(messageWithExtension3a)[200] != nil { | ||||
| 		panic("expect extension 200 unregistered") | ||||
| 	} | ||||
| 	bytes := []byte{ | ||||
| 		0xc0, 0x0c, 0x01, // id=200, wiretype=0 (varint), data=1 | ||||
| 	} | ||||
| 	bytes2 := []byte{ | ||||
| 		0xc0, 0x0c, 0x02, // id=200, wiretype=0 (varint), data=2 | ||||
| 	} | ||||
| 	SetRawExtension(messageWithExtension3a, 200, bytes) | ||||
| 	SetRawExtension(messageWithExtension3b, 200, bytes) | ||||
| 	SetRawExtension(messageWithExtension3c, 200, bytes2) | ||||
| } | ||||
|  | ||||
| var EqualTests = []struct { | ||||
| @@ -159,9 +142,6 @@ var EqualTests = []struct { | ||||
| 	{"int32 extension vs. itself", messageWithInt32Extension1, messageWithInt32Extension1, true}, | ||||
| 	{"int32 extension vs. a different int32", messageWithInt32Extension1, messageWithInt32Extension2, false}, | ||||
|  | ||||
| 	{"unregistered extension same", messageWithExtension3a, messageWithExtension3b, true}, | ||||
| 	{"unregistered extension different", messageWithExtension3a, messageWithExtension3c, false}, | ||||
|  | ||||
| 	{ | ||||
| 		"message with group", | ||||
| 		&pb.MyMessage{ | ||||
|   | ||||
							
								
								
									
										290
									
								
								vendor/github.com/gogo/protobuf/proto/extensions.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										290
									
								
								vendor/github.com/gogo/protobuf/proto/extensions.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -38,7 +38,6 @@ package proto | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"reflect" | ||||
| 	"strconv" | ||||
| 	"sync" | ||||
| @@ -70,6 +69,12 @@ type extendableProtoV1 interface { | ||||
| 	ExtensionMap() map[int32]Extension | ||||
| } | ||||
|  | ||||
| type extensionsBytes interface { | ||||
| 	Message | ||||
| 	ExtensionRangeArray() []ExtensionRange | ||||
| 	GetExtensions() *[]byte | ||||
| } | ||||
|  | ||||
| // extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto. | ||||
| type extensionAdapter struct { | ||||
| 	extendableProtoV1 | ||||
| @@ -92,31 +97,14 @@ func (n notLocker) Unlock() {} | ||||
| // extendable returns the extendableProto interface for the given generated proto message. | ||||
| // If the proto message has the old extension format, it returns a wrapper that implements | ||||
| // the extendableProto interface. | ||||
| func extendable(p interface{}) (extendableProto, error) { | ||||
| 	switch p := p.(type) { | ||||
| 	case extendableProto: | ||||
| 		if isNilPtr(p) { | ||||
| 			return nil, fmt.Errorf("proto: nil %T is not extendable", p) | ||||
| 		} | ||||
| 		return p, nil | ||||
| 	case extendableProtoV1: | ||||
| 		if isNilPtr(p) { | ||||
| 			return nil, fmt.Errorf("proto: nil %T is not extendable", p) | ||||
| 		} | ||||
| 		return extensionAdapter{p}, nil | ||||
| 	case extensionsBytes: | ||||
| 		return slowExtensionAdapter{p}, nil | ||||
| func extendable(p interface{}) (extendableProto, bool) { | ||||
| 	if ep, ok := p.(extendableProto); ok { | ||||
| 		return ep, ok | ||||
| 	} | ||||
| 	// Don't allocate a specific error containing %T: | ||||
| 	// this is the hot path for Clone and MarshalText. | ||||
| 	return nil, errNotExtendable | ||||
| } | ||||
|  | ||||
| var errNotExtendable = errors.New("proto: not an extendable proto.Message") | ||||
|  | ||||
| func isNilPtr(x interface{}) bool { | ||||
| 	v := reflect.ValueOf(x) | ||||
| 	return v.Kind() == reflect.Ptr && v.IsNil() | ||||
| 	if ep, ok := p.(extendableProtoV1); ok { | ||||
| 		return extensionAdapter{ep}, ok | ||||
| 	} | ||||
| 	return nil, false | ||||
| } | ||||
|  | ||||
| // XXX_InternalExtensions is an internal representation of proto extensions. | ||||
| @@ -161,6 +149,16 @@ func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Loc | ||||
| 	return e.p.extensionMap, &e.p.mu | ||||
| } | ||||
|  | ||||
| type extensionRange interface { | ||||
| 	Message | ||||
| 	ExtensionRangeArray() []ExtensionRange | ||||
| } | ||||
|  | ||||
| var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem() | ||||
| var extendableProtoV1Type = reflect.TypeOf((*extendableProtoV1)(nil)).Elem() | ||||
| var extendableBytesType = reflect.TypeOf((*extensionsBytes)(nil)).Elem() | ||||
| var extensionRangeType = reflect.TypeOf((*extensionRange)(nil)).Elem() | ||||
|  | ||||
| // ExtensionDesc represents an extension specification. | ||||
| // Used in generated code from the protocol compiler. | ||||
| type ExtensionDesc struct { | ||||
| @@ -200,8 +198,8 @@ func SetRawExtension(base Message, id int32, b []byte) { | ||||
| 		*ext = append(*ext, b...) | ||||
| 		return | ||||
| 	} | ||||
| 	epb, err := extendable(base) | ||||
| 	if err != nil { | ||||
| 	epb, ok := extendable(base) | ||||
| 	if !ok { | ||||
| 		return | ||||
| 	} | ||||
| 	extmap := epb.extensionsWrite() | ||||
| @@ -209,7 +207,7 @@ func SetRawExtension(base Message, id int32, b []byte) { | ||||
| } | ||||
|  | ||||
| // isExtensionField returns true iff the given field number is in an extension range. | ||||
| func isExtensionField(pb extendableProto, field int32) bool { | ||||
| func isExtensionField(pb extensionRange, field int32) bool { | ||||
| 	for _, er := range pb.ExtensionRangeArray() { | ||||
| 		if er.Start <= field && field <= er.End { | ||||
| 			return true | ||||
| @@ -225,11 +223,8 @@ func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { | ||||
| 	if ea, ok := pbi.(extensionAdapter); ok { | ||||
| 		pbi = ea.extendableProtoV1 | ||||
| 	} | ||||
| 	if ea, ok := pbi.(slowExtensionAdapter); ok { | ||||
| 		pbi = ea.extensionsBytes | ||||
| 	} | ||||
| 	if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b { | ||||
| 		return fmt.Errorf("proto: bad extended type; %v does not extend %v", b, a) | ||||
| 		return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String()) | ||||
| 	} | ||||
| 	// Check the range. | ||||
| 	if !isExtensionField(pb, extension.Field) { | ||||
| @@ -274,6 +269,80 @@ func extensionProperties(ed *ExtensionDesc) *Properties { | ||||
| 	return prop | ||||
| } | ||||
|  | ||||
| // encode encodes any unmarshaled (unencoded) extensions in e. | ||||
| func encodeExtensions(e *XXX_InternalExtensions) error { | ||||
| 	m, mu := e.extensionsRead() | ||||
| 	if m == nil { | ||||
| 		return nil // fast path | ||||
| 	} | ||||
| 	mu.Lock() | ||||
| 	defer mu.Unlock() | ||||
| 	return encodeExtensionsMap(m) | ||||
| } | ||||
|  | ||||
| // encode encodes any unmarshaled (unencoded) extensions in e. | ||||
| func encodeExtensionsMap(m map[int32]Extension) error { | ||||
| 	for k, e := range m { | ||||
| 		if e.value == nil || e.desc == nil { | ||||
| 			// Extension is only in its encoded form. | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		// We don't skip extensions that have an encoded form set, | ||||
| 		// because the extension value may have been mutated after | ||||
| 		// the last time this function was called. | ||||
|  | ||||
| 		et := reflect.TypeOf(e.desc.ExtensionType) | ||||
| 		props := extensionProperties(e.desc) | ||||
|  | ||||
| 		p := NewBuffer(nil) | ||||
| 		// If e.value has type T, the encoder expects a *struct{ X T }. | ||||
| 		// Pass a *T with a zero field and hope it all works out. | ||||
| 		x := reflect.New(et) | ||||
| 		x.Elem().Set(reflect.ValueOf(e.value)) | ||||
| 		if err := props.enc(p, props, toStructPointer(x)); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		e.enc = p.buf | ||||
| 		m[k] = e | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func extensionsSize(e *XXX_InternalExtensions) (n int) { | ||||
| 	m, mu := e.extensionsRead() | ||||
| 	if m == nil { | ||||
| 		return 0 | ||||
| 	} | ||||
| 	mu.Lock() | ||||
| 	defer mu.Unlock() | ||||
| 	return extensionsMapSize(m) | ||||
| } | ||||
|  | ||||
| func extensionsMapSize(m map[int32]Extension) (n int) { | ||||
| 	for _, e := range m { | ||||
| 		if e.value == nil || e.desc == nil { | ||||
| 			// Extension is only in its encoded form. | ||||
| 			n += len(e.enc) | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		// We don't skip extensions that have an encoded form set, | ||||
| 		// because the extension value may have been mutated after | ||||
| 		// the last time this function was called. | ||||
|  | ||||
| 		et := reflect.TypeOf(e.desc.ExtensionType) | ||||
| 		props := extensionProperties(e.desc) | ||||
|  | ||||
| 		// If e.value has type T, the encoder expects a *struct{ X T }. | ||||
| 		// Pass a *T with a zero field and hope it all works out. | ||||
| 		x := reflect.New(et) | ||||
| 		x.Elem().Set(reflect.ValueOf(e.value)) | ||||
| 		n += props.size(props, toStructPointer(x)) | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // HasExtension returns whether the given extension is present in pb. | ||||
| func HasExtension(pb Message, extension *ExtensionDesc) bool { | ||||
| 	if epb, doki := pb.(extensionsBytes); doki { | ||||
| @@ -297,8 +366,8 @@ func HasExtension(pb Message, extension *ExtensionDesc) bool { | ||||
| 		return false | ||||
| 	} | ||||
| 	// TODO: Check types, field numbers, etc.? | ||||
| 	epb, err := extendable(pb) | ||||
| 	if err != nil { | ||||
| 	epb, ok := extendable(pb) | ||||
| 	if !ok { | ||||
| 		return false | ||||
| 	} | ||||
| 	extmap, mu := epb.extensionsRead() | ||||
| @@ -306,26 +375,46 @@ func HasExtension(pb Message, extension *ExtensionDesc) bool { | ||||
| 		return false | ||||
| 	} | ||||
| 	mu.Lock() | ||||
| 	_, ok := extmap[extension.Field] | ||||
| 	_, ok = extmap[extension.Field] | ||||
| 	mu.Unlock() | ||||
| 	return ok | ||||
| } | ||||
|  | ||||
| func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int { | ||||
| 	ext := pb.GetExtensions() | ||||
| 	for offset < len(*ext) { | ||||
| 		tag, n1 := DecodeVarint((*ext)[offset:]) | ||||
| 		fieldNum := int32(tag >> 3) | ||||
| 		wireType := int(tag & 0x7) | ||||
| 		n2, err := size((*ext)[offset+n1:], wireType) | ||||
| 		if err != nil { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 		newOffset := offset + n1 + n2 | ||||
| 		if fieldNum == theFieldNum { | ||||
| 			*ext = append((*ext)[:offset], (*ext)[newOffset:]...) | ||||
| 			return offset | ||||
| 		} | ||||
| 		offset = newOffset | ||||
| 	} | ||||
| 	return -1 | ||||
| } | ||||
|  | ||||
| // ClearExtension removes the given extension from pb. | ||||
| func ClearExtension(pb Message, extension *ExtensionDesc) { | ||||
| 	clearExtension(pb, extension.Field) | ||||
| } | ||||
|  | ||||
| func clearExtension(pb Message, fieldNum int32) { | ||||
| 	if epb, ok := pb.(extensionsBytes); ok { | ||||
| 	if epb, doki := pb.(extensionsBytes); doki { | ||||
| 		offset := 0 | ||||
| 		for offset != -1 { | ||||
| 			offset = deleteExtension(epb, fieldNum, offset) | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
| 	epb, err := extendable(pb) | ||||
| 	if err != nil { | ||||
| 	epb, ok := extendable(pb) | ||||
| 	if !ok { | ||||
| 		return | ||||
| 	} | ||||
| 	// TODO: Check types, field numbers, etc.? | ||||
| @@ -333,31 +422,37 @@ func clearExtension(pb Message, fieldNum int32) { | ||||
| 	delete(extmap, fieldNum) | ||||
| } | ||||
|  | ||||
| // GetExtension retrieves a proto2 extended field from pb. | ||||
| // | ||||
| // If the descriptor is type complete (i.e., ExtensionDesc.ExtensionType is non-nil), | ||||
| // then GetExtension parses the encoded field and returns a Go value of the specified type. | ||||
| // If the field is not present, then the default value is returned (if one is specified), | ||||
| // otherwise ErrMissingExtension is reported. | ||||
| // | ||||
| // If the descriptor is not type complete (i.e., ExtensionDesc.ExtensionType is nil), | ||||
| // then GetExtension returns the raw encoded bytes of the field extension. | ||||
| // GetExtension parses and returns the given extension of pb. | ||||
| // If the extension is not present and has no default value it returns ErrMissingExtension. | ||||
| func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { | ||||
| 	if epb, doki := pb.(extensionsBytes); doki { | ||||
| 		ext := epb.GetExtensions() | ||||
| 		return decodeExtensionFromBytes(extension, *ext) | ||||
| 	} | ||||
|  | ||||
| 	epb, err := extendable(pb) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	if extension.ExtendedType != nil { | ||||
| 		// can only check type if this is a complete descriptor | ||||
| 		if cerr := checkExtensionTypes(epb, extension); cerr != nil { | ||||
| 			return nil, cerr | ||||
| 		o := 0 | ||||
| 		for o < len(*ext) { | ||||
| 			tag, n := DecodeVarint((*ext)[o:]) | ||||
| 			fieldNum := int32(tag >> 3) | ||||
| 			wireType := int(tag & 0x7) | ||||
| 			l, err := size((*ext)[o+n:], wireType) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			if int32(fieldNum) == extension.Field { | ||||
| 				v, err := decodeExtension((*ext)[o:o+n+l], extension) | ||||
| 				if err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				return v, nil | ||||
| 			} | ||||
| 			o += n + l | ||||
| 		} | ||||
| 		return defaultExtensionValue(extension) | ||||
| 	} | ||||
| 	epb, ok := extendable(pb) | ||||
| 	if !ok { | ||||
| 		return nil, errors.New("proto: not an extendable proto") | ||||
| 	} | ||||
| 	if err := checkExtensionTypes(epb, extension); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	emap, mu := epb.extensionsRead() | ||||
| @@ -384,11 +479,6 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { | ||||
| 		return e.value, nil | ||||
| 	} | ||||
|  | ||||
| 	if extension.ExtensionType == nil { | ||||
| 		// incomplete descriptor | ||||
| 		return e.enc, nil | ||||
| 	} | ||||
|  | ||||
| 	v, err := decodeExtension(e.enc, extension) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| @@ -406,11 +496,6 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { | ||||
| // defaultExtensionValue returns the default value for extension. | ||||
| // If no default for an extension is defined ErrMissingExtension is returned. | ||||
| func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { | ||||
| 	if extension.ExtensionType == nil { | ||||
| 		// incomplete descriptor, so no default | ||||
| 		return nil, ErrMissingExtension | ||||
| 	} | ||||
|  | ||||
| 	t := reflect.TypeOf(extension.ExtensionType) | ||||
| 	props := extensionProperties(extension) | ||||
|  | ||||
| @@ -445,28 +530,31 @@ func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { | ||||
|  | ||||
| // decodeExtension decodes an extension encoded in b. | ||||
| func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { | ||||
| 	o := NewBuffer(b) | ||||
|  | ||||
| 	t := reflect.TypeOf(extension.ExtensionType) | ||||
| 	unmarshal := typeUnmarshaler(t, extension.Tag) | ||||
|  | ||||
| 	props := extensionProperties(extension) | ||||
|  | ||||
| 	// t is a pointer to a struct, pointer to basic type or a slice. | ||||
| 	// Allocate space to store the pointer/slice. | ||||
| 	// Allocate a "field" to store the pointer/slice itself; the | ||||
| 	// pointer/slice will be stored here. We pass | ||||
| 	// the address of this field to props.dec. | ||||
| 	// This passes a zero field and a *t and lets props.dec | ||||
| 	// interpret it as a *struct{ x t }. | ||||
| 	value := reflect.New(t).Elem() | ||||
|  | ||||
| 	var err error | ||||
| 	for { | ||||
| 		x, n := decodeVarint(b) | ||||
| 		if n == 0 { | ||||
| 			return nil, io.ErrUnexpectedEOF | ||||
| 		} | ||||
| 		b = b[n:] | ||||
| 		wire := int(x) & 7 | ||||
|  | ||||
| 		b, err = unmarshal(b, valToPointer(value.Addr()), wire) | ||||
| 		if err != nil { | ||||
| 		// Discard wire type and field number varint. It isn't needed. | ||||
| 		if _, err := o.DecodeVarint(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
|  | ||||
| 		if len(b) == 0 { | ||||
| 		if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
|  | ||||
| 		if o.index >= len(o.buf) { | ||||
| 			break | ||||
| 		} | ||||
| 	} | ||||
| @@ -476,13 +564,9 @@ func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { | ||||
| // GetExtensions returns a slice of the extensions present in pb that are also listed in es. | ||||
| // The returned slice has the same length as es; missing extensions will appear as nil elements. | ||||
| func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { | ||||
| 	epb, err := extendable(pb) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	extensions = make([]interface{}, len(es)) | ||||
| 	for i, e := range es { | ||||
| 		extensions[i], err = GetExtension(epb, e) | ||||
| 		extensions[i], err = GetExtension(pb, e) | ||||
| 		if err == ErrMissingExtension { | ||||
| 			err = nil | ||||
| 		} | ||||
| @@ -497,9 +581,9 @@ func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, e | ||||
| // For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing | ||||
| // just the Field field, which defines the extension's field number. | ||||
| func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { | ||||
| 	epb, err := extendable(pb) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	epb, ok := extendable(pb) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("proto: %T is not an extendable proto.Message", pb) | ||||
| 	} | ||||
| 	registeredExtensions := RegisteredExtensions(pb) | ||||
|  | ||||
| @@ -526,26 +610,30 @@ func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { | ||||
|  | ||||
| // SetExtension sets the specified extension of pb to the specified value. | ||||
| func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error { | ||||
| 	if epb, ok := pb.(extensionsBytes); ok { | ||||
| 	if epb, doki := pb.(extensionsBytes); doki { | ||||
| 		ClearExtension(pb, extension) | ||||
| 		newb, err := encodeExtension(extension, value) | ||||
| 		if err != nil { | ||||
| 		ext := epb.GetExtensions() | ||||
| 		et := reflect.TypeOf(extension.ExtensionType) | ||||
| 		props := extensionProperties(extension) | ||||
| 		p := NewBuffer(nil) | ||||
| 		x := reflect.New(et) | ||||
| 		x.Elem().Set(reflect.ValueOf(value)) | ||||
| 		if err := props.enc(p, props, toStructPointer(x)); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		bb := epb.GetExtensions() | ||||
| 		*bb = append(*bb, newb...) | ||||
| 		*ext = append(*ext, p.buf...) | ||||
| 		return nil | ||||
| 	} | ||||
| 	epb, err := extendable(pb) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	epb, ok := extendable(pb) | ||||
| 	if !ok { | ||||
| 		return errors.New("proto: not an extendable proto") | ||||
| 	} | ||||
| 	if err := checkExtensionTypes(epb, extension); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	typ := reflect.TypeOf(extension.ExtensionType) | ||||
| 	if typ != reflect.TypeOf(value) { | ||||
| 		return fmt.Errorf("proto: bad extension value type. got: %T, want: %T", value, extension.ExtensionType) | ||||
| 		return errors.New("proto: bad extension value type") | ||||
| 	} | ||||
| 	// nil extension values need to be caught early, because the | ||||
| 	// encoder can't distinguish an ErrNil due to a nil extension | ||||
| @@ -568,8 +656,8 @@ func ClearAllExtensions(pb Message) { | ||||
| 		*ext = []byte{} | ||||
| 		return | ||||
| 	} | ||||
| 	epb, err := extendable(pb) | ||||
| 	if err != nil { | ||||
| 	epb, ok := extendable(pb) | ||||
| 	if !ok { | ||||
| 		return | ||||
| 	} | ||||
| 	m := epb.extensionsWrite() | ||||
|   | ||||
							
								
								
									
										179
									
								
								vendor/github.com/gogo/protobuf/proto/extensions_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										179
									
								
								vendor/github.com/gogo/protobuf/proto/extensions_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -32,36 +32,12 @@ import ( | ||||
| 	"bytes" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"reflect" | ||||
| 	"sort" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| ) | ||||
|  | ||||
| type extensionsBytes interface { | ||||
| 	Message | ||||
| 	ExtensionRangeArray() []ExtensionRange | ||||
| 	GetExtensions() *[]byte | ||||
| } | ||||
|  | ||||
| type slowExtensionAdapter struct { | ||||
| 	extensionsBytes | ||||
| } | ||||
|  | ||||
| func (s slowExtensionAdapter) extensionsWrite() map[int32]Extension { | ||||
| 	panic("Please report a bug to github.com/gogo/protobuf if you see this message: Writing extensions is not supported for extensions stored in a byte slice field.") | ||||
| } | ||||
|  | ||||
| func (s slowExtensionAdapter) extensionsRead() (map[int32]Extension, sync.Locker) { | ||||
| 	b := s.GetExtensions() | ||||
| 	m, err := BytesToExtensionsMap(*b) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return m, notLocker{} | ||||
| } | ||||
|  | ||||
| func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool { | ||||
| 	if reflect.ValueOf(pb).IsNil() { | ||||
| 		return ifnotset | ||||
| @@ -80,28 +56,19 @@ func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool | ||||
| } | ||||
|  | ||||
| func (this *Extension) Equal(that *Extension) bool { | ||||
| 	if err := this.Encode(); err != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	if err := that.Encode(); err != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	return bytes.Equal(this.enc, that.enc) | ||||
| } | ||||
|  | ||||
| func (this *Extension) Compare(that *Extension) int { | ||||
| 	if err := this.Encode(); err != nil { | ||||
| 		return 1 | ||||
| 	} | ||||
| 	if err := that.Encode(); err != nil { | ||||
| 		return -1 | ||||
| 	} | ||||
| 	return bytes.Compare(this.enc, that.enc) | ||||
| } | ||||
|  | ||||
| func SizeOfInternalExtension(m extendableProto) (n int) { | ||||
| 	info := getMarshalInfo(reflect.TypeOf(m)) | ||||
| 	return info.sizeV1Extensions(m.extensionsWrite()) | ||||
| 	return SizeOfExtensionMap(m.extensionsWrite()) | ||||
| } | ||||
|  | ||||
| func SizeOfExtensionMap(m map[int32]Extension) (n int) { | ||||
| 	return extensionsMapSize(m) | ||||
| } | ||||
|  | ||||
| type sortableMapElem struct { | ||||
| @@ -154,48 +121,29 @@ func EncodeInternalExtension(m extendableProto, data []byte) (n int, err error) | ||||
| 	return EncodeExtensionMap(m.extensionsWrite(), data) | ||||
| } | ||||
|  | ||||
| func EncodeInternalExtensionBackwards(m extendableProto, data []byte) (n int, err error) { | ||||
| 	return EncodeExtensionMapBackwards(m.extensionsWrite(), data) | ||||
| } | ||||
|  | ||||
| func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) { | ||||
| 	o := 0 | ||||
| 	for _, e := range m { | ||||
| 		if err := e.Encode(); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 		n := copy(data[o:], e.enc) | ||||
| 		if n != len(e.enc) { | ||||
| 			return 0, io.ErrShortBuffer | ||||
| 		} | ||||
| 		o += n | ||||
| 	if err := encodeExtensionsMap(m); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return o, nil | ||||
| } | ||||
|  | ||||
| func EncodeExtensionMapBackwards(m map[int32]Extension, data []byte) (n int, err error) { | ||||
| 	o := 0 | ||||
| 	end := len(data) | ||||
| 	for _, e := range m { | ||||
| 		if err := e.Encode(); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 		n := copy(data[end-len(e.enc):], e.enc) | ||||
| 		if n != len(e.enc) { | ||||
| 			return 0, io.ErrShortBuffer | ||||
| 		} | ||||
| 		end -= n | ||||
| 		o += n | ||||
| 	keys := make([]int, 0, len(m)) | ||||
| 	for k := range m { | ||||
| 		keys = append(keys, int(k)) | ||||
| 	} | ||||
| 	return o, nil | ||||
| 	sort.Ints(keys) | ||||
| 	for _, k := range keys { | ||||
| 		n += copy(data[n:], m[int32(k)].enc) | ||||
| 	} | ||||
| 	return n, nil | ||||
| } | ||||
|  | ||||
| func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) { | ||||
| 	e := m[id] | ||||
| 	if err := e.Encode(); err != nil { | ||||
| 	if m[id].value == nil || m[id].desc == nil { | ||||
| 		return m[id].enc, nil | ||||
| 	} | ||||
| 	if err := encodeExtensionsMap(m); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return e.enc, nil | ||||
| 	return m[id].enc, nil | ||||
| } | ||||
|  | ||||
| func size(buf []byte, wire int) (int, error) { | ||||
| @@ -270,58 +218,35 @@ func AppendExtension(e Message, tag int32, buf []byte) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func encodeExtension(extension *ExtensionDesc, value interface{}) ([]byte, error) { | ||||
| 	u := getMarshalInfo(reflect.TypeOf(extension.ExtendedType)) | ||||
| 	ei := u.getExtElemInfo(extension) | ||||
| 	v := value | ||||
| 	p := toAddrPointer(&v, ei.isptr) | ||||
| 	siz := ei.sizer(p, SizeVarint(ei.wiretag)) | ||||
| 	buf := make([]byte, 0, siz) | ||||
| 	return ei.marshaler(buf, p, ei.wiretag, false) | ||||
| } | ||||
|  | ||||
| func decodeExtensionFromBytes(extension *ExtensionDesc, buf []byte) (interface{}, error) { | ||||
| 	o := 0 | ||||
| 	for o < len(buf) { | ||||
| 		tag, n := DecodeVarint((buf)[o:]) | ||||
| 		fieldNum := int32(tag >> 3) | ||||
| 		wireType := int(tag & 0x7) | ||||
| 		if o+n > len(buf) { | ||||
| 			return nil, fmt.Errorf("unable to decode extension") | ||||
| 		} | ||||
| 		l, err := size((buf)[o+n:], wireType) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		if int32(fieldNum) == extension.Field { | ||||
| 			if o+n+l > len(buf) { | ||||
| 				return nil, fmt.Errorf("unable to decode extension") | ||||
| 			} | ||||
| 			v, err := decodeExtension((buf)[o:o+n+l], extension) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			return v, nil | ||||
| 		} | ||||
| 		o += n + l | ||||
| func encodeExtension(e *Extension) error { | ||||
| 	if e.value == nil || e.desc == nil { | ||||
| 		// Extension is only in its encoded form. | ||||
| 		return nil | ||||
| 	} | ||||
| 	return defaultExtensionValue(extension) | ||||
| } | ||||
| 	// We don't skip extensions that have an encoded form set, | ||||
| 	// because the extension value may have been mutated after | ||||
| 	// the last time this function was called. | ||||
|  | ||||
| func (this *Extension) Encode() error { | ||||
| 	if this.enc == nil { | ||||
| 		var err error | ||||
| 		this.enc, err = encodeExtension(this.desc, this.value) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	et := reflect.TypeOf(e.desc.ExtensionType) | ||||
| 	props := extensionProperties(e.desc) | ||||
|  | ||||
| 	p := NewBuffer(nil) | ||||
| 	// If e.value has type T, the encoder expects a *struct{ X T }. | ||||
| 	// Pass a *T with a zero field and hope it all works out. | ||||
| 	x := reflect.New(et) | ||||
| 	x.Elem().Set(reflect.ValueOf(e.value)) | ||||
| 	if err := props.enc(p, props, toStructPointer(x)); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	e.enc = p.buf | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (this Extension) GoString() string { | ||||
| 	if err := this.Encode(); err != nil { | ||||
| 		return fmt.Sprintf("error encoding extension: %v", err) | ||||
| 	if this.enc == nil { | ||||
| 		if err := encodeExtension(&this); err != nil { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 	} | ||||
| 	return fmt.Sprintf("proto.NewExtension(%#v)", this.enc) | ||||
| } | ||||
| @@ -367,23 +292,3 @@ func GetUnsafeExtensionsMap(extendable Message) map[int32]Extension { | ||||
| 	pb := extendable.(extendableProto) | ||||
| 	return pb.extensionsWrite() | ||||
| } | ||||
|  | ||||
| func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int { | ||||
| 	ext := pb.GetExtensions() | ||||
| 	for offset < len(*ext) { | ||||
| 		tag, n1 := DecodeVarint((*ext)[offset:]) | ||||
| 		fieldNum := int32(tag >> 3) | ||||
| 		wireType := int(tag & 0x7) | ||||
| 		n2, err := size((*ext)[offset+n1:], wireType) | ||||
| 		if err != nil { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 		newOffset := offset + n1 + n2 | ||||
| 		if fieldNum == theFieldNum { | ||||
| 			*ext = append((*ext)[:offset], (*ext)[newOffset:]...) | ||||
| 			return offset | ||||
| 		} | ||||
| 		offset = newOffset | ||||
| 	} | ||||
| 	return -1 | ||||
| } | ||||
|   | ||||
							
								
								
									
										197
									
								
								vendor/github.com/gogo/protobuf/proto/extensions_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										197
									
								
								vendor/github.com/gogo/protobuf/proto/extensions_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -34,14 +34,12 @@ package proto_test | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"reflect" | ||||
| 	"sort" | ||||
| 	"strings" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
| 	pb "github.com/gogo/protobuf/proto/test_proto" | ||||
| 	pb "github.com/gogo/protobuf/proto/testdata" | ||||
| ) | ||||
|  | ||||
| func TestGetExtensionsWithMissingExtensions(t *testing.T) { | ||||
| @@ -65,107 +63,7 @@ func TestGetExtensionsWithMissingExtensions(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestGetExtensionWithEmptyBuffer(t *testing.T) { | ||||
| 	// Make sure that GetExtension returns an error if its | ||||
| 	// undecoded buffer is empty. | ||||
| 	msg := &pb.MyMessage{} | ||||
| 	proto.SetRawExtension(msg, pb.E_Ext_More.Field, []byte{}) | ||||
| 	_, err := proto.GetExtension(msg, pb.E_Ext_More) | ||||
| 	if want := io.ErrUnexpectedEOF; err != want { | ||||
| 		t.Errorf("unexpected error in GetExtension from empty buffer: got %v, want %v", err, want) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestGetExtensionForIncompleteDesc(t *testing.T) { | ||||
| 	msg := &pb.MyMessage{Count: proto.Int32(0)} | ||||
| 	extdesc1 := &proto.ExtensionDesc{ | ||||
| 		ExtendedType:  (*pb.MyMessage)(nil), | ||||
| 		ExtensionType: (*bool)(nil), | ||||
| 		Field:         123456789, | ||||
| 		Name:          "a.b", | ||||
| 		Tag:           "varint,123456789,opt", | ||||
| 	} | ||||
| 	ext1 := proto.Bool(true) | ||||
| 	if err := proto.SetExtension(msg, extdesc1, ext1); err != nil { | ||||
| 		t.Fatalf("Could not set ext1: %s", err) | ||||
| 	} | ||||
| 	extdesc2 := &proto.ExtensionDesc{ | ||||
| 		ExtendedType:  (*pb.MyMessage)(nil), | ||||
| 		ExtensionType: ([]byte)(nil), | ||||
| 		Field:         123456790, | ||||
| 		Name:          "a.c", | ||||
| 		Tag:           "bytes,123456790,opt", | ||||
| 	} | ||||
| 	ext2 := []byte{0, 1, 2, 3, 4, 5, 6, 7} | ||||
| 	if err := proto.SetExtension(msg, extdesc2, ext2); err != nil { | ||||
| 		t.Fatalf("Could not set ext2: %s", err) | ||||
| 	} | ||||
| 	extdesc3 := &proto.ExtensionDesc{ | ||||
| 		ExtendedType:  (*pb.MyMessage)(nil), | ||||
| 		ExtensionType: (*pb.Ext)(nil), | ||||
| 		Field:         123456791, | ||||
| 		Name:          "a.d", | ||||
| 		Tag:           "bytes,123456791,opt", | ||||
| 	} | ||||
| 	ext3 := &pb.Ext{Data: proto.String("foo")} | ||||
| 	if err := proto.SetExtension(msg, extdesc3, ext3); err != nil { | ||||
| 		t.Fatalf("Could not set ext3: %s", err) | ||||
| 	} | ||||
|  | ||||
| 	b, err := proto.Marshal(msg) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("Could not marshal msg: %v", err) | ||||
| 	} | ||||
| 	if err := proto.Unmarshal(b, msg); err != nil { | ||||
| 		t.Fatalf("Could not unmarshal into msg: %v", err) | ||||
| 	} | ||||
|  | ||||
| 	var expected proto.Buffer | ||||
| 	if err := expected.EncodeVarint(uint64((extdesc1.Field << 3) | proto.WireVarint)); err != nil { | ||||
| 		t.Fatalf("failed to compute expected prefix for ext1: %s", err) | ||||
| 	} | ||||
| 	if err := expected.EncodeVarint(1 /* bool true */); err != nil { | ||||
| 		t.Fatalf("failed to compute expected value for ext1: %s", err) | ||||
| 	} | ||||
|  | ||||
| 	if b, err := proto.GetExtension(msg, &proto.ExtensionDesc{Field: extdesc1.Field}); err != nil { | ||||
| 		t.Fatalf("Failed to get raw value for ext1: %s", err) | ||||
| 	} else if !reflect.DeepEqual(b, expected.Bytes()) { | ||||
| 		t.Fatalf("Raw value for ext1: got %v, want %v", b, expected.Bytes()) | ||||
| 	} | ||||
|  | ||||
| 	expected = proto.Buffer{} // reset | ||||
| 	if err := expected.EncodeVarint(uint64((extdesc2.Field << 3) | proto.WireBytes)); err != nil { | ||||
| 		t.Fatalf("failed to compute expected prefix for ext2: %s", err) | ||||
| 	} | ||||
| 	if err := expected.EncodeRawBytes(ext2); err != nil { | ||||
| 		t.Fatalf("failed to compute expected value for ext2: %s", err) | ||||
| 	} | ||||
|  | ||||
| 	if b, err := proto.GetExtension(msg, &proto.ExtensionDesc{Field: extdesc2.Field}); err != nil { | ||||
| 		t.Fatalf("Failed to get raw value for ext2: %s", err) | ||||
| 	} else if !reflect.DeepEqual(b, expected.Bytes()) { | ||||
| 		t.Fatalf("Raw value for ext2: got %v, want %v", b, expected.Bytes()) | ||||
| 	} | ||||
|  | ||||
| 	expected = proto.Buffer{} // reset | ||||
| 	if err := expected.EncodeVarint(uint64((extdesc3.Field << 3) | proto.WireBytes)); err != nil { | ||||
| 		t.Fatalf("failed to compute expected prefix for ext3: %s", err) | ||||
| 	} | ||||
| 	if b, err := proto.Marshal(ext3); err != nil { | ||||
| 		t.Fatalf("failed to compute expected value for ext3: %s", err) | ||||
| 	} else if err := expected.EncodeRawBytes(b); err != nil { | ||||
| 		t.Fatalf("failed to compute expected value for ext3: %s", err) | ||||
| 	} | ||||
|  | ||||
| 	if b, err := proto.GetExtension(msg, &proto.ExtensionDesc{Field: extdesc3.Field}); err != nil { | ||||
| 		t.Fatalf("Failed to get raw value for ext3: %s", err) | ||||
| 	} else if !reflect.DeepEqual(b, expected.Bytes()) { | ||||
| 		t.Fatalf("Raw value for ext3: got %v, want %v", b, expected.Bytes()) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestExtensionDescsWithUnregisteredExtensions(t *testing.T) { | ||||
| func TestExtensionDescsWithMissingExtensions(t *testing.T) { | ||||
| 	msg := &pb.MyMessage{Count: proto.Int32(0)} | ||||
| 	extdesc1 := pb.E_Ext_More | ||||
| 	if descs, err := proto.ExtensionDescs(msg); len(descs) != 0 || err != nil { | ||||
| @@ -301,7 +199,7 @@ func TestGetExtensionDefaults(t *testing.T) { | ||||
| 		{pb.E_DefaultSfixed64, setInt64, int64(51)}, | ||||
| 		{pb.E_DefaultBool, setBool, true}, | ||||
| 		{pb.E_DefaultBool, setBool2, true}, | ||||
| 		{pb.E_DefaultString, setString, "Hello, string,def=foo"}, | ||||
| 		{pb.E_DefaultString, setString, "Hello, string"}, | ||||
| 		{pb.E_DefaultBytes, setBytes, []byte("Hello, bytes")}, | ||||
| 		{pb.E_DefaultEnum, setEnum, pb.DefaultsMessage_ONE}, | ||||
| 	} | ||||
| @@ -388,44 +286,6 @@ func TestGetExtensionDefaults(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestNilMessage(t *testing.T) { | ||||
| 	name := "nil interface" | ||||
| 	if got, err := proto.GetExtension(nil, pb.E_Ext_More); err == nil { | ||||
| 		t.Errorf("%s: got %T %v, expected to fail", name, got, got) | ||||
| 	} else if !strings.Contains(err.Error(), "extendable") { | ||||
| 		t.Errorf("%s: got error %v, expected not-extendable error", name, err) | ||||
| 	} | ||||
|  | ||||
| 	// Regression tests: all functions of the Extension API | ||||
| 	// used to panic when passed (*M)(nil), where M is a concrete message | ||||
| 	// type.  Now they handle this gracefully as a no-op or reported error. | ||||
| 	var nilMsg *pb.MyMessage | ||||
| 	desc := pb.E_Ext_More | ||||
|  | ||||
| 	isNotExtendable := func(err error) bool { | ||||
| 		return strings.Contains(fmt.Sprint(err), "not extendable") | ||||
| 	} | ||||
|  | ||||
| 	if proto.HasExtension(nilMsg, desc) { | ||||
| 		t.Error("HasExtension(nil) = true") | ||||
| 	} | ||||
|  | ||||
| 	if _, err := proto.GetExtensions(nilMsg, []*proto.ExtensionDesc{desc}); !isNotExtendable(err) { | ||||
| 		t.Errorf("GetExtensions(nil) = %q (wrong error)", err) | ||||
| 	} | ||||
|  | ||||
| 	if _, err := proto.ExtensionDescs(nilMsg); !isNotExtendable(err) { | ||||
| 		t.Errorf("ExtensionDescs(nil) = %q (wrong error)", err) | ||||
| 	} | ||||
|  | ||||
| 	if err := proto.SetExtension(nilMsg, desc, nil); !isNotExtendable(err) { | ||||
| 		t.Errorf("SetExtension(nil) = %q (wrong error)", err) | ||||
| 	} | ||||
|  | ||||
| 	proto.ClearExtension(nilMsg, desc) // no-op | ||||
| 	proto.ClearAllExtensions(nilMsg)   // no-op | ||||
| } | ||||
|  | ||||
| func TestExtensionsRoundTrip(t *testing.T) { | ||||
| 	msg := &pb.MyMessage{} | ||||
| 	ext1 := &pb.Ext{ | ||||
| @@ -450,7 +310,7 @@ func TestExtensionsRoundTrip(t *testing.T) { | ||||
| 	} | ||||
| 	x, ok := e.(*pb.Ext) | ||||
| 	if !ok { | ||||
| 		t.Errorf("e has type %T, expected test_proto.Ext", e) | ||||
| 		t.Errorf("e has type %T, expected testdata.Ext", e) | ||||
| 	} else if *x.Data != "there" { | ||||
| 		t.Errorf("SetExtension failed to overwrite, got %+v, not 'there'", x) | ||||
| 	} | ||||
| @@ -478,7 +338,7 @@ func TestNilExtension(t *testing.T) { | ||||
| 	} | ||||
| 	if err := proto.SetExtension(msg, pb.E_Ext_More, (*pb.Ext)(nil)); err == nil { | ||||
| 		t.Error("expected SetExtension to fail due to a nil extension") | ||||
| 	} else if want := fmt.Sprintf("proto: SetExtension called with nil value of type %T", new(pb.Ext)); err.Error() != want { | ||||
| 	} else if want := "proto: SetExtension called with nil value of type *testdata.Ext"; err.Error() != want { | ||||
| 		t.Errorf("expected error %v, got %v", want, err) | ||||
| 	} | ||||
| 	// Note: if the behavior of Marshal is ever changed to ignore nil extensions, update | ||||
| @@ -541,13 +401,8 @@ func TestMarshalUnmarshalRepeatedExtension(t *testing.T) { | ||||
| 		if ext == nil { | ||||
| 			t.Fatalf("[%s] Invalid extension", test.name) | ||||
| 		} | ||||
| 		if len(ext) != len(test.ext) { | ||||
| 			t.Errorf("[%s] Wrong length of ComplexExtension: got: %v want: %v\n", test.name, len(ext), len(test.ext)) | ||||
| 		} | ||||
| 		for i := range test.ext { | ||||
| 			if !proto.Equal(ext[i], test.ext[i]) { | ||||
| 				t.Errorf("[%s] Wrong value for ComplexExtension[%d]: got: %v want: %v\n", test.name, i, ext[i], test.ext[i]) | ||||
| 			} | ||||
| 		if !reflect.DeepEqual(ext, test.ext) { | ||||
| 			t.Errorf("[%s] Wrong value for ComplexExtension: got: %v want: %v\n", test.name, ext, test.ext) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -621,9 +476,8 @@ func TestUnmarshalRepeatingNonRepeatedExtension(t *testing.T) { | ||||
| 		if ext == nil { | ||||
| 			t.Fatalf("[%s] Invalid extension", test.name) | ||||
| 		} | ||||
| 		if !proto.Equal(ext, &want) { | ||||
| 			t.Errorf("[%s] Wrong value for ComplexExtension: got: %v want: %v\n", test.name, ext, &want) | ||||
|  | ||||
| 		if !reflect.DeepEqual(*ext, want) { | ||||
| 			t.Errorf("[%s] Wrong value for ComplexExtension: got: %v want: %v\n", test.name, ext, want) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -654,35 +508,28 @@ func TestClearAllExtensions(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestMarshalRace(t *testing.T) { | ||||
| 	ext := &pb.Ext{} | ||||
| 	// unregistered extension | ||||
| 	desc := &proto.ExtensionDesc{ | ||||
| 		ExtendedType:  (*pb.MyMessage)(nil), | ||||
| 		ExtensionType: (*bool)(nil), | ||||
| 		Field:         101010100, | ||||
| 		Name:          "emptyextension", | ||||
| 		Tag:           "varint,0,opt", | ||||
| 	} | ||||
|  | ||||
| 	m := &pb.MyMessage{Count: proto.Int32(4)} | ||||
| 	if err := proto.SetExtension(m, pb.E_Ext_More, ext); err != nil { | ||||
| 		t.Fatalf("proto.SetExtension(m, desc, true): got error %q, want nil", err) | ||||
| 	if err := proto.SetExtension(m, desc, proto.Bool(true)); err != nil { | ||||
| 		t.Errorf("proto.SetExtension(m, desc, true): got error %q, want nil", err) | ||||
| 	} | ||||
|  | ||||
| 	b, err := proto.Marshal(m) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("Could not marshal message: %v", err) | ||||
| 	} | ||||
| 	if err := proto.Unmarshal(b, m); err != nil { | ||||
| 		t.Fatalf("Could not unmarshal message: %v", err) | ||||
| 	} | ||||
| 	// after Unmarshal, the extension is in undecoded form. | ||||
| 	// GetExtension will decode it lazily. Make sure this does | ||||
| 	// not race against Marshal. | ||||
|  | ||||
| 	errChan := make(chan error, 6) | ||||
| 	errChan := make(chan error, 3) | ||||
| 	for n := 3; n > 0; n-- { | ||||
| 		go func() { | ||||
| 			_, err := proto.Marshal(m) | ||||
| 			errChan <- err | ||||
| 		}() | ||||
| 		go func() { | ||||
| 			_, err := proto.GetExtension(m, pb.E_Ext_More) | ||||
| 			errChan <- err | ||||
| 		}() | ||||
| 	} | ||||
| 	for i := 0; i < 6; i++ { | ||||
| 	for i := 0; i < 3; i++ { | ||||
| 		err := <-errChan | ||||
| 		if err != nil { | ||||
| 			t.Fatal(err) | ||||
|   | ||||
							
								
								
									
										187
									
								
								vendor/github.com/gogo/protobuf/proto/lib.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										187
									
								
								vendor/github.com/gogo/protobuf/proto/lib.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -73,6 +73,7 @@ for a protocol buffer variable v: | ||||
| When the .proto file specifies `syntax="proto3"`, there are some differences: | ||||
|  | ||||
|   - Non-repeated fields of non-message type are values instead of pointers. | ||||
|   - Getters are only generated for message and oneof fields. | ||||
|   - Enum types do not get an Enum method. | ||||
|  | ||||
| The simplest way to describe this is to see an example. | ||||
| @@ -273,67 +274,6 @@ import ( | ||||
| 	"sync" | ||||
| ) | ||||
|  | ||||
| // RequiredNotSetError is an error type returned by either Marshal or Unmarshal. | ||||
| // Marshal reports this when a required field is not initialized. | ||||
| // Unmarshal reports this when a required field is missing from the wire data. | ||||
| type RequiredNotSetError struct{ field string } | ||||
|  | ||||
| func (e *RequiredNotSetError) Error() string { | ||||
| 	if e.field == "" { | ||||
| 		return fmt.Sprintf("proto: required field not set") | ||||
| 	} | ||||
| 	return fmt.Sprintf("proto: required field %q not set", e.field) | ||||
| } | ||||
| func (e *RequiredNotSetError) RequiredNotSet() bool { | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| type invalidUTF8Error struct{ field string } | ||||
|  | ||||
| func (e *invalidUTF8Error) Error() string { | ||||
| 	if e.field == "" { | ||||
| 		return "proto: invalid UTF-8 detected" | ||||
| 	} | ||||
| 	return fmt.Sprintf("proto: field %q contains invalid UTF-8", e.field) | ||||
| } | ||||
| func (e *invalidUTF8Error) InvalidUTF8() bool { | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| // errInvalidUTF8 is a sentinel error to identify fields with invalid UTF-8. | ||||
| // This error should not be exposed to the external API as such errors should | ||||
| // be recreated with the field information. | ||||
| var errInvalidUTF8 = &invalidUTF8Error{} | ||||
|  | ||||
| // isNonFatal reports whether the error is either a RequiredNotSet error | ||||
| // or a InvalidUTF8 error. | ||||
| func isNonFatal(err error) bool { | ||||
| 	if re, ok := err.(interface{ RequiredNotSet() bool }); ok && re.RequiredNotSet() { | ||||
| 		return true | ||||
| 	} | ||||
| 	if re, ok := err.(interface{ InvalidUTF8() bool }); ok && re.InvalidUTF8() { | ||||
| 		return true | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| type nonFatal struct{ E error } | ||||
|  | ||||
| // Merge merges err into nf and reports whether it was successful. | ||||
| // Otherwise it returns false for any fatal non-nil errors. | ||||
| func (nf *nonFatal) Merge(err error) (ok bool) { | ||||
| 	if err == nil { | ||||
| 		return true // not an error | ||||
| 	} | ||||
| 	if !isNonFatal(err) { | ||||
| 		return false // fatal error | ||||
| 	} | ||||
| 	if nf.E == nil { | ||||
| 		nf.E = err // store first instance of non-fatal error | ||||
| 	} | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| // Message is implemented by generated protocol buffer messages. | ||||
| type Message interface { | ||||
| 	Reset() | ||||
| @@ -341,6 +281,26 @@ type Message interface { | ||||
| 	ProtoMessage() | ||||
| } | ||||
|  | ||||
| // Stats records allocation details about the protocol buffer encoders | ||||
| // and decoders.  Useful for tuning the library itself. | ||||
| type Stats struct { | ||||
| 	Emalloc uint64 // mallocs in encode | ||||
| 	Dmalloc uint64 // mallocs in decode | ||||
| 	Encode  uint64 // number of encodes | ||||
| 	Decode  uint64 // number of decodes | ||||
| 	Chit    uint64 // number of cache hits | ||||
| 	Cmiss   uint64 // number of cache misses | ||||
| 	Size    uint64 // number of sizes | ||||
| } | ||||
|  | ||||
| // Set to true to enable stats collection. | ||||
| const collectStats = false | ||||
|  | ||||
| var stats Stats | ||||
|  | ||||
| // GetStats returns a copy of the global Stats structure. | ||||
| func GetStats() Stats { return stats } | ||||
|  | ||||
| // A Buffer is a buffer manager for marshaling and unmarshaling | ||||
| // protocol buffers.  It may be reused between invocations to | ||||
| // reduce memory usage.  It is not necessary to use a Buffer; | ||||
| @@ -350,7 +310,16 @@ type Buffer struct { | ||||
| 	buf   []byte // encode/decode byte stream | ||||
| 	index int    // read point | ||||
|  | ||||
| 	deterministic bool | ||||
| 	// pools of basic types to amortize allocation. | ||||
| 	bools   []bool | ||||
| 	uint32s []uint32 | ||||
| 	uint64s []uint64 | ||||
|  | ||||
| 	// extra pools, only used with pointer_reflect.go | ||||
| 	int32s   []int32 | ||||
| 	int64s   []int64 | ||||
| 	float32s []float32 | ||||
| 	float64s []float64 | ||||
| } | ||||
|  | ||||
| // NewBuffer allocates a new Buffer and initializes its internal data to | ||||
| @@ -375,30 +344,6 @@ func (p *Buffer) SetBuf(s []byte) { | ||||
| // Bytes returns the contents of the Buffer. | ||||
| func (p *Buffer) Bytes() []byte { return p.buf } | ||||
|  | ||||
| // SetDeterministic sets whether to use deterministic serialization. | ||||
| // | ||||
| // Deterministic serialization guarantees that for a given binary, equal | ||||
| // messages will always be serialized to the same bytes. This implies: | ||||
| // | ||||
| //   - Repeated serialization of a message will return the same bytes. | ||||
| //   - Different processes of the same binary (which may be executing on | ||||
| //     different machines) will serialize equal messages to the same bytes. | ||||
| // | ||||
| // Note that the deterministic serialization is NOT canonical across | ||||
| // languages. It is not guaranteed to remain stable over time. It is unstable | ||||
| // across different builds with schema changes due to unknown fields. | ||||
| // Users who need canonical serialization (e.g., persistent storage in a | ||||
| // canonical form, fingerprinting, etc.) should define their own | ||||
| // canonicalization specification and implement their own serializer rather | ||||
| // than relying on this API. | ||||
| // | ||||
| // If deterministic serialization is requested, map entries will be sorted | ||||
| // by keys in lexographical order. This is an implementation detail and | ||||
| // subject to change. | ||||
| func (p *Buffer) SetDeterministic(deterministic bool) { | ||||
| 	p.deterministic = deterministic | ||||
| } | ||||
|  | ||||
| /* | ||||
|  * Helper routines for simplifying the creation of optional fields of basic type. | ||||
|  */ | ||||
| @@ -608,11 +553,9 @@ func SetDefaults(pb Message) { | ||||
| 	setDefaults(reflect.ValueOf(pb), true, false) | ||||
| } | ||||
|  | ||||
| // v is a struct. | ||||
| // v is a pointer to a struct. | ||||
| func setDefaults(v reflect.Value, recur, zeros bool) { | ||||
| 	if v.Kind() == reflect.Ptr { | ||||
| 		v = v.Elem() | ||||
| 	} | ||||
| 	v = v.Elem() | ||||
|  | ||||
| 	defaultMu.RLock() | ||||
| 	dm, ok := defaults[v.Type()] | ||||
| @@ -714,11 +657,8 @@ func setDefaults(v reflect.Value, recur, zeros bool) { | ||||
|  | ||||
| 	for _, ni := range dm.nested { | ||||
| 		f := v.Field(ni) | ||||
| 		// f is *T or T or []*T or []T | ||||
| 		// f is *T or []*T or map[T]*T | ||||
| 		switch f.Kind() { | ||||
| 		case reflect.Struct: | ||||
| 			setDefaults(f, recur, zeros) | ||||
|  | ||||
| 		case reflect.Ptr: | ||||
| 			if f.IsNil() { | ||||
| 				continue | ||||
| @@ -728,7 +668,7 @@ func setDefaults(v reflect.Value, recur, zeros bool) { | ||||
| 		case reflect.Slice: | ||||
| 			for i := 0; i < f.Len(); i++ { | ||||
| 				e := f.Index(i) | ||||
| 				if e.Kind() == reflect.Ptr && e.IsNil() { | ||||
| 				if e.IsNil() { | ||||
| 					continue | ||||
| 				} | ||||
| 				setDefaults(e, recur, zeros) | ||||
| @@ -800,9 +740,6 @@ func buildDefaultMessage(t reflect.Type) (dm defaultMessage) { | ||||
| func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) { | ||||
| 	var canHaveDefault bool | ||||
| 	switch ft.Kind() { | ||||
| 	case reflect.Struct: | ||||
| 		nestedMessage = true // non-nullable | ||||
|  | ||||
| 	case reflect.Ptr: | ||||
| 		if ft.Elem().Kind() == reflect.Struct { | ||||
| 			nestedMessage = true | ||||
| @@ -812,7 +749,7 @@ func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMes | ||||
|  | ||||
| 	case reflect.Slice: | ||||
| 		switch ft.Elem().Kind() { | ||||
| 		case reflect.Ptr, reflect.Struct: | ||||
| 		case reflect.Ptr: | ||||
| 			nestedMessage = true // repeated message | ||||
| 		case reflect.Uint8: | ||||
| 			canHaveDefault = true // bytes field | ||||
| @@ -895,12 +832,22 @@ func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMes | ||||
| 	return sf, false, nil | ||||
| } | ||||
|  | ||||
| // mapKeys returns a sort.Interface to be used for sorting the map keys. | ||||
| // Map fields may have key types of non-float scalars, strings and enums. | ||||
| func mapKeys(vs []reflect.Value) sort.Interface { | ||||
| 	s := mapKeySorter{vs: vs} | ||||
| // The easiest way to sort them in some deterministic order is to use fmt. | ||||
| // If this turns out to be inefficient we can always consider other options, | ||||
| // such as doing a Schwartzian transform. | ||||
|  | ||||
| 	// Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps. | ||||
| func mapKeys(vs []reflect.Value) sort.Interface { | ||||
| 	s := mapKeySorter{ | ||||
| 		vs: vs, | ||||
| 		// default Less function: textual comparison | ||||
| 		less: func(a, b reflect.Value) bool { | ||||
| 			return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface()) | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	// Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps; | ||||
| 	// numeric keys are sorted numerically. | ||||
| 	if len(vs) == 0 { | ||||
| 		return s | ||||
| 	} | ||||
| @@ -909,12 +856,6 @@ func mapKeys(vs []reflect.Value) sort.Interface { | ||||
| 		s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() } | ||||
| 	case reflect.Uint32, reflect.Uint64: | ||||
| 		s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() } | ||||
| 	case reflect.Bool: | ||||
| 		s.less = func(a, b reflect.Value) bool { return !a.Bool() && b.Bool() } // false < true | ||||
| 	case reflect.String: | ||||
| 		s.less = func(a, b reflect.Value) bool { return a.String() < b.String() } | ||||
| 	default: | ||||
| 		panic(fmt.Sprintf("unsupported map key type: %v", vs[0].Kind())) | ||||
| 	} | ||||
|  | ||||
| 	return s | ||||
| @@ -948,26 +889,10 @@ func isProto3Zero(v reflect.Value) bool { | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| const ( | ||||
| 	// ProtoPackageIsVersion3 is referenced from generated protocol buffer files | ||||
| 	// to assert that that code is compatible with this version of the proto package. | ||||
| 	GoGoProtoPackageIsVersion3 = true | ||||
| // ProtoPackageIsVersion2 is referenced from generated protocol buffer files | ||||
| // to assert that that code is compatible with this version of the proto package. | ||||
| const GoGoProtoPackageIsVersion2 = true | ||||
|  | ||||
| 	// ProtoPackageIsVersion2 is referenced from generated protocol buffer files | ||||
| 	// to assert that that code is compatible with this version of the proto package. | ||||
| 	GoGoProtoPackageIsVersion2 = true | ||||
|  | ||||
| 	// ProtoPackageIsVersion1 is referenced from generated protocol buffer files | ||||
| 	// to assert that that code is compatible with this version of the proto package. | ||||
| 	GoGoProtoPackageIsVersion1 = true | ||||
| ) | ||||
|  | ||||
| // InternalMessageInfo is a type used internally by generated .pb.go files. | ||||
| // This type is not intended to be used by non-generated code. | ||||
| // This type is not subject to any compatibility guarantee. | ||||
| type InternalMessageInfo struct { | ||||
| 	marshal   *marshalInfo | ||||
| 	unmarshal *unmarshalInfo | ||||
| 	merge     *mergeInfo | ||||
| 	discard   *discardInfo | ||||
| } | ||||
| // ProtoPackageIsVersion1 is referenced from generated protocol buffer files | ||||
| // to assert that that code is compatible with this version of the proto package. | ||||
| const GoGoProtoPackageIsVersion1 = true | ||||
|   | ||||
							
								
								
									
										8
									
								
								vendor/github.com/gogo/protobuf/proto/lib_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								vendor/github.com/gogo/protobuf/proto/lib_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -33,14 +33,6 @@ import ( | ||||
| 	"strconv" | ||||
| ) | ||||
|  | ||||
| type Sizer interface { | ||||
| 	Size() int | ||||
| } | ||||
|  | ||||
| type ProtoSizer interface { | ||||
| 	ProtoSize() int | ||||
| } | ||||
|  | ||||
| func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) { | ||||
| 	s, ok := m[value] | ||||
| 	if !ok { | ||||
|   | ||||
							
								
								
									
										24
									
								
								vendor/github.com/gogo/protobuf/proto/map_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								vendor/github.com/gogo/protobuf/proto/map_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -2,36 +2,12 @@ package proto_test | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"reflect" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
| 	ppb "github.com/gogo/protobuf/proto/proto3_proto" | ||||
| ) | ||||
|  | ||||
| func TestMap(t *testing.T) { | ||||
| 	var b []byte | ||||
| 	fmt.Sscanf("a2010c0a044b657931120456616c31a201130a044b657932120556616c3261120456616c32a201240a044b6579330d05000000120556616c33621a0556616c3361120456616c331505000000a20100a201260a044b657934130a07536f6d6555524c1209536f6d655469746c651a08536e69707065743114", "%x", &b) | ||||
|  | ||||
| 	var m ppb.Message | ||||
| 	if err := proto.Unmarshal(b, &m); err != nil { | ||||
| 		t.Fatalf("proto.Unmarshal error: %v", err) | ||||
| 	} | ||||
|  | ||||
| 	got := m.StringMap | ||||
| 	want := map[string]string{ | ||||
| 		"":     "", | ||||
| 		"Key1": "Val1", | ||||
| 		"Key2": "Val2", | ||||
| 		"Key3": "Val3", | ||||
| 		"Key4": "", | ||||
| 	} | ||||
|  | ||||
| 	if !reflect.DeepEqual(got, want) { | ||||
| 		t.Errorf("maps differ:\ngot  %#v\nwant %#v", got, want) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func marshalled() []byte { | ||||
| 	m := &ppb.IntMaps{} | ||||
| 	for i := 0; i < 1000; i++ { | ||||
|   | ||||
							
								
								
									
										138
									
								
								vendor/github.com/gogo/protobuf/proto/message_set.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										138
									
								
								vendor/github.com/gogo/protobuf/proto/message_set.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -36,7 +36,12 @@ package proto | ||||
|  */ | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"encoding/json" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"reflect" | ||||
| 	"sort" | ||||
| ) | ||||
|  | ||||
| // errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. | ||||
| @@ -89,7 +94,10 @@ func (ms *messageSet) find(pb Message) *_MessageSet_Item { | ||||
| } | ||||
|  | ||||
| func (ms *messageSet) Has(pb Message) bool { | ||||
| 	return ms.find(pb) != nil | ||||
| 	if ms.find(pb) != nil { | ||||
| 		return true | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| func (ms *messageSet) Unmarshal(pb Message) error { | ||||
| @@ -139,9 +147,50 @@ func skipVarint(buf []byte) []byte { | ||||
| 	return buf[i+1:] | ||||
| } | ||||
|  | ||||
| // unmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. | ||||
| // It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option. | ||||
| func unmarshalMessageSet(buf []byte, exts interface{}) error { | ||||
| // MarshalMessageSet encodes the extension map represented by m in the message set wire format. | ||||
| // It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. | ||||
| func MarshalMessageSet(exts interface{}) ([]byte, error) { | ||||
| 	var m map[int32]Extension | ||||
| 	switch exts := exts.(type) { | ||||
| 	case *XXX_InternalExtensions: | ||||
| 		if err := encodeExtensions(exts); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		m, _ = exts.extensionsRead() | ||||
| 	case map[int32]Extension: | ||||
| 		if err := encodeExtensionsMap(exts); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		m = exts | ||||
| 	default: | ||||
| 		return nil, errors.New("proto: not an extension map") | ||||
| 	} | ||||
|  | ||||
| 	// Sort extension IDs to provide a deterministic encoding. | ||||
| 	// See also enc_map in encode.go. | ||||
| 	ids := make([]int, 0, len(m)) | ||||
| 	for id := range m { | ||||
| 		ids = append(ids, int(id)) | ||||
| 	} | ||||
| 	sort.Ints(ids) | ||||
|  | ||||
| 	ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))} | ||||
| 	for _, id := range ids { | ||||
| 		e := m[int32(id)] | ||||
| 		// Remove the wire type and field number varint, as well as the length varint. | ||||
| 		msg := skipVarint(skipVarint(e.enc)) | ||||
|  | ||||
| 		ms.Item = append(ms.Item, &_MessageSet_Item{ | ||||
| 			TypeId:  Int32(int32(id)), | ||||
| 			Message: msg, | ||||
| 		}) | ||||
| 	} | ||||
| 	return Marshal(ms) | ||||
| } | ||||
|  | ||||
| // UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. | ||||
| // It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option. | ||||
| func UnmarshalMessageSet(buf []byte, exts interface{}) error { | ||||
| 	var m map[int32]Extension | ||||
| 	switch exts := exts.(type) { | ||||
| 	case *XXX_InternalExtensions: | ||||
| @@ -179,3 +228,84 @@ func unmarshalMessageSet(buf []byte, exts interface{}) error { | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // MarshalMessageSetJSON encodes the extension map represented by m in JSON format. | ||||
| // It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. | ||||
| func MarshalMessageSetJSON(exts interface{}) ([]byte, error) { | ||||
| 	var m map[int32]Extension | ||||
| 	switch exts := exts.(type) { | ||||
| 	case *XXX_InternalExtensions: | ||||
| 		m, _ = exts.extensionsRead() | ||||
| 	case map[int32]Extension: | ||||
| 		m = exts | ||||
| 	default: | ||||
| 		return nil, errors.New("proto: not an extension map") | ||||
| 	} | ||||
| 	var b bytes.Buffer | ||||
| 	b.WriteByte('{') | ||||
|  | ||||
| 	// Process the map in key order for deterministic output. | ||||
| 	ids := make([]int32, 0, len(m)) | ||||
| 	for id := range m { | ||||
| 		ids = append(ids, id) | ||||
| 	} | ||||
| 	sort.Sort(int32Slice(ids)) // int32Slice defined in text.go | ||||
|  | ||||
| 	for i, id := range ids { | ||||
| 		ext := m[id] | ||||
| 		if i > 0 { | ||||
| 			b.WriteByte(',') | ||||
| 		} | ||||
|  | ||||
| 		msd, ok := messageSetMap[id] | ||||
| 		if !ok { | ||||
| 			// Unknown type; we can't render it, so skip it. | ||||
| 			continue | ||||
| 		} | ||||
| 		fmt.Fprintf(&b, `"[%s]":`, msd.name) | ||||
|  | ||||
| 		x := ext.value | ||||
| 		if x == nil { | ||||
| 			x = reflect.New(msd.t.Elem()).Interface() | ||||
| 			if err := Unmarshal(ext.enc, x.(Message)); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 		} | ||||
| 		d, err := json.Marshal(x) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		b.Write(d) | ||||
| 	} | ||||
| 	b.WriteByte('}') | ||||
| 	return b.Bytes(), nil | ||||
| } | ||||
|  | ||||
| // UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. | ||||
| // It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. | ||||
| func UnmarshalMessageSetJSON(buf []byte, exts interface{}) error { | ||||
| 	// Common-case fast path. | ||||
| 	if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	// This is fairly tricky, and it's not clear that it is needed. | ||||
| 	return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented") | ||||
| } | ||||
|  | ||||
| // A global registry of types that can be used in a MessageSet. | ||||
|  | ||||
| var messageSetMap = make(map[int32]messageSetDesc) | ||||
|  | ||||
| type messageSetDesc struct { | ||||
| 	t    reflect.Type // pointer to struct | ||||
| 	name string | ||||
| } | ||||
|  | ||||
| // RegisterMessageSetType is called from the generated code. | ||||
| func RegisterMessageSetType(m Message, fieldNum int32, name string) { | ||||
| 	messageSetMap[fieldNum] = messageSetDesc{ | ||||
| 		t:    reflect.TypeOf(m), | ||||
| 		name: name, | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										66
									
								
								vendor/github.com/gogo/protobuf/proto/message_set_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										66
									
								
								vendor/github.com/gogo/protobuf/proto/message_set_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,60 +29,38 @@ | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| package proto_test | ||||
| package proto | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"fmt" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
| 	. "github.com/gogo/protobuf/proto/test_proto" | ||||
| ) | ||||
|  | ||||
| func TestUnmarshalMessageSetWithDuplicate(t *testing.T) { | ||||
| 	/* | ||||
| 		Message{ | ||||
| 			Tag{1, StartGroup}, | ||||
| 			Message{ | ||||
| 				Tag{2, Varint}, Uvarint(12345), | ||||
| 				Tag{3, Bytes}, Bytes("hoo"), | ||||
| 			}, | ||||
| 			Tag{1, EndGroup}, | ||||
| 			Tag{1, StartGroup}, | ||||
| 			Message{ | ||||
| 				Tag{2, Varint}, Uvarint(12345), | ||||
| 				Tag{3, Bytes}, Bytes("hah"), | ||||
| 			}, | ||||
| 			Tag{1, EndGroup}, | ||||
| 		} | ||||
| 	*/ | ||||
| 	var in []byte | ||||
| 	fmt.Sscanf("0b10b9601a03686f6f0c0b10b9601a036861680c", "%x", &in) | ||||
|  | ||||
| 	/* | ||||
| 		Message{ | ||||
| 			Tag{1, StartGroup}, | ||||
| 			Message{ | ||||
| 				Tag{2, Varint}, Uvarint(12345), | ||||
| 				Tag{3, Bytes}, Bytes("hoohah"), | ||||
| 			}, | ||||
| 			Tag{1, EndGroup}, | ||||
| 		} | ||||
| 	*/ | ||||
| 	var want []byte | ||||
| 	fmt.Sscanf("0b10b9601a06686f6f6861680c", "%x", &want) | ||||
|  | ||||
| 	var m MyMessageSet | ||||
| 	if err := proto.Unmarshal(in, &m); err != nil { | ||||
| 		t.Fatalf("unexpected Unmarshal error: %v", err) | ||||
| 	// Check that a repeated message set entry will be concatenated. | ||||
| 	in := &messageSet{ | ||||
| 		Item: []*_MessageSet_Item{ | ||||
| 			{TypeId: Int32(12345), Message: []byte("hoo")}, | ||||
| 			{TypeId: Int32(12345), Message: []byte("hah")}, | ||||
| 		}, | ||||
| 	} | ||||
| 	got, err := proto.Marshal(&m) | ||||
| 	b, err := Marshal(in) | ||||
| 	if err != nil { | ||||
| 		t.Fatalf("unexpected Marshal error: %v", err) | ||||
| 		t.Fatalf("Marshal: %v", err) | ||||
| 	} | ||||
| 	t.Logf("Marshaled bytes: %q", b) | ||||
|  | ||||
| 	if !bytes.Equal(got, want) { | ||||
| 		t.Errorf("output mismatch:\ngot  %x\nwant %x", got, want) | ||||
| 	var extensions XXX_InternalExtensions | ||||
| 	if err := UnmarshalMessageSet(b, &extensions); err != nil { | ||||
| 		t.Fatalf("UnmarshalMessageSet: %v", err) | ||||
| 	} | ||||
| 	ext, ok := extensions.p.extensionMap[12345] | ||||
| 	if !ok { | ||||
| 		t.Fatalf("Didn't retrieve extension 12345; map is %v", extensions.p.extensionMap) | ||||
| 	} | ||||
| 	// Skip wire type/field number and length varints. | ||||
| 	got := skipVarint(skipVarint(ext.enc)) | ||||
| 	if want := []byte("hoohah"); !bytes.Equal(got, want) { | ||||
| 		t.Errorf("Combined extension is %q, want %q", got, want) | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										647
									
								
								vendor/github.com/gogo/protobuf/proto/pointer_reflect.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										647
									
								
								vendor/github.com/gogo/protobuf/proto/pointer_reflect.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,7 +29,7 @@ | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| // +build purego appengine js | ||||
| // +build appengine js | ||||
|  | ||||
| // This file contains an implementation of proto field accesses using package reflect. | ||||
| // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can | ||||
| @@ -38,13 +38,32 @@ | ||||
| package proto | ||||
|  | ||||
| import ( | ||||
| 	"math" | ||||
| 	"reflect" | ||||
| 	"sync" | ||||
| ) | ||||
|  | ||||
| const unsafeAllowed = false | ||||
| // A structPointer is a pointer to a struct. | ||||
| type structPointer struct { | ||||
| 	v reflect.Value | ||||
| } | ||||
|  | ||||
| // A field identifies a field in a struct, accessible from a pointer. | ||||
| // toStructPointer returns a structPointer equivalent to the given reflect value. | ||||
| // The reflect value must itself be a pointer to a struct. | ||||
| func toStructPointer(v reflect.Value) structPointer { | ||||
| 	return structPointer{v} | ||||
| } | ||||
|  | ||||
| // IsNil reports whether p is nil. | ||||
| func structPointer_IsNil(p structPointer) bool { | ||||
| 	return p.v.IsNil() | ||||
| } | ||||
|  | ||||
| // Interface returns the struct pointer as an interface value. | ||||
| func structPointer_Interface(p structPointer, _ reflect.Type) interface{} { | ||||
| 	return p.v.Interface() | ||||
| } | ||||
|  | ||||
| // A field identifies a field in a struct, accessible from a structPointer. | ||||
| // In this implementation, a field is identified by the sequence of field indices | ||||
| // passed to reflect's FieldByIndex. | ||||
| type field []int | ||||
| @@ -57,301 +76,409 @@ func toField(f *reflect.StructField) field { | ||||
| // invalidField is an invalid field identifier. | ||||
| var invalidField = field(nil) | ||||
|  | ||||
| // zeroField is a noop when calling pointer.offset. | ||||
| var zeroField = field([]int{}) | ||||
|  | ||||
| // IsValid reports whether the field identifier is valid. | ||||
| func (f field) IsValid() bool { return f != nil } | ||||
|  | ||||
| // The pointer type is for the table-driven decoder. | ||||
| // The implementation here uses a reflect.Value of pointer type to | ||||
| // create a generic pointer. In pointer_unsafe.go we use unsafe | ||||
| // instead of reflect to implement the same (but faster) interface. | ||||
| type pointer struct { | ||||
| // field returns the given field in the struct as a reflect value. | ||||
| func structPointer_field(p structPointer, f field) reflect.Value { | ||||
| 	// Special case: an extension map entry with a value of type T | ||||
| 	// passes a *T to the struct-handling code with a zero field, | ||||
| 	// expecting that it will be treated as equivalent to *struct{ X T }, | ||||
| 	// which has the same memory layout. We have to handle that case | ||||
| 	// specially, because reflect will panic if we call FieldByIndex on a | ||||
| 	// non-struct. | ||||
| 	if f == nil { | ||||
| 		return p.v.Elem() | ||||
| 	} | ||||
|  | ||||
| 	return p.v.Elem().FieldByIndex(f) | ||||
| } | ||||
|  | ||||
| // ifield returns the given field in the struct as an interface value. | ||||
| func structPointer_ifield(p structPointer, f field) interface{} { | ||||
| 	return structPointer_field(p, f).Addr().Interface() | ||||
| } | ||||
|  | ||||
| // Bytes returns the address of a []byte field in the struct. | ||||
| func structPointer_Bytes(p structPointer, f field) *[]byte { | ||||
| 	return structPointer_ifield(p, f).(*[]byte) | ||||
| } | ||||
|  | ||||
| // BytesSlice returns the address of a [][]byte field in the struct. | ||||
| func structPointer_BytesSlice(p structPointer, f field) *[][]byte { | ||||
| 	return structPointer_ifield(p, f).(*[][]byte) | ||||
| } | ||||
|  | ||||
| // Bool returns the address of a *bool field in the struct. | ||||
| func structPointer_Bool(p structPointer, f field) **bool { | ||||
| 	return structPointer_ifield(p, f).(**bool) | ||||
| } | ||||
|  | ||||
| // BoolVal returns the address of a bool field in the struct. | ||||
| func structPointer_BoolVal(p structPointer, f field) *bool { | ||||
| 	return structPointer_ifield(p, f).(*bool) | ||||
| } | ||||
|  | ||||
| // BoolSlice returns the address of a []bool field in the struct. | ||||
| func structPointer_BoolSlice(p structPointer, f field) *[]bool { | ||||
| 	return structPointer_ifield(p, f).(*[]bool) | ||||
| } | ||||
|  | ||||
| // String returns the address of a *string field in the struct. | ||||
| func structPointer_String(p structPointer, f field) **string { | ||||
| 	return structPointer_ifield(p, f).(**string) | ||||
| } | ||||
|  | ||||
| // StringVal returns the address of a string field in the struct. | ||||
| func structPointer_StringVal(p structPointer, f field) *string { | ||||
| 	return structPointer_ifield(p, f).(*string) | ||||
| } | ||||
|  | ||||
| // StringSlice returns the address of a []string field in the struct. | ||||
| func structPointer_StringSlice(p structPointer, f field) *[]string { | ||||
| 	return structPointer_ifield(p, f).(*[]string) | ||||
| } | ||||
|  | ||||
| // Extensions returns the address of an extension map field in the struct. | ||||
| func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions { | ||||
| 	return structPointer_ifield(p, f).(*XXX_InternalExtensions) | ||||
| } | ||||
|  | ||||
| // ExtMap returns the address of an extension map field in the struct. | ||||
| func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { | ||||
| 	return structPointer_ifield(p, f).(*map[int32]Extension) | ||||
| } | ||||
|  | ||||
| // NewAt returns the reflect.Value for a pointer to a field in the struct. | ||||
| func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { | ||||
| 	return structPointer_field(p, f).Addr() | ||||
| } | ||||
|  | ||||
| // SetStructPointer writes a *struct field in the struct. | ||||
| func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { | ||||
| 	structPointer_field(p, f).Set(q.v) | ||||
| } | ||||
|  | ||||
| // GetStructPointer reads a *struct field in the struct. | ||||
| func structPointer_GetStructPointer(p structPointer, f field) structPointer { | ||||
| 	return structPointer{structPointer_field(p, f)} | ||||
| } | ||||
|  | ||||
| // StructPointerSlice the address of a []*struct field in the struct. | ||||
| func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice { | ||||
| 	return structPointerSlice{structPointer_field(p, f)} | ||||
| } | ||||
|  | ||||
| // A structPointerSlice represents the address of a slice of pointers to structs | ||||
| // (themselves messages or groups). That is, v.Type() is *[]*struct{...}. | ||||
| type structPointerSlice struct { | ||||
| 	v reflect.Value | ||||
| } | ||||
|  | ||||
| // toPointer converts an interface of pointer type to a pointer | ||||
| // that points to the same target. | ||||
| func toPointer(i *Message) pointer { | ||||
| 	return pointer{v: reflect.ValueOf(*i)} | ||||
| func (p structPointerSlice) Len() int                  { return p.v.Len() } | ||||
| func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} } | ||||
| func (p structPointerSlice) Append(q structPointer) { | ||||
| 	p.v.Set(reflect.Append(p.v, q.v)) | ||||
| } | ||||
|  | ||||
| // toAddrPointer converts an interface to a pointer that points to | ||||
| // the interface data. | ||||
| func toAddrPointer(i *interface{}, isptr bool) pointer { | ||||
| 	v := reflect.ValueOf(*i) | ||||
| 	u := reflect.New(v.Type()) | ||||
| 	u.Elem().Set(v) | ||||
| 	return pointer{v: u} | ||||
| var ( | ||||
| 	int32Type   = reflect.TypeOf(int32(0)) | ||||
| 	uint32Type  = reflect.TypeOf(uint32(0)) | ||||
| 	float32Type = reflect.TypeOf(float32(0)) | ||||
| 	int64Type   = reflect.TypeOf(int64(0)) | ||||
| 	uint64Type  = reflect.TypeOf(uint64(0)) | ||||
| 	float64Type = reflect.TypeOf(float64(0)) | ||||
| ) | ||||
|  | ||||
| // A word32 represents a field of type *int32, *uint32, *float32, or *enum. | ||||
| // That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable. | ||||
| type word32 struct { | ||||
| 	v reflect.Value | ||||
| } | ||||
|  | ||||
| // valToPointer converts v to a pointer.  v must be of pointer type. | ||||
| func valToPointer(v reflect.Value) pointer { | ||||
| 	return pointer{v: v} | ||||
| } | ||||
|  | ||||
| // offset converts from a pointer to a structure to a pointer to | ||||
| // one of its fields. | ||||
| func (p pointer) offset(f field) pointer { | ||||
| 	return pointer{v: p.v.Elem().FieldByIndex(f).Addr()} | ||||
| } | ||||
|  | ||||
| func (p pointer) isNil() bool { | ||||
| // IsNil reports whether p is nil. | ||||
| func word32_IsNil(p word32) bool { | ||||
| 	return p.v.IsNil() | ||||
| } | ||||
|  | ||||
| // grow updates the slice s in place to make it one element longer. | ||||
| // s must be addressable. | ||||
| // Returns the (addressable) new element. | ||||
| func grow(s reflect.Value) reflect.Value { | ||||
| 	n, m := s.Len(), s.Cap() | ||||
| // Set sets p to point at a newly allocated word with bits set to x. | ||||
| func word32_Set(p word32, o *Buffer, x uint32) { | ||||
| 	t := p.v.Type().Elem() | ||||
| 	switch t { | ||||
| 	case int32Type: | ||||
| 		if len(o.int32s) == 0 { | ||||
| 			o.int32s = make([]int32, uint32PoolSize) | ||||
| 		} | ||||
| 		o.int32s[0] = int32(x) | ||||
| 		p.v.Set(reflect.ValueOf(&o.int32s[0])) | ||||
| 		o.int32s = o.int32s[1:] | ||||
| 		return | ||||
| 	case uint32Type: | ||||
| 		if len(o.uint32s) == 0 { | ||||
| 			o.uint32s = make([]uint32, uint32PoolSize) | ||||
| 		} | ||||
| 		o.uint32s[0] = x | ||||
| 		p.v.Set(reflect.ValueOf(&o.uint32s[0])) | ||||
| 		o.uint32s = o.uint32s[1:] | ||||
| 		return | ||||
| 	case float32Type: | ||||
| 		if len(o.float32s) == 0 { | ||||
| 			o.float32s = make([]float32, uint32PoolSize) | ||||
| 		} | ||||
| 		o.float32s[0] = math.Float32frombits(x) | ||||
| 		p.v.Set(reflect.ValueOf(&o.float32s[0])) | ||||
| 		o.float32s = o.float32s[1:] | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	// must be enum | ||||
| 	p.v.Set(reflect.New(t)) | ||||
| 	p.v.Elem().SetInt(int64(int32(x))) | ||||
| } | ||||
|  | ||||
| // Get gets the bits pointed at by p, as a uint32. | ||||
| func word32_Get(p word32) uint32 { | ||||
| 	elem := p.v.Elem() | ||||
| 	switch elem.Kind() { | ||||
| 	case reflect.Int32: | ||||
| 		return uint32(elem.Int()) | ||||
| 	case reflect.Uint32: | ||||
| 		return uint32(elem.Uint()) | ||||
| 	case reflect.Float32: | ||||
| 		return math.Float32bits(float32(elem.Float())) | ||||
| 	} | ||||
| 	panic("unreachable") | ||||
| } | ||||
|  | ||||
| // Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct. | ||||
| func structPointer_Word32(p structPointer, f field) word32 { | ||||
| 	return word32{structPointer_field(p, f)} | ||||
| } | ||||
|  | ||||
| // A word32Val represents a field of type int32, uint32, float32, or enum. | ||||
| // That is, v.Type() is int32, uint32, float32, or enum and v is assignable. | ||||
| type word32Val struct { | ||||
| 	v reflect.Value | ||||
| } | ||||
|  | ||||
| // Set sets *p to x. | ||||
| func word32Val_Set(p word32Val, x uint32) { | ||||
| 	switch p.v.Type() { | ||||
| 	case int32Type: | ||||
| 		p.v.SetInt(int64(x)) | ||||
| 		return | ||||
| 	case uint32Type: | ||||
| 		p.v.SetUint(uint64(x)) | ||||
| 		return | ||||
| 	case float32Type: | ||||
| 		p.v.SetFloat(float64(math.Float32frombits(x))) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	// must be enum | ||||
| 	p.v.SetInt(int64(int32(x))) | ||||
| } | ||||
|  | ||||
| // Get gets the bits pointed at by p, as a uint32. | ||||
| func word32Val_Get(p word32Val) uint32 { | ||||
| 	elem := p.v | ||||
| 	switch elem.Kind() { | ||||
| 	case reflect.Int32: | ||||
| 		return uint32(elem.Int()) | ||||
| 	case reflect.Uint32: | ||||
| 		return uint32(elem.Uint()) | ||||
| 	case reflect.Float32: | ||||
| 		return math.Float32bits(float32(elem.Float())) | ||||
| 	} | ||||
| 	panic("unreachable") | ||||
| } | ||||
|  | ||||
| // Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct. | ||||
| func structPointer_Word32Val(p structPointer, f field) word32Val { | ||||
| 	return word32Val{structPointer_field(p, f)} | ||||
| } | ||||
|  | ||||
| // A word32Slice is a slice of 32-bit values. | ||||
| // That is, v.Type() is []int32, []uint32, []float32, or []enum. | ||||
| type word32Slice struct { | ||||
| 	v reflect.Value | ||||
| } | ||||
|  | ||||
| func (p word32Slice) Append(x uint32) { | ||||
| 	n, m := p.v.Len(), p.v.Cap() | ||||
| 	if n < m { | ||||
| 		s.SetLen(n + 1) | ||||
| 		p.v.SetLen(n + 1) | ||||
| 	} else { | ||||
| 		s.Set(reflect.Append(s, reflect.Zero(s.Type().Elem()))) | ||||
| 		t := p.v.Type().Elem() | ||||
| 		p.v.Set(reflect.Append(p.v, reflect.Zero(t))) | ||||
| 	} | ||||
| 	return s.Index(n) | ||||
| } | ||||
|  | ||||
| func (p pointer) toInt64() *int64 { | ||||
| 	return p.v.Interface().(*int64) | ||||
| } | ||||
| func (p pointer) toInt64Ptr() **int64 { | ||||
| 	return p.v.Interface().(**int64) | ||||
| } | ||||
| func (p pointer) toInt64Slice() *[]int64 { | ||||
| 	return p.v.Interface().(*[]int64) | ||||
| } | ||||
|  | ||||
| var int32ptr = reflect.TypeOf((*int32)(nil)) | ||||
|  | ||||
| func (p pointer) toInt32() *int32 { | ||||
| 	return p.v.Convert(int32ptr).Interface().(*int32) | ||||
| } | ||||
|  | ||||
| // The toInt32Ptr/Slice methods don't work because of enums. | ||||
| // Instead, we must use set/get methods for the int32ptr/slice case. | ||||
| /* | ||||
| 	func (p pointer) toInt32Ptr() **int32 { | ||||
| 		return p.v.Interface().(**int32) | ||||
| } | ||||
| 	func (p pointer) toInt32Slice() *[]int32 { | ||||
| 		return p.v.Interface().(*[]int32) | ||||
| } | ||||
| */ | ||||
| func (p pointer) getInt32Ptr() *int32 { | ||||
| 	if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) { | ||||
| 		// raw int32 type | ||||
| 		return p.v.Elem().Interface().(*int32) | ||||
| 	elem := p.v.Index(n) | ||||
| 	switch elem.Kind() { | ||||
| 	case reflect.Int32: | ||||
| 		elem.SetInt(int64(int32(x))) | ||||
| 	case reflect.Uint32: | ||||
| 		elem.SetUint(uint64(x)) | ||||
| 	case reflect.Float32: | ||||
| 		elem.SetFloat(float64(math.Float32frombits(x))) | ||||
| 	} | ||||
| 	// an enum | ||||
| 	return p.v.Elem().Convert(int32PtrType).Interface().(*int32) | ||||
| } | ||||
| func (p pointer) setInt32Ptr(v int32) { | ||||
| 	// Allocate value in a *int32. Possibly convert that to a *enum. | ||||
| 	// Then assign it to a **int32 or **enum. | ||||
| 	// Note: we can convert *int32 to *enum, but we can't convert | ||||
| 	// **int32 to **enum! | ||||
| 	p.v.Elem().Set(reflect.ValueOf(&v).Convert(p.v.Type().Elem())) | ||||
| } | ||||
|  | ||||
| // getInt32Slice copies []int32 from p as a new slice. | ||||
| // This behavior differs from the implementation in pointer_unsafe.go. | ||||
| func (p pointer) getInt32Slice() []int32 { | ||||
| 	if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) { | ||||
| 		// raw int32 type | ||||
| 		return p.v.Elem().Interface().([]int32) | ||||
| 	} | ||||
| 	// an enum | ||||
| 	// Allocate a []int32, then assign []enum's values into it. | ||||
| 	// Note: we can't convert []enum to []int32. | ||||
| 	slice := p.v.Elem() | ||||
| 	s := make([]int32, slice.Len()) | ||||
| 	for i := 0; i < slice.Len(); i++ { | ||||
| 		s[i] = int32(slice.Index(i).Int()) | ||||
| 	} | ||||
| 	return s | ||||
| func (p word32Slice) Len() int { | ||||
| 	return p.v.Len() | ||||
| } | ||||
|  | ||||
| // setInt32Slice copies []int32 into p as a new slice. | ||||
| // This behavior differs from the implementation in pointer_unsafe.go. | ||||
| func (p pointer) setInt32Slice(v []int32) { | ||||
| 	if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) { | ||||
| 		// raw int32 type | ||||
| 		p.v.Elem().Set(reflect.ValueOf(v)) | ||||
| func (p word32Slice) Index(i int) uint32 { | ||||
| 	elem := p.v.Index(i) | ||||
| 	switch elem.Kind() { | ||||
| 	case reflect.Int32: | ||||
| 		return uint32(elem.Int()) | ||||
| 	case reflect.Uint32: | ||||
| 		return uint32(elem.Uint()) | ||||
| 	case reflect.Float32: | ||||
| 		return math.Float32bits(float32(elem.Float())) | ||||
| 	} | ||||
| 	panic("unreachable") | ||||
| } | ||||
|  | ||||
| // Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct. | ||||
| func structPointer_Word32Slice(p structPointer, f field) word32Slice { | ||||
| 	return word32Slice{structPointer_field(p, f)} | ||||
| } | ||||
|  | ||||
| // word64 is like word32 but for 64-bit values. | ||||
| type word64 struct { | ||||
| 	v reflect.Value | ||||
| } | ||||
|  | ||||
| func word64_Set(p word64, o *Buffer, x uint64) { | ||||
| 	t := p.v.Type().Elem() | ||||
| 	switch t { | ||||
| 	case int64Type: | ||||
| 		if len(o.int64s) == 0 { | ||||
| 			o.int64s = make([]int64, uint64PoolSize) | ||||
| 		} | ||||
| 		o.int64s[0] = int64(x) | ||||
| 		p.v.Set(reflect.ValueOf(&o.int64s[0])) | ||||
| 		o.int64s = o.int64s[1:] | ||||
| 		return | ||||
| 	case uint64Type: | ||||
| 		if len(o.uint64s) == 0 { | ||||
| 			o.uint64s = make([]uint64, uint64PoolSize) | ||||
| 		} | ||||
| 		o.uint64s[0] = x | ||||
| 		p.v.Set(reflect.ValueOf(&o.uint64s[0])) | ||||
| 		o.uint64s = o.uint64s[1:] | ||||
| 		return | ||||
| 	case float64Type: | ||||
| 		if len(o.float64s) == 0 { | ||||
| 			o.float64s = make([]float64, uint64PoolSize) | ||||
| 		} | ||||
| 		o.float64s[0] = math.Float64frombits(x) | ||||
| 		p.v.Set(reflect.ValueOf(&o.float64s[0])) | ||||
| 		o.float64s = o.float64s[1:] | ||||
| 		return | ||||
| 	} | ||||
| 	// an enum | ||||
| 	// Allocate a []enum, then assign []int32's values into it. | ||||
| 	// Note: we can't convert []enum to []int32. | ||||
| 	slice := reflect.MakeSlice(p.v.Type().Elem(), len(v), cap(v)) | ||||
| 	for i, x := range v { | ||||
| 		slice.Index(i).SetInt(int64(x)) | ||||
| 	} | ||||
| 	p.v.Elem().Set(slice) | ||||
| } | ||||
| func (p pointer) appendInt32Slice(v int32) { | ||||
| 	grow(p.v.Elem()).SetInt(int64(v)) | ||||
| 	panic("unreachable") | ||||
| } | ||||
|  | ||||
| func (p pointer) toUint64() *uint64 { | ||||
| 	return p.v.Interface().(*uint64) | ||||
| } | ||||
| func (p pointer) toUint64Ptr() **uint64 { | ||||
| 	return p.v.Interface().(**uint64) | ||||
| } | ||||
| func (p pointer) toUint64Slice() *[]uint64 { | ||||
| 	return p.v.Interface().(*[]uint64) | ||||
| } | ||||
| func (p pointer) toUint32() *uint32 { | ||||
| 	return p.v.Interface().(*uint32) | ||||
| } | ||||
| func (p pointer) toUint32Ptr() **uint32 { | ||||
| 	return p.v.Interface().(**uint32) | ||||
| } | ||||
| func (p pointer) toUint32Slice() *[]uint32 { | ||||
| 	return p.v.Interface().(*[]uint32) | ||||
| } | ||||
| func (p pointer) toBool() *bool { | ||||
| 	return p.v.Interface().(*bool) | ||||
| } | ||||
| func (p pointer) toBoolPtr() **bool { | ||||
| 	return p.v.Interface().(**bool) | ||||
| } | ||||
| func (p pointer) toBoolSlice() *[]bool { | ||||
| 	return p.v.Interface().(*[]bool) | ||||
| } | ||||
| func (p pointer) toFloat64() *float64 { | ||||
| 	return p.v.Interface().(*float64) | ||||
| } | ||||
| func (p pointer) toFloat64Ptr() **float64 { | ||||
| 	return p.v.Interface().(**float64) | ||||
| } | ||||
| func (p pointer) toFloat64Slice() *[]float64 { | ||||
| 	return p.v.Interface().(*[]float64) | ||||
| } | ||||
| func (p pointer) toFloat32() *float32 { | ||||
| 	return p.v.Interface().(*float32) | ||||
| } | ||||
| func (p pointer) toFloat32Ptr() **float32 { | ||||
| 	return p.v.Interface().(**float32) | ||||
| } | ||||
| func (p pointer) toFloat32Slice() *[]float32 { | ||||
| 	return p.v.Interface().(*[]float32) | ||||
| } | ||||
| func (p pointer) toString() *string { | ||||
| 	return p.v.Interface().(*string) | ||||
| } | ||||
| func (p pointer) toStringPtr() **string { | ||||
| 	return p.v.Interface().(**string) | ||||
| } | ||||
| func (p pointer) toStringSlice() *[]string { | ||||
| 	return p.v.Interface().(*[]string) | ||||
| } | ||||
| func (p pointer) toBytes() *[]byte { | ||||
| 	return p.v.Interface().(*[]byte) | ||||
| } | ||||
| func (p pointer) toBytesSlice() *[][]byte { | ||||
| 	return p.v.Interface().(*[][]byte) | ||||
| } | ||||
| func (p pointer) toExtensions() *XXX_InternalExtensions { | ||||
| 	return p.v.Interface().(*XXX_InternalExtensions) | ||||
| } | ||||
| func (p pointer) toOldExtensions() *map[int32]Extension { | ||||
| 	return p.v.Interface().(*map[int32]Extension) | ||||
| } | ||||
| func (p pointer) getPointer() pointer { | ||||
| 	return pointer{v: p.v.Elem()} | ||||
| } | ||||
| func (p pointer) setPointer(q pointer) { | ||||
| 	p.v.Elem().Set(q.v) | ||||
| } | ||||
| func (p pointer) appendPointer(q pointer) { | ||||
| 	grow(p.v.Elem()).Set(q.v) | ||||
| func word64_IsNil(p word64) bool { | ||||
| 	return p.v.IsNil() | ||||
| } | ||||
|  | ||||
| // getPointerSlice copies []*T from p as a new []pointer. | ||||
| // This behavior differs from the implementation in pointer_unsafe.go. | ||||
| func (p pointer) getPointerSlice() []pointer { | ||||
| 	if p.v.IsNil() { | ||||
| 		return nil | ||||
| func word64_Get(p word64) uint64 { | ||||
| 	elem := p.v.Elem() | ||||
| 	switch elem.Kind() { | ||||
| 	case reflect.Int64: | ||||
| 		return uint64(elem.Int()) | ||||
| 	case reflect.Uint64: | ||||
| 		return elem.Uint() | ||||
| 	case reflect.Float64: | ||||
| 		return math.Float64bits(elem.Float()) | ||||
| 	} | ||||
| 	n := p.v.Elem().Len() | ||||
| 	s := make([]pointer, n) | ||||
| 	for i := 0; i < n; i++ { | ||||
| 		s[i] = pointer{v: p.v.Elem().Index(i)} | ||||
| 	} | ||||
| 	return s | ||||
| 	panic("unreachable") | ||||
| } | ||||
|  | ||||
| // setPointerSlice copies []pointer into p as a new []*T. | ||||
| // This behavior differs from the implementation in pointer_unsafe.go. | ||||
| func (p pointer) setPointerSlice(v []pointer) { | ||||
| 	if v == nil { | ||||
| 		p.v.Elem().Set(reflect.New(p.v.Elem().Type()).Elem()) | ||||
| func structPointer_Word64(p structPointer, f field) word64 { | ||||
| 	return word64{structPointer_field(p, f)} | ||||
| } | ||||
|  | ||||
| // word64Val is like word32Val but for 64-bit values. | ||||
| type word64Val struct { | ||||
| 	v reflect.Value | ||||
| } | ||||
|  | ||||
| func word64Val_Set(p word64Val, o *Buffer, x uint64) { | ||||
| 	switch p.v.Type() { | ||||
| 	case int64Type: | ||||
| 		p.v.SetInt(int64(x)) | ||||
| 		return | ||||
| 	case uint64Type: | ||||
| 		p.v.SetUint(x) | ||||
| 		return | ||||
| 	case float64Type: | ||||
| 		p.v.SetFloat(math.Float64frombits(x)) | ||||
| 		return | ||||
| 	} | ||||
| 	s := reflect.MakeSlice(p.v.Elem().Type(), 0, len(v)) | ||||
| 	for _, p := range v { | ||||
| 		s = reflect.Append(s, p.v) | ||||
| 	panic("unreachable") | ||||
| } | ||||
|  | ||||
| func word64Val_Get(p word64Val) uint64 { | ||||
| 	elem := p.v | ||||
| 	switch elem.Kind() { | ||||
| 	case reflect.Int64: | ||||
| 		return uint64(elem.Int()) | ||||
| 	case reflect.Uint64: | ||||
| 		return elem.Uint() | ||||
| 	case reflect.Float64: | ||||
| 		return math.Float64bits(elem.Float()) | ||||
| 	} | ||||
| 	p.v.Elem().Set(s) | ||||
| 	panic("unreachable") | ||||
| } | ||||
|  | ||||
| // getInterfacePointer returns a pointer that points to the | ||||
| // interface data of the interface pointed by p. | ||||
| func (p pointer) getInterfacePointer() pointer { | ||||
| 	if p.v.Elem().IsNil() { | ||||
| 		return pointer{v: p.v.Elem()} | ||||
| func structPointer_Word64Val(p structPointer, f field) word64Val { | ||||
| 	return word64Val{structPointer_field(p, f)} | ||||
| } | ||||
|  | ||||
| type word64Slice struct { | ||||
| 	v reflect.Value | ||||
| } | ||||
|  | ||||
| func (p word64Slice) Append(x uint64) { | ||||
| 	n, m := p.v.Len(), p.v.Cap() | ||||
| 	if n < m { | ||||
| 		p.v.SetLen(n + 1) | ||||
| 	} else { | ||||
| 		t := p.v.Type().Elem() | ||||
| 		p.v.Set(reflect.Append(p.v, reflect.Zero(t))) | ||||
| 	} | ||||
| 	elem := p.v.Index(n) | ||||
| 	switch elem.Kind() { | ||||
| 	case reflect.Int64: | ||||
| 		elem.SetInt(int64(int64(x))) | ||||
| 	case reflect.Uint64: | ||||
| 		elem.SetUint(uint64(x)) | ||||
| 	case reflect.Float64: | ||||
| 		elem.SetFloat(float64(math.Float64frombits(x))) | ||||
| 	} | ||||
| 	return pointer{v: p.v.Elem().Elem().Elem().Field(0).Addr()} // *interface -> interface -> *struct -> struct | ||||
| } | ||||
|  | ||||
| func (p pointer) asPointerTo(t reflect.Type) reflect.Value { | ||||
| 	// TODO: check that p.v.Type().Elem() == t? | ||||
| 	return p.v | ||||
| func (p word64Slice) Len() int { | ||||
| 	return p.v.Len() | ||||
| } | ||||
|  | ||||
| func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo { | ||||
| 	atomicLock.Lock() | ||||
| 	defer atomicLock.Unlock() | ||||
| 	return *p | ||||
| } | ||||
| func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) { | ||||
| 	atomicLock.Lock() | ||||
| 	defer atomicLock.Unlock() | ||||
| 	*p = v | ||||
| } | ||||
| func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo { | ||||
| 	atomicLock.Lock() | ||||
| 	defer atomicLock.Unlock() | ||||
| 	return *p | ||||
| } | ||||
| func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) { | ||||
| 	atomicLock.Lock() | ||||
| 	defer atomicLock.Unlock() | ||||
| 	*p = v | ||||
| } | ||||
| func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo { | ||||
| 	atomicLock.Lock() | ||||
| 	defer atomicLock.Unlock() | ||||
| 	return *p | ||||
| } | ||||
| func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) { | ||||
| 	atomicLock.Lock() | ||||
| 	defer atomicLock.Unlock() | ||||
| 	*p = v | ||||
| } | ||||
| func atomicLoadDiscardInfo(p **discardInfo) *discardInfo { | ||||
| 	atomicLock.Lock() | ||||
| 	defer atomicLock.Unlock() | ||||
| 	return *p | ||||
| } | ||||
| func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) { | ||||
| 	atomicLock.Lock() | ||||
| 	defer atomicLock.Unlock() | ||||
| 	*p = v | ||||
| func (p word64Slice) Index(i int) uint64 { | ||||
| 	elem := p.v.Index(i) | ||||
| 	switch elem.Kind() { | ||||
| 	case reflect.Int64: | ||||
| 		return uint64(elem.Int()) | ||||
| 	case reflect.Uint64: | ||||
| 		return uint64(elem.Uint()) | ||||
| 	case reflect.Float64: | ||||
| 		return math.Float64bits(float64(elem.Float())) | ||||
| 	} | ||||
| 	panic("unreachable") | ||||
| } | ||||
|  | ||||
| var atomicLock sync.Mutex | ||||
| func structPointer_Word64Slice(p structPointer, f field) word64Slice { | ||||
| 	return word64Slice{structPointer_field(p, f)} | ||||
| } | ||||
|   | ||||
							
								
								
									
										66
									
								
								vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										66
									
								
								vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| // Protocol Buffers for Go with Gadgets | ||||
| // | ||||
| // Copyright (c) 2018, The GoGo Authors. All rights reserved. | ||||
| // Copyright (c) 2016, The GoGo Authors. All rights reserved. | ||||
| // http://github.com/gogo/protobuf | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| @@ -26,11 +26,7 @@ | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| // +build purego appengine js | ||||
|  | ||||
| // This file contains an implementation of proto field accesses using package reflect. | ||||
| // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can | ||||
| // be used on App Engine. | ||||
| // +build appengine js | ||||
|  | ||||
| package proto | ||||
|  | ||||
| @@ -38,22 +34,52 @@ import ( | ||||
| 	"reflect" | ||||
| ) | ||||
|  | ||||
| // TODO: untested, so probably incorrect. | ||||
|  | ||||
| func (p pointer) getRef() pointer { | ||||
| 	return pointer{v: p.v.Addr()} | ||||
| func structPointer_FieldPointer(p structPointer, f field) structPointer { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| func (p pointer) appendRef(v pointer, typ reflect.Type) { | ||||
| 	slice := p.getSlice(typ) | ||||
| 	elem := v.asPointerTo(typ).Elem() | ||||
| 	newSlice := reflect.Append(slice, elem) | ||||
| 	slice.Set(newSlice) | ||||
| func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| func (p pointer) getSlice(typ reflect.Type) reflect.Value { | ||||
| 	sliceTyp := reflect.SliceOf(typ) | ||||
| 	slice := p.asPointerTo(sliceTyp) | ||||
| 	slice = slice.Elem() | ||||
| 	return slice | ||||
| func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| func structPointer_GetRefStructPointer(p structPointer, f field) structPointer { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| func structPointer_Add(p structPointer, size field) structPointer { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| func structPointer_Len(p structPointer, f field) int { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| func structPointer_StructRefSlice(p structPointer, f field, size uintptr) *structRefSlice { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| type structRefSlice struct{} | ||||
|  | ||||
| func (v *structRefSlice) Len() int { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|  | ||||
| func (v *structRefSlice) Index(i int) structPointer { | ||||
| 	panic("not implemented") | ||||
| } | ||||
|   | ||||
							
								
								
									
										398
									
								
								vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										398
									
								
								vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -29,7 +29,7 @@ | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| // +build !purego,!appengine,!js | ||||
| // +build !appengine,!js | ||||
|  | ||||
| // This file contains the implementation of the proto field accesses using package unsafe. | ||||
|  | ||||
| @@ -37,13 +37,38 @@ package proto | ||||
|  | ||||
| import ( | ||||
| 	"reflect" | ||||
| 	"sync/atomic" | ||||
| 	"unsafe" | ||||
| ) | ||||
|  | ||||
| const unsafeAllowed = true | ||||
| // NOTE: These type_Foo functions would more idiomatically be methods, | ||||
| // but Go does not allow methods on pointer types, and we must preserve | ||||
| // some pointer type for the garbage collector. We use these | ||||
| // funcs with clunky names as our poor approximation to methods. | ||||
| // | ||||
| // An alternative would be | ||||
| //	type structPointer struct { p unsafe.Pointer } | ||||
| // but that does not registerize as well. | ||||
|  | ||||
| // A field identifies a field in a struct, accessible from a pointer. | ||||
| // A structPointer is a pointer to a struct. | ||||
| type structPointer unsafe.Pointer | ||||
|  | ||||
| // toStructPointer returns a structPointer equivalent to the given reflect value. | ||||
| func toStructPointer(v reflect.Value) structPointer { | ||||
| 	return structPointer(unsafe.Pointer(v.Pointer())) | ||||
| } | ||||
|  | ||||
| // IsNil reports whether p is nil. | ||||
| func structPointer_IsNil(p structPointer) bool { | ||||
| 	return p == nil | ||||
| } | ||||
|  | ||||
| // Interface returns the struct pointer, assumed to have element type t, | ||||
| // as an interface value. | ||||
| func structPointer_Interface(p structPointer, t reflect.Type) interface{} { | ||||
| 	return reflect.NewAt(t, unsafe.Pointer(p)).Interface() | ||||
| } | ||||
|  | ||||
| // A field identifies a field in a struct, accessible from a structPointer. | ||||
| // In this implementation, a field is identified by its byte offset from the start of the struct. | ||||
| type field uintptr | ||||
|  | ||||
| @@ -55,254 +80,191 @@ func toField(f *reflect.StructField) field { | ||||
| // invalidField is an invalid field identifier. | ||||
| const invalidField = ^field(0) | ||||
|  | ||||
| // zeroField is a noop when calling pointer.offset. | ||||
| const zeroField = field(0) | ||||
|  | ||||
| // IsValid reports whether the field identifier is valid. | ||||
| func (f field) IsValid() bool { | ||||
| 	return f != invalidField | ||||
| 	return f != ^field(0) | ||||
| } | ||||
|  | ||||
| // The pointer type below is for the new table-driven encoder/decoder. | ||||
| // The implementation here uses unsafe.Pointer to create a generic pointer. | ||||
| // In pointer_reflect.go we use reflect instead of unsafe to implement | ||||
| // the same (but slower) interface. | ||||
| type pointer struct { | ||||
| 	p unsafe.Pointer | ||||
| // Bytes returns the address of a []byte field in the struct. | ||||
| func structPointer_Bytes(p structPointer, f field) *[]byte { | ||||
| 	return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // size of pointer | ||||
| var ptrSize = unsafe.Sizeof(uintptr(0)) | ||||
|  | ||||
| // toPointer converts an interface of pointer type to a pointer | ||||
| // that points to the same target. | ||||
| func toPointer(i *Message) pointer { | ||||
| 	// Super-tricky - read pointer out of data word of interface value. | ||||
| 	// Saves ~25ns over the equivalent: | ||||
| 	// return valToPointer(reflect.ValueOf(*i)) | ||||
| 	return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} | ||||
| // BytesSlice returns the address of a [][]byte field in the struct. | ||||
| func structPointer_BytesSlice(p structPointer, f field) *[][]byte { | ||||
| 	return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // toAddrPointer converts an interface to a pointer that points to | ||||
| // the interface data. | ||||
| func toAddrPointer(i *interface{}, isptr bool) pointer { | ||||
| 	// Super-tricky - read or get the address of data word of interface value. | ||||
| 	if isptr { | ||||
| 		// The interface is of pointer type, thus it is a direct interface. | ||||
| 		// The data word is the pointer data itself. We take its address. | ||||
| 		return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} | ||||
| // Bool returns the address of a *bool field in the struct. | ||||
| func structPointer_Bool(p structPointer, f field) **bool { | ||||
| 	return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // BoolVal returns the address of a bool field in the struct. | ||||
| func structPointer_BoolVal(p structPointer, f field) *bool { | ||||
| 	return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // BoolSlice returns the address of a []bool field in the struct. | ||||
| func structPointer_BoolSlice(p structPointer, f field) *[]bool { | ||||
| 	return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // String returns the address of a *string field in the struct. | ||||
| func structPointer_String(p structPointer, f field) **string { | ||||
| 	return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // StringVal returns the address of a string field in the struct. | ||||
| func structPointer_StringVal(p structPointer, f field) *string { | ||||
| 	return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // StringSlice returns the address of a []string field in the struct. | ||||
| func structPointer_StringSlice(p structPointer, f field) *[]string { | ||||
| 	return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // ExtMap returns the address of an extension map field in the struct. | ||||
| func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions { | ||||
| 	return (*XXX_InternalExtensions)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { | ||||
| 	return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // NewAt returns the reflect.Value for a pointer to a field in the struct. | ||||
| func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { | ||||
| 	return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f))) | ||||
| } | ||||
|  | ||||
| // SetStructPointer writes a *struct field in the struct. | ||||
| func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { | ||||
| 	*(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q | ||||
| } | ||||
|  | ||||
| // GetStructPointer reads a *struct field in the struct. | ||||
| func structPointer_GetStructPointer(p structPointer, f field) structPointer { | ||||
| 	return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // StructPointerSlice the address of a []*struct field in the struct. | ||||
| func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice { | ||||
| 	return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups). | ||||
| type structPointerSlice []structPointer | ||||
|  | ||||
| func (v *structPointerSlice) Len() int                  { return len(*v) } | ||||
| func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] } | ||||
| func (v *structPointerSlice) Append(p structPointer)    { *v = append(*v, p) } | ||||
|  | ||||
| // A word32 is the address of a "pointer to 32-bit value" field. | ||||
| type word32 **uint32 | ||||
|  | ||||
| // IsNil reports whether *v is nil. | ||||
| func word32_IsNil(p word32) bool { | ||||
| 	return *p == nil | ||||
| } | ||||
|  | ||||
| // Set sets *v to point at a newly allocated word set to x. | ||||
| func word32_Set(p word32, o *Buffer, x uint32) { | ||||
| 	if len(o.uint32s) == 0 { | ||||
| 		o.uint32s = make([]uint32, uint32PoolSize) | ||||
| 	} | ||||
| 	// The interface is not of pointer type. The data word is the pointer | ||||
| 	// to the data. | ||||
| 	return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} | ||||
| 	o.uint32s[0] = x | ||||
| 	*p = &o.uint32s[0] | ||||
| 	o.uint32s = o.uint32s[1:] | ||||
| } | ||||
|  | ||||
| // valToPointer converts v to a pointer. v must be of pointer type. | ||||
| func valToPointer(v reflect.Value) pointer { | ||||
| 	return pointer{p: unsafe.Pointer(v.Pointer())} | ||||
| // Get gets the value pointed at by *v. | ||||
| func word32_Get(p word32) uint32 { | ||||
| 	return **p | ||||
| } | ||||
|  | ||||
| // offset converts from a pointer to a structure to a pointer to | ||||
| // one of its fields. | ||||
| func (p pointer) offset(f field) pointer { | ||||
| 	// For safety, we should panic if !f.IsValid, however calling panic causes | ||||
| 	// this to no longer be inlineable, which is a serious performance cost. | ||||
| 	/* | ||||
| 		if !f.IsValid() { | ||||
| 			panic("invalid field") | ||||
| 		} | ||||
| 	*/ | ||||
| 	return pointer{p: unsafe.Pointer(uintptr(p.p) + uintptr(f))} | ||||
| // Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct. | ||||
| func structPointer_Word32(p structPointer, f field) word32 { | ||||
| 	return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) | ||||
| } | ||||
|  | ||||
| func (p pointer) isNil() bool { | ||||
| 	return p.p == nil | ||||
| // A word32Val is the address of a 32-bit value field. | ||||
| type word32Val *uint32 | ||||
|  | ||||
| // Set sets *p to x. | ||||
| func word32Val_Set(p word32Val, x uint32) { | ||||
| 	*p = x | ||||
| } | ||||
|  | ||||
| func (p pointer) toInt64() *int64 { | ||||
| 	return (*int64)(p.p) | ||||
| } | ||||
| func (p pointer) toInt64Ptr() **int64 { | ||||
| 	return (**int64)(p.p) | ||||
| } | ||||
| func (p pointer) toInt64Slice() *[]int64 { | ||||
| 	return (*[]int64)(p.p) | ||||
| } | ||||
| func (p pointer) toInt32() *int32 { | ||||
| 	return (*int32)(p.p) | ||||
| // Get gets the value pointed at by p. | ||||
| func word32Val_Get(p word32Val) uint32 { | ||||
| 	return *p | ||||
| } | ||||
|  | ||||
| // See pointer_reflect.go for why toInt32Ptr/Slice doesn't exist. | ||||
| /* | ||||
| 	func (p pointer) toInt32Ptr() **int32 { | ||||
| 		return (**int32)(p.p) | ||||
| // Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct. | ||||
| func structPointer_Word32Val(p structPointer, f field) word32Val { | ||||
| 	return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) | ||||
| } | ||||
|  | ||||
| // A word32Slice is a slice of 32-bit values. | ||||
| type word32Slice []uint32 | ||||
|  | ||||
| func (v *word32Slice) Append(x uint32)    { *v = append(*v, x) } | ||||
| func (v *word32Slice) Len() int           { return len(*v) } | ||||
| func (v *word32Slice) Index(i int) uint32 { return (*v)[i] } | ||||
|  | ||||
| // Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct. | ||||
| func structPointer_Word32Slice(p structPointer, f field) *word32Slice { | ||||
| 	return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| // word64 is like word32 but for 64-bit values. | ||||
| type word64 **uint64 | ||||
|  | ||||
| func word64_Set(p word64, o *Buffer, x uint64) { | ||||
| 	if len(o.uint64s) == 0 { | ||||
| 		o.uint64s = make([]uint64, uint64PoolSize) | ||||
| 	} | ||||
| 	func (p pointer) toInt32Slice() *[]int32 { | ||||
| 		return (*[]int32)(p.p) | ||||
| 	} | ||||
| */ | ||||
| func (p pointer) getInt32Ptr() *int32 { | ||||
| 	return *(**int32)(p.p) | ||||
| } | ||||
| func (p pointer) setInt32Ptr(v int32) { | ||||
| 	*(**int32)(p.p) = &v | ||||
| 	o.uint64s[0] = x | ||||
| 	*p = &o.uint64s[0] | ||||
| 	o.uint64s = o.uint64s[1:] | ||||
| } | ||||
|  | ||||
| // getInt32Slice loads a []int32 from p. | ||||
| // The value returned is aliased with the original slice. | ||||
| // This behavior differs from the implementation in pointer_reflect.go. | ||||
| func (p pointer) getInt32Slice() []int32 { | ||||
| 	return *(*[]int32)(p.p) | ||||
| func word64_IsNil(p word64) bool { | ||||
| 	return *p == nil | ||||
| } | ||||
|  | ||||
| // setInt32Slice stores a []int32 to p. | ||||
| // The value set is aliased with the input slice. | ||||
| // This behavior differs from the implementation in pointer_reflect.go. | ||||
| func (p pointer) setInt32Slice(v []int32) { | ||||
| 	*(*[]int32)(p.p) = v | ||||
| func word64_Get(p word64) uint64 { | ||||
| 	return **p | ||||
| } | ||||
|  | ||||
| // TODO: Can we get rid of appendInt32Slice and use setInt32Slice instead? | ||||
| func (p pointer) appendInt32Slice(v int32) { | ||||
| 	s := (*[]int32)(p.p) | ||||
| 	*s = append(*s, v) | ||||
| func structPointer_Word64(p structPointer, f field) word64 { | ||||
| 	return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) | ||||
| } | ||||
|  | ||||
| func (p pointer) toUint64() *uint64 { | ||||
| 	return (*uint64)(p.p) | ||||
| } | ||||
| func (p pointer) toUint64Ptr() **uint64 { | ||||
| 	return (**uint64)(p.p) | ||||
| } | ||||
| func (p pointer) toUint64Slice() *[]uint64 { | ||||
| 	return (*[]uint64)(p.p) | ||||
| } | ||||
| func (p pointer) toUint32() *uint32 { | ||||
| 	return (*uint32)(p.p) | ||||
| } | ||||
| func (p pointer) toUint32Ptr() **uint32 { | ||||
| 	return (**uint32)(p.p) | ||||
| } | ||||
| func (p pointer) toUint32Slice() *[]uint32 { | ||||
| 	return (*[]uint32)(p.p) | ||||
| } | ||||
| func (p pointer) toBool() *bool { | ||||
| 	return (*bool)(p.p) | ||||
| } | ||||
| func (p pointer) toBoolPtr() **bool { | ||||
| 	return (**bool)(p.p) | ||||
| } | ||||
| func (p pointer) toBoolSlice() *[]bool { | ||||
| 	return (*[]bool)(p.p) | ||||
| } | ||||
| func (p pointer) toFloat64() *float64 { | ||||
| 	return (*float64)(p.p) | ||||
| } | ||||
| func (p pointer) toFloat64Ptr() **float64 { | ||||
| 	return (**float64)(p.p) | ||||
| } | ||||
| func (p pointer) toFloat64Slice() *[]float64 { | ||||
| 	return (*[]float64)(p.p) | ||||
| } | ||||
| func (p pointer) toFloat32() *float32 { | ||||
| 	return (*float32)(p.p) | ||||
| } | ||||
| func (p pointer) toFloat32Ptr() **float32 { | ||||
| 	return (**float32)(p.p) | ||||
| } | ||||
| func (p pointer) toFloat32Slice() *[]float32 { | ||||
| 	return (*[]float32)(p.p) | ||||
| } | ||||
| func (p pointer) toString() *string { | ||||
| 	return (*string)(p.p) | ||||
| } | ||||
| func (p pointer) toStringPtr() **string { | ||||
| 	return (**string)(p.p) | ||||
| } | ||||
| func (p pointer) toStringSlice() *[]string { | ||||
| 	return (*[]string)(p.p) | ||||
| } | ||||
| func (p pointer) toBytes() *[]byte { | ||||
| 	return (*[]byte)(p.p) | ||||
| } | ||||
| func (p pointer) toBytesSlice() *[][]byte { | ||||
| 	return (*[][]byte)(p.p) | ||||
| } | ||||
| func (p pointer) toExtensions() *XXX_InternalExtensions { | ||||
| 	return (*XXX_InternalExtensions)(p.p) | ||||
| } | ||||
| func (p pointer) toOldExtensions() *map[int32]Extension { | ||||
| 	return (*map[int32]Extension)(p.p) | ||||
| // word64Val is like word32Val but for 64-bit values. | ||||
| type word64Val *uint64 | ||||
|  | ||||
| func word64Val_Set(p word64Val, o *Buffer, x uint64) { | ||||
| 	*p = x | ||||
| } | ||||
|  | ||||
| // getPointerSlice loads []*T from p as a []pointer. | ||||
| // The value returned is aliased with the original slice. | ||||
| // This behavior differs from the implementation in pointer_reflect.go. | ||||
| func (p pointer) getPointerSlice() []pointer { | ||||
| 	// Super-tricky - p should point to a []*T where T is a | ||||
| 	// message type. We load it as []pointer. | ||||
| 	return *(*[]pointer)(p.p) | ||||
| func word64Val_Get(p word64Val) uint64 { | ||||
| 	return *p | ||||
| } | ||||
|  | ||||
| // setPointerSlice stores []pointer into p as a []*T. | ||||
| // The value set is aliased with the input slice. | ||||
| // This behavior differs from the implementation in pointer_reflect.go. | ||||
| func (p pointer) setPointerSlice(v []pointer) { | ||||
| 	// Super-tricky - p should point to a []*T where T is a | ||||
| 	// message type. We store it as []pointer. | ||||
| 	*(*[]pointer)(p.p) = v | ||||
| func structPointer_Word64Val(p structPointer, f field) word64Val { | ||||
| 	return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) | ||||
| } | ||||
|  | ||||
| // getPointer loads the pointer at p and returns it. | ||||
| func (p pointer) getPointer() pointer { | ||||
| 	return pointer{p: *(*unsafe.Pointer)(p.p)} | ||||
| } | ||||
| // word64Slice is like word32Slice but for 64-bit values. | ||||
| type word64Slice []uint64 | ||||
|  | ||||
| // setPointer stores the pointer q at p. | ||||
| func (p pointer) setPointer(q pointer) { | ||||
| 	*(*unsafe.Pointer)(p.p) = q.p | ||||
| } | ||||
| func (v *word64Slice) Append(x uint64)    { *v = append(*v, x) } | ||||
| func (v *word64Slice) Len() int           { return len(*v) } | ||||
| func (v *word64Slice) Index(i int) uint64 { return (*v)[i] } | ||||
|  | ||||
| // append q to the slice pointed to by p. | ||||
| func (p pointer) appendPointer(q pointer) { | ||||
| 	s := (*[]unsafe.Pointer)(p.p) | ||||
| 	*s = append(*s, q.p) | ||||
| } | ||||
|  | ||||
| // getInterfacePointer returns a pointer that points to the | ||||
| // interface data of the interface pointed by p. | ||||
| func (p pointer) getInterfacePointer() pointer { | ||||
| 	// Super-tricky - read pointer out of data word of interface value. | ||||
| 	return pointer{p: (*(*[2]unsafe.Pointer)(p.p))[1]} | ||||
| } | ||||
|  | ||||
| // asPointerTo returns a reflect.Value that is a pointer to an | ||||
| // object of type t stored at p. | ||||
| func (p pointer) asPointerTo(t reflect.Type) reflect.Value { | ||||
| 	return reflect.NewAt(t, p.p) | ||||
| } | ||||
|  | ||||
| func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo { | ||||
| 	return (*unmarshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) | ||||
| } | ||||
| func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) { | ||||
| 	atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) | ||||
| } | ||||
| func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo { | ||||
| 	return (*marshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) | ||||
| } | ||||
| func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) { | ||||
| 	atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) | ||||
| } | ||||
| func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo { | ||||
| 	return (*mergeInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) | ||||
| } | ||||
| func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) { | ||||
| 	atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) | ||||
| } | ||||
| func atomicLoadDiscardInfo(p **discardInfo) *discardInfo { | ||||
| 	return (*discardInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p)))) | ||||
| } | ||||
| func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) { | ||||
| 	atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v)) | ||||
| func structPointer_Word64Slice(p structPointer, f field) *word64Slice { | ||||
| 	return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|   | ||||
							
								
								
									
										100
									
								
								vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										100
									
								
								vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| // Protocol Buffers for Go with Gadgets | ||||
| // | ||||
| // Copyright (c) 2018, The GoGo Authors. All rights reserved. | ||||
| // Copyright (c) 2013, The GoGo Authors. All rights reserved. | ||||
| // http://github.com/gogo/protobuf | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| @@ -26,7 +26,7 @@ | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| // +build !purego,!appengine,!js | ||||
| // +build !appengine,!js | ||||
|  | ||||
| // This file contains the implementation of the proto field accesses using package unsafe. | ||||
|  | ||||
| @@ -37,20 +37,92 @@ import ( | ||||
| 	"unsafe" | ||||
| ) | ||||
|  | ||||
| func (p pointer) getRef() pointer { | ||||
| 	return pointer{p: (unsafe.Pointer)(&p.p)} | ||||
| func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} { | ||||
| 	point := unsafe.Pointer(uintptr(p) + uintptr(f)) | ||||
| 	r := reflect.NewAt(t, point) | ||||
| 	return r.Interface() | ||||
| } | ||||
|  | ||||
| func (p pointer) appendRef(v pointer, typ reflect.Type) { | ||||
| 	slice := p.getSlice(typ) | ||||
| 	elem := v.asPointerTo(typ).Elem() | ||||
| 	newSlice := reflect.Append(slice, elem) | ||||
| 	slice.Set(newSlice) | ||||
| func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} { | ||||
| 	point := unsafe.Pointer(uintptr(p) + uintptr(f)) | ||||
| 	r := reflect.NewAt(t, point) | ||||
| 	if r.Elem().IsNil() { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return r.Elem().Interface() | ||||
| } | ||||
|  | ||||
| func (p pointer) getSlice(typ reflect.Type) reflect.Value { | ||||
| 	sliceTyp := reflect.SliceOf(typ) | ||||
| 	slice := p.asPointerTo(sliceTyp) | ||||
| 	slice = slice.Elem() | ||||
| 	return slice | ||||
| func copyUintPtr(oldptr, newptr uintptr, size int) { | ||||
| 	oldbytes := make([]byte, 0) | ||||
| 	oldslice := (*reflect.SliceHeader)(unsafe.Pointer(&oldbytes)) | ||||
| 	oldslice.Data = oldptr | ||||
| 	oldslice.Len = size | ||||
| 	oldslice.Cap = size | ||||
| 	newbytes := make([]byte, 0) | ||||
| 	newslice := (*reflect.SliceHeader)(unsafe.Pointer(&newbytes)) | ||||
| 	newslice.Data = newptr | ||||
| 	newslice.Len = size | ||||
| 	newslice.Cap = size | ||||
| 	copy(newbytes, oldbytes) | ||||
| } | ||||
|  | ||||
| func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) { | ||||
| 	copyUintPtr(uintptr(oldptr), uintptr(newptr), size) | ||||
| } | ||||
|  | ||||
| func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer { | ||||
| 	size := typ.Elem().Size() | ||||
|  | ||||
| 	oldHeader := structPointer_GetSliceHeader(base, f) | ||||
| 	oldSlice := reflect.NewAt(typ, unsafe.Pointer(oldHeader)).Elem() | ||||
| 	newLen := oldHeader.Len + 1 | ||||
| 	newSlice := reflect.MakeSlice(typ, newLen, newLen) | ||||
| 	reflect.Copy(newSlice, oldSlice) | ||||
| 	bas := toStructPointer(newSlice) | ||||
| 	oldHeader.Data = uintptr(bas) | ||||
| 	oldHeader.Len = newLen | ||||
| 	oldHeader.Cap = newLen | ||||
|  | ||||
| 	return structPointer(unsafe.Pointer(uintptr(unsafe.Pointer(bas)) + uintptr(uintptr(newLen-1)*size))) | ||||
| } | ||||
|  | ||||
| func structPointer_FieldPointer(p structPointer, f field) structPointer { | ||||
| 	return structPointer(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| func structPointer_GetRefStructPointer(p structPointer, f field) structPointer { | ||||
| 	return structPointer((*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f)))) | ||||
| } | ||||
|  | ||||
| func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader { | ||||
| 	return (*reflect.SliceHeader)(unsafe.Pointer(uintptr(p) + uintptr(f))) | ||||
| } | ||||
|  | ||||
| func structPointer_Add(p structPointer, size field) structPointer { | ||||
| 	return structPointer(unsafe.Pointer(uintptr(p) + uintptr(size))) | ||||
| } | ||||
|  | ||||
| func structPointer_Len(p structPointer, f field) int { | ||||
| 	return len(*(*[]interface{})(unsafe.Pointer(structPointer_GetRefStructPointer(p, f)))) | ||||
| } | ||||
|  | ||||
| func structPointer_StructRefSlice(p structPointer, f field, size uintptr) *structRefSlice { | ||||
| 	return &structRefSlice{p: p, f: f, size: size} | ||||
| } | ||||
|  | ||||
| // A structRefSlice represents a slice of structs (themselves submessages or groups). | ||||
| type structRefSlice struct { | ||||
| 	p    structPointer | ||||
| 	f    field | ||||
| 	size uintptr | ||||
| } | ||||
|  | ||||
| func (v *structRefSlice) Len() int { | ||||
| 	return structPointer_Len(v.p, v.f) | ||||
| } | ||||
|  | ||||
| func (v *structRefSlice) Index(i int) structPointer { | ||||
| 	ss := structPointer_GetStructPointer(v.p, v.f) | ||||
| 	ss1 := structPointer_GetRefStructPointer(ss, 0) | ||||
| 	return structPointer_Add(ss1, field(uintptr(i)*v.size)) | ||||
| } | ||||
|   | ||||
							
								
								
									
										588
									
								
								vendor/github.com/gogo/protobuf/proto/properties.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										588
									
								
								vendor/github.com/gogo/protobuf/proto/properties.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -43,6 +43,7 @@ package proto | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"log" | ||||
| 	"os" | ||||
| 	"reflect" | ||||
| 	"sort" | ||||
| 	"strconv" | ||||
| @@ -62,6 +63,42 @@ const ( | ||||
| 	WireFixed32    = 5 | ||||
| ) | ||||
|  | ||||
| const startSize = 10 // initial slice/string sizes | ||||
|  | ||||
| // Encoders are defined in encode.go | ||||
| // An encoder outputs the full representation of a field, including its | ||||
| // tag and encoder type. | ||||
| type encoder func(p *Buffer, prop *Properties, base structPointer) error | ||||
|  | ||||
| // A valueEncoder encodes a single integer in a particular encoding. | ||||
| type valueEncoder func(o *Buffer, x uint64) error | ||||
|  | ||||
| // Sizers are defined in encode.go | ||||
| // A sizer returns the encoded size of a field, including its tag and encoder | ||||
| // type. | ||||
| type sizer func(prop *Properties, base structPointer) int | ||||
|  | ||||
| // A valueSizer returns the encoded size of a single integer in a particular | ||||
| // encoding. | ||||
| type valueSizer func(x uint64) int | ||||
|  | ||||
| // Decoders are defined in decode.go | ||||
| // A decoder creates a value from its wire representation. | ||||
| // Unrecognized subelements are saved in unrec. | ||||
| type decoder func(p *Buffer, prop *Properties, base structPointer) error | ||||
|  | ||||
| // A valueDecoder decodes a single integer in a particular encoding. | ||||
| type valueDecoder func(o *Buffer) (x uint64, err error) | ||||
|  | ||||
| // A oneofMarshaler does the marshaling for all oneof fields in a message. | ||||
| type oneofMarshaler func(Message, *Buffer) error | ||||
|  | ||||
| // A oneofUnmarshaler does the unmarshaling for a oneof field in a message. | ||||
| type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error) | ||||
|  | ||||
| // A oneofSizer does the sizing for all oneof fields in a message. | ||||
| type oneofSizer func(Message) int | ||||
|  | ||||
| // tagMap is an optimization over map[int]int for typical protocol buffer | ||||
| // use-cases. Encoded protocol buffers are often in tag order with small tag | ||||
| // numbers. | ||||
| @@ -108,6 +145,13 @@ type StructProperties struct { | ||||
| 	decoderTags      tagMap         // map from proto tag to struct field number | ||||
| 	decoderOrigNames map[string]int // map from original name to struct field number | ||||
| 	order            []int          // list of struct field numbers in tag order | ||||
| 	unrecField       field          // field id of the XXX_unrecognized []byte field | ||||
| 	extendable       bool           // is this an extendable proto | ||||
|  | ||||
| 	oneofMarshaler   oneofMarshaler | ||||
| 	oneofUnmarshaler oneofUnmarshaler | ||||
| 	oneofSizer       oneofSizer | ||||
| 	stype            reflect.Type | ||||
|  | ||||
| 	// OneofTypes contains information about the oneof fields in this message. | ||||
| 	// It is keyed by the original name of a field. | ||||
| @@ -143,30 +187,45 @@ type Properties struct { | ||||
| 	Repeated bool | ||||
| 	Packed   bool   // relevant for repeated primitives only | ||||
| 	Enum     string // set for enum types only | ||||
| 	proto3   bool   // whether this is known to be a proto3 field | ||||
| 	proto3   bool   // whether this is known to be a proto3 field; set for []byte only | ||||
| 	oneof    bool   // whether this is a oneof field | ||||
|  | ||||
| 	Default     string // default value | ||||
| 	HasDefault  bool   // whether an explicit default was provided | ||||
| 	CustomType  string | ||||
| 	CastType    string | ||||
| 	StdTime     bool | ||||
| 	StdDuration bool | ||||
| 	WktPointer  bool | ||||
|  | ||||
| 	stype reflect.Type      // set for struct types only | ||||
| 	ctype reflect.Type      // set for custom types only | ||||
| 	sprop *StructProperties // set for struct types only | ||||
| 	enc           encoder | ||||
| 	valEnc        valueEncoder // set for bool and numeric types only | ||||
| 	field         field | ||||
| 	tagcode       []byte // encoding of EncodeVarint((Tag<<3)|WireType) | ||||
| 	tagbuf        [8]byte | ||||
| 	stype         reflect.Type      // set for struct types only | ||||
| 	sstype        reflect.Type      // set for slices of structs types only | ||||
| 	ctype         reflect.Type      // set for custom types only | ||||
| 	sprop         *StructProperties // set for struct types only | ||||
| 	isMarshaler   bool | ||||
| 	isUnmarshaler bool | ||||
|  | ||||
| 	mtype      reflect.Type // set for map types only | ||||
| 	MapKeyProp *Properties  // set for map types only | ||||
| 	MapValProp *Properties  // set for map types only | ||||
| 	mtype    reflect.Type // set for map types only | ||||
| 	mkeyprop *Properties  // set for map types only | ||||
| 	mvalprop *Properties  // set for map types only | ||||
|  | ||||
| 	size    sizer | ||||
| 	valSize valueSizer // set for bool and numeric types only | ||||
|  | ||||
| 	dec    decoder | ||||
| 	valDec valueDecoder // set for bool and numeric types only | ||||
|  | ||||
| 	// If this is a packable field, this will be the decoder for the packed version of the field. | ||||
| 	packedDec decoder | ||||
| } | ||||
|  | ||||
| // String formats the properties in the protobuf struct field tag style. | ||||
| func (p *Properties) String() string { | ||||
| 	s := p.Wire | ||||
| 	s += "," | ||||
| 	s = "," | ||||
| 	s += strconv.Itoa(p.Tag) | ||||
| 	if p.Required { | ||||
| 		s += ",req" | ||||
| @@ -204,7 +263,7 @@ func (p *Properties) Parse(s string) { | ||||
| 	// "bytes,49,opt,name=foo,def=hello!" | ||||
| 	fields := strings.Split(s, ",") // breaks def=, but handled below. | ||||
| 	if len(fields) < 2 { | ||||
| 		log.Printf("proto: tag has too few fields: %q", s) | ||||
| 		fmt.Fprintf(os.Stderr, "proto: tag has too few fields: %q\n", s) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| @@ -212,19 +271,34 @@ func (p *Properties) Parse(s string) { | ||||
| 	switch p.Wire { | ||||
| 	case "varint": | ||||
| 		p.WireType = WireVarint | ||||
| 		p.valEnc = (*Buffer).EncodeVarint | ||||
| 		p.valDec = (*Buffer).DecodeVarint | ||||
| 		p.valSize = sizeVarint | ||||
| 	case "fixed32": | ||||
| 		p.WireType = WireFixed32 | ||||
| 		p.valEnc = (*Buffer).EncodeFixed32 | ||||
| 		p.valDec = (*Buffer).DecodeFixed32 | ||||
| 		p.valSize = sizeFixed32 | ||||
| 	case "fixed64": | ||||
| 		p.WireType = WireFixed64 | ||||
| 		p.valEnc = (*Buffer).EncodeFixed64 | ||||
| 		p.valDec = (*Buffer).DecodeFixed64 | ||||
| 		p.valSize = sizeFixed64 | ||||
| 	case "zigzag32": | ||||
| 		p.WireType = WireVarint | ||||
| 		p.valEnc = (*Buffer).EncodeZigzag32 | ||||
| 		p.valDec = (*Buffer).DecodeZigzag32 | ||||
| 		p.valSize = sizeZigzag32 | ||||
| 	case "zigzag64": | ||||
| 		p.WireType = WireVarint | ||||
| 		p.valEnc = (*Buffer).EncodeZigzag64 | ||||
| 		p.valDec = (*Buffer).DecodeZigzag64 | ||||
| 		p.valSize = sizeZigzag64 | ||||
| 	case "bytes", "group": | ||||
| 		p.WireType = WireBytes | ||||
| 		// no numeric converter for non-numeric types | ||||
| 	default: | ||||
| 		log.Printf("proto: tag has unknown wire type: %q", s) | ||||
| 		fmt.Fprintf(os.Stderr, "proto: tag has unknown wire type: %q\n", s) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| @@ -234,7 +308,6 @@ func (p *Properties) Parse(s string) { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| outer: | ||||
| 	for i := 2; i < len(fields); i++ { | ||||
| 		f := fields[i] | ||||
| 		switch { | ||||
| @@ -262,70 +335,311 @@ outer: | ||||
| 			if i+1 < len(fields) { | ||||
| 				// Commas aren't escaped, and def is always last. | ||||
| 				p.Default += "," + strings.Join(fields[i+1:], ",") | ||||
| 				break outer | ||||
| 				break | ||||
| 			} | ||||
| 		case strings.HasPrefix(f, "embedded="): | ||||
| 			p.OrigName = strings.Split(f, "=")[1] | ||||
| 		case strings.HasPrefix(f, "customtype="): | ||||
| 			p.CustomType = strings.Split(f, "=")[1] | ||||
| 		case strings.HasPrefix(f, "casttype="): | ||||
| 			p.CastType = strings.Split(f, "=")[1] | ||||
| 		case f == "stdtime": | ||||
| 			p.StdTime = true | ||||
| 		case f == "stdduration": | ||||
| 			p.StdDuration = true | ||||
| 		case f == "wktptr": | ||||
| 			p.WktPointer = true | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func logNoSliceEnc(t1, t2 reflect.Type) { | ||||
| 	fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2) | ||||
| } | ||||
|  | ||||
| var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem() | ||||
|  | ||||
| // setFieldProps initializes the field properties for submessages and maps. | ||||
| func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { | ||||
| // Initialize the fields for encoding and decoding. | ||||
| func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { | ||||
| 	p.enc = nil | ||||
| 	p.dec = nil | ||||
| 	p.size = nil | ||||
| 	isMap := typ.Kind() == reflect.Map | ||||
| 	if len(p.CustomType) > 0 && !isMap { | ||||
| 		p.ctype = typ | ||||
| 		p.setCustomEncAndDec(typ) | ||||
| 		p.setTag(lockGetProp) | ||||
| 		return | ||||
| 	} | ||||
| 	if p.StdTime && !isMap { | ||||
| 		p.setTimeEncAndDec(typ) | ||||
| 		p.setTag(lockGetProp) | ||||
| 		return | ||||
| 	} | ||||
| 	if p.StdDuration && !isMap { | ||||
| 		p.setTag(lockGetProp) | ||||
| 		return | ||||
| 	} | ||||
| 	if p.WktPointer && !isMap { | ||||
| 		p.setDurationEncAndDec(typ) | ||||
| 		p.setTag(lockGetProp) | ||||
| 		return | ||||
| 	} | ||||
| 	switch t1 := typ; t1.Kind() { | ||||
| 	default: | ||||
| 		fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1) | ||||
|  | ||||
| 	// proto3 scalar types | ||||
|  | ||||
| 	case reflect.Bool: | ||||
| 		if p.proto3 { | ||||
| 			p.enc = (*Buffer).enc_proto3_bool | ||||
| 			p.dec = (*Buffer).dec_proto3_bool | ||||
| 			p.size = size_proto3_bool | ||||
| 		} else { | ||||
| 			p.enc = (*Buffer).enc_ref_bool | ||||
| 			p.dec = (*Buffer).dec_proto3_bool | ||||
| 			p.size = size_ref_bool | ||||
| 		} | ||||
| 	case reflect.Int32: | ||||
| 		if p.proto3 { | ||||
| 			p.enc = (*Buffer).enc_proto3_int32 | ||||
| 			p.dec = (*Buffer).dec_proto3_int32 | ||||
| 			p.size = size_proto3_int32 | ||||
| 		} else { | ||||
| 			p.enc = (*Buffer).enc_ref_int32 | ||||
| 			p.dec = (*Buffer).dec_proto3_int32 | ||||
| 			p.size = size_ref_int32 | ||||
| 		} | ||||
| 	case reflect.Uint32: | ||||
| 		if p.proto3 { | ||||
| 			p.enc = (*Buffer).enc_proto3_uint32 | ||||
| 			p.dec = (*Buffer).dec_proto3_int32 // can reuse | ||||
| 			p.size = size_proto3_uint32 | ||||
| 		} else { | ||||
| 			p.enc = (*Buffer).enc_ref_uint32 | ||||
| 			p.dec = (*Buffer).dec_proto3_int32 // can reuse | ||||
| 			p.size = size_ref_uint32 | ||||
| 		} | ||||
| 	case reflect.Int64, reflect.Uint64: | ||||
| 		if p.proto3 { | ||||
| 			p.enc = (*Buffer).enc_proto3_int64 | ||||
| 			p.dec = (*Buffer).dec_proto3_int64 | ||||
| 			p.size = size_proto3_int64 | ||||
| 		} else { | ||||
| 			p.enc = (*Buffer).enc_ref_int64 | ||||
| 			p.dec = (*Buffer).dec_proto3_int64 | ||||
| 			p.size = size_ref_int64 | ||||
| 		} | ||||
| 	case reflect.Float32: | ||||
| 		if p.proto3 { | ||||
| 			p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits | ||||
| 			p.dec = (*Buffer).dec_proto3_int32 | ||||
| 			p.size = size_proto3_uint32 | ||||
| 		} else { | ||||
| 			p.enc = (*Buffer).enc_ref_uint32 // can just treat them as bits | ||||
| 			p.dec = (*Buffer).dec_proto3_int32 | ||||
| 			p.size = size_ref_uint32 | ||||
| 		} | ||||
| 	case reflect.Float64: | ||||
| 		if p.proto3 { | ||||
| 			p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits | ||||
| 			p.dec = (*Buffer).dec_proto3_int64 | ||||
| 			p.size = size_proto3_int64 | ||||
| 		} else { | ||||
| 			p.enc = (*Buffer).enc_ref_int64 // can just treat them as bits | ||||
| 			p.dec = (*Buffer).dec_proto3_int64 | ||||
| 			p.size = size_ref_int64 | ||||
| 		} | ||||
| 	case reflect.String: | ||||
| 		if p.proto3 { | ||||
| 			p.enc = (*Buffer).enc_proto3_string | ||||
| 			p.dec = (*Buffer).dec_proto3_string | ||||
| 			p.size = size_proto3_string | ||||
| 		} else { | ||||
| 			p.enc = (*Buffer).enc_ref_string | ||||
| 			p.dec = (*Buffer).dec_proto3_string | ||||
| 			p.size = size_ref_string | ||||
| 		} | ||||
| 	case reflect.Struct: | ||||
| 		p.stype = typ | ||||
| 	case reflect.Ptr: | ||||
| 		if t1.Elem().Kind() == reflect.Struct { | ||||
| 			p.stype = t1.Elem() | ||||
| 		p.isMarshaler = isMarshaler(typ) | ||||
| 		p.isUnmarshaler = isUnmarshaler(typ) | ||||
| 		if p.Wire == "bytes" { | ||||
| 			p.enc = (*Buffer).enc_ref_struct_message | ||||
| 			p.dec = (*Buffer).dec_ref_struct_message | ||||
| 			p.size = size_ref_struct_message | ||||
| 		} else { | ||||
| 			fmt.Fprintf(os.Stderr, "proto: no coders for struct %T\n", typ) | ||||
| 		} | ||||
|  | ||||
| 	case reflect.Ptr: | ||||
| 		switch t2 := t1.Elem(); t2.Kind() { | ||||
| 		default: | ||||
| 			fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2) | ||||
| 			break | ||||
| 		case reflect.Bool: | ||||
| 			p.enc = (*Buffer).enc_bool | ||||
| 			p.dec = (*Buffer).dec_bool | ||||
| 			p.size = size_bool | ||||
| 		case reflect.Int32: | ||||
| 			p.enc = (*Buffer).enc_int32 | ||||
| 			p.dec = (*Buffer).dec_int32 | ||||
| 			p.size = size_int32 | ||||
| 		case reflect.Uint32: | ||||
| 			p.enc = (*Buffer).enc_uint32 | ||||
| 			p.dec = (*Buffer).dec_int32 // can reuse | ||||
| 			p.size = size_uint32 | ||||
| 		case reflect.Int64, reflect.Uint64: | ||||
| 			p.enc = (*Buffer).enc_int64 | ||||
| 			p.dec = (*Buffer).dec_int64 | ||||
| 			p.size = size_int64 | ||||
| 		case reflect.Float32: | ||||
| 			p.enc = (*Buffer).enc_uint32 // can just treat them as bits | ||||
| 			p.dec = (*Buffer).dec_int32 | ||||
| 			p.size = size_uint32 | ||||
| 		case reflect.Float64: | ||||
| 			p.enc = (*Buffer).enc_int64 // can just treat them as bits | ||||
| 			p.dec = (*Buffer).dec_int64 | ||||
| 			p.size = size_int64 | ||||
| 		case reflect.String: | ||||
| 			p.enc = (*Buffer).enc_string | ||||
| 			p.dec = (*Buffer).dec_string | ||||
| 			p.size = size_string | ||||
| 		case reflect.Struct: | ||||
| 			p.stype = t1.Elem() | ||||
| 			p.isMarshaler = isMarshaler(t1) | ||||
| 			p.isUnmarshaler = isUnmarshaler(t1) | ||||
| 			if p.Wire == "bytes" { | ||||
| 				p.enc = (*Buffer).enc_struct_message | ||||
| 				p.dec = (*Buffer).dec_struct_message | ||||
| 				p.size = size_struct_message | ||||
| 			} else { | ||||
| 				p.enc = (*Buffer).enc_struct_group | ||||
| 				p.dec = (*Buffer).dec_struct_group | ||||
| 				p.size = size_struct_group | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 	case reflect.Slice: | ||||
| 		switch t2 := t1.Elem(); t2.Kind() { | ||||
| 		default: | ||||
| 			logNoSliceEnc(t1, t2) | ||||
| 			break | ||||
| 		case reflect.Bool: | ||||
| 			if p.Packed { | ||||
| 				p.enc = (*Buffer).enc_slice_packed_bool | ||||
| 				p.size = size_slice_packed_bool | ||||
| 			} else { | ||||
| 				p.enc = (*Buffer).enc_slice_bool | ||||
| 				p.size = size_slice_bool | ||||
| 			} | ||||
| 			p.dec = (*Buffer).dec_slice_bool | ||||
| 			p.packedDec = (*Buffer).dec_slice_packed_bool | ||||
| 		case reflect.Int32: | ||||
| 			if p.Packed { | ||||
| 				p.enc = (*Buffer).enc_slice_packed_int32 | ||||
| 				p.size = size_slice_packed_int32 | ||||
| 			} else { | ||||
| 				p.enc = (*Buffer).enc_slice_int32 | ||||
| 				p.size = size_slice_int32 | ||||
| 			} | ||||
| 			p.dec = (*Buffer).dec_slice_int32 | ||||
| 			p.packedDec = (*Buffer).dec_slice_packed_int32 | ||||
| 		case reflect.Uint32: | ||||
| 			if p.Packed { | ||||
| 				p.enc = (*Buffer).enc_slice_packed_uint32 | ||||
| 				p.size = size_slice_packed_uint32 | ||||
| 			} else { | ||||
| 				p.enc = (*Buffer).enc_slice_uint32 | ||||
| 				p.size = size_slice_uint32 | ||||
| 			} | ||||
| 			p.dec = (*Buffer).dec_slice_int32 | ||||
| 			p.packedDec = (*Buffer).dec_slice_packed_int32 | ||||
| 		case reflect.Int64, reflect.Uint64: | ||||
| 			if p.Packed { | ||||
| 				p.enc = (*Buffer).enc_slice_packed_int64 | ||||
| 				p.size = size_slice_packed_int64 | ||||
| 			} else { | ||||
| 				p.enc = (*Buffer).enc_slice_int64 | ||||
| 				p.size = size_slice_int64 | ||||
| 			} | ||||
| 			p.dec = (*Buffer).dec_slice_int64 | ||||
| 			p.packedDec = (*Buffer).dec_slice_packed_int64 | ||||
| 		case reflect.Uint8: | ||||
| 			p.dec = (*Buffer).dec_slice_byte | ||||
| 			if p.proto3 { | ||||
| 				p.enc = (*Buffer).enc_proto3_slice_byte | ||||
| 				p.size = size_proto3_slice_byte | ||||
| 			} else { | ||||
| 				p.enc = (*Buffer).enc_slice_byte | ||||
| 				p.size = size_slice_byte | ||||
| 			} | ||||
| 		case reflect.Float32, reflect.Float64: | ||||
| 			switch t2.Bits() { | ||||
| 			case 32: | ||||
| 				// can just treat them as bits | ||||
| 				if p.Packed { | ||||
| 					p.enc = (*Buffer).enc_slice_packed_uint32 | ||||
| 					p.size = size_slice_packed_uint32 | ||||
| 				} else { | ||||
| 					p.enc = (*Buffer).enc_slice_uint32 | ||||
| 					p.size = size_slice_uint32 | ||||
| 				} | ||||
| 				p.dec = (*Buffer).dec_slice_int32 | ||||
| 				p.packedDec = (*Buffer).dec_slice_packed_int32 | ||||
| 			case 64: | ||||
| 				// can just treat them as bits | ||||
| 				if p.Packed { | ||||
| 					p.enc = (*Buffer).enc_slice_packed_int64 | ||||
| 					p.size = size_slice_packed_int64 | ||||
| 				} else { | ||||
| 					p.enc = (*Buffer).enc_slice_int64 | ||||
| 					p.size = size_slice_int64 | ||||
| 				} | ||||
| 				p.dec = (*Buffer).dec_slice_int64 | ||||
| 				p.packedDec = (*Buffer).dec_slice_packed_int64 | ||||
| 			default: | ||||
| 				logNoSliceEnc(t1, t2) | ||||
| 				break | ||||
| 			} | ||||
| 		case reflect.String: | ||||
| 			p.enc = (*Buffer).enc_slice_string | ||||
| 			p.dec = (*Buffer).dec_slice_string | ||||
| 			p.size = size_slice_string | ||||
| 		case reflect.Ptr: | ||||
| 			switch t3 := t2.Elem(); t3.Kind() { | ||||
| 			default: | ||||
| 				fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3) | ||||
| 				break | ||||
| 			case reflect.Struct: | ||||
| 				p.stype = t3 | ||||
| 				p.stype = t2.Elem() | ||||
| 				p.isMarshaler = isMarshaler(t2) | ||||
| 				p.isUnmarshaler = isUnmarshaler(t2) | ||||
| 				if p.Wire == "bytes" { | ||||
| 					p.enc = (*Buffer).enc_slice_struct_message | ||||
| 					p.dec = (*Buffer).dec_slice_struct_message | ||||
| 					p.size = size_slice_struct_message | ||||
| 				} else { | ||||
| 					p.enc = (*Buffer).enc_slice_struct_group | ||||
| 					p.dec = (*Buffer).dec_slice_struct_group | ||||
| 					p.size = size_slice_struct_group | ||||
| 				} | ||||
| 			} | ||||
| 		case reflect.Slice: | ||||
| 			switch t2.Elem().Kind() { | ||||
| 			default: | ||||
| 				fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem()) | ||||
| 				break | ||||
| 			case reflect.Uint8: | ||||
| 				p.enc = (*Buffer).enc_slice_slice_byte | ||||
| 				p.dec = (*Buffer).dec_slice_slice_byte | ||||
| 				p.size = size_slice_slice_byte | ||||
| 			} | ||||
| 		case reflect.Struct: | ||||
| 			p.stype = t2 | ||||
| 			p.setSliceOfNonPointerStructs(t1) | ||||
| 		} | ||||
|  | ||||
| 	case reflect.Map: | ||||
| 		p.enc = (*Buffer).enc_new_map | ||||
| 		p.dec = (*Buffer).dec_new_map | ||||
| 		p.size = size_new_map | ||||
|  | ||||
| 		p.mtype = t1 | ||||
| 		p.MapKeyProp = &Properties{} | ||||
| 		p.MapKeyProp.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp) | ||||
| 		p.MapValProp = &Properties{} | ||||
| 		p.mkeyprop = &Properties{} | ||||
| 		p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp) | ||||
| 		p.mvalprop = &Properties{} | ||||
| 		vtype := p.mtype.Elem() | ||||
| 		if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice { | ||||
| 			// The value type is not a message (*T) or bytes ([]byte), | ||||
| @@ -333,16 +647,29 @@ func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, loc | ||||
| 			vtype = reflect.PtrTo(vtype) | ||||
| 		} | ||||
|  | ||||
| 		p.MapValProp.CustomType = p.CustomType | ||||
| 		p.MapValProp.StdDuration = p.StdDuration | ||||
| 		p.MapValProp.StdTime = p.StdTime | ||||
| 		p.MapValProp.WktPointer = p.WktPointer | ||||
| 		p.MapValProp.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) | ||||
| 		p.mvalprop.CustomType = p.CustomType | ||||
| 		p.mvalprop.StdDuration = p.StdDuration | ||||
| 		p.mvalprop.StdTime = p.StdTime | ||||
| 		p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) | ||||
| 	} | ||||
| 	p.setTag(lockGetProp) | ||||
| } | ||||
|  | ||||
| func (p *Properties) setTag(lockGetProp bool) { | ||||
| 	// precalculate tag code | ||||
| 	wire := p.WireType | ||||
| 	if p.Packed { | ||||
| 		wire = WireBytes | ||||
| 	} | ||||
| 	x := uint32(p.Tag)<<3 | uint32(wire) | ||||
| 	i := 0 | ||||
| 	for i = 0; x > 127; i++ { | ||||
| 		p.tagbuf[i] = 0x80 | uint8(x&0x7F) | ||||
| 		x >>= 7 | ||||
| 	} | ||||
| 	p.tagbuf[i] = uint8(x) | ||||
| 	p.tagcode = p.tagbuf[0 : i+1] | ||||
|  | ||||
| 	if p.stype != nil { | ||||
| 		if lockGetProp { | ||||
| 			p.sprop = GetProperties(p.stype) | ||||
| @@ -353,9 +680,20 @@ func (p *Properties) setTag(lockGetProp bool) { | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() | ||||
| 	marshalerType   = reflect.TypeOf((*Marshaler)(nil)).Elem() | ||||
| 	unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() | ||||
| ) | ||||
|  | ||||
| // isMarshaler reports whether type t implements Marshaler. | ||||
| func isMarshaler(t reflect.Type) bool { | ||||
| 	return t.Implements(marshalerType) | ||||
| } | ||||
|  | ||||
| // isUnmarshaler reports whether type t implements Unmarshaler. | ||||
| func isUnmarshaler(t reflect.Type) bool { | ||||
| 	return t.Implements(unmarshalerType) | ||||
| } | ||||
|  | ||||
| // Init populates the properties from a protocol buffer struct tag. | ||||
| func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { | ||||
| 	p.init(typ, name, tag, f, true) | ||||
| @@ -365,11 +703,14 @@ func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructF | ||||
| 	// "bytes,49,opt,def=hello!" | ||||
| 	p.Name = name | ||||
| 	p.OrigName = name | ||||
| 	if f != nil { | ||||
| 		p.field = toField(f) | ||||
| 	} | ||||
| 	if tag == "" { | ||||
| 		return | ||||
| 	} | ||||
| 	p.Parse(tag) | ||||
| 	p.setFieldProps(typ, f, lockGetProp) | ||||
| 	p.setEncAndDec(typ, f, lockGetProp) | ||||
| } | ||||
|  | ||||
| var ( | ||||
| @@ -390,6 +731,9 @@ func GetProperties(t reflect.Type) *StructProperties { | ||||
| 	sprop, ok := propertiesMap[t] | ||||
| 	propertiesMu.RUnlock() | ||||
| 	if ok { | ||||
| 		if collectStats { | ||||
| 			stats.Chit++ | ||||
| 		} | ||||
| 		return sprop | ||||
| 	} | ||||
|  | ||||
| @@ -399,26 +743,27 @@ func GetProperties(t reflect.Type) *StructProperties { | ||||
| 	return sprop | ||||
| } | ||||
|  | ||||
| type ( | ||||
| 	oneofFuncsIface interface { | ||||
| 		XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) | ||||
| 	} | ||||
| 	oneofWrappersIface interface { | ||||
| 		XXX_OneofWrappers() []interface{} | ||||
| 	} | ||||
| ) | ||||
|  | ||||
| // getPropertiesLocked requires that propertiesMu is held. | ||||
| func getPropertiesLocked(t reflect.Type) *StructProperties { | ||||
| 	if prop, ok := propertiesMap[t]; ok { | ||||
| 		if collectStats { | ||||
| 			stats.Chit++ | ||||
| 		} | ||||
| 		return prop | ||||
| 	} | ||||
| 	if collectStats { | ||||
| 		stats.Cmiss++ | ||||
| 	} | ||||
|  | ||||
| 	prop := new(StructProperties) | ||||
| 	// in case of recursive protos, fill this in now. | ||||
| 	propertiesMap[t] = prop | ||||
|  | ||||
| 	// build properties | ||||
| 	prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) || | ||||
| 		reflect.PtrTo(t).Implements(extendableProtoV1Type) || | ||||
| 		reflect.PtrTo(t).Implements(extendableBytesType) | ||||
| 	prop.unrecField = invalidField | ||||
| 	prop.Prop = make([]*Properties, t.NumField()) | ||||
| 	prop.order = make([]int, t.NumField()) | ||||
|  | ||||
| @@ -429,6 +774,23 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { | ||||
| 		name := f.Name | ||||
| 		p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false) | ||||
|  | ||||
| 		if f.Name == "XXX_InternalExtensions" { // special case | ||||
| 			p.enc = (*Buffer).enc_exts | ||||
| 			p.dec = nil // not needed | ||||
| 			p.size = size_exts | ||||
| 		} else if f.Name == "XXX_extensions" { // special case | ||||
| 			if len(f.Tag.Get("protobuf")) > 0 { | ||||
| 				p.enc = (*Buffer).enc_ext_slice_byte | ||||
| 				p.dec = nil // not needed | ||||
| 				p.size = size_ext_slice_byte | ||||
| 			} else { | ||||
| 				p.enc = (*Buffer).enc_map | ||||
| 				p.dec = nil // not needed | ||||
| 				p.size = size_map | ||||
| 			} | ||||
| 		} else if f.Name == "XXX_unrecognized" { // special case | ||||
| 			prop.unrecField = toField(&f) | ||||
| 		} | ||||
| 		oneof := f.Tag.Get("protobuf_oneof") // special case | ||||
| 		if oneof != "" { | ||||
| 			isOneofMessage = true | ||||
| @@ -444,45 +806,46 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { | ||||
| 			} | ||||
| 			print("\n") | ||||
| 		} | ||||
| 		if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && oneof == "" { | ||||
| 			fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]") | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Re-order prop.order. | ||||
| 	sort.Sort(prop) | ||||
|  | ||||
| 	if isOneofMessage { | ||||
| 	type oneofMessage interface { | ||||
| 		XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) | ||||
| 	} | ||||
| 	if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok { | ||||
| 		var oots []interface{} | ||||
| 		switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { | ||||
| 		case oneofFuncsIface: | ||||
| 			_, _, _, oots = m.XXX_OneofFuncs() | ||||
| 		case oneofWrappersIface: | ||||
| 			oots = m.XXX_OneofWrappers() | ||||
| 		} | ||||
| 		if len(oots) > 0 { | ||||
| 			// Interpret oneof metadata. | ||||
| 			prop.OneofTypes = make(map[string]*OneofProperties) | ||||
| 			for _, oot := range oots { | ||||
| 				oop := &OneofProperties{ | ||||
| 					Type: reflect.ValueOf(oot).Type(), // *T | ||||
| 					Prop: new(Properties), | ||||
| 				} | ||||
| 				sft := oop.Type.Elem().Field(0) | ||||
| 				oop.Prop.Name = sft.Name | ||||
| 				oop.Prop.Parse(sft.Tag.Get("protobuf")) | ||||
| 				// There will be exactly one interface field that | ||||
| 				// this new value is assignable to. | ||||
| 				for i := 0; i < t.NumField(); i++ { | ||||
| 					f := t.Field(i) | ||||
| 					if f.Type.Kind() != reflect.Interface { | ||||
| 						continue | ||||
| 					} | ||||
| 					if !oop.Type.AssignableTo(f.Type) { | ||||
| 						continue | ||||
| 					} | ||||
| 					oop.Field = i | ||||
| 					break | ||||
| 				} | ||||
| 				prop.OneofTypes[oop.Prop.OrigName] = oop | ||||
| 		prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs() | ||||
| 		prop.stype = t | ||||
|  | ||||
| 		// Interpret oneof metadata. | ||||
| 		prop.OneofTypes = make(map[string]*OneofProperties) | ||||
| 		for _, oot := range oots { | ||||
| 			oop := &OneofProperties{ | ||||
| 				Type: reflect.ValueOf(oot).Type(), // *T | ||||
| 				Prop: new(Properties), | ||||
| 			} | ||||
| 			sft := oop.Type.Elem().Field(0) | ||||
| 			oop.Prop.Name = sft.Name | ||||
| 			oop.Prop.Parse(sft.Tag.Get("protobuf")) | ||||
| 			// There will be exactly one interface field that | ||||
| 			// this new value is assignable to. | ||||
| 			for i := 0; i < t.NumField(); i++ { | ||||
| 				f := t.Field(i) | ||||
| 				if f.Type.Kind() != reflect.Interface { | ||||
| 					continue | ||||
| 				} | ||||
| 				if !oop.Type.AssignableTo(f.Type) { | ||||
| 					continue | ||||
| 				} | ||||
| 				oop.Field = i | ||||
| 				break | ||||
| 			} | ||||
| 			prop.OneofTypes[oop.Prop.OrigName] = oop | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -507,6 +870,30 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { | ||||
| 	return prop | ||||
| } | ||||
|  | ||||
| // Return the Properties object for the x[0]'th field of the structure. | ||||
| func propByIndex(t reflect.Type, x []int) *Properties { | ||||
| 	if len(x) != 1 { | ||||
| 		fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t) | ||||
| 		return nil | ||||
| 	} | ||||
| 	prop := GetProperties(t) | ||||
| 	return prop.Prop[x[0]] | ||||
| } | ||||
|  | ||||
| // Get the address and type of a pointer to a struct from an interface. | ||||
| func getbase(pb Message) (t reflect.Type, b structPointer, err error) { | ||||
| 	if pb == nil { | ||||
| 		err = ErrNil | ||||
| 		return | ||||
| 	} | ||||
| 	// get the reflect type of the pointer to the struct. | ||||
| 	t = reflect.TypeOf(pb) | ||||
| 	// get the address of the struct. | ||||
| 	value := reflect.ValueOf(pb) | ||||
| 	b = toStructPointer(value) | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // A global registry of enum types. | ||||
| // The generated code will register the generated maps by calling RegisterEnum. | ||||
|  | ||||
| @@ -535,42 +922,20 @@ func EnumValueMap(enumType string) map[string]int32 { | ||||
| // A registry of all linked message types. | ||||
| // The string is a fully-qualified proto name ("pkg.Message"). | ||||
| var ( | ||||
| 	protoTypedNils = make(map[string]Message)      // a map from proto names to typed nil pointers | ||||
| 	protoMapTypes  = make(map[string]reflect.Type) // a map from proto names to map types | ||||
| 	revProtoTypes  = make(map[reflect.Type]string) | ||||
| 	protoTypes    = make(map[string]reflect.Type) | ||||
| 	revProtoTypes = make(map[reflect.Type]string) | ||||
| ) | ||||
|  | ||||
| // RegisterType is called from generated code and maps from the fully qualified | ||||
| // proto name to the type (pointer to struct) of the protocol buffer. | ||||
| func RegisterType(x Message, name string) { | ||||
| 	if _, ok := protoTypedNils[name]; ok { | ||||
| 	if _, ok := protoTypes[name]; ok { | ||||
| 		// TODO: Some day, make this a panic. | ||||
| 		log.Printf("proto: duplicate proto type registered: %s", name) | ||||
| 		return | ||||
| 	} | ||||
| 	t := reflect.TypeOf(x) | ||||
| 	if v := reflect.ValueOf(x); v.Kind() == reflect.Ptr && v.Pointer() == 0 { | ||||
| 		// Generated code always calls RegisterType with nil x. | ||||
| 		// This check is just for extra safety. | ||||
| 		protoTypedNils[name] = x | ||||
| 	} else { | ||||
| 		protoTypedNils[name] = reflect.Zero(t).Interface().(Message) | ||||
| 	} | ||||
| 	revProtoTypes[t] = name | ||||
| } | ||||
|  | ||||
| // RegisterMapType is called from generated code and maps from the fully qualified | ||||
| // proto name to the native map type of the proto map definition. | ||||
| func RegisterMapType(x interface{}, name string) { | ||||
| 	if reflect.TypeOf(x).Kind() != reflect.Map { | ||||
| 		panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name)) | ||||
| 	} | ||||
| 	if _, ok := protoMapTypes[name]; ok { | ||||
| 		log.Printf("proto: duplicate proto type registered: %s", name) | ||||
| 		return | ||||
| 	} | ||||
| 	t := reflect.TypeOf(x) | ||||
| 	protoMapTypes[name] = t | ||||
| 	protoTypes[name] = t | ||||
| 	revProtoTypes[t] = name | ||||
| } | ||||
|  | ||||
| @@ -586,14 +951,7 @@ func MessageName(x Message) string { | ||||
| } | ||||
|  | ||||
| // MessageType returns the message type (pointer to struct) for a named message. | ||||
| // The type is not guaranteed to implement proto.Message if the name refers to a | ||||
| // map entry. | ||||
| func MessageType(name string) reflect.Type { | ||||
| 	if t, ok := protoTypedNils[name]; ok { | ||||
| 		return reflect.TypeOf(t) | ||||
| 	} | ||||
| 	return protoMapTypes[name] | ||||
| } | ||||
| func MessageType(name string) reflect.Type { return protoTypes[name] } | ||||
|  | ||||
| // A registry of all linked proto files. | ||||
| var ( | ||||
|   | ||||
							
								
								
									
										81
									
								
								vendor/github.com/gogo/protobuf/proto/properties_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										81
									
								
								vendor/github.com/gogo/protobuf/proto/properties_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| // Protocol Buffers for Go with Gadgets | ||||
| // | ||||
| // Copyright (c) 2018, The GoGo Authors. All rights reserved. | ||||
| // Copyright (c) 2013, The GoGo Authors. All rights reserved. | ||||
| // http://github.com/gogo/protobuf | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| @@ -29,8 +29,83 @@ | ||||
| package proto | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"reflect" | ||||
| ) | ||||
|  | ||||
| var sizerType = reflect.TypeOf((*Sizer)(nil)).Elem() | ||||
| var protosizerType = reflect.TypeOf((*ProtoSizer)(nil)).Elem() | ||||
| func (p *Properties) setCustomEncAndDec(typ reflect.Type) { | ||||
| 	p.ctype = typ | ||||
| 	if p.Repeated { | ||||
| 		p.enc = (*Buffer).enc_custom_slice_bytes | ||||
| 		p.dec = (*Buffer).dec_custom_slice_bytes | ||||
| 		p.size = size_custom_slice_bytes | ||||
| 	} else if typ.Kind() == reflect.Ptr { | ||||
| 		p.enc = (*Buffer).enc_custom_bytes | ||||
| 		p.dec = (*Buffer).dec_custom_bytes | ||||
| 		p.size = size_custom_bytes | ||||
| 	} else { | ||||
| 		p.enc = (*Buffer).enc_custom_ref_bytes | ||||
| 		p.dec = (*Buffer).dec_custom_ref_bytes | ||||
| 		p.size = size_custom_ref_bytes | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (p *Properties) setDurationEncAndDec(typ reflect.Type) { | ||||
| 	if p.Repeated { | ||||
| 		if typ.Elem().Kind() == reflect.Ptr { | ||||
| 			p.enc = (*Buffer).enc_slice_duration | ||||
| 			p.dec = (*Buffer).dec_slice_duration | ||||
| 			p.size = size_slice_duration | ||||
| 		} else { | ||||
| 			p.enc = (*Buffer).enc_slice_ref_duration | ||||
| 			p.dec = (*Buffer).dec_slice_ref_duration | ||||
| 			p.size = size_slice_ref_duration | ||||
| 		} | ||||
| 	} else if typ.Kind() == reflect.Ptr { | ||||
| 		p.enc = (*Buffer).enc_duration | ||||
| 		p.dec = (*Buffer).dec_duration | ||||
| 		p.size = size_duration | ||||
| 	} else { | ||||
| 		p.enc = (*Buffer).enc_ref_duration | ||||
| 		p.dec = (*Buffer).dec_ref_duration | ||||
| 		p.size = size_ref_duration | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (p *Properties) setTimeEncAndDec(typ reflect.Type) { | ||||
| 	if p.Repeated { | ||||
| 		if typ.Elem().Kind() == reflect.Ptr { | ||||
| 			p.enc = (*Buffer).enc_slice_time | ||||
| 			p.dec = (*Buffer).dec_slice_time | ||||
| 			p.size = size_slice_time | ||||
| 		} else { | ||||
| 			p.enc = (*Buffer).enc_slice_ref_time | ||||
| 			p.dec = (*Buffer).dec_slice_ref_time | ||||
| 			p.size = size_slice_ref_time | ||||
| 		} | ||||
| 	} else if typ.Kind() == reflect.Ptr { | ||||
| 		p.enc = (*Buffer).enc_time | ||||
| 		p.dec = (*Buffer).dec_time | ||||
| 		p.size = size_time | ||||
| 	} else { | ||||
| 		p.enc = (*Buffer).enc_ref_time | ||||
| 		p.dec = (*Buffer).dec_ref_time | ||||
| 		p.size = size_ref_time | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| func (p *Properties) setSliceOfNonPointerStructs(typ reflect.Type) { | ||||
| 	t2 := typ.Elem() | ||||
| 	p.sstype = typ | ||||
| 	p.stype = t2 | ||||
| 	p.isMarshaler = isMarshaler(t2) | ||||
| 	p.isUnmarshaler = isUnmarshaler(t2) | ||||
| 	p.enc = (*Buffer).enc_slice_ref_struct_message | ||||
| 	p.dec = (*Buffer).dec_slice_ref_struct_message | ||||
| 	p.size = size_slice_ref_struct_message | ||||
| 	if p.Wire != "bytes" { | ||||
| 		fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T \n", typ, t2) | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/github.com/gogo/protobuf/proto/proto3_proto/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/gogo/protobuf/proto/proto3_proto/Makefile
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,7 +0,0 @@ | ||||
| regenerate: | ||||
| 	go install github.com/gogo/protobuf/protoc-min-version | ||||
| 	protoc-min-version --version="3.0.0" --gogo_out=\ | ||||
| 	Mtest_proto/test.proto=github.com/gogo/protobuf/proto/test_proto,\ | ||||
| 	Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. \ | ||||
| 	--proto_path=../../protobuf:../:. proto3.proto | ||||
| 	 | ||||
							
								
								
									
										464
									
								
								vendor/github.com/gogo/protobuf/proto/proto3_proto/proto3.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										464
									
								
								vendor/github.com/gogo/protobuf/proto/proto3_proto/proto3.pb.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,15 +1,27 @@ | ||||
| // Code generated by protoc-gen-gogo. DO NOT EDIT. | ||||
| // source: proto3.proto | ||||
| // Code generated by protoc-gen-gogo. | ||||
| // source: proto3_proto/proto3.proto | ||||
| // DO NOT EDIT! | ||||
|  | ||||
| /* | ||||
| Package proto3_proto is a generated protocol buffer package. | ||||
|  | ||||
| It is generated from these files: | ||||
| 	proto3_proto/proto3.proto | ||||
|  | ||||
| It has these top-level messages: | ||||
| 	Message | ||||
| 	Nested | ||||
| 	MessageWithMap | ||||
| 	IntMap | ||||
| 	IntMaps | ||||
| */ | ||||
| package proto3_proto | ||||
|  | ||||
| import ( | ||||
| 	fmt "fmt" | ||||
| 	proto "github.com/gogo/protobuf/proto" | ||||
| 	test_proto "github.com/gogo/protobuf/proto/test_proto" | ||||
| 	types "github.com/gogo/protobuf/types" | ||||
| 	math "math" | ||||
| ) | ||||
| import proto "github.com/gogo/protobuf/proto" | ||||
| import fmt "fmt" | ||||
| import math "math" | ||||
| import google_protobuf "github.com/gogo/protobuf/types" | ||||
| import testdata "github.com/gogo/protobuf/proto/testdata" | ||||
|  | ||||
| // Reference imports to suppress errors if they are not otherwise used. | ||||
| var _ = proto.Marshal | ||||
| @@ -20,7 +32,7 @@ var _ = math.Inf | ||||
| // is compatible with the proto package it is being compiled against. | ||||
| // A compilation error at this line likely means your copy of the | ||||
| // proto package needs to be updated. | ||||
| const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package | ||||
| const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package | ||||
|  | ||||
| type Message_Humour int32 | ||||
|  | ||||
| @@ -37,7 +49,6 @@ var Message_Humour_name = map[int32]string{ | ||||
| 	2: "SLAPSTICK", | ||||
| 	3: "BILL_BAILEY", | ||||
| } | ||||
|  | ||||
| var Message_Humour_value = map[string]int32{ | ||||
| 	"UNKNOWN":     0, | ||||
| 	"PUNS":        1, | ||||
| @@ -48,59 +59,33 @@ var Message_Humour_value = map[string]int32{ | ||||
| func (x Message_Humour) String() string { | ||||
| 	return proto.EnumName(Message_Humour_name, int32(x)) | ||||
| } | ||||
|  | ||||
| func (Message_Humour) EnumDescriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_4fee6d65e34a64b6, []int{0, 0} | ||||
| } | ||||
| func (Message_Humour) EnumDescriptor() ([]byte, []int) { return fileDescriptorProto3, []int{0, 0} } | ||||
|  | ||||
| type Message struct { | ||||
| 	Name                 string                             `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` | ||||
| 	Hilarity             Message_Humour                     `protobuf:"varint,2,opt,name=hilarity,proto3,enum=proto3_proto.Message_Humour" json:"hilarity,omitempty"` | ||||
| 	HeightInCm           uint32                             `protobuf:"varint,3,opt,name=height_in_cm,json=heightInCm,proto3" json:"height_in_cm,omitempty"` | ||||
| 	Data                 []byte                             `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` | ||||
| 	ResultCount          int64                              `protobuf:"varint,7,opt,name=result_count,json=resultCount,proto3" json:"result_count,omitempty"` | ||||
| 	TrueScotsman         bool                               `protobuf:"varint,8,opt,name=true_scotsman,json=trueScotsman,proto3" json:"true_scotsman,omitempty"` | ||||
| 	Score                float32                            `protobuf:"fixed32,9,opt,name=score,proto3" json:"score,omitempty"` | ||||
| 	Key                  []uint64                           `protobuf:"varint,5,rep,packed,name=key,proto3" json:"key,omitempty"` | ||||
| 	ShortKey             []int32                            `protobuf:"varint,19,rep,packed,name=short_key,json=shortKey,proto3" json:"short_key,omitempty"` | ||||
| 	Nested               *Nested                            `protobuf:"bytes,6,opt,name=nested,proto3" json:"nested,omitempty"` | ||||
| 	RFunny               []Message_Humour                   `protobuf:"varint,16,rep,packed,name=r_funny,json=rFunny,proto3,enum=proto3_proto.Message_Humour" json:"r_funny,omitempty"` | ||||
| 	Terrain              map[string]*Nested                 `protobuf:"bytes,10,rep,name=terrain,proto3" json:"terrain,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	Proto2Field          *test_proto.SubDefaults            `protobuf:"bytes,11,opt,name=proto2_field,json=proto2Field,proto3" json:"proto2_field,omitempty"` | ||||
| 	Proto2Value          map[string]*test_proto.SubDefaults `protobuf:"bytes,13,rep,name=proto2_value,json=proto2Value,proto3" json:"proto2_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	Anything             *types.Any                         `protobuf:"bytes,14,opt,name=anything,proto3" json:"anything,omitempty"` | ||||
| 	ManyThings           []*types.Any                       `protobuf:"bytes,15,rep,name=many_things,json=manyThings,proto3" json:"many_things,omitempty"` | ||||
| 	Submessage           *Message                           `protobuf:"bytes,17,opt,name=submessage,proto3" json:"submessage,omitempty"` | ||||
| 	Children             []*Message                         `protobuf:"bytes,18,rep,name=children,proto3" json:"children,omitempty"` | ||||
| 	StringMap            map[string]string                  `protobuf:"bytes,20,rep,name=string_map,json=stringMap,proto3" json:"string_map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	XXX_NoUnkeyedLiteral struct{}                           `json:"-"` | ||||
| 	XXX_unrecognized     []byte                             `json:"-"` | ||||
| 	XXX_sizecache        int32                              `json:"-"` | ||||
| 	Name         string                           `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` | ||||
| 	Hilarity     Message_Humour                   `protobuf:"varint,2,opt,name=hilarity,proto3,enum=proto3_proto.Message_Humour" json:"hilarity,omitempty"` | ||||
| 	HeightInCm   uint32                           `protobuf:"varint,3,opt,name=height_in_cm,json=heightInCm,proto3" json:"height_in_cm,omitempty"` | ||||
| 	Data         []byte                           `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` | ||||
| 	ResultCount  int64                            `protobuf:"varint,7,opt,name=result_count,json=resultCount,proto3" json:"result_count,omitempty"` | ||||
| 	TrueScotsman bool                             `protobuf:"varint,8,opt,name=true_scotsman,json=trueScotsman,proto3" json:"true_scotsman,omitempty"` | ||||
| 	Score        float32                          `protobuf:"fixed32,9,opt,name=score,proto3" json:"score,omitempty"` | ||||
| 	Key          []uint64                         `protobuf:"varint,5,rep,packed,name=key" json:"key,omitempty"` | ||||
| 	ShortKey     []int32                          `protobuf:"varint,19,rep,packed,name=short_key,json=shortKey" json:"short_key,omitempty"` | ||||
| 	Nested       *Nested                          `protobuf:"bytes,6,opt,name=nested" json:"nested,omitempty"` | ||||
| 	RFunny       []Message_Humour                 `protobuf:"varint,16,rep,packed,name=r_funny,json=rFunny,enum=proto3_proto.Message_Humour" json:"r_funny,omitempty"` | ||||
| 	Terrain      map[string]*Nested               `protobuf:"bytes,10,rep,name=terrain" json:"terrain,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"` | ||||
| 	Proto2Field  *testdata.SubDefaults            `protobuf:"bytes,11,opt,name=proto2_field,json=proto2Field" json:"proto2_field,omitempty"` | ||||
| 	Proto2Value  map[string]*testdata.SubDefaults `protobuf:"bytes,13,rep,name=proto2_value,json=proto2Value" json:"proto2_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"` | ||||
| 	Anything     *google_protobuf.Any             `protobuf:"bytes,14,opt,name=anything" json:"anything,omitempty"` | ||||
| 	ManyThings   []*google_protobuf.Any           `protobuf:"bytes,15,rep,name=many_things,json=manyThings" json:"many_things,omitempty"` | ||||
| 	Submessage   *Message                         `protobuf:"bytes,17,opt,name=submessage" json:"submessage,omitempty"` | ||||
| 	Children     []*Message                       `protobuf:"bytes,18,rep,name=children" json:"children,omitempty"` | ||||
| } | ||||
|  | ||||
| func (m *Message) Reset()         { *m = Message{} } | ||||
| func (m *Message) String() string { return proto.CompactTextString(m) } | ||||
| func (*Message) ProtoMessage()    {} | ||||
| func (*Message) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_4fee6d65e34a64b6, []int{0} | ||||
| } | ||||
| func (m *Message) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_Message.Unmarshal(m, b) | ||||
| } | ||||
| func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_Message.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *Message) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_Message.Merge(m, src) | ||||
| } | ||||
| func (m *Message) XXX_Size() int { | ||||
| 	return xxx_messageInfo_Message.Size(m) | ||||
| } | ||||
| func (m *Message) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_Message.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_Message proto.InternalMessageInfo | ||||
| func (m *Message) Reset()                    { *m = Message{} } | ||||
| func (m *Message) String() string            { return proto.CompactTextString(m) } | ||||
| func (*Message) ProtoMessage()               {} | ||||
| func (*Message) Descriptor() ([]byte, []int) { return fileDescriptorProto3, []int{0} } | ||||
|  | ||||
| func (m *Message) GetName() string { | ||||
| 	if m != nil { | ||||
| @@ -186,28 +171,28 @@ func (m *Message) GetTerrain() map[string]*Nested { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *Message) GetProto2Field() *test_proto.SubDefaults { | ||||
| func (m *Message) GetProto2Field() *testdata.SubDefaults { | ||||
| 	if m != nil { | ||||
| 		return m.Proto2Field | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *Message) GetProto2Value() map[string]*test_proto.SubDefaults { | ||||
| func (m *Message) GetProto2Value() map[string]*testdata.SubDefaults { | ||||
| 	if m != nil { | ||||
| 		return m.Proto2Value | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *Message) GetAnything() *types.Any { | ||||
| func (m *Message) GetAnything() *google_protobuf.Any { | ||||
| 	if m != nil { | ||||
| 		return m.Anything | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *Message) GetManyThings() []*types.Any { | ||||
| func (m *Message) GetManyThings() []*google_protobuf.Any { | ||||
| 	if m != nil { | ||||
| 		return m.ManyThings | ||||
| 	} | ||||
| @@ -228,44 +213,15 @@ func (m *Message) GetChildren() []*Message { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *Message) GetStringMap() map[string]string { | ||||
| 	if m != nil { | ||||
| 		return m.StringMap | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| type Nested struct { | ||||
| 	Bunny                string   `protobuf:"bytes,1,opt,name=bunny,proto3" json:"bunny,omitempty"` | ||||
| 	Cute                 bool     `protobuf:"varint,2,opt,name=cute,proto3" json:"cute,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{} `json:"-"` | ||||
| 	XXX_unrecognized     []byte   `json:"-"` | ||||
| 	XXX_sizecache        int32    `json:"-"` | ||||
| 	Bunny string `protobuf:"bytes,1,opt,name=bunny,proto3" json:"bunny,omitempty"` | ||||
| 	Cute  bool   `protobuf:"varint,2,opt,name=cute,proto3" json:"cute,omitempty"` | ||||
| } | ||||
|  | ||||
| func (m *Nested) Reset()         { *m = Nested{} } | ||||
| func (m *Nested) String() string { return proto.CompactTextString(m) } | ||||
| func (*Nested) ProtoMessage()    {} | ||||
| func (*Nested) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_4fee6d65e34a64b6, []int{1} | ||||
| } | ||||
| func (m *Nested) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_Nested.Unmarshal(m, b) | ||||
| } | ||||
| func (m *Nested) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_Nested.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *Nested) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_Nested.Merge(m, src) | ||||
| } | ||||
| func (m *Nested) XXX_Size() int { | ||||
| 	return xxx_messageInfo_Nested.Size(m) | ||||
| } | ||||
| func (m *Nested) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_Nested.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_Nested proto.InternalMessageInfo | ||||
| func (m *Nested) Reset()                    { *m = Nested{} } | ||||
| func (m *Nested) String() string            { return proto.CompactTextString(m) } | ||||
| func (*Nested) ProtoMessage()               {} | ||||
| func (*Nested) Descriptor() ([]byte, []int) { return fileDescriptorProto3, []int{1} } | ||||
|  | ||||
| func (m *Nested) GetBunny() string { | ||||
| 	if m != nil { | ||||
| @@ -282,35 +238,13 @@ func (m *Nested) GetCute() bool { | ||||
| } | ||||
|  | ||||
| type MessageWithMap struct { | ||||
| 	ByteMapping          map[bool][]byte `protobuf:"bytes,1,rep,name=byte_mapping,json=byteMapping,proto3" json:"byte_mapping,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	XXX_NoUnkeyedLiteral struct{}        `json:"-"` | ||||
| 	XXX_unrecognized     []byte          `json:"-"` | ||||
| 	XXX_sizecache        int32           `json:"-"` | ||||
| 	ByteMapping map[bool][]byte `protobuf:"bytes,1,rep,name=byte_mapping,json=byteMapping" json:"byte_mapping,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| } | ||||
|  | ||||
| func (m *MessageWithMap) Reset()         { *m = MessageWithMap{} } | ||||
| func (m *MessageWithMap) String() string { return proto.CompactTextString(m) } | ||||
| func (*MessageWithMap) ProtoMessage()    {} | ||||
| func (*MessageWithMap) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_4fee6d65e34a64b6, []int{2} | ||||
| } | ||||
| func (m *MessageWithMap) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_MessageWithMap.Unmarshal(m, b) | ||||
| } | ||||
| func (m *MessageWithMap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_MessageWithMap.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *MessageWithMap) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_MessageWithMap.Merge(m, src) | ||||
| } | ||||
| func (m *MessageWithMap) XXX_Size() int { | ||||
| 	return xxx_messageInfo_MessageWithMap.Size(m) | ||||
| } | ||||
| func (m *MessageWithMap) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_MessageWithMap.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_MessageWithMap proto.InternalMessageInfo | ||||
| func (m *MessageWithMap) Reset()                    { *m = MessageWithMap{} } | ||||
| func (m *MessageWithMap) String() string            { return proto.CompactTextString(m) } | ||||
| func (*MessageWithMap) ProtoMessage()               {} | ||||
| func (*MessageWithMap) Descriptor() ([]byte, []int) { return fileDescriptorProto3, []int{2} } | ||||
|  | ||||
| func (m *MessageWithMap) GetByteMapping() map[bool][]byte { | ||||
| 	if m != nil { | ||||
| @@ -320,35 +254,13 @@ func (m *MessageWithMap) GetByteMapping() map[bool][]byte { | ||||
| } | ||||
|  | ||||
| type IntMap struct { | ||||
| 	Rtt                  map[int32]int32 `protobuf:"bytes,1,rep,name=rtt,proto3" json:"rtt,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	XXX_NoUnkeyedLiteral struct{}        `json:"-"` | ||||
| 	XXX_unrecognized     []byte          `json:"-"` | ||||
| 	XXX_sizecache        int32           `json:"-"` | ||||
| 	Rtt map[int32]int32 `protobuf:"bytes,1,rep,name=rtt" json:"rtt,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| } | ||||
|  | ||||
| func (m *IntMap) Reset()         { *m = IntMap{} } | ||||
| func (m *IntMap) String() string { return proto.CompactTextString(m) } | ||||
| func (*IntMap) ProtoMessage()    {} | ||||
| func (*IntMap) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_4fee6d65e34a64b6, []int{3} | ||||
| } | ||||
| func (m *IntMap) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_IntMap.Unmarshal(m, b) | ||||
| } | ||||
| func (m *IntMap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_IntMap.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *IntMap) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_IntMap.Merge(m, src) | ||||
| } | ||||
| func (m *IntMap) XXX_Size() int { | ||||
| 	return xxx_messageInfo_IntMap.Size(m) | ||||
| } | ||||
| func (m *IntMap) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_IntMap.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_IntMap proto.InternalMessageInfo | ||||
| func (m *IntMap) Reset()                    { *m = IntMap{} } | ||||
| func (m *IntMap) String() string            { return proto.CompactTextString(m) } | ||||
| func (*IntMap) ProtoMessage()               {} | ||||
| func (*IntMap) Descriptor() ([]byte, []int) { return fileDescriptorProto3, []int{3} } | ||||
|  | ||||
| func (m *IntMap) GetRtt() map[int32]int32 { | ||||
| 	if m != nil { | ||||
| @@ -358,35 +270,13 @@ func (m *IntMap) GetRtt() map[int32]int32 { | ||||
| } | ||||
|  | ||||
| type IntMaps struct { | ||||
| 	Maps                 []*IntMap `protobuf:"bytes,1,rep,name=maps,proto3" json:"maps,omitempty"` | ||||
| 	XXX_NoUnkeyedLiteral struct{}  `json:"-"` | ||||
| 	XXX_unrecognized     []byte    `json:"-"` | ||||
| 	XXX_sizecache        int32     `json:"-"` | ||||
| 	Maps []*IntMap `protobuf:"bytes,1,rep,name=maps" json:"maps,omitempty"` | ||||
| } | ||||
|  | ||||
| func (m *IntMaps) Reset()         { *m = IntMaps{} } | ||||
| func (m *IntMaps) String() string { return proto.CompactTextString(m) } | ||||
| func (*IntMaps) ProtoMessage()    {} | ||||
| func (*IntMaps) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_4fee6d65e34a64b6, []int{4} | ||||
| } | ||||
| func (m *IntMaps) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_IntMaps.Unmarshal(m, b) | ||||
| } | ||||
| func (m *IntMaps) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_IntMaps.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *IntMaps) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_IntMaps.Merge(m, src) | ||||
| } | ||||
| func (m *IntMaps) XXX_Size() int { | ||||
| 	return xxx_messageInfo_IntMaps.Size(m) | ||||
| } | ||||
| func (m *IntMaps) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_IntMaps.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_IntMaps proto.InternalMessageInfo | ||||
| func (m *IntMaps) Reset()                    { *m = IntMaps{} } | ||||
| func (m *IntMaps) String() string            { return proto.CompactTextString(m) } | ||||
| func (*IntMaps) ProtoMessage()               {} | ||||
| func (*IntMaps) Descriptor() ([]byte, []int) { return fileDescriptorProto3, []int{4} } | ||||
|  | ||||
| func (m *IntMaps) GetMaps() []*IntMap { | ||||
| 	if m != nil { | ||||
| @@ -395,177 +285,63 @@ func (m *IntMaps) GetMaps() []*IntMap { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| type TestUTF8 struct { | ||||
| 	Scalar string   `protobuf:"bytes,1,opt,name=scalar,proto3" json:"scalar,omitempty"` | ||||
| 	Vector []string `protobuf:"bytes,2,rep,name=vector,proto3" json:"vector,omitempty"` | ||||
| 	// Types that are valid to be assigned to Oneof: | ||||
| 	//	*TestUTF8_Field | ||||
| 	Oneof                isTestUTF8_Oneof `protobuf_oneof:"oneof"` | ||||
| 	MapKey               map[string]int64 `protobuf:"bytes,4,rep,name=map_key,json=mapKey,proto3" json:"map_key,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` | ||||
| 	MapValue             map[int64]string `protobuf:"bytes,5,rep,name=map_value,json=mapValue,proto3" json:"map_value,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` | ||||
| 	XXX_NoUnkeyedLiteral struct{}         `json:"-"` | ||||
| 	XXX_unrecognized     []byte           `json:"-"` | ||||
| 	XXX_sizecache        int32            `json:"-"` | ||||
| } | ||||
|  | ||||
| func (m *TestUTF8) Reset()         { *m = TestUTF8{} } | ||||
| func (m *TestUTF8) String() string { return proto.CompactTextString(m) } | ||||
| func (*TestUTF8) ProtoMessage()    {} | ||||
| func (*TestUTF8) Descriptor() ([]byte, []int) { | ||||
| 	return fileDescriptor_4fee6d65e34a64b6, []int{5} | ||||
| } | ||||
| func (m *TestUTF8) XXX_Unmarshal(b []byte) error { | ||||
| 	return xxx_messageInfo_TestUTF8.Unmarshal(m, b) | ||||
| } | ||||
| func (m *TestUTF8) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { | ||||
| 	return xxx_messageInfo_TestUTF8.Marshal(b, m, deterministic) | ||||
| } | ||||
| func (m *TestUTF8) XXX_Merge(src proto.Message) { | ||||
| 	xxx_messageInfo_TestUTF8.Merge(m, src) | ||||
| } | ||||
| func (m *TestUTF8) XXX_Size() int { | ||||
| 	return xxx_messageInfo_TestUTF8.Size(m) | ||||
| } | ||||
| func (m *TestUTF8) XXX_DiscardUnknown() { | ||||
| 	xxx_messageInfo_TestUTF8.DiscardUnknown(m) | ||||
| } | ||||
|  | ||||
| var xxx_messageInfo_TestUTF8 proto.InternalMessageInfo | ||||
|  | ||||
| type isTestUTF8_Oneof interface { | ||||
| 	isTestUTF8_Oneof() | ||||
| } | ||||
|  | ||||
| type TestUTF8_Field struct { | ||||
| 	Field string `protobuf:"bytes,3,opt,name=field,proto3,oneof" json:"field,omitempty"` | ||||
| } | ||||
|  | ||||
| func (*TestUTF8_Field) isTestUTF8_Oneof() {} | ||||
|  | ||||
| func (m *TestUTF8) GetOneof() isTestUTF8_Oneof { | ||||
| 	if m != nil { | ||||
| 		return m.Oneof | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *TestUTF8) GetScalar() string { | ||||
| 	if m != nil { | ||||
| 		return m.Scalar | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
|  | ||||
| func (m *TestUTF8) GetVector() []string { | ||||
| 	if m != nil { | ||||
| 		return m.Vector | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *TestUTF8) GetField() string { | ||||
| 	if x, ok := m.GetOneof().(*TestUTF8_Field); ok { | ||||
| 		return x.Field | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
|  | ||||
| func (m *TestUTF8) GetMapKey() map[string]int64 { | ||||
| 	if m != nil { | ||||
| 		return m.MapKey | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (m *TestUTF8) GetMapValue() map[int64]string { | ||||
| 	if m != nil { | ||||
| 		return m.MapValue | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // XXX_OneofWrappers is for the internal use of the proto package. | ||||
| func (*TestUTF8) XXX_OneofWrappers() []interface{} { | ||||
| 	return []interface{}{ | ||||
| 		(*TestUTF8_Field)(nil), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func init() { | ||||
| 	proto.RegisterEnum("proto3_proto.Message_Humour", Message_Humour_name, Message_Humour_value) | ||||
| 	proto.RegisterType((*Message)(nil), "proto3_proto.Message") | ||||
| 	proto.RegisterMapType((map[string]*test_proto.SubDefaults)(nil), "proto3_proto.Message.Proto2ValueEntry") | ||||
| 	proto.RegisterMapType((map[string]string)(nil), "proto3_proto.Message.StringMapEntry") | ||||
| 	proto.RegisterMapType((map[string]*Nested)(nil), "proto3_proto.Message.TerrainEntry") | ||||
| 	proto.RegisterType((*Nested)(nil), "proto3_proto.Nested") | ||||
| 	proto.RegisterType((*MessageWithMap)(nil), "proto3_proto.MessageWithMap") | ||||
| 	proto.RegisterMapType((map[bool][]byte)(nil), "proto3_proto.MessageWithMap.ByteMappingEntry") | ||||
| 	proto.RegisterType((*IntMap)(nil), "proto3_proto.IntMap") | ||||
| 	proto.RegisterMapType((map[int32]int32)(nil), "proto3_proto.IntMap.RttEntry") | ||||
| 	proto.RegisterType((*IntMaps)(nil), "proto3_proto.IntMaps") | ||||
| 	proto.RegisterType((*TestUTF8)(nil), "proto3_proto.TestUTF8") | ||||
| 	proto.RegisterMapType((map[string]int64)(nil), "proto3_proto.TestUTF8.MapKeyEntry") | ||||
| 	proto.RegisterMapType((map[int64]string)(nil), "proto3_proto.TestUTF8.MapValueEntry") | ||||
| 	proto.RegisterEnum("proto3_proto.Message_Humour", Message_Humour_name, Message_Humour_value) | ||||
| } | ||||
|  | ||||
| func init() { proto.RegisterFile("proto3.proto", fileDescriptor_4fee6d65e34a64b6) } | ||||
| func init() { proto.RegisterFile("proto3_proto/proto3.proto", fileDescriptorProto3) } | ||||
|  | ||||
| var fileDescriptor_4fee6d65e34a64b6 = []byte{ | ||||
| 	// 891 bytes of a gzipped FileDescriptorProto | ||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xff, 0x8e, 0xdb, 0x44, | ||||
| 	0x10, 0xae, 0xe3, 0xfc, 0x70, 0x26, 0xc9, 0x35, 0x2c, 0x69, 0x59, 0x02, 0x48, 0x26, 0x20, 0x64, | ||||
| 	0x21, 0xea, 0x83, 0x54, 0x87, 0x8e, 0xb6, 0x02, 0xdd, 0x1d, 0x3d, 0x35, 0xba, 0x4b, 0x88, 0x36, | ||||
| 	0x39, 0x4e, 0xfc, 0x65, 0x6d, 0x72, 0x9b, 0xc4, 0x22, 0x5e, 0x07, 0xef, 0xba, 0x92, 0x5f, 0x80, | ||||
| 	0x07, 0xe1, 0x95, 0x78, 0x21, 0xb4, 0xbb, 0xce, 0xd5, 0xa9, 0x5c, 0xee, 0x2f, 0xef, 0x7c, 0xfe, | ||||
| 	0x66, 0xbe, 0xd9, 0x99, 0xd9, 0x81, 0xf6, 0x2e, 0x89, 0x65, 0xfc, 0xdc, 0xd7, 0x1f, 0x94, 0x5b, | ||||
| 	0x81, 0xfe, 0xf4, 0x3f, 0x5d, 0xc7, 0xf1, 0x7a, 0xcb, 0x8e, 0xb5, 0xb5, 0x48, 0x57, 0xc7, 0x94, | ||||
| 	0x67, 0x86, 0xd8, 0x7f, 0x22, 0x99, 0x90, 0x86, 0x76, 0xac, 0x8e, 0x06, 0x1e, 0xfc, 0xdd, 0x84, | ||||
| 	0xc6, 0x98, 0x09, 0x41, 0xd7, 0x0c, 0x21, 0xa8, 0x72, 0x1a, 0x31, 0x6c, 0xb9, 0x96, 0xd7, 0x24, | ||||
| 	0xfa, 0x8c, 0x4e, 0xc1, 0xd9, 0x84, 0x5b, 0x9a, 0x84, 0x32, 0xc3, 0x15, 0xd7, 0xf2, 0x8e, 0x86, | ||||
| 	0x9f, 0xfb, 0x45, 0x49, 0x3f, 0x77, 0xf6, 0xdf, 0xa4, 0x51, 0x9c, 0x26, 0xe4, 0x9e, 0x8d, 0x5c, | ||||
| 	0x68, 0x6f, 0x58, 0xb8, 0xde, 0xc8, 0x20, 0xe4, 0xc1, 0x32, 0xc2, 0xb6, 0x6b, 0x79, 0x1d, 0x02, | ||||
| 	0x06, 0x1b, 0xf1, 0x8b, 0x48, 0xe9, 0xdd, 0x51, 0x49, 0x71, 0xd5, 0xb5, 0xbc, 0x36, 0xd1, 0x67, | ||||
| 	0xf4, 0x25, 0xb4, 0x13, 0x26, 0xd2, 0xad, 0x0c, 0x96, 0x71, 0xca, 0x25, 0x6e, 0xb8, 0x96, 0x67, | ||||
| 	0x93, 0x96, 0xc1, 0x2e, 0x14, 0x84, 0xbe, 0x82, 0x8e, 0x4c, 0x52, 0x16, 0x88, 0x65, 0x2c, 0x45, | ||||
| 	0x44, 0x39, 0x76, 0x5c, 0xcb, 0x73, 0x48, 0x5b, 0x81, 0xb3, 0x1c, 0x43, 0x3d, 0xa8, 0x89, 0x65, | ||||
| 	0x9c, 0x30, 0xdc, 0x74, 0x2d, 0xaf, 0x42, 0x8c, 0x81, 0xba, 0x60, 0xff, 0xc9, 0x32, 0x5c, 0x73, | ||||
| 	0x6d, 0xaf, 0x4a, 0xd4, 0x11, 0x7d, 0x06, 0x4d, 0xb1, 0x89, 0x13, 0x19, 0x28, 0xfc, 0x63, 0xd7, | ||||
| 	0xf6, 0x6a, 0xc4, 0xd1, 0xc0, 0x15, 0xcb, 0xd0, 0x77, 0x50, 0xe7, 0x4c, 0x48, 0x76, 0x87, 0xeb, | ||||
| 	0xae, 0xe5, 0xb5, 0x86, 0xbd, 0xc3, 0xab, 0x4f, 0xf4, 0x3f, 0x92, 0x73, 0xd0, 0x09, 0x34, 0x92, | ||||
| 	0x60, 0x95, 0x72, 0x9e, 0xe1, 0xae, 0x6b, 0x3f, 0x58, 0xa9, 0x7a, 0x72, 0xa9, 0xb8, 0xe8, 0x15, | ||||
| 	0x34, 0x24, 0x4b, 0x12, 0x1a, 0x72, 0x0c, 0xae, 0xed, 0xb5, 0x86, 0x83, 0x72, 0xb7, 0xb9, 0x21, | ||||
| 	0xbd, 0xe6, 0x32, 0xc9, 0xc8, 0xde, 0x05, 0xbd, 0xc8, 0xe7, 0x61, 0x18, 0xac, 0x42, 0xb6, 0xbd, | ||||
| 	0xc3, 0x2d, 0x9d, 0xe8, 0x27, 0xfe, 0xbb, 0x6e, 0xfb, 0xb3, 0x74, 0xf1, 0x2b, 0x5b, 0xd1, 0x74, | ||||
| 	0x2b, 0x05, 0x69, 0x19, 0xf2, 0xa5, 0xe2, 0xa2, 0xd1, 0xbd, 0xef, 0x5b, 0xba, 0x4d, 0x19, 0xee, | ||||
| 	0x68, 0xf9, 0x6f, 0xca, 0xe5, 0xa7, 0x9a, 0xf9, 0xbb, 0x22, 0x9a, 0x14, 0xf2, 0x50, 0x1a, 0x41, | ||||
| 	0xdf, 0x83, 0x43, 0x79, 0x26, 0x37, 0x21, 0x5f, 0xe3, 0xa3, 0xbc, 0x56, 0x66, 0x16, 0xfd, 0xfd, | ||||
| 	0x2c, 0xfa, 0x67, 0x3c, 0x23, 0xf7, 0x2c, 0x74, 0x02, 0xad, 0x88, 0xf2, 0x2c, 0xd0, 0x96, 0xc0, | ||||
| 	0x8f, 0xb5, 0x76, 0xb9, 0x13, 0x28, 0xe2, 0x5c, 0xf3, 0xd0, 0x09, 0x80, 0x48, 0x17, 0x91, 0x49, | ||||
| 	0x0a, 0x7f, 0xa4, 0xa5, 0x9e, 0x94, 0x66, 0x4c, 0x0a, 0x44, 0xf4, 0x03, 0x38, 0xcb, 0x4d, 0xb8, | ||||
| 	0xbd, 0x4b, 0x18, 0xc7, 0x48, 0x4b, 0x7d, 0xc0, 0xe9, 0x9e, 0x86, 0x2e, 0x00, 0x84, 0x4c, 0x42, | ||||
| 	0xbe, 0x0e, 0x22, 0xba, 0xc3, 0x3d, 0xed, 0xf4, 0x75, 0x79, 0x6d, 0x66, 0x9a, 0x37, 0xa6, 0x3b, | ||||
| 	0x53, 0x99, 0xa6, 0xd8, 0xdb, 0xfd, 0x29, 0xb4, 0x8b, 0x7d, 0xdb, 0x0f, 0xa0, 0x79, 0x61, 0x7a, | ||||
| 	0x00, 0xbf, 0x85, 0x9a, 0xa9, 0x7e, 0xe5, 0x7f, 0x46, 0xcc, 0x50, 0x5e, 0x54, 0x4e, 0xad, 0xfe, | ||||
| 	0x2d, 0x74, 0xdf, 0x6f, 0x45, 0x49, 0xd4, 0x67, 0x87, 0x51, 0x3f, 0x38, 0x0f, 0x85, 0xc0, 0xaf, | ||||
| 	0xe0, 0xe8, 0xf0, 0x1e, 0x25, 0x61, 0x7b, 0xc5, 0xb0, 0xcd, 0x82, 0xf7, 0xe0, 0x17, 0xa8, 0x9b, | ||||
| 	0xb9, 0x46, 0x2d, 0x68, 0xdc, 0x4c, 0xae, 0x26, 0xbf, 0xdd, 0x4e, 0xba, 0x8f, 0x90, 0x03, 0xd5, | ||||
| 	0xe9, 0xcd, 0x64, 0xd6, 0xb5, 0x50, 0x07, 0x9a, 0xb3, 0xeb, 0xb3, 0xe9, 0x6c, 0x3e, 0xba, 0xb8, | ||||
| 	0xea, 0x56, 0xd0, 0x63, 0x68, 0x9d, 0x8f, 0xae, 0xaf, 0x83, 0xf3, 0xb3, 0xd1, 0xf5, 0xeb, 0x3f, | ||||
| 	0xba, 0xf6, 0x60, 0x08, 0x75, 0x73, 0x59, 0x25, 0xb2, 0xd0, 0xaf, 0xc8, 0x08, 0x1b, 0x43, 0x2d, | ||||
| 	0x8b, 0x65, 0x2a, 0x8d, 0xb2, 0x43, 0xf4, 0x79, 0xf0, 0x8f, 0x05, 0x47, 0x79, 0x0f, 0x6e, 0x43, | ||||
| 	0xb9, 0x19, 0xd3, 0x1d, 0x9a, 0x42, 0x7b, 0x91, 0x49, 0xa6, 0x7a, 0xb6, 0x53, 0xc3, 0x68, 0xe9, | ||||
| 	0xbe, 0x3d, 0x2b, 0xed, 0x5b, 0xee, 0xe3, 0x9f, 0x67, 0x92, 0x8d, 0x0d, 0x3f, 0x1f, 0xed, 0xc5, | ||||
| 	0x3b, 0xa4, 0xff, 0x33, 0x74, 0xdf, 0x27, 0x14, 0x2b, 0xe3, 0x94, 0x54, 0xa6, 0x5d, 0xac, 0xcc, | ||||
| 	0x5f, 0x50, 0x1f, 0x71, 0xa9, 0x72, 0x3b, 0x06, 0x3b, 0x91, 0x32, 0x4f, 0xe9, 0x8b, 0xc3, 0x94, | ||||
| 	0x0c, 0xc5, 0x27, 0x52, 0x9a, 0x14, 0x14, 0xb3, 0xff, 0x23, 0x38, 0x7b, 0xa0, 0x28, 0x59, 0x2b, | ||||
| 	0x91, 0xac, 0x15, 0x25, 0x9f, 0x43, 0xc3, 0xc4, 0x13, 0xc8, 0x83, 0x6a, 0x44, 0x77, 0x22, 0x17, | ||||
| 	0xed, 0x95, 0x89, 0x12, 0xcd, 0x18, 0xfc, 0x5b, 0x01, 0x67, 0xce, 0x84, 0xbc, 0x99, 0x5f, 0x9e, | ||||
| 	0xa2, 0xa7, 0x50, 0x17, 0x4b, 0xba, 0xa5, 0x49, 0xde, 0x84, 0xdc, 0x52, 0xf8, 0x5b, 0xb6, 0x94, | ||||
| 	0x71, 0x82, 0x2b, 0xae, 0xad, 0x70, 0x63, 0xa1, 0xa7, 0x50, 0x33, 0xfb, 0x47, 0x6d, 0xf9, 0xe6, | ||||
| 	0x9b, 0x47, 0xc4, 0x98, 0xe8, 0x25, 0x34, 0x22, 0xba, 0xd3, 0xcb, 0xb5, 0x5a, 0xb6, 0xdc, 0xf6, | ||||
| 	0x82, 0xfe, 0x98, 0xee, 0xae, 0x58, 0x66, 0xee, 0x5e, 0x8f, 0xb4, 0x81, 0xce, 0xa0, 0xa9, 0x9c, | ||||
| 	0xcd, 0x25, 0x6b, 0x65, 0x0f, 0xb0, 0xe8, 0x5e, 0x58, 0x4d, 0x4e, 0x94, 0x9b, 0xfd, 0x9f, 0xa0, | ||||
| 	0x55, 0x88, 0xfc, 0xd0, 0x44, 0xdb, 0xc5, 0xf7, 0xf0, 0x12, 0x3a, 0x07, 0x51, 0x8b, 0xce, 0xf6, | ||||
| 	0x03, 0xcf, 0xe1, 0xbc, 0x01, 0xb5, 0x98, 0xb3, 0x78, 0xb5, 0xa8, 0x9b, 0x7c, 0xff, 0x0b, 0x00, | ||||
| 	0x00, 0xff, 0xff, 0x0e, 0x22, 0xea, 0x15, 0xb6, 0x07, 0x00, 0x00, | ||||
| var fileDescriptorProto3 = []byte{ | ||||
| 	// 733 bytes of a gzipped FileDescriptorProto | ||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x6d, 0x6f, 0xf3, 0x34, | ||||
| 	0x14, 0x25, 0x4d, 0x5f, 0xd2, 0x9b, 0x74, 0x0b, 0x5e, 0x91, 0xbc, 0x02, 0x52, 0x28, 0x12, 0x8a, | ||||
| 	0x78, 0x49, 0xa1, 0xd3, 0xd0, 0x84, 0x10, 0x68, 0x1b, 0x9b, 0xa8, 0xd6, 0x95, 0xca, 0xdd, 0x98, | ||||
| 	0xf8, 0x14, 0xa5, 0xad, 0xdb, 0x46, 0x34, 0x4e, 0x49, 0x1c, 0xa4, 0xfc, 0x1d, 0xfe, 0x28, 0x8f, | ||||
| 	0x6c, 0xa7, 0x5d, 0x36, 0x65, 0xcf, 0xf3, 0x29, 0xf6, 0xf1, 0xb9, 0xf7, 0x9c, 0x1c, 0x5f, 0xc3, | ||||
| 	0xe9, 0x2e, 0x89, 0x79, 0x7c, 0xe6, 0xcb, 0xcf, 0x40, 0x6d, 0x3c, 0xf9, 0x41, 0x56, 0xf9, 0xa8, | ||||
| 	0x77, 0xba, 0x8e, 0xe3, 0xf5, 0x96, 0x2a, 0xca, 0x3c, 0x5b, 0x0d, 0x02, 0x96, 0x2b, 0x62, 0xef, | ||||
| 	0x84, 0xd3, 0x94, 0x2f, 0x03, 0x1e, 0x0c, 0xc4, 0x42, 0x81, 0xfd, 0xff, 0x5b, 0xd0, 0xba, 0xa7, | ||||
| 	0x69, 0x1a, 0xac, 0x29, 0x42, 0x50, 0x67, 0x41, 0x44, 0xb1, 0xe6, 0x68, 0x6e, 0x9b, 0xc8, 0x35, | ||||
| 	0xba, 0x00, 0x63, 0x13, 0x6e, 0x83, 0x24, 0xe4, 0x39, 0xae, 0x39, 0x9a, 0x7b, 0x34, 0xfc, 0xcc, | ||||
| 	0x2b, 0x0b, 0x7a, 0x45, 0xb1, 0xf7, 0x7b, 0x16, 0xc5, 0x59, 0x42, 0x0e, 0x6c, 0xe4, 0x80, 0xb5, | ||||
| 	0xa1, 0xe1, 0x7a, 0xc3, 0xfd, 0x90, 0xf9, 0x8b, 0x08, 0xeb, 0x8e, 0xe6, 0x76, 0x08, 0x28, 0x6c, | ||||
| 	0xc4, 0xae, 0x23, 0xa1, 0x27, 0xec, 0xe0, 0xba, 0xa3, 0xb9, 0x16, 0x91, 0x6b, 0xf4, 0x05, 0x58, | ||||
| 	0x09, 0x4d, 0xb3, 0x2d, 0xf7, 0x17, 0x71, 0xc6, 0x38, 0x6e, 0x39, 0x9a, 0xab, 0x13, 0x53, 0x61, | ||||
| 	0xd7, 0x02, 0x42, 0x5f, 0x42, 0x87, 0x27, 0x19, 0xf5, 0xd3, 0x45, 0xcc, 0xd3, 0x28, 0x60, 0xd8, | ||||
| 	0x70, 0x34, 0xd7, 0x20, 0x96, 0x00, 0x67, 0x05, 0x86, 0xba, 0xd0, 0x48, 0x17, 0x71, 0x42, 0x71, | ||||
| 	0xdb, 0xd1, 0xdc, 0x1a, 0x51, 0x1b, 0x64, 0x83, 0xfe, 0x37, 0xcd, 0x71, 0xc3, 0xd1, 0xdd, 0x3a, | ||||
| 	0x11, 0x4b, 0xf4, 0x29, 0xb4, 0xd3, 0x4d, 0x9c, 0x70, 0x5f, 0xe0, 0x27, 0x8e, 0xee, 0x36, 0x88, | ||||
| 	0x21, 0x81, 0x3b, 0x9a, 0xa3, 0x6f, 0xa1, 0xc9, 0x68, 0xca, 0xe9, 0x12, 0x37, 0x1d, 0xcd, 0x35, | ||||
| 	0x87, 0xdd, 0x97, 0xbf, 0x3e, 0x91, 0x67, 0xa4, 0xe0, 0xa0, 0x73, 0x68, 0x25, 0xfe, 0x2a, 0x63, | ||||
| 	0x2c, 0xc7, 0xb6, 0xa3, 0x7f, 0x30, 0xa9, 0x66, 0x72, 0x2b, 0xb8, 0xe8, 0x67, 0x68, 0x71, 0x9a, | ||||
| 	0x24, 0x41, 0xc8, 0x30, 0x38, 0xba, 0x6b, 0x0e, 0xfb, 0xd5, 0x65, 0x0f, 0x8a, 0x74, 0xc3, 0x78, | ||||
| 	0x92, 0x93, 0x7d, 0x09, 0xba, 0x00, 0x75, 0xff, 0x43, 0x7f, 0x15, 0xd2, 0xed, 0x12, 0x9b, 0xd2, | ||||
| 	0xe8, 0x27, 0xde, 0xfe, 0xae, 0xbd, 0x59, 0x36, 0xff, 0x8d, 0xae, 0x82, 0x6c, 0xcb, 0x53, 0x62, | ||||
| 	0x2a, 0xea, 0xad, 0x60, 0xa2, 0xd1, 0xa1, 0xf2, 0xdf, 0x60, 0x9b, 0x51, 0xdc, 0x91, 0xe2, 0x5f, | ||||
| 	0x55, 0x8b, 0x4f, 0x25, 0xf3, 0x4f, 0x41, 0x54, 0x06, 0x8a, 0x56, 0x12, 0x41, 0xdf, 0x83, 0x11, | ||||
| 	0xb0, 0x9c, 0x6f, 0x42, 0xb6, 0xc6, 0x47, 0x45, 0x52, 0x6a, 0x0e, 0xbd, 0xfd, 0x1c, 0x7a, 0x97, | ||||
| 	0x2c, 0x27, 0x07, 0x16, 0x3a, 0x07, 0x33, 0x0a, 0x58, 0xee, 0xcb, 0x5d, 0x8a, 0x8f, 0xa5, 0x76, | ||||
| 	0x75, 0x11, 0x08, 0xe2, 0x83, 0xe4, 0xa1, 0x73, 0x80, 0x34, 0x9b, 0x47, 0xca, 0x14, 0xfe, 0xb8, | ||||
| 	0xf8, 0xd7, 0x2a, 0xc7, 0xa4, 0x44, 0x44, 0x3f, 0x80, 0xb1, 0xd8, 0x84, 0xdb, 0x65, 0x42, 0x19, | ||||
| 	0x46, 0x52, 0xea, 0x8d, 0xa2, 0x03, 0xad, 0x37, 0x05, 0xab, 0x1c, 0xf8, 0x7e, 0x72, 0xd4, 0xd3, | ||||
| 	0x90, 0x93, 0xf3, 0x35, 0x34, 0x54, 0x70, 0xb5, 0xf7, 0xcc, 0x86, 0xa2, 0xfc, 0x54, 0xbb, 0xd0, | ||||
| 	0x7a, 0x8f, 0x60, 0xbf, 0x4e, 0xb1, 0xa2, 0xeb, 0x37, 0x2f, 0xbb, 0xbe, 0x71, 0x91, 0xcf, 0x6d, | ||||
| 	0xfb, 0xbf, 0x42, 0x53, 0x0d, 0x14, 0x32, 0xa1, 0xf5, 0x38, 0xb9, 0x9b, 0xfc, 0xf1, 0x34, 0xb1, | ||||
| 	0x3f, 0x42, 0x06, 0xd4, 0xa7, 0x8f, 0x93, 0x99, 0xad, 0xa1, 0x0e, 0xb4, 0x67, 0xe3, 0xcb, 0xe9, | ||||
| 	0xec, 0x61, 0x74, 0x7d, 0x67, 0xd7, 0xd0, 0x31, 0x98, 0x57, 0xa3, 0xf1, 0xd8, 0xbf, 0xba, 0x1c, | ||||
| 	0x8d, 0x6f, 0xfe, 0xb2, 0xf5, 0xfe, 0x10, 0x9a, 0xca, 0xac, 0x78, 0x33, 0x73, 0x39, 0xbe, 0xca, | ||||
| 	0x8f, 0xda, 0x88, 0x57, 0xba, 0xc8, 0xb8, 0x32, 0x64, 0x10, 0xb9, 0xee, 0xff, 0xa7, 0xc1, 0x51, | ||||
| 	0x91, 0xd9, 0x53, 0xc8, 0x37, 0xf7, 0xc1, 0x0e, 0x4d, 0xc1, 0x9a, 0xe7, 0x9c, 0xfa, 0x51, 0xb0, | ||||
| 	0xdb, 0x89, 0x39, 0xd0, 0x64, 0xce, 0xdf, 0x55, 0xe6, 0x5c, 0xd4, 0x78, 0x57, 0x39, 0xa7, 0xf7, | ||||
| 	0x8a, 0x5f, 0x4c, 0xd5, 0xfc, 0x19, 0xe9, 0xfd, 0x02, 0xf6, 0x6b, 0x42, 0x39, 0x30, 0x43, 0x05, | ||||
| 	0xd6, 0x2d, 0x07, 0x66, 0x95, 0x93, 0xf9, 0x07, 0x9a, 0x23, 0xc6, 0x85, 0xb7, 0x01, 0xe8, 0x09, | ||||
| 	0xe7, 0x85, 0xa5, 0xcf, 0x5f, 0x5a, 0x52, 0x14, 0x8f, 0x70, 0xae, 0x2c, 0x08, 0x66, 0xef, 0x47, | ||||
| 	0x30, 0xf6, 0x40, 0x59, 0xb2, 0x51, 0x21, 0xd9, 0x28, 0x4b, 0x9e, 0x41, 0x4b, 0xf5, 0x4b, 0x91, | ||||
| 	0x0b, 0xf5, 0x28, 0xd8, 0xa5, 0x85, 0x68, 0xb7, 0x4a, 0x94, 0x48, 0xc6, 0xbc, 0xa9, 0x8e, 0xde, | ||||
| 	0x05, 0x00, 0x00, 0xff, 0xff, 0x75, 0x38, 0xad, 0x84, 0xe4, 0x05, 0x00, 0x00, | ||||
| } | ||||
|   | ||||
							
								
								
									
										18
									
								
								vendor/github.com/gogo/protobuf/proto/proto3_proto/proto3.proto
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								vendor/github.com/gogo/protobuf/proto/proto3_proto/proto3.proto
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -32,7 +32,7 @@ | ||||
| syntax = "proto3"; | ||||
|  | ||||
| import "google/protobuf/any.proto"; | ||||
| import "test_proto/test.proto"; | ||||
| import "testdata/test.proto"; | ||||
|  | ||||
| package proto3_proto; | ||||
|  | ||||
| @@ -58,16 +58,14 @@ message Message { | ||||
|   repeated Humour r_funny = 16; | ||||
|  | ||||
|   map<string, Nested> terrain = 10; | ||||
|   test_proto.SubDefaults proto2_field = 11; | ||||
|   map<string, test_proto.SubDefaults> proto2_value = 13; | ||||
|   testdata.SubDefaults proto2_field = 11; | ||||
|   map<string, testdata.SubDefaults> proto2_value = 13; | ||||
|  | ||||
|   google.protobuf.Any anything = 14; | ||||
|   repeated google.protobuf.Any many_things = 15; | ||||
|  | ||||
|   Message submessage = 17; | ||||
|   repeated Message children = 18; | ||||
|  | ||||
|   map<string, string> string_map = 20; | ||||
| } | ||||
|  | ||||
| message Nested { | ||||
| @@ -86,12 +84,4 @@ message IntMap { | ||||
|  | ||||
| message IntMaps { | ||||
|   repeated IntMap maps = 1; | ||||
| } | ||||
|  | ||||
| message TestUTF8 { | ||||
|   string scalar = 1; | ||||
|   repeated string vector = 2; | ||||
|   oneof oneof { string field = 3; } | ||||
|   map<string, int64> map_key = 4; | ||||
|   map<int64, string> map_value = 5; | ||||
| } | ||||
| } | ||||
							
								
								
									
										18
									
								
								vendor/github.com/gogo/protobuf/proto/proto3_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								vendor/github.com/gogo/protobuf/proto/proto3_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -32,12 +32,11 @@ | ||||
| package proto_test | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
| 	pb "github.com/gogo/protobuf/proto/proto3_proto" | ||||
| 	tpb "github.com/gogo/protobuf/proto/test_proto" | ||||
| 	tpb "github.com/gogo/protobuf/proto/testdata" | ||||
| ) | ||||
|  | ||||
| func TestProto3ZeroValues(t *testing.T) { | ||||
| @@ -134,18 +133,3 @@ func TestProto3SetDefaults(t *testing.T) { | ||||
| 		t.Errorf("with in = %v\nproto.SetDefaults(in) =>\ngot %v\nwant %v", in, got, want) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestUnknownFieldPreservation(t *testing.T) { | ||||
| 	b1 := "\x0a\x05David"      // Known tag 1 | ||||
| 	b2 := "\xc2\x0c\x06Google" // Unknown tag 200 | ||||
| 	b := []byte(b1 + b2) | ||||
|  | ||||
| 	m := new(pb.Message) | ||||
| 	if err := proto.Unmarshal(b, m); err != nil { | ||||
| 		t.Fatalf("proto.Unmarshal: %v", err) | ||||
| 	} | ||||
|  | ||||
| 	if !bytes.Equal(m.XXX_unrecognized, []byte(b2)) { | ||||
| 		t.Fatalf("mismatching unknown fields:\ngot  %q\nwant %q", m.XXX_unrecognized, b2) | ||||
| 	} | ||||
| } | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/github.com/gogo/protobuf/proto/size2_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/gogo/protobuf/proto/size2_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -32,7 +32,6 @@ | ||||
| package proto | ||||
|  | ||||
| import ( | ||||
| 	"math" | ||||
| 	"testing" | ||||
| ) | ||||
|  | ||||
| @@ -52,11 +51,11 @@ func TestVarintSize(t *testing.T) { | ||||
| 		{128, 2}, | ||||
| 		{16383, 2}, | ||||
| 		{16384, 3}, | ||||
| 		{math.MaxInt64, 9}, | ||||
| 		{math.MaxInt64 + 1, 10}, | ||||
| 		{1<<63 - 1, 9}, | ||||
| 		{1 << 63, 10}, | ||||
| 	} | ||||
| 	for _, tc := range testCases { | ||||
| 		size := SizeVarint(tc.n) | ||||
| 		size := sizeVarint(tc.n) | ||||
| 		if size != tc.size { | ||||
| 			t.Errorf("sizeVarint(%d) = %d, want %d", tc.n, size, tc.size) | ||||
| 		} | ||||
|   | ||||
							
								
								
									
										28
									
								
								vendor/github.com/gogo/protobuf/proto/size_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								vendor/github.com/gogo/protobuf/proto/size_test.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -38,7 +38,7 @@ import ( | ||||
|  | ||||
| 	. "github.com/gogo/protobuf/proto" | ||||
| 	proto3pb "github.com/gogo/protobuf/proto/proto3_proto" | ||||
| 	pb "github.com/gogo/protobuf/proto/test_proto" | ||||
| 	pb "github.com/gogo/protobuf/proto/testdata" | ||||
| ) | ||||
|  | ||||
| var messageWithExtension1 = &pb.MyMessage{Count: Int32(7)} | ||||
| @@ -59,30 +59,6 @@ func init() { | ||||
|  | ||||
| } | ||||
|  | ||||
| // non-pointer custom message | ||||
| type nonptrMessage struct{} | ||||
|  | ||||
| func (m nonptrMessage) ProtoMessage()  {} | ||||
| func (m nonptrMessage) Reset()         {} | ||||
| func (m nonptrMessage) String() string { return "" } | ||||
|  | ||||
| func (m nonptrMessage) Marshal() ([]byte, error) { | ||||
| 	return []byte{42}, nil | ||||
| } | ||||
|  | ||||
| // custom message embedding a proto.Message | ||||
| type messageWithEmbedding struct { | ||||
| 	*pb.OtherMessage | ||||
| } | ||||
|  | ||||
| func (m *messageWithEmbedding) ProtoMessage()  {} | ||||
| func (m *messageWithEmbedding) Reset()         {} | ||||
| func (m *messageWithEmbedding) String() string { return "" } | ||||
|  | ||||
| func (m *messageWithEmbedding) Marshal() ([]byte, error) { | ||||
| 	return []byte{42}, nil | ||||
| } | ||||
|  | ||||
| var SizeTests = []struct { | ||||
| 	desc string | ||||
| 	pb   Message | ||||
| @@ -170,8 +146,6 @@ var SizeTests = []struct { | ||||
| 	{"oneof group", &pb.Oneof{Union: &pb.Oneof_FGroup{FGroup: &pb.Oneof_F_Group{X: Int32(52)}}}}, | ||||
| 	{"oneof largest tag", &pb.Oneof{Union: &pb.Oneof_F_Largest_Tag{F_Largest_Tag: 1}}}, | ||||
| 	{"multiple oneofs", &pb.Oneof{Union: &pb.Oneof_F_Int32{F_Int32: 1}, Tormato: &pb.Oneof_Value{Value: 2}}}, | ||||
| 	{"non-pointer message", nonptrMessage{}}, | ||||
| 	{"custom message with embedding", &messageWithEmbedding{&pb.OtherMessage{}}}, | ||||
| } | ||||
|  | ||||
| func TestSize(t *testing.T) { | ||||
|   | ||||
							
								
								
									
										3009
									
								
								vendor/github.com/gogo/protobuf/proto/table_marshal.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3009
									
								
								vendor/github.com/gogo/protobuf/proto/table_marshal.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										388
									
								
								vendor/github.com/gogo/protobuf/proto/table_marshal_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										388
									
								
								vendor/github.com/gogo/protobuf/proto/table_marshal_gogo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,388 +0,0 @@ | ||||
| // Protocol Buffers for Go with Gadgets | ||||
| // | ||||
| // Copyright (c) 2018, The GoGo Authors. All rights reserved. | ||||
| // http://github.com/gogo/protobuf | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| // | ||||
| //     * Redistributions of source code must retain the above copyright | ||||
| // notice, this list of conditions and the following disclaimer. | ||||
| //     * Redistributions in binary form must reproduce the above | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| package proto | ||||
|  | ||||
| import ( | ||||
| 	"reflect" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| // makeMessageRefMarshaler differs a bit from makeMessageMarshaler | ||||
| // It marshal a message T instead of a *T | ||||
| func makeMessageRefMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			siz := u.size(ptr) | ||||
| 			return siz + SizeVarint(uint64(siz)) + tagsize | ||||
| 		}, | ||||
| 		func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			b = appendVarint(b, wiretag) | ||||
| 			siz := u.cachedsize(ptr) | ||||
| 			b = appendVarint(b, uint64(siz)) | ||||
| 			return u.marshal(b, ptr, deterministic) | ||||
| 		} | ||||
| } | ||||
|  | ||||
| // makeMessageRefSliceMarshaler differs quite a lot from makeMessageSliceMarshaler | ||||
| // It marshals a slice of messages []T instead of []*T | ||||
| func makeMessageRefSliceMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			s := ptr.getSlice(u.typ) | ||||
| 			n := 0 | ||||
| 			for i := 0; i < s.Len(); i++ { | ||||
| 				elem := s.Index(i) | ||||
| 				e := elem.Interface() | ||||
| 				v := toAddrPointer(&e, false) | ||||
| 				siz := u.size(v) | ||||
| 				n += siz + SizeVarint(uint64(siz)) + tagsize | ||||
| 			} | ||||
| 			return n | ||||
| 		}, | ||||
| 		func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			s := ptr.getSlice(u.typ) | ||||
| 			var err, errreq error | ||||
| 			for i := 0; i < s.Len(); i++ { | ||||
| 				elem := s.Index(i) | ||||
| 				e := elem.Interface() | ||||
| 				v := toAddrPointer(&e, false) | ||||
| 				b = appendVarint(b, wiretag) | ||||
| 				siz := u.size(v) | ||||
| 				b = appendVarint(b, uint64(siz)) | ||||
| 				b, err = u.marshal(b, v, deterministic) | ||||
|  | ||||
| 				if err != nil { | ||||
| 					if _, ok := err.(*RequiredNotSetError); ok { | ||||
| 						// Required field in submessage is not set. | ||||
| 						// We record the error but keep going, to give a complete marshaling. | ||||
| 						if errreq == nil { | ||||
| 							errreq = err | ||||
| 						} | ||||
| 						continue | ||||
| 					} | ||||
| 					if err == ErrNil { | ||||
| 						err = errRepeatedHasNil | ||||
| 					} | ||||
| 					return b, err | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			return b, errreq | ||||
| 		} | ||||
| } | ||||
|  | ||||
| func makeCustomPtrMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			if ptr.isNil() { | ||||
| 				return 0 | ||||
| 			} | ||||
| 			m := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(custom) | ||||
| 			siz := m.Size() | ||||
| 			return tagsize + SizeVarint(uint64(siz)) + siz | ||||
| 		}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			if ptr.isNil() { | ||||
| 				return b, nil | ||||
| 			} | ||||
| 			m := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(custom) | ||||
| 			siz := m.Size() | ||||
| 			buf, err := m.Marshal() | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			b = appendVarint(b, wiretag) | ||||
| 			b = appendVarint(b, uint64(siz)) | ||||
| 			b = append(b, buf...) | ||||
| 			return b, nil | ||||
| 		} | ||||
| } | ||||
|  | ||||
| func makeCustomMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			m := ptr.asPointerTo(u.typ).Interface().(custom) | ||||
| 			siz := m.Size() | ||||
| 			return tagsize + SizeVarint(uint64(siz)) + siz | ||||
| 		}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			m := ptr.asPointerTo(u.typ).Interface().(custom) | ||||
| 			siz := m.Size() | ||||
| 			buf, err := m.Marshal() | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			b = appendVarint(b, wiretag) | ||||
| 			b = appendVarint(b, uint64(siz)) | ||||
| 			b = append(b, buf...) | ||||
| 			return b, nil | ||||
| 		} | ||||
| } | ||||
|  | ||||
| func makeTimeMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			t := ptr.asPointerTo(u.typ).Interface().(*time.Time) | ||||
| 			ts, err := timestampProto(*t) | ||||
| 			if err != nil { | ||||
| 				return 0 | ||||
| 			} | ||||
| 			siz := Size(ts) | ||||
| 			return tagsize + SizeVarint(uint64(siz)) + siz | ||||
| 		}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			t := ptr.asPointerTo(u.typ).Interface().(*time.Time) | ||||
| 			ts, err := timestampProto(*t) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			buf, err := Marshal(ts) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			b = appendVarint(b, wiretag) | ||||
| 			b = appendVarint(b, uint64(len(buf))) | ||||
| 			b = append(b, buf...) | ||||
| 			return b, nil | ||||
| 		} | ||||
| } | ||||
|  | ||||
| func makeTimePtrMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			if ptr.isNil() { | ||||
| 				return 0 | ||||
| 			} | ||||
| 			t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Time) | ||||
| 			ts, err := timestampProto(*t) | ||||
| 			if err != nil { | ||||
| 				return 0 | ||||
| 			} | ||||
| 			siz := Size(ts) | ||||
| 			return tagsize + SizeVarint(uint64(siz)) + siz | ||||
| 		}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			if ptr.isNil() { | ||||
| 				return b, nil | ||||
| 			} | ||||
| 			t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Time) | ||||
| 			ts, err := timestampProto(*t) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			buf, err := Marshal(ts) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			b = appendVarint(b, wiretag) | ||||
| 			b = appendVarint(b, uint64(len(buf))) | ||||
| 			b = append(b, buf...) | ||||
| 			return b, nil | ||||
| 		} | ||||
| } | ||||
|  | ||||
| func makeTimeSliceMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			s := ptr.getSlice(u.typ) | ||||
| 			n := 0 | ||||
| 			for i := 0; i < s.Len(); i++ { | ||||
| 				elem := s.Index(i) | ||||
| 				t := elem.Interface().(time.Time) | ||||
| 				ts, err := timestampProto(t) | ||||
| 				if err != nil { | ||||
| 					return 0 | ||||
| 				} | ||||
| 				siz := Size(ts) | ||||
| 				n += siz + SizeVarint(uint64(siz)) + tagsize | ||||
| 			} | ||||
| 			return n | ||||
| 		}, | ||||
| 		func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			s := ptr.getSlice(u.typ) | ||||
| 			for i := 0; i < s.Len(); i++ { | ||||
| 				elem := s.Index(i) | ||||
| 				t := elem.Interface().(time.Time) | ||||
| 				ts, err := timestampProto(t) | ||||
| 				if err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				siz := Size(ts) | ||||
| 				buf, err := Marshal(ts) | ||||
| 				if err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				b = appendVarint(b, wiretag) | ||||
| 				b = appendVarint(b, uint64(siz)) | ||||
| 				b = append(b, buf...) | ||||
| 			} | ||||
|  | ||||
| 			return b, nil | ||||
| 		} | ||||
| } | ||||
|  | ||||
| func makeTimePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			s := ptr.getSlice(reflect.PtrTo(u.typ)) | ||||
| 			n := 0 | ||||
| 			for i := 0; i < s.Len(); i++ { | ||||
| 				elem := s.Index(i) | ||||
| 				t := elem.Interface().(*time.Time) | ||||
| 				ts, err := timestampProto(*t) | ||||
| 				if err != nil { | ||||
| 					return 0 | ||||
| 				} | ||||
| 				siz := Size(ts) | ||||
| 				n += siz + SizeVarint(uint64(siz)) + tagsize | ||||
| 			} | ||||
| 			return n | ||||
| 		}, | ||||
| 		func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			s := ptr.getSlice(reflect.PtrTo(u.typ)) | ||||
| 			for i := 0; i < s.Len(); i++ { | ||||
| 				elem := s.Index(i) | ||||
| 				t := elem.Interface().(*time.Time) | ||||
| 				ts, err := timestampProto(*t) | ||||
| 				if err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				siz := Size(ts) | ||||
| 				buf, err := Marshal(ts) | ||||
| 				if err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				b = appendVarint(b, wiretag) | ||||
| 				b = appendVarint(b, uint64(siz)) | ||||
| 				b = append(b, buf...) | ||||
| 			} | ||||
|  | ||||
| 			return b, nil | ||||
| 		} | ||||
| } | ||||
|  | ||||
| func makeDurationMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			d := ptr.asPointerTo(u.typ).Interface().(*time.Duration) | ||||
| 			dur := durationProto(*d) | ||||
| 			siz := Size(dur) | ||||
| 			return tagsize + SizeVarint(uint64(siz)) + siz | ||||
| 		}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			d := ptr.asPointerTo(u.typ).Interface().(*time.Duration) | ||||
| 			dur := durationProto(*d) | ||||
| 			buf, err := Marshal(dur) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			b = appendVarint(b, wiretag) | ||||
| 			b = appendVarint(b, uint64(len(buf))) | ||||
| 			b = append(b, buf...) | ||||
| 			return b, nil | ||||
| 		} | ||||
| } | ||||
|  | ||||
| func makeDurationPtrMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			if ptr.isNil() { | ||||
| 				return 0 | ||||
| 			} | ||||
| 			d := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Duration) | ||||
| 			dur := durationProto(*d) | ||||
| 			siz := Size(dur) | ||||
| 			return tagsize + SizeVarint(uint64(siz)) + siz | ||||
| 		}, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			if ptr.isNil() { | ||||
| 				return b, nil | ||||
| 			} | ||||
| 			d := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Duration) | ||||
| 			dur := durationProto(*d) | ||||
| 			buf, err := Marshal(dur) | ||||
| 			if err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			b = appendVarint(b, wiretag) | ||||
| 			b = appendVarint(b, uint64(len(buf))) | ||||
| 			b = append(b, buf...) | ||||
| 			return b, nil | ||||
| 		} | ||||
| } | ||||
|  | ||||
| func makeDurationSliceMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			s := ptr.getSlice(u.typ) | ||||
| 			n := 0 | ||||
| 			for i := 0; i < s.Len(); i++ { | ||||
| 				elem := s.Index(i) | ||||
| 				d := elem.Interface().(time.Duration) | ||||
| 				dur := durationProto(d) | ||||
| 				siz := Size(dur) | ||||
| 				n += siz + SizeVarint(uint64(siz)) + tagsize | ||||
| 			} | ||||
| 			return n | ||||
| 		}, | ||||
| 		func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			s := ptr.getSlice(u.typ) | ||||
| 			for i := 0; i < s.Len(); i++ { | ||||
| 				elem := s.Index(i) | ||||
| 				d := elem.Interface().(time.Duration) | ||||
| 				dur := durationProto(d) | ||||
| 				siz := Size(dur) | ||||
| 				buf, err := Marshal(dur) | ||||
| 				if err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				b = appendVarint(b, wiretag) | ||||
| 				b = appendVarint(b, uint64(siz)) | ||||
| 				b = append(b, buf...) | ||||
| 			} | ||||
|  | ||||
| 			return b, nil | ||||
| 		} | ||||
| } | ||||
|  | ||||
| func makeDurationPtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { | ||||
| 	return func(ptr pointer, tagsize int) int { | ||||
| 			s := ptr.getSlice(reflect.PtrTo(u.typ)) | ||||
| 			n := 0 | ||||
| 			for i := 0; i < s.Len(); i++ { | ||||
| 				elem := s.Index(i) | ||||
| 				d := elem.Interface().(*time.Duration) | ||||
| 				dur := durationProto(*d) | ||||
| 				siz := Size(dur) | ||||
| 				n += siz + SizeVarint(uint64(siz)) + tagsize | ||||
| 			} | ||||
| 			return n | ||||
| 		}, | ||||
| 		func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { | ||||
| 			s := ptr.getSlice(reflect.PtrTo(u.typ)) | ||||
| 			for i := 0; i < s.Len(); i++ { | ||||
| 				elem := s.Index(i) | ||||
| 				d := elem.Interface().(*time.Duration) | ||||
| 				dur := durationProto(*d) | ||||
| 				siz := Size(dur) | ||||
| 				buf, err := Marshal(dur) | ||||
| 				if err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				b = appendVarint(b, wiretag) | ||||
| 				b = appendVarint(b, uint64(siz)) | ||||
| 				b = append(b, buf...) | ||||
| 			} | ||||
|  | ||||
| 			return b, nil | ||||
| 		} | ||||
| } | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	 Tomas Kral
					Tomas Kral