Skip to content

Commit

Permalink
remove some NON_PUBLIC_CALL_FROM_PUBLIC_INLINE
Browse files Browse the repository at this point in the history
  • Loading branch information
Bixilon committed Jun 11, 2024
1 parent 25ad7a1 commit c3a97a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2024 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
Expand Down Expand Up @@ -28,37 +28,32 @@ import kotlin.reflect.KProperty0

object JavaFXDelegate {

private fun checkErosState() {
internal fun checkErosState() {
if (RunConfiguration.DISABLE_EROS) {
throw IllegalStateException("Eros is disabled!")
}
}

@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <V> KProperty0<V>.observeFX(owner: Any, instant: Boolean = false, observer: (V) -> Unit) {
checkErosState()
this.observe(owner, instant) { JavaFXUtil.runLater { observer(it) } }
}

@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <V> KProperty0<Set<V>>.observeSetFX(owner: Any, instant: Boolean = false, observer: (SetChange<V>) -> Unit) {
checkErosState()
this.observeSet(owner, instant) { JavaFXUtil.runLater { observer(it) } }
}

@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <V> KProperty0<List<V>>.observeListFX(owner: Any, instant: Boolean = false, observer: (ListChange<V>) -> Unit) {
checkErosState()
this.observeList(owner, instant) { JavaFXUtil.runLater { observer(it) } }
}

@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <K, V> KProperty0<Map<K, V>>.observeMapFX(owner: Any, instant: Boolean = false, observer: (MapChange<K, V>) -> Unit) {
checkErosState()
this.observeMap(owner, instant) { JavaFXUtil.runLater { observer(it) } }
}

@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <K, V> KProperty0<AbstractBiMap<K, V>>.observeBiMapFX(owner: Any, instant: Boolean = false, observer: (MapChange<K, V>) -> Unit) {
checkErosState()
this.observeBiMap(owner, instant) { JavaFXUtil.runLater { observer(it) } }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2024 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
Expand Down Expand Up @@ -32,7 +32,7 @@ object RenderingDelegate {
return Rendering.currentContext ?: throw IllegalStateException("Can only be registered in a render context!")
}

private fun <V> runInContext(context: RenderContext, value: V, runnable: (V) -> Unit) {
internal fun <V> runInContext(context: RenderContext, value: V, runnable: (V) -> Unit) {
val changeContext = Rendering.currentContext
if (changeContext === context) {
runnable(value)
Expand All @@ -41,27 +41,22 @@ object RenderingDelegate {
}
}

@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <V> KProperty0<V>.observeRendering(owner: Any, instant: Boolean = false, context: RenderContext = requireContext(), observer: (V) -> Unit) {
this.observe(owner, instant) { runInContext(context, it, observer) }
}

@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <V> KProperty0<Set<V>>.observeSetRendering(owner: Any, instant: Boolean = false, context: RenderContext = requireContext(), observer: (SetChange<V>) -> Unit) {
this.observeSet(owner, instant) { runInContext(context, it, observer) }
}

@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <V> KProperty0<List<V>>.observeListRendering(owner: Any, instant: Boolean = false, context: RenderContext = requireContext(), observer: (ListChange<V>) -> Unit) {
this.observeList(owner, instant) { runInContext(context, it, observer) }
}

@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <K, V> KProperty0<Map<K, V>>.observeMapRendering(owner: Any, instant: Boolean = false, context: RenderContext = requireContext(), observer: (MapChange<K, V>) -> Unit) {
this.observeMap(owner, instant) { runInContext(context, it, observer) }
}

@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
fun <K, V> KProperty0<AbstractBiMap<K, V>>.observeBiMapRendering(owner: Any, instant: Boolean = false, context: RenderContext = requireContext(), observer: (MapChange<K, V>) -> Unit) {
this.observeBiMap(owner, instant) { runInContext(context, it, observer) }
}
Expand Down

0 comments on commit c3a97a0

Please sign in to comment.