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
85b72ac4
Commit
85b72ac4
authored
Jan 31, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove println
parent
3ac9cdcc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
23 deletions
+25
-23
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
.../kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
+25
-23
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt
View file @
85b72ac4
...
@@ -55,7 +55,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -55,7 +55,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
override fun endEncode(desc: SerialDescriptor) {
override fun endEncode(desc: SerialDescriptor) {
parentEncoder.writeHead(MAP, this.tag)
parentEncoder.writeHead(MAP, this.tag)
parentEncoder.encodeTaggedInt(Int.STUB_FOR_PRIMITIVE_NUMBERS_GBK, count)
parentEncoder.encodeTaggedInt(Int.STUB_FOR_PRIMITIVE_NUMBERS_GBK, count)
println(this.output.toByteArray().toUHexString())
//
println(this.output.toByteArray().toUHexString())
parentEncoder.output.write(this.output.toByteArray())
parentEncoder.output.write(this.output.toByteArray())
}*/
}*/
...
@@ -340,7 +340,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -340,7 +340,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
* 在 [KSerializer.serialize] 前
* 在 [KSerializer.serialize] 前
*/
*/
override
fun
beginStructure
(
desc
:
SerialDescriptor
,
vararg
typeParams
:
KSerializer
<
*
>):
CompositeDecoder
{
override
fun
beginStructure
(
desc
:
SerialDescriptor
,
vararg
typeParams
:
KSerializer
<
*
>):
CompositeDecoder
{
//println("beginStructure: desc=${desc.getClassName()}, typeParams: ${typeParams.contentToString()}")
//
//
println("beginStructure: desc=${desc.getClassName()}, typeParams: ${typeParams.contentToString()}")
when
(
desc
)
{
when
(
desc
)
{
// 由于 Byte 的数组有两种方式写入, 需特定读取器
// 由于 Byte 的数组有两种方式写入, 需特定读取器
ByteArraySerializer
.
descriptor
->
{
ByteArraySerializer
.
descriptor
->
{
...
@@ -403,7 +403,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -403,7 +403,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
@Suppress
(
"UNCHECKED_CAST"
)
@Suppress
(
"UNCHECKED_CAST"
)
override
fun
<
T
:
Any
>
decodeNullableSerializableValue
(
deserializer
:
DeserializationStrategy
<
T
?
>):
T
?
{
override
fun
<
T
:
Any
>
decodeNullableSerializableValue
(
deserializer
:
DeserializationStrategy
<
T
?
>):
T
?
{
// println("decodeNullableSerializableValue: ${deserializer::class.qualifiedName}")
//
//
println("decodeNullableSerializableValue: ${deserializer::class.qualifiedName}")
if
(
deserializer
is
NullReader
)
{
if
(
deserializer
is
NullReader
)
{
return
null
return
null
}
}
...
@@ -430,7 +430,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -430,7 +430,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
else
input
.
readByteArray
(
tag
).
toMutableList
()
as
T
else
input
.
readByteArray
(
tag
).
toMutableList
()
as
T
}
}
val
tag
=
currentTag
val
tag
=
currentTag
// println(tag)
//
//
println(tag)
@Suppress
(
"SENSELESS_COMPARISON"
)
// false positive
@Suppress
(
"SENSELESS_COMPARISON"
)
// false positive
if
(
input
.
skipToTagOrNull
(
tag
)
{
if
(
input
.
skipToTagOrNull
(
tag
)
{
return
deserializer
.
deserialize
(
JceListReader
(
input
.
readInt
(
0
),
input
))
return
deserializer
.
deserialize
(
JceListReader
(
input
.
readInt
(
0
),
input
))
...
@@ -502,17 +502,18 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -502,17 +502,18 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
internal
val
leastRemaining
=
input
.
remaining
-
maxReadSize
internal
val
leastRemaining
=
input
.
remaining
-
maxReadSize
internal
val
isEndOfInput
:
Boolean
get
()
=
input
.
remaining
<=
leastRemaining
internal
val
isEndOfInput
:
Boolean
get
()
=
input
.
remaining
<=
leastRemaining
internal
var
currentJceHead
:
JceHead
?
=
input
.
doReadHead
().
also
{
println
(
"first jce head = $it"
)
}
internal
var
currentJceHead
:
JceHead
?
=
input
.
doReadHead
().
also
{
// println("first jce head = $it") }
override
fun
close
()
=
input
.
close
()
override
fun
close
()
=
input
.
close
()
internal
fun
peakHeadOrNull
():
JceHead
?
=
currentJceHead
?:
readHeadOrNull
()
internal
fun
peakHeadOrNull
():
JceHead
?
=
currentJceHead
?:
readHeadOrNull
()
internal
fun
peakHead
():
JceHead
=
peakHeadOrNull
()
?:
error
(
"no enough data to read head"
)
internal
fun
peakHead
():
JceHead
=
peakHeadOrNull
()
?:
error
(
"no enough data to read head"
)
@PublishedApi
@PublishedApi
internal
fun
readHead
():
JceHead
=
readHeadOrNull
()
?:
error
(
"no enough data to read head"
)
internal
fun
readHead
():
JceHead
=
readHeadOrNull
()
?:
error
(
"no enough data to read head"
)
@PublishedApi
@PublishedApi
internal
fun
readHeadOrNull
():
JceHead
?
=
input
.
doReadHead
()
internal
fun
readHeadOrNull
():
JceHead
?
=
input
.
doReadHead
()
/**
/**
...
@@ -521,7 +522,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -521,7 +522,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
private
fun
ByteReadPacket
.
doReadHead
():
JceHead
?
{
private
fun
ByteReadPacket
.
doReadHead
():
JceHead
?
{
if
(
isEndOfInput
)
{
if
(
isEndOfInput
)
{
currentJceHead
=
null
currentJceHead
=
null
println
(
"doReadHead: endOfInput"
)
//
println("doReadHead: endOfInput")
return
null
return
null
}
}
val
var2
=
readUByte
()
val
var2
=
readUByte
()
...
@@ -530,13 +531,13 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -530,13 +531,13 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
if
(
tag
==
15
u
)
{
if
(
tag
==
15
u
)
{
if
(
isEndOfInput
)
{
if
(
isEndOfInput
)
{
currentJceHead
=
null
currentJceHead
=
null
println
(
"doReadHead: endOfInput2"
)
//
println("doReadHead: endOfInput2")
return
null
return
null
}
}
tag
=
readUByte
().
toUInt
()
tag
=
readUByte
().
toUInt
()
}
}
currentJceHead
=
JceHead
(
tag
=
tag
.
toInt
(),
type
=
type
.
toByte
())
currentJceHead
=
JceHead
(
tag
=
tag
.
toInt
(),
type
=
type
.
toByte
())
println
(
"doReadHead: $currentJceHead"
)
//
println("doReadHead: $currentJceHead")
return
currentJceHead
return
currentJceHead
}
}
...
@@ -596,9 +597,10 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -596,9 +597,10 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
val
head
=
readHead
()
val
head
=
readHead
()
readHead
()
readHead
()
check
(
head
.
type
.
toInt
()
==
0
)
{
"type mismatch"
}
check
(
head
.
type
.
toInt
()
==
0
)
{
"type mismatch"
}
input
.
readBytes
(
readInt
(
0
).
also
{
println
(
"list size=$it"
)
})
input
.
readBytes
(
readInt
(
0
).
also
{
}
// println("list size=$it") })
else
->
error
(
"type mismatch"
)
}
else
->
error
(
"type mismatch"
)
}
}
}
}
...
@@ -790,11 +792,11 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
...
@@ -790,11 +792,11 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo
}
}
internal
inline
fun
<
R
>
Jce
.
JceInput
.
skipToTagOrNull
(
tag
:
Int
,
block
:
(
JceHead
)
->
R
):
R
?
{
internal
inline
fun
<
R
>
Jce
.
JceInput
.
skipToTagOrNull
(
tag
:
Int
,
block
:
(
JceHead
)
->
R
):
R
?
{
println
(
"skipping to $tag start"
)
//
println("skipping to $tag start")
while
(
true
)
{
while
(
true
)
{
if
(
isEndOfInput
)
{
// 读不了了
if
(
isEndOfInput
)
{
// 读不了了
currentJceHead
=
null
currentJceHead
=
null
println
(
"skipping to $tag: endOfInput"
)
//
println("skipping to $tag: endOfInput")
return
null
return
null
}
}
...
@@ -804,19 +806,19 @@ internal inline fun <R> Jce.JceInput.skipToTagOrNull(tag: Int, block: (JceHead)
...
@@ -804,19 +806,19 @@ internal inline fun <R> Jce.JceInput.skipToTagOrNull(tag: Int, block: (JceHead)
}
}
if
(
head
.
tag
>
tag
)
{
if
(
head
.
tag
>
tag
)
{
println
(
"skipping to $tag: head.tag > tag"
)
//
println("skipping to $tag: head.tag > tag")
return
null
return
null
}
}
// readHead()
// readHead()
if
(
head
.
tag
==
tag
)
{
if
(
head
.
tag
==
tag
)
{
// readHeadOrNull()
// readHeadOrNull()
currentJceHead
=
null
currentJceHead
=
null
println
(
"skipping to $tag: run block"
)
//
println("skipping to $tag: run block")
return
block
(
head
)
return
block
(
head
)
}
else
{
}
else
{
println
(
"skipping to $tag: tag not matching"
)
//
println("skipping to $tag: tag not matching")
}
}
println
(
"skipping to $tag: skipField"
)
//
println("skipping to $tag: skipField")
this
.
skipField
(
head
.
type
)
this
.
skipField
(
head
.
type
)
currentJceHead
=
readHeadOrNull
()
currentJceHead
=
readHeadOrNull
()
}
}
...
...
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