Rework Objective-C constructors and support 'initBy' intrinsic
This commit is contained in:
committed by
SvyatoslavScherbina
parent
5a7e3e20b4
commit
07f26dc1df
@@ -51,8 +51,17 @@ class ObjCPointerHolder(inline val rawPtr: NativePtr) {
|
||||
@konan.internal.ExportForCompiler
|
||||
private external fun ObjCObject.initFromPtr(ptr: NativePtr)
|
||||
|
||||
@konan.internal.Intrinsic
|
||||
external fun <T : ObjCObjectBase> T.initBy(constructorCall: T): T
|
||||
|
||||
@konan.internal.ExportForCompiler
|
||||
private fun ObjCObject.initFrom(other: ObjCObject?) = this.initFromPtr(other!!.rawPtr)
|
||||
private fun ObjCObjectBase.superInitCheck(superInitCallResult: ObjCObject?) {
|
||||
if (superInitCallResult == null)
|
||||
throw RuntimeException("Super initialization failed")
|
||||
|
||||
if (superInitCallResult.rawPtr != this.rawPtr)
|
||||
throw UnsupportedOperationException("Super initializer has replaced object")
|
||||
}
|
||||
|
||||
fun <T : Any?> Any?.uncheckedCast(): T = @Suppress("UNCHECKED_CAST") (this as T) // TODO: make private
|
||||
|
||||
|
||||
+1
-1
@@ -421,7 +421,7 @@ val ObjCClassOrProtocol.kotlinName: String get() = when (this) {
|
||||
}
|
||||
|
||||
private val ObjCClass.baseClassName: String
|
||||
get() = baseClass?.name ?: "ObjCObject"
|
||||
get() = baseClass?.name ?: "ObjCObjectBase"
|
||||
|
||||
private fun Parameter.getTypeStringRepresentation() =
|
||||
(if (this.nsConsumed) "__attribute__((ns_consumed)) " else "") + type.getStringRepresentation()
|
||||
|
||||
Reference in New Issue
Block a user