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
70dd71cb
Commit
70dd71cb
authored
Mar 24, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate to Kotlin 1.4
parent
eb7afb6c
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
70 deletions
+56
-70
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/internal/InternalEventListeners.kt
.../net.mamoe.mirai/event/internal/InternalEventListeners.kt
+2
-17
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/select.kt
...ore/src/commonMain/kotlin/net.mamoe.mirai/event/select.kt
+3
-5
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt
...monMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt
+39
-47
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/contentToString.kt
...ommonMain/kotlin/net.mamoe.mirai/utils/contentToString.kt
+12
-1
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/internal/InternalEventListeners.kt
View file @
70dd71cb
...
@@ -115,24 +115,9 @@ internal class Handler<in E : Event>
...
@@ -115,24 +115,9 @@ internal class Handler<in E : Event>
*/
*/
internal
fun
<
E
:
Event
>
KClass
<
out
E
>.
listeners
():
EventListeners
<
E
>
=
EventListenerManager
.
get
(
this
)
internal
fun
<
E
:
Event
>
KClass
<
out
E
>.
listeners
():
EventListeners
<
E
>
=
EventListenerManager
.
get
(
this
)
internal
class
EventListeners
<
E
:
Event
>(
clazz
:
KClass
<
E
>)
:
LockFreeLinkedList
<
Listener
<
E
>>()
{
internal
expect
class
EventListeners
<
E
:
Event
>(
clazz
:
KClass
<
E
>)
:
LockFreeLinkedList
<
Listener
<
E
>>
{
@Suppress
(
"UNCHECKED_CAST"
,
"UNSUPPORTED"
,
"NO_REFLECTION_IN_CLASS_PATH"
)
@Suppress
(
"UNCHECKED_CAST"
,
"UNSUPPORTED"
,
"NO_REFLECTION_IN_CLASS_PATH"
)
val
supertypes
:
Set
<
KClass
<
out
Event
>>
by
lazy
{
val
supertypes
:
Set
<
KClass
<
out
Event
>>
val
supertypes
=
mutableSetOf
<
KClass
<
out
Event
>>()
fun
addSupertypes
(
clazz
:
KClass
<
out
Event
>)
{
clazz
.
supertypes
.
forEach
{
val
classifier
=
it
.
classifier
as
?
KClass
<
out
Event
>
if
(
classifier
!=
null
)
{
supertypes
.
add
(
classifier
)
addSupertypes
(
classifier
)
}
}
}
addSupertypes
(
clazz
)
supertypes
}
}
}
internal
expect
class
MiraiAtomicBoolean
(
initial
:
Boolean
)
{
internal
expect
class
MiraiAtomicBoolean
(
initial
:
Boolean
)
{
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/select.kt
View file @
70dd71cb
...
@@ -285,7 +285,7 @@ abstract class MessageSelectBuilderUnit<M : MessagePacket<*, *>, R> @PublishedAp
...
@@ -285,7 +285,7 @@ abstract class MessageSelectBuilderUnit<M : MessagePacket<*, *>, R> @PublishedAp
* 在超时后引用回复原消息
* 在超时后引用回复原消息
*
*
* 当 [block] 返回值为 [Unit] 时不回复, 为 [Message] 时回复 [Message], 其他将 [toString] 后回复为 [PlainText]
* 当 [block] 返回值为 [Unit] 时不回复, 为 [Message] 时回复 [Message], 其他将 [toString] 后回复为 [PlainText]
*
* @see timeout
* @see timeout
* @see reply
* @see reply
*/
*/
...
@@ -304,8 +304,7 @@ abstract class MessageSelectBuilderUnit<M : MessagePacket<*, *>, R> @PublishedAp
...
@@ -304,8 +304,7 @@ abstract class MessageSelectBuilderUnit<M : MessagePacket<*, *>, R> @PublishedAp
*/
*/
@MessageDsl
@MessageDsl
fun
defaultReply
(
block
:
suspend
()
->
Any
?):
Unit
=
subscriber
({
true
},
{
fun
defaultReply
(
block
:
suspend
()
->
Any
?):
Unit
=
subscriber
({
true
},
{
@Suppress
(
"DSL_SCOPE_VIOLATION_WARNING"
)
// false positive
this
@MessageSelectBuilderUnit
.
executeAndReply
(
block
)
executeAndReply
(
block
)
})
})
...
@@ -316,8 +315,7 @@ abstract class MessageSelectBuilderUnit<M : MessagePacket<*, *>, R> @PublishedAp
...
@@ -316,8 +315,7 @@ abstract class MessageSelectBuilderUnit<M : MessagePacket<*, *>, R> @PublishedAp
*/
*/
@MessageDsl
@MessageDsl
fun
defaultQuoteReply
(
block
:
suspend
()
->
Any
?):
Unit
=
subscriber
({
true
},
{
fun
defaultQuoteReply
(
block
:
suspend
()
->
Any
?):
Unit
=
subscriber
({
true
},
{
@Suppress
(
"DSL_SCOPE_VIOLATION_WARNING"
)
// false positive
this
@MessageSelectBuilderUnit
.
executeAndQuoteReply
(
block
)
executeAndQuoteReply
(
block
)
})
})
private
suspend
inline
fun
executeAndReply
(
noinline
block
:
suspend
()
->
Any
?)
{
private
suspend
inline
fun
executeAndReply
(
noinline
block
:
suspend
()
->
Any
?)
{
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt
View file @
70dd71cb
This diff is collapsed.
Click to expand it.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/contentToString.kt
View file @
70dd71cb
...
@@ -13,7 +13,9 @@ package net.mamoe.mirai.utils
...
@@ -13,7 +13,9 @@ package net.mamoe.mirai.utils
import
net.mamoe.mirai.utils.io.toUHexString
import
net.mamoe.mirai.utils.io.toUHexString
import
kotlin.reflect.KClass
import
kotlin.reflect.KClass
import
kotlin.reflect.KProperty
import
kotlin.reflect.KProperty1
import
kotlin.reflect.KProperty1
import
kotlin.reflect.KType
private
val
indent
:
String
=
" "
.
repeat
(
4
)
private
val
indent
:
String
=
" "
.
repeat
(
4
)
...
@@ -127,8 +129,14 @@ fun Any?._miraiContentToString(prefix: String = ""): String = when (this) {
...
@@ -127,8 +129,14 @@ fun Any?._miraiContentToString(prefix: String = ""): String = when (this) {
internal
expect
fun
KProperty1
<*,
*>.
getValueAgainstPermission
(
receiver
:
Any
):
Any
?
internal
expect
fun
KProperty1
<*,
*>.
getValueAgainstPermission
(
receiver
:
Any
):
Any
?
private
val
KProperty1
<*,
*>.
isConst
:
Boolean
get
()
=
false
// on JVM, it will be resolved to member function
private
val
KClass
<*>.
isData
:
Boolean
get
()
=
false
// on JVM, it will be resolved to member function
@MiraiDebugAPI
@MiraiDebugAPI
private
fun
Any
.
contentToStringReflectively
(
prefix
:
String
,
filter
:
((
name
:
String
,
value
:
Any
?)
->
Boolean
)?
=
null
):
String
{
private
fun
Any
.
contentToStringReflectively
(
prefix
:
String
,
filter
:
((
name
:
String
,
value
:
Any
?)
->
Boolean
)?
=
null
):
String
{
val
newPrefix
=
"$prefix "
val
newPrefix
=
"$prefix "
return
(
this
::
class
.
simpleName
?:
"<UnnamedClass>"
)
+
"#"
+
this
::
class
.
hashCode
()
+
" {\n"
+
return
(
this
::
class
.
simpleName
?:
"<UnnamedClass>"
)
+
"#"
+
this
::
class
.
hashCode
()
+
" {\n"
+
this
.
allMembersFromSuperClassesMatching
{
it
.
qualifiedName
?.
startsWith
(
"net.mamoe.mirai"
)
==
true
}
this
.
allMembersFromSuperClassesMatching
{
it
.
qualifiedName
?.
startsWith
(
"net.mamoe.mirai"
)
==
true
}
...
@@ -155,11 +163,14 @@ private fun Any.contentToStringReflectively(prefix: String, filter: ((name: Stri
...
@@ -155,11 +163,14 @@ private fun Any.contentToStringReflectively(prefix: String, filter: ((name: Stri
}
+
"\n$prefix}"
}
+
"\n$prefix}"
}
}
private
val
<
T
:
Any
>
KClass
<
T
>.
supertypes
:
List
<
KType
>
get
()
=
listOf
()
// on JVM, it will be resolved to member function
private
fun
KClass
<
out
Any
>.
thisClassAndSuperclassSequence
():
Sequence
<
KClass
<
out
Any
>>
{
private
fun
KClass
<
out
Any
>.
thisClassAndSuperclassSequence
():
Sequence
<
KClass
<
out
Any
>>
{
return
sequenceOf
(
this
)
+
return
sequenceOf
(
this
)
+
this
.
supertypes
.
asSequence
()
this
.
supertypes
.
asSequence
()
.
mapNotNull
{
type
->
type
.
classifier
?.
takeIf
{
it
is
KClass
<
*
>
}
?.
takeIf
{
it
!=
Any
::
class
} as?
KClass
<
out
Any
>
}.
flatMap
{
it
.
thisClassAndSuperclassSequence
()
}
.
mapNotNull
{
type
->
type
.
classifier
?.
takeIf
{
it
is
KClass
<
*
>
}
?.
takeIf
{
it
!=
Any
::
class
} as?
KClass
<
out
Any
>
}.
flatMap
{
it
.
thisClassAndSuperclassSequence
()
}
}
}
private
val
<
T
:
Any
>
KClass
<
T
>.
members
:
List
<
KProperty
<
*
>>
get
()
=
listOf
()
// on JVM, it will be resolved to member function
@Suppress
(
"UNCHECKED_CAST"
)
@Suppress
(
"UNCHECKED_CAST"
)
private
fun
Any
.
allMembersFromSuperClassesMatching
(
classFilter
:
(
KClass
<
out
Any
>)
->
Boolean
):
Sequence
<
KProperty1
<
Any
,
*
>>
{
private
fun
Any
.
allMembersFromSuperClassesMatching
(
classFilter
:
(
KClass
<
out
Any
>)
->
Boolean
):
Sequence
<
KProperty1
<
Any
,
*
>>
{
...
...
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