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

Method encode

core/java/jdwp/coder.go:36–150  ·  view source on GitHub ↗

encode writes the value v to w, using the JDWP encoding scheme.

(w binary.Writer, v reflect.Value)

Source from the content-addressed store, hash-verified

34
35// encode writes the value v to w, using the JDWP encoding scheme.
36func (c *Connection) encode(w binary.Writer, v reflect.Value) error {
37 if debug {
38 defer func() {
39 if r := recover(); r != nil {
40 panic(fmt.Errorf("Type %T %v %v", v.Interface(), v.Type().Name(), v.Kind()))
41 }
42 }()
43 }
44
45 t := v.Type()
46 o := v.Interface()
47
48 switch v.Type() {
49 case reflect.TypeOf((*EventModifier)(nil)).Elem():
50 // EventModifier's are prefixed with their 1-byte modKind.
51 w.Uint8(o.(EventModifier).modKind())
52
53 case reflect.TypeOf((*Value)(nil)).Elem():
54 // values are prefixed with their 1-tag type.
55 switch o.(type) {
56 case ArrayID:
57 w.Uint8(uint8(TagArray))
58 case byte:
59 w.Uint8(uint8(TagByte))
60 case Char:
61 w.Uint8(uint8(TagChar))
62 case ObjectID:
63 w.Uint8(uint8(TagObject))
64 case float32:
65 w.Uint8(uint8(TagFloat))
66 case float64:
67 w.Uint8(uint8(TagDouble))
68 case int, int32:
69 w.Uint8(uint8(TagInt))
70 case int16:
71 w.Uint8(uint8(TagShort))
72 case int64:
73 w.Uint8(uint8(TagLong))
74 case nil:
75 w.Uint8(uint8(TagVoid))
76 case bool:
77 w.Uint8(uint8(TagBoolean))
78 case StringID:
79 w.Uint8(uint8(TagString))
80 case ThreadID:
81 w.Uint8(uint8(TagThread))
82 case ThreadGroupID:
83 w.Uint8(uint8(TagThreadGroup))
84 case ClassLoaderID:
85 w.Uint8(uint8(TagClassLoader))
86 case ClassObjectID:
87 w.Uint8(uint8(TagClassObject))
88 default:
89 panic(fmt.Errorf("Got Value of type %T", o))
90 }
91 }
92
93 switch o := o.(type) {

Callers 1

reqMethod · 0.95

Calls 15

unboxFunction · 0.85
InterfaceMethod · 0.80
NameMethod · 0.65
TypeMethod · 0.65
KindMethod · 0.65
Uint8Method · 0.65
modKindMethod · 0.65
Uint32Method · 0.65
DataMethod · 0.65
LenMethod · 0.65
StringMethod · 0.65
Uint64Method · 0.65

Tested by

no test coverage detected