diff --git a/CHANGELOG.md b/CHANGELOG.md index d3fbfd51..1a543111 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - `ListValue` and `DoubleArrayValue` implement `Iterable`. - Changed the logic of `Value::isList` to check for type instead of size - `Meta{}` builder made inline +- Moved `Envelope` builder to a top level function. Companion invoke is deprecated. ### Deprecated diff --git a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Envelope.kt b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Envelope.kt index 992a080f..d938fe5a 100644 --- a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Envelope.kt +++ b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/Envelope.kt @@ -29,6 +29,9 @@ public interface Envelope { /** * Build a static envelope using provided builder */ + @Deprecated("Use top level function instead", + replaceWith = ReplaceWith("Envelope(block)", "hep.dataforge.io.Envelope") + ) public inline operator fun invoke(block: EnvelopeBuilder.() -> Unit): Envelope = EnvelopeBuilder().apply(block).seal() } diff --git a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeBuilder.kt b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeBuilder.kt index 73775af3..20710198 100644 --- a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeBuilder.kt +++ b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/EnvelopeBuilder.kt @@ -44,6 +44,12 @@ public class EnvelopeBuilder : Envelope { } + +/** + * Build a static envelope using provided [builder] + */ +public inline fun Envelope(builder: EnvelopeBuilder.() -> Unit): Envelope = EnvelopeBuilder().apply(builder).seal() + //@ExperimentalContracts //suspend fun EnvelopeBuilder.buildData(block: suspend Output.() -> Unit): Binary{ // contract { diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MetaBuilder.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MetaBuilder.kt index 63ce1961..12730d46 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MetaBuilder.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MetaBuilder.kt @@ -136,7 +136,7 @@ public fun Meta.builder(): MetaBuilder { /** * Create a deep copy of this meta and apply builder to it */ -public fun Meta.edit(builder: MetaBuilder.() -> Unit): MetaBuilder = builder().apply(builder) +public inline fun Meta.edit(builder: MetaBuilder.() -> Unit): MetaBuilder = builder().apply(builder) /** * Build a [MetaBuilder] using given transformation