Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "chore(deps): update kotlin core dependencies to v1.9.0 (#540)" #543

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ kotlin {
* linux mingw macos
*/
sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
}
val commonMain by getting
val commonTest by getting {
dependencies {
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
kotlin = "1.9.0"
kotlin = "1.8.22"
okio = "3.4.0"
serialization = "1.5.1"
diktat = "1.2.5"
kotlinx-cli = "0.3.5"
kotlinx-datetime = "0.4.0"
kotlinx-coroutines = "1.7.2"
kotlinx-coroutines = "1.6.3-native-mt"
junit = "5.10.0"
ktoml = "0.5.0"
multiplatform-diff = "0.4.0"
Expand Down
11 changes: 9 additions & 2 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"*"
],
"excludePackagePatterns": [
"^org\\.jetbrains\\.kotlinx?[.:]",
"^org\\.jetbrains\\.kotlin[.:]",
"^org\\.cqfn\\.diktat[.:]diktat-gradle-plugin"
],
"matchUpdateTypes": [
Expand All @@ -37,10 +37,17 @@
{
"managers": ["gradle"],
"matchPackagePatterns": [
"^org\\.jetbrains\\.kotlinx?[.:]"
"^org\\.jetbrains\\.kotlin[.:]"
],
"groupName": "Kotlin core dependencies",
"groupSlug": "core-kotlin"
},
{
"managers": ["gradle"],
"matchPackagePatterns": [
"^org\\.jetbrains\\.kotlinx:kotlinx-coroutines.*"
],
"versioning": "docker"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,40 @@ enum class CurrentOs {
LINUX, MACOS, UNDEFINED, WINDOWS
}

/**
* Atomic values
*/
expect class AtomicInt(value: Int) {
/**
* @return value
*/
fun get(): Int

/**
* @param delta increments the value_ by delta
* @return the new value
*/
fun addAndGet(delta: Int): Int
}

/**
* Atomic boolean
*/
@Suppress("FUNCTION_BOOLEAN_PREFIX")
expect class AtomicBoolean(value: Boolean) {
/**
* @return value
*/
fun get(): Boolean

/**
* @param expect expected value
* @param update updated value
* @return the result of the comparison
*/
fun compareAndSet(expect: Boolean, update: Boolean): Boolean
}

/**
* Class that holds value and shares atomic reference to the value (native only)
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ package com.saveourtool.save.core.utils

import com.saveourtool.save.core.config.OutputStreamType

actual class AtomicInt actual constructor(value: Int) {
actual fun get(): Int = error("Not implemented for JS")
actual fun addAndGet(delta: Int): Int = error("Not implemented for JS")
}

actual class AtomicBoolean actual constructor(value: Boolean) {
actual fun get(): Boolean = error("Not implemented for JS")
actual fun compareAndSet(expect: Boolean, update: Boolean): Boolean = error("Not implemented for JS")
}

@Suppress("USE_DATA_CLASS")
actual class GenericAtomicReference<T> actual constructor(valueToStore: T) {
private var value: T = valueToStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
"MISSING_KDOC_TOP_LEVEL",
"MISSING_KDOC_ON_FUNCTION",
"FILE_NAME_MATCH_CLASS",
"MatchingDeclarationName",
)

package com.saveourtool.save.core.utils

import com.saveourtool.save.core.config.OutputStreamType

actual typealias AtomicInt = java.util.concurrent.atomic.AtomicInteger

actual typealias AtomicBoolean = java.util.concurrent.atomic.AtomicBoolean

@Suppress("USE_DATA_CLASS")
actual class GenericAtomicReference<T> actual constructor(valueToStore: T) {
private val holder: java.util.concurrent.atomic.AtomicReference<T> = java.util.concurrent.atomic.AtomicReference(valueToStore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import com.saveourtool.save.core.logging.logTrace
import okio.FileSystem
import okio.Path
import okio.Path.Companion.toPath
import platform.posix.FTW
import platform.posix.FTW_DEPTH
import platform.posix.nftw
import platform.posix.remove
import platform.posix.stat

import kotlinx.cinterop.ByteVar
import kotlinx.cinterop.CPointer
import kotlinx.cinterop.staticCFunction
import kotlinx.cinterop.toKString

Expand All @@ -25,8 +29,7 @@ actual val fs: FileSystem = FileSystem.SYSTEM
*/
@Suppress("MAGIC_NUMBER", "MagicNumber")
actual fun FileSystem.myDeleteRecursively(path: Path) {
@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
nftw(path.toString(), staticCFunction { pathName, _, _, _ ->
nftw(path.toString(), staticCFunction<CPointer<ByteVar>?, CPointer<stat>?, Int, CPointer<FTW>?, Int> { pathName, _, _, _ ->
val fileName = pathName!!.toKString()
logTrace("Attempt to delete file $fileName")
remove(fileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE",
"MISSING_KDOC_TOP_LEVEL",
"MISSING_KDOC_ON_FUNCTION",
"FILE_NAME_MATCH_CLASS",
"MatchingDeclarationName",
"FILE_NAME_MATCH_CLASS"
)

package com.saveourtool.save.core.utils
Expand All @@ -15,11 +14,44 @@ import platform.posix.fprintf
import platform.posix.stderr
import platform.posix.stdout

import kotlinx.cinterop.ExperimentalForeignApi
/**
* Atomic values
*/
actual class AtomicInt actual constructor(value: Int) {
private val holder = kotlin.native.concurrent.AtomicInt(value)

/**
* @return value
*/
actual fun get(): Int = holder.value

/**
* @param delta increments the value_ by delta
* @return the new value
*/
actual fun addAndGet(delta: Int): Int = holder.addAndGet(delta)
}

@Suppress("FUNCTION_BOOLEAN_PREFIX")
actual class AtomicBoolean actual constructor(value: Boolean) {
private val holder = kotlin.native.concurrent.AtomicReference(value)

/**
* @return value
*/
actual fun get(): Boolean = holder.value

/**
* @param expect expected value
* @param update updated value
* @return the result of the comparison
*/
actual fun compareAndSet(expect: Boolean, update: Boolean): Boolean = holder.compareAndSet(expect, update)
}

@Suppress("USE_DATA_CLASS")
actual class GenericAtomicReference<T> actual constructor(valueToStore: T) {
private val holder: kotlin.concurrent.AtomicReference<T> = kotlin.concurrent.AtomicReference(valueToStore)
private val holder: kotlin.native.concurrent.AtomicReference<T> = kotlin.native.concurrent.AtomicReference(valueToStore)
actual fun get(): T = holder.value
actual fun set(newValue: T) {
holder.value = newValue
Expand Down Expand Up @@ -72,14 +104,11 @@ actual fun writeToConsole(msg: String, outputType: OutputStreamType) {
* @param msg a message string
* @param output output stream (stdout or stderr)
*/
private fun processStandardStreams(msg: String, output: OutputStreamType) {
@OptIn(ExperimentalForeignApi::class)
fun processStandardStreams(msg: String, output: OutputStreamType) {
val stream = when (output) {
OutputStreamType.STDERR -> stderr
else -> stdout
}
@OptIn(ExperimentalForeignApi::class)
fprintf(stream, msg.escapePercent() + "\n")
@OptIn(ExperimentalForeignApi::class)
fflush(stream)
}
Loading
Loading