diff --git a/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt b/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt index 384c911fb..b4c0014a3 100644 --- a/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt +++ b/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt @@ -110,7 +110,7 @@ fun genAllValueImpl(): String = buildString { ): Mutable${number}${collectionName}Value { var internalValue: Mutable${collectionName}<${number}> = default - val delegt = dynamicMutable${collectionName}{ internalValue } + val delegt = dynamicMutable${collectionName} { internalValue } return object : Mutable${number}${collectionName}Value(), Mutable${collectionName}<${number}> by delegt { override var value: Mutable${collectionName}<${number}> get() = internalValue @@ -128,7 +128,7 @@ fun genAllValueImpl(): String = buildString { override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): Mutable${collectionName}<${number}> { - return delegate.deserialize(decoder).toMutable${collectionName}().observable { + return delegate.deserialize(decoder).toMutable${collectionName}().observable { onElementChanged(outerThis) } } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/_ValueImpl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/_ValueImpl.kt index 6804471fe..e6ac2ab62 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/_ValueImpl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/_ValueImpl.kt @@ -9,7 +9,10 @@ package net.mamoe.mirai.console.setting.internal -import kotlinx.serialization.* +import kotlinx.serialization.Decoder +import kotlinx.serialization.Encoder +import kotlinx.serialization.KSerializer +import kotlinx.serialization.SerialDescriptor import kotlinx.serialization.builtins.* import net.mamoe.mirai.console.setting.* @@ -705,7 +708,7 @@ internal fun Setting.valueImpl( ): MutableIntListValue { var internalValue: MutableList = default - val delegt = dynamicMutableList{ internalValue } + val delegt = dynamicMutableList { internalValue } return object : MutableIntListValue(), MutableList by delegt { override var value: MutableList get() = internalValue @@ -715,15 +718,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Int.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableList { - return delegate.deserialize(decoder).toMutableList().observable { + return delegate.deserialize(decoder).toMutableList().observable { onElementChanged(outerThis) } } @@ -741,7 +744,7 @@ internal fun Setting.valueImpl( ): MutableShortListValue { var internalValue: MutableList = default - val delegt = dynamicMutableList{ internalValue } + val delegt = dynamicMutableList { internalValue } return object : MutableShortListValue(), MutableList by delegt { override var value: MutableList get() = internalValue @@ -751,15 +754,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Short.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableList { - return delegate.deserialize(decoder).toMutableList().observable { + return delegate.deserialize(decoder).toMutableList().observable { onElementChanged(outerThis) } } @@ -777,7 +780,7 @@ internal fun Setting.valueImpl( ): MutableByteListValue { var internalValue: MutableList = default - val delegt = dynamicMutableList{ internalValue } + val delegt = dynamicMutableList { internalValue } return object : MutableByteListValue(), MutableList by delegt { override var value: MutableList get() = internalValue @@ -787,15 +790,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Byte.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableList { - return delegate.deserialize(decoder).toMutableList().observable { + return delegate.deserialize(decoder).toMutableList().observable { onElementChanged(outerThis) } } @@ -813,7 +816,7 @@ internal fun Setting.valueImpl( ): MutableLongListValue { var internalValue: MutableList = default - val delegt = dynamicMutableList{ internalValue } + val delegt = dynamicMutableList { internalValue } return object : MutableLongListValue(), MutableList by delegt { override var value: MutableList get() = internalValue @@ -823,15 +826,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Long.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableList { - return delegate.deserialize(decoder).toMutableList().observable { + return delegate.deserialize(decoder).toMutableList().observable { onElementChanged(outerThis) } } @@ -849,7 +852,7 @@ internal fun Setting.valueImpl( ): MutableFloatListValue { var internalValue: MutableList = default - val delegt = dynamicMutableList{ internalValue } + val delegt = dynamicMutableList { internalValue } return object : MutableFloatListValue(), MutableList by delegt { override var value: MutableList get() = internalValue @@ -859,15 +862,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Float.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableList { - return delegate.deserialize(decoder).toMutableList().observable { + return delegate.deserialize(decoder).toMutableList().observable { onElementChanged(outerThis) } } @@ -885,7 +888,7 @@ internal fun Setting.valueImpl( ): MutableDoubleListValue { var internalValue: MutableList = default - val delegt = dynamicMutableList{ internalValue } + val delegt = dynamicMutableList { internalValue } return object : MutableDoubleListValue(), MutableList by delegt { override var value: MutableList get() = internalValue @@ -895,15 +898,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Double.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableList { - return delegate.deserialize(decoder).toMutableList().observable { + return delegate.deserialize(decoder).toMutableList().observable { onElementChanged(outerThis) } } @@ -921,7 +924,7 @@ internal fun Setting.valueImpl( ): MutableBooleanListValue { var internalValue: MutableList = default - val delegt = dynamicMutableList{ internalValue } + val delegt = dynamicMutableList { internalValue } return object : MutableBooleanListValue(), MutableList by delegt { override var value: MutableList get() = internalValue @@ -931,15 +934,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Boolean.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableList { - return delegate.deserialize(decoder).toMutableList().observable { + return delegate.deserialize(decoder).toMutableList().observable { onElementChanged(outerThis) } } @@ -957,7 +960,7 @@ internal fun Setting.valueImpl( ): MutableCharListValue { var internalValue: MutableList = default - val delegt = dynamicMutableList{ internalValue } + val delegt = dynamicMutableList { internalValue } return object : MutableCharListValue(), MutableList by delegt { override var value: MutableList get() = internalValue @@ -967,15 +970,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(Char.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableList { - return delegate.deserialize(decoder).toMutableList().observable { + return delegate.deserialize(decoder).toMutableList().observable { onElementChanged(outerThis) } } @@ -993,7 +996,7 @@ internal fun Setting.valueImpl( ): MutableStringListValue { var internalValue: MutableList = default - val delegt = dynamicMutableList{ internalValue } + val delegt = dynamicMutableList { internalValue } return object : MutableStringListValue(), MutableList by delegt { override var value: MutableList get() = internalValue @@ -1003,15 +1006,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = ListSerializer(String.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableList { - return delegate.deserialize(decoder).toMutableList().observable { + return delegate.deserialize(decoder).toMutableList().observable { onElementChanged(outerThis) } } @@ -1029,7 +1032,7 @@ internal fun Setting.valueImpl( ): MutableIntSetValue { var internalValue: MutableSet = default - val delegt = dynamicMutableSet{ internalValue } + val delegt = dynamicMutableSet { internalValue } return object : MutableIntSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue @@ -1039,15 +1042,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Int.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableSet { - return delegate.deserialize(decoder).toMutableSet().observable { + return delegate.deserialize(decoder).toMutableSet().observable { onElementChanged(outerThis) } } @@ -1065,7 +1068,7 @@ internal fun Setting.valueImpl( ): MutableShortSetValue { var internalValue: MutableSet = default - val delegt = dynamicMutableSet{ internalValue } + val delegt = dynamicMutableSet { internalValue } return object : MutableShortSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue @@ -1075,15 +1078,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Short.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableSet { - return delegate.deserialize(decoder).toMutableSet().observable { + return delegate.deserialize(decoder).toMutableSet().observable { onElementChanged(outerThis) } } @@ -1101,7 +1104,7 @@ internal fun Setting.valueImpl( ): MutableByteSetValue { var internalValue: MutableSet = default - val delegt = dynamicMutableSet{ internalValue } + val delegt = dynamicMutableSet { internalValue } return object : MutableByteSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue @@ -1111,15 +1114,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Byte.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableSet { - return delegate.deserialize(decoder).toMutableSet().observable { + return delegate.deserialize(decoder).toMutableSet().observable { onElementChanged(outerThis) } } @@ -1137,7 +1140,7 @@ internal fun Setting.valueImpl( ): MutableLongSetValue { var internalValue: MutableSet = default - val delegt = dynamicMutableSet{ internalValue } + val delegt = dynamicMutableSet { internalValue } return object : MutableLongSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue @@ -1147,15 +1150,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Long.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableSet { - return delegate.deserialize(decoder).toMutableSet().observable { + return delegate.deserialize(decoder).toMutableSet().observable { onElementChanged(outerThis) } } @@ -1173,7 +1176,7 @@ internal fun Setting.valueImpl( ): MutableFloatSetValue { var internalValue: MutableSet = default - val delegt = dynamicMutableSet{ internalValue } + val delegt = dynamicMutableSet { internalValue } return object : MutableFloatSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue @@ -1183,15 +1186,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Float.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableSet { - return delegate.deserialize(decoder).toMutableSet().observable { + return delegate.deserialize(decoder).toMutableSet().observable { onElementChanged(outerThis) } } @@ -1209,7 +1212,7 @@ internal fun Setting.valueImpl( ): MutableDoubleSetValue { var internalValue: MutableSet = default - val delegt = dynamicMutableSet{ internalValue } + val delegt = dynamicMutableSet { internalValue } return object : MutableDoubleSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue @@ -1219,15 +1222,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Double.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableSet { - return delegate.deserialize(decoder).toMutableSet().observable { + return delegate.deserialize(decoder).toMutableSet().observable { onElementChanged(outerThis) } } @@ -1245,7 +1248,7 @@ internal fun Setting.valueImpl( ): MutableBooleanSetValue { var internalValue: MutableSet = default - val delegt = dynamicMutableSet{ internalValue } + val delegt = dynamicMutableSet { internalValue } return object : MutableBooleanSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue @@ -1255,15 +1258,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Boolean.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableSet { - return delegate.deserialize(decoder).toMutableSet().observable { + return delegate.deserialize(decoder).toMutableSet().observable { onElementChanged(outerThis) } } @@ -1281,7 +1284,7 @@ internal fun Setting.valueImpl( ): MutableCharSetValue { var internalValue: MutableSet = default - val delegt = dynamicMutableSet{ internalValue } + val delegt = dynamicMutableSet { internalValue } return object : MutableCharSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue @@ -1291,15 +1294,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(Char.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableSet { - return delegate.deserialize(decoder).toMutableSet().observable { + return delegate.deserialize(decoder).toMutableSet().observable { onElementChanged(outerThis) } } @@ -1317,7 +1320,7 @@ internal fun Setting.valueImpl( ): MutableStringSetValue { var internalValue: MutableSet = default - val delegt = dynamicMutableSet{ internalValue } + val delegt = dynamicMutableSet { internalValue } return object : MutableStringSetValue(), MutableSet by delegt { override var value: MutableSet get() = internalValue @@ -1327,15 +1330,15 @@ internal fun Setting.valueImpl( onElementChanged(this) } } - + private val outerThis get() = this - + override val serializer: KSerializer> = object : KSerializer> { private val delegate = SetSerializer(String.serializer()) override val descriptor: SerialDescriptor get() = delegate.descriptor override fun deserialize(decoder: Decoder): MutableSet { - return delegate.deserialize(decoder).toMutableSet().observable { + return delegate.deserialize(decoder).toMutableSet().observable { onElementChanged(outerThis) } } @@ -1359,7 +1362,7 @@ internal fun Setting.valueImpl(default: T): Value { onElementChanged(this) } } - override val serializer = object : KSerializer{ + override val serializer = object : KSerializer { override val descriptor: SerialDescriptor get() = internalValue.updaterSerializer.descriptor