internal api refactoring

This commit is contained in:
Alexander Nozik 2020-08-27 21:43:56 +03:00
parent 08982dcd3e
commit 3f8d62ebc4
4 changed files with 6 additions and 5 deletions

View File

@ -28,5 +28,6 @@ kotlin {
dependencies{
}
}
val nativeMain by getting{}
}
}

View File

@ -28,7 +28,7 @@ class ActionDelegate<D : DeviceBase>(
) : ReadOnlyProperty<D, Action> {
override fun getValue(thisRef: D, property: KProperty<*>): Action {
val name = property.name
return owner.resolveAction(name) {
return owner.registerAction(name) {
SimpleAction(name, ActionDescriptor(name).apply(descriptorBuilder), block)
}
}

View File

@ -33,11 +33,11 @@ abstract class DeviceBase : Device {
override val actionDescriptors: Collection<ActionDescriptor>
get() = actions.values.map { it.descriptor }
internal fun resolveProperty(name: String, builder: () -> ReadOnlyDeviceProperty): ReadOnlyDeviceProperty {
internal fun registerProperty(name: String, builder: () -> ReadOnlyDeviceProperty): ReadOnlyDeviceProperty {
return properties.getOrPut(name, builder)
}
internal fun resolveAction(name: String, builder: () -> Action): Action {
internal fun registerAction(name: String, builder: () -> Action): Action {
return actions.getOrPut(name, builder)
}

View File

@ -72,7 +72,7 @@ private class ReadOnlyDevicePropertyDelegate<D : DeviceBase>(
override fun getValue(thisRef: D, property: KProperty<*>): IsolatedReadOnlyDeviceProperty {
val name = property.name
return owner.resolveProperty(name) {
return owner.registerProperty(name) {
@OptIn(ExperimentalCoroutinesApi::class)
IsolatedReadOnlyDeviceProperty(
name,
@ -186,7 +186,7 @@ private class DevicePropertyDelegate<D : DeviceBase>(
override fun getValue(thisRef: D, property: KProperty<*>): IsolatedDeviceProperty {
val name = property.name
return owner.resolveProperty(name) {
return owner.registerProperty(name) {
@OptIn(ExperimentalCoroutinesApi::class)
IsolatedDeviceProperty(
name,