trivial implementation of class name = based serialization (LynonType.Other)
This commit is contained in:
1 parent
d7bd159fcb
commit
2339130241
5 files changed
+132
-49
No files matched your search
@@ -85,13 +85,16 @@ open class LynonEncoder(val bout: BitOutput, val settings: LynonSettings = Lynon
|
||||
*/
|
||||
suspend fun encodeAny(scope: Scope, obj: Obj) {
|
||||
encodeCached(obj) {
|
||||
val type = putTypeRecord(obj, obj.lynonType())
|
||||
val type = putTypeRecord(scope, obj, obj.lynonType())
|
||||
obj.serialize(scope, this, type)
|
||||
}
|
||||
}
|
||||
|
||||
private fun putTypeRecord(obj: Obj, type: LynonType): LynonType {
|
||||
private suspend fun putTypeRecord(scope: Scope, obj: Obj, type: LynonType): LynonType {
|
||||
putType(type)
|
||||
if( type == LynonType.Other) {
|
||||
encodeObject(scope, obj.objClass.classNameObj)
|
||||
}
|
||||
return type
|
||||
}
|
||||
|
||||
@@ -120,7 +123,7 @@ open class LynonEncoder(val bout: BitOutput, val settings: LynonSettings = Lynon
|
||||
}
|
||||
if (isHomogeneous) {
|
||||
putBit(1)
|
||||
putTypeRecord(list[0], type)
|
||||
putTypeRecord(scope, list[0], type)
|
||||
encodeUnsigned(list.size.toULong())
|
||||
for (i in list) encodeObject(scope, i, type)
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user