funcArgsToStruct converts a slice of [FuncArg] objects to a new non-pointer struct [reflect.Value].
(args []FuncArg)
| 379 | // funcArgsToStruct converts a slice of [FuncArg] objects |
| 380 | // to a new non-pointer struct [reflect.Value]. |
| 381 | func funcArgsToStruct(args []FuncArg) reflect.Value { |
| 382 | fields := make([]reflect.StructField, len(args)) |
| 383 | for i, arg := range args { |
| 384 | fields[i] = reflect.StructField{ |
| 385 | Name: strcase.ToCamel(arg.Name), |
| 386 | Type: reflect.TypeOf(arg.Value), |
| 387 | Tag: arg.Tag, |
| 388 | } |
| 389 | } |
| 390 | typ := reflect.StructOf(fields) |
| 391 | value := reflect.New(typ).Elem() |
| 392 | for i, arg := range args { |
| 393 | value.Field(i).Set(reflect.ValueOf(arg.Value)) |
| 394 | } |
| 395 | return value |
| 396 | } |
| 397 | |
| 398 | // setMethodImpl is the underlying implementation of [FuncButton.SetFunc] for methods. |
| 399 | // It should typically not be used by end-user code. |