Skip to content

Commit

Permalink
fix: fixed Int32 serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
y9san9 committed Oct 12, 2023
1 parent 9c9f7a6 commit 7cabb4c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ kotlin {
iosArm64()
iosX64()
iosSimulatorArm64()

explicitApi()

sourceSets {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]

kotlin = "1.9.0"
koTLVersion = "0.0.14"
koTLVersion = "0.0.15"
kotlinxSerialization = "1.5.0"

[libraries]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package kotl.serialization.encoder

import kotl.core.descriptor.TLIntDescriptor
import kotl.core.element.TLExpression
import kotl.core.element.TLInt32
import kotl.core.element.typedLanguage
import kotl.serialization.TL
import kotl.serialization.annotation.TLBare
Expand Down Expand Up @@ -47,7 +48,14 @@ internal class TLEncoder(
require(descriptor.kind in supportedDescriptors) { "TL doesn't support ${descriptor.kind}" }
}

override fun encodeInt(value: Int) = writer.writeElement(value)
override fun encodeInt(value: Int) {
if (writer is IntElementWriter) {
writer.writeElement(value)
} else {
writer.writeElement(TLInt32(value))
}
}

override fun encodeByte(value: Byte) {
if (writer is BytesElementWriter) {
writer.writeElement(value)
Expand Down

0 comments on commit 7cabb4c

Please sign in to comment.