Commit 702d8d9f authored by Him188's avatar Him188

Fix optional element detecting

parent f0680334
...@@ -231,11 +231,12 @@ internal class JceDecoder( ...@@ -231,11 +231,12 @@ 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
} }
while (!jce.input.endOfInput){
repeat(descriptor.elementsCount) { repeat(descriptor.elementsCount) {
val tag = descriptor.getJceTagId(it) val tag = descriptor.getJceTagId(it)
if (tag == jceHead.tag) { if (tag == jceHead.tag) {
...@@ -243,6 +244,13 @@ internal class JceDecoder( ...@@ -243,6 +244,13 @@ internal class JceDecoder(
} }
} }
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