diff --git a/CHANGELOG.md b/CHANGELOG.md index 03bc4627..5f981e24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Changed - **API breaking** Descriptor no has a member property `defaultValue` instead of `defaultItem()` extension. It cahces default value state on the first call. It is done because computing default on each call is too expensive. +- Kotlin 1.5.10 ### Deprecated diff --git a/build.gradle.kts b/build.gradle.kts index ead6c9c2..8a37909d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { allprojects { group = "space.kscience" - version = "0.4.1" + version = "0.4.2" } subprojects { diff --git a/dataforge-context/api/dataforge-context.api b/dataforge-context/api/dataforge-context.api index 3cf0970c..e41727af 100644 --- a/dataforge-context/api/dataforge-context.api +++ b/dataforge-context/api/dataforge-context.api @@ -228,28 +228,6 @@ public final class space/kscience/dataforge/context/SlfLogManager$Companion : sp public fun invoke (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/context/Context;)Lspace/kscience/dataforge/context/SlfLogManager; } -public abstract interface annotation class space/kscience/dataforge/descriptors/Attribute : java/lang/annotation/Annotation { - public abstract fun key ()Ljava/lang/String; - public abstract fun value ()Ljava/lang/String; -} - -public abstract interface annotation class space/kscience/dataforge/descriptors/Attributes : java/lang/annotation/Annotation { - public abstract fun attrs ()[Lspace/kscience/dataforge/descriptors/Attribute; -} - -public abstract interface annotation class space/kscience/dataforge/descriptors/ItemDef : java/lang/annotation/Annotation { - public abstract fun info ()Ljava/lang/String; - public abstract fun multiple ()Z - public abstract fun required ()Z -} - -public abstract interface annotation class space/kscience/dataforge/descriptors/ValueDef : java/lang/annotation/Annotation { - public abstract fun allowed ()[Ljava/lang/String; - public abstract fun def ()Ljava/lang/String; - public abstract fun enumeration ()Ljava/lang/Class; - public abstract fun type ()[Lspace/kscience/dataforge/values/ValueType; -} - public final class space/kscience/dataforge/properties/PropertyKt { } diff --git a/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/context/Global.kt b/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/context/Global.kt index fe22af62..59450fdb 100644 --- a/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/context/Global.kt +++ b/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/context/Global.kt @@ -1,6 +1,6 @@ package space.kscience.dataforge.context -import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.Job import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.names.asName @@ -14,7 +14,7 @@ internal expect val globalLoggerFactory: PluginFactory */ @ThreadLocal private object GlobalContext : Context("GLOBAL".asName(), null, Meta.EMPTY) { - override val coroutineContext: CoroutineContext = GlobalScope.coroutineContext + Job() + override val coroutineContext: CoroutineContext = Job() + CoroutineName("GlobalContext") } public val Global: Context get() = GlobalContext diff --git a/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/context/PluginManager.kt b/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/context/PluginManager.kt index 26e32f3c..748c2359 100644 --- a/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/context/PluginManager.kt +++ b/dataforge-context/src/commonMain/kotlin/space/kscience/dataforge/context/PluginManager.kt @@ -88,6 +88,7 @@ public class PluginManager(override val context: Context) : ContextAware, Iterab error("Plugin with tag ${plugin.tag} already exists in ${context.name}") } else { for ((factory, meta) in plugin.dependsOn()) { + @Suppress("DEPRECATION") fetch(factory, meta, true) } diff --git a/dataforge-context/src/jvmMain/kotlin/space/kscience/dataforge/descriptors/annotations.kt b/dataforge-context/src/jvmMain/kotlin/space/kscience/dataforge/descriptors/annotations.kt index 25daa096..f97cb28d 100644 --- a/dataforge-context/src/jvmMain/kotlin/space/kscience/dataforge/descriptors/annotations.kt +++ b/dataforge-context/src/jvmMain/kotlin/space/kscience/dataforge/descriptors/annotations.kt @@ -16,35 +16,32 @@ package space.kscience.dataforge.descriptors -import space.kscience.dataforge.values.ValueType -import kotlin.reflect.KClass - -@MustBeDocumented -annotation class Attribute( - val key: String, - val value: String -) - -@MustBeDocumented -annotation class Attributes( - val attrs: Array -) - -@MustBeDocumented -annotation class ItemDef( - val info: String = "", - val multiple: Boolean = false, - val required: Boolean = false -) - -@Target(AnnotationTarget.PROPERTY) -@MustBeDocumented -annotation class ValueDef( - val type: Array = [ValueType.STRING], - val def: String = "", - val allowed: Array = [], - val enumeration: KClass<*> = Any::class -) +//@MustBeDocumented +//annotation class Attribute( +// val key: String, +// val value: String +//) +// +//@MustBeDocumented +//annotation class Attributes( +// val attrs: Array +//) +// +//@MustBeDocumented +//annotation class ItemDef( +// val info: String = "", +// val multiple: Boolean = false, +// val required: Boolean = false +//) +// +//@Target(AnnotationTarget.PROPERTY) +//@MustBeDocumented +//annotation class ValueDef( +// val type: Array = [ValueType.STRING], +// val def: String = "", +// val allowed: Array = [], +// val enumeration: KClass<*> = Any::class +//) ///** // * Description text for meta property, node or whole object diff --git a/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/actions/MapAction.kt b/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/actions/MapAction.kt index aa71ff44..3479d3f7 100644 --- a/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/actions/MapAction.kt +++ b/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/actions/MapAction.kt @@ -68,7 +68,8 @@ internal class MapAction( //getting new meta val newMeta = builder.meta.seal() - @OptIn(DFInternal::class) val newData = Data(outputType, newMeta, dependencies = listOf(data)) { + @OptIn(DFInternal::class) + val newData = Data(outputType, newMeta, dependencies = listOf(data)) { builder.result(env, data.await()) } //setting the data node diff --git a/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/Data.kt b/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/Data.kt index 955af3ef..8e681678 100644 --- a/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/Data.kt +++ b/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/Data.kt @@ -49,6 +49,7 @@ public interface Data : Goal, MetaRepr { /** * An empty data containing only meta */ + @OptIn(DelicateCoroutinesApi::class) public fun empty(meta: Meta): Data = object : Data { override val type: KType = TYPE_OF_NOTHING override val meta: Meta = meta diff --git a/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/GroupRule.kt b/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/GroupRule.kt index 90a85f30..64f5f6f4 100644 --- a/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/GroupRule.kt +++ b/dataforge-data/src/commonMain/kotlin/space/kscience/dataforge/data/GroupRule.kt @@ -52,7 +52,9 @@ public interface GroupRule { scope.launch { set.updates.collect { name -> val data = set.getData(name) - val tagValue = data?.meta[key].string ?: defaultTagValue + + @Suppress("NULLABLE_EXTENSION_OPERATOR_WITH_SAFE_CALL_RECEIVER") + val tagValue = data?.meta[key]?.string ?: defaultTagValue map.getOrPut(tagValue) { ActiveDataTree(set.dataType) }.emit(name, data) } } diff --git a/dataforge-meta/api/dataforge-meta.api b/dataforge-meta/api/dataforge-meta.api index c2362a0d..a4f8ad8a 100644 --- a/dataforge-meta/api/dataforge-meta.api +++ b/dataforge-meta/api/dataforge-meta.api @@ -249,6 +249,7 @@ public final class space/kscience/dataforge/meta/MetaItemNode : space/kscience/d public static final field Companion Lspace/kscience/dataforge/meta/MetaItemNode$Companion; public fun (Lspace/kscience/dataforge/meta/Meta;)V public fun equals (Ljava/lang/Object;)Z + public fun getItem (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/TypedMetaItem; public final fun getNode ()Lspace/kscience/dataforge/meta/Meta; public fun hashCode ()I public fun toString ()Ljava/lang/String; @@ -271,6 +272,7 @@ public final class space/kscience/dataforge/meta/MetaItemValue : space/kscience/ public static final field Companion Lspace/kscience/dataforge/meta/MetaItemValue$Companion; public fun (Lspace/kscience/dataforge/values/Value;)V public fun equals (Ljava/lang/Object;)Z + public fun getItem (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/TypedMetaItem; public final fun getValue ()Lspace/kscience/dataforge/values/Value; public fun hashCode ()I public fun toString ()Ljava/lang/String; @@ -464,6 +466,7 @@ public abstract interface class space/kscience/dataforge/meta/Specification : sp } public final class space/kscience/dataforge/meta/SpecificationKt { + public static synthetic fun listOfSpec$default (Lspace/kscience/dataforge/meta/MutableItemProvider;Lspace/kscience/dataforge/meta/Specification;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; public static final fun spec (Lspace/kscience/dataforge/meta/MutableItemProvider;Lspace/kscience/dataforge/meta/Specification;Lspace/kscience/dataforge/names/Name;)Lkotlin/properties/ReadWriteProperty; public static synthetic fun spec$default (Lspace/kscience/dataforge/meta/MutableItemProvider;Lspace/kscience/dataforge/meta/Specification;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lkotlin/properties/ReadWriteProperty; public static final fun update (Lspace/kscience/dataforge/meta/Configurable;Lspace/kscience/dataforge/meta/Specification;Lkotlin/jvm/functions/Function1;)V @@ -476,7 +479,7 @@ public abstract interface class space/kscience/dataforge/meta/TypedMeta : space/ public abstract fun getItems ()Ljava/util/Map; } -public abstract class space/kscience/dataforge/meta/TypedMetaItem { +public abstract class space/kscience/dataforge/meta/TypedMetaItem : space/kscience/dataforge/meta/ItemProvider { public static final field Companion Lspace/kscience/dataforge/meta/TypedMetaItem$Companion; public abstract fun equals (Ljava/lang/Object;)Z public abstract fun hashCode ()I diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt index 12a03a62..22c69138 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Meta.kt @@ -54,7 +54,7 @@ public interface Meta : MetaRepr, ItemProvider { */ public const val VALUE_KEY: String = "@value" - public fun equals(meta1: Meta, meta2: Meta): Boolean = meta1.items == meta2.items + public fun equals(meta1: Meta?, meta2: Meta?): Boolean = meta1?.items == meta2?.items public val EMPTY: Meta = object : MetaBase() { override val items: Map = emptyMap() diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MetaItem.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MetaItem.kt index 4b8dc25d..a486a6ee 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MetaItem.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/MetaItem.kt @@ -54,7 +54,7 @@ public class MetaItemNode(public val node: M) : TypedMetaItem() { //Fixing serializer for node could cause class cast problems, but it should not since Meta descendants are not serializable override fun toString(): String = node.toString() - override fun equals(other: Any?): Boolean = node == (other as? MetaItemNode<*>)?.node + override fun equals(other: Any?): Boolean = Meta.equals(node, (other as? MetaItemNode<*>)?.node) override fun hashCode(): Int = node.hashCode() } diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableItemProvider.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableItemProvider.kt index d5183fb9..b6dc78e7 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableItemProvider.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/ObservableItemProvider.kt @@ -2,8 +2,8 @@ package space.kscience.dataforge.meta import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.names.Name +import space.kscience.dataforge.names.asName import space.kscience.dataforge.names.startsWith -import space.kscience.dataforge.names.toName import kotlin.reflect.KProperty1 @@ -35,7 +35,7 @@ public fun O.useProperty( //Pass initial value. callBack(property.get(this)) onChange(owner) { name, oldItem, newItem -> - if (name.startsWith(property.name.toName()) && oldItem != newItem) { + if (name.startsWith(property.name.asName()) && oldItem != newItem) { callBack(property.get(this)) } } diff --git a/settings.gradle.kts b/settings.gradle.kts index c77e05e2..7040baaf 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,8 +5,8 @@ pluginManagement { gradlePluginPortal() } - val toolsVersion = "0.9.5" - val kotlinVersion = "1.5.0" + val toolsVersion = "0.9.10" + val kotlinVersion = "1.5.10" plugins { id("ru.mipt.npm.gradle.project") version toolsVersion