Rearrange files

This commit is contained in:
Him188 2020-06-21 15:38:47 +08:00
parent 4ce4c025ee
commit ecd41bc4e0
6 changed files with 65 additions and 20 deletions

View File

@ -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.valueFromKTypeImpl
import net.mamoe.mirai.console.setting.internal.valueImpl
import net.mamoe.mirai.utils.MiraiExperimentalAPI
import kotlin.internal.LowPriorityInOverloadResolution
import kotlin.reflect.KProperty
@ -54,7 +55,7 @@ internal abstract class SettingImpl {
// 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 ////

View File

@ -13,25 +13,6 @@ package net.mamoe.mirai.console.setting.internal
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
internal fun <T> Setting.createCompositeSetValueImpl(tToValue: (T) -> Value<T>): CompositeSetValueImpl<T> {

View File

@ -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 ////

View File

@ -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 ////