MCPcopy Index your code
hub / github.com/google/gvisor / decodeInterface

Method decodeInterface

pkg/state/decode.go:470–492  ·  view source on GitHub ↗

decodeInterface decodes an interface value.

(ods *objectDecodeState, obj reflect.Value, encoded *wire.Interface)

Source from the content-addressed store, hash-verified

468
469// decodeInterface decodes an interface value.
470func (ds *decodeState) decodeInterface(ods *objectDecodeState, obj reflect.Value, encoded *wire.Interface) {
471 if _, ok := encoded.Type.(wire.TypeSpecNil); ok {
472 // Special case; the nil object. Just decode directly, which
473 // will read nil from the wire (if encoded correctly).
474 ds.decodeObject(ods, obj, encoded.Value)
475 return
476 }
477
478 // We now need to resolve the actual type.
479 typ := ds.findType(encoded.Type)
480
481 // We need to imbue type information here, then we can proceed to
482 // decode normally. In order to avoid issues with setting value-types,
483 // we create a new non-interface version of this object. We will then
484 // set the interface object to be equal to whatever we decode.
485 origObj := obj
486 obj = reflect.New(typ).Elem()
487 defer origObj.Set(obj)
488
489 // With the object now having sufficient type information to actually
490 // have Set called on it, we can proceed to decode the value.
491 ds.decodeObject(ods, obj, encoded.Value)
492}
493
494// isFloatEq determines if x and y represent the same value.
495func isFloatEq(x float64, y float64) bool {

Callers 1

decodeObjectMethod · 0.95

Calls 5

decodeObjectMethod · 0.95
findTypeMethod · 0.95
ElemMethod · 0.80
NewMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected