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

Function funcToPredicate

core/event/function.go:118–134  ·  view source on GitHub ↗
(ctx context.Context, f reflect.Value)

Source from the content-addressed store, hash-verified

116}
117
118func funcToPredicate(ctx context.Context, f reflect.Value) Predicate {
119 t, err := checkSignature(ctx, f.Type(),
120 []reflect.Type{contextType, nil},
121 []reflect.Type{boolType},
122 )
123 if err != nil {
124 log.F(ctx, true, "Checking handler signature. Error: %v", err)
125 }
126 return func(ctx context.Context, event interface{}) bool {
127 args := []reflect.Value{reflect.ValueOf(ctx), safeValue(event, t)}
128 if args[1].Type() != t {
129 return false
130 }
131 result := f.Call(args)
132 return result[0].Bool()
133 }
134}

Callers 1

AsPredicateFunction · 0.85

Calls 6

checkSignatureFunction · 0.85
safeValueFunction · 0.85
FMethod · 0.80
TypeMethod · 0.65
CallMethod · 0.65
BoolMethod · 0.65

Tested by

no test coverage detected