[K/N] Internalize functions for throwing specific exception from C++ code
As a part of efforts to stabilize Native stdlib.
This commit is contained in:
@@ -11,7 +11,8 @@ import kotlin.native.concurrent.FreezableAtomicReference
|
|||||||
import kotlin.native.concurrent.freeze
|
import kotlin.native.concurrent.freeze
|
||||||
|
|
||||||
@ExportForCppRuntime
|
@ExportForCppRuntime
|
||||||
fun ThrowNullPointerException(): Nothing {
|
@PublishedApi
|
||||||
|
internal fun ThrowNullPointerException(): Nothing {
|
||||||
throw NullPointerException()
|
throw NullPointerException()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,23 +27,27 @@ internal fun ThrowArrayIndexOutOfBoundsException(): Nothing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ExportForCppRuntime
|
@ExportForCppRuntime
|
||||||
fun ThrowClassCastException(instance: Any, typeInfo: NativePtr): Nothing {
|
@PublishedApi
|
||||||
|
internal fun ThrowClassCastException(instance: Any, typeInfo: NativePtr): Nothing {
|
||||||
val clazz = KClassImpl<Any>(typeInfo)
|
val clazz = KClassImpl<Any>(typeInfo)
|
||||||
throw ClassCastException("${instance::class} cannot be cast to $clazz")
|
throw ClassCastException("${instance::class} cannot be cast to $clazz")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExportForCppRuntime
|
@ExportForCppRuntime
|
||||||
fun ThrowTypeCastException(instance: Any, typeName: String): Nothing {
|
@PublishedApi
|
||||||
|
internal fun ThrowTypeCastException(instance: Any, typeName: String): Nothing {
|
||||||
throw TypeCastException("${instance::class} cannot be cast to class $typeName")
|
throw TypeCastException("${instance::class} cannot be cast to class $typeName")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExportForCppRuntime
|
@ExportForCppRuntime
|
||||||
fun ThrowKotlinNothingValueException(): Nothing {
|
@PublishedApi
|
||||||
|
internal fun ThrowKotlinNothingValueException(): Nothing {
|
||||||
throw KotlinNothingValueException()
|
throw KotlinNothingValueException()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExportForCppRuntime
|
@ExportForCppRuntime
|
||||||
fun ThrowInvalidReceiverTypeException(klass: KClass<*>): Nothing {
|
@PublishedApi
|
||||||
|
internal fun ThrowInvalidReceiverTypeException(klass: KClass<*>): Nothing {
|
||||||
throw RuntimeException("Unexpected receiver type: " + (klass.qualifiedName ?: "noname"))
|
throw RuntimeException("Unexpected receiver type: " + (klass.qualifiedName ?: "noname"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,11 +66,13 @@ internal fun ThrowOutOfMemoryError() : Nothing {
|
|||||||
throw OutOfMemoryError()
|
throw OutOfMemoryError()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ThrowNoWhenBranchMatchedException(): Nothing {
|
@PublishedApi
|
||||||
|
internal fun ThrowNoWhenBranchMatchedException(): Nothing {
|
||||||
throw NoWhenBranchMatchedException()
|
throw NoWhenBranchMatchedException()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ThrowUninitializedPropertyAccessException(propertyName: String): Nothing {
|
@PublishedApi
|
||||||
|
internal fun ThrowUninitializedPropertyAccessException(propertyName: String): Nothing {
|
||||||
throw UninitializedPropertyAccessException("lateinit property $propertyName has not been initialized")
|
throw UninitializedPropertyAccessException("lateinit property $propertyName has not been initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user