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

Function Write

core/data/binary/writer.go:103–137  ·  view source on GitHub ↗

Write writes v to the writer w. v must be an byte, integer, float, boolean, string, slice or array.

(w Writer, v interface{})

Source from the content-addressed store, hash-verified

101// Write writes v to the writer w. v must be an byte, integer, float, boolean,
102// string, slice or array.
103func Write(w Writer, v interface{}) {
104 r := reflect.ValueOf(v)
105 switch r.Kind() {
106 case reflect.Bool:
107 w.Bool(r.Bool())
108 case reflect.Int8:
109 w.Int8(int8(r.Int()))
110 case reflect.Int16:
111 w.Int16(int16(r.Int()))
112 case reflect.Int32:
113 w.Int32(int32(r.Int()))
114 case reflect.Int, reflect.Int64:
115 w.Int64(int64(r.Int()))
116 case reflect.Uint8:
117 w.Uint8(uint8(r.Uint()))
118 case reflect.Uint16:
119 w.Uint16(uint16(r.Uint()))
120 case reflect.Uint32:
121 w.Uint32(uint32(r.Uint()))
122 case reflect.Uint, reflect.Uint64, reflect.Uintptr:
123 w.Uint64(uint64(r.Uint()))
124 case reflect.Float32:
125 w.Float32(float32(r.Float()))
126 case reflect.Float64:
127 w.Float64(r.Float())
128 case reflect.Slice, reflect.Array:
129 for i, c := 0, r.Len(); i < c; i++ {
130 Write(w, r.Index(i).Interface())
131 }
132 case reflect.String:
133 w.String(r.String())
134 default:
135 panic(fmt.Errorf("Cannot write type %T", v))
136 }
137}

Callers

nothing calls this directly

Calls 15

InterfaceMethod · 0.80
KindMethod · 0.65
BoolMethod · 0.65
Int8Method · 0.65
Int16Method · 0.65
Int32Method · 0.65
Int64Method · 0.65
Uint8Method · 0.65
Uint16Method · 0.65
Uint32Method · 0.65
Uint64Method · 0.65
Float32Method · 0.65

Tested by

no test coverage detected