tape: WIP

This commit is contained in:
2025-07-02 06:25:24 -04:00
parent 2138d47f07
commit 07fc77c83e
2 changed files with 65 additions and 2 deletions

View File

@@ -6,6 +6,8 @@ package tape
// TODO: add support for struct tags: `tape:"0000"`, tape:"0001"` so they can get
// transformed into tables with a defined schema
// TODO: test all of these smaller functions individually
import "fmt"
import "reflect"
@@ -346,10 +348,12 @@ func peekSlice(decoder *Decoder, tag Tag) (Tag, int, error) {
for {
elem, populated, n, err := peekSliceOnce(decoder, tag, offset)
if err != nil { return 0, 0, err }
offset += n
offset = n
dimension += 1
if elem.Is(OTA) {
if !populated {
// default to a large byte array, will be
// interpreted as a string.
return LBA, dimension + 1, nil
}
} else {
@@ -371,7 +375,7 @@ func peekSliceOnce(decoder *Decoder, tag Tag, offset int) (elem Tag, populated b
headerBytes, err := decoder.Peek(elemTagEnd)
if err != nil { return 0, false, 0, err }
elem = Tag(headerBytes[len(headerBytes)])
elem = Tag(headerBytes[len(headerBytes) - 1])
for index := lengthStart; index < lengthEnd; index += 1 {
if headerBytes[index] > 0 {
populated = true