diff options
Diffstat (limited to 'vendor/github.com/golang/protobuf/proto')
11 files changed, 244 insertions, 244 deletions
diff --git a/vendor/github.com/golang/protobuf/proto/decode.go b/vendor/github.com/golang/protobuf/proto/decode.go index d9aa3c4..63b0f08 100644 --- a/vendor/github.com/golang/protobuf/proto/decode.go +++ b/vendor/github.com/golang/protobuf/proto/decode.go | |||
@@ -186,7 +186,6 @@ func (p *Buffer) DecodeVarint() (x uint64, err error) { | |||
186 | if b&0x80 == 0 { | 186 | if b&0x80 == 0 { |
187 | goto done | 187 | goto done |
188 | } | 188 | } |
189 | // x -= 0x80 << 63 // Always zero. | ||
190 | 189 | ||
191 | return 0, errOverflow | 190 | return 0, errOverflow |
192 | 191 | ||
diff --git a/vendor/github.com/golang/protobuf/proto/deprecated.go b/vendor/github.com/golang/protobuf/proto/deprecated.go new file mode 100644 index 0000000..35b882c --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/deprecated.go | |||
@@ -0,0 +1,63 @@ | |||
1 | // Go support for Protocol Buffers - Google's data interchange format | ||
2 | // | ||
3 | // Copyright 2018 The Go Authors. All rights reserved. | ||
4 | // https://github.com/golang/protobuf | ||
5 | // | ||
6 | // Redistribution and use in source and binary forms, with or without | ||
7 | // modification, are permitted provided that the following conditions are | ||
8 | // met: | ||
9 | // | ||
10 | // * Redistributions of source code must retain the above copyright | ||
11 | // notice, this list of conditions and the following disclaimer. | ||
12 | // * Redistributions in binary form must reproduce the above | ||
13 | // copyright notice, this list of conditions and the following disclaimer | ||
14 | // in the documentation and/or other materials provided with the | ||
15 | // distribution. | ||
16 | // * Neither the name of Google Inc. nor the names of its | ||
17 | // contributors may be used to endorse or promote products derived from | ||
18 | // this software without specific prior written permission. | ||
19 | // | ||
20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
31 | |||
32 | package proto | ||
33 | |||
34 | import "errors" | ||
35 | |||
36 | // Deprecated: do not use. | ||
37 | type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 } | ||
38 | |||
39 | // Deprecated: do not use. | ||
40 | func GetStats() Stats { return Stats{} } | ||
41 | |||
42 | // Deprecated: do not use. | ||
43 | func MarshalMessageSet(interface{}) ([]byte, error) { | ||
44 | return nil, errors.New("proto: not implemented") | ||
45 | } | ||
46 | |||
47 | // Deprecated: do not use. | ||
48 | func UnmarshalMessageSet([]byte, interface{}) error { | ||
49 | return errors.New("proto: not implemented") | ||
50 | } | ||
51 | |||
52 | // Deprecated: do not use. | ||
53 | func MarshalMessageSetJSON(interface{}) ([]byte, error) { | ||
54 | return nil, errors.New("proto: not implemented") | ||
55 | } | ||
56 | |||
57 | // Deprecated: do not use. | ||
58 | func UnmarshalMessageSetJSON([]byte, interface{}) error { | ||
59 | return errors.New("proto: not implemented") | ||
60 | } | ||
61 | |||
62 | // Deprecated: do not use. | ||
63 | func RegisterMessageSetType(Message, int32, string) {} | ||
diff --git a/vendor/github.com/golang/protobuf/proto/equal.go b/vendor/github.com/golang/protobuf/proto/equal.go index d4db5a1..f9b6e41 100644 --- a/vendor/github.com/golang/protobuf/proto/equal.go +++ b/vendor/github.com/golang/protobuf/proto/equal.go | |||
@@ -246,7 +246,8 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool { | |||
246 | return false | 246 | return false |
247 | } | 247 | } |
248 | 248 | ||
249 | m1, m2 := e1.value, e2.value | 249 | m1 := extensionAsLegacyType(e1.value) |
250 | m2 := extensionAsLegacyType(e2.value) | ||
250 | 251 | ||
251 | if m1 == nil && m2 == nil { | 252 | if m1 == nil && m2 == nil { |
252 | // Both have only encoded form. | 253 | // Both have only encoded form. |
diff --git a/vendor/github.com/golang/protobuf/proto/extensions.go b/vendor/github.com/golang/protobuf/proto/extensions.go index 816a3b9..fa88add 100644 --- a/vendor/github.com/golang/protobuf/proto/extensions.go +++ b/vendor/github.com/golang/protobuf/proto/extensions.go | |||
@@ -185,9 +185,25 @@ type Extension struct { | |||
185 | // extension will have only enc set. When such an extension is | 185 | // extension will have only enc set. When such an extension is |
186 | // accessed using GetExtension (or GetExtensions) desc and value | 186 | // accessed using GetExtension (or GetExtensions) desc and value |
187 | // will be set. | 187 | // will be set. |
188 | desc *ExtensionDesc | 188 | desc *ExtensionDesc |
189 | |||
190 | // value is a concrete value for the extension field. Let the type of | ||
191 | // desc.ExtensionType be the "API type" and the type of Extension.value | ||
192 | // be the "storage type". The API type and storage type are the same except: | ||
193 | // * For scalars (except []byte), the API type uses *T, | ||
194 | // while the storage type uses T. | ||
195 | // * For repeated fields, the API type uses []T, while the storage type | ||
196 | // uses *[]T. | ||
197 | // | ||
198 | // The reason for the divergence is so that the storage type more naturally | ||
199 | // matches what is expected of when retrieving the values through the | ||
200 | // protobuf reflection APIs. | ||
201 | // | ||
202 | // The value may only be populated if desc is also populated. | ||
189 | value interface{} | 203 | value interface{} |
190 | enc []byte | 204 | |
205 | // enc is the raw bytes for the extension field. | ||
206 | enc []byte | ||
191 | } | 207 | } |
192 | 208 | ||
193 | // SetRawExtension is for testing only. | 209 | // SetRawExtension is for testing only. |
@@ -334,7 +350,7 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { | |||
334 | // descriptors with the same field number. | 350 | // descriptors with the same field number. |
335 | return nil, errors.New("proto: descriptor conflict") | 351 | return nil, errors.New("proto: descriptor conflict") |
336 | } | 352 | } |
337 | return e.value, nil | 353 | return extensionAsLegacyType(e.value), nil |
338 | } | 354 | } |
339 | 355 | ||
340 | if extension.ExtensionType == nil { | 356 | if extension.ExtensionType == nil { |
@@ -349,11 +365,11 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { | |||
349 | 365 | ||
350 | // Remember the decoded version and drop the encoded version. | 366 | // Remember the decoded version and drop the encoded version. |
351 | // That way it is safe to mutate what we return. | 367 | // That way it is safe to mutate what we return. |
352 | e.value = v | 368 | e.value = extensionAsStorageType(v) |
353 | e.desc = extension | 369 | e.desc = extension |
354 | e.enc = nil | 370 | e.enc = nil |
355 | emap[extension.Field] = e | 371 | emap[extension.Field] = e |
356 | return e.value, nil | 372 | return extensionAsLegacyType(e.value), nil |
357 | } | 373 | } |
358 | 374 | ||
359 | // defaultExtensionValue returns the default value for extension. | 375 | // defaultExtensionValue returns the default value for extension. |
@@ -488,7 +504,7 @@ func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error | |||
488 | } | 504 | } |
489 | typ := reflect.TypeOf(extension.ExtensionType) | 505 | typ := reflect.TypeOf(extension.ExtensionType) |
490 | if typ != reflect.TypeOf(value) { | 506 | if typ != reflect.TypeOf(value) { |
491 | return errors.New("proto: bad extension value type") | 507 | return fmt.Errorf("proto: bad extension value type. got: %T, want: %T", value, extension.ExtensionType) |
492 | } | 508 | } |
493 | // nil extension values need to be caught early, because the | 509 | // nil extension values need to be caught early, because the |
494 | // encoder can't distinguish an ErrNil due to a nil extension | 510 | // encoder can't distinguish an ErrNil due to a nil extension |
@@ -500,7 +516,7 @@ func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error | |||
500 | } | 516 | } |
501 | 517 | ||
502 | extmap := epb.extensionsWrite() | 518 | extmap := epb.extensionsWrite() |
503 | extmap[extension.Field] = Extension{desc: extension, value: value} | 519 | extmap[extension.Field] = Extension{desc: extension, value: extensionAsStorageType(value)} |
504 | return nil | 520 | return nil |
505 | } | 521 | } |
506 | 522 | ||
@@ -541,3 +557,51 @@ func RegisterExtension(desc *ExtensionDesc) { | |||
541 | func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { | 557 | func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { |
542 | return extensionMaps[reflect.TypeOf(pb).Elem()] | 558 | return extensionMaps[reflect.TypeOf(pb).Elem()] |
543 | } | 559 | } |
560 | |||
561 | // extensionAsLegacyType converts an value in the storage type as the API type. | ||
562 | // See Extension.value. | ||
563 | func extensionAsLegacyType(v interface{}) interface{} { | ||
564 | switch rv := reflect.ValueOf(v); rv.Kind() { | ||
565 | case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String: | ||
566 | // Represent primitive types as a pointer to the value. | ||
567 | rv2 := reflect.New(rv.Type()) | ||
568 | rv2.Elem().Set(rv) | ||
569 | v = rv2.Interface() | ||
570 | case reflect.Ptr: | ||
571 | // Represent slice types as the value itself. | ||
572 | switch rv.Type().Elem().Kind() { | ||
573 | case reflect.Slice: | ||
574 | if rv.IsNil() { | ||
575 | v = reflect.Zero(rv.Type().Elem()).Interface() | ||
576 | } else { | ||
577 | v = rv.Elem().Interface() | ||
578 | } | ||
579 | } | ||
580 | } | ||
581 | return v | ||
582 | } | ||
583 | |||
584 | // extensionAsStorageType converts an value in the API type as the storage type. | ||
585 | // See Extension.value. | ||
586 | func extensionAsStorageType(v interface{}) interface{} { | ||
587 | switch rv := reflect.ValueOf(v); rv.Kind() { | ||
588 | case reflect.Ptr: | ||
589 | // Represent slice types as the value itself. | ||
590 | switch rv.Type().Elem().Kind() { | ||
591 | case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64, reflect.String: | ||
592 | if rv.IsNil() { | ||
593 | v = reflect.Zero(rv.Type().Elem()).Interface() | ||
594 | } else { | ||
595 | v = rv.Elem().Interface() | ||
596 | } | ||
597 | } | ||
598 | case reflect.Slice: | ||
599 | // Represent slice types as a pointer to the value. | ||
600 | if rv.Type().Elem().Kind() != reflect.Uint8 { | ||
601 | rv2 := reflect.New(rv.Type()) | ||
602 | rv2.Elem().Set(rv) | ||
603 | v = rv2.Interface() | ||
604 | } | ||
605 | } | ||
606 | return v | ||
607 | } | ||
diff --git a/vendor/github.com/golang/protobuf/proto/lib.go b/vendor/github.com/golang/protobuf/proto/lib.go index 75565cc..fdd328b 100644 --- a/vendor/github.com/golang/protobuf/proto/lib.go +++ b/vendor/github.com/golang/protobuf/proto/lib.go | |||
@@ -341,26 +341,6 @@ type Message interface { | |||
341 | ProtoMessage() | 341 | ProtoMessage() |
342 | } | 342 | } |
343 | 343 | ||
344 | // Stats records allocation details about the protocol buffer encoders | ||
345 | // and decoders. Useful for tuning the library itself. | ||
346 | type Stats struct { | ||
347 | Emalloc uint64 // mallocs in encode | ||
348 | Dmalloc uint64 // mallocs in decode | ||
349 | Encode uint64 // number of encodes | ||
350 | Decode uint64 // number of decodes | ||
351 | Chit uint64 // number of cache hits | ||
352 | Cmiss uint64 // number of cache misses | ||
353 | Size uint64 // number of sizes | ||
354 | } | ||
355 | |||
356 | // Set to true to enable stats collection. | ||
357 | const collectStats = false | ||
358 | |||
359 | var stats Stats | ||
360 | |||
361 | // GetStats returns a copy of the global Stats structure. | ||
362 | func GetStats() Stats { return stats } | ||
363 | |||
364 | // A Buffer is a buffer manager for marshaling and unmarshaling | 344 | // A Buffer is a buffer manager for marshaling and unmarshaling |
365 | // protocol buffers. It may be reused between invocations to | 345 | // protocol buffers. It may be reused between invocations to |
366 | // reduce memory usage. It is not necessary to use a Buffer; | 346 | // reduce memory usage. It is not necessary to use a Buffer; |
@@ -960,13 +940,19 @@ func isProto3Zero(v reflect.Value) bool { | |||
960 | return false | 940 | return false |
961 | } | 941 | } |
962 | 942 | ||
963 | // ProtoPackageIsVersion2 is referenced from generated protocol buffer files | 943 | const ( |
964 | // to assert that that code is compatible with this version of the proto package. | 944 | // ProtoPackageIsVersion3 is referenced from generated protocol buffer files |
965 | const ProtoPackageIsVersion2 = true | 945 | // to assert that that code is compatible with this version of the proto package. |
946 | ProtoPackageIsVersion3 = true | ||
947 | |||
948 | // ProtoPackageIsVersion2 is referenced from generated protocol buffer files | ||
949 | // to assert that that code is compatible with this version of the proto package. | ||
950 | ProtoPackageIsVersion2 = true | ||
966 | 951 | ||
967 | // ProtoPackageIsVersion1 is referenced from generated protocol buffer files | 952 | // ProtoPackageIsVersion1 is referenced from generated protocol buffer files |
968 | // to assert that that code is compatible with this version of the proto package. | 953 | // to assert that that code is compatible with this version of the proto package. |
969 | const ProtoPackageIsVersion1 = true | 954 | ProtoPackageIsVersion1 = true |
955 | ) | ||
970 | 956 | ||
971 | // InternalMessageInfo is a type used internally by generated .pb.go files. | 957 | // InternalMessageInfo is a type used internally by generated .pb.go files. |
972 | // This type is not intended to be used by non-generated code. | 958 | // This type is not intended to be used by non-generated code. |
diff --git a/vendor/github.com/golang/protobuf/proto/message_set.go b/vendor/github.com/golang/protobuf/proto/message_set.go index 3b6ca41..f48a756 100644 --- a/vendor/github.com/golang/protobuf/proto/message_set.go +++ b/vendor/github.com/golang/protobuf/proto/message_set.go | |||
@@ -36,13 +36,7 @@ package proto | |||
36 | */ | 36 | */ |
37 | 37 | ||
38 | import ( | 38 | import ( |
39 | "bytes" | ||
40 | "encoding/json" | ||
41 | "errors" | 39 | "errors" |
42 | "fmt" | ||
43 | "reflect" | ||
44 | "sort" | ||
45 | "sync" | ||
46 | ) | 40 | ) |
47 | 41 | ||
48 | // errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. | 42 | // errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. |
@@ -145,46 +139,9 @@ func skipVarint(buf []byte) []byte { | |||
145 | return buf[i+1:] | 139 | return buf[i+1:] |
146 | } | 140 | } |
147 | 141 | ||
148 | // MarshalMessageSet encodes the extension map represented by m in the message set wire format. | 142 | // unmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. |
149 | // It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. | ||
150 | func MarshalMessageSet(exts interface{}) ([]byte, error) { | ||
151 | return marshalMessageSet(exts, false) | ||
152 | } | ||
153 | |||
154 | // marshaMessageSet implements above function, with the opt to turn on / off deterministic during Marshal. | ||
155 | func marshalMessageSet(exts interface{}, deterministic bool) ([]byte, error) { | ||
156 | switch exts := exts.(type) { | ||
157 | case *XXX_InternalExtensions: | ||
158 | var u marshalInfo | ||
159 | siz := u.sizeMessageSet(exts) | ||
160 | b := make([]byte, 0, siz) | ||
161 | return u.appendMessageSet(b, exts, deterministic) | ||
162 | |||
163 | case map[int32]Extension: | ||
164 | // This is an old-style extension map. | ||
165 | // Wrap it in a new-style XXX_InternalExtensions. | ||
166 | ie := XXX_InternalExtensions{ | ||
167 | p: &struct { | ||
168 | mu sync.Mutex | ||
169 | extensionMap map[int32]Extension | ||
170 | }{ | ||
171 | extensionMap: exts, | ||
172 | }, | ||
173 | } | ||
174 | |||
175 | var u marshalInfo | ||
176 | siz := u.sizeMessageSet(&ie) | ||
177 | b := make([]byte, 0, siz) | ||
178 | return u.appendMessageSet(b, &ie, deterministic) | ||
179 | |||
180 | default: | ||
181 | return nil, errors.New("proto: not an extension map") | ||
182 | } | ||
183 | } | ||
184 | |||
185 | // UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. | ||
186 | // It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option. | 143 | // It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option. |
187 | func UnmarshalMessageSet(buf []byte, exts interface{}) error { | 144 | func unmarshalMessageSet(buf []byte, exts interface{}) error { |
188 | var m map[int32]Extension | 145 | var m map[int32]Extension |
189 | switch exts := exts.(type) { | 146 | switch exts := exts.(type) { |
190 | case *XXX_InternalExtensions: | 147 | case *XXX_InternalExtensions: |
@@ -222,93 +179,3 @@ func UnmarshalMessageSet(buf []byte, exts interface{}) error { | |||
222 | } | 179 | } |
223 | return nil | 180 | return nil |
224 | } | 181 | } |
225 | |||
226 | // MarshalMessageSetJSON encodes the extension map represented by m in JSON format. | ||
227 | // It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. | ||
228 | func MarshalMessageSetJSON(exts interface{}) ([]byte, error) { | ||
229 | var m map[int32]Extension | ||
230 | switch exts := exts.(type) { | ||
231 | case *XXX_InternalExtensions: | ||
232 | var mu sync.Locker | ||
233 | m, mu = exts.extensionsRead() | ||
234 | if m != nil { | ||
235 | // Keep the extensions map locked until we're done marshaling to prevent | ||
236 | // races between marshaling and unmarshaling the lazily-{en,de}coded | ||
237 | // values. | ||
238 | mu.Lock() | ||
239 | defer mu.Unlock() | ||
240 | } | ||
241 | case map[int32]Extension: | ||
242 | m = exts | ||
243 | default: | ||
244 | return nil, errors.New("proto: not an extension map") | ||
245 | } | ||
246 | var b bytes.Buffer | ||
247 | b.WriteByte('{') | ||
248 | |||
249 | // Process the map in key order for deterministic output. | ||
250 | ids := make([]int32, 0, len(m)) | ||
251 | for id := range m { | ||
252 | ids = append(ids, id) | ||
253 | } | ||
254 | sort.Sort(int32Slice(ids)) // int32Slice defined in text.go | ||
255 | |||
256 | for i, id := range ids { | ||
257 | ext := m[id] | ||
258 | msd, ok := messageSetMap[id] | ||
259 | if !ok { | ||
260 | // Unknown type; we can't render it, so skip it. | ||
261 | continue | ||
262 | } | ||
263 | |||
264 | if i > 0 && b.Len() > 1 { | ||
265 | b.WriteByte(',') | ||
266 | } | ||
267 | |||
268 | fmt.Fprintf(&b, `"[%s]":`, msd.name) | ||
269 | |||
270 | x := ext.value | ||
271 | if x == nil { | ||
272 | x = reflect.New(msd.t.Elem()).Interface() | ||
273 | if err := Unmarshal(ext.enc, x.(Message)); err != nil { | ||
274 | return nil, err | ||
275 | } | ||
276 | } | ||
277 | d, err := json.Marshal(x) | ||
278 | if err != nil { | ||
279 | return nil, err | ||
280 | } | ||
281 | b.Write(d) | ||
282 | } | ||
283 | b.WriteByte('}') | ||
284 | return b.Bytes(), nil | ||
285 | } | ||
286 | |||
287 | // UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. | ||
288 | // It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. | ||
289 | func UnmarshalMessageSetJSON(buf []byte, exts interface{}) error { | ||
290 | // Common-case fast path. | ||
291 | if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { | ||
292 | return nil | ||
293 | } | ||
294 | |||
295 | // This is fairly tricky, and it's not clear that it is needed. | ||
296 | return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented") | ||
297 | } | ||
298 | |||
299 | // A global registry of types that can be used in a MessageSet. | ||
300 | |||
301 | var messageSetMap = make(map[int32]messageSetDesc) | ||
302 | |||
303 | type messageSetDesc struct { | ||
304 | t reflect.Type // pointer to struct | ||
305 | name string | ||
306 | } | ||
307 | |||
308 | // RegisterMessageSetType is called from the generated code. | ||
309 | func RegisterMessageSetType(m Message, fieldNum int32, name string) { | ||
310 | messageSetMap[fieldNum] = messageSetDesc{ | ||
311 | t: reflect.TypeOf(m), | ||
312 | name: name, | ||
313 | } | ||
314 | } | ||
diff --git a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go index b6cad90..94fa919 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go | |||
@@ -79,10 +79,13 @@ func toPointer(i *Message) pointer { | |||
79 | 79 | ||
80 | // toAddrPointer converts an interface to a pointer that points to | 80 | // toAddrPointer converts an interface to a pointer that points to |
81 | // the interface data. | 81 | // the interface data. |
82 | func toAddrPointer(i *interface{}, isptr bool) pointer { | 82 | func toAddrPointer(i *interface{}, isptr, deref bool) pointer { |
83 | v := reflect.ValueOf(*i) | 83 | v := reflect.ValueOf(*i) |
84 | u := reflect.New(v.Type()) | 84 | u := reflect.New(v.Type()) |
85 | u.Elem().Set(v) | 85 | u.Elem().Set(v) |
86 | if deref { | ||
87 | u = u.Elem() | ||
88 | } | ||
86 | return pointer{v: u} | 89 | return pointer{v: u} |
87 | } | 90 | } |
88 | 91 | ||
diff --git a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go index d55a335..dbfffe0 100644 --- a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go +++ b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go | |||
@@ -85,16 +85,21 @@ func toPointer(i *Message) pointer { | |||
85 | 85 | ||
86 | // toAddrPointer converts an interface to a pointer that points to | 86 | // toAddrPointer converts an interface to a pointer that points to |
87 | // the interface data. | 87 | // the interface data. |
88 | func toAddrPointer(i *interface{}, isptr bool) pointer { | 88 | func toAddrPointer(i *interface{}, isptr, deref bool) (p pointer) { |
89 | // Super-tricky - read or get the address of data word of interface value. | 89 | // Super-tricky - read or get the address of data word of interface value. |
90 | if isptr { | 90 | if isptr { |
91 | // The interface is of pointer type, thus it is a direct interface. | 91 | // The interface is of pointer type, thus it is a direct interface. |
92 | // The data word is the pointer data itself. We take its address. | 92 | // The data word is the pointer data itself. We take its address. |
93 | return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} | 93 | p = pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)} |
94 | } else { | ||
95 | // The interface is not of pointer type. The data word is the pointer | ||
96 | // to the data. | ||
97 | p = pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} | ||
94 | } | 98 | } |
95 | // The interface is not of pointer type. The data word is the pointer | 99 | if deref { |
96 | // to the data. | 100 | p.p = *(*unsafe.Pointer)(p.p) |
97 | return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]} | 101 | } |
102 | return p | ||
98 | } | 103 | } |
99 | 104 | ||
100 | // valToPointer converts v to a pointer. v must be of pointer type. | 105 | // valToPointer converts v to a pointer. v must be of pointer type. |
diff --git a/vendor/github.com/golang/protobuf/proto/properties.go b/vendor/github.com/golang/protobuf/proto/properties.go index 50b99b8..79668ff 100644 --- a/vendor/github.com/golang/protobuf/proto/properties.go +++ b/vendor/github.com/golang/protobuf/proto/properties.go | |||
@@ -334,9 +334,6 @@ func GetProperties(t reflect.Type) *StructProperties { | |||
334 | sprop, ok := propertiesMap[t] | 334 | sprop, ok := propertiesMap[t] |
335 | propertiesMu.RUnlock() | 335 | propertiesMu.RUnlock() |
336 | if ok { | 336 | if ok { |
337 | if collectStats { | ||
338 | stats.Chit++ | ||
339 | } | ||
340 | return sprop | 337 | return sprop |
341 | } | 338 | } |
342 | 339 | ||
@@ -346,17 +343,20 @@ func GetProperties(t reflect.Type) *StructProperties { | |||
346 | return sprop | 343 | return sprop |
347 | } | 344 | } |
348 | 345 | ||
346 | type ( | ||
347 | oneofFuncsIface interface { | ||
348 | XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) | ||
349 | } | ||
350 | oneofWrappersIface interface { | ||
351 | XXX_OneofWrappers() []interface{} | ||
352 | } | ||
353 | ) | ||
354 | |||
349 | // getPropertiesLocked requires that propertiesMu is held. | 355 | // getPropertiesLocked requires that propertiesMu is held. |
350 | func getPropertiesLocked(t reflect.Type) *StructProperties { | 356 | func getPropertiesLocked(t reflect.Type) *StructProperties { |
351 | if prop, ok := propertiesMap[t]; ok { | 357 | if prop, ok := propertiesMap[t]; ok { |
352 | if collectStats { | ||
353 | stats.Chit++ | ||
354 | } | ||
355 | return prop | 358 | return prop |
356 | } | 359 | } |
357 | if collectStats { | ||
358 | stats.Cmiss++ | ||
359 | } | ||
360 | 360 | ||
361 | prop := new(StructProperties) | 361 | prop := new(StructProperties) |
362 | // in case of recursive protos, fill this in now. | 362 | // in case of recursive protos, fill this in now. |
@@ -391,13 +391,14 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { | |||
391 | // Re-order prop.order. | 391 | // Re-order prop.order. |
392 | sort.Sort(prop) | 392 | sort.Sort(prop) |
393 | 393 | ||
394 | type oneofMessage interface { | 394 | var oots []interface{} |
395 | XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) | 395 | switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { |
396 | case oneofFuncsIface: | ||
397 | _, _, _, oots = m.XXX_OneofFuncs() | ||
398 | case oneofWrappersIface: | ||
399 | oots = m.XXX_OneofWrappers() | ||
396 | } | 400 | } |
397 | if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok { | 401 | if len(oots) > 0 { |
398 | var oots []interface{} | ||
399 | _, _, _, oots = om.XXX_OneofFuncs() | ||
400 | |||
401 | // Interpret oneof metadata. | 402 | // Interpret oneof metadata. |
402 | prop.OneofTypes = make(map[string]*OneofProperties) | 403 | prop.OneofTypes = make(map[string]*OneofProperties) |
403 | for _, oot := range oots { | 404 | for _, oot := range oots { |
diff --git a/vendor/github.com/golang/protobuf/proto/table_marshal.go b/vendor/github.com/golang/protobuf/proto/table_marshal.go index b167944..5cb11fa 100644 --- a/vendor/github.com/golang/protobuf/proto/table_marshal.go +++ b/vendor/github.com/golang/protobuf/proto/table_marshal.go | |||
@@ -87,6 +87,7 @@ type marshalElemInfo struct { | |||
87 | sizer sizer | 87 | sizer sizer |
88 | marshaler marshaler | 88 | marshaler marshaler |
89 | isptr bool // elem is pointer typed, thus interface of this type is a direct interface (extension only) | 89 | isptr bool // elem is pointer typed, thus interface of this type is a direct interface (extension only) |
90 | deref bool // dereference the pointer before operating on it; implies isptr | ||
90 | } | 91 | } |
91 | 92 | ||
92 | var ( | 93 | var ( |
@@ -320,8 +321,11 @@ func (u *marshalInfo) computeMarshalInfo() { | |||
320 | 321 | ||
321 | // get oneof implementers | 322 | // get oneof implementers |
322 | var oneofImplementers []interface{} | 323 | var oneofImplementers []interface{} |
323 | if m, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok { | 324 | switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { |
325 | case oneofFuncsIface: | ||
324 | _, _, _, oneofImplementers = m.XXX_OneofFuncs() | 326 | _, _, _, oneofImplementers = m.XXX_OneofFuncs() |
327 | case oneofWrappersIface: | ||
328 | oneofImplementers = m.XXX_OneofWrappers() | ||
325 | } | 329 | } |
326 | 330 | ||
327 | n := t.NumField() | 331 | n := t.NumField() |
@@ -407,13 +411,22 @@ func (u *marshalInfo) getExtElemInfo(desc *ExtensionDesc) *marshalElemInfo { | |||
407 | panic("tag is not an integer") | 411 | panic("tag is not an integer") |
408 | } | 412 | } |
409 | wt := wiretype(tags[0]) | 413 | wt := wiretype(tags[0]) |
414 | if t.Kind() == reflect.Ptr && t.Elem().Kind() != reflect.Struct { | ||
415 | t = t.Elem() | ||
416 | } | ||
410 | sizer, marshaler := typeMarshaler(t, tags, false, false) | 417 | sizer, marshaler := typeMarshaler(t, tags, false, false) |
418 | var deref bool | ||
419 | if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 { | ||
420 | t = reflect.PtrTo(t) | ||
421 | deref = true | ||
422 | } | ||
411 | e = &marshalElemInfo{ | 423 | e = &marshalElemInfo{ |
412 | wiretag: uint64(tag)<<3 | wt, | 424 | wiretag: uint64(tag)<<3 | wt, |
413 | tagsize: SizeVarint(uint64(tag) << 3), | 425 | tagsize: SizeVarint(uint64(tag) << 3), |
414 | sizer: sizer, | 426 | sizer: sizer, |
415 | marshaler: marshaler, | 427 | marshaler: marshaler, |
416 | isptr: t.Kind() == reflect.Ptr, | 428 | isptr: t.Kind() == reflect.Ptr, |
429 | deref: deref, | ||
417 | } | 430 | } |
418 | 431 | ||
419 | // update cache | 432 | // update cache |
@@ -448,7 +461,7 @@ func (fi *marshalFieldInfo) computeMarshalFieldInfo(f *reflect.StructField) { | |||
448 | 461 | ||
449 | func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []interface{}) { | 462 | func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []interface{}) { |
450 | fi.field = toField(f) | 463 | fi.field = toField(f) |
451 | fi.wiretag = 1<<31 - 1 // Use a large tag number, make oneofs sorted at the end. This tag will not appear on the wire. | 464 | fi.wiretag = math.MaxInt32 // Use a large tag number, make oneofs sorted at the end. This tag will not appear on the wire. |
452 | fi.isPointer = true | 465 | fi.isPointer = true |
453 | fi.sizer, fi.marshaler = makeOneOfMarshaler(fi, f) | 466 | fi.sizer, fi.marshaler = makeOneOfMarshaler(fi, f) |
454 | fi.oneofElems = make(map[reflect.Type]*marshalElemInfo) | 467 | fi.oneofElems = make(map[reflect.Type]*marshalElemInfo) |
@@ -476,10 +489,6 @@ func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofI | |||
476 | } | 489 | } |
477 | } | 490 | } |
478 | 491 | ||
479 | type oneofMessage interface { | ||
480 | XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) | ||
481 | } | ||
482 | |||
483 | // wiretype returns the wire encoding of the type. | 492 | // wiretype returns the wire encoding of the type. |
484 | func wiretype(encoding string) uint64 { | 493 | func wiretype(encoding string) uint64 { |
485 | switch encoding { | 494 | switch encoding { |
@@ -2310,8 +2319,8 @@ func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) { | |||
2310 | for _, k := range m.MapKeys() { | 2319 | for _, k := range m.MapKeys() { |
2311 | ki := k.Interface() | 2320 | ki := k.Interface() |
2312 | vi := m.MapIndex(k).Interface() | 2321 | vi := m.MapIndex(k).Interface() |
2313 | kaddr := toAddrPointer(&ki, false) // pointer to key | 2322 | kaddr := toAddrPointer(&ki, false, false) // pointer to key |
2314 | vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value | 2323 | vaddr := toAddrPointer(&vi, valIsPtr, false) // pointer to value |
2315 | siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1) | 2324 | siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1) |
2316 | n += siz + SizeVarint(uint64(siz)) + tagsize | 2325 | n += siz + SizeVarint(uint64(siz)) + tagsize |
2317 | } | 2326 | } |
@@ -2329,8 +2338,8 @@ func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) { | |||
2329 | for _, k := range keys { | 2338 | for _, k := range keys { |
2330 | ki := k.Interface() | 2339 | ki := k.Interface() |
2331 | vi := m.MapIndex(k).Interface() | 2340 | vi := m.MapIndex(k).Interface() |
2332 | kaddr := toAddrPointer(&ki, false) // pointer to key | 2341 | kaddr := toAddrPointer(&ki, false, false) // pointer to key |
2333 | vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value | 2342 | vaddr := toAddrPointer(&vi, valIsPtr, false) // pointer to value |
2334 | b = appendVarint(b, tag) | 2343 | b = appendVarint(b, tag) |
2335 | siz := keySizer(kaddr, 1) + valCachedSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1) | 2344 | siz := keySizer(kaddr, 1) + valCachedSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1) |
2336 | b = appendVarint(b, uint64(siz)) | 2345 | b = appendVarint(b, uint64(siz)) |
@@ -2399,7 +2408,7 @@ func (u *marshalInfo) sizeExtensions(ext *XXX_InternalExtensions) int { | |||
2399 | // the last time this function was called. | 2408 | // the last time this function was called. |
2400 | ei := u.getExtElemInfo(e.desc) | 2409 | ei := u.getExtElemInfo(e.desc) |
2401 | v := e.value | 2410 | v := e.value |
2402 | p := toAddrPointer(&v, ei.isptr) | 2411 | p := toAddrPointer(&v, ei.isptr, ei.deref) |
2403 | n += ei.sizer(p, ei.tagsize) | 2412 | n += ei.sizer(p, ei.tagsize) |
2404 | } | 2413 | } |
2405 | mu.Unlock() | 2414 | mu.Unlock() |
@@ -2434,7 +2443,7 @@ func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, de | |||
2434 | 2443 | ||
2435 | ei := u.getExtElemInfo(e.desc) | 2444 | ei := u.getExtElemInfo(e.desc) |
2436 | v := e.value | 2445 | v := e.value |
2437 | p := toAddrPointer(&v, ei.isptr) | 2446 | p := toAddrPointer(&v, ei.isptr, ei.deref) |
2438 | b, err = ei.marshaler(b, p, ei.wiretag, deterministic) | 2447 | b, err = ei.marshaler(b, p, ei.wiretag, deterministic) |
2439 | if !nerr.Merge(err) { | 2448 | if !nerr.Merge(err) { |
2440 | return b, err | 2449 | return b, err |
@@ -2465,7 +2474,7 @@ func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, de | |||
2465 | 2474 | ||
2466 | ei := u.getExtElemInfo(e.desc) | 2475 | ei := u.getExtElemInfo(e.desc) |
2467 | v := e.value | 2476 | v := e.value |
2468 | p := toAddrPointer(&v, ei.isptr) | 2477 | p := toAddrPointer(&v, ei.isptr, ei.deref) |
2469 | b, err = ei.marshaler(b, p, ei.wiretag, deterministic) | 2478 | b, err = ei.marshaler(b, p, ei.wiretag, deterministic) |
2470 | if !nerr.Merge(err) { | 2479 | if !nerr.Merge(err) { |
2471 | return b, err | 2480 | return b, err |
@@ -2510,7 +2519,7 @@ func (u *marshalInfo) sizeMessageSet(ext *XXX_InternalExtensions) int { | |||
2510 | 2519 | ||
2511 | ei := u.getExtElemInfo(e.desc) | 2520 | ei := u.getExtElemInfo(e.desc) |
2512 | v := e.value | 2521 | v := e.value |
2513 | p := toAddrPointer(&v, ei.isptr) | 2522 | p := toAddrPointer(&v, ei.isptr, ei.deref) |
2514 | n += ei.sizer(p, 1) // message, tag = 3 (size=1) | 2523 | n += ei.sizer(p, 1) // message, tag = 3 (size=1) |
2515 | } | 2524 | } |
2516 | mu.Unlock() | 2525 | mu.Unlock() |
@@ -2553,7 +2562,7 @@ func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, de | |||
2553 | 2562 | ||
2554 | ei := u.getExtElemInfo(e.desc) | 2563 | ei := u.getExtElemInfo(e.desc) |
2555 | v := e.value | 2564 | v := e.value |
2556 | p := toAddrPointer(&v, ei.isptr) | 2565 | p := toAddrPointer(&v, ei.isptr, ei.deref) |
2557 | b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic) | 2566 | b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic) |
2558 | if !nerr.Merge(err) { | 2567 | if !nerr.Merge(err) { |
2559 | return b, err | 2568 | return b, err |
@@ -2591,7 +2600,7 @@ func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, de | |||
2591 | 2600 | ||
2592 | ei := u.getExtElemInfo(e.desc) | 2601 | ei := u.getExtElemInfo(e.desc) |
2593 | v := e.value | 2602 | v := e.value |
2594 | p := toAddrPointer(&v, ei.isptr) | 2603 | p := toAddrPointer(&v, ei.isptr, ei.deref) |
2595 | b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic) | 2604 | b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic) |
2596 | b = append(b, 1<<3|WireEndGroup) | 2605 | b = append(b, 1<<3|WireEndGroup) |
2597 | if !nerr.Merge(err) { | 2606 | if !nerr.Merge(err) { |
@@ -2621,7 +2630,7 @@ func (u *marshalInfo) sizeV1Extensions(m map[int32]Extension) int { | |||
2621 | 2630 | ||
2622 | ei := u.getExtElemInfo(e.desc) | 2631 | ei := u.getExtElemInfo(e.desc) |
2623 | v := e.value | 2632 | v := e.value |
2624 | p := toAddrPointer(&v, ei.isptr) | 2633 | p := toAddrPointer(&v, ei.isptr, ei.deref) |
2625 | n += ei.sizer(p, ei.tagsize) | 2634 | n += ei.sizer(p, ei.tagsize) |
2626 | } | 2635 | } |
2627 | return n | 2636 | return n |
@@ -2656,7 +2665,7 @@ func (u *marshalInfo) appendV1Extensions(b []byte, m map[int32]Extension, determ | |||
2656 | 2665 | ||
2657 | ei := u.getExtElemInfo(e.desc) | 2666 | ei := u.getExtElemInfo(e.desc) |
2658 | v := e.value | 2667 | v := e.value |
2659 | p := toAddrPointer(&v, ei.isptr) | 2668 | p := toAddrPointer(&v, ei.isptr, ei.deref) |
2660 | b, err = ei.marshaler(b, p, ei.wiretag, deterministic) | 2669 | b, err = ei.marshaler(b, p, ei.wiretag, deterministic) |
2661 | if !nerr.Merge(err) { | 2670 | if !nerr.Merge(err) { |
2662 | return b, err | 2671 | return b, err |
diff --git a/vendor/github.com/golang/protobuf/proto/table_unmarshal.go b/vendor/github.com/golang/protobuf/proto/table_unmarshal.go index ebf1caa..acee2fc 100644 --- a/vendor/github.com/golang/protobuf/proto/table_unmarshal.go +++ b/vendor/github.com/golang/protobuf/proto/table_unmarshal.go | |||
@@ -136,7 +136,7 @@ func (u *unmarshalInfo) unmarshal(m pointer, b []byte) error { | |||
136 | u.computeUnmarshalInfo() | 136 | u.computeUnmarshalInfo() |
137 | } | 137 | } |
138 | if u.isMessageSet { | 138 | if u.isMessageSet { |
139 | return UnmarshalMessageSet(b, m.offset(u.extensions).toExtensions()) | 139 | return unmarshalMessageSet(b, m.offset(u.extensions).toExtensions()) |
140 | } | 140 | } |
141 | var reqMask uint64 // bitmask of required fields we've seen. | 141 | var reqMask uint64 // bitmask of required fields we've seen. |
142 | var errLater error | 142 | var errLater error |
@@ -362,46 +362,48 @@ func (u *unmarshalInfo) computeUnmarshalInfo() { | |||
362 | } | 362 | } |
363 | 363 | ||
364 | // Find any types associated with oneof fields. | 364 | // Find any types associated with oneof fields. |
365 | // TODO: XXX_OneofFuncs returns more info than we need. Get rid of some of it? | 365 | var oneofImplementers []interface{} |
366 | fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("XXX_OneofFuncs") | 366 | switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { |
367 | if fn.IsValid() { | 367 | case oneofFuncsIface: |
368 | res := fn.Call(nil)[3] // last return value from XXX_OneofFuncs: []interface{} | 368 | _, _, _, oneofImplementers = m.XXX_OneofFuncs() |
369 | for i := res.Len() - 1; i >= 0; i-- { | 369 | case oneofWrappersIface: |
370 | v := res.Index(i) // interface{} | 370 | oneofImplementers = m.XXX_OneofWrappers() |
371 | tptr := reflect.ValueOf(v.Interface()).Type() // *Msg_X | 371 | } |
372 | typ := tptr.Elem() // Msg_X | 372 | for _, v := range oneofImplementers { |
373 | 373 | tptr := reflect.TypeOf(v) // *Msg_X | |
374 | f := typ.Field(0) // oneof implementers have one field | 374 | typ := tptr.Elem() // Msg_X |
375 | baseUnmarshal := fieldUnmarshaler(&f) | 375 | |
376 | tags := strings.Split(f.Tag.Get("protobuf"), ",") | 376 | f := typ.Field(0) // oneof implementers have one field |
377 | fieldNum, err := strconv.Atoi(tags[1]) | 377 | baseUnmarshal := fieldUnmarshaler(&f) |
378 | if err != nil { | 378 | tags := strings.Split(f.Tag.Get("protobuf"), ",") |
379 | panic("protobuf tag field not an integer: " + tags[1]) | 379 | fieldNum, err := strconv.Atoi(tags[1]) |
380 | } | 380 | if err != nil { |
381 | var name string | 381 | panic("protobuf tag field not an integer: " + tags[1]) |
382 | for _, tag := range tags { | 382 | } |
383 | if strings.HasPrefix(tag, "name=") { | 383 | var name string |
384 | name = strings.TrimPrefix(tag, "name=") | 384 | for _, tag := range tags { |
385 | break | 385 | if strings.HasPrefix(tag, "name=") { |
386 | } | 386 | name = strings.TrimPrefix(tag, "name=") |
387 | break | ||
387 | } | 388 | } |
389 | } | ||
388 | 390 | ||
389 | // Find the oneof field that this struct implements. | 391 | // Find the oneof field that this struct implements. |
390 | // Might take O(n^2) to process all of the oneofs, but who cares. | 392 | // Might take O(n^2) to process all of the oneofs, but who cares. |
391 | for _, of := range oneofFields { | 393 | for _, of := range oneofFields { |
392 | if tptr.Implements(of.ityp) { | 394 | if tptr.Implements(of.ityp) { |
393 | // We have found the corresponding interface for this struct. | 395 | // We have found the corresponding interface for this struct. |
394 | // That lets us know where this struct should be stored | 396 | // That lets us know where this struct should be stored |
395 | // when we encounter it during unmarshaling. | 397 | // when we encounter it during unmarshaling. |
396 | unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal) | 398 | unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal) |
397 | u.setTag(fieldNum, of.field, unmarshal, 0, name) | 399 | u.setTag(fieldNum, of.field, unmarshal, 0, name) |
398 | } | ||
399 | } | 400 | } |
400 | } | 401 | } |
402 | |||
401 | } | 403 | } |
402 | 404 | ||
403 | // Get extension ranges, if any. | 405 | // Get extension ranges, if any. |
404 | fn = reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray") | 406 | fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray") |
405 | if fn.IsValid() { | 407 | if fn.IsValid() { |
406 | if !u.extensions.IsValid() && !u.oldExtensions.IsValid() { | 408 | if !u.extensions.IsValid() && !u.oldExtensions.IsValid() { |
407 | panic("a message with extensions, but no extensions field in " + t.Name()) | 409 | panic("a message with extensions, but no extensions field in " + t.Name()) |
@@ -1948,7 +1950,7 @@ func encodeVarint(b []byte, x uint64) []byte { | |||
1948 | // If there is an error, it returns 0,0. | 1950 | // If there is an error, it returns 0,0. |
1949 | func decodeVarint(b []byte) (uint64, int) { | 1951 | func decodeVarint(b []byte) (uint64, int) { |
1950 | var x, y uint64 | 1952 | var x, y uint64 |
1951 | if len(b) <= 0 { | 1953 | if len(b) == 0 { |
1952 | goto bad | 1954 | goto bad |
1953 | } | 1955 | } |
1954 | x = uint64(b[0]) | 1956 | x = uint64(b[0]) |