Compare commits

...

4 Commits

40 changed files with 318 additions and 221 deletions

View File

@ -14,6 +14,22 @@
### Security ### Security
## 0.9.0 - 2024-06-04
### Added
- Custom CoroutineContext during `Context` creation.
### Changed
- Kotlin 2.0
- `MetaSpec` renamed to `MetaReader`. MetaSpec is now reserved for builder-based generation of meta descriptors.
- Add self-type for Meta. Remove unsafe cast method for meta instances.
### Removed
- Automatic descriptors for schema. It is not possible to implement them without heavy reflection.
## 0.8.2 - 2024-04-27 ## 0.8.2 - 2024-04-27
### Added ### Added

View File

@ -3,21 +3,21 @@ import space.kscience.gradle.useApache2Licence
import space.kscience.gradle.useSPCTeam import space.kscience.gradle.useSPCTeam
plugins { plugins {
id("space.kscience.gradle.project") alias(spclibs.plugins.kscience.project)
id("org.jetbrains.kotlinx.kover") version "0.7.6" alias(spclibs.plugins.kotlinx.kover)
} }
allprojects { allprojects {
group = "space.kscience" group = "space.kscience"
version = "0.8.2" version = "0.9.0"
} }
subprojects { subprojects {
apply(plugin = "maven-publish") apply(plugin = "maven-publish")
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
kotlinOptions { compilerOptions {
freeCompilerArgs = freeCompilerArgs + "-Xcontext-receivers" freeCompilerArgs.add("-Xcontext-receivers")
} }
} }
} }

View File

@ -6,7 +6,7 @@ Context and provider definitions
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-context:0.8.2`. The Maven coordinates of this project are `space.kscience:dataforge-context:0.9.0-dev-1`.
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
```kotlin ```kotlin
@ -16,6 +16,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:dataforge-context:0.8.2") implementation("space.kscience:dataforge-context:0.9.0-dev-1")
} }
``` ```

View File

@ -57,6 +57,7 @@ public abstract interface class space/kscience/dataforge/context/ContextAware {
public final class space/kscience/dataforge/context/ContextBuilder { public final class space/kscience/dataforge/context/ContextBuilder {
public final fun build ()Lspace/kscience/dataforge/context/Context; public final fun build ()Lspace/kscience/dataforge/context/Context;
public final fun coroutineContext (Lkotlin/coroutines/CoroutineContext;)V
public final fun getName ()Lspace/kscience/dataforge/names/Name; public final fun getName ()Lspace/kscience/dataforge/names/Name;
public final fun plugin (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V public final fun plugin (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V
public final fun plugin (Lspace/kscience/dataforge/context/Plugin;)V public final fun plugin (Lspace/kscience/dataforge/context/Plugin;)V
@ -69,9 +70,6 @@ public final class space/kscience/dataforge/context/ContextBuilder {
public final fun properties (Lkotlin/jvm/functions/Function1;)V public final fun properties (Lkotlin/jvm/functions/Function1;)V
} }
public final class space/kscience/dataforge/context/ContextBuilderKt {
}
public final class space/kscience/dataforge/context/DefaultLogManager : space/kscience/dataforge/context/AbstractPlugin, space/kscience/dataforge/context/LogManager { public final class space/kscience/dataforge/context/DefaultLogManager : space/kscience/dataforge/context/AbstractPlugin, space/kscience/dataforge/context/LogManager {
public static final field Companion Lspace/kscience/dataforge/context/DefaultLogManager$Companion; public static final field Companion Lspace/kscience/dataforge/context/DefaultLogManager$Companion;
public fun <init> ()V public fun <init> ()V
@ -212,14 +210,14 @@ public final class space/kscience/dataforge/context/PluginTag : space/kscience/d
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
} }
public final class space/kscience/dataforge/context/PluginTag$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public synthetic class space/kscience/dataforge/context/PluginTag$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lspace/kscience/dataforge/context/PluginTag$$serializer; public static final field INSTANCE Lspace/kscience/dataforge/context/PluginTag$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/dataforge/context/PluginTag; public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/dataforge/context/PluginTag;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/dataforge/context/PluginTag;)V public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/dataforge/context/PluginTag;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
} }
@ -264,15 +262,6 @@ public abstract interface annotation class space/kscience/dataforge/descriptors/
public abstract interface annotation class space/kscience/dataforge/descriptors/Multiple : java/lang/annotation/Annotation { public abstract interface annotation class space/kscience/dataforge/descriptors/Multiple : java/lang/annotation/Annotation {
} }
public final class space/kscience/dataforge/descriptors/ReflectiveDescriptorsKt {
}
public final class space/kscience/dataforge/properties/MetaAsFlowKt {
}
public final class space/kscience/dataforge/provider/DfTypeKt {
}
public final class space/kscience/dataforge/provider/Path : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker { public final class space/kscience/dataforge/provider/Path : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker {
public static final field Companion Lspace/kscience/dataforge/provider/Path$Companion; public static final field Companion Lspace/kscience/dataforge/provider/Path$Companion;
public static final field PATH_SEGMENT_SEPARATOR Ljava/lang/String; public static final field PATH_SEGMENT_SEPARATOR Ljava/lang/String;

View File

@ -10,6 +10,7 @@ import space.kscience.dataforge.misc.ThreadSafe
import space.kscience.dataforge.names.Name import space.kscience.dataforge.names.Name
import space.kscience.dataforge.provider.Provider import space.kscience.dataforge.provider.Provider
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
/** /**
* The local environment for anything being done in DataForge framework. Contexts are organized into tree structure with [Global] at the top. * The local environment for anything being done in DataForge framework. Contexts are organized into tree structure with [Global] at the top.
@ -26,6 +27,7 @@ public open class Context internal constructor(
public val parent: Context?, public val parent: Context?,
plugins: Set<Plugin>, // set of unattached plugins plugins: Set<Plugin>, // set of unattached plugins
meta: Meta, meta: Meta,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
) : Named, MetaRepr, Provider, CoroutineScope { ) : Named, MetaRepr, Provider, CoroutineScope {
/** /**
@ -65,7 +67,7 @@ public open class Context internal constructor(
override val coroutineContext: CoroutineContext by lazy { override val coroutineContext: CoroutineContext by lazy {
(parent ?: Global).coroutineContext.let { parenContext -> (parent ?: Global).coroutineContext.let { parenContext ->
parenContext + SupervisorJob(parenContext[Job]) parenContext + coroutineContext + SupervisorJob(parenContext[Job])
} }
} }

View File

@ -13,6 +13,8 @@ import space.kscience.dataforge.names.plus
import kotlin.collections.component1 import kotlin.collections.component1
import kotlin.collections.component2 import kotlin.collections.component2
import kotlin.collections.set import kotlin.collections.set
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
/** /**
* A convenience builder for context * A convenience builder for context
@ -59,8 +61,15 @@ public class ContextBuilder internal constructor(
plugin(DeFactoPluginFactory(plugin)) plugin(DeFactoPluginFactory(plugin))
} }
private var coroutineContext: CoroutineContext = EmptyCoroutineContext
public fun coroutineContext(coroutineContext: CoroutineContext) {
this.coroutineContext = coroutineContext
}
public fun build(): Context { public fun build(): Context {
val contextName = name ?: NameToken("@auto",hashCode().toUInt().toString(16)).asName() val contextName = name ?: NameToken("@auto", hashCode().toUInt().toString(16)).asName()
val plugins = HashMap<PluginTag, Plugin>() val plugins = HashMap<PluginTag, Plugin>()
fun addPlugin(factory: PluginFactory<*>, meta: Meta) { fun addPlugin(factory: PluginFactory<*>, meta: Meta) {
@ -86,7 +95,7 @@ public class ContextBuilder internal constructor(
addPlugin(factory, meta) addPlugin(factory, meta)
} }
return Context(contextName, parent, plugins.values.toSet(), meta.seal()) return Context(contextName, parent, plugins.values.toSet(), meta.seal(), coroutineContext)
} }
} }

View File

@ -10,7 +10,7 @@ import space.kscience.dataforge.meta.*
import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.misc.DFExperimental
@DFExperimental @DFExperimental
public fun <T> ObservableMeta.asFlow(converter: MetaSpec<T>): Flow<T> = callbackFlow { public fun <T> ObservableMeta.asFlow(converter: MetaReader<T>): Flow<T> = callbackFlow {
onChange(this){ onChange(this){
trySend(converter.read(this)) trySend(converter.read(this))
} }

View File

@ -4,18 +4,12 @@ import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.decodeFromStream import kotlinx.serialization.json.decodeFromStream
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import space.kscience.dataforge.meta.Scheme
import space.kscience.dataforge.meta.SchemeSpec
import space.kscience.dataforge.meta.ValueType
import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.meta.descriptors.MetaDescriptorBuilder import space.kscience.dataforge.meta.descriptors.MetaDescriptorBuilder
import space.kscience.dataforge.meta.descriptors.node
import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.misc.DFExperimental
import java.net.URL import java.net.URL
import kotlin.reflect.KClass import kotlin.reflect.KAnnotatedElement
import kotlin.reflect.full.isSubclassOf import kotlin.reflect.KProperty
import kotlin.reflect.full.memberProperties
/** /**
* Description text for meta property, node or whole object * Description text for meta property, node or whole object
@ -59,18 +53,8 @@ private fun MetaDescriptorBuilder.loadDescriptorFromResource(resource: Descripto
} }
@DFExperimental @DFExperimental
public fun MetaDescriptor.Companion.forClass( public fun MetaDescriptorBuilder.forAnnotatedElement(element: KAnnotatedElement) {
kClass: KClass<out Any>, element.annotations.forEach {
mod: MetaDescriptorBuilder.() -> Unit = {},
): MetaDescriptor = MetaDescriptor {
when {
kClass.isSubclassOf(Number::class) -> valueType(ValueType.NUMBER)
kClass == String::class -> ValueType.STRING
kClass == Boolean::class -> ValueType.BOOLEAN
kClass == DoubleArray::class -> ValueType.LIST
}
kClass.annotations.forEach {
when (it) { when (it) {
is Description -> description = it.value is Description -> description = it.value
@ -79,47 +63,70 @@ public fun MetaDescriptor.Companion.forClass(
is DescriptorUrl -> loadDescriptorFromUrl(URL(it.url)) is DescriptorUrl -> loadDescriptorFromUrl(URL(it.url))
} }
} }
kClass.memberProperties.forEach { property ->
var flag = false
val descriptor = MetaDescriptor {
//use base type descriptor as a base
(property.returnType.classifier as? KClass<*>)?.let {
from(forClass(it))
}
property.annotations.forEach {
when (it) {
is Description -> {
description = it.value
flag = true
}
is Multiple -> {
multiple = true
flag = true
}
is DescriptorResource -> {
loadDescriptorFromResource(it)
flag = true
}
is DescriptorUrl -> {
loadDescriptorFromUrl(URL(it.url))
flag = true
}
}
}
}
if (flag) {
node(property.name, descriptor)
}
}
mod()
} }
@DFExperimental @DFExperimental
public inline fun <reified T : Scheme> SchemeSpec<T>.autoDescriptor(noinline mod: MetaDescriptorBuilder.() -> Unit = {}): MetaDescriptor = public fun MetaDescriptorBuilder.forProperty(property: KProperty<*>) {
MetaDescriptor.forClass(T::class, mod) property.annotations.forEach {
when (it) {
is Description -> description = it.value
is DescriptorResource -> loadDescriptorFromResource(it)
is DescriptorUrl -> loadDescriptorFromUrl(URL(it.url))
}
}
}
//
//@DFExperimental
//public fun <T : Scheme> MetaDescriptor.Companion.forScheme(
// spec: SchemeSpec<T>,
// mod: MetaDescriptorBuilder.() -> Unit = {},
//): MetaDescriptor = MetaDescriptor {
// val scheme = spec.empty()
// val kClass: KClass<T> = scheme::class as KClass<T>
// when {
// kClass.isSubclassOf(Number::class) -> valueType(ValueType.NUMBER)
// kClass == String::class -> ValueType.STRING
// kClass == Boolean::class -> ValueType.BOOLEAN
// kClass == DoubleArray::class -> ValueType.LIST
// kClass == ByteArray::class -> ValueType.LIST
// }
//
// forAnnotatedElement(kClass)
// kClass.memberProperties.forEach { property ->
// node(property.name) {
//
// (property.getDelegate(scheme) as? MetaDelegate<*>)?.descriptor?.let {
// from(it)
// }
//
// property.annotations.forEach {
// when (it) {
// is Description -> {
// description = it.value
// }
//
// is Multiple -> {
// multiple = true
// }
//
// is DescriptorResource -> {
// loadDescriptorFromResource(it)
// }
//
// is DescriptorUrl -> {
// loadDescriptorFromUrl(URL(it.url))
// }
// }
// }
// }
//
// }
// mod()
//}
//
//@DFExperimental
//public inline fun <reified T : Scheme> SchemeSpec<T>.autoDescriptor(
// noinline mod: MetaDescriptorBuilder.() -> Unit = {},
//): MetaDescriptor = MetaDescriptor.forScheme(this, mod)

View File

@ -2,35 +2,28 @@
package space.kscience.dataforge.descriptors package space.kscience.dataforge.descriptors
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.junit.jupiter.api.Test
import space.kscience.dataforge.meta.Scheme
import space.kscience.dataforge.meta.SchemeSpec
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.meta.int
import space.kscience.dataforge.meta.string
import space.kscience.dataforge.misc.DFExperimental import space.kscience.dataforge.misc.DFExperimental
private class TestScheme : Scheme() { //
//class TestScheme : Scheme() {
@Description("A") //
val a by string() // @Description("A")
// val a by string()
@Description("B") //
val b by int() // @Description("B")
// val b by int()
val c by int() //
// val c by int()
companion object : SchemeSpec<TestScheme>(::TestScheme) { //
override val descriptor: MetaDescriptor = autoDescriptor() // companion object : SchemeSpec<TestScheme>(::TestScheme) {
} // override val descriptor: MetaDescriptor = autoDescriptor()
} // }
//}
class TestAutoDescriptors { //
@Test //class TestAutoDescriptors {
fun autoDescriptor() { // @Test
val autoDescriptor = MetaDescriptor.forClass(TestScheme::class) // fun autoDescriptor() {
println(Json { prettyPrint = true }.encodeToString(autoDescriptor)) // val autoDescriptor = MetaDescriptor.forScheme(TestScheme)
} // println(Json { prettyPrint = true }.encodeToString(autoDescriptor))
} // }
//}

View File

@ -6,7 +6,7 @@
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-data:0.8.2`. The Maven coordinates of this project are `space.kscience:dataforge-data:0.9.0-dev-1`.
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
```kotlin ```kotlin
@ -16,6 +16,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:dataforge-data:0.8.2") implementation("space.kscience:dataforge-data:0.9.0-dev-1")
} }
``` ```

View File

@ -18,6 +18,24 @@ public data class NamedValueWithMeta<T>(val name: Name, val value: T, val meta:
public suspend fun <T> NamedData<T>.awaitWithMeta(): NamedValueWithMeta<T> = public suspend fun <T> NamedData<T>.awaitWithMeta(): NamedValueWithMeta<T> =
NamedValueWithMeta(name, await(), meta) NamedValueWithMeta(name, await(), meta)
/**
* Lazily transform this data to another data. By convention [block] should not use external data (be pure).
* @param type explicit type of the resulting [Data]
* @param coroutineContext additional [CoroutineContext] elements used for data computation.
* @param meta for the resulting data. By default equals input data.
* @param block the transformation itself
*/
@UnsafeKType
public fun <T, R> Data<T>.transform(
type: KType,
meta: Meta = this.meta,
coroutineContext: CoroutineContext = EmptyCoroutineContext,
block: suspend (T) -> R,
): Data<R> = Data(type, meta, coroutineContext, listOf(this)) {
block(await())
}
/** /**
* Lazily transform this data to another data. By convention [block] should not use external data (be pure). * Lazily transform this data to another data. By convention [block] should not use external data (be pure).

View File

@ -43,6 +43,7 @@ internal class ActionsTest {
repeat(10) { repeat(10) {
source.updateValue(it.toString(), it) source.updateValue(it.toString(), it)
} }
result.updates.take(10).onEach { println(it.name) }.collect() result.updates.take(10).onEach { println(it.name) }.collect()
assertEquals(2, result["1"]?.await()) assertEquals(2, result["1"]?.await())

View File

@ -6,7 +6,7 @@ IO module
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-io:0.8.2`. The Maven coordinates of this project are `space.kscience:dataforge-io:0.9.0-dev-1`.
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
```kotlin ```kotlin
@ -16,6 +16,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:dataforge-io:0.8.2") implementation("space.kscience:dataforge-io:0.9.0-dev-1")
} }
``` ```

View File

@ -6,7 +6,7 @@ YAML meta IO
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-io-yaml:0.8.2`. The Maven coordinates of this project are `space.kscience:dataforge-io-yaml:0.9.0-dev-1`.
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
```kotlin ```kotlin
@ -16,6 +16,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:dataforge-io-yaml:0.8.2") implementation("space.kscience:dataforge-io-yaml:0.9.0-dev-1")
} }
``` ```

View File

@ -6,7 +6,7 @@ Meta definition and basic operations on meta
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-meta:0.8.2`. The Maven coordinates of this project are `space.kscience:dataforge-meta:0.9.0-dev-1`.
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
```kotlin ```kotlin
@ -16,6 +16,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:dataforge-meta:0.8.2") implementation("space.kscience:dataforge-meta:0.9.0-dev-1")
} }
``` ```

View File

@ -103,6 +103,8 @@ public final class space/kscience/dataforge/meta/Laminate : space/kscience/dataf
public synthetic fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/TypedMeta; public synthetic fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/TypedMeta;
public fun getItems ()Ljava/util/Map; public fun getItems ()Ljava/util/Map;
public final fun getLayers ()Ljava/util/List; public final fun getLayers ()Ljava/util/List;
public fun getSelf ()Lspace/kscience/dataforge/meta/Laminate;
public synthetic fun getSelf ()Lspace/kscience/dataforge/meta/TypedMeta;
public fun getValue ()Lspace/kscience/dataforge/meta/Value; public fun getValue ()Lspace/kscience/dataforge/meta/Value;
public fun hashCode ()I public fun hashCode ()I
public final fun merge ()Lspace/kscience/dataforge/meta/SealedMeta; public final fun merge ()Lspace/kscience/dataforge/meta/SealedMeta;
@ -198,7 +200,7 @@ public final class space/kscience/dataforge/meta/MetaBuilder : space/kscience/da
public abstract interface annotation class space/kscience/dataforge/meta/MetaBuilderMarker : java/lang/annotation/Annotation { public abstract interface annotation class space/kscience/dataforge/meta/MetaBuilderMarker : java/lang/annotation/Annotation {
} }
public abstract interface class space/kscience/dataforge/meta/MetaConverter : space/kscience/dataforge/meta/MetaSpec { public abstract interface class space/kscience/dataforge/meta/MetaConverter : space/kscience/dataforge/meta/MetaReader {
public static final field Companion Lspace/kscience/dataforge/meta/MetaConverter$Companion; public static final field Companion Lspace/kscience/dataforge/meta/MetaConverter$Companion;
public abstract fun convert (Ljava/lang/Object;)Lspace/kscience/dataforge/meta/Meta; public abstract fun convert (Ljava/lang/Object;)Lspace/kscience/dataforge/meta/Meta;
public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; public fun getDescriptor ()Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;
@ -246,15 +248,15 @@ public final class space/kscience/dataforge/meta/MetaDelegateKt {
public static final fun int (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun int (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static synthetic fun int$default (Lspace/kscience/dataforge/meta/MetaProvider;ILspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate; public static synthetic fun int$default (Lspace/kscience/dataforge/meta/MetaProvider;ILspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static synthetic fun int$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate; public static synthetic fun int$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static final fun listOfSpec (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/meta/MetaSpec;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun listOfSpec (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/meta/MetaReader;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static synthetic fun listOfSpec$default (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/meta/MetaSpec;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate; public static synthetic fun listOfSpec$default (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/meta/MetaReader;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static final fun long (Lspace/kscience/dataforge/meta/MetaProvider;JLspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun long (Lspace/kscience/dataforge/meta/MetaProvider;JLspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static final fun long (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun long (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static synthetic fun long$default (Lspace/kscience/dataforge/meta/MetaProvider;JLspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate; public static synthetic fun long$default (Lspace/kscience/dataforge/meta/MetaProvider;JLspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static synthetic fun long$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate; public static synthetic fun long$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static final fun node (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/MetaSpec;)Lkotlin/properties/ReadOnlyProperty; public static final fun node (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/MetaReader;)Lkotlin/properties/ReadOnlyProperty;
public static final fun node (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun node (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static synthetic fun node$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/MetaSpec;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty; public static synthetic fun node$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/MetaReader;ILjava/lang/Object;)Lkotlin/properties/ReadOnlyProperty;
public static synthetic fun node$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate; public static synthetic fun node$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static final fun number (Lspace/kscience/dataforge/meta/MetaProvider;Ljava/lang/Number;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun number (Lspace/kscience/dataforge/meta/MetaProvider;Ljava/lang/Number;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static final fun number (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun number (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate;
@ -262,8 +264,8 @@ public final class space/kscience/dataforge/meta/MetaDelegateKt {
public static synthetic fun number$default (Lspace/kscience/dataforge/meta/MetaProvider;Ljava/lang/Number;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate; public static synthetic fun number$default (Lspace/kscience/dataforge/meta/MetaProvider;Ljava/lang/Number;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static synthetic fun number$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate; public static synthetic fun number$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static synthetic fun number$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate; public static synthetic fun number$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static final fun spec (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/meta/MetaSpec;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun spec (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/meta/MetaReader;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static synthetic fun spec$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/meta/MetaSpec;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate; public static synthetic fun spec$default (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/meta/MetaReader;Lspace/kscience/dataforge/names/Name;ILjava/lang/Object;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static final fun string (Lspace/kscience/dataforge/meta/MetaProvider;Ljava/lang/String;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun string (Lspace/kscience/dataforge/meta/MetaProvider;Ljava/lang/String;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static final fun string (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun string (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/MetaDelegate;
public static final fun string (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function0;)Lspace/kscience/dataforge/meta/MetaDelegate; public static final fun string (Lspace/kscience/dataforge/meta/MetaProvider;Lspace/kscience/dataforge/names/Name;Lkotlin/jvm/functions/Function0;)Lspace/kscience/dataforge/meta/MetaDelegate;
@ -294,7 +296,6 @@ public final class space/kscience/dataforge/meta/MetaKt {
public static final fun getLong (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Long; public static final fun getLong (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Long;
public static final synthetic fun getNonNullable (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/names/NameToken;)Lspace/kscience/dataforge/meta/Meta; public static final synthetic fun getNonNullable (Lspace/kscience/dataforge/meta/Meta;Lspace/kscience/dataforge/names/NameToken;)Lspace/kscience/dataforge/meta/Meta;
public static final fun getNumber (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Number; public static final fun getNumber (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Number;
public static final fun getSelf (Lspace/kscience/dataforge/meta/TypedMeta;)Lspace/kscience/dataforge/meta/TypedMeta;
public static final fun getShort (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Short; public static final fun getShort (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Short;
public static final fun getString (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/String; public static final fun getString (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/String;
public static final fun getStringList (Lspace/kscience/dataforge/meta/Meta;)Ljava/util/List; public static final fun getStringList (Lspace/kscience/dataforge/meta/Meta;)Ljava/util/List;
@ -311,6 +312,16 @@ public abstract interface class space/kscience/dataforge/meta/MetaProvider : spa
public fun getValue (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/Value; public fun getValue (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/Value;
} }
public abstract interface class space/kscience/dataforge/meta/MetaReader : space/kscience/dataforge/meta/descriptors/Described {
public fun read (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object;
public abstract fun readOrNull (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object;
}
public final class space/kscience/dataforge/meta/MetaReaderKt {
public static final fun readNullable (Lspace/kscience/dataforge/meta/MetaReader;Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object;
public static final fun readValue (Lspace/kscience/dataforge/meta/MetaReader;Lspace/kscience/dataforge/meta/Value;)Ljava/lang/Object;
}
public abstract interface class space/kscience/dataforge/meta/MetaRepr { public abstract interface class space/kscience/dataforge/meta/MetaRepr {
public abstract fun toMeta ()Lspace/kscience/dataforge/meta/Meta; public abstract fun toMeta ()Lspace/kscience/dataforge/meta/Meta;
} }
@ -324,16 +335,6 @@ public final class space/kscience/dataforge/meta/MetaSerializer : kotlinx/serial
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/dataforge/meta/Meta;)V public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/dataforge/meta/Meta;)V
} }
public abstract interface class space/kscience/dataforge/meta/MetaSpec : space/kscience/dataforge/meta/descriptors/Described {
public fun read (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object;
public abstract fun readOrNull (Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object;
}
public final class space/kscience/dataforge/meta/MetaSpecKt {
public static final fun readNullable (Lspace/kscience/dataforge/meta/MetaSpec;Lspace/kscience/dataforge/meta/Meta;)Ljava/lang/Object;
public static final fun readValue (Lspace/kscience/dataforge/meta/MetaSpec;Lspace/kscience/dataforge/meta/Value;)Ljava/lang/Object;
}
public final class space/kscience/dataforge/meta/MetaTransformation { public final class space/kscience/dataforge/meta/MetaTransformation {
public static final field Companion Lspace/kscience/dataforge/meta/MetaTransformation$Companion; public static final field Companion Lspace/kscience/dataforge/meta/MetaTransformation$Companion;
public static final fun apply-impl (Ljava/util/Collection;Lspace/kscience/dataforge/meta/Meta;)Lspace/kscience/dataforge/meta/Meta; public static final fun apply-impl (Ljava/util/Collection;Lspace/kscience/dataforge/meta/Meta;)Lspace/kscience/dataforge/meta/Meta;
@ -551,6 +552,8 @@ public abstract interface class space/kscience/dataforge/meta/ObservableMutableM
public fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/ObservableMutableMeta; public fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/ObservableMutableMeta;
public synthetic fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/TypedMeta; public synthetic fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/TypedMeta;
public abstract fun getOrCreate (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/ObservableMutableMeta; public abstract fun getOrCreate (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/ObservableMutableMeta;
public fun getSelf ()Lspace/kscience/dataforge/meta/ObservableMutableMeta;
public synthetic fun getSelf ()Lspace/kscience/dataforge/meta/TypedMeta;
} }
public final class space/kscience/dataforge/meta/RegexItemTransformationRule : space/kscience/dataforge/meta/TransformationRule { public final class space/kscience/dataforge/meta/RegexItemTransformationRule : space/kscience/dataforge/meta/TransformationRule {
@ -624,19 +627,21 @@ public final class space/kscience/dataforge/meta/SealedMeta : space/kscience/dat
public fun <init> (Lspace/kscience/dataforge/meta/Value;Ljava/util/Map;)V public fun <init> (Lspace/kscience/dataforge/meta/Value;Ljava/util/Map;)V
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public fun getItems ()Ljava/util/Map; public fun getItems ()Ljava/util/Map;
public fun getSelf ()Lspace/kscience/dataforge/meta/SealedMeta;
public synthetic fun getSelf ()Lspace/kscience/dataforge/meta/TypedMeta;
public fun getValue ()Lspace/kscience/dataforge/meta/Value; public fun getValue ()Lspace/kscience/dataforge/meta/Value;
public fun hashCode ()I public fun hashCode ()I
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
} }
public final class space/kscience/dataforge/meta/SealedMeta$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public synthetic class space/kscience/dataforge/meta/SealedMeta$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lspace/kscience/dataforge/meta/SealedMeta$$serializer; public static final field INSTANCE Lspace/kscience/dataforge/meta/SealedMeta$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/dataforge/meta/SealedMeta; public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/dataforge/meta/SealedMeta;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/dataforge/meta/SealedMeta;)V public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/dataforge/meta/SealedMeta;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
} }
@ -710,6 +715,7 @@ public abstract interface class space/kscience/dataforge/meta/TypedMeta : space/
public synthetic fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/Meta; public synthetic fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/Meta;
public fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/TypedMeta; public fun get (Lspace/kscience/dataforge/names/Name;)Lspace/kscience/dataforge/meta/TypedMeta;
public abstract fun getItems ()Ljava/util/Map; public abstract fun getItems ()Ljava/util/Map;
public abstract fun getSelf ()Lspace/kscience/dataforge/meta/TypedMeta;
public fun toMeta ()Lspace/kscience/dataforge/meta/Meta; public fun toMeta ()Lspace/kscience/dataforge/meta/Meta;
} }
@ -844,14 +850,14 @@ public final class space/kscience/dataforge/meta/descriptors/MetaDescriptor {
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
} }
public final class space/kscience/dataforge/meta/descriptors/MetaDescriptor$$serializer : kotlinx/serialization/internal/GeneratedSerializer { public synthetic class space/kscience/dataforge/meta/descriptors/MetaDescriptor$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
public static final field INSTANCE Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor$$serializer; public static final field INSTANCE Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor$$serializer;
public fun childSerializers ()[Lkotlinx/serialization/KSerializer; public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor; public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)V public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)V
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
} }
@ -876,6 +882,7 @@ public final class space/kscience/dataforge/meta/descriptors/MetaDescriptorBuild
public final fun getMultiple ()Z public final fun getMultiple ()Z
public final fun getValueRestriction ()Lspace/kscience/dataforge/meta/descriptors/ValueRestriction; public final fun getValueRestriction ()Lspace/kscience/dataforge/meta/descriptors/ValueRestriction;
public final fun getValueTypes ()Ljava/util/List; public final fun getValueTypes ()Ljava/util/List;
public final fun node (Lspace/kscience/dataforge/names/Name;Lspace/kscience/dataforge/meta/descriptors/MetaDescriptor;)V
public final fun setAllowedValues (Ljava/util/List;)V public final fun setAllowedValues (Ljava/util/List;)V
public final fun setAttributes (Lspace/kscience/dataforge/meta/MutableMeta;)V public final fun setAttributes (Lspace/kscience/dataforge/meta/MutableMeta;)V
public final fun setChildren (Ljava/util/Map;)V public final fun setChildren (Ljava/util/Map;)V
@ -927,10 +934,6 @@ public final class space/kscience/dataforge/meta/descriptors/ValueRestriction$Co
public final fun serializer ()Lkotlinx/serialization/KSerializer; public final fun serializer ()Lkotlinx/serialization/KSerializer;
} }
public final class space/kscience/dataforge/misc/CastJvmKt {
public static final fun unsafeCast (Ljava/lang/Object;)Ljava/lang/Object;
}
public abstract interface annotation class space/kscience/dataforge/misc/DFBuilder : java/lang/annotation/Annotation { public abstract interface annotation class space/kscience/dataforge/misc/DFBuilder : java/lang/annotation/Annotation {
} }

View File

@ -9,6 +9,8 @@ import space.kscience.dataforge.names.NameToken
*/ */
public class Laminate internal constructor(public val layers: List<Meta>) : TypedMeta<Laminate> { public class Laminate internal constructor(public val layers: List<Meta>) : TypedMeta<Laminate> {
override val self: Laminate get() = this
override val value: Value? = layers.firstNotNullOfOrNull { it.value } override val value: Value? = layers.firstNotNullOfOrNull { it.value }
override val items: Map<NameToken, Laminate> by lazy { override val items: Map<NameToken, Laminate> by lazy {

View File

@ -3,7 +3,6 @@ package space.kscience.dataforge.meta
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import space.kscience.dataforge.misc.DfType import space.kscience.dataforge.misc.DfType
import space.kscience.dataforge.misc.unsafeCast
import space.kscience.dataforge.names.* import space.kscience.dataforge.names.*
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
@ -151,6 +150,8 @@ public interface TypedMeta<out M : TypedMeta<M>> : Meta {
override val items: Map<NameToken, M> override val items: Map<NameToken, M>
public val self: M
override fun get(name: Name): M? { override fun get(name: Name): M? {
tailrec fun M.find(name: Name): M? = if (name.isEmpty()) { tailrec fun M.find(name: Name): M? = if (name.isEmpty()) {
this this
@ -164,11 +165,6 @@ public interface TypedMeta<out M : TypedMeta<M>> : Meta {
override fun toMeta(): Meta = this override fun toMeta(): Meta = this
} }
/**
* Access self as a recursive type instance
*/
public inline val <M : TypedMeta<M>> TypedMeta<M>.self: M get() = unsafeCast()
//public typealias Meta = TypedMeta<*> //public typealias Meta = TypedMeta<*>
public operator fun <M : TypedMeta<M>> TypedMeta<M>?.get(token: NameToken): M? = this?.items?.get(token) public operator fun <M : TypedMeta<M>> TypedMeta<M>?.get(token: NameToken): M? = this?.items?.get(token)

View File

@ -11,7 +11,7 @@ import space.kscience.dataforge.misc.DFExperimental
/** /**
* A converter of generic object to and from [Meta] * A converter of generic object to and from [Meta]
*/ */
public interface MetaConverter<T>: MetaSpec<T> { public interface MetaConverter<T>: MetaReader<T> {
/** /**
* A descriptor for resulting meta * A descriptor for resulting meta

View File

@ -25,16 +25,16 @@ public fun MetaProvider.node(
} }
/** /**
* Use [metaSpec] to read the Meta node * Use [metaReader] to read the Meta node
*/ */
public fun <T> MetaProvider.spec( public fun <T> MetaProvider.spec(
metaSpec: MetaSpec<T>, metaReader: MetaReader<T>,
key: Name? = null, key: Name? = null,
): MetaDelegate<T?> = object : MetaDelegate<T?> { ): MetaDelegate<T?> = object : MetaDelegate<T?> {
override val descriptor: MetaDescriptor? get() = metaSpec.descriptor override val descriptor: MetaDescriptor? get() = metaReader.descriptor
override fun getValue(thisRef: Any?, property: KProperty<*>): T? { override fun getValue(thisRef: Any?, property: KProperty<*>): T? {
return get(key ?: property.name.asName())?.let { metaSpec.read(it) } return get(key ?: property.name.asName())?.let { metaReader.read(it) }
} }
} }
@ -50,14 +50,14 @@ public inline fun <reified T> MetaProvider.serializable(
@Deprecated("Use convertable", ReplaceWith("convertable(converter, key)")) @Deprecated("Use convertable", ReplaceWith("convertable(converter, key)"))
public fun <T> MetaProvider.node( public fun <T> MetaProvider.node(
key: Name? = null, key: Name? = null,
converter: MetaSpec<T>, converter: MetaReader<T>,
): ReadOnlyProperty<Any?, T?> = spec(converter, key) ): ReadOnlyProperty<Any?, T?> = spec(converter, key)
/** /**
* Use [converter] to convert a list of same name siblings meta to object * Use [converter] to convert a list of same name siblings meta to object
*/ */
public fun <T> Meta.listOfSpec( public fun <T> Meta.listOfSpec(
converter: MetaSpec<T>, converter: MetaReader<T>,
key: Name? = null, key: Name? = null,
): MetaDelegate<List<T>> = object : MetaDelegate<List<T>> { ): MetaDelegate<List<T>> = object : MetaDelegate<List<T>> {
override fun getValue(thisRef: Any?, property: KProperty<*>): List<T> { override fun getValue(thisRef: Any?, property: KProperty<*>): List<T> {

View File

@ -2,7 +2,7 @@ package space.kscience.dataforge.meta
import space.kscience.dataforge.meta.descriptors.Described import space.kscience.dataforge.meta.descriptors.Described
public interface MetaSpec<out T> : Described { public interface MetaReader<out T> : Described {
/** /**
* Read the source meta into an object and return null if Meta could not be interpreted as a target type * Read the source meta into an object and return null if Meta could not be interpreted as a target type
@ -10,12 +10,12 @@ public interface MetaSpec<out T> : Described {
public fun readOrNull(source: Meta): T? public fun readOrNull(source: Meta): T?
/** /**
* Read generic read-only meta with this [MetaSpec] producing instance of the desired type. * Read generic read-only meta with this [MetaReader] producing instance of the desired type.
* Throws an error if conversion could not be done. * Throws an error if conversion could not be done.
*/ */
public fun read(source: Meta): T = readOrNull(source) ?: error("Meta $source could not be interpreted by $this") public fun read(source: Meta): T = readOrNull(source) ?: error("Meta $source could not be interpreted by $this")
} }
public fun <T : Any> MetaSpec<T>.readNullable(item: Meta?): T? = item?.let { read(it) } public fun <T : Any> MetaReader<T>.readNullable(item: Meta?): T? = item?.let { read(it) }
public fun <T> MetaSpec<T>.readValue(value: Value): T? = read(Meta(value)) public fun <T> MetaReader<T>.readValue(value: Value): T? = read(Meta(value))

View File

@ -0,0 +1,64 @@
package space.kscience.dataforge.meta
import space.kscience.dataforge.meta.descriptors.Described
import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.meta.descriptors.MetaDescriptorBuilder
import space.kscience.dataforge.misc.DFExperimental
import space.kscience.dataforge.names.Name
import space.kscience.dataforge.names.asName
import kotlin.properties.PropertyDelegateProvider
import kotlin.properties.ReadOnlyProperty
/**
* A reference to a read-only value of type [T] inside [MetaProvider]
*/
@DFExperimental
public data class MetaRef<T>(
public val name: Name,
public val converter: MetaConverter<T>,
override val descriptor: MetaDescriptor? = converter.descriptor,
) : Described
@DFExperimental
public operator fun <T> MetaProvider.get(ref: MetaRef<T>): T? = get(ref.name)?.let { ref.converter.readOrNull(it) }
@DFExperimental
public operator fun <T> MutableMetaProvider.set(ref: MetaRef<T>, value: T) {
set(ref.name, ref.converter.convert(value))
}
@DFExperimental
public class MetaSpec(
private val configuration: MetaDescriptorBuilder.() -> Unit = {},
) : Described {
private val refs: MutableList<MetaRef<*>> = mutableListOf()
private fun registerRef(ref: MetaRef<*>) {
refs.add(ref)
}
public fun <T> item(
converter: MetaConverter<T>,
descriptor: MetaDescriptor? = converter.descriptor,
key: Name? = null,
): PropertyDelegateProvider<MetaSpec, ReadOnlyProperty<MetaSpec, MetaRef<T>>> =
PropertyDelegateProvider { _, property ->
val ref = MetaRef(key ?: property.name.asName(), converter, descriptor)
registerRef(ref)
ReadOnlyProperty { _, _ ->
ref
}
}
override val descriptor: MetaDescriptor by lazy {
MetaDescriptor {
refs.forEach { ref ->
ref.descriptor?.let {
node(ref.name, ref.descriptor)
}
}
configuration()
}
}
}

View File

@ -253,6 +253,9 @@ private class MutableMetaImpl(
value: Value?, value: Value?,
children: Map<NameToken, Meta> = emptyMap(), children: Map<NameToken, Meta> = emptyMap(),
) : AbstractObservableMeta(), ObservableMutableMeta { ) : AbstractObservableMeta(), ObservableMutableMeta {
override val self get() = this
override var value = value override var value = value
@ThreadSafe set(value) { @ThreadSafe set(value) {
val oldValue = field val oldValue = field

View File

@ -39,6 +39,9 @@ public interface ObservableMeta : Meta {
* A [Meta] which is both observable and mutable * A [Meta] which is both observable and mutable
*/ */
public interface ObservableMutableMeta : ObservableMeta, MutableMeta, MutableTypedMeta<ObservableMutableMeta> { public interface ObservableMutableMeta : ObservableMeta, MutableMeta, MutableTypedMeta<ObservableMutableMeta> {
override val self: ObservableMutableMeta get() = this
override fun getOrCreate(name: Name): ObservableMutableMeta override fun getOrCreate(name: Name): ObservableMutableMeta
override fun get(name: Name): ObservableMutableMeta? { override fun get(name: Name): ObservableMutableMeta? {

View File

@ -14,6 +14,9 @@ private class ObservableMetaWrapper(
val nodeName: Name, val nodeName: Name,
val listeners: MutableSet<MetaListener>, val listeners: MutableSet<MetaListener>,
) : ObservableMutableMeta { ) : ObservableMutableMeta {
override val self get() = this
override val items: Map<NameToken, ObservableMutableMeta> override val items: Map<NameToken, ObservableMutableMeta>
get() = root[nodeName]?.items?.keys?.associateWith { get() = root[nodeName]?.items?.keys?.associateWith {
ObservableMetaWrapper(root, nodeName + it, listeners) ObservableMetaWrapper(root, nodeName + it, listeners)

View File

@ -12,7 +12,7 @@ import kotlin.reflect.KProperty
import kotlin.reflect.KProperty1 import kotlin.reflect.KProperty1
/** /**
* A base for delegate-based or descriptor-based scheme. [Scheme] has an empty constructor to simplify usage from [MetaSpec]. * A base for delegate-based or descriptor-based scheme. [Scheme] has an empty constructor to simplify usage from [MetaReader].
* *
* @param prototype default values provided by this scheme * @param prototype default values provided by this scheme
*/ */
@ -80,6 +80,9 @@ public open class Scheme(
override fun toString(): String = meta.toString() override fun toString(): String = meta.toString()
private inner class SchemeMeta(val pathName: Name) : ObservableMutableMeta { private inner class SchemeMeta(val pathName: Name) : ObservableMutableMeta {
override val self get() = this
override var value: Value? override var value: Value?
get() = target[pathName]?.value get() = target[pathName]?.value
?: prototype?.get(pathName)?.value ?: prototype?.get(pathName)?.value
@ -216,7 +219,7 @@ public fun <T : Scheme> Configurable.updateWith(
/** /**
* A delegate that uses a [MetaSpec] to wrap a child of this provider * A delegate that uses a [MetaReader] to wrap a child of this provider
*/ */
public fun <T : Scheme> MutableMeta.scheme( public fun <T : Scheme> MutableMeta.scheme(
spec: SchemeSpec<T>, spec: SchemeSpec<T>,
@ -239,7 +242,7 @@ public fun <T : Scheme> Scheme.scheme(
): ReadWriteProperty<Any?, T> = meta.scheme(spec, key) ): ReadWriteProperty<Any?, T> = meta.scheme(spec, key)
/** /**
* A delegate that uses a [MetaSpec] to wrap a child of this provider. * A delegate that uses a [MetaReader] to wrap a child of this provider.
* Returns null if meta with given name does not exist. * Returns null if meta with given name does not exist.
*/ */
public fun <T : Scheme> MutableMeta.schemeOrNull( public fun <T : Scheme> MutableMeta.schemeOrNull(
@ -264,7 +267,7 @@ public fun <T : Scheme> Scheme.schemeOrNull(
): ReadWriteProperty<Any?, T?> = meta.schemeOrNull(spec, key) ): ReadWriteProperty<Any?, T?> = meta.schemeOrNull(spec, key)
/** /**
* A delegate that uses a [MetaSpec] to wrap a list of child providers. * A delegate that uses a [MetaReader] to wrap a list of child providers.
* If children are mutable, the changes in list elements are reflected on them. * If children are mutable, the changes in list elements are reflected on them.
* The list is a snapshot of children state, so change in structure is not reflected on its composition. * The list is a snapshot of children state, so change in structure is not reflected on its composition.
*/ */

View File

@ -13,6 +13,9 @@ public class SealedMeta(
override val value: Value?, override val value: Value?,
override val items: Map<NameToken, SealedMeta>, override val items: Map<NameToken, SealedMeta>,
) : TypedMeta<SealedMeta> { ) : TypedMeta<SealedMeta> {
override val self: SealedMeta get() = this
override fun toString(): String = Meta.toString(this) override fun toString(): String = Meta.toString(this)
override fun equals(other: Any?): Boolean = Meta.equals(this, other as? Meta) override fun equals(other: Any?): Boolean = Meta.equals(this, other as? Meta)

View File

@ -58,7 +58,7 @@ public class MetaDescriptorBuilder @PublishedApi internal constructor() {
} }
} }
internal fun node( public fun node(
name: Name, name: Name,
descriptorBuilder: MetaDescriptor, descriptorBuilder: MetaDescriptor,
): Unit { ): Unit {

View File

@ -1,3 +0,0 @@
package space.kscience.dataforge.misc
public expect inline fun <T> Any?.unsafeCast(): T

View File

@ -58,7 +58,7 @@ public class Name(public val tokens: List<NameToken>) {
*/ */
public fun parse(string: String): Name { public fun parse(string: String): Name {
if (string.isBlank()) return EMPTY if (string.isBlank()) return EMPTY
val tokens = sequence { val tokens = buildList<NameToken> {
var bodyBuilder = StringBuilder() var bodyBuilder = StringBuilder()
var queryBuilder = StringBuilder() var queryBuilder = StringBuilder()
var bracketCount = 0 var bracketCount = 0
@ -91,7 +91,7 @@ public class Name(public val tokens: List<NameToken>) {
else -> when (it) { else -> when (it) {
'.' -> { '.' -> {
val query = if (queryBuilder.isEmpty()) null else queryBuilder.toString() val query = if (queryBuilder.isEmpty()) null else queryBuilder.toString()
yield(NameToken(bodyBuilder.toString(), query)) add(NameToken(bodyBuilder.toString(), query))
bodyBuilder = StringBuilder() bodyBuilder = StringBuilder()
queryBuilder = StringBuilder() queryBuilder = StringBuilder()
} }
@ -106,9 +106,9 @@ public class Name(public val tokens: List<NameToken>) {
} }
} }
val query = if (queryBuilder.isEmpty()) null else queryBuilder.toString() val query = if (queryBuilder.isEmpty()) null else queryBuilder.toString()
yield(NameToken(bodyBuilder.toString(), query)) add(NameToken(bodyBuilder.toString(), query))
} }
return Name(tokens.toList()) return Name(tokens)
} }
} }
} }

View File

@ -31,6 +31,9 @@ public fun Meta.toDynamic(): dynamic {
} }
public class DynamicMeta(internal val obj: dynamic) : TypedMeta<DynamicMeta> { public class DynamicMeta(internal val obj: dynamic) : TypedMeta<DynamicMeta> {
override val self: DynamicMeta get() = this
private fun keys(): Array<String> = js("Object").keys(obj) as Array<String> private fun keys(): Array<String> = js("Object").keys(obj) as Array<String>
private fun isArray(obj: dynamic): Boolean = private fun isArray(obj: dynamic): Boolean =

View File

@ -1,5 +0,0 @@
package space.kscience.dataforge.misc
import kotlin.js.unsafeCast as unsafeCastJs
@Suppress("NOTHING_TO_INLINE")
public actual inline fun <T> Any?.unsafeCast(): T = unsafeCastJs<T>()

View File

@ -1,4 +0,0 @@
package space.kscience.dataforge.misc
@Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE")
public actual inline fun <T> Any?.unsafeCast(): T = this as T

View File

@ -1,4 +0,0 @@
package space.kscience.dataforge.misc
@Suppress("UNCHECKED_CAST")
public actual inline fun <T> Any?.unsafeCast(): T = this as T

View File

@ -1,4 +0,0 @@
package space.kscience.dataforge.misc
@Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE")
public actual inline fun <T> Any?.unsafeCast(): T = this as T

View File

@ -6,7 +6,7 @@
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-scripting:0.8.2`. The Maven coordinates of this project are `space.kscience:dataforge-scripting:0.9.0-dev-1`.
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
```kotlin ```kotlin
@ -16,6 +16,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:dataforge-scripting:0.8.2") implementation("space.kscience:dataforge-scripting:0.9.0-dev-1")
} }
``` ```

View File

@ -6,7 +6,7 @@
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:dataforge-workspace:0.8.2`. The Maven coordinates of this project are `space.kscience:dataforge-workspace:0.9.0-dev-1`.
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
```kotlin ```kotlin
@ -16,6 +16,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:dataforge-workspace:0.8.2") implementation("space.kscience:dataforge-workspace:0.9.0-dev-1")
} }
``` ```

View File

@ -5,8 +5,8 @@ import space.kscience.dataforge.data.DataSink
import space.kscience.dataforge.data.GoalExecutionRestriction import space.kscience.dataforge.data.GoalExecutionRestriction
import space.kscience.dataforge.data.MutableDataTree import space.kscience.dataforge.data.MutableDataTree
import space.kscience.dataforge.meta.Meta import space.kscience.dataforge.meta.Meta
import space.kscience.dataforge.meta.MetaReader
import space.kscience.dataforge.meta.MetaRepr import space.kscience.dataforge.meta.MetaRepr
import space.kscience.dataforge.meta.MetaSpec
import space.kscience.dataforge.meta.descriptors.Described import space.kscience.dataforge.meta.descriptors.Described
import space.kscience.dataforge.meta.descriptors.MetaDescriptor import space.kscience.dataforge.meta.descriptors.MetaDescriptor
import space.kscience.dataforge.misc.DfType import space.kscience.dataforge.misc.DfType
@ -44,10 +44,10 @@ public interface Task<T> : Described {
} }
/** /**
* A [Task] with [MetaSpec] for wrapping and unwrapping task configuration * A [Task] with [MetaReader] for wrapping and unwrapping task configuration
*/ */
public interface TaskWithSpec<T, C : Any> : Task<T> { public interface TaskWithSpec<T, C : Any> : Task<T> {
public val spec: MetaSpec<C> public val spec: MetaReader<C>
override val descriptor: MetaDescriptor? get() = spec.descriptor override val descriptor: MetaDescriptor? get() = spec.descriptor
public suspend fun execute(workspace: Workspace, taskName: Name, configuration: C): TaskResult<T> public suspend fun execute(workspace: Workspace, taskName: Name, configuration: C): TaskResult<T>
@ -122,10 +122,10 @@ public inline fun <reified T : Any> Task(
@Suppress("FunctionName") @Suppress("FunctionName")
public fun <T : Any, C : MetaRepr> Task( public fun <T : Any, C : MetaRepr> Task(
resultType: KType, resultType: KType,
specification: MetaSpec<C>, specification: MetaReader<C>,
builder: suspend TaskResultBuilder<T>.(C) -> Unit, builder: suspend TaskResultBuilder<T>.(C) -> Unit,
): TaskWithSpec<T, C> = object : TaskWithSpec<T, C> { ): TaskWithSpec<T, C> = object : TaskWithSpec<T, C> {
override val spec: MetaSpec<C> = specification override val spec: MetaReader<C> = specification
override suspend fun execute( override suspend fun execute(
workspace: Workspace, workspace: Workspace,
@ -143,6 +143,6 @@ public fun <T : Any, C : MetaRepr> Task(
} }
public inline fun <reified T : Any, C : MetaRepr> Task( public inline fun <reified T : Any, C : MetaRepr> Task(
specification: MetaSpec<C>, specification: MetaReader<C>,
noinline builder: suspend TaskResultBuilder<T>.(C) -> Unit, noinline builder: suspend TaskResultBuilder<T>.(C) -> Unit,
): Task<T> = Task(typeOf<T>(), specification, builder) ): Task<T> = Task(typeOf<T>(), specification, builder)

View File

@ -71,10 +71,10 @@ public inline fun <reified T : Any> TaskContainer.task(
} }
/** /**
* Create a task based on [MetaSpec] * Create a task based on [MetaReader]
*/ */
public inline fun <reified T : Any, C : MetaRepr> TaskContainer.task( public inline fun <reified T : Any, C : MetaRepr> TaskContainer.task(
specification: MetaSpec<C>, specification: MetaReader<C>,
noinline builder: suspend TaskResultBuilder<T>.(C) -> Unit, noinline builder: suspend TaskResultBuilder<T>.(C) -> Unit,
): PropertyDelegateProvider<Any?, ReadOnlyProperty<Any?, TaskReference<T>>> = PropertyDelegateProvider { _, property -> ): PropertyDelegateProvider<Any?, ReadOnlyProperty<Any?, TaskReference<T>>> = PropertyDelegateProvider { _, property ->
val taskName = Name.parse(property.name) val taskName = Name.parse(property.name)

View File

@ -1,10 +1,9 @@
kotlin.code.style=official
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.jvmargs=-Xmx4096m org.gradle.jvmargs=-Xmx4096m
kotlin.code.style=official
kotlin.mpp.stability.nowarn=true kotlin.mpp.stability.nowarn=true
kotlin.incremental.js.ir=true
kotlin.native.ignoreDisabledTargets=true kotlin.native.ignoreDisabledTargets=true
toolsVersion=0.15.2-kotlin-1.9.21 toolsVersion=0.15.4-kotlin-2.0.0
#kotlin.experimental.tryK2=true