From d4a24d4c9d7845c4006565324b294e4bd50c5a57 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 17 Mar 2025 02:27:27 -0400 Subject: [PATCH] lang: funcs: wrapped: Simplify the implementation --- lang/funcs/wrapped/wrapped.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lang/funcs/wrapped/wrapped.go b/lang/funcs/wrapped/wrapped.go index f6cc6f16..2c5f8eda 100644 --- a/lang/funcs/wrapped/wrapped.go +++ b/lang/funcs/wrapped/wrapped.go @@ -141,16 +141,15 @@ func (obj *Func) Stream(ctx context.Context) error { obj.last = input // store for next } - values := []types.Value{} - for _, name := range obj.Fn.Type().Ord { - x := input.Struct()[name] - values = append(values, x) + args, err := interfaces.StructToCallableArgs(input) // []types.Value, error) + if err != nil { + return err } if obj.init.Debug { - obj.init.Logf("Calling function with: %+v", values) + obj.init.Logf("Calling function with: %+v", args) } - result, err := obj.Call(ctx, values) // (Value, error) + result, err := obj.Call(ctx, args) // (Value, error) if err != nil { if obj.init.Debug { obj.init.Logf("Function returned error: %+v", err)