Place Char constants into builtin Char companion object.

This commit is contained in:
Ilya Gorbunov
2015-11-21 07:31:43 +03:00
parent de11ed4fc6
commit f9ba35af64
5 changed files with 67 additions and 3 deletions
+12
View File
@@ -233,6 +233,18 @@ public final class Char : kotlin.Comparable<kotlin.Char> {
public companion object Companion { public companion object Companion {
/*primary*/ private constructor Companion() /*primary*/ private constructor Companion()
public const final val MAX_HIGH_SURROGATE: kotlin.Char
public final fun <get-MAX_HIGH_SURROGATE>(): kotlin.Char
public const final val MAX_LOW_SURROGATE: kotlin.Char
public final fun <get-MAX_LOW_SURROGATE>(): kotlin.Char
public const final val MAX_SURROGATE: kotlin.Char
public final fun <get-MAX_SURROGATE>(): kotlin.Char
public const final val MIN_HIGH_SURROGATE: kotlin.Char
public final fun <get-MIN_HIGH_SURROGATE>(): kotlin.Char
public const final val MIN_LOW_SURROGATE: kotlin.Char
public final fun <get-MIN_LOW_SURROGATE>(): kotlin.Char
public const final val MIN_SURROGATE: kotlin.Char
public final fun <get-MIN_SURROGATE>(): kotlin.Char
} }
} }
+33 -1
View File
@@ -21,7 +21,6 @@ package kotlin
* On the JVM, non-nullable values of this type are represented as values of the primitive type `char`. * On the JVM, non-nullable values of this type are represented as values of the primitive type `char`.
*/ */
public class Char private () : Comparable<Char> { public class Char private () : Comparable<Char> {
companion object {}
/** /**
* Compares this value with the specified value for order. * Compares this value with the specified value for order.
@@ -60,5 +59,38 @@ public class Char private () : Comparable<Char> {
public override fun toFloat(): Float public override fun toFloat(): Float
/** Returns the value of this character as a `Double`. */ /** Returns the value of this character as a `Double`. */
public override fun toDouble(): Double public override fun toDouble(): Double
companion object {
/**
* The minimum value of a Unicode high-surrogate code unit.
*/
public const val MIN_HIGH_SURROGATE: Char = '\uD800'
/**
* The maximum value of a Unicode high-surrogate code unit.
*/
public const val MAX_HIGH_SURROGATE: Char = '\uDBFF'
/**
* The minimum value of a Unicode low-surrogate code unit.
*/
public const val MIN_LOW_SURROGATE: Char = '\uDC00'
/**
* The maximum value of a Unicode low-surrogate code unit.
*/
public const val MAX_LOW_SURROGATE: Char = '\uDFFF'
/**
* The minimum value of a Unicode surrogate code unit.
*/
public const val MIN_SURROGATE: Char = MIN_HIGH_SURROGATE
/**
* The maximum value of a Unicode surrogate code unit.
*/
public const val MAX_SURROGATE: Char = MAX_LOW_SURROGATE
}
} }
@@ -53,7 +53,14 @@ private object ByteCompanionObject {
} }
private object CharCompanionObject {} private object CharCompanionObject {
public const val MIN_HIGH_SURROGATE: Char = '\uD800'
public const val MAX_HIGH_SURROGATE: Char = '\uDBFF'
public const val MIN_LOW_SURROGATE: Char = '\uDC00'
public const val MAX_LOW_SURROGATE: Char = '\uDFFF'
public const val MIN_SURROGATE: Char = MIN_HIGH_SURROGATE
public const val MAX_SURROGATE: Char = MAX_LOW_SURROGATE
}
private object StringCompanionObject {} private object StringCompanionObject {}
private object EnumCompanionObject {} private object EnumCompanionObject {}
@@ -52,7 +52,14 @@ private object ByteCompanionObject {
val MAX_VALUE: Byte = 127 val MAX_VALUE: Byte = 127
} }
private object CharCompanionObject {} private object CharCompanionObject {
public const val MIN_HIGH_SURROGATE: Char = '\uD800'
public const val MAX_HIGH_SURROGATE: Char = '\uDBFF'
public const val MIN_LOW_SURROGATE: Char = '\uDC00'
public const val MAX_LOW_SURROGATE: Char = '\uDFFF'
public const val MIN_SURROGATE: Char = MIN_HIGH_SURROGATE
public const val MAX_SURROGATE: Char = MAX_LOW_SURROGATE
}
private object StringCompanionObject {} private object StringCompanionObject {}
private object EnumCompanionObject {} private object EnumCompanionObject {}
+6
View File
@@ -61,35 +61,41 @@ public fun Char.isSurrogate(): Boolean = this in Char.MIN_SURROGATE..Char.MAX_SU
/** /**
* The minimum value of a Unicode high-surrogate code unit. * The minimum value of a Unicode high-surrogate code unit.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public val Char.Companion.MIN_HIGH_SURROGATE: Char public val Char.Companion.MIN_HIGH_SURROGATE: Char
get() = '\uD800' get() = '\uD800'
/** /**
* The maximum value of a Unicode high-surrogate code unit. * The maximum value of a Unicode high-surrogate code unit.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public val Char.Companion.MAX_HIGH_SURROGATE: Char public val Char.Companion.MAX_HIGH_SURROGATE: Char
get() = '\uDBFF' get() = '\uDBFF'
/** /**
* The minimum value of a Unicode low-surrogate code unit. * The minimum value of a Unicode low-surrogate code unit.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public val Char.Companion.MIN_LOW_SURROGATE: Char public val Char.Companion.MIN_LOW_SURROGATE: Char
get() = '\uDC00' get() = '\uDC00'
/** /**
* The maximum value of a Unicode low-surrogate code unit. * The maximum value of a Unicode low-surrogate code unit.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public val Char.Companion.MAX_LOW_SURROGATE: Char public val Char.Companion.MAX_LOW_SURROGATE: Char
get() = '\uDFFF' get() = '\uDFFF'
/** /**
* The minimum value of a Unicode surrogate code unit. * The minimum value of a Unicode surrogate code unit.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public val Char.Companion.MIN_SURROGATE: Char public val Char.Companion.MIN_SURROGATE: Char
get() = MIN_HIGH_SURROGATE get() = MIN_HIGH_SURROGATE
/** /**
* The maximum value of a Unicode surrogate code unit. * The maximum value of a Unicode surrogate code unit.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public val Char.Companion.MAX_SURROGATE: Char public val Char.Companion.MAX_SURROGATE: Char
get() = MAX_LOW_SURROGATE get() = MAX_LOW_SURROGATE