Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New native plugin + use common coroutines
- Loading branch information
1 parent
539d4bd
commit 57fb7b7
Showing
27 changed files
with
125 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
common-client-js/src/main/kotlin/org/kotlinacademy/common/coroutinesJs.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
common-client-jvm/src/main/kotlin/org/kotlinacademy/common/coroutinesJvm.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
apply plugin: 'konan' | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
maven { url 'https://plugins.gradle.org/m2/' } | ||
maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' } | ||
} | ||
|
||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version" | ||
} | ||
|
||
konanArtifacts { | ||
framework('KotlinAcademyCommon', targets: ['iphone', 'iphone_sim']) { | ||
enableDebug true | ||
enableMultiplatform true | ||
} | ||
|
||
apply plugin: 'kotlin-platform-native' | ||
|
||
repositories { | ||
jcenter() | ||
} | ||
|
||
srcDir 'src/main/kotlin' | ||
srcFiles fileTree('../common-native/src/main/kotlin') | ||
sourceSets { | ||
//noinspection GroovyAssignabilityCheck | ||
main { | ||
component { | ||
target "ios_arm64", "ios_arm32", "ios_x64", "macos_x64", "linux_x64", "mingw_x64" | ||
outputKinds = [EXECUTABLE] | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
expectedBy project(':common') | ||
expectedBy project(':common-client') | ||
implementation dep.coroutines_native | ||
} |
42 changes: 42 additions & 0 deletions
42
common-client-native/src/main/kotlin/org/kotlinacademy/DateTimeNative.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.kotlinacademy | ||
|
||
actual data class DateTime( | ||
actual val second: Int, | ||
actual val minute: Int, | ||
actual val hour: Int, | ||
actual val dayOfMonth: Int, | ||
actual val monthOfYear: Int, | ||
actual val year: Int | ||
) : Comparable<DateTime> { | ||
|
||
actual fun toDateFormatString(): String = DATE_FORMAT | ||
.replace("yyyy", year.toString(4)) | ||
.replace("MM", monthOfYear.toString(2)) | ||
.replace("dd", dayOfMonth.toString(2)) | ||
.replace("'T'", "T") | ||
.replace("HH", hour.toString(2)) | ||
.replace("mm", minute.toString(2)) | ||
.replace("ss", second.toString(2)) | ||
|
||
override operator fun compareTo(other: DateTime): Int | ||
= compareValuesBy(this, other, DateTime::year, DateTime::monthOfYear, DateTime::dayOfMonth, DateTime::hour, DateTime::minute, DateTime::second) | ||
|
||
actual operator fun plus(millis: Long): DateTime = this // Sorry | ||
} | ||
|
||
actual fun String.parseDateTime() = DateTime( | ||
substring(17, 19).toInt(), | ||
substring(14, 16).toInt(), | ||
substring(11, 13).toInt(), | ||
substring(8, 10).toInt(), | ||
substring(5, 7).toInt(), | ||
substring(0, 4).toInt() | ||
) | ||
|
||
actual val now: DateTime | ||
get() = DateTime(0, 0, 0, 0, 0, 0) | ||
|
||
private fun Int.toString(minSize: Int): String { | ||
val str = toString() | ||
return if (str.length >= minSize) str else generateSequence { "0" }.take(minSize - str.length).joinToString() + str | ||
} |
20 changes: 20 additions & 0 deletions
20
common-client-native/src/main/kotlin/org/kotlinacademy/SerializableMocksNative.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.kotlinacademy | ||
|
||
actual annotation class Serializable | ||
|
||
actual interface KSerializer<T> { | ||
actual val serialClassDesc: KSerialClassDesc | ||
actual fun save(output: KOutput, obj: T) | ||
actual fun load(input: KInput): T | ||
} | ||
|
||
actual interface KSerialClassDesc | ||
actual open class SerialClassDescImpl: KSerialClassDesc { | ||
actual constructor(name: String) | ||
} | ||
actual abstract class KOutput { | ||
actual abstract fun writeStringValue(value: String) | ||
} | ||
actual abstract class KInput { | ||
actual abstract fun readStringValue(): String | ||
} |
38 changes: 0 additions & 38 deletions
38
common-client-native/src/main/kotlin/org/kotlinacademy/common/ContinuationDispatcher.kt
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
common-client-native/src/main/kotlin/org/kotlinacademy/common/MainQueueDispatcher.kt
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
common-client-native/src/main/kotlin/org/kotlinacademy/common/coroutinesNative.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletions
5
common-client/src/main/kotlin/org/kotlinacademy/common/HttpError.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
package org.kotlinacademy.common | ||
|
||
class HttpError( | ||
val code: Int, | ||
override val message: String | ||
) : Throwable() | ||
class HttpError(val code: Int, override val message: String) : Throwable() |
12 changes: 0 additions & 12 deletions
12
common-client/src/main/kotlin/org/kotlinacademy/common/coroutines.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
common-client/src/main/kotlin/org/kotlinacademy/presentation/BasePresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
common-client/src/main/kotlin/org/kotlinacademy/presentation/feedback/FeedbackPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
common-client/src/main/kotlin/org/kotlinacademy/presentation/info/InfoPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
common-client/src/main/kotlin/org/kotlinacademy/presentation/manager/ManagerPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
common-client/src/main/kotlin/org/kotlinacademy/presentation/news/NewsPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...kotlin/org/kotlinacademy/presentation/notifications/RegisterNotificationTokenPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
common-client/src/main/kotlin/org/kotlinacademy/presentation/puzzler/PuzzlerPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
common-client/src/test/kotlin/org/kotlinacademy/BasePresenterUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.