JS: Move declaration to match their packages in JVM and Common stdlib
Mostly internal, but also two public annotations
This commit is contained in:
@@ -35,4 +35,13 @@ internal annotation class JvmMultifileClass
|
||||
@Target(AnnotationTarget.FIELD)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@MustBeDocumented
|
||||
internal annotation class JvmField
|
||||
internal annotation class JvmField
|
||||
|
||||
|
||||
@Target(AnnotationTarget.FIELD)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public annotation class Volatile
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public annotation class Synchronized
|
||||
|
||||
@@ -139,3 +139,19 @@ private fun <T> collectionsSort(list: MutableList<T>, comparator: Comparator<in
|
||||
list[i] = array[i]
|
||||
}
|
||||
}
|
||||
|
||||
internal fun <T> arrayOfNulls(reference: Array<out T>, size: Int): Array<T> {
|
||||
return arrayOfNulls<Any>(size).unsafeCast<Array<T>>()
|
||||
}
|
||||
|
||||
// no singleton map implementation in js, return map as is
|
||||
internal inline fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V> = this
|
||||
|
||||
internal inline fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V> = this.toMutableMap()
|
||||
|
||||
internal inline fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<out Any?> =
|
||||
if (isVarargs)
|
||||
// no need to copy vararg array in JS
|
||||
this
|
||||
else
|
||||
this.copyOf()
|
||||
|
||||
@@ -17,23 +17,10 @@
|
||||
package kotlin
|
||||
|
||||
|
||||
// Note:
|
||||
// Right now we don't want to have neither 'volatile' nor 'synchronized' at runtime,
|
||||
// so they annotated as `external` to avoid warnings/errors from some minifiers.
|
||||
// They was reserved word in ECMAScript 2, but is not since ECMAScript 5.
|
||||
|
||||
// Additional note:
|
||||
// Although it's reasonable to mark these annotations as `@native` (`external` since 1.1),
|
||||
// we prohibit marking annotations this way.
|
||||
// TODO: Another workaround is required to remove these annotations from kotlin.js
|
||||
|
||||
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FIELD)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public annotation class Volatile
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public annotation class Synchronized
|
||||
@Deprecated("Use Synchronized annotation from kotlin.jvm package", ReplaceWith("kotlin.jvm.Synchronized"), level = DeprecationLevel.WARNING)
|
||||
public typealias Synchronized = kotlin.jvm.Synchronized
|
||||
@Deprecated("Use Volatile annotation from kotlin.jvm package", ReplaceWith("kotlin.jvm.Volatile"), level = DeprecationLevel.WARNING)
|
||||
public typealias Volatile = kotlin.jvm.Volatile
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R> synchronized(@Suppress("UNUSED_PARAMETER") lock: Any, block: () -> R): R = block()
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.io
|
||||
|
||||
// temporary for shared code, until we have an annotation like JvmSerializable
|
||||
internal interface Serializable
|
||||
@@ -69,10 +69,6 @@ public fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> =
|
||||
public fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> = UnsafeLazyImpl(initializer)
|
||||
|
||||
|
||||
internal fun <T> arrayOfNulls(reference: Array<out T>, size: Int): Array<T> {
|
||||
return arrayOfNulls<Any>(size).unsafeCast<Array<T>>()
|
||||
}
|
||||
|
||||
internal fun fillFrom(src: dynamic, dst: dynamic): dynamic {
|
||||
val srcLen: Int = src.length
|
||||
val dstLen: Int = dst.length
|
||||
@@ -113,18 +109,3 @@ internal inline fun copyArrayType(from: dynamic, to: dynamic) {
|
||||
to.`$type$` = from.`$type$`
|
||||
}
|
||||
}
|
||||
|
||||
// no singleton map implementation in js, return map as is
|
||||
internal inline fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V> = this
|
||||
|
||||
internal inline fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V> = this.toMutableMap()
|
||||
|
||||
internal inline fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<out Any?> =
|
||||
if (isVarargs)
|
||||
// no need to copy vararg array in JS
|
||||
this
|
||||
else
|
||||
this.copyOf()
|
||||
|
||||
// temporary for shared code, until we have an annotation like JvmSerializable
|
||||
internal interface Serializable
|
||||
Reference in New Issue
Block a user