Scott Baker | 611f6bd | 2019-10-18 13:45:19 -0700 | [diff] [blame^] | 1 | package ndr |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "reflect" |
| 6 | ) |
| 7 | |
| 8 | func (dec *Decoder) fillPipe(v reflect.Value, tag reflect.StructTag) error { |
| 9 | s, err := dec.readUint32() // read element count of first chunk |
| 10 | if err != nil { |
| 11 | return err |
| 12 | } |
| 13 | a := reflect.MakeSlice(v.Type(), 0, 0) |
| 14 | c := reflect.MakeSlice(v.Type(), int(s), int(s)) |
| 15 | for s != 0 { |
| 16 | for i := 0; i < int(s); i++ { |
| 17 | err := dec.fill(c.Index(i), tag, &[]deferedPtr{}) |
| 18 | if err != nil { |
| 19 | return fmt.Errorf("could not fill element %d of pipe: %v", i, err) |
| 20 | } |
| 21 | } |
| 22 | s, err = dec.readUint32() // read element count of first chunk |
| 23 | if err != nil { |
| 24 | return err |
| 25 | } |
| 26 | a = reflect.AppendSlice(a, c) |
| 27 | c = reflect.MakeSlice(v.Type(), int(s), int(s)) |
| 28 | } |
| 29 | v.Set(a) |
| 30 | return nil |
| 31 | } |