mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 17:00:14 +08:00
Rearrange files
This commit is contained in:
parent
4ce4c025ee
commit
ecd41bc4e0
@ -13,6 +13,7 @@ package net.mamoe.mirai.console.setting
|
|||||||
|
|
||||||
import net.mamoe.mirai.console.setting.internal.cast
|
import net.mamoe.mirai.console.setting.internal.cast
|
||||||
import net.mamoe.mirai.console.setting.internal.valueFromKTypeImpl
|
import net.mamoe.mirai.console.setting.internal.valueFromKTypeImpl
|
||||||
|
import net.mamoe.mirai.console.setting.internal.valueImpl
|
||||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||||
import kotlin.internal.LowPriorityInOverloadResolution
|
import kotlin.internal.LowPriorityInOverloadResolution
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
@ -54,7 +55,7 @@ internal abstract class SettingImpl {
|
|||||||
|
|
||||||
// TODO: 2020/6/19 CODEGEN
|
// TODO: 2020/6/19 CODEGEN
|
||||||
|
|
||||||
fun Setting.value(value: Int): IntValue = TODO("codegen")
|
fun Setting.value(default: Int): IntValue = valueImpl(default)
|
||||||
|
|
||||||
//// endregion Setting.value primitives CODEGEN ////
|
//// endregion Setting.value primitives CODEGEN ////
|
||||||
|
|
||||||
|
@ -13,25 +13,6 @@ package net.mamoe.mirai.console.setting.internal
|
|||||||
|
|
||||||
import net.mamoe.mirai.console.setting.*
|
import net.mamoe.mirai.console.setting.*
|
||||||
|
|
||||||
internal abstract class IntValueImpl : IntValue {
|
|
||||||
constructor()
|
|
||||||
constructor(default: Int) {
|
|
||||||
_value = default
|
|
||||||
}
|
|
||||||
|
|
||||||
private var _value: Int? = null
|
|
||||||
|
|
||||||
override var value: Int
|
|
||||||
get() = _value ?: throw IllegalStateException("IntValue should be initialized before get.")
|
|
||||||
set(v) {
|
|
||||||
if (v != this._value) {
|
|
||||||
this._value = v
|
|
||||||
onChanged()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract fun onChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
// type inference bug
|
// type inference bug
|
||||||
internal fun <T> Setting.createCompositeSetValueImpl(tToValue: (T) -> Value<T>): CompositeSetValueImpl<T> {
|
internal fun <T> Setting.createCompositeSetValueImpl(tToValue: (T) -> Value<T>): CompositeSetValueImpl<T> {
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.mamoe.mirai.console.setting.internal
|
||||||
|
|
||||||
|
import net.mamoe.mirai.console.setting.IntValue
|
||||||
|
|
||||||
|
|
||||||
|
//// region PrimitiveValues CODEGEN ////
|
||||||
|
|
||||||
|
// TODO: 2020/6/21 CODEGEN
|
||||||
|
|
||||||
|
internal abstract class IntValueImpl : IntValue {
|
||||||
|
constructor()
|
||||||
|
constructor(default: Int) {
|
||||||
|
_value = default
|
||||||
|
}
|
||||||
|
|
||||||
|
private var _value: Int? = null
|
||||||
|
|
||||||
|
override var value: Int
|
||||||
|
get() = _value ?: throw IllegalStateException("IntValue should be initialized before get.")
|
||||||
|
set(v) {
|
||||||
|
if (v != this._value) {
|
||||||
|
this._value = v
|
||||||
|
onChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract fun onChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
//// endregion PrimitiveValues CODEGEN ////
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2020 Mamoe Technologies and contributors.
|
||||||
|
*
|
||||||
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||||
|
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.mamoe.mirai.console.setting.internal
|
||||||
|
|
||||||
|
import net.mamoe.mirai.console.setting.IntValue
|
||||||
|
import net.mamoe.mirai.console.setting.Setting
|
||||||
|
|
||||||
|
|
||||||
|
//// region Setting.value primitives impl CODEGEN ////
|
||||||
|
|
||||||
|
// TODO: 2020/6/21 CODEGEN
|
||||||
|
|
||||||
|
internal fun Setting.valueImpl(default: Int): IntValue = object : IntValueImpl(default) {
|
||||||
|
override fun onChanged() = this@valueImpl.onValueChanged(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
//// endregion Setting.value primitives impl CODEGEN ////
|
Loading…
Reference in New Issue
Block a user