Skip to content
Snippets Groups Projects
Verified Commit 075c4c06 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Further tests

parent 00aa4fb3
Branches
No related tags found
1 merge request!2Draft: Jetpack compose rewrite
Pipeline #577 passed
Showing
with 288 additions and 62 deletions
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins { plugins {
id("com.android.application") id("com.android.application")
id("kotlin-android") id("kotlin-android")
...@@ -23,6 +21,10 @@ android { ...@@ -23,6 +21,10 @@ android {
val androidxComposeVersion: String by project.extra val androidxComposeVersion: String by project.extra
kotlinCompilerExtensionVersion = androidxComposeVersion kotlinCompilerExtensionVersion = androidxComposeVersion
} }
kotlinOptions {
useIR = true
}
} }
kapt { kapt {
...@@ -65,7 +67,8 @@ dependencies { ...@@ -65,7 +67,8 @@ dependencies {
implementation("io.coil-kt", "coil", "1.1.1") implementation("io.coil-kt", "coil", "1.1.1")
implementation("dev.chrisbanes.accompanist", "accompanist-coil", "0.5.0") implementation("dev.chrisbanes.accompanist", "accompanist-coil", "0.5.0")
testImplementation("junit", "junit", "4.13.1") val junit4Version: String by project.extra
testImplementation("junit", "junit", junit4Version)
androidTestImplementation("androidx.test.ext", "junit", "1.1.2") androidTestImplementation("androidx.test.ext", "junit", "1.1.2")
androidTestImplementation("androidx.test.espresso", "espresso-core", "3.3.0") androidTestImplementation("androidx.test.espresso", "espresso-core", "3.3.0")
} }
plugins { plugins {
kotlin("jvm") kotlin("jvm")
id("jacoco")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.getByName<JacocoReport>("jacocoTestReport") {
reports {
sourceDirectories.from(fileTree("src/main/kotlin"))
classDirectories.from(fileTree("build/classes"))
xml.destination = File("$buildDir/reports/jacoco/report.xml")
html.isEnabled = true
xml.isEnabled = true
csv.isEnabled = false
}
} }
dependencies { dependencies {
implementation(kotlin("stdlib")) implementation(kotlin("stdlib"))
testImplementation("junit", "junit", "4.13.1") val junit5Version: String by project.extra
testImplementation("org.junit.jupiter", "junit-jupiter-api", junit5Version)
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", junit5Version)
val hamcrestVersion: String by project.extra
testImplementation("org.hamcrest", "hamcrest-library", hamcrestVersion)
} }
...@@ -19,26 +19,7 @@ ...@@ -19,26 +19,7 @@
package de.kuschku.bitflags package de.kuschku.bitflags
import java.util.*
interface Flags<T, U> where U : Flag<T>, U : Enum<U> { interface Flags<T, U> where U : Flag<T>, U : Enum<U> {
operator fun get(value: T): U? operator fun get(value: T): U?
fun all(): Collection<U> val all: Set<U>
}
inline fun <reified T> Flags<*, T>.of(
vararg values: T
) where T: Flag<*>, T: Enum<T> = values.toEnumSet()
inline fun <reified T> Flags<*, T>.of(
values: Collection<T>
) where T: Flag<*>, T: Enum<T> = values.toEnumSet()
inline fun <reified T: Enum<T>> Array<out T>.toEnumSet() =
EnumSet.noneOf(T::class.java).apply {
addAll(this@toEnumSet)
}
inline fun <reified T: Enum<T>> Collection<T>.toEnumSet() =
EnumSet.noneOf(T::class.java).apply {
addAll(this@toEnumSet)
} }
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
import java.util.*
inline fun <reified T> Flags<*, T>.none(): EnumSet<T>
where T : Flag<*>, T : Enum<T> = EnumSet.noneOf(T::class.java)
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
import java.util.*
inline fun <reified T> Flags<*, T>.of(vararg values: T): EnumSet<T>
where T : Flag<*>, T : Enum<T> = values.toEnumSet()
inline fun <reified T> Flags<*, T>.of(values: Collection<T>): EnumSet<T>
where T : Flag<*>, T : Enum<T> = values.toEnumSet()
...@@ -21,6 +21,12 @@ package de.kuschku.bitflags ...@@ -21,6 +21,12 @@ package de.kuschku.bitflags
import java.util.* import java.util.*
inline fun <reified T : Enum<T>> List<T>.toEnumSet(): EnumSet<T> = inline fun <reified T : Enum<T>> Array<out T>.toEnumSet() =
if (this.isEmpty()) EnumSet.noneOf(T::class.java) EnumSet.noneOf(T::class.java).apply {
else EnumSet.of(this.first(), *this.subList(1, this.size).toTypedArray()) addAll(this@toEnumSet)
}
inline fun <reified T : Enum<T>> Collection<T>.toEnumSet() =
EnumSet.noneOf(T::class.java).apply {
addAll(this@toEnumSet)
}
...@@ -24,40 +24,40 @@ import kotlin.experimental.and ...@@ -24,40 +24,40 @@ import kotlin.experimental.and
inline fun <reified T> Flags<Byte, T>.of(value: Byte?): EnumSet<T> where T : Flag<Byte>, T : Enum<T> { inline fun <reified T> Flags<Byte, T>.of(value: Byte?): EnumSet<T> where T : Flag<Byte>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet() if (value == null) return emptyList<T>().toEnumSet()
return this.all().filter { (value and it.value) != 0.toByte() }.toEnumSet() return all.filter { (value and it.value) != 0.toByte() }.toEnumSet()
} }
inline fun <reified T> Flags<UByte, T>.of(value: UByte?): EnumSet<T> where T : Flag<UByte>, T : Enum<T> { inline fun <reified T> Flags<UByte, T>.of(value: UByte?): EnumSet<T> where T : Flag<UByte>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet() if (value == null) return emptyList<T>().toEnumSet()
return this.all().filter { (value and it.value) != 0.toUByte() }.toEnumSet() return all.filter { (value and it.value) != 0.toUByte() }.toEnumSet()
} }
inline fun <reified T> Flags<Short, T>.of(value: Short?): EnumSet<T> where T : Flag<Short>, T : Enum<T> { inline fun <reified T> Flags<Short, T>.of(value: Short?): EnumSet<T> where T : Flag<Short>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet() if (value == null) return emptyList<T>().toEnumSet()
return this.all().filter { (value and it.value) != 0.toShort() }.toEnumSet() return all.filter { (value and it.value) != 0.toShort() }.toEnumSet()
} }
inline fun <reified T> Flags<UShort, T>.of(value: UShort?): EnumSet<T> where T : Flag<UShort>, T : Enum<T> { inline fun <reified T> Flags<UShort, T>.of(value: UShort?): EnumSet<T> where T : Flag<UShort>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet() if (value == null) return emptyList<T>().toEnumSet()
return this.all().filter { (value and it.value) != 0.toUShort() }.toEnumSet() return all.filter { (value and it.value) != 0.toUShort() }.toEnumSet()
} }
inline fun <reified T> Flags<Int, T>.of(value: Int?): EnumSet<T> where T : Flag<Int>, T : Enum<T> { inline fun <reified T> Flags<Int, T>.of(value: Int?): EnumSet<T> where T : Flag<Int>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet() if (value == null) return emptyList<T>().toEnumSet()
return this.all().filter { (value and it.value) != 0 }.toEnumSet() return all.filter { (value and it.value) != 0 }.toEnumSet()
} }
inline fun <reified T> Flags<UInt, T>.of(value: UInt?): EnumSet<T> where T : Flag<UInt>, T : Enum<T> { inline fun <reified T> Flags<UInt, T>.of(value: UInt?): EnumSet<T> where T : Flag<UInt>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet() if (value == null) return emptyList<T>().toEnumSet()
return this.all().filter { (value and it.value) != 0u }.toEnumSet() return all.filter { (value and it.value) != 0u }.toEnumSet()
} }
inline fun <reified T> Flags<Long, T>.of(value: Long?): EnumSet<T> where T : Flag<Long>, T : Enum<T> { inline fun <reified T> Flags<Long, T>.of(value: Long?): EnumSet<T> where T : Flag<Long>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet() if (value == null) return emptyList<T>().toEnumSet()
return this.all().filter { (value and it.value) != 0L }.toEnumSet() return all.filter { (value and it.value) != 0L }.toEnumSet()
} }
inline fun <reified T> Flags<ULong, T>.of(value: ULong?): EnumSet<T> where T : Flag<ULong>, T : Enum<T> { inline fun <reified T> Flags<ULong, T>.of(value: ULong?): EnumSet<T> where T : Flag<ULong>, T : Enum<T> {
if (value == null) return emptyList<T>().toEnumSet() if (value == null) return emptyList<T>().toEnumSet()
return this.all().filter { (value and it.value) != 0uL }.toEnumSet() return all.filter { (value and it.value) != 0uL }.toEnumSet()
} }
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.bitflags
import java.util.*
@JvmName("validValuesUByte")
inline fun <reified T> Flags<UByte, T>.validValues(): EnumSet<T>
where T : Flag<UByte>, T : Enum<T> =
all.filter { it.value != 0.toUByte() }.toEnumSet()
@JvmName("validValuesByte")
inline fun <reified T> Flags<Byte, T>.validValues(): EnumSet<T>
where T : Flag<Byte>, T : Enum<T> =
all.filter { it.value != 0.toByte() }.toEnumSet()
@JvmName("validValuesUShort")
inline fun <reified T> Flags<UShort, T>.validValues(): EnumSet<T>
where T : Flag<UShort>, T : Enum<T> =
all.filter { it.value != 0.toUShort() }.toEnumSet()
@JvmName("validValuesShort")
inline fun <reified T> Flags<Short, T>.validValues(): EnumSet<T>
where T : Flag<Short>, T : Enum<T> =
all.filter { it.value != 0.toShort() }.toEnumSet()
@JvmName("validValuesUInt")
inline fun <reified T> Flags<UInt, T>.validValues(): EnumSet<T>
where T : Flag<UInt>, T : Enum<T> =
all.filter { it.value != 0u }.toEnumSet()
@JvmName("validValuesInt")
inline fun <reified T> Flags<Int, T>.validValues(): EnumSet<T>
where T : Flag<Int>, T : Enum<T> =
all.filter { it.value != 0 }.toEnumSet()
@JvmName("validValuesULong")
inline fun <reified T> Flags<ULong, T>.validValues(): EnumSet<T>
where T : Flag<ULong>, T : Enum<T> =
all.filter { it.value != 0uL }.toEnumSet()
@JvmName("validValuesLong")
inline fun <reified T> Flags<Long, T>.validValues(): EnumSet<T>
where T : Flag<Long>, T : Enum<T> =
all.filter { it.value != 0L }.toEnumSet()
...@@ -41,6 +41,9 @@ allprojects { ...@@ -41,6 +41,9 @@ allprojects {
extra["androidxLifecycleVersion"] = "2.3.0-rc01" extra["androidxLifecycleVersion"] = "2.3.0-rc01"
extra["androidxMultidexVersion"] = "2.0.1" extra["androidxMultidexVersion"] = "2.0.1"
extra["daggerHiltVersion"] = "2.31.2-alpha" extra["daggerHiltVersion"] = "2.31.2-alpha"
extra["hamcrestVersion"] = "2.1"
extra["junit4Version"] = "4.13.1"
extra["junit5Version"] = "5.3.1"
extra["mdcVersion"] = "1.2.1" extra["mdcVersion"] = "1.2.1"
repositories { repositories {
...@@ -56,7 +59,6 @@ allprojects { ...@@ -56,7 +59,6 @@ allprojects {
"-Xopt-in=kotlin.ExperimentalUnsignedTypes" "-Xopt-in=kotlin.ExperimentalUnsignedTypes"
) )
jvmTarget = "1.8" jvmTarget = "1.8"
useIR = true
} }
} }
} }
plugins { plugins {
kotlin("jvm") kotlin("jvm")
jacoco
}
tasks.withType<Test> {
useJUnitPlatform()
}
jacoco {
toolVersion = "0.8.6"
}
tasks.getByName<JacocoReport>("jacocoTestReport") {
reports {
sourceDirectories.from(fileTree("src/main/kotlin"))
xml.destination = File("$buildDir/reports/jacoco/report.xml")
html.isEnabled = true
xml.isEnabled = true
csv.isEnabled = false
}
} }
dependencies { dependencies {
...@@ -7,5 +26,9 @@ dependencies { ...@@ -7,5 +26,9 @@ dependencies {
implementation("org.threeten", "threetenbp", "1.4.0") implementation("org.threeten", "threetenbp", "1.4.0")
api(project(":bitflags")) api(project(":bitflags"))
testImplementation("junit", "junit", "4.13.1") val junit5Version: String by project.extra
testImplementation("org.junit.jupiter", "junit-jupiter-api", junit5Version)
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", junit5Version)
val hamcrestVersion: String by project.extra
testImplementation("org.hamcrest", "hamcrest-library", hamcrestVersion)
} }
...@@ -45,7 +45,7 @@ class FeatureSet internal constructor( ...@@ -45,7 +45,7 @@ class FeatureSet internal constructor(
fun build(vararg features: QuasselFeature) = FeatureSet(features.toSet()) fun build(vararg features: QuasselFeature) = FeatureSet(features.toSet())
fun build(features: Set<QuasselFeature>) = FeatureSet(features) fun build(features: Set<QuasselFeature>) = FeatureSet(features)
fun all() = build(*QuasselFeature.values()) fun all() = build(*QuasselFeature.values())
fun empty() = build() fun none() = build()
private fun parseFeatures(features: LegacyFeatures) = private fun parseFeatures(features: LegacyFeatures) =
features.map(LegacyFeature::feature).toSet() features.map(LegacyFeature::feature).toSet()
......
...@@ -21,6 +21,8 @@ package de.kuschku.libquassel.protocol.features ...@@ -21,6 +21,8 @@ package de.kuschku.libquassel.protocol.features
import de.kuschku.bitflags.Flag import de.kuschku.bitflags.Flag
import de.kuschku.bitflags.Flags import de.kuschku.bitflags.Flags
import de.kuschku.bitflags.toEnumSet
import java.util.*
/** /**
* A list of features that are optional in core and/or client, but need runtime checking * A list of features that are optional in core and/or client, but need runtime checking
...@@ -68,7 +70,7 @@ enum class LegacyFeature( ...@@ -68,7 +70,7 @@ enum class LegacyFeature(
private val values = values().associateBy(LegacyFeature::value) private val values = values().associateBy(LegacyFeature::value)
override fun get(value: UInt) = values[value] override fun get(value: UInt) = values[value]
override fun all() = values.values override val all: LegacyFeatures = values.values.toEnumSet()
} }
} }
......
...@@ -32,7 +32,7 @@ object DateTimeSerializer : QtSerializer<Temporal> { ...@@ -32,7 +32,7 @@ object DateTimeSerializer : QtSerializer<Temporal> {
override val javaType: Class<out Temporal> = Temporal::class.java override val javaType: Class<out Temporal> = Temporal::class.java
override fun serialize(buffer: ChainedByteBuffer, data: Temporal, featureSet: FeatureSet) { override fun serialize(buffer: ChainedByteBuffer, data: Temporal, featureSet: FeatureSet) {
fun serialize(data: LocalDateTime, timeSpec: TimeSpec, offset: ZoneOffset? = null) { fun serialize(data: LocalDateTime, timeSpec: TimeSpec, offset: ZoneOffset?) {
DateSerializer.serialize(buffer, data.toLocalDate(), featureSet) DateSerializer.serialize(buffer, data.toLocalDate(), featureSet)
TimeSerializer.serialize(buffer, data.toLocalTime(), featureSet) TimeSerializer.serialize(buffer, data.toLocalTime(), featureSet)
ByteSerializer.serialize(buffer, timeSpec.value, featureSet) ByteSerializer.serialize(buffer, timeSpec.value, featureSet)
...@@ -43,13 +43,13 @@ object DateTimeSerializer : QtSerializer<Temporal> { ...@@ -43,13 +43,13 @@ object DateTimeSerializer : QtSerializer<Temporal> {
when (data) { when (data) {
is LocalDateTime -> is LocalDateTime ->
serialize(data, TimeSpec.LocalUnknown) serialize(data, TimeSpec.LocalUnknown, null)
is OffsetDateTime -> is OffsetDateTime ->
serialize(data.toLocalDateTime(), TimeSpec.OffsetFromUTC, data.offset) serialize(data.toLocalDateTime(), TimeSpec.OffsetFromUTC, data.offset)
is ZonedDateTime -> is ZonedDateTime ->
serialize(data.toLocalDateTime(), TimeSpec.OffsetFromUTC, data.offset) serialize(data.toLocalDateTime(), TimeSpec.OffsetFromUTC, data.offset)
is Instant -> is Instant ->
serialize(data.atOffset(ZoneOffset.UTC).toLocalDateTime(), TimeSpec.OffsetFromUTC) serialize(data.atOffset(ZoneOffset.UTC).toLocalDateTime(), TimeSpec.UTC, null)
else -> else ->
throw IllegalArgumentException("Unsupported Format: ${data::class.java.canonicalName}") throw IllegalArgumentException("Unsupported Format: ${data::class.java.canonicalName}")
} }
...@@ -66,12 +66,10 @@ object DateTimeSerializer : QtSerializer<Temporal> { ...@@ -66,12 +66,10 @@ object DateTimeSerializer : QtSerializer<Temporal> {
TimeSpec.LocalUnknown, TimeSpec.LocalUnknown,
TimeSpec.LocalDST -> TimeSpec.LocalDST ->
localDateTime localDateTime
.atZone(ZoneId.systemDefault())
TimeSpec.OffsetFromUTC -> TimeSpec.OffsetFromUTC ->
localDateTime localDateTime
.atOffset(ZoneOffset.ofTotalSeconds( .atOffset(ZoneOffset.ofTotalSeconds(
IntSerializer.deserialize(buffer, featureSet))) IntSerializer.deserialize(buffer, featureSet)))
.toInstant()
TimeSpec.UTC -> TimeSpec.UTC ->
localDateTime localDateTime
.atOffset(ZoneOffset.UTC) .atOffset(ZoneOffset.UTC)
......
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.features.FeatureSet
import de.kuschku.libquassel.protocol.io.ChainedByteBuffer
import de.kuschku.libquassel.protocol.variant.QtType
import java.nio.ByteBuffer
object DoubleSerializer : QtSerializer<Double> {
override val qtType: QtType = QtType.Double
override val javaType: Class<Double> = Double::class.java
override fun serialize(buffer: ChainedByteBuffer, data: Double, featureSet: FeatureSet) {
buffer.putDouble(data)
}
override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Double {
return buffer.getDouble()
}
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2021 Janne Mareike Koschinski
* Copyright (c) 2021 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.features.FeatureSet
import de.kuschku.libquassel.protocol.io.ChainedByteBuffer
import de.kuschku.libquassel.protocol.variant.QtType
import java.nio.ByteBuffer
object FloatSerializer : QtSerializer<Float> {
override val qtType: QtType = QtType.Float
override val javaType: Class<Float> = Float::class.java
override fun serialize(buffer: ChainedByteBuffer, data: Float, featureSet: FeatureSet) {
buffer.putFloat(data)
}
override fun deserialize(buffer: ByteBuffer, featureSet: FeatureSet): Float {
return buffer.getFloat()
}
}
...@@ -65,7 +65,7 @@ object MessageSerializer : QuasselSerializer<Message> { ...@@ -65,7 +65,7 @@ object MessageSerializer : QuasselSerializer<Message> {
Instant.ofEpochSecond(IntSerializer.deserialize(buffer, featureSet).toLong()), Instant.ofEpochSecond(IntSerializer.deserialize(buffer, featureSet).toLong()),
type = MessageType.of(UIntSerializer.deserialize(buffer, featureSet)), type = MessageType.of(UIntSerializer.deserialize(buffer, featureSet)),
flag = MessageFlag.of( flag = MessageFlag.of(
UByteSerializer.deserialize(buffer, featureSet).toUInt() and 0xffu UByteSerializer.deserialize(buffer, featureSet).toUInt()
), ),
bufferInfo = BufferInfoSerializer.deserialize(buffer, featureSet), bufferInfo = BufferInfoSerializer.deserialize(buffer, featureSet),
sender = StringSerializerUtf8.deserialize(buffer, featureSet) ?: "", sender = StringSerializerUtf8.deserialize(buffer, featureSet) ?: "",
......
...@@ -21,7 +21,7 @@ package de.kuschku.libquassel.protocol.serializers.primitive ...@@ -21,7 +21,7 @@ package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.features.FeatureSet import de.kuschku.libquassel.protocol.features.FeatureSet
import de.kuschku.libquassel.protocol.io.ChainedByteBuffer import de.kuschku.libquassel.protocol.io.ChainedByteBuffer
import de.kuschku.libquassel.protocol.serializers.* import de.kuschku.libquassel.protocol.serializers.NoSerializerForTypeException
import de.kuschku.libquassel.protocol.variant.QVariant import de.kuschku.libquassel.protocol.variant.QVariant
import de.kuschku.libquassel.protocol.variant.QVariant_ import de.kuschku.libquassel.protocol.variant.QVariant_
import de.kuschku.libquassel.protocol.variant.QtType import de.kuschku.libquassel.protocol.variant.QtType
......
...@@ -29,13 +29,20 @@ object Serializers { ...@@ -29,13 +29,20 @@ object Serializers {
private val qtSerializers = setOf<QtSerializer<*>>( private val qtSerializers = setOf<QtSerializer<*>>(
VoidSerializer, VoidSerializer,
BoolSerializer, BoolSerializer,
ByteSerializer,
UByteSerializer,
ShortSerializer,
UShortSerializer,
IntSerializer, IntSerializer,
UIntSerializer, UIntSerializer,
LongSerializer,
ULongSerializer,
QCharSerializer, FloatSerializer,
QVariantMapSerializer, DoubleSerializer,
QVariantListSerializer,
QCharSerializer,
StringSerializerUtf16, StringSerializerUtf16,
QStringListSerializer, QStringListSerializer,
ByteBufferSerializer, ByteBufferSerializer,
...@@ -44,16 +51,12 @@ object Serializers { ...@@ -44,16 +51,12 @@ object Serializers {
TimeSerializer, TimeSerializer,
DateTimeSerializer, DateTimeSerializer,
LongSerializer,
ShortSerializer,
ByteSerializer,
ULongSerializer,
UShortSerializer,
UByteSerializer,
QVariantSerializer, QVariantSerializer,
QVariantListSerializer,
QVariantMapSerializer,
).associateBy(QtSerializer<*>::qtType)
private val quasselSerializers = listOf<QuasselSerializer<*>>(
BufferIdSerializer, BufferIdSerializer,
BufferInfoSerializer, BufferInfoSerializer,
//DccConfigIpDetectionModeSerializer, //DccConfigIpDetectionModeSerializer,
...@@ -69,9 +72,6 @@ object Serializers { ...@@ -69,9 +72,6 @@ object Serializers {
//NetworkServerSerializer, //NetworkServerSerializer,
//QHostAddressSerializer, //QHostAddressSerializer,
PeerPtrSerializer, PeerPtrSerializer,
).associateBy(QtSerializer<*>::qtType)
private val quasselSerializers = listOf<QuasselSerializer<*>>(
).associateBy(QuasselSerializer<*>::quasselType) ).associateBy(QuasselSerializer<*>::quasselType)
operator fun get(type: QtType) = qtSerializers[type] operator fun get(type: QtType) = qtSerializers[type]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment