diff --git a/.gitignore b/.gitignore index 89cc712a..17a319a4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ out/ build/ -!gradle-wrapper.jar -gradle.properties \ No newline at end of file +!gradle-wrapper.jar \ No newline at end of file diff --git a/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Context.kt b/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Context.kt index 640c7b5a..b675a42b 100644 --- a/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Context.kt +++ b/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Context.kt @@ -47,7 +47,7 @@ public open class Context( /** * A [PluginManager] for current context */ - public val plugins: PluginManager by lazy { PluginManager(this) } + public val plugins: PluginManager = PluginManager(this) @Deprecated("To be removed in favor of immutable plugins") private val activators = HashSet() @@ -92,7 +92,7 @@ public open class Context( } } - override fun content(target: String): Map = content(target,true) + override fun content(target: String): Map = content(target, true) override val coroutineContext: CoroutineContext by lazy { (parent ?: Global).coroutineContext.let { parenContext -> diff --git a/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Global.kt b/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Global.kt index 4666fb78..0193ca4b 100644 --- a/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Global.kt +++ b/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Global.kt @@ -5,10 +5,12 @@ import hep.dataforge.names.asName import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.SupervisorJob import kotlin.coroutines.CoroutineContext +import kotlin.native.concurrent.ThreadLocal /** * A global root context. Closing [Global] terminates the framework. */ +@ThreadLocal public object Global : Context("GLOBAL".asName(), null, Meta.EMPTY) { override val coroutineContext: CoroutineContext = GlobalScope.coroutineContext + SupervisorJob() @@ -39,6 +41,8 @@ public object Global : Context("GLOBAL".asName(), null, Meta.EMPTY) { } public fun context(name: String, parent: Context = this, block: ContextBuilder.() -> Unit = {}): Context = - ContextBuilder(parent, name).apply(block).build() + ContextBuilder(parent, name).apply(block).build().also { + contextRegistry[name] = it + } } \ No newline at end of file diff --git a/dataforge-context/src/commonTest/kotlin/hep/dataforge/context/ContextTest.kt b/dataforge-context/src/commonTest/kotlin/hep/dataforge/context/ContextTest.kt index ef3d1254..58647400 100644 --- a/dataforge-context/src/commonTest/kotlin/hep/dataforge/context/ContextTest.kt +++ b/dataforge-context/src/commonTest/kotlin/hep/dataforge/context/ContextTest.kt @@ -21,8 +21,11 @@ class ContextTest { @Test fun testPluginManager() { - Global.plugins.load(DummyPlugin()) - val members = Global.gather("test") + val context = Global.context("test"){ + plugin(DummyPlugin()) + } + //Global.plugins.load(DummyPlugin()) + val members = context.gather("test") assertEquals(3, members.count()) members.forEach { assertEquals(it.key, it.value.appendLeft("test")) diff --git a/dataforge-data/build.gradle.kts b/dataforge-data/build.gradle.kts index 587f7492..b75b0a6d 100644 --- a/dataforge-data/build.gradle.kts +++ b/dataforge-data/build.gradle.kts @@ -1,7 +1,7 @@ plugins { id("ru.mipt.npm.mpp") id("ru.mipt.npm.node") -// id("ru.mipt.npm.native") + id("ru.mipt.npm.native") } kscience{ diff --git a/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/DataFilter.kt b/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/DataFilter.kt index 79f790ab..51e58ac6 100644 --- a/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/DataFilter.kt +++ b/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/DataFilter.kt @@ -28,7 +28,7 @@ public class DataFilter : Scheme() { /** * Apply meta-based filter to given data node */ -fun DataNode.filter(filter: DataFilter): DataNode { +public fun DataNode.filter(filter: DataFilter): DataNode { val sourceNode = filter.from?.let { get(it.toName()).node } ?: this@filter val regex = filter.pattern.toRegex() val targetNode = DataTreeBuilder(type).apply { @@ -46,10 +46,10 @@ fun DataNode.filter(filter: DataFilter): DataNode { /** * Filter data using [DataFilter] specification */ -fun DataNode.filter(filter: Meta): DataNode = filter(DataFilter.wrap(filter)) +public fun DataNode.filter(filter: Meta): DataNode = filter(DataFilter.wrap(filter)) /** * Filter data using [DataFilter] builder */ -fun DataNode.filter(filterBuilder: DataFilter.() -> Unit): DataNode = +public fun DataNode.filter(filterBuilder: DataFilter.() -> Unit): DataNode = filter(DataFilter(filterBuilder)) \ No newline at end of file diff --git a/dataforge-data/src/jsMain/kotlin/hep/dataforge/data/dataJS.kt b/dataforge-data/src/jsMain/kotlin/hep/dataforge/data/dataJS.kt index afdb032e..0257b85a 100644 --- a/dataforge-data/src/jsMain/kotlin/hep/dataforge/data/dataJS.kt +++ b/dataforge-data/src/jsMain/kotlin/hep/dataforge/data/dataJS.kt @@ -6,11 +6,9 @@ import kotlin.reflect.KClass * Check that node is compatible with given type meaning that each element could be cast to the type */ internal actual fun DataNode<*>.canCast(type: KClass): Boolean { - //Not supported in js yet - return true + return this.type == type } internal actual fun Data<*>.canCast(type: KClass): Boolean { - //Not supported in js yet - return true + return this.type == type } diff --git a/dataforge-data/src/nativeMain/kotlin/hep/dataforge/data/dataNative.kt b/dataforge-data/src/nativeMain/kotlin/hep/dataforge/data/dataNative.kt new file mode 100644 index 00000000..fe770f88 --- /dev/null +++ b/dataforge-data/src/nativeMain/kotlin/hep/dataforge/data/dataNative.kt @@ -0,0 +1,14 @@ +package hep.dataforge.data + +import kotlin.reflect.KClass + +/** + * Check that node is compatible with given type meaning that each element could be cast to the type + */ +internal actual fun DataNode<*>.canCast(type: KClass): Boolean { + return this.type == type +} + +internal actual fun Data<*>.canCast(type: KClass): Boolean { + return this.type == type +} \ No newline at end of file diff --git a/dataforge-io/build.gradle.kts b/dataforge-io/build.gradle.kts index 6525a243..f68129af 100644 --- a/dataforge-io/build.gradle.kts +++ b/dataforge-io/build.gradle.kts @@ -1,7 +1,7 @@ plugins { id("ru.mipt.npm.mpp") id("ru.mipt.npm.node") -// id("ru.mipt.npm.native") + id("ru.mipt.npm.native") } description = "IO module" @@ -12,7 +12,7 @@ kscience { } } -val ioVersion by rootProject.extra("0.2.0-npm-dev-10") +val ioVersion by rootProject.extra("0.2.0-npm-dev-11") kotlin { sourceSets { diff --git a/dataforge-io/src/commonTest/kotlin/hep/dataforge/io/MetaSerializerTest.kt b/dataforge-io/src/commonTest/kotlin/hep/dataforge/io/MetaSerializerTest.kt index 64fd3d02..11177e71 100644 --- a/dataforge-io/src/commonTest/kotlin/hep/dataforge/io/MetaSerializerTest.kt +++ b/dataforge-io/src/commonTest/kotlin/hep/dataforge/io/MetaSerializerTest.kt @@ -48,8 +48,10 @@ class MetaSerializerTest { assertEquals(name, restored) } + @OptIn(ExperimentalSerializationApi::class) @Test fun testMetaItemDescriptor() { val descriptor = MetaItem.serializer(MetaSerializer).descriptor.getElementDescriptor(0) + println(descriptor) } } \ No newline at end of file diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/transformations/MetaTransformation.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/transformations/MetaTransformation.kt index 2c09faa5..9529b28e 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/transformations/MetaTransformation.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/transformations/MetaTransformation.kt @@ -138,8 +138,8 @@ public inline class MetaTransformation(public val transformations: Collection Unit): MetaTransformation = + public companion object { + public fun make(block: MetaTransformationBuilder.() -> Unit): MetaTransformation = MetaTransformationBuilder().apply(block).build() } } diff --git a/dataforge-output/build.gradle.kts b/dataforge-output/build.gradle.kts index 1de9ca2e..de64db60 100644 --- a/dataforge-output/build.gradle.kts +++ b/dataforge-output/build.gradle.kts @@ -1,7 +1,7 @@ plugins { id("ru.mipt.npm.mpp") id("ru.mipt.npm.node") -// id("ru.mipt.npm.native") + id("ru.mipt.npm.native") } kotlin { diff --git a/dataforge-output/src/nativeMain/kotlin/hep/dataforge/output/outputNative.kt b/dataforge-output/src/nativeMain/kotlin/hep/dataforge/output/outputNative.kt new file mode 100644 index 00000000..32eb85f5 --- /dev/null +++ b/dataforge-output/src/nativeMain/kotlin/hep/dataforge/output/outputNative.kt @@ -0,0 +1,6 @@ +package hep.dataforge.output + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers + +public actual val Dispatchers.Output: CoroutineDispatcher get() = Dispatchers.Default \ No newline at end of file diff --git a/dataforge-tables/build.gradle.kts b/dataforge-tables/build.gradle.kts index b181416b..de64db60 100644 --- a/dataforge-tables/build.gradle.kts +++ b/dataforge-tables/build.gradle.kts @@ -1,5 +1,7 @@ plugins { id("ru.mipt.npm.mpp") + id("ru.mipt.npm.node") + id("ru.mipt.npm.native") } kotlin { diff --git a/dataforge-workspace/build.gradle.kts b/dataforge-workspace/build.gradle.kts index 8abe87cd..7af72e4b 100644 --- a/dataforge-workspace/build.gradle.kts +++ b/dataforge-workspace/build.gradle.kts @@ -1,5 +1,7 @@ plugins { id("ru.mipt.npm.mpp") + id("ru.mipt.npm.node") + id("ru.mipt.npm.native") } kotlin { diff --git a/dataforge-workspace/src/commonMain/kotlin/hep/dataforge/workspace/Task.kt b/dataforge-workspace/src/commonMain/kotlin/hep/dataforge/workspace/Task.kt index fbc8637d..6792adfa 100644 --- a/dataforge-workspace/src/commonMain/kotlin/hep/dataforge/workspace/Task.kt +++ b/dataforge-workspace/src/commonMain/kotlin/hep/dataforge/workspace/Task.kt @@ -49,6 +49,6 @@ public interface Task : Named, Described { public fun run(workspace: Workspace, model: TaskModel): DataNode public companion object { - public const val TYPE = "task" + public const val TYPE: String = "task" } } \ No newline at end of file diff --git a/dataforge-workspace/src/commonMain/kotlin/hep/dataforge/workspace/TaskModel.kt b/dataforge-workspace/src/commonMain/kotlin/hep/dataforge/workspace/TaskModel.kt index d9a558e0..5053292e 100644 --- a/dataforge-workspace/src/commonMain/kotlin/hep/dataforge/workspace/TaskModel.kt +++ b/dataforge-workspace/src/commonMain/kotlin/hep/dataforge/workspace/TaskModel.kt @@ -46,7 +46,7 @@ public data class TaskModel( } public companion object { - public val MODEL_TARGET_KEY = "@target".asName() + public val MODEL_TARGET_KEY: Name = "@target".asName() } } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..4bc2b611 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,7 @@ +kotlin.code.style=official +kotlin.parallel.tasks.in.project=true +kotlin.mpp.enableGranularSourceSetsMetadata=true + +org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m +org.gradle.parallel=true +systemProp.org.gradle.internal.publish.checksums.insecure=true \ No newline at end of file