Commit 702d8d9f authored by Him188's avatar Him188

Fix optional element detecting

parent f0680334
......@@ -231,16 +231,24 @@ internal class JceDecoder(
override fun decodeSequentially(): Boolean = false
override fun decodeElementIndex(descriptor: SerialDescriptor): Int {
val jceHead = jce.currentHeadOrNull ?: return CompositeDecoder.READ_DONE
var jceHead = jce.currentHeadOrNull ?: return CompositeDecoder.READ_DONE
if (jceHead.type == Jce.STRUCT_END) {
return CompositeDecoder.READ_DONE
}
repeat(descriptor.elementsCount) {
val tag = descriptor.getJceTagId(it)
if (tag == jceHead.tag) {
return it
while (!jce.input.endOfInput){
repeat(descriptor.elementsCount) {
val tag = descriptor.getJceTagId(it)
if (tag == jceHead.tag) {
return it
}
}
jce.skipField(jceHead.type)
if (!jce.prepareNextHead()) {
break
}
jceHead = jce.currentHead
}
return CompositeDecoder.READ_DONE // optional support
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment