MCPcopy Create free account
hub / github.com/google/gapid / encode

Function encode

gapis/memory/write.go:29–115  ·  view source on GitHub ↗
(e *Encoder, v reflect.Value)

Source from the content-addressed store, hash-verified

27}
28
29func encode(e *Encoder, v reflect.Value) {
30 t := v.Type()
31
32 if t.Implements(tyEncodable) {
33 v.Interface().(Encodable).Encode(e)
34 return
35 }
36
37 switch t.Kind() {
38 case reflect.Float32:
39 e.F32(float32(v.Float()))
40 case reflect.Float64:
41 e.F64(v.Float())
42 case reflect.Int8:
43 e.I8(int8(v.Int()))
44 case reflect.Int16:
45 e.I16(int16(v.Int()))
46 case reflect.Int32:
47 e.I32(int32(v.Int()))
48 case reflect.Int64:
49 if t.Implements(tyIntTy) {
50 e.Int(Int(v.Int()))
51 } else {
52 e.I64(v.Int())
53 }
54 case reflect.Uint8:
55 if t.Implements(tyCharTy) {
56 e.Char(Char(v.Uint()))
57 } else {
58 e.U8(uint8(v.Uint()))
59 }
60 case reflect.Uint16:
61 e.U16(uint16(v.Uint()))
62 case reflect.Uint32:
63 e.U32(uint32(v.Uint()))
64 case reflect.Uint64:
65 switch {
66 case t.Implements(tyPointer):
67 e.Pointer(v.Uint())
68 case t.Implements(tySizeTy):
69 e.Size(Size(v.Uint()))
70 case t.Implements(tyUintTy):
71 e.Uint(Uint(v.Uint()))
72 default:
73 e.U64(v.Uint())
74 }
75 case reflect.Int:
76 e.Int(Int(v.Int()))
77 case reflect.Uint:
78 e.Uint(Uint(v.Uint()))
79 case reflect.Array:
80 for i, c := 0, v.Len(); i < c; i++ {
81 encode(e, v.Index(i))
82 }
83 case reflect.Slice:
84 if t.Elem() == tyUint8Ty {
85 e.Data(v.Interface().([]uint8))
86 } else {

Callers 1

WriteFunction · 0.85

Calls 15

IntTypeAlias · 0.85
UintTypeAlias · 0.85
AlignOfFunction · 0.85
SizeOfFunction · 0.85
ImplementsMethod · 0.80
InterfaceMethod · 0.80
PadMethod · 0.80
CharTypeAlias · 0.70
SizeTypeAlias · 0.70
TypeMethod · 0.65
EncodeMethod · 0.65
KindMethod · 0.65

Tested by

no test coverage detected