go-hep.org/x/hep@v0.38.1/groot/cmd/root-gen-rfunc/testdata/func1_golden.txt (about) 1 // FuncF64F64ToBool implements rfunc.Formula 2 type FuncF64F64ToBool struct { 3 rvars []string 4 arg0 *float64 5 arg1 *float64 6 fct func(arg00 float64, arg01 float64) bool 7 } 8 9 // NewFuncF64F64ToBool return a new formula, from the provided function. 10 func NewFuncF64F64ToBool(rvars []string, fct func(arg00 float64, arg01 float64) bool) *FuncF64F64ToBool { 11 return &FuncF64F64ToBool{ 12 rvars: rvars, 13 fct: fct, 14 } 15 } 16 17 18 // RVars implements rfunc.Formula 19 func (f *FuncF64F64ToBool) RVars() []string { return f.rvars } 20 21 22 // Bind implements rfunc.Formula 23 func (f *FuncF64F64ToBool) Bind(args []any) error { 24 if got, want := len(args), 2; got != want { 25 return fmt.Errorf( 26 "rfunc: invalid number of bind arguments (got=%d, want=%d)", 27 got, want, 28 ) 29 } 30 { 31 ptr, ok := args[0].(*float64) 32 if !ok { 33 return fmt.Errorf( 34 "rfunc: argument type 0 (name=%s) mismatch: got=%T, want=*float64", 35 f.rvars[0], args[0], 36 ) 37 } 38 f.arg0 = ptr 39 } 40 { 41 ptr, ok := args[1].(*float64) 42 if !ok { 43 return fmt.Errorf( 44 "rfunc: argument type 1 (name=%s) mismatch: got=%T, want=*float64", 45 f.rvars[1], args[1], 46 ) 47 } 48 f.arg1 = ptr 49 } 50 return nil 51 } 52 53 // Func implements rfunc.Formula 54 func (f *FuncF64F64ToBool) Func() any { 55 return func() bool { 56 return f.fct( 57 *f.arg0, 58 *f.arg1, 59 ) 60 } 61 } 62 63 var ( 64 _ rfunc.Formula = (*FuncF64F64ToBool)(nil) 65 )