Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
Simplify project structure so any source set has only one parent
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz-invideo committed Mar 2, 2022
1 parent 8a78882 commit d66797b
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 10 deletions.
18 changes: 8 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ subprojects {
}
}

fun createPairSourceSet(name: String, vararg dependencies: PairSourceSet, block: org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet.(test: Boolean) -> Unit = { }): PairSourceSet {
//fun createPairSourceSet(name: String, vararg dependencies: PairSourceSet, block: org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet.(test: Boolean) -> Unit = { }): PairSourceSet {
fun createPairSourceSet(name: String, dependency: PairSourceSet? = null, block: org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet.(test: Boolean) -> Unit = { }): PairSourceSet { val dependencies = listOfNotNull(dependency)
//println("${project.name}: CREATED SOURCE SET: \"${name}Main\"")
val main = maybeCreate("${name}Main").apply { block(false) }
val test = maybeCreate("${name}Test").apply { block(true) }
Expand All @@ -366,14 +367,11 @@ subprojects {
}

val concurrent = createPairSourceSet("concurrent", common)
val nonNativeCommon = createPairSourceSet("nonNativeCommon", common)
val nonJs = createPairSourceSet("nonJs", common)
val nonJvm = createPairSourceSet("nonJvm", common)
val jvmAndroid = createPairSourceSet("jvmAndroid", common)
val jvmAndroid = createPairSourceSet("jvmAndroid", concurrent)

// Default source set for JVM-specific sources and dependencies:
// JVM-specific tests and their dependencies:
val jvm = createPairSourceSet("jvm", concurrent, nonNativeCommon, nonJs, jvmAndroid) { test ->
val jvm = createPairSourceSet("jvm", jvmAndroid) { test ->
dependencies {
if (test) {
implementation(kotlin("test-junit"))
Expand All @@ -384,7 +382,7 @@ subprojects {
}

if (hasAndroid) {
val android = createPairSourceSet("android", concurrent, nonNativeCommon, nonJs, jvmAndroid) { test ->
val android = createPairSourceSet("android", jvmAndroid) { test ->
dependencies {
if (test) {
//implementation(kotlin("test"))
Expand All @@ -398,7 +396,7 @@ subprojects {
}
}

val js = createPairSourceSet("js", common, nonNativeCommon, nonJvm) { test ->
val js = createPairSourceSet("js", common) { test ->
dependencies {
if (test) {
implementation(kotlin("test-js"))
Expand Down Expand Up @@ -429,7 +427,7 @@ subprojects {
val nativeTargets = nativeTargets()

for (target in nativeTargets) {
val native = createPairSourceSet(target.name, common, nativeCommon, nonJvm, nonJs)
val native = createPairSourceSet(target.name, nativeCommon)
if (target.isDesktop) {
native.dependsOn(nativeDesktop)
}
Expand All @@ -453,7 +451,7 @@ subprojects {

if (doEnableKotlinMobile) {
for (target in mobileTargets()) {
val native = createPairSourceSet(target.name, common, nativeCommon, nonJvm, nonJs)
val native = createPairSourceSet(target.name, nativeCommon)
if (target.isIos) {
native.dependsOn(nativePosixApple)
native.dependsOn(iosCommon)
Expand Down
4 changes: 4 additions & 0 deletions kds/src/jvmAndroidMain/kotlin/com/soywiz/kds/atomic/Frozen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.soywiz.kds.atomic

actual fun <T> kdsFreeze(value: T): T = value
actual fun <T> kdsIsFrozen(value: T): Boolean = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.soywiz.kmem

@PublishedApi internal val EmptyByteArray = ByteArray(1)
@PublishedApi internal val EmptyShortArray = ShortArray(1)
@PublishedApi internal val EmptyIntArray = IntArray(1)
@PublishedApi internal val EmptyFloatArray = FloatArray(1)

public actual class FastByteTransfer actual constructor() {
@PublishedApi internal var ptr: ByteArray = EmptyByteArray

public actual inline operator fun get(index: Int): Byte = ptr[index]
public actual inline operator fun set(index: Int, value: Byte) { ptr[index] = value }
public actual inline fun use(array: ByteArray, block: (FastByteTransfer) -> Unit) {
try {
ptr = array
block(this)
} finally {
ptr = EmptyByteArray
}
}
}

public actual class FastShortTransfer actual constructor() {
@PublishedApi internal var ptr: ShortArray = EmptyShortArray

public actual inline operator fun get(index: Int): Short = ptr[index]
public actual inline operator fun set(index: Int, value: Short) { ptr[index] = value }
public actual inline fun use(array: ShortArray, block: (FastShortTransfer) -> Unit) {
try {
ptr = array
block(this)
} finally {
ptr = EmptyShortArray
}
}
}

public actual class FastIntTransfer actual constructor() {
@PublishedApi internal var ptr: IntArray = EmptyIntArray

public actual inline operator fun get(index: Int): Int = ptr[index]
public actual inline operator fun set(index: Int, value: Int) { ptr[index] = value }
public actual inline fun use(array: IntArray, block: (FastIntTransfer) -> Unit) {
try {
ptr = array
block(this)
} finally {
ptr = EmptyIntArray
}
}
}

public actual class FastFloatTransfer actual constructor() {
@PublishedApi internal var ptr: FloatArray = EmptyFloatArray

public actual inline operator fun get(index: Int): Float = ptr[index]
public actual inline operator fun set(index: Int, value: Float) { ptr[index] = value }
public actual inline fun use(array: FloatArray, block: (FastFloatTransfer) -> Unit) {
try {
ptr = array
block(this)
} finally {
ptr = EmptyFloatArray
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.soywiz.korio.lang

actual object SystemProperties : Properties() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.soywiz.korio.net.ssl

import com.soywiz.korio.util.*

actual fun DefaultSSLProcessor(): SSLProcessor = TODO("DefaultSSLProcessor not implemented in ${OS.rawName}")

0 comments on commit d66797b

Please sign in to comment.