(dst reflect.Value, typ reflect.Type, ctx *objectExportCtx)
| 520 | } |
| 521 | |
| 522 | func (a *arrayObject) exportToArrayOrSlice(dst reflect.Value, typ reflect.Type, ctx *objectExportCtx) error { |
| 523 | r := a.val.runtime |
| 524 | if iter := a.getSym(SymIterator, nil); iter == r.getArrayValues() || iter == nil { |
| 525 | l := toIntStrict(int64(a.length)) |
| 526 | if typ.Kind() == reflect.Array { |
| 527 | if dst.Len() != l { |
| 528 | return fmt.Errorf("cannot convert an Array into an array, lengths mismatch (have %d, need %d)", l, dst.Len()) |
| 529 | } |
| 530 | } else { |
| 531 | dst.Set(reflect.MakeSlice(typ, l, l)) |
| 532 | } |
| 533 | ctx.putTyped(a.val, typ, dst.Interface()) |
| 534 | for i := 0; i < l; i++ { |
| 535 | if i >= len(a.values) { |
| 536 | break |
| 537 | } |
| 538 | val := a.values[i] |
| 539 | if p, ok := val.(*valueProperty); ok { |
| 540 | val = p.get(a.val) |
| 541 | } |
| 542 | err := r.toReflectValue(val, dst.Index(i), ctx) |
| 543 | if err != nil { |
| 544 | return fmt.Errorf("could not convert array element %v to %v at %d: %w", val, typ, i, err) |
| 545 | } |
| 546 | } |
| 547 | return nil |
| 548 | } |
| 549 | return a.baseObject.exportToArrayOrSlice(dst, typ, ctx) |
| 550 | } |
| 551 | |
| 552 | func (a *arrayObject) setValuesFromSparse(items []sparseArrayItem, newMaxIdx int) { |
| 553 | a.values = make([]Value, newMaxIdx+1) |
nothing calls this directly
no test coverage detected