MCPcopy
hub / github.com/google/gvisor / encodeInterface

Method encodeInterface

pkg/state/encode.go:595–613  ·  view source on GitHub ↗

encodeInterface encodes an interface.

(obj reflect.Value, dest *wire.Object)

Source from the content-addressed store, hash-verified

593
594// encodeInterface encodes an interface.
595func (es *encodeState) encodeInterface(obj reflect.Value, dest *wire.Object) {
596 // Dereference the object.
597 obj = obj.Elem()
598 if !obj.IsValid() {
599 // Special case: the nil object.
600 *dest = &wire.Interface{
601 Type: wire.TypeSpecNil{},
602 Value: wire.Nil{},
603 }
604 return
605 }
606
607 // Encode underlying object.
608 i := &wire.Interface{
609 Type: es.findType(obj.Type()),
610 }
611 *dest = i
612 es.encodeObject(obj, encodeAsValue, &i.Value)
613}
614
615// isPrimitive returns true if this is a primitive object, or a composite
616// object composed entirely of primitives.

Callers 1

encodeObjectMethod · 0.95

Calls 5

findTypeMethod · 0.95
encodeObjectMethod · 0.95
ElemMethod · 0.80
TypeMethod · 0.65
IsValidMethod · 0.45

Tested by

no test coverage detected