diff --git a/libraries/stdlib/common/src/kotlin/CollectionsH.kt b/libraries/stdlib/common/src/kotlin/CollectionsH.kt new file mode 100644 index 00000000000..32ca0b50926 --- /dev/null +++ b/libraries/stdlib/common/src/kotlin/CollectionsH.kt @@ -0,0 +1,124 @@ +package kotlin.collections + +open header class ArrayList : MutableList { + constructor(capacity: Int) + constructor() + constructor(c: Collection) + + // From List + override val size: Int + override fun isEmpty(): Boolean + override fun contains(element: @UnsafeVariance E): Boolean + override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean + override operator fun get(index: Int): E + override fun indexOf(element: @UnsafeVariance E): Int + override fun lastIndexOf(element: @UnsafeVariance E): Int + + // From MutableCollection + override fun iterator(): MutableIterator + + // From MutableList + override fun add(element: E): Boolean + override fun remove(element: E): Boolean + override fun addAll(elements: Collection): Boolean + override fun addAll(index: Int, elements: Collection): Boolean + override fun removeAll(elements: Collection): Boolean + override fun retainAll(elements: Collection): Boolean + override fun clear() + override operator fun set(index: Int, element: E): E + override fun add(index: Int, element: E) + override fun removeAt(index: Int): E + override fun listIterator(): MutableListIterator + override fun listIterator(index: Int): MutableListIterator + override fun subList(fromIndex: Int, toIndex: Int): MutableList +} + +open header class HashMap : MutableMap { + constructor(initialCapacity: Int) + constructor() + + // From Map + override val size: Int + override fun isEmpty(): Boolean + override fun containsKey(key: K): Boolean + override fun containsValue(value: @UnsafeVariance V): Boolean + override operator fun get(key: K): V? + + // From MutableMap + override fun put(key: K, value: V): V? + override fun remove(key: K): V? + override fun putAll(from: Map) + override fun clear() + override val keys: MutableSet + override val values: MutableCollection + override val entries: MutableSet> +} + +open header class LinkedHashMap : HashMap { + constructor(initialCapacity: Int) + constructor() + constructor(m: Map) +} + +open header class HashSet : MutableSet { + constructor() + constructor(initialCapacity: Int) + + // From Set + override val size: Int + override fun isEmpty(): Boolean + override fun contains(element: @UnsafeVariance E): Boolean + override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean + + // From MutableSet + override fun iterator(): MutableIterator + override fun add(element: E): Boolean + override fun remove(element: E): Boolean + override fun addAll(elements: Collection): Boolean + override fun removeAll(elements: Collection): Boolean + override fun retainAll(elements: Collection): Boolean + override fun clear() +} + +open header class LinkedHashSet : HashSet { + constructor(initialCapacity: Int) + constructor() + constructor(c: Collection) +} + +header interface RandomAccess + + +header abstract class AbstractMutableList : MutableList { + protected constructor() + + // From List + override fun isEmpty(): Boolean + override fun contains(element: @UnsafeVariance E): Boolean + override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean + override fun indexOf(element: @UnsafeVariance E): Int + override fun lastIndexOf(element: @UnsafeVariance E): Int + + // From MutableCollection + override fun iterator(): MutableIterator + + // From MutableList + override fun add(element: E): Boolean + override fun remove(element: E): Boolean + override fun addAll(elements: Collection): Boolean + override fun addAll(index: Int, elements: Collection): Boolean + override fun removeAll(elements: Collection): Boolean + override fun retainAll(elements: Collection): Boolean + override fun clear() + override fun listIterator(): MutableListIterator + override fun listIterator(index: Int): MutableListIterator + override fun subList(fromIndex: Int, toIndex: Int): MutableList +} + + +// From collections.kt + +header inline fun Collection.toTypedArray(): Array + +header fun > MutableList.sort(): Unit +header fun MutableList.sortWith(comparator: Comparator): Unit diff --git a/libraries/stdlib/common/src/kotlin/JvmAnnotationsH.kt b/libraries/stdlib/common/src/kotlin/JvmAnnotationsH.kt new file mode 100644 index 00000000000..6e8a8842817 --- /dev/null +++ b/libraries/stdlib/common/src/kotlin/JvmAnnotationsH.kt @@ -0,0 +1,11 @@ +package kotlin.jvm + +import kotlin.annotation.AnnotationTarget.* + +@Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, FILE) +header annotation class JvmName(val name: String) + +@Target(FILE) +header annotation class JvmMultifileClass + +header annotation class JvmField diff --git a/libraries/stdlib/common/src/kotlin/KotlinH.kt b/libraries/stdlib/common/src/kotlin/KotlinH.kt new file mode 100644 index 00000000000..70ca61fd430 --- /dev/null +++ b/libraries/stdlib/common/src/kotlin/KotlinH.kt @@ -0,0 +1,67 @@ +package kotlin + +import kotlin.annotation.AnnotationTarget.* + +open header class Error : Throwable { + constructor(message: String) +} + +open header class Exception : Throwable + +open header class IllegalArgumentException : RuntimeException { + constructor() + constructor(message: String) +} + +open header class IllegalStateException : RuntimeException { + constructor(message: String) +} + +open header class IndexOutOfBoundsException : RuntimeException { + constructor(message: String) +} + +open header class NoSuchElementException : RuntimeException { + constructor() + constructor(message: String) +} + +open header class RuntimeException : Exception { + constructor() + constructor(message: String) +} + +open header class UnsupportedOperationException : RuntimeException { + constructor(message: String) +} + + +header interface Comparator { + fun compare(a: T, b: T): Int +} + + +// From kotlin.kt + +internal header fun arrayOfNulls(reference: Array, size: Int): Array +internal inline header fun Map.toSingletonMapOrSelf(): Map +internal inline header fun Map.toSingletonMap(): Map +internal inline header fun Array.copyToArrayOfAny(isVarargs: Boolean): Array + +internal header interface Serializable + +// temporary +internal header object Math { + fun max(a: Int, b: Int): Int + fun min(a: Int, b: Int): Int +} + + +// From concurrent.kt + +@Target(PROPERTY, FIELD) +header annotation class Volatile + +inline header fun synchronized(lock: Any, crossinline block: () -> R): R + + diff --git a/libraries/stdlib/common/src/kotlin/SequencesH.kt b/libraries/stdlib/common/src/kotlin/SequencesH.kt new file mode 100644 index 00000000000..54bb012610f --- /dev/null +++ b/libraries/stdlib/common/src/kotlin/SequencesH.kt @@ -0,0 +1,7 @@ +package kotlin.sequences + +internal header class ConstrainedOnceSequence : Sequence { + constructor(sequence: Sequence) + + override fun iterator(): Iterator +} diff --git a/libraries/stdlib/common/src/kotlin/TextH.kt b/libraries/stdlib/common/src/kotlin/TextH.kt new file mode 100644 index 00000000000..03d82e68b42 --- /dev/null +++ b/libraries/stdlib/common/src/kotlin/TextH.kt @@ -0,0 +1,79 @@ +package kotlin.text + +header interface Appendable { + fun append(c: Char): Appendable +} + +header class StringBuilder : Appendable, CharSequence { + constructor() + constructor(capacity: Int) + constructor(seq: CharSequence) + + override val length: Int + override operator fun get(index: Int): Char + override fun subSequence(startIndex: Int, endIndex: Int): CharSequence + + fun reverse(): StringBuilder + override fun append(c: Char): Appendable +} + +header class Regex { + constructor(pattern: String) + constructor(pattern: String, option: RegexOption) + constructor(pattern: String, options: Set) + + fun matches(input: CharSequence): Boolean + fun containsMatchIn(input: CharSequence): Boolean + fun replace(input: CharSequence, replacement: String): String + fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String + fun replaceFirst(input: CharSequence, replacement: String): String + fun split(input: CharSequence, limit: Int): List +} + +header class MatchGroup + +header enum class RegexOption + +public header interface MatchGroupCollection : Collection { + public operator fun get(index: Int): MatchGroup? +} + +public header interface MatchNamedGroupCollection : MatchGroupCollection { + public operator fun get(name: String): MatchGroup? +} + + +public header interface MatchResult { + public val range: IntRange + public val value: String + public val groups: MatchGroupCollection + public val groupValues: List + //public val destructured: Destructured + + public fun next(): MatchResult? + + +} + +// From char.kt + +header fun Char.isWhitespace(): Boolean +header fun Char.toLowerCase(): Char +header fun Char.toUpperCase(): Char +header fun Char.isHighSurrogate(): Boolean +header fun Char.isLowSurrogate(): Boolean + +// From string.kt + +internal header fun String.nativeIndexOf(str: String, fromIndex: Int): Int +internal header fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int +internal header fun String.nativeStartsWith(s: String, position: Int): Boolean +internal header fun String.nativeEndsWith(s: String): Boolean + +// From stringsCode.kt + +internal inline header fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int +internal inline header fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int + +header fun CharSequence.isBlank(): Boolean +header fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, otherOffset: Int, length: Int, ignoreCase: Boolean): Boolean