Update kotlin version. Minor fix to Meta equality

This commit is contained in:
Alexander Nozik 2021-06-04 19:52:34 +03:00
parent 1037c45c0d
commit 254163bdef
14 changed files with 47 additions and 63 deletions

View File

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

View File

@ -4,7 +4,7 @@ plugins {
allprojects {
group = "space.kscience"
version = "0.4.1"
version = "0.4.2"
}
subprojects {

View File

@ -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 {
}

View File

@ -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<out LogManager>
*/
@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

View File

@ -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)
}

View File

@ -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<Attribute>
)
@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> = [ValueType.STRING],
val def: String = "",
val allowed: Array<String> = [],
val enumeration: KClass<*> = Any::class
)
//@MustBeDocumented
//annotation class Attribute(
// val key: String,
// val value: String
//)
//
//@MustBeDocumented
//annotation class Attributes(
// val attrs: Array<Attribute>
//)
//
//@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> = [ValueType.STRING],
// val def: String = "",
// val allowed: Array<String> = [],
// val enumeration: KClass<*> = Any::class
//)
///**
// * Description text for meta property, node or whole object

View File

@ -68,7 +68,8 @@ internal class MapAction<in T : Any, out R : Any>(
//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

View File

@ -49,6 +49,7 @@ public interface Data<out T : Any> : Goal<T>, MetaRepr {
/**
* An empty data containing only meta
*/
@OptIn(DelicateCoroutinesApi::class)
public fun empty(meta: Meta): Data<Nothing> = object : Data<Nothing> {
override val type: KType = TYPE_OF_NOTHING
override val meta: Meta = meta

View File

@ -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)
}
}

View File

@ -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 <init> (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 <init> (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

View File

@ -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<NameToken, MetaItem> = emptyMap()

View File

@ -54,7 +54,7 @@ public class MetaItemNode<M : Meta>(public val node: M) : TypedMetaItem<M>() {
//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()
}

View File

@ -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 : ObservableItemProvider, T> 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))
}
}

View File

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