Introduce SIZE_BYTES and SIZE_BITS constants for all integral types
#KT-8247 Fixed
This commit is contained in:
@@ -48,6 +48,12 @@ private object IntCompanionObject {
|
||||
|
||||
@JsName("MAX_VALUE")
|
||||
val MAX_VALUE: Int = 2147483647
|
||||
|
||||
@JsName("SIZE_BYTES")
|
||||
const val SIZE_BYTES = 4
|
||||
|
||||
@JsName("SIZE_BITS")
|
||||
const val SIZE_BITS = 32
|
||||
}
|
||||
|
||||
@JsName("LongCompanionObject")
|
||||
@@ -57,6 +63,12 @@ private object LongCompanionObject {
|
||||
|
||||
@JsName("MAX_VALUE")
|
||||
val MAX_VALUE: Long = js("Kotlin.Long.MAX_VALUE")
|
||||
|
||||
@JsName("SIZE_BYTES")
|
||||
const val SIZE_BYTES = 8
|
||||
|
||||
@JsName("SIZE_BITS")
|
||||
const val SIZE_BITS = 64
|
||||
}
|
||||
|
||||
@JsName("ShortCompanionObject")
|
||||
@@ -66,6 +78,12 @@ private object ShortCompanionObject {
|
||||
|
||||
@JsName("MAX_VALUE")
|
||||
val MAX_VALUE: Short = 32767
|
||||
|
||||
@JsName("SIZE_BYTES")
|
||||
const val SIZE_BYTES = 2
|
||||
|
||||
@JsName("SIZE_BITS")
|
||||
const val SIZE_BITS = 16
|
||||
}
|
||||
|
||||
@JsName("ByteCompanionObject")
|
||||
@@ -75,6 +93,12 @@ private object ByteCompanionObject {
|
||||
|
||||
@JsName("MAX_VALUE")
|
||||
val MAX_VALUE: Byte = 127
|
||||
|
||||
@JsName("SIZE_BYTES")
|
||||
const val SIZE_BYTES = 1
|
||||
|
||||
@JsName("SIZE_BITS")
|
||||
const val SIZE_BITS = 8
|
||||
}
|
||||
|
||||
@JsName("CharCompanionObject")
|
||||
@@ -96,6 +120,12 @@ private object CharCompanionObject {
|
||||
|
||||
@JsName("MAX_SURROGATE")
|
||||
public const val MAX_SURROGATE: Char = MAX_LOW_SURROGATE
|
||||
|
||||
@JsName("SIZE_BYTES")
|
||||
const val SIZE_BYTES = 2
|
||||
|
||||
@JsName("SIZE_BITS")
|
||||
const val SIZE_BITS = 16
|
||||
}
|
||||
|
||||
private object StringCompanionObject {}
|
||||
|
||||
@@ -24,21 +24,29 @@ internal object FloatCompanionObject {
|
||||
internal object IntCompanionObject {
|
||||
const val MIN_VALUE: Int = java.lang.Integer.MIN_VALUE
|
||||
const val MAX_VALUE: Int = java.lang.Integer.MAX_VALUE
|
||||
const val SIZE_BYTES: Int = 4
|
||||
const val SIZE_BITS: Int = SIZE_BYTES * 8
|
||||
}
|
||||
|
||||
internal object LongCompanionObject {
|
||||
const val MIN_VALUE: Long = java.lang.Long.MIN_VALUE
|
||||
const val MAX_VALUE: Long = java.lang.Long.MAX_VALUE
|
||||
const val SIZE_BYTES: Int = 8
|
||||
const val SIZE_BITS: Int = SIZE_BYTES * 8
|
||||
}
|
||||
|
||||
internal object ShortCompanionObject {
|
||||
const val MIN_VALUE: Short = java.lang.Short.MIN_VALUE
|
||||
const val MAX_VALUE: Short = java.lang.Short.MAX_VALUE
|
||||
const val SIZE_BYTES: Int = 2
|
||||
const val SIZE_BITS: Int = SIZE_BYTES * 8
|
||||
}
|
||||
|
||||
internal object ByteCompanionObject {
|
||||
const val MIN_VALUE: Byte = java.lang.Byte.MIN_VALUE
|
||||
const val MAX_VALUE: Byte = java.lang.Byte.MAX_VALUE
|
||||
const val SIZE_BYTES: Int = 1
|
||||
const val SIZE_BITS: Int = SIZE_BYTES * 8
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +57,8 @@ internal object CharCompanionObject {
|
||||
const val MAX_LOW_SURROGATE: Char = '\uDFFF'
|
||||
const val MIN_SURROGATE: Char = MIN_HIGH_SURROGATE
|
||||
const val MAX_SURROGATE: Char = MAX_LOW_SURROGATE
|
||||
const val SIZE_BYTES: Int = 2
|
||||
const val SIZE_BITS: Int = SIZE_BYTES * 8
|
||||
}
|
||||
|
||||
internal object StringCompanionObject {}
|
||||
|
||||
@@ -24,6 +24,16 @@ public inline class UByte internal constructor(private val data: Byte) : Compara
|
||||
* A constant holding the maximum value an instance of UByte can have.
|
||||
*/
|
||||
public const val MAX_VALUE: UByte = UByte(-1)
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent an instance of UByte in a binary form.
|
||||
*/
|
||||
public const val SIZE_BYTES: Int = 1
|
||||
|
||||
/**
|
||||
* The number of bits used to represent an instance of UByte in a binary form.
|
||||
*/
|
||||
public const val SIZE_BITS: Int = 8
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,16 @@ public inline class UInt internal constructor(private val data: Int) : Comparabl
|
||||
* A constant holding the maximum value an instance of UInt can have.
|
||||
*/
|
||||
public const val MAX_VALUE: UInt = UInt(-1)
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent an instance of UInt in a binary form.
|
||||
*/
|
||||
public const val SIZE_BYTES: Int = 4
|
||||
|
||||
/**
|
||||
* The number of bits used to represent an instance of UInt in a binary form.
|
||||
*/
|
||||
public const val SIZE_BITS: Int = 32
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,16 @@ public inline class ULong internal constructor(private val data: Long) : Compara
|
||||
* A constant holding the maximum value an instance of ULong can have.
|
||||
*/
|
||||
public const val MAX_VALUE: ULong = ULong(-1)
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent an instance of ULong in a binary form.
|
||||
*/
|
||||
public const val SIZE_BYTES: Int = 8
|
||||
|
||||
/**
|
||||
* The number of bits used to represent an instance of ULong in a binary form.
|
||||
*/
|
||||
public const val SIZE_BITS: Int = 64
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,16 @@ public inline class UShort internal constructor(private val data: Short) : Compa
|
||||
* A constant holding the maximum value an instance of UShort can have.
|
||||
*/
|
||||
public const val MAX_VALUE: UShort = UShort(-1)
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent an instance of UShort in a binary form.
|
||||
*/
|
||||
public const val SIZE_BYTES: Int = 2
|
||||
|
||||
/**
|
||||
* The number of bits used to represent an instance of UShort in a binary form.
|
||||
*/
|
||||
public const val SIZE_BITS: Int = 16
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user