From d16d051a1c54ddfdb36b2219d6c9d915c38293c6 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 17 Aug 2019 17:10:40 +0300 Subject: [PATCH] 0.1.3 release --- .../src/commonMain/kotlin/hep/dataforge/data/JoinAction.kt | 2 +- dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Binary.kt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/JoinAction.kt b/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/JoinAction.kt index 5f0f5845..4acae87f 100644 --- a/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/JoinAction.kt +++ b/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/JoinAction.kt @@ -29,7 +29,7 @@ class JoinGroupBuilder(val actionMeta: Meta) { */ fun byValue(tag: String, defaultTag: String = "@default", action: JoinGroup.() -> Unit) { groupRules += { node -> - GroupBuilder.byValue(tag, defaultTag).invoke(node).map { + GroupRule.byValue(tag, defaultTag).invoke(node).map { JoinGroup(it.key, it.value).apply(action) } } 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 d8fe9ad7..67c962dd 100644 --- a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Binary.kt +++ b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Binary.kt @@ -25,6 +25,7 @@ interface Binary { /** * A [Binary] with addition random access functionality. It by default allows multiple [read] operations. */ +@ExperimentalUnsignedTypes interface RandomAccessBinary : Binary { /** * Read at most [size] of bytes starting at [from] offset from the beginning of the binary. @@ -39,10 +40,12 @@ fun Binary.readAll(): ByteReadPacket = read { ByteReadPacket(this.readBytes()) } +@ExperimentalUnsignedTypes fun RandomAccessBinary.readPacket(from: UInt, size: UInt): ByteReadPacket = read(from, size) { ByteReadPacket(this.readBytes()) } +@ExperimentalUnsignedTypes object EmptyBinary : RandomAccessBinary { override val size: ULong = 0.toULong() @@ -52,6 +55,7 @@ object EmptyBinary : RandomAccessBinary { } } +@ExperimentalUnsignedTypes class ArrayBinary(val array: ByteArray) : RandomAccessBinary { override val size: ULong get() = array.size.toULong()