From 9f6d53f214782597780dbdd91caee33cbf75c649 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 27 Jul 2019 17:45:14 +0300 Subject: [PATCH] Some additional fixes --- .../src/commonMain/kotlin/hep/dataforge/io/Binary.kt | 1 - .../commonTest/kotlin/hep/dataforge/io/MetaFormatTest.kt | 4 ++++ .../src/commonMain/kotlin/hep/dataforge/meta/Meta.kt | 6 +----- .../src/commonMain/kotlin/hep/dataforge/values/Value.kt | 2 +- .../kotlin/hep/dataforge/output/html/HtmlOutput.kt | 3 +-- .../kotlin/hep/dataforge/scripting/Placeholder.kt | 4 ++++ 6 files changed, 11 insertions(+), 9 deletions(-) rename dataforge-output-html/src/{jvmMain => commonMain}/kotlin/hep/dataforge/output/html/HtmlOutput.kt (93%) create mode 100644 dataforge-scripting/src/commonMain/kotlin/hep/dataforge/scripting/Placeholder.kt diff --git a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Binary.kt b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Binary.kt index 75ef0422..a0374968 100644 --- a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Binary.kt +++ b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Binary.kt @@ -7,7 +7,6 @@ import kotlinx.io.core.readBytes /** * A source of binary data */ - interface Binary { /** * The size of binary in bytes diff --git a/dataforge-io/src/commonTest/kotlin/hep/dataforge/io/MetaFormatTest.kt b/dataforge-io/src/commonTest/kotlin/hep/dataforge/io/MetaFormatTest.kt index 3788a0ef..ab4ab677 100644 --- a/dataforge-io/src/commonTest/kotlin/hep/dataforge/io/MetaFormatTest.kt +++ b/dataforge-io/src/commonTest/kotlin/hep/dataforge/io/MetaFormatTest.kt @@ -1,7 +1,9 @@ package hep.dataforge.io +import hep.dataforge.meta.Meta import hep.dataforge.meta.buildMeta import hep.dataforge.meta.get +import hep.dataforge.meta.seal import kotlin.test.Test import kotlin.test.assertEquals @@ -34,6 +36,8 @@ class MetaFormatTest { val string = meta.toString(JsonMetaFormat) val result = JsonMetaFormat.parse(string) + assertEquals(meta, meta.seal()) + meta.items.keys.forEach { if (meta[it] != result[it]) error("${meta[it]} != ${result[it]}") } diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Meta.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Meta.kt index 9e71023c..1687b66a 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Meta.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Meta.kt @@ -16,14 +16,10 @@ import hep.dataforge.values.boolean */ sealed class MetaItem { data class ValueItem(val value: Value) : MetaItem(){ - override fun toString(): String = value.string + override fun toString(): String = value.toString() } data class NodeItem(val node: M) : MetaItem(){ override fun toString(): String = node.toString() - - override fun equals(other: Any?): Boolean { - return this.node == (other as? NodeItem<*>).node - } } } diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/values/Value.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/values/Value.kt index 140178c2..7b42f639 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/values/Value.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/values/Value.kt @@ -188,7 +188,7 @@ class ListValue(override val list: List) : Value { override val number: Number get() = list.first().number override val string: String get() = list.first().string - override fun toString(): String = value.toString() + override fun toString(): String = list.joinToString (prefix = "[ ", postfix = " ]") override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/dataforge-output-html/src/jvmMain/kotlin/hep/dataforge/output/html/HtmlOutput.kt b/dataforge-output-html/src/commonMain/kotlin/hep/dataforge/output/html/HtmlOutput.kt similarity index 93% rename from dataforge-output-html/src/jvmMain/kotlin/hep/dataforge/output/html/HtmlOutput.kt rename to dataforge-output-html/src/commonMain/kotlin/hep/dataforge/output/html/HtmlOutput.kt index bfbd74eb..c7aea610 100644 --- a/dataforge-output-html/src/jvmMain/kotlin/hep/dataforge/output/html/HtmlOutput.kt +++ b/dataforge-output-html/src/commonMain/kotlin/hep/dataforge/output/html/HtmlOutput.kt @@ -27,8 +27,7 @@ class HtmlOutput(override val context: Context, private val consumer: T } else { val value = cache[obj::class] if (value == null) { - val answer = context.top>().values - .filter { it.type.isInstance(obj) }.firstOrNull() + val answer = context.top>(HTML_CONVERTER_TYPE).values.firstOrNull { it.type.isInstance(obj) } if (answer != null) { cache[obj::class] = answer answer diff --git a/dataforge-scripting/src/commonMain/kotlin/hep/dataforge/scripting/Placeholder.kt b/dataforge-scripting/src/commonMain/kotlin/hep/dataforge/scripting/Placeholder.kt new file mode 100644 index 00000000..a09e35c1 --- /dev/null +++ b/dataforge-scripting/src/commonMain/kotlin/hep/dataforge/scripting/Placeholder.kt @@ -0,0 +1,4 @@ +package hep.dataforge.scripting + +internal object Placeholder { +} \ No newline at end of file