mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +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
|
||||
*/
|
||||
|
@ -146,13 +146,19 @@ internal abstract class SettingImpl {
|
||||
}
|
||||
|
||||
|
||||
//// region Setting.value primitives CODEGEN ////
|
||||
|
||||
// TODO: 2020/6/19 CODEGEN
|
||||
//// region Setting_value_primitives 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: 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 ////
|
||||
|
||||
|
||||
/**
|
||||
@ -170,4 +176,6 @@ inline fun <reified T> Setting.valueReified(default: T): SerializerAwareValue<T>
|
||||
valueFromKTypeImpl(typeOf<T>()).cast()
|
||||
|
||||
@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