mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 17:00:14 +08:00
Codegen for Setting_value_primitives
This commit is contained in:
parent
927943322a
commit
1425378e19
@ -136,6 +136,22 @@ internal fun Setting.${ktType.lowerCaseName}ValueImpl(): SerializerAwareValue<${
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object Setting_value_primitivesCodegen : RegionCodegen("Setting.kt"), DefaultInvoke {
|
||||||
|
@JvmStatic
|
||||||
|
fun main(args: Array<String>) = super.startIndependent()
|
||||||
|
override val defaultInvokeArgs: List<KtType> = KtPrimitives + KtString
|
||||||
|
|
||||||
|
override fun StringBuilder.apply(ktType: KtType) {
|
||||||
|
@Suppress("unused")
|
||||||
|
appendKCode(
|
||||||
|
"""
|
||||||
|
fun Setting.value(default: ${ktType.standardName}): SerializerAwareValue<${ktType.standardName}> = valueImpl(default)
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运行本 object 中所有嵌套 object Codegen
|
* 运行本 object 中所有嵌套 object Codegen
|
||||||
*/
|
*/
|
||||||
|
@ -146,13 +146,19 @@ internal abstract class SettingImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//// region Setting.value primitives CODEGEN ////
|
//// region Setting_value_primitives CODEGEN ////
|
||||||
|
|
||||||
// TODO: 2020/6/19 CODEGEN
|
|
||||||
|
|
||||||
|
fun Setting.value(default: Byte): SerializerAwareValue<Byte> = valueImpl(default)
|
||||||
|
fun Setting.value(default: Short): SerializerAwareValue<Short> = valueImpl(default)
|
||||||
fun Setting.value(default: Int): SerializerAwareValue<Int> = valueImpl(default)
|
fun Setting.value(default: Int): SerializerAwareValue<Int> = valueImpl(default)
|
||||||
|
fun Setting.value(default: Long): SerializerAwareValue<Long> = valueImpl(default)
|
||||||
|
fun Setting.value(default: Float): SerializerAwareValue<Float> = valueImpl(default)
|
||||||
|
fun Setting.value(default: Double): SerializerAwareValue<Double> = valueImpl(default)
|
||||||
|
fun Setting.value(default: Char): SerializerAwareValue<Char> = valueImpl(default)
|
||||||
|
fun Setting.value(default: Boolean): SerializerAwareValue<Boolean> = valueImpl(default)
|
||||||
|
fun Setting.value(default: String): SerializerAwareValue<String> = valueImpl(default)
|
||||||
|
|
||||||
//// endregion Setting.value primitives CODEGEN ////
|
//// endregion Setting_value_primitives CODEGEN ////
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,3 +177,5 @@ inline fun <reified T> Setting.valueReified(default: T): SerializerAwareValue<T>
|
|||||||
|
|
||||||
@MiraiExperimentalAPI
|
@MiraiExperimentalAPI
|
||||||
fun <T> Setting.valueFromKType(type: KType): SerializerAwareValue<T> = valueFromKTypeImpl(type).cast()
|
fun <T> Setting.valueFromKType(type: KType): SerializerAwareValue<T> = valueFromKTypeImpl(type).cast()
|
||||||
|
|
||||||
|
// TODO: 2020/6/24 Introduce class TypeToken for compound types for Java.
|
Loading…
Reference in New Issue
Block a user