Splitting meta and mata-io. Project rename
This commit is contained in:
parent
a5a4b67c97
commit
ad059dea33
@ -1,6 +1,7 @@
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.0-rc-57'
|
||||
ext.serialization_version = '0.8.0-rc13'
|
||||
ext.kotlinx_io_version = '0.1.0-alpha-15-rc13'
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
@ -34,7 +35,3 @@ allprojects {
|
||||
//maven { url 'https://jitpack.io' }
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
}
|
||||
|
13
dataforge-envelope/build.gradle
Normal file
13
dataforge-envelope/build.gradle
Normal file
@ -0,0 +1,13 @@
|
||||
plugins{
|
||||
id 'kotlin-platform-common'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(":dataforge-meta")
|
||||
|
||||
compile "org.jetbrains.kotlinx:kotlinx-io:$kotlinx_io_version"
|
||||
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common"
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-common"
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package hep.dataforge.envelopes
|
||||
|
||||
import hep.dataforge.meta.Meta
|
||||
import kotlinx.io.core.IoBuffer
|
||||
|
||||
interface Envelope{
|
||||
val meta: Meta
|
||||
val data: IoBuffer
|
||||
}
|
@ -4,7 +4,7 @@ plugins{
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
|
||||
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
|
||||
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common"
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-common"
|
||||
}
|
19
dataforge-meta/dataforge-meta-io/build.gradle
Normal file
19
dataforge-meta/dataforge-meta-io/build.gradle
Normal file
@ -0,0 +1,19 @@
|
||||
plugins{
|
||||
id 'kotlin-platform-common'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(":dataforge-meta")
|
||||
|
||||
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
|
||||
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
|
||||
compile "org.jetbrains.kotlinx:kotlinx-io:$kotlinx_io_version"
|
||||
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common"
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-common"
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package hep.dataforge.meta.io
|
||||
|
||||
import hep.dataforge.meta.Meta
|
||||
import kotlinx.io.core.Input
|
||||
import kotlinx.io.core.Output
|
||||
|
||||
/**
|
||||
* A format for meta serialization
|
||||
*/
|
||||
interface MetaFormat {
|
||||
val name : String
|
||||
val key : Short
|
||||
|
||||
suspend fun write(meta: Meta, out: Output)
|
||||
suspend fun read(input: Input): Meta
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve format by its name. Null if not provided
|
||||
*/
|
||||
expect fun resolveFormat(name: String): MetaFormat?
|
||||
|
||||
/**
|
||||
* Resolve format by its binary key. Null if not provided
|
||||
*/
|
||||
expect fun resolveFormat(key: Short): MetaFormat?
|
@ -1,46 +1,47 @@
|
||||
package hep.dataforge.meta
|
||||
package hep.dataforge.meta.io
|
||||
|
||||
import kotlinx.serialization.json.*
|
||||
import hep.dataforge.meta.*
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
/*Universal serialization*/
|
||||
|
||||
//sealed class MetaItemProxy {
|
||||
//
|
||||
// @Serializable
|
||||
// class NumberValueProxy(val number: Number) : MetaItemProxy()
|
||||
//
|
||||
// @Serializable
|
||||
// class StringValueProxy(val string: String) : MetaItemProxy()
|
||||
//
|
||||
// @Serializable
|
||||
// class BooleanValueProxy(val boolean: Boolean) : MetaItemProxy()
|
||||
//
|
||||
// @Serializable
|
||||
// object NullValueProxy : MetaItemProxy()
|
||||
//
|
||||
// @Serializable
|
||||
// class MetaProxy(@Serializable val map: Map<String, MetaItemProxy>) : MetaItemProxy()
|
||||
//
|
||||
// @Serializable
|
||||
// class MetaListProxy(@Serializable val nodes: List<MetaProxy>) : MetaItemProxy()
|
||||
//}
|
||||
//
|
||||
//
|
||||
//fun Meta.toMap(): Map<String, MetaItemProxy> {
|
||||
// return this.items.mapValues { (_, value) ->
|
||||
// when (value) {
|
||||
// is MetaItem.ValueItem -> when (value.value.type) {
|
||||
// ValueType.NUMBER -> MetaItemProxy.NumberValueProxy(value.value.number)
|
||||
// ValueType.STRING -> MetaItemProxy.StringValueProxy(value.value.string)
|
||||
// ValueType.BOOLEAN -> MetaItemProxy.BooleanValueProxy(value.value.boolean)
|
||||
// ValueType.NULL -> MetaItemProxy.NullValueProxy
|
||||
// }
|
||||
// is MetaItem.SingleNodeItem -> MetaItemProxy.MetaProxy(value.node.toMap())
|
||||
// is MetaItem.MultiNodeItem -> MetaItemProxy.MetaListProxy(value.nodes.map { MetaItemProxy.MetaProxy(it.toMap()) })
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
sealed class MetaItemProxy {
|
||||
|
||||
@Serializable
|
||||
class NumberValueProxy(val number: Number) : MetaItemProxy()
|
||||
|
||||
@Serializable
|
||||
class StringValueProxy(val string: String) : MetaItemProxy()
|
||||
|
||||
@Serializable
|
||||
class BooleanValueProxy(val boolean: Boolean) : MetaItemProxy()
|
||||
|
||||
@Serializable
|
||||
object NullValueProxy : MetaItemProxy()
|
||||
|
||||
@Serializable
|
||||
class MetaProxy(@Serializable val map: Map<String, MetaItemProxy>) : MetaItemProxy()
|
||||
|
||||
@Serializable
|
||||
class MetaListProxy(@Serializable val nodes: List<MetaProxy>) : MetaItemProxy()
|
||||
}
|
||||
|
||||
|
||||
fun Meta.toMap(): Map<String, MetaItemProxy> {
|
||||
return this.items.mapValues { (_, value) ->
|
||||
when (value) {
|
||||
is MetaItem.ValueItem<*> -> when (value.value.type) {
|
||||
ValueType.NUMBER -> MetaItemProxy.NumberValueProxy(value.value.number)
|
||||
ValueType.STRING -> MetaItemProxy.StringValueProxy(value.value.string)
|
||||
ValueType.BOOLEAN -> MetaItemProxy.BooleanValueProxy(value.value.boolean)
|
||||
ValueType.NULL -> MetaItemProxy.NullValueProxy
|
||||
}
|
||||
is MetaItem.SingleNodeItem<*> -> MetaItemProxy.MetaProxy(value.node.toMap())
|
||||
is MetaItem.MultiNodeItem<*> -> MetaItemProxy.MetaListProxy(value.nodes.map { MetaItemProxy.MetaProxy(it.toMap()) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*Direct JSON serialization*/
|
@ -3,9 +3,8 @@ plugins{
|
||||
}
|
||||
|
||||
dependencies {
|
||||
expectedBy project(":dataforge-meta-common")
|
||||
expectedBy project(":dataforge-meta")
|
||||
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serialization_version"
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-js"
|
||||
}
|
@ -3,11 +3,9 @@ plugins{
|
||||
}
|
||||
|
||||
dependencies {
|
||||
expectedBy project(":dataforge-meta-common")
|
||||
expectedBy project(":dataforge-meta")
|
||||
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test"
|
||||
testCompile "org.jetbrains.kotlin:kotlin-test-junit"
|
||||
}
|
@ -96,11 +96,6 @@ abstract class MetaNode<M : MetaNode<M>> : Meta {
|
||||
override fun hashCode(): Int {
|
||||
return items.hashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return toJSON().toString()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
@ -14,8 +14,12 @@ pluginManagement {
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'dataforge-meta'
|
||||
rootProject.name = 'dataforge-core'
|
||||
|
||||
include ":dataforge-meta-common"
|
||||
include ":dataforge-meta-jvm"
|
||||
include ":dataforge-meta-js"
|
||||
include ":dataforge-meta"
|
||||
include ":dataforge-meta:dataforge-meta-jvm"
|
||||
include ":dataforge-meta:dataforge-meta-js"
|
||||
|
||||
include ":dataforge-meta:dataforge-meta-io"
|
||||
|
||||
include ":dataforge-envelope"
|
Loading…
Reference in New Issue
Block a user