Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
c378dcb0
Commit
c378dcb0
authored
Jan 30, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add length param
parent
db4954ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
.../kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
+2
-2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/SerializationUtils.kt
...oe/mirai/qqandroid/io/serialization/SerializationUtils.kt
+10
-6
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
View file @
c378dcb0
...
...
@@ -754,8 +754,8 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
return
dumpAsPacket
(
serializer
,
obj
).
readBytes
()
}
fun
<
T
>
load
(
deserializer
:
DeserializationStrategy
<
T
>,
packet
:
ByteReadPacket
):
T
{
packet
.
readIoBuffer
().
withUse
{
fun
<
T
>
load
(
deserializer
:
DeserializationStrategy
<
T
>,
packet
:
ByteReadPacket
,
length
:
Int
=
packet
.
remaining
.
toInt
()
):
T
{
packet
.
readIoBuffer
(
n
=
length
).
withUse
{
val
decoder
=
JceDecoder
(
JceInput
(
this
))
return
decoder
.
decode
(
deserializer
)
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/SerializationUtils.kt
View file @
c378dcb0
...
...
@@ -22,8 +22,12 @@ fun <T : JceStruct> BytePacketBuilder.writeJceStruct(serializer: SerializationSt
this
.
writePacket
(
Jce
.
byCharSet
(
charset
).
dumpAsPacket
(
serializer
,
struct
))
}
fun
<
T
:
JceStruct
>
ByteReadPacket
.
readRemainingAsJceStruct
(
serializer
:
DeserializationStrategy
<
T
>,
charset
:
JceCharset
=
JceCharset
.
UTF8
):
T
{
return
Jce
.
byCharSet
(
charset
).
load
(
serializer
,
this
)
fun
<
T
:
JceStruct
>
ByteReadPacket
.
readRemainingAsJceStruct
(
serializer
:
DeserializationStrategy
<
T
>,
charset
:
JceCharset
=
JceCharset
.
UTF8
,
length
:
Int
=
this
.
remaining
.
toInt
()
):
T
{
return
Jce
.
byCharSet
(
charset
).
load
(
serializer
,
this
,
length
)
}
/**
...
...
@@ -33,7 +37,7 @@ fun <T : JceStruct> ByteReadPacket.decodeUniPacket(deserializer: Deserialization
return
decodeUniRequestPacketAndDeserialize
(
name
)
{
it
.
read
{
discardExact
(
1
)
this
.
readRemainingAsJceStruct
(
deserializer
)
this
.
readRemainingAsJceStruct
(
deserializer
,
length
=
(
this
.
remaining
-
1
).
toInt
()
)
}
}
}
...
...
@@ -45,7 +49,7 @@ fun <T : ProtoBuf> ByteReadPacket.decodeUniPacket(deserializer: DeserializationS
return
decodeUniRequestPacketAndDeserialize
(
name
)
{
it
.
read
{
discardExact
(
1
)
this
.
readRemainingAsProtoBuf
(
deserializer
)
this
.
readRemainingAsProtoBuf
(
deserializer
,
(
this
.
remaining
-
1
).
toInt
()
)
}
}
}
...
...
@@ -89,8 +93,8 @@ fun <T : ProtoBuf> ByteArray.loadAs(deserializer: DeserializationStrategy<T>): T
/**
* load
*/
fun
<
T
:
ProtoBuf
>
Input
.
readRemainingAsProtoBuf
(
serializer
:
DeserializationStrategy
<
T
>
):
T
{
return
ProtoBufWithNullableSupport
.
load
(
serializer
,
this
.
readBytes
())
fun
<
T
:
ProtoBuf
>
ByteReadPacket
.
readRemainingAsProtoBuf
(
serializer
:
DeserializationStrategy
<
T
>,
length
:
Int
=
this
.
remaining
.
toInt
()
):
T
{
return
ProtoBufWithNullableSupport
.
load
(
serializer
,
this
.
readBytes
(
length
))
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment