Compare commits
2 Commits
master/k1.
...
master/k2.
Author | SHA1 | Date | |
---|---|---|---|
77f99c6e59 | |||
f55bea6bcc |
@ -1,76 +1,40 @@
|
|||||||
|
import ru.landgrafhomyak.kotlin.kmp_gradle_build_helper.defineAllMultiplatformTargets
|
||||||
|
import ru.landgrafhomyak.kotlin.kmp_gradle_build_helper.optInContracts
|
||||||
|
import ru.landgrafhomyak.kotlin.kmp_gradle_build_helper.defineXomrkGiteaMavenRepo
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
maven("https://maven.landgrafhomyak.ru/")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("ru.landgrafhomyak.kotlin:kotlin-mpp-gradle-build-helper:v0.1k2.0.20")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform") version "1.7.20"
|
kotlin("multiplatform") version "2.0.20"
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "ru.landgrafhomyak.kotlin.utilities"
|
group = "ru.landgrafhomyak.kotlin"
|
||||||
version = "v1.0k1.7.20"
|
version = "v1.0k2.0.20"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven("https://maven.landgrafhomyak.ru/")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
explicitApi()
|
explicitApi()
|
||||||
|
|
||||||
jvmToolchain(8)
|
jvmToolchain(8)
|
||||||
jvm {
|
optInContracts()
|
||||||
}
|
defineAllMultiplatformTargets()
|
||||||
js(IR) {
|
|
||||||
browser()
|
|
||||||
nodejs()
|
|
||||||
}
|
|
||||||
|
|
||||||
macosArm64()
|
|
||||||
macosX64()
|
|
||||||
linuxArm32Hfp()
|
|
||||||
linuxMips32()
|
|
||||||
linuxMipsel32()
|
|
||||||
linuxArm64()
|
|
||||||
linuxX64()
|
|
||||||
mingwX86()
|
|
||||||
mingwX64()
|
|
||||||
androidNativeArm32()
|
|
||||||
androidNativeArm64()
|
|
||||||
androidNativeX64()
|
|
||||||
androidNativeX86()
|
|
||||||
iosArm32()
|
|
||||||
iosArm64()
|
|
||||||
iosSimulatorArm64()
|
|
||||||
iosX64()
|
|
||||||
tvosX64()
|
|
||||||
tvosArm64()
|
|
||||||
tvosSimulatorArm64()
|
|
||||||
watchosX64()
|
|
||||||
watchosArm32()
|
|
||||||
watchosArm64()
|
|
||||||
watchosSimulatorArm64()
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
commonMain {
|
|
||||||
dependencies {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
// other settings of publication
|
// other settings of publication
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
defineXomrkGiteaMavenRepo()
|
||||||
name = "XomrkMaven"
|
|
||||||
url = uri("https://git.landgrafhomyak.ru/api/packages/xomrk/maven")
|
|
||||||
|
|
||||||
credentials(HttpHeaderCredentials::class) {
|
|
||||||
name = "Authorization"
|
|
||||||
value = "token ${System.getenv("XOMRK_MAVEN_REPO_DEPLOY_TOKEN")}"
|
|
||||||
}
|
|
||||||
|
|
||||||
authentication {
|
|
||||||
create<HttpHeaderAuthentication>("header")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,2 +1,2 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin.internal.mpp.hierarchicalStructureByDefault=true
|
kotlin.native.ignoreDisabledTargets=true
|
@ -1,184 +0,0 @@
|
|||||||
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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> ifAnyWasm(wasm: () -> R, notWasm: () -> R): R {
|
|
||||||
contract {
|
|
||||||
callsInPlace(notWasm, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
|
|
||||||
return notWasm()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,184 +0,0 @@
|
|||||||
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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> ifAnyWasm(wasm: () -> R, notWasm: () -> R): R {
|
|
||||||
contract {
|
|
||||||
callsInPlace(notWasm, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
|
|
||||||
return notWasm()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,184 +0,0 @@
|
|||||||
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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> 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 <R> ifAnyWasm(wasm: () -> R, notWasm: () -> R): R {
|
|
||||||
contract {
|
|
||||||
callsInPlace(notWasm, InvocationKind.EXACTLY_ONCE)
|
|
||||||
}
|
|
||||||
|
|
||||||
return notWasm()
|
|
||||||
}
|
|
||||||
}
|
|
@ -53,10 +53,10 @@ public actual object KotlinPlatforms1 {
|
|||||||
*/
|
*/
|
||||||
public actual inline fun <R> ifNative(native: () -> R, notNative: () -> R): R {
|
public actual inline fun <R> ifNative(native: () -> R, notNative: () -> R): R {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(native, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(notNative, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return native()
|
return notNative()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,10 +64,10 @@ public actual object KotlinPlatforms1 {
|
|||||||
*/
|
*/
|
||||||
public actual inline fun <R> ifNative32(is32: () -> R, not32: () -> R): R {
|
public actual inline fun <R> ifNative32(is32: () -> R, not32: () -> R): R {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(is32, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(not32, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return is32()
|
return not32()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,10 +97,10 @@ public actual object KotlinPlatforms1 {
|
|||||||
*/
|
*/
|
||||||
public actual inline fun <R> ifNativeArm(arm: () -> R, notArm: () -> R): R {
|
public actual inline fun <R> ifNativeArm(arm: () -> R, notArm: () -> R): R {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(arm, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(notArm, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return arm()
|
return notArm()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -165,10 +165,10 @@ public actual object KotlinPlatforms1 {
|
|||||||
*/
|
*/
|
||||||
public actual inline fun <R> ifNativeIos(ios: () -> R, notIos: () -> R): R {
|
public actual inline fun <R> ifNativeIos(ios: () -> R, notIos: () -> R): R {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(ios, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(notIos, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ios()
|
return notIos()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,9 +176,9 @@ public actual object KotlinPlatforms1 {
|
|||||||
*/
|
*/
|
||||||
public actual inline fun <R> ifAnyWasm(wasm: () -> R, notWasm: () -> R): R {
|
public actual inline fun <R> ifAnyWasm(wasm: () -> R, notWasm: () -> R): R {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(notWasm, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(wasm, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return notWasm()
|
return wasm()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -53,10 +53,10 @@ public actual object KotlinPlatforms1 {
|
|||||||
*/
|
*/
|
||||||
public actual inline fun <R> ifNative(native: () -> R, notNative: () -> R): R {
|
public actual inline fun <R> ifNative(native: () -> R, notNative: () -> R): R {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(native, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(notNative, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return native()
|
return notNative()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,10 +64,10 @@ public actual object KotlinPlatforms1 {
|
|||||||
*/
|
*/
|
||||||
public actual inline fun <R> ifNative32(is32: () -> R, not32: () -> R): R {
|
public actual inline fun <R> ifNative32(is32: () -> R, not32: () -> R): R {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(is32, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(not32, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return is32()
|
return not32()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,10 +132,10 @@ public actual object KotlinPlatforms1 {
|
|||||||
*/
|
*/
|
||||||
public actual inline fun <R> ifNativeLinux(linux: () -> R, notLinux: () -> R): R {
|
public actual inline fun <R> ifNativeLinux(linux: () -> R, notLinux: () -> R): R {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(linux, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(notLinux, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return linux()
|
return notLinux()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,10 +154,10 @@ public actual object KotlinPlatforms1 {
|
|||||||
*/
|
*/
|
||||||
public actual inline fun <R> switchNativeWindowsLinuxMacos(windows: () -> R, linux: () -> R, macos: () -> R, other: () -> R): R {
|
public actual inline fun <R> switchNativeWindowsLinuxMacos(windows: () -> R, linux: () -> R, macos: () -> R, other: () -> R): R {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(linux, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(other, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return linux()
|
return other()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,9 +176,9 @@ public actual object KotlinPlatforms1 {
|
|||||||
*/
|
*/
|
||||||
public actual inline fun <R> ifAnyWasm(wasm: () -> R, notWasm: () -> R): R {
|
public actual inline fun <R> ifAnyWasm(wasm: () -> R, notWasm: () -> R): R {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(notWasm, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(wasm, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return notWasm()
|
return wasm()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user