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`. - `ListValue` and `DoubleArrayValue` implement `Iterable`.
- Changed the logic of `Value::isList` to check for type instead of size - Changed the logic of `Value::isList` to check for type instead of size
- `Meta{}` builder made inline - `Meta{}` builder made inline
- Moved `Envelope` builder to a top level function. Companion invoke is deprecated.
### Deprecated ### Deprecated

View File

@ -29,6 +29,9 @@ public interface Envelope {
/** /**
* Build a static envelope using provided builder * 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 = public inline operator fun invoke(block: EnvelopeBuilder.() -> Unit): Envelope =
EnvelopeBuilder().apply(block).seal() 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 //@ExperimentalContracts
//suspend fun EnvelopeBuilder.buildData(block: suspend Output.() -> Unit): Binary{ //suspend fun EnvelopeBuilder.buildData(block: suspend Output.() -> Unit): Binary{
// contract { // contract {

View File

@ -136,7 +136,7 @@ public fun Meta.builder(): MetaBuilder {
/** /**
* Create a deep copy of this meta and apply builder to it * 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 * Build a [MetaBuilder] using given transformation