Commit 702d8d9f authored by Him188's avatar Him188

Fix optional element detecting

parent f0680334
...@@ -231,16 +231,24 @@ internal class JceDecoder( ...@@ -231,16 +231,24 @@ internal class JceDecoder(
override fun decodeSequentially(): Boolean = false override fun decodeSequentially(): Boolean = false
override fun decodeElementIndex(descriptor: SerialDescriptor): Int { 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) { if (jceHead.type == Jce.STRUCT_END) {
return CompositeDecoder.READ_DONE return CompositeDecoder.READ_DONE
} }
repeat(descriptor.elementsCount) { while (!jce.input.endOfInput){
val tag = descriptor.getJceTagId(it) repeat(descriptor.elementsCount) {
if (tag == jceHead.tag) { val tag = descriptor.getJceTagId(it)
return it if (tag == jceHead.tag) {
return it
}
}
jce.skipField(jceHead.type)
if (!jce.prepareNextHead()) {
break
} }
jceHead = jce.currentHead
} }
return CompositeDecoder.READ_DONE // optional support 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