[K/N] Replace SymbolName with GCUnsafeCall in stdlib
This commit is contained in:
+2
-1
@@ -5,6 +5,7 @@
|
||||
package kotlinx.cinterop
|
||||
|
||||
import kotlin.native.internal.ExportForCppRuntime
|
||||
import kotlin.native.internal.GCUnsafeCall
|
||||
|
||||
public class ForeignException internal constructor(val nativeException: Any?): Exception() {
|
||||
override val message: String = nativeException?.let {
|
||||
@@ -12,7 +13,7 @@ public class ForeignException internal constructor(val nativeException: Any?): E
|
||||
}?: ""
|
||||
|
||||
// Current implementation expects NSException type only, which is ensured by CodeGenerator.
|
||||
@SymbolName("Kotlin_ObjCExport_ExceptionDetails")
|
||||
@GCUnsafeCall("Kotlin_ObjCExport_ExceptionDetails")
|
||||
private external fun kotlin_ObjCExport_ExceptionDetails(nativeException: Any): String?
|
||||
}
|
||||
|
||||
|
||||
+17
-21
@@ -18,11 +18,7 @@
|
||||
|
||||
package kotlinx.cinterop
|
||||
import kotlin.native.*
|
||||
import kotlin.native.internal.ExportTypeInfo
|
||||
import kotlin.native.internal.ExportForCppRuntime
|
||||
import kotlin.native.internal.TypedIntrinsic
|
||||
import kotlin.native.internal.IntrinsicType
|
||||
import kotlin.native.internal.FilterExceptions
|
||||
import kotlin.native.internal.*
|
||||
|
||||
interface ObjCObject
|
||||
interface ObjCClass : ObjCObject
|
||||
@@ -63,16 +59,16 @@ private fun ObjCObjectBase.superInitCheck(superInitCallResult: ObjCObject?) {
|
||||
internal fun <T : Any?> Any?.uncheckedCast(): T = @Suppress("UNCHECKED_CAST") (this as T)
|
||||
|
||||
// Note: if this is called for non-frozen object on a wrong worker, the program will terminate.
|
||||
@SymbolName("Kotlin_Interop_refFromObjC")
|
||||
@GCUnsafeCall("Kotlin_Interop_refFromObjC")
|
||||
external fun <T> interpretObjCPointerOrNull(objcPtr: NativePtr): T?
|
||||
|
||||
@ExportForCppRuntime
|
||||
inline fun <T : Any> interpretObjCPointer(objcPtr: NativePtr): T = interpretObjCPointerOrNull<T>(objcPtr)!!
|
||||
|
||||
@SymbolName("Kotlin_Interop_refToObjC")
|
||||
@GCUnsafeCall("Kotlin_Interop_refToObjC")
|
||||
external fun Any?.objcPtr(): NativePtr
|
||||
|
||||
@SymbolName("Kotlin_Interop_createKotlinObjectHolder")
|
||||
@GCUnsafeCall("Kotlin_Interop_createKotlinObjectHolder")
|
||||
external fun createKotlinObjectHolder(any: Any?): NativePtr
|
||||
|
||||
// Note: if this is called for non-frozen underlying ref on a wrong worker, the program will terminate.
|
||||
@@ -81,7 +77,7 @@ inline fun <reified T : Any> unwrapKotlinObjectHolder(holder: Any?): T {
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
@SymbolName("Kotlin_Interop_unwrapKotlinObjectHolder")
|
||||
@GCUnsafeCall("Kotlin_Interop_unwrapKotlinObjectHolder")
|
||||
external internal fun unwrapKotlinObjectHolderImpl(ptr: NativePtr): Any
|
||||
|
||||
class ObjCObjectVar<T>(rawPtr: NativePtr) : CVariable(rawPtr) {
|
||||
@@ -175,11 +171,11 @@ internal external fun getMessengerStret(superClass: NativePtr): COpaquePointer?
|
||||
|
||||
|
||||
internal class ObjCWeakReferenceImpl : kotlin.native.ref.WeakReferenceImpl() {
|
||||
@SymbolName("Konan_ObjCInterop_getWeakReference")
|
||||
@GCUnsafeCall("Konan_ObjCInterop_getWeakReference")
|
||||
external override fun get(): Any?
|
||||
}
|
||||
|
||||
@SymbolName("Konan_ObjCInterop_initWeakReference")
|
||||
@GCUnsafeCall("Konan_ObjCInterop_initWeakReference")
|
||||
private external fun ObjCWeakReferenceImpl.init(objcPtr: NativePtr)
|
||||
|
||||
@kotlin.native.internal.ExportForCppRuntime internal fun makeObjCWeakReferenceImpl(objcPtr: NativePtr): ObjCWeakReferenceImpl {
|
||||
@@ -191,37 +187,37 @@ private external fun ObjCWeakReferenceImpl.init(objcPtr: NativePtr)
|
||||
// Konan runtme:
|
||||
|
||||
@Deprecated("Use plain Kotlin cast of String to NSString", level = DeprecationLevel.ERROR)
|
||||
@SymbolName("Kotlin_Interop_CreateNSStringFromKString")
|
||||
@GCUnsafeCall("Kotlin_Interop_CreateNSStringFromKString")
|
||||
external fun CreateNSStringFromKString(str: String?): NativePtr
|
||||
|
||||
@Deprecated("Use plain Kotlin cast of NSString to String", level = DeprecationLevel.ERROR)
|
||||
@SymbolName("Kotlin_Interop_CreateKStringFromNSString")
|
||||
@GCUnsafeCall("Kotlin_Interop_CreateKStringFromNSString")
|
||||
external fun CreateKStringFromNSString(ptr: NativePtr): String?
|
||||
|
||||
@PublishedApi
|
||||
@SymbolName("Kotlin_Interop_CreateObjCObjectHolder")
|
||||
@GCUnsafeCall("Kotlin_Interop_CreateObjCObjectHolder")
|
||||
internal external fun createObjCObjectHolder(ptr: NativePtr): Any?
|
||||
|
||||
// Objective-C runtime:
|
||||
|
||||
@SymbolName("objc_retainAutoreleaseReturnValue")
|
||||
@GCUnsafeCall("objc_retainAutoreleaseReturnValue")
|
||||
external fun objc_retainAutoreleaseReturnValue(ptr: NativePtr): NativePtr
|
||||
|
||||
@SymbolName("Kotlin_objc_autoreleasePoolPush")
|
||||
@GCUnsafeCall("Kotlin_objc_autoreleasePoolPush")
|
||||
external fun objc_autoreleasePoolPush(): NativePtr
|
||||
|
||||
@SymbolName("Kotlin_objc_autoreleasePoolPop")
|
||||
@GCUnsafeCall("Kotlin_objc_autoreleasePoolPop")
|
||||
external fun objc_autoreleasePoolPop(ptr: NativePtr)
|
||||
|
||||
@SymbolName("Kotlin_objc_allocWithZone")
|
||||
@GCUnsafeCall("Kotlin_objc_allocWithZone")
|
||||
@FilterExceptions
|
||||
private external fun objc_allocWithZone(clazz: NativePtr): NativePtr
|
||||
|
||||
@SymbolName("Kotlin_objc_retain")
|
||||
@GCUnsafeCall("Kotlin_objc_retain")
|
||||
external fun objc_retain(ptr: NativePtr): NativePtr
|
||||
|
||||
@SymbolName("Kotlin_objc_release")
|
||||
@GCUnsafeCall("Kotlin_objc_release")
|
||||
external fun objc_release(ptr: NativePtr)
|
||||
|
||||
@SymbolName("Kotlin_objc_lookUpClass")
|
||||
@GCUnsafeCall("Kotlin_objc_lookUpClass")
|
||||
external fun objc_lookUpClass(name: NativePtr): NativePtr
|
||||
|
||||
+3
-2
@@ -6,6 +6,7 @@
|
||||
package kotlinx.cinterop
|
||||
|
||||
import kotlin.native.internal.KClassImpl
|
||||
import kotlin.native.internal.GCUnsafeCall
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
@@ -34,8 +35,8 @@ fun getOriginalKotlinClass(objCProtocol: ObjCProtocol): KClass<*>? {
|
||||
return KClassImpl<Any>(typeInfo)
|
||||
}
|
||||
|
||||
@SymbolName("Kotlin_ObjCInterop_getTypeInfoForClass")
|
||||
@GCUnsafeCall("Kotlin_ObjCInterop_getTypeInfoForClass")
|
||||
private external fun getTypeInfoForClass(ptr: NativePtr): NativePtr
|
||||
|
||||
@SymbolName("Kotlin_ObjCInterop_getTypeInfoForProtocol")
|
||||
@GCUnsafeCall("Kotlin_ObjCInterop_getTypeInfoForProtocol")
|
||||
private external fun getTypeInfoForProtocol(ptr: NativePtr): NativePtr
|
||||
Reference in New Issue
Block a user