d.prepare initializes and dereferences pointers and calls UnmarshalYAML if a value is found to implement it. It returns the initialized and dereferenced out value, whether unmarshalling was already done by UnmarshalYAML, and if so whether its types unmarshalled appropriately. If n holds a null valu
(n *Node, out reflect.Value)
| 404 | // |
| 405 | // If n holds a null value, prepare returns before doing anything. |
| 406 | func (d *decoder) prepare(n *Node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) { |
| 407 | if n.ShortTag() == nullTag { |
| 408 | return out, false, false |
| 409 | } |
| 410 | again := true |
| 411 | for again { |
| 412 | again = false |
| 413 | if out.Kind() == reflect.Ptr { |
| 414 | if out.IsNil() { |
| 415 | out.Set(reflect.New(out.Type().Elem())) |
| 416 | } |
| 417 | out = out.Elem() |
| 418 | again = true |
| 419 | } |
| 420 | if out.CanAddr() { |
| 421 | outi := out.Addr().Interface() |
| 422 | if u, ok := outi.(Unmarshaler); ok { |
| 423 | good = d.callUnmarshaler(n, u) |
| 424 | return out, true, good |
| 425 | } |
| 426 | if u, ok := outi.(obsoleteUnmarshaler); ok { |
| 427 | good = d.callObsoleteUnmarshaler(n, u) |
| 428 | return out, true, good |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | return out, false, false |
| 433 | } |
| 434 | |
| 435 | func (d *decoder) fieldByIndex(n *Node, v reflect.Value, index []int) (field reflect.Value) { |
| 436 | if n.ShortTag() == nullTag { |
no test coverage detected