(dst reflect.Value, typ reflect.Type, ctx *objectExportCtx)
| 469 | } |
| 470 | |
| 471 | func (a *sparseArrayObject) exportToArrayOrSlice(dst reflect.Value, typ reflect.Type, ctx *objectExportCtx) error { |
| 472 | r := a.val.runtime |
| 473 | if iter := a.getSym(SymIterator, nil); iter == r.getArrayValues() || iter == nil { |
| 474 | l := toIntStrict(int64(a.length)) |
| 475 | if typ.Kind() == reflect.Array { |
| 476 | if dst.Len() != l { |
| 477 | return fmt.Errorf("cannot convert an Array into an array, lengths mismatch (have %d, need %d)", l, dst.Len()) |
| 478 | } |
| 479 | } else { |
| 480 | dst.Set(reflect.MakeSlice(typ, l, l)) |
| 481 | } |
| 482 | ctx.putTyped(a.val, typ, dst.Interface()) |
| 483 | for _, item := range a.items { |
| 484 | val := item.value |
| 485 | if p, ok := val.(*valueProperty); ok { |
| 486 | val = p.get(a.val) |
| 487 | } |
| 488 | idx := toIntStrict(int64(item.idx)) |
| 489 | if idx >= l { |
| 490 | break |
| 491 | } |
| 492 | err := r.toReflectValue(val, dst.Index(idx), ctx) |
| 493 | if err != nil { |
| 494 | return fmt.Errorf("could not convert array element %v to %v at %d: %w", item.value, typ, idx, err) |
| 495 | } |
| 496 | } |
| 497 | return nil |
| 498 | } |
| 499 | return a.baseObject.exportToArrayOrSlice(dst, typ, ctx) |
| 500 | } |
nothing calls this directly
no test coverage detected