mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 02:35:40 +08:00
Added new function to call CurrentClass in ReflectionFactory
This commit is contained in:
@@ -147,10 +147,20 @@ inline fun Class<*>.constructor(initiate: ConstructorFinder.() -> Unit = { empty
|
||||
* @return [T]
|
||||
*/
|
||||
inline fun <reified T : Any> T.current(initiate: CurrentClass.() -> Unit): T {
|
||||
if (javaClass.name == CurrentClass::class.java.name) error("Cannot create itself within CurrentClass itself")
|
||||
CurrentClass(javaClass, self = this).apply(initiate)
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得当前实例的类操作对象
|
||||
* @return [CurrentClass]
|
||||
*/
|
||||
inline fun <reified T : Any> T.current(): CurrentClass {
|
||||
if (javaClass.name == CurrentClass::class.java.name) error("Cannot create itself within CurrentClass itself")
|
||||
return CurrentClass(javaClass, self = this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过构造方法创建新实例 - 任意类型 [Any]
|
||||
* @param param 方法参数
|
||||
|
Reference in New Issue
Block a user