Skip to content

Commit

Permalink
All flags, Color and Snowflake migrated to value classes
Browse files Browse the repository at this point in the history
  • Loading branch information
zTrap committed Jun 2, 2024
1 parent 2cdf33c commit e1ff834
Show file tree
Hide file tree
Showing 77 changed files with 4,393 additions and 4,518 deletions.
1,701 changes: 942 additions & 759 deletions common/api/common.api

Large diffs are not rendered by default.

768 changes: 417 additions & 351 deletions common/api/common.klib.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

import kotlin.LazyThreadSafetyMode.PUBLICATION
import kotlin.contracts.InvocationKind.EXACTLY_ONCE
import kotlin.contracts.contract
import kotlin.jvm.JvmInline
import kotlin.jvm.JvmName
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

/**
* See [ActivityFlag]s in the
Expand Down Expand Up @@ -191,8 +185,9 @@ public sealed class ActivityFlag(
* @see ActivityFlag
* @see ActivityFlags.Builder
*/
@Serializable(with = ActivityFlags.Serializer::class)
public class ActivityFlags internal constructor(
@JvmInline
@Serializable
public value class ActivityFlags internal constructor(
/**
* The raw value used by Discord.
*/
Expand Down Expand Up @@ -260,11 +255,6 @@ public class ActivityFlags internal constructor(
return Builder(value).apply(builder).build()
}

override fun equals(other: Any?): Boolean = this === other ||
(other is ActivityFlags && this.value == other.value)

override fun hashCode(): Int = value.hashCode()

override fun toString(): String = "ActivityFlags(values=$values)"

public class Builder(
Expand Down Expand Up @@ -304,20 +294,6 @@ public class ActivityFlags internal constructor(
*/
public fun build(): ActivityFlags = ActivityFlags(value)
}

internal object Serializer : KSerializer<ActivityFlags> {
override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("dev.kord.common.entity.ActivityFlags", PrimitiveKind.INT)

private val `delegate`: KSerializer<Int> = Int.serializer()

override fun serialize(encoder: Encoder, `value`: ActivityFlags) {
encoder.encodeSerializableValue(delegate, value.value)
}

override fun deserialize(decoder: Decoder): ActivityFlags =
ActivityFlags(decoder.decodeSerializableValue(delegate))
}
}

/**
Expand All @@ -336,14 +312,6 @@ public fun ActivityFlags(vararg flags: ActivityFlag): ActivityFlags = ActivityFl
flags.forEach { +it }
}

/**
* Returns an instance of [ActivityFlags] that has all bits set that are set in any element of
* [flags].
*/
public fun ActivityFlags(vararg flags: ActivityFlags): ActivityFlags = ActivityFlags {
flags.forEach { +it }
}

/**
* Returns an instance of [ActivityFlags] that has all bits set that are set in any element of
* [flags].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

import kotlin.LazyThreadSafetyMode.PUBLICATION
import kotlin.contracts.InvocationKind.EXACTLY_ONCE
import kotlin.contracts.contract
import kotlin.jvm.JvmInline
import kotlin.jvm.JvmName
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

/**
* See [ApplicationFlag]s in the
Expand Down Expand Up @@ -237,8 +231,9 @@ public sealed class ApplicationFlag(
* @see ApplicationFlag
* @see ApplicationFlags.Builder
*/
@Serializable(with = ApplicationFlags.Serializer::class)
public class ApplicationFlags internal constructor(
@JvmInline
@Serializable
public value class ApplicationFlags internal constructor(
/**
* The raw code used by Discord.
*/
Expand Down Expand Up @@ -306,11 +301,6 @@ public class ApplicationFlags internal constructor(
return Builder(code).apply(builder).build()
}

override fun equals(other: Any?): Boolean = this === other ||
(other is ApplicationFlags && this.code == other.code)

override fun hashCode(): Int = code.hashCode()

override fun toString(): String = "ApplicationFlags(values=$values)"

public class Builder(
Expand Down Expand Up @@ -350,21 +340,6 @@ public class ApplicationFlags internal constructor(
*/
public fun build(): ApplicationFlags = ApplicationFlags(code)
}

internal object Serializer : KSerializer<ApplicationFlags> {
override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("dev.kord.common.entity.ApplicationFlags",
PrimitiveKind.INT)

private val `delegate`: KSerializer<Int> = Int.serializer()

override fun serialize(encoder: Encoder, `value`: ApplicationFlags) {
encoder.encodeSerializableValue(delegate, value.code)
}

override fun deserialize(decoder: Decoder): ApplicationFlags =
ApplicationFlags(decoder.decodeSerializableValue(delegate))
}
}

/**
Expand All @@ -384,14 +359,6 @@ public fun ApplicationFlags(vararg flags: ApplicationFlag): ApplicationFlags = A
flags.forEach { +it }
}

/**
* Returns an instance of [ApplicationFlags] that has all bits set that are set in any element of
* [flags].
*/
public fun ApplicationFlags(vararg flags: ApplicationFlags): ApplicationFlags = ApplicationFlags {
flags.forEach { +it }
}

/**
* Returns an instance of [ApplicationFlags] that has all bits set that are set in any element of
* [flags].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

import kotlin.LazyThreadSafetyMode.PUBLICATION
import kotlin.contracts.InvocationKind.EXACTLY_ONCE
import kotlin.contracts.contract
import kotlin.jvm.JvmInline
import kotlin.jvm.JvmName
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

/**
* See [AttachmentFlag]s in the
Expand Down Expand Up @@ -162,8 +156,9 @@ public sealed class AttachmentFlag(
* @see AttachmentFlag
* @see AttachmentFlags.Builder
*/
@Serializable(with = AttachmentFlags.Serializer::class)
public class AttachmentFlags internal constructor(
@JvmInline
@Serializable
public value class AttachmentFlags internal constructor(
/**
* The raw value used by Discord.
*/
Expand Down Expand Up @@ -231,11 +226,6 @@ public class AttachmentFlags internal constructor(
return Builder(value).apply(builder).build()
}

override fun equals(other: Any?): Boolean = this === other ||
(other is AttachmentFlags && this.value == other.value)

override fun hashCode(): Int = value.hashCode()

override fun toString(): String = "AttachmentFlags(values=$values)"

public class Builder(
Expand Down Expand Up @@ -275,21 +265,6 @@ public class AttachmentFlags internal constructor(
*/
public fun build(): AttachmentFlags = AttachmentFlags(value)
}

internal object Serializer : KSerializer<AttachmentFlags> {
override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("dev.kord.common.entity.AttachmentFlags",
PrimitiveKind.INT)

private val `delegate`: KSerializer<Int> = Int.serializer()

override fun serialize(encoder: Encoder, `value`: AttachmentFlags) {
encoder.encodeSerializableValue(delegate, value.value)
}

override fun deserialize(decoder: Decoder): AttachmentFlags =
AttachmentFlags(decoder.decodeSerializableValue(delegate))
}
}

/**
Expand All @@ -309,14 +284,6 @@ public fun AttachmentFlags(vararg flags: AttachmentFlag): AttachmentFlags = Atta
flags.forEach { +it }
}

/**
* Returns an instance of [AttachmentFlags] that has all bits set that are set in any element of
* [flags].
*/
public fun AttachmentFlags(vararg flags: AttachmentFlags): AttachmentFlags = AttachmentFlags {
flags.forEach { +it }
}

/**
* Returns an instance of [AttachmentFlags] that has all bits set that are set in any element of
* [flags].
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
@file:Suppress(names = arrayOf("IncorrectFormatting", "ReplaceArrayOfWithLiteral",
"SpellCheckingInspection", "GrazieInspection"))
"SpellCheckingInspection", "GrazieInspection", "MemberVisibilityCanBePrivate"))

package dev.kord.common.entity

Expand Down
Loading

0 comments on commit e1ff834

Please sign in to comment.