mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-10-10 16:19:37 +00:00
19 lines
478 B
Kotlin
19 lines
478 B
Kotlin
|
package gay.pizza.pork.execution
|
||
|
|
||
|
class NativeRegistry {
|
||
|
private val providers = mutableMapOf<String, NativeProvider>()
|
||
|
|
||
|
fun add(form: String, provider: NativeProvider) {
|
||
|
providers[form] = provider
|
||
|
}
|
||
|
|
||
|
fun forEachProvider(block: (String, NativeProvider) -> Unit) {
|
||
|
for ((form, provider) in providers) {
|
||
|
block(form, provider)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fun of(form: String): NativeProvider =
|
||
|
providers[form] ?: throw RuntimeException("Unknown native form: ${form}")
|
||
|
}
|