(cfunc any, ctx context.Context, props map[string]any)
| 378 | } |
| 379 | |
| 380 | func callCFunc(cfunc any, ctx context.Context, props map[string]any) any { |
| 381 | rval := reflect.ValueOf(cfunc) |
| 382 | arg2Type := rval.Type().In(1) |
| 383 | |
| 384 | var arg2Val reflect.Value |
| 385 | if arg2Type.Kind() == reflect.Interface && arg2Type.NumMethod() == 0 { |
| 386 | // For any/interface{}, pass nil properly |
| 387 | arg2Val = reflect.New(arg2Type) |
| 388 | } else { |
| 389 | arg2Val = reflect.New(arg2Type) |
| 390 | // if arg2 is a map, just pass props |
| 391 | if arg2Type.Kind() == reflect.Map { |
| 392 | arg2Val.Elem().Set(reflect.ValueOf(props)) |
| 393 | } else { |
| 394 | err := utilfn.MapToStruct(props, arg2Val.Interface()) |
| 395 | if err != nil { |
| 396 | fmt.Printf("error unmarshalling props: %v\n", err) |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | rtnVal := rval.Call([]reflect.Value{reflect.ValueOf(ctx), arg2Val.Elem()}) |
| 401 | if len(rtnVal) == 0 { |
| 402 | return nil |
| 403 | } |
| 404 | return rtnVal[0].Interface() |
| 405 | } |
| 406 | |
| 407 | func (r *RootElem) renderComponent(cfunc any, elem *VDomElem, comp **ComponentImpl) { |
| 408 | if (*comp).Children != nil { |
no test coverage detected