MCPcopy Create free account
hub / github.com/cogentcore/core / funcArgsToStruct

Function funcArgsToStruct

core/funcbutton.go:381–396  ·  view source on GitHub ↗

funcArgsToStruct converts a slice of [FuncArg] objects to a new non-pointer struct [reflect.Value].

(args []FuncArg)

Source from the content-addressed store, hash-verified

379// funcArgsToStruct converts a slice of [FuncArg] objects
380// to a new non-pointer struct [reflect.Value].
381func 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.

Callers 2

CallFuncMethod · 0.85
showReturnsDialogMethod · 0.85

Calls 5

ToCamelFunction · 0.92
ElemMethod · 0.80
FieldMethod · 0.80
NewMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected