Skip to content

Commit

Permalink
rename bindingId to more correctly be called className
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottPierce committed Jun 22, 2024
1 parent ac8a59c commit bcc99c3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import platform.objc.objc_sync_exit
import kotlin.reflect.KClass

internal actual object KinjectPlatform {
actual val KClass<*>.bindingId: String
actual val KClass<*>.className: String
get() = this.qualifiedName ?: error("No qualified name found for '$this'")

actual inline fun <R> synchronized(lock: Any, func: () -> R): R {
Expand Down
2 changes: 1 addition & 1 deletion kinject/src/commonMain/kotlin/kinject/KinjectPlatform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package kinject
import kotlin.reflect.KClass

internal expect object KinjectPlatform {
val KClass<*>.bindingId: String
val KClass<*>.className: String

inline fun <R> synchronized(lock: Any, func: () -> R): R
}
8 changes: 4 additions & 4 deletions kinject/src/commonMain/kotlin/kinject/ObjectGraph.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kinject

import kinject.KinjectPlatform.bindingId
import kinject.KinjectPlatform.className
import kotlin.reflect.KClass

inline fun objectGraph(
Expand All @@ -16,7 +16,7 @@ class ObjectGraph private constructor(
) {
inline fun <reified T : Any> get(): T = get(T::class)

fun <T : Any> get(clazz: KClass<T>): T = internalGet(clazz.bindingId)
fun <T : Any> get(clazz: KClass<T>): T = internalGet(clazz.className)

@Suppress("UNCHECKED_CAST")
private fun <T : Any> internalGet(className: String, tag: String? = null): T {
Expand All @@ -40,15 +40,15 @@ class ObjectGraph private constructor(
clazz: KClass<T>,
provider: ObjectGraph.() -> T,
) {
val bindingId = clazz.bindingId
val bindingId = clazz.className
bindings[bindingId] = SingletonLazyBinding(bindingId, provider)
}

fun <T : Any> singleton(
instance: T,
bindType: KClass<*> = instance::class,
) {
val bindingId = bindType.bindingId
val bindingId = bindType.className
bindings[bindingId] = SingletonBinding(bindingId, instance)
}

Expand Down
2 changes: 1 addition & 1 deletion kinject/src/jsMain/kotlin/kinject/KinjectPlatform.js.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package kinject
import kotlin.reflect.KClass

internal actual object KinjectPlatform {
actual val KClass<*>.bindingId: String
actual val KClass<*>.className: String
get() = this.js.name
actual inline fun <R> synchronized(lock: Any, func: () -> R): R = func()
}
2 changes: 1 addition & 1 deletion kinject/src/jvmMain/kotlin/kinject/KinjectPlatform.jvm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package kinject
import kotlin.reflect.KClass

internal actual object KinjectPlatform {
actual val KClass<*>.bindingId: String
actual val KClass<*>.className: String
get() = this.java.name

actual inline fun <R> synchronized(lock: Any, func: () -> R): R {
Expand Down

0 comments on commit bcc99c3

Please sign in to comment.