simplified adapter/command logic, adapeter builder introduced
This commit is contained in:
1 parent
32280ffc61
commit
0cfe95d4f4
9 files changed
+161
-32
No files matched your search
@@ -1,19 +1,19 @@
|
||||
package channel
|
||||
package net.sergeych.parsec3
|
||||
|
||||
import kotlin.reflect.KType
|
||||
|
||||
class CommandDescriptor<I, A, R>(
|
||||
class CommandDescriptor<A, R>(
|
||||
val name: String,
|
||||
val ass: KType,
|
||||
val rss: KType,
|
||||
) {
|
||||
suspend operator fun invoke(adapter: Adapter<I>, args: A): R =
|
||||
suspend operator fun invoke(adapter: Adapter<*>, args: A): R =
|
||||
adapter.invokeCommand(this, args)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
suspend operator fun invoke(adapter: Adapter<I>): R = adapter.invokeCommand(this,Unit as A)
|
||||
suspend operator fun invoke(adapter: Adapter<*>): R = adapter.invokeCommand(this,Unit as A)
|
||||
|
||||
operator fun invoke(commandHost: CommandHost<I>, block: suspend I.(A)->R) {
|
||||
operator fun <I>invoke(commandHost: CommandHost<I>, block: suspend I.(A)->R) {
|
||||
commandHost.on(this, block)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user