Skip to content

Commit

Permalink
Add no-op JVM target (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
konpach authored Feb 12, 2024
1 parent 4e043de commit c3c8adc
Show file tree
Hide file tree
Showing 18 changed files with 645 additions and 1 deletion.
File renamed without changes.
450 changes: 450 additions & 0 deletions core/api/jvm/core.api

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ kotlin {
js().browser()
macosArm64()
macosX64()
jvm()

sourceSets {
commonMain.dependencies {
Expand Down Expand Up @@ -75,3 +76,4 @@ android {
disable += "GradleDependency"
}
}

2 changes: 1 addition & 1 deletion core/src/androidMain/kotlin/Profile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public actual data class DiscoveredCharacteristic internal constructor(
override val serviceUuid: Uuid get() = characteristic.service.uuid
override val characteristicUuid: Uuid get() = characteristic.uuid
val instanceId: Int get() = characteristic.instanceId
actual val properties: Properties get() = Properties(characteristic.properties)
public actual val properties: Properties get() = Properties(characteristic.properties)
}

public actual data class DiscoveredDescriptor internal constructor(
Expand Down
9 changes: 9 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/Bluetooth.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.juul.kable

import kotlinx.coroutines.flow.Flow

public actual enum class Reason {
// Not implemented.
}

internal actual val bluetoothAvailability: Flow<Bluetooth.Availability> = jvmNotImplementedException()
5 changes: 5 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/Exceptions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.juul.kable

internal fun jvmNotImplementedException(): Nothing = throw NotImplementedError(
"JVM target not yet implemented. See https://github.com/JuulLabs/kable/issues/380 for details.",
)
5 changes: 5 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/Identifier.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.juul.kable

public actual typealias Identifier = String

public actual fun String.toIdentifier(): Identifier = this
11 changes: 11 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/Observations.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.juul.kable

internal actual fun Peripheral.observationHandler(): Observation.Handler = object : Observation.Handler {
override suspend fun startObservation(characteristic: Characteristic) {
jvmNotImplementedException()
}

override suspend fun stopObservation(characteristic: Characteristic) {
jvmNotImplementedException()
}
}
10 changes: 10 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/Peripheral.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.juul.kable

import kotlinx.coroutines.CoroutineScope

public actual fun CoroutineScope.peripheral(
advertisement: Advertisement,
builderAction: PeripheralBuilderAction,
): Peripheral {
jvmNotImplementedException()
}
44 changes: 44 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/PeripheralBuilder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.juul.kable

import com.juul.kable.logs.LoggingBuilder

public actual class ServicesDiscoveredPeripheral internal constructor() {

public actual suspend fun read(
characteristic: Characteristic,
): ByteArray = jvmNotImplementedException()

public actual suspend fun read(
descriptor: Descriptor,
): ByteArray = jvmNotImplementedException()

public actual suspend fun write(
characteristic: Characteristic,
data: ByteArray,
writeType: WriteType,
) {
jvmNotImplementedException()
}

public actual suspend fun write(
descriptor: Descriptor,
data: ByteArray,
) {
jvmNotImplementedException()
}
}

public actual class PeripheralBuilder internal actual constructor() {

public actual fun logging(init: LoggingBuilder) {
jvmNotImplementedException()
}

public actual fun onServicesDiscovered(action: ServicesDiscoveredAction) {
jvmNotImplementedException()
}

public actual fun observationExceptionHandler(handler: ObservationExceptionHandler) {
jvmNotImplementedException()
}
}
3 changes: 3 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/PlatformScanner.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.juul.kable

public actual interface PlatformScanner : Scanner
43 changes: 43 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/Profile.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.juul.kable

import com.benasher44.uuid.Uuid

internal actual class PlatformService
internal actual class PlatformCharacteristic
internal actual class PlatformDescriptor

/** Wrapper around platform specific Bluetooth LE service. Holds a strong reference to underlying service. */
public actual class DiscoveredService : Service {
internal actual val service: PlatformService
get() = jvmNotImplementedException()
public actual val characteristics: List<DiscoveredCharacteristic>
get() = jvmNotImplementedException()
override val serviceUuid: Uuid
get() = jvmNotImplementedException()
}

/** Wrapper around platform specific Bluetooth LE characteristic. Holds a strong reference to underlying characteristic. */
public actual class DiscoveredCharacteristic : Characteristic {
internal actual val characteristic: PlatformCharacteristic
get() = jvmNotImplementedException()
public actual val descriptors: List<DiscoveredDescriptor>
get() = jvmNotImplementedException()
public actual val properties: Characteristic.Properties
get() = jvmNotImplementedException()
override val serviceUuid: Uuid
get() = jvmNotImplementedException()
override val characteristicUuid: Uuid
get() = jvmNotImplementedException()
}

/** Wrapper around platform specific Bluetooth LE descriptor. Holds a strong reference to underlying descriptor. */
public actual class DiscoveredDescriptor : Descriptor {
internal actual val descriptor: PlatformDescriptor
get() = jvmNotImplementedException()
override val serviceUuid: Uuid
get() = jvmNotImplementedException()
override val characteristicUuid: Uuid
get() = jvmNotImplementedException()
override val descriptorUuid: Uuid
get() = jvmNotImplementedException()
}
14 changes: 14 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/ScannerBuilder.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.juul.kable

import com.juul.kable.logs.LoggingBuilder

public actual class ScannerBuilder {

public actual var filters: List<Filter>? = null

public actual fun logging(init: LoggingBuilder) {
jvmNotImplementedException()
}

internal actual fun build(): PlatformScanner = jvmNotImplementedException()
}
3 changes: 3 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/logs/Log.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.juul.kable.logs

internal actual val LOG_INDENT: String? = " "
30 changes: 30 additions & 0 deletions core/src/jvmMain/kotlin/com/juul/kable/logs/SystemLogEngine.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.juul.kable.logs

import com.juul.kable.jvmNotImplementedException

public actual object SystemLogEngine : LogEngine {

override fun verbose(throwable: Throwable?, tag: String, message: String) {
jvmNotImplementedException()
}

override fun debug(throwable: Throwable?, tag: String, message: String) {
jvmNotImplementedException()
}

override fun info(throwable: Throwable?, tag: String, message: String) {
jvmNotImplementedException()
}

override fun warn(throwable: Throwable?, tag: String, message: String) {
jvmNotImplementedException()
}

override fun error(throwable: Throwable?, tag: String, message: String) {
jvmNotImplementedException()
}

override fun assert(throwable: Throwable?, tag: String, message: String) {
jvmNotImplementedException()
}
}
14 changes: 14 additions & 0 deletions log-engine-tuulbox/api/jvm/log-engine-tuulbox.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public final class com/juul/kable/logs/Kable : com/juul/tuulbox/logging/Key {
public static final field INSTANCE Lcom/juul/kable/logs/Kable;
}

public final class com/juul/kable/logs/TuulboxLogEngine : com/juul/kable/logs/LogEngine, com/juul/tuulbox/logging/HideFromStackTraceTag {
public static final field INSTANCE Lcom/juul/kable/logs/TuulboxLogEngine;
public fun assert (Ljava/lang/Throwable;Ljava/lang/String;Ljava/lang/String;)V
public fun debug (Ljava/lang/Throwable;Ljava/lang/String;Ljava/lang/String;)V
public fun error (Ljava/lang/Throwable;Ljava/lang/String;Ljava/lang/String;)V
public fun info (Ljava/lang/Throwable;Ljava/lang/String;Ljava/lang/String;)V
public fun verbose (Ljava/lang/Throwable;Ljava/lang/String;Ljava/lang/String;)V
public fun warn (Ljava/lang/Throwable;Ljava/lang/String;Ljava/lang/String;)V
}

1 change: 1 addition & 0 deletions log-engine-tuulbox/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ kotlin {
js().browser()
macosArm64()
macosX64()
jvm()

sourceSets {
commonMain.dependencies {
Expand Down

0 comments on commit c3c8adc

Please sign in to comment.