Move scheme descriptors to core

This commit is contained in:
Alexander Nozik 2021-08-07 13:41:47 +03:00
parent 24187722e4
commit 67554a8c98
2 changed files with 22 additions and 25 deletions

View File

@ -90,9 +90,8 @@ public class MetaDescriptorBuilder internal constructor() {
)
}
public fun MetaDescriptorBuilder.item(name: String, block: MetaDescriptorBuilder.() -> Unit) {
public fun MetaDescriptorBuilder.item(name: String, block: MetaDescriptorBuilder.() -> Unit): MetaDescriptorBuilder =
item(Name.parse(name), block)
}
public fun MetaDescriptor(block: MetaDescriptorBuilder.() -> Unit): MetaDescriptor =
MetaDescriptorBuilder().apply(block).build()

View File

@ -9,8 +9,7 @@ import kotlin.reflect.typeOf
public inline fun <S : Scheme, reified T> MetaDescriptorBuilder.value(
property: KProperty1<S, T>,
noinline block: MetaDescriptorBuilder.() -> Unit = {},
) {
when (typeOf<T>()) {
): MetaDescriptorBuilder = when (typeOf<T>()) {
typeOf<Number>(), typeOf<Int>(), typeOf<Double>(), typeOf<Short>(), typeOf<Long>(), typeOf<Float>() ->
value(property.name, ValueType.NUMBER) {
block()
@ -37,7 +36,6 @@ public inline fun <S : Scheme, reified T> MetaDescriptorBuilder.value(
}
else -> item(property.name, block)
}
}
public inline fun <S : Scheme, reified T : Scheme> MetaDescriptorBuilder.scheme(
property: KProperty1<S, T>,