Move envelope builder to the top level.

This commit is contained in:
Alexander Nozik 2020-12-04 11:26:03 +03:00
parent 221cc65b78
commit 17c9bf3d54
4 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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()
}

View File

@ -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 {

View File

@ -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