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

Function NewCmdAndIDList

gapis/api/transform/recorder.go:65–86  ·  view source on GitHub ↗

NewCmdAndIDList takes a mix of CmdWithIDs and Cmds with an ID property and returns a CmdAndIDList. Cmds that have an ID property are transformed into CmdAndID by using the ID.

(cmds ...interface{})

Source from the content-addressed store, hash-verified

63// returns a CmdAndIDList.
64// Cmds that have an ID property are transformed into CmdAndID by using the ID.
65func NewCmdAndIDList(cmds ...interface{}) CmdAndIDList {
66 l := CmdAndIDList{}
67 for _, a := range cmds {
68 switch a := a.(type) {
69 case api.Cmd:
70 p, err := api.GetParameter(a, "ID")
71 if err != nil {
72 panic(fmt.Errorf("Command %v does not have ID property: %v", a.CmdName(), err))
73 }
74 v := reflect.ValueOf(p)
75 if v.Kind() != reflect.Uint64 {
76 panic(fmt.Errorf("Command %v has unexpected ID property type: %T", a.CmdName(), p))
77 }
78 l = append(l, CmdAndID{a, api.CmdID(v.Uint())})
79 case CmdAndID:
80 l = append(l, a)
81 default:
82 panic(fmt.Errorf("list only accepts types CmdWithID or CmdAndID. Got %T", a))
83 }
84 }
85 return l
86}
87
88func (l *CmdAndIDList) Write(ctx context.Context, id api.CmdID, c api.Cmd) {
89 *l = append(*l, CmdAndID{c, id})

Callers

nothing calls this directly

Calls 3

CmdNameMethod · 0.65
KindMethod · 0.65
UintMethod · 0.45

Tested by

no test coverage detected