@@ -585,32 +585,33 @@ internal class StructuredCborParser(internal val element: CborElement, private v
585
585
listIterator = layerStack.removeLast()
586
586
}
587
587
588
+
588
589
override fun startArray (tags : ULongArray? ): Int {
589
590
processTags(tags)
590
591
if (currentElement !is CborList ) {
591
592
throw CborDecodingException (" Expected array, got ${currentElement::class .simpleName} " )
592
593
}
593
- isMapStack+ = isMap
594
- layerStack+ = listIterator
594
+ isMapStack + = isMap
595
+ layerStack + = listIterator
595
596
isMap = false
596
597
val list = currentElement as CborList
597
598
listIterator = list.listIterator()
598
- return list.size
599
+ return - 1 // just let the iterator run out of elements
599
600
}
600
601
601
602
override fun startMap (tags : ULongArray? ): Int {
602
603
processTags(tags)
603
604
if (currentElement !is CborMap ) {
604
605
throw CborDecodingException (" Expected map, got ${currentElement::class .simpleName} " )
605
606
}
606
- layerStack+ = listIterator
607
- isMapStack+ = isMap
607
+ layerStack + = listIterator
608
+ isMapStack + = isMap
608
609
isMap = true
609
610
610
611
val map = currentElement as CborMap
611
612
// zip key, value, key, value, ... pairs to mirror byte-layout of CBOR map
612
613
listIterator = map.entries.flatMap { listOf (it.key, it.value) }.listIterator()
613
- return map.size // cbor map size is the size of the map, not the doubled size of the flattened pairs
614
+ return - 1 // just let the iterator run out of elements
614
615
}
615
616
616
617
override fun nextNull (tags : ULongArray? ): Nothing? {
@@ -681,7 +682,7 @@ internal class StructuredCborParser(internal val element: CborElement, private v
681
682
682
683
// If we're in a list, advance to the next element
683
684
if (listIterator != null && listIterator!! .hasNext()) {
684
- currentElement= listIterator!! .next()
685
+ currentElement = listIterator!! .next()
685
686
}
686
687
687
688
// Store collected tags for verification
@@ -707,6 +708,7 @@ internal class StructuredCborParser(internal val element: CborElement, private v
707
708
708
709
override fun skipElement (tags : ULongArray? ) {
709
710
// Process tags but don't do anything with the element
711
+ // TODO check for maps
710
712
processTags(tags)
711
713
}
712
714
}
0 commit comments