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

Method add

gapis/capture/decoder.go:99–147  ·  view source on GitHub ↗
(ctx context.Context, child, parent interface{})

Source from the content-addressed store, hash-verified

97}
98
99func (d *decoder) add(ctx context.Context, child, parent interface{}) error {
100 if parent, ok := parent.(*cmdGroup); ok {
101 // adding something to a command
102
103 // is the child the result?
104 if res, ok := child.(proto.Message); ok {
105 if cmd, ok := parent.cmd.(api.CmdWithResult); ok {
106 if cmd.SetCallResult(ctx, res) == nil {
107 parent.invoked = true
108 return nil
109 }
110 }
111 }
112
113 switch obj := child.(type) {
114 case api.Cmd:
115 parent.children = append(parent.children, obj)
116
117 case *cmdGroup:
118 parent.children = append(parent.children, obj.cmd)
119
120 case api.CmdObservation:
121 d.builder.addObservation(ctx, &obj)
122 observations := parent.cmd.Extras().GetOrAppendObservations()
123 if !parent.invoked {
124 observations.Reads = append(observations.Reads, obj)
125 } else {
126 observations.Writes = append(observations.Writes, obj)
127 }
128
129 case *api.CmdCall:
130 parent.invoked = true
131
132 default:
133 parent.cmd.Extras().Add(obj)
134 }
135 }
136 if _, ok := parent.(*InitialState); ok {
137 switch obj := child.(type) {
138 case api.CmdObservation:
139 return d.builder.addInitialMemory(ctx, obj)
140 case api.State:
141 return d.builder.addInitialState(ctx, obj)
142 default:
143 return fmt.Errorf("We do not expect a %T as a child of an initial state: %+v", obj, obj)
144 }
145 }
146 return nil
147}
148
149func (d *decoder) unmarshal(ctx context.Context, in proto.Message) (interface{}, error) {
150 obj, err := protoconv.ToObject(ctx, in)

Callers 2

BeginChildGroupMethod · 0.95
ChildObjectMethod · 0.95

Calls 7

SetCallResultMethod · 0.80
addObservationMethod · 0.80
addInitialMemoryMethod · 0.80
addInitialStateMethod · 0.80
ExtrasMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected