Native for all
This commit is contained in:
parent
4ab9751bea
commit
bc4456637c
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,4 +7,3 @@ build/
|
|||||||
|
|
||||||
|
|
||||||
!gradle-wrapper.jar
|
!gradle-wrapper.jar
|
||||||
gradle.properties
|
|
@ -47,7 +47,7 @@ public open class Context(
|
|||||||
/**
|
/**
|
||||||
* A [PluginManager] for current 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")
|
@Deprecated("To be removed in favor of immutable plugins")
|
||||||
private val activators = HashSet<Any>()
|
private val activators = HashSet<Any>()
|
||||||
|
@ -5,10 +5,12 @@ import hep.dataforge.names.asName
|
|||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
import kotlin.native.concurrent.ThreadLocal
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A global root context. Closing [Global] terminates the framework.
|
* A global root context. Closing [Global] terminates the framework.
|
||||||
*/
|
*/
|
||||||
|
@ThreadLocal
|
||||||
public object Global : Context("GLOBAL".asName(), null, Meta.EMPTY) {
|
public object Global : Context("GLOBAL".asName(), null, Meta.EMPTY) {
|
||||||
|
|
||||||
override val coroutineContext: CoroutineContext = GlobalScope.coroutineContext + SupervisorJob()
|
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 =
|
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
|
@Test
|
||||||
fun testPluginManager() {
|
fun testPluginManager() {
|
||||||
Global.plugins.load(DummyPlugin())
|
val context = Global.context("test"){
|
||||||
val members = Global.gather<Name>("test")
|
plugin(DummyPlugin())
|
||||||
|
}
|
||||||
|
//Global.plugins.load(DummyPlugin())
|
||||||
|
val members = context.gather<Name>("test")
|
||||||
assertEquals(3, members.count())
|
assertEquals(3, members.count())
|
||||||
members.forEach {
|
members.forEach {
|
||||||
assertEquals(it.key, it.value.appendLeft("test"))
|
assertEquals(it.key, it.value.appendLeft("test"))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.mpp")
|
||||||
id("ru.mipt.npm.node")
|
id("ru.mipt.npm.node")
|
||||||
// id("ru.mipt.npm.native")
|
id("ru.mipt.npm.native")
|
||||||
}
|
}
|
||||||
|
|
||||||
kscience{
|
kscience{
|
||||||
|
@ -28,7 +28,7 @@ public class DataFilter : Scheme() {
|
|||||||
/**
|
/**
|
||||||
* Apply meta-based filter to given data node
|
* 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 sourceNode = filter.from?.let { get(it.toName()).node } ?: this@filter
|
||||||
val regex = filter.pattern.toRegex()
|
val regex = filter.pattern.toRegex()
|
||||||
val targetNode = DataTreeBuilder(type).apply {
|
val targetNode = DataTreeBuilder(type).apply {
|
||||||
@ -46,10 +46,10 @@ fun <T : Any> DataNode<T>.filter(filter: DataFilter): DataNode<T> {
|
|||||||
/**
|
/**
|
||||||
* Filter data using [DataFilter] specification
|
* 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
|
* 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))
|
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
|
* 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 {
|
internal actual fun <R : Any> DataNode<*>.canCast(type: KClass<out R>): Boolean {
|
||||||
//Not supported in js yet
|
return this.type == type
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal actual fun <R : Any> Data<*>.canCast(type: KClass<out R>): Boolean {
|
internal actual fun <R : Any> Data<*>.canCast(type: KClass<out R>): Boolean {
|
||||||
//Not supported in js yet
|
return this.type == type
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.mpp")
|
||||||
id("ru.mipt.npm.node")
|
id("ru.mipt.npm.node")
|
||||||
// id("ru.mipt.npm.native")
|
id("ru.mipt.npm.native")
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "IO module"
|
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 {
|
kotlin {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
@ -48,8 +48,10 @@ class MetaSerializerTest {
|
|||||||
assertEquals(name, restored)
|
assertEquals(name, restored)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalSerializationApi::class)
|
||||||
@Test
|
@Test
|
||||||
fun testMetaItemDescriptor() {
|
fun testMetaItemDescriptor() {
|
||||||
val descriptor = MetaItem.serializer(MetaSerializer).descriptor.getElementDescriptor(0)
|
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 {
|
public companion object {
|
||||||
fun make(block: MetaTransformationBuilder.() -> Unit): MetaTransformation =
|
public fun make(block: MetaTransformationBuilder.() -> Unit): MetaTransformation =
|
||||||
MetaTransformationBuilder().apply(block).build()
|
MetaTransformationBuilder().apply(block).build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.mpp")
|
||||||
id("ru.mipt.npm.node")
|
id("ru.mipt.npm.node")
|
||||||
// id("ru.mipt.npm.native")
|
id("ru.mipt.npm.native")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
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 {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.mpp")
|
||||||
|
id("ru.mipt.npm.node")
|
||||||
|
id("ru.mipt.npm.native")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("ru.mipt.npm.mpp")
|
id("ru.mipt.npm.mpp")
|
||||||
|
id("ru.mipt.npm.node")
|
||||||
|
id("ru.mipt.npm.native")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
@ -49,6 +49,6 @@ public interface Task<out R : Any> : Named, Described {
|
|||||||
public fun run(workspace: Workspace, model: TaskModel): DataNode<R>
|
public fun run(workspace: Workspace, model: TaskModel): DataNode<R>
|
||||||
|
|
||||||
public companion object {
|
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 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