Native for all
This commit is contained in:
parent
4ab9751bea
commit
bc4456637c
3
.gitignore
vendored
3
.gitignore
vendored
@ -6,5 +6,4 @@ out/
|
||||
build/
|
||||
|
||||
|
||||
!gradle-wrapper.jar
|
||||
gradle.properties
|
||||
!gradle-wrapper.jar
|
@ -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<Any>()
|
||||
@ -92,7 +92,7 @@ public open class Context(
|
||||
}
|
||||
}
|
||||
|
||||
override fun content(target: String): Map<Name, Any> = content(target,true)
|
||||
override fun content(target: String): Map<Name, Any> = content(target, true)
|
||||
|
||||
override val coroutineContext: CoroutineContext by lazy {
|
||||
(parent ?: Global).coroutineContext.let { parenContext ->
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
@ -21,8 +21,11 @@ class ContextTest {
|
||||
|
||||
@Test
|
||||
fun testPluginManager() {
|
||||
Global.plugins.load(DummyPlugin())
|
||||
val members = Global.gather<Name>("test")
|
||||
val context = Global.context("test"){
|
||||
plugin(DummyPlugin())
|
||||
}
|
||||
//Global.plugins.load(DummyPlugin())
|
||||
val members = context.gather<Name>("test")
|
||||
assertEquals(3, members.count())
|
||||
members.forEach {
|
||||
assertEquals(it.key, it.value.appendLeft("test"))
|
||||
|
@ -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{
|
||||
|
@ -28,7 +28,7 @@ public class DataFilter : Scheme() {
|
||||
/**
|
||||
* Apply meta-based filter to given data node
|
||||
*/
|
||||
fun <T : Any> DataNode<T>.filter(filter: DataFilter): DataNode<T> {
|
||||
public fun <T : Any> DataNode<T>.filter(filter: DataFilter): DataNode<T> {
|
||||
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 <T : Any> DataNode<T>.filter(filter: DataFilter): DataNode<T> {
|
||||
/**
|
||||
* Filter data using [DataFilter] specification
|
||||
*/
|
||||
fun <T : Any> DataNode<T>.filter(filter: Meta): DataNode<T> = filter(DataFilter.wrap(filter))
|
||||
public fun <T : Any> DataNode<T>.filter(filter: Meta): DataNode<T> = filter(DataFilter.wrap(filter))
|
||||
|
||||
/**
|
||||
* Filter data using [DataFilter] builder
|
||||
*/
|
||||
fun <T : Any> DataNode<T>.filter(filterBuilder: DataFilter.() -> Unit): DataNode<T> =
|
||||
public fun <T : Any> DataNode<T>.filter(filterBuilder: DataFilter.() -> Unit): DataNode<T> =
|
||||
filter(DataFilter(filterBuilder))
|
@ -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 <R : Any> DataNode<*>.canCast(type: KClass<out R>): Boolean {
|
||||
//Not supported in js yet
|
||||
return true
|
||||
return this.type == type
|
||||
}
|
||||
|
||||
internal actual fun <R : Any> Data<*>.canCast(type: KClass<out R>): Boolean {
|
||||
//Not supported in js yet
|
||||
return true
|
||||
return this.type == type
|
||||
}
|
||||
|
@ -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 <R : Any> DataNode<*>.canCast(type: KClass<out R>): Boolean {
|
||||
return this.type == type
|
||||
}
|
||||
|
||||
internal actual fun <R : Any> Data<*>.canCast(type: KClass<out R>): Boolean {
|
||||
return this.type == type
|
||||
}
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
@ -138,8 +138,8 @@ public inline class MetaTransformation(public val transformations: Collection<Tr
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun make(block: MetaTransformationBuilder.() -> Unit): MetaTransformation =
|
||||
public companion object {
|
||||
public fun make(block: MetaTransformationBuilder.() -> Unit): MetaTransformation =
|
||||
MetaTransformationBuilder().apply(block).build()
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
@ -1,5 +1,7 @@
|
||||
plugins {
|
||||
id("ru.mipt.npm.mpp")
|
||||
id("ru.mipt.npm.node")
|
||||
id("ru.mipt.npm.native")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
@ -1,5 +1,7 @@
|
||||
plugins {
|
||||
id("ru.mipt.npm.mpp")
|
||||
id("ru.mipt.npm.node")
|
||||
id("ru.mipt.npm.native")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
@ -49,6 +49,6 @@ public interface Task<out R : Any> : Named, Described {
|
||||
public fun run(workspace: Workspace, model: TaskModel): DataNode<R>
|
||||
|
||||
public companion object {
|
||||
public const val TYPE = "task"
|
||||
public const val TYPE: String = "task"
|
||||
}
|
||||
}
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
7
gradle.properties
Normal file
7
gradle.properties
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user