diff --git a/build.gradle.kts b/build.gradle.kts index bf84b41..fddaf72 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,19 +1,17 @@ -import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl plugins { - kotlin("multiplatform") version "2.0.20" + kotlin("multiplatform") version "1.7.20" `maven-publish` } group = "ru.landgrafhomyak.kotlin.utilities" -version = "v1.0k2.0.20" +version = "v1.0k1.7.20" repositories { mavenCentral() maven("https://maven.landgrafhomyak.ru/") } -@OptIn(ExperimentalWasmDsl::class) kotlin { explicitApi() @@ -24,24 +22,21 @@ kotlin { browser() nodejs() } - wasmWasi { - nodejs() - } - wasmJs { - nodejs() - browser() - d8() - } macosArm64() macosX64() + linuxArm32Hfp() + linuxMips32() + linuxMipsel32() linuxArm64() linuxX64() + mingwX86() mingwX64() androidNativeArm32() androidNativeArm64() androidNativeX64() androidNativeX86() + iosArm32() iosArm64() iosSimulatorArm64() iosX64() @@ -51,7 +46,6 @@ kotlin { watchosX64() watchosArm32() watchosArm64() - watchosDeviceArm64() watchosSimulatorArm64() sourceSets { @@ -67,7 +61,7 @@ publishing { repositories { maven { name = "XomrkMaven" - url = uri("https://maven.landgrafhomyak.ru/") + url = uri("https://git.landgrafhomyak.ru/api/packages/xomrk/maven") credentials(HttpHeaderCredentials::class) { name = "Authorization" diff --git a/gradle.properties b/gradle.properties index 7fc6f1f..5e92bf3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ kotlin.code.style=official +kotlin.internal.mpp.hierarchicalStructureByDefault=true \ No newline at end of file diff --git a/src/wasmJsMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt b/src/iosArm32Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt similarity index 93% rename from src/wasmJsMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt rename to src/iosArm32Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt index e888574..64c8984 100644 --- a/src/wasmJsMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt +++ b/src/iosArm32Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt @@ -53,10 +53,10 @@ public actual object KotlinPlatforms1 { */ public actual inline fun ifNative(native: () -> R, notNative: () -> R): R { contract { - callsInPlace(notNative, InvocationKind.EXACTLY_ONCE) + callsInPlace(native, InvocationKind.EXACTLY_ONCE) } - return notNative() + return native() } /** @@ -64,10 +64,10 @@ public actual object KotlinPlatforms1 { */ public actual inline fun ifNative32(is32: () -> R, not32: () -> R): R { contract { - callsInPlace(not32, InvocationKind.EXACTLY_ONCE) + callsInPlace(is32, InvocationKind.EXACTLY_ONCE) } - return not32() + return is32() } /** @@ -97,10 +97,10 @@ public actual object KotlinPlatforms1 { */ public actual inline fun ifNativeArm(arm: () -> R, notArm: () -> R): R { contract { - callsInPlace(notArm, InvocationKind.EXACTLY_ONCE) + callsInPlace(arm, InvocationKind.EXACTLY_ONCE) } - return notArm() + return arm() } /** @@ -165,10 +165,10 @@ public actual object KotlinPlatforms1 { */ public actual inline fun ifNativeIos(ios: () -> R, notIos: () -> R): R { contract { - callsInPlace(notIos, InvocationKind.EXACTLY_ONCE) + callsInPlace(ios, InvocationKind.EXACTLY_ONCE) } - return notIos() + return ios() } /** @@ -176,9 +176,9 @@ public actual object KotlinPlatforms1 { */ public actual inline fun ifAnyWasm(wasm: () -> R, notWasm: () -> R): R { contract { - callsInPlace(wasm, InvocationKind.EXACTLY_ONCE) + callsInPlace(notWasm, InvocationKind.EXACTLY_ONCE) } - return wasm() + return notWasm() } } \ No newline at end of file diff --git a/src/linuxArm32HfpMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt b/src/linuxArm32HfpMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt new file mode 100644 index 0000000..59eb24f --- /dev/null +++ b/src/linuxArm32HfpMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt @@ -0,0 +1,184 @@ +package ru.landrafhomyak.kotlin.multiplatform_switches + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + +/** + * Utility class containing intrinsics for compiling platform-specific calls in simple cases without the actual/expect mechanism. + * + * All used symbols should be accessible in common (not necessary "commonMain" but any other set that commonizes several targets). + */ +@OptIn(ExperimentalContracts::class) +public actual object KotlinPlatforms1 { + /** + * Calls [jvm] if function called in code compiled for **Kotlin/JVM** and [notJvm] for all other targets (including **Kotlin/Android**). + */ + public actual inline fun ifJvm(jvm: () -> R, notJvm: () -> R): R { + contract { + callsInPlace(notJvm, InvocationKind.EXACTLY_ONCE) + } + + return notJvm() + } + + /** + * Calls [java] if function called in code compiled for **Kotlin/JVM**, **Kotlin/Android** or whatever platform in future that compiles to java, otherwise calls [notJava]. + * + * To clarify which target being compiled, recursively use functions like [ifJvm][KotlinPlatforms1.ifJvm], [ifAnyAndroid][KotlinPlatforms1.ifAnyAndroid] and others. + */ + public actual inline fun ifAnyJava(java: () -> R, notJava: () -> R): R { + contract { + callsInPlace(notJava, InvocationKind.EXACTLY_ONCE) + } + + return notJava() + } + + /** + * Calls [android] if function called in code compiled for **Kotlin/Android** and **Kotlin/Native** for the android platform, otherwise calls [notAndroid]. + * + * To determine which **Kotlin/Android** target being compiled, recursively use functions like [ifNative][KotlinPlatforms1.ifNative], [ifAnyJava][KotlinPlatforms1.ifAnyJava] and others. + */ + public actual inline fun ifAnyAndroid(android: () -> R, notAndroid: () -> R): R { + contract { + callsInPlace(notAndroid, InvocationKind.EXACTLY_ONCE) + } + + return notAndroid() + } + + /** + * Calls [native] if function called in code compiled for any **Kotlin/Native** target, otherwise calls [notNative]. + */ + public actual inline fun ifNative(native: () -> R, notNative: () -> R): R { + contract { + callsInPlace(native, InvocationKind.EXACTLY_ONCE) + } + + return native() + } + + /** + * Calls [is32] if function called in code compiled for 32-bit **Kotlin/Native** target, otherwise calls [not32]. + */ + public actual inline fun ifNative32(is32: () -> R, not32: () -> R): R { + contract { + callsInPlace(is32, InvocationKind.EXACTLY_ONCE) + } + + return is32() + } + + /** + * Calls [is64] if function called in code compiled for 64-bit **Kotlin/Native** target, otherwise calls [not64]. + */ + public actual inline fun ifNative64(is64: () -> R, not64: () -> R): R { + contract { + callsInPlace(not64, InvocationKind.EXACTLY_ONCE) + } + + return not64() + } + + /** + * Calls [intel] if function called in code compiled for **Intel X86** or **AMD x86-64** **Kotlin/Native** target, otherwise calls [notIntel]. + */ + public actual inline fun ifNativeIntel(intel: () -> R, notIntel: () -> R): R { + contract { + callsInPlace(notIntel, InvocationKind.EXACTLY_ONCE) + } + + return notIntel() + } + + /** + * Calls [arm] if function called in code compiled for any **ARM** **Kotlin/Native** target, otherwise calls [notArm]. + */ + public actual inline fun ifNativeArm(arm: () -> R, notArm: () -> R): R { + contract { + callsInPlace(arm, InvocationKind.EXACTLY_ONCE) + } + + return arm() + } + + /** + * Calls [js] if function called in code compiled for any **Kotlin/JS** target, otherwise calls [notJs]. + */ + public actual inline fun ifAnyJs(js: () -> R, notJs: () -> R): R { + contract { + callsInPlace(notJs, InvocationKind.EXACTLY_ONCE) + } + + return notJs() + } + + /** + * Calls [windows] if function called in code compiled for Microsoft Windows **Kotlin/Native** target, otherwise calls [notWindows]. + */ + public actual inline fun ifNativeWindows(windows: () -> R, notWindows: () -> R): R { + contract { + callsInPlace(notWindows, InvocationKind.EXACTLY_ONCE) + } + + return notWindows() + } + + /** + * Calls [linux] if function called in code compiled for GNU Linux **Kotlin/Native** target, otherwise calls [notLinux]. + * + * On **Kotlin/Android** targets will be called [notLinux]. + */ + public actual inline fun ifNativeLinux(linux: () -> R, notLinux: () -> R): R { + contract { + callsInPlace(linux, InvocationKind.EXACTLY_ONCE) + } + + return linux() + } + + /** + * Calls [macos] if function called in code compiled for Apple Mac OS X **Kotlin/Native** target, otherwise calls [notMacos]. + */ + public actual inline fun ifNativeMacOS(macos: () -> R, notMacos: () -> R): R { + contract { + callsInPlace(notMacos, InvocationKind.EXACTLY_ONCE) + } + + return notMacos() + } + + /** + * Switches to function dependent on OS of **Kotlin/Native** target for which code being compiled. + */ + public actual inline fun switchNativeWindowsLinuxMacos(windows: () -> R, linux: () -> R, macos: () -> R, other: () -> R): R { + contract { + callsInPlace(linux, InvocationKind.EXACTLY_ONCE) + } + + return linux() + } + + /** + * Calls [ios] if function called in code compiled for Apple iOS **Kotlin/Native** target, otherwise calls [notIos]. + */ + public actual inline fun ifNativeIos(ios: () -> R, notIos: () -> R): R { + contract { + callsInPlace(notIos, InvocationKind.EXACTLY_ONCE) + } + + return notIos() + } + + /** + * Calls [wasm] if function called in code compiled for **Kotlin/WASM** target, otherwise calls [notWasm]. + */ + public actual inline fun ifAnyWasm(wasm: () -> R, notWasm: () -> R): R { + contract { + callsInPlace(notWasm, InvocationKind.EXACTLY_ONCE) + } + + return notWasm() + } +} \ No newline at end of file diff --git a/src/wasmWasiMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt b/src/linuxMips32Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt similarity index 93% rename from src/wasmWasiMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt rename to src/linuxMips32Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt index e888574..9df8d06 100644 --- a/src/wasmWasiMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt +++ b/src/linuxMips32Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt @@ -53,10 +53,10 @@ public actual object KotlinPlatforms1 { */ public actual inline fun ifNative(native: () -> R, notNative: () -> R): R { contract { - callsInPlace(notNative, InvocationKind.EXACTLY_ONCE) + callsInPlace(native, InvocationKind.EXACTLY_ONCE) } - return notNative() + return native() } /** @@ -64,10 +64,10 @@ public actual object KotlinPlatforms1 { */ public actual inline fun ifNative32(is32: () -> R, not32: () -> R): R { contract { - callsInPlace(not32, InvocationKind.EXACTLY_ONCE) + callsInPlace(is32, InvocationKind.EXACTLY_ONCE) } - return not32() + return is32() } /** @@ -132,10 +132,10 @@ public actual object KotlinPlatforms1 { */ public actual inline fun ifNativeLinux(linux: () -> R, notLinux: () -> R): R { contract { - callsInPlace(notLinux, InvocationKind.EXACTLY_ONCE) + callsInPlace(linux, InvocationKind.EXACTLY_ONCE) } - return notLinux() + return linux() } /** @@ -154,10 +154,10 @@ public actual object KotlinPlatforms1 { */ public actual inline fun switchNativeWindowsLinuxMacos(windows: () -> R, linux: () -> R, macos: () -> R, other: () -> R): R { contract { - callsInPlace(other, InvocationKind.EXACTLY_ONCE) + callsInPlace(linux, InvocationKind.EXACTLY_ONCE) } - return other() + return linux() } /** @@ -176,9 +176,9 @@ public actual object KotlinPlatforms1 { */ public actual inline fun ifAnyWasm(wasm: () -> R, notWasm: () -> R): R { contract { - callsInPlace(wasm, InvocationKind.EXACTLY_ONCE) + callsInPlace(notWasm, InvocationKind.EXACTLY_ONCE) } - return wasm() + return notWasm() } } \ No newline at end of file diff --git a/src/linuxMipsel32Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt b/src/linuxMipsel32Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt new file mode 100644 index 0000000..9df8d06 --- /dev/null +++ b/src/linuxMipsel32Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt @@ -0,0 +1,184 @@ +package ru.landrafhomyak.kotlin.multiplatform_switches + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + +/** + * Utility class containing intrinsics for compiling platform-specific calls in simple cases without the actual/expect mechanism. + * + * All used symbols should be accessible in common (not necessary "commonMain" but any other set that commonizes several targets). + */ +@OptIn(ExperimentalContracts::class) +public actual object KotlinPlatforms1 { + /** + * Calls [jvm] if function called in code compiled for **Kotlin/JVM** and [notJvm] for all other targets (including **Kotlin/Android**). + */ + public actual inline fun ifJvm(jvm: () -> R, notJvm: () -> R): R { + contract { + callsInPlace(notJvm, InvocationKind.EXACTLY_ONCE) + } + + return notJvm() + } + + /** + * Calls [java] if function called in code compiled for **Kotlin/JVM**, **Kotlin/Android** or whatever platform in future that compiles to java, otherwise calls [notJava]. + * + * To clarify which target being compiled, recursively use functions like [ifJvm][KotlinPlatforms1.ifJvm], [ifAnyAndroid][KotlinPlatforms1.ifAnyAndroid] and others. + */ + public actual inline fun ifAnyJava(java: () -> R, notJava: () -> R): R { + contract { + callsInPlace(notJava, InvocationKind.EXACTLY_ONCE) + } + + return notJava() + } + + /** + * Calls [android] if function called in code compiled for **Kotlin/Android** and **Kotlin/Native** for the android platform, otherwise calls [notAndroid]. + * + * To determine which **Kotlin/Android** target being compiled, recursively use functions like [ifNative][KotlinPlatforms1.ifNative], [ifAnyJava][KotlinPlatforms1.ifAnyJava] and others. + */ + public actual inline fun ifAnyAndroid(android: () -> R, notAndroid: () -> R): R { + contract { + callsInPlace(notAndroid, InvocationKind.EXACTLY_ONCE) + } + + return notAndroid() + } + + /** + * Calls [native] if function called in code compiled for any **Kotlin/Native** target, otherwise calls [notNative]. + */ + public actual inline fun ifNative(native: () -> R, notNative: () -> R): R { + contract { + callsInPlace(native, InvocationKind.EXACTLY_ONCE) + } + + return native() + } + + /** + * Calls [is32] if function called in code compiled for 32-bit **Kotlin/Native** target, otherwise calls [not32]. + */ + public actual inline fun ifNative32(is32: () -> R, not32: () -> R): R { + contract { + callsInPlace(is32, InvocationKind.EXACTLY_ONCE) + } + + return is32() + } + + /** + * Calls [is64] if function called in code compiled for 64-bit **Kotlin/Native** target, otherwise calls [not64]. + */ + public actual inline fun ifNative64(is64: () -> R, not64: () -> R): R { + contract { + callsInPlace(not64, InvocationKind.EXACTLY_ONCE) + } + + return not64() + } + + /** + * Calls [intel] if function called in code compiled for **Intel X86** or **AMD x86-64** **Kotlin/Native** target, otherwise calls [notIntel]. + */ + public actual inline fun ifNativeIntel(intel: () -> R, notIntel: () -> R): R { + contract { + callsInPlace(notIntel, InvocationKind.EXACTLY_ONCE) + } + + return notIntel() + } + + /** + * Calls [arm] if function called in code compiled for any **ARM** **Kotlin/Native** target, otherwise calls [notArm]. + */ + public actual inline fun ifNativeArm(arm: () -> R, notArm: () -> R): R { + contract { + callsInPlace(notArm, InvocationKind.EXACTLY_ONCE) + } + + return notArm() + } + + /** + * Calls [js] if function called in code compiled for any **Kotlin/JS** target, otherwise calls [notJs]. + */ + public actual inline fun ifAnyJs(js: () -> R, notJs: () -> R): R { + contract { + callsInPlace(notJs, InvocationKind.EXACTLY_ONCE) + } + + return notJs() + } + + /** + * Calls [windows] if function called in code compiled for Microsoft Windows **Kotlin/Native** target, otherwise calls [notWindows]. + */ + public actual inline fun ifNativeWindows(windows: () -> R, notWindows: () -> R): R { + contract { + callsInPlace(notWindows, InvocationKind.EXACTLY_ONCE) + } + + return notWindows() + } + + /** + * Calls [linux] if function called in code compiled for GNU Linux **Kotlin/Native** target, otherwise calls [notLinux]. + * + * On **Kotlin/Android** targets will be called [notLinux]. + */ + public actual inline fun ifNativeLinux(linux: () -> R, notLinux: () -> R): R { + contract { + callsInPlace(linux, InvocationKind.EXACTLY_ONCE) + } + + return linux() + } + + /** + * Calls [macos] if function called in code compiled for Apple Mac OS X **Kotlin/Native** target, otherwise calls [notMacos]. + */ + public actual inline fun ifNativeMacOS(macos: () -> R, notMacos: () -> R): R { + contract { + callsInPlace(notMacos, InvocationKind.EXACTLY_ONCE) + } + + return notMacos() + } + + /** + * Switches to function dependent on OS of **Kotlin/Native** target for which code being compiled. + */ + public actual inline fun switchNativeWindowsLinuxMacos(windows: () -> R, linux: () -> R, macos: () -> R, other: () -> R): R { + contract { + callsInPlace(linux, InvocationKind.EXACTLY_ONCE) + } + + return linux() + } + + /** + * Calls [ios] if function called in code compiled for Apple iOS **Kotlin/Native** target, otherwise calls [notIos]. + */ + public actual inline fun ifNativeIos(ios: () -> R, notIos: () -> R): R { + contract { + callsInPlace(notIos, InvocationKind.EXACTLY_ONCE) + } + + return notIos() + } + + /** + * Calls [wasm] if function called in code compiled for **Kotlin/WASM** target, otherwise calls [notWasm]. + */ + public actual inline fun ifAnyWasm(wasm: () -> R, notWasm: () -> R): R { + contract { + callsInPlace(notWasm, InvocationKind.EXACTLY_ONCE) + } + + return notWasm() + } +} \ No newline at end of file diff --git a/src/mingwMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt b/src/mingwX64Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt similarity index 100% rename from src/mingwMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt rename to src/mingwX64Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt diff --git a/src/mingwX86Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt b/src/mingwX86Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt new file mode 100644 index 0000000..ffd34f1 --- /dev/null +++ b/src/mingwX86Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt @@ -0,0 +1,184 @@ +package ru.landrafhomyak.kotlin.multiplatform_switches + +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + +/** + * Utility class containing intrinsics for compiling platform-specific calls in simple cases without the actual/expect mechanism. + * + * All used symbols should be accessible in common (not necessary "commonMain" but any other set that commonizes several targets). + */ +@OptIn(ExperimentalContracts::class) +public actual object KotlinPlatforms1 { + /** + * Calls [jvm] if function called in code compiled for **Kotlin/JVM** and [notJvm] for all other targets (including **Kotlin/Android**). + */ + public actual inline fun ifJvm(jvm: () -> R, notJvm: () -> R): R { + contract { + callsInPlace(notJvm, InvocationKind.EXACTLY_ONCE) + } + + return notJvm() + } + + /** + * Calls [java] if function called in code compiled for **Kotlin/JVM**, **Kotlin/Android** or whatever platform in future that compiles to java, otherwise calls [notJava]. + * + * To clarify which target being compiled, recursively use functions like [ifJvm][KotlinPlatforms1.ifJvm], [ifAnyAndroid][KotlinPlatforms1.ifAnyAndroid] and others. + */ + public actual inline fun ifAnyJava(java: () -> R, notJava: () -> R): R { + contract { + callsInPlace(notJava, InvocationKind.EXACTLY_ONCE) + } + + return notJava() + } + + /** + * Calls [android] if function called in code compiled for **Kotlin/Android** and **Kotlin/Native** for the android platform, otherwise calls [notAndroid]. + * + * To determine which **Kotlin/Android** target being compiled, recursively use functions like [ifNative][KotlinPlatforms1.ifNative], [ifAnyJava][KotlinPlatforms1.ifAnyJava] and others. + */ + public actual inline fun ifAnyAndroid(android: () -> R, notAndroid: () -> R): R { + contract { + callsInPlace(notAndroid, InvocationKind.EXACTLY_ONCE) + } + + return notAndroid() + } + + /** + * Calls [native] if function called in code compiled for any **Kotlin/Native** target, otherwise calls [notNative]. + */ + public actual inline fun ifNative(native: () -> R, notNative: () -> R): R { + contract { + callsInPlace(native, InvocationKind.EXACTLY_ONCE) + } + + return native() + } + + /** + * Calls [is32] if function called in code compiled for 32-bit **Kotlin/Native** target, otherwise calls [not32]. + */ + public actual inline fun ifNative32(is32: () -> R, not32: () -> R): R { + contract { + callsInPlace(is32, InvocationKind.EXACTLY_ONCE) + } + + return is32() + } + + /** + * Calls [is64] if function called in code compiled for 64-bit **Kotlin/Native** target, otherwise calls [not64]. + */ + public actual inline fun ifNative64(is64: () -> R, not64: () -> R): R { + contract { + callsInPlace(not64, InvocationKind.EXACTLY_ONCE) + } + + return not64() + } + + /** + * Calls [intel] if function called in code compiled for **Intel X86** or **AMD x86-64** **Kotlin/Native** target, otherwise calls [notIntel]. + */ + public actual inline fun ifNativeIntel(intel: () -> R, notIntel: () -> R): R { + contract { + callsInPlace(intel, InvocationKind.EXACTLY_ONCE) + } + + return intel() + } + + /** + * Calls [arm] if function called in code compiled for any **ARM** **Kotlin/Native** target, otherwise calls [notArm]. + */ + public actual inline fun ifNativeArm(arm: () -> R, notArm: () -> R): R { + contract { + callsInPlace(notArm, InvocationKind.EXACTLY_ONCE) + } + + return notArm() + } + + /** + * Calls [js] if function called in code compiled for any **Kotlin/JS** target, otherwise calls [notJs]. + */ + public actual inline fun ifAnyJs(js: () -> R, notJs: () -> R): R { + contract { + callsInPlace(notJs, InvocationKind.EXACTLY_ONCE) + } + + return notJs() + } + + /** + * Calls [windows] if function called in code compiled for Microsoft Windows **Kotlin/Native** target, otherwise calls [notWindows]. + */ + public actual inline fun ifNativeWindows(windows: () -> R, notWindows: () -> R): R { + contract { + callsInPlace(windows, InvocationKind.EXACTLY_ONCE) + } + + return windows() + } + + /** + * Calls [linux] if function called in code compiled for GNU Linux **Kotlin/Native** target, otherwise calls [notLinux]. + * + * On **Kotlin/Android** targets will be called [notLinux]. + */ + public actual inline fun ifNativeLinux(linux: () -> R, notLinux: () -> R): R { + contract { + callsInPlace(notLinux, InvocationKind.EXACTLY_ONCE) + } + + return notLinux() + } + + /** + * Calls [macos] if function called in code compiled for Apple Mac OS X **Kotlin/Native** target, otherwise calls [notMacos]. + */ + public actual inline fun ifNativeMacOS(macos: () -> R, notMacos: () -> R): R { + contract { + callsInPlace(notMacos, InvocationKind.EXACTLY_ONCE) + } + + return notMacos() + } + + /** + * Switches to function dependent on OS of **Kotlin/Native** target for which code being compiled. + */ + public actual inline fun switchNativeWindowsLinuxMacos(windows: () -> R, linux: () -> R, macos: () -> R, other: () -> R): R { + contract { + callsInPlace(windows, InvocationKind.EXACTLY_ONCE) + } + + return windows() + } + + /** + * Calls [ios] if function called in code compiled for Apple iOS **Kotlin/Native** target, otherwise calls [notIos]. + */ + public actual inline fun ifNativeIos(ios: () -> R, notIos: () -> R): R { + contract { + callsInPlace(notIos, InvocationKind.EXACTLY_ONCE) + } + + return notIos() + } + + /** + * Calls [wasm] if function called in code compiled for **Kotlin/WASM** target, otherwise calls [notWasm]. + */ + public actual inline fun ifAnyWasm(wasm: () -> R, notWasm: () -> R): R { + contract { + callsInPlace(notWasm, InvocationKind.EXACTLY_ONCE) + } + + return notWasm() + } +} \ No newline at end of file diff --git a/src/watchosDeviceArm64Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt b/src/tvosArm64Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt similarity index 100% rename from src/watchosDeviceArm64Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt rename to src/tvosArm64Main/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/KotlinPlatforms1.kt