diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CompilerOutput.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CompilerOutput.kt index 737ce279404..f178d7d3740 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CompilerOutput.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CompilerOutput.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.backend.konan import llvm.* import org.jetbrains.kotlin.backend.konan.llvm.* import org.jetbrains.kotlin.backend.konan.llvm.Llvm +import org.jetbrains.kotlin.backend.konan.llvm.objc.linkObjC import org.jetbrains.kotlin.konan.CURRENT import org.jetbrains.kotlin.library.KotlinAbiVersion import org.jetbrains.kotlin.konan.KonanVersion @@ -59,11 +60,9 @@ private fun linkAllDependencies(context: Context, generatedBitcodeFiles: List = listOf("objc.bc").map { - File(distribution.defaultNatives(target)).child(it).absolutePath - } + internal val objCNativeLibrary: String = + File(distribution.defaultNatives(target)).child("objc.bc").absolutePath internal val nativeLibraries: List = configuration.getList(KonanConfigKeys.NATIVE_LIBRARY_FILES) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objc/linkObjC.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objc/linkObjC.kt new file mode 100644 index 00000000000..13fa16b387f --- /dev/null +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objc/linkObjC.kt @@ -0,0 +1,233 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +package org.jetbrains.kotlin.backend.konan.llvm.objc + +import kotlinx.cinterop.* +import llvm.* +import org.jetbrains.kotlin.backend.konan.Context +import org.jetbrains.kotlin.backend.konan.isFinalBinary +import org.jetbrains.kotlin.backend.konan.llvm.* +import org.jetbrains.kotlin.backend.konan.objcexport.NSNumberKind +import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportNamer + +internal fun linkObjC(context: Context) { + val config = context.config + if (!(config.produce.isFinalBinary && config.target.family.isAppleFamily)) return + + val patchBuilder = PatchBuilder(context) + patchBuilder.addObjCPatches() + + val bitcodeFile = config.objCNativeLibrary + val parsedModule = parseBitcodeFile(bitcodeFile) + + patchBuilder.buildAndApply(parsedModule) + + val failed = LLVMLinkModules2(context.llvmModule!!, parsedModule) + if (failed != 0) { + throw Error("failed to link $bitcodeFile") + } +} + +private class PatchBuilder(val context: Context) { + enum class GlobalKind(val prefix: String) { + OBJC_CLASS("OBJC_CLASS_\$_"), + OBJC_METACLASS("OBJC_METACLASS_\$_"), + OBJC_IVAR("OBJC_IVAR_\$_"), + } + + data class GlobalPatch(val kind: GlobalKind, val suffix: String, val newSuffix: String) { + val globalName: String + get() = "${kind.prefix}$suffix" + + val newGlobalName: String + get() = "${kind.prefix}$newSuffix" + } + + data class LiteralPatch( + val generator: ObjCDataGenerator.CStringLiteralsGenerator, + val value: String, + val newValue: String + ) + + val globalPatches = mutableListOf() + val literalPatches = mutableListOf() + + val objCExportNamer = context.objCExport.namer + + // Note: exported classes anyway use the same prefix, + // so using more unique private prefix wouldn't help to prevent any clashes. + private val privatePrefix = objCExportNamer.topLevelNamePrefix + + fun addProtocolImport(name: String) { + literalPatches += LiteralPatch(ObjCDataGenerator.classNameGenerator, name, name) + // So that protocol name literal wouldn't be detected as unhandled class. + } + + fun addExportedClass(publicName: ObjCExportNamer.ClassOrProtocolName, runtimeName: String, vararg ivars: String) { + addRenameClass(runtimeName, publicName.binaryName, ivars) + } + + fun addPrivateClass(name: String, vararg ivars: String) { + addRenameClass(name, "$privatePrefix$name", ivars) + } + + private fun addRenameClass(oldName: String, newName: String, ivars: Array) { + globalPatches += GlobalPatch(GlobalKind.OBJC_CLASS, oldName, newName) + globalPatches += GlobalPatch(GlobalKind.OBJC_METACLASS, oldName, newName) + + ivars.mapTo(globalPatches) { + GlobalPatch(GlobalKind.OBJC_IVAR, "$oldName.$it", "$newName.$it") + } + + literalPatches += LiteralPatch(ObjCDataGenerator.classNameGenerator, oldName, newName) + } + + fun addPrivateCategory(name: String) { + literalPatches += LiteralPatch(ObjCDataGenerator.classNameGenerator, name, "$privatePrefix$name") + } + + fun addPrivateSelector(name: String) { + literalPatches += LiteralPatch(ObjCDataGenerator.selectorGenerator, name, "${privatePrefix}_$name") + } +} + +/** + * Add patches for objc.bc. + */ +private fun PatchBuilder.addObjCPatches() { + addProtocolImport("NSCopying") + + addPrivateSelector("toKotlin:") + addPrivateSelector("releaseAsAssociatedObject") + + addPrivateClass("KIteratorAsNSEnumerator", "iteratorHolder") + addPrivateClass("KListAsNSArray", "listHolder") + addPrivateClass("KMutableListAsNSMutableArray", "listHolder") + addPrivateClass("KSetAsNSSet", "setHolder") + addPrivateClass("KMapAsNSDictionary", "mapHolder") + + addPrivateClass("KotlinObjectHolder", "refHolder") + addPrivateClass("KotlinObjCWeakReference", "referred") + + addPrivateCategory("NSObjectToKotlin") + addPrivateCategory("NSStringToKotlin") + addPrivateCategory("NSNumberToKotlin") + addPrivateCategory("NSDecimalNumberToKotlin") + addPrivateCategory("NSArrayToKotlin") + addPrivateCategory("NSSetToKotlin") + addPrivateCategory("NSDictionaryToKotlin") + addPrivateCategory("NSEnumeratorAsAssociatedObject") + + addExportedClass(objCExportNamer.kotlinAnyName, "KotlinBase", "refHolder") + + addExportedClass(objCExportNamer.mutableSetName, "KotlinMutableSet", "setHolder") + addExportedClass(objCExportNamer.mutableMapName, "KotlinMutableDictionary", "mapHolder") + + addExportedClass(objCExportNamer.kotlinNumberName, "KotlinNumber") + NSNumberKind.values().mapNotNull { it.mappedKotlinClassId }.forEach { + addExportedClass(objCExportNamer.numberBoxName(it), "Kotlin${it.shortClassName}", "value_") + } +} + +private fun PatchBuilder.buildAndApply(llvmModule: LLVMModuleRef) { + val nameToGlobalPatch = globalPatches.associateNonRepeatingBy { it.globalName } + + val sectionToValueToLiteralPatch = literalPatches.groupBy { it.generator.section } + .mapValues { (_, patches) -> + patches.associateNonRepeatingBy { it.value } + } + + val unusedPatches = (globalPatches + literalPatches).toMutableSet() + + val globals = generateSequence(LLVMGetFirstGlobal(llvmModule), { LLVMGetNextGlobal(it) }).toList() + for (global in globals) { + val initializer = LLVMGetInitializer(global) ?: continue + val name = LLVMGetValueName(global)?.toKString().orEmpty() + + val globalPatch = nameToGlobalPatch[name] + if (globalPatch != null) { + LLVMSetValueName(global, globalPatch.newGlobalName) + unusedPatches -= globalPatch + } else if (PatchBuilder.GlobalKind.values().any { name.startsWith(it.prefix) }) { + error("Objective-C global '$name' is not patched") + } + + val section = LLVMGetSection(global)?.toKString() + sectionToValueToLiteralPatch[section]?.let { valueToLiteralPatch -> + val value = getStringValue(initializer) + val patch = valueToLiteralPatch[value] + if (patch != null) { + if (patch.newValue != value) patchLiteral(global, patch.generator, patch.newValue) + unusedPatches -= patch + } else if (section == ObjCDataGenerator.classNameGenerator.section) { + error("Objective-C class name literal is not patched: $value") + } + } + } + + unusedPatches.firstOrNull()?.let { + error("Patch is not applied: $it") + } +} + +private fun getStringValue(initializer: LLVMValueRef): String? = when (LLVMGetValueKind(initializer)) { + LLVMValueKind.LLVMConstantDataArrayValueKind -> memScoped { + require(LLVMIsConstantString(initializer) != 0) { "not a constant string: ${llvm2string(initializer)}" } + + val lengthVar = alloc() + val bytePtr = LLVMGetAsString(initializer, lengthVar.ptr)!! + val length = lengthVar.value + + val lastByte = bytePtr[length - 1] + require(lastByte == 0.toByte()) { + "${llvm2string(initializer)}:\n expected zero terminator, found $lastByte" + } + + bytePtr.toKString() + } + + LLVMValueKind.LLVMConstantAggregateZeroValueKind -> "" + + else -> error("Unexpected literal initializer: ${llvm2string(initializer)}") +} + +private fun List.associateNonRepeatingBy(keySelector: (T) -> K): Map = + this.groupBy(keySelector) + .mapValues { (key, values) -> + values.singleOrNull() + ?: error("multiple values found for $key: ${values.joinToString()}") + } + +private fun patchLiteral( + global: LLVMValueRef, + generator: ObjCDataGenerator.CStringLiteralsGenerator, + newValue: String +) { + val module = LLVMGetGlobalParent(global)!! + + val newFirstCharPtr = generator.generate(module, newValue).getElementPtr(0).llvm + + generateSequence(LLVMGetFirstUse(global), { LLVMGetNextUse(it) }).forEach { use -> + val firstCharPtr = LLVMGetUser(use)!!.also { + require(it.isFirstCharPtr(global)) { + "Unexpected literal usage: ${llvm2string(it)}" + } + } + LLVMReplaceAllUsesWith(firstCharPtr, newFirstCharPtr) + } +} + +private fun LLVMValueRef.isFirstCharPtr(global: LLVMValueRef): Boolean = + this.type == int8TypePtr && + LLVMIsConstant(this) != 0 && LLVMGetConstOpcode(this) == LLVMOpcode.LLVMGetElementPtr + && LLVMGetNumOperands(this) == 3 + && LLVMGetOperand(this, 0) == global + && LLVMGetOperand(this, 1).isZeroConst() + && LLVMGetOperand(this, 2).isZeroConst() + +private fun LLVMValueRef?.isZeroConst(): Boolean = + this != null && LLVMGetValueKind(this) == LLVMValueKind.LLVMConstantIntValueKind + && LLVMConstIntGetZExtValue(this) == 0L diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt index 049b8f9b46a..adaa156de01 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt @@ -336,7 +336,11 @@ internal class ObjCExportCodeGenerator( ObjCDataGenerator.Method(selector, getEncoding(bridge), constPointer(imp)) } - dataGenerator.emitClass("KotlinSelectorsHolder", "NSObject", instanceMethods = methods) + dataGenerator.emitClass( + "${namer.topLevelNamePrefix}KotlinSelectorsHolder", + superName = "NSObject", + instanceMethods = methods + ) } private val impType = pointerType(functionType(int8TypePtr, true, int8TypePtr, int8TypePtr)) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExport.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExport.kt index 45c7d9c1a32..25538e53cb2 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExport.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExport.kt @@ -70,13 +70,15 @@ internal class ObjCExport(val context: Context, symbolTable: SymbolTable) { } } + lateinit var namer: ObjCExportNamer + internal fun generate(codegen: CodeGenerator) { if (!target.family.isAppleFamily) return if (!context.config.produce.isFinalBinary) return // TODO: emit RTTI to the same modules as classes belong to. val mapper = exportedInterface?.mapper ?: ObjCExportMapper() - val namer = exportedInterface?.namer ?: ObjCExportNamerImpl( + namer = exportedInterface?.namer ?: ObjCExportNamerImpl( setOf(codegen.context.moduleDescriptor), context.moduleDescriptor.builtIns, mapper, diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGenerator.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGenerator.kt index 430e23795e0..b7e5c99ce84 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGenerator.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGenerator.kt @@ -91,7 +91,8 @@ internal class ObjCExportTranslatorImpl( superClass = "NSMutableDictionary" )) - stubs.add(ObjCInterfaceImpl("NSError", categoryName = "NSErrorKotlinException", members = buildMembers { + val nsErrorCategoryName = "NSError${namer.topLevelNamePrefix}KotlinException" + stubs.add(ObjCInterfaceImpl("NSError", categoryName = nsErrorCategoryName, members = buildMembers { +ObjCProperty("kotlinException", null, ObjCNullableReferenceType(ObjCIdType), listOf("readonly")) })) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportNamer.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportNamer.kt index d24fff2c4f1..fa128a6bee5 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportNamer.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportNamer.kt @@ -40,6 +40,8 @@ interface ObjCExportNamer { val objcGenerics: Boolean } + val topLevelNamePrefix: String + fun getFileClassName(file: SourceFile): ClassOrProtocolName fun getClassOrProtocolName(descriptor: ClassDescriptor): ClassOrProtocolName fun getSelector(method: FunctionDescriptor): String @@ -192,20 +194,16 @@ internal class ObjCExportNamerImpl( local ) - private fun String.toUnmangledClassOrProtocolName(): ObjCExportNamer.ClassOrProtocolName = - ObjCExportNamer.ClassOrProtocolName(swiftName = this, objCName = this) - private val objcGenerics get() = configuration.objcGenerics - private val topLevelNamePrefix get() = configuration.topLevelNamePrefix + override val topLevelNamePrefix get() = configuration.topLevelNamePrefix private val helper = ObjCExportNamingHelper(configuration.topLevelNamePrefix) private fun String.toSpecialStandardClassOrProtocolName() = ObjCExportNamer.ClassOrProtocolName( swiftName = "Kotlin$this", - objCName = "${topLevelNamePrefix}$this", - binaryName = "Kotlin$this" + objCName = "${topLevelNamePrefix}$this" ) - override val kotlinAnyName = "KotlinBase".toUnmangledClassOrProtocolName() + override val kotlinAnyName = "Base".toSpecialStandardClassOrProtocolName() override val mutableSetName = "MutableSet".toSpecialStandardClassOrProtocolName() override val mutableMapName = "MutableDictionary".toSpecialStandardClassOrProtocolName() diff --git a/backend.native/tests/framework/stdlib/stdlib.swift b/backend.native/tests/framework/stdlib/stdlib.swift index 43df1748f24..23d00392296 100644 --- a/backend.native/tests/framework/stdlib/stdlib.swift +++ b/backend.native/tests/framework/stdlib/stdlib.swift @@ -355,7 +355,7 @@ class StdlibTests : TestProvider { _ set: KotlinMutableSet, _ check: (KotlinMutableSet) throws -> Void = { _ in } ) throws { - try assertEquals(actual: String(describing: type(of: set)), expected: "KotlinMutableSet") + try assertEquals(actual: String(describing: type(of: set)), expected: "StdlibMutableSet") try check(set) try assertFalse(set.contains("1")) set.add("1") @@ -414,7 +414,7 @@ class StdlibTests : TestProvider { _ dict: KotlinMutableDictionary, _ check: (KotlinMutableDictionary) throws -> Void = { _ in } ) throws { - try assertEquals(actual: String(describing: type(of: dict)), expected: "KotlinMutableDictionary") + try assertEquals(actual: String(describing: type(of: dict)), expected: "StdlibMutableDictionary") try check(dict) try assertTrue(dict["1"] == nil) dict["1"] = "2" diff --git a/backend.native/tests/framework/values/expectedLazy.h b/backend.native/tests/framework/values/expectedLazy.h index ca37c8f08fb..ac7763bbfb5 100644 --- a/backend.native/tests/framework/values/expectedLazy.h +++ b/backend.native/tests/framework/values/expectedLazy.h @@ -1,27 +1,25 @@ -@interface KotlinBase : NSObject +__attribute__((swift_name("KotlinBase"))) +@interface ValuesBase : NSObject - (instancetype)init __attribute__((unavailable)); + (instancetype)new __attribute__((unavailable)); + (void)initialize __attribute__((objc_requires_super)); @end; -@interface KotlinBase (KotlinBaseCopying) +@interface ValuesBase (ValuesBaseCopying) @end; -__attribute__((objc_runtime_name("KotlinMutableSet"))) __attribute__((swift_name("KotlinMutableSet"))) @interface ValuesMutableSet : NSMutableSet @end; -__attribute__((objc_runtime_name("KotlinMutableDictionary"))) __attribute__((swift_name("KotlinMutableDictionary"))) @interface ValuesMutableDictionary : NSMutableDictionary @end; -@interface NSError (NSErrorKotlinException) +@interface NSError (NSErrorValuesKotlinException) @property (readonly) id _Nullable kotlinException; @end; -__attribute__((objc_runtime_name("KotlinNumber"))) __attribute__((swift_name("KotlinNumber"))) @interface ValuesNumber : NSNumber - (instancetype)initWithChar:(char)value __attribute__((unavailable)); @@ -56,77 +54,66 @@ __attribute__((swift_name("KotlinNumber"))) + (instancetype)numberWithUnsignedInteger:(NSUInteger)value __attribute__((unavailable)); @end; -__attribute__((objc_runtime_name("KotlinByte"))) __attribute__((swift_name("KotlinByte"))) @interface ValuesByte : ValuesNumber - (instancetype)initWithChar:(char)value; + (instancetype)numberWithChar:(char)value; @end; -__attribute__((objc_runtime_name("KotlinUByte"))) __attribute__((swift_name("KotlinUByte"))) @interface ValuesUByte : ValuesNumber - (instancetype)initWithUnsignedChar:(unsigned char)value; + (instancetype)numberWithUnsignedChar:(unsigned char)value; @end; -__attribute__((objc_runtime_name("KotlinShort"))) __attribute__((swift_name("KotlinShort"))) @interface ValuesShort : ValuesNumber - (instancetype)initWithShort:(short)value; + (instancetype)numberWithShort:(short)value; @end; -__attribute__((objc_runtime_name("KotlinUShort"))) __attribute__((swift_name("KotlinUShort"))) @interface ValuesUShort : ValuesNumber - (instancetype)initWithUnsignedShort:(unsigned short)value; + (instancetype)numberWithUnsignedShort:(unsigned short)value; @end; -__attribute__((objc_runtime_name("KotlinInt"))) __attribute__((swift_name("KotlinInt"))) @interface ValuesInt : ValuesNumber - (instancetype)initWithInt:(int)value; + (instancetype)numberWithInt:(int)value; @end; -__attribute__((objc_runtime_name("KotlinUInt"))) __attribute__((swift_name("KotlinUInt"))) @interface ValuesUInt : ValuesNumber - (instancetype)initWithUnsignedInt:(unsigned int)value; + (instancetype)numberWithUnsignedInt:(unsigned int)value; @end; -__attribute__((objc_runtime_name("KotlinLong"))) __attribute__((swift_name("KotlinLong"))) @interface ValuesLong : ValuesNumber - (instancetype)initWithLongLong:(long long)value; + (instancetype)numberWithLongLong:(long long)value; @end; -__attribute__((objc_runtime_name("KotlinULong"))) __attribute__((swift_name("KotlinULong"))) @interface ValuesULong : ValuesNumber - (instancetype)initWithUnsignedLongLong:(unsigned long long)value; + (instancetype)numberWithUnsignedLongLong:(unsigned long long)value; @end; -__attribute__((objc_runtime_name("KotlinFloat"))) __attribute__((swift_name("KotlinFloat"))) @interface ValuesFloat : ValuesNumber - (instancetype)initWithFloat:(float)value; + (instancetype)numberWithFloat:(float)value; @end; -__attribute__((objc_runtime_name("KotlinDouble"))) __attribute__((swift_name("KotlinDouble"))) @interface ValuesDouble : ValuesNumber - (instancetype)initWithDouble:(double)value; + (instancetype)numberWithDouble:(double)value; @end; -__attribute__((objc_runtime_name("KotlinBoolean"))) __attribute__((swift_name("KotlinBoolean"))) @interface ValuesBoolean : ValuesNumber - (instancetype)initWithBool:(BOOL)value; @@ -135,7 +122,7 @@ __attribute__((swift_name("KotlinBoolean"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("DelegateClass"))) -@interface ValuesDelegateClass : KotlinBase +@interface ValuesDelegateClass : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (ValuesKotlinArray *)getValueThisRef:(ValuesKotlinNothing * _Nullable)thisRef property:(id)property __attribute__((swift_name("getValue(thisRef:property:)"))); @@ -150,13 +137,13 @@ __attribute__((swift_name("I"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("DefaultInterfaceExt"))) -@interface ValuesDefaultInterfaceExt : KotlinBase +@interface ValuesDefaultInterfaceExt : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; __attribute__((swift_name("OpenClassI"))) -@interface ValuesOpenClassI : KotlinBase +@interface ValuesOpenClassI : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (NSString *)iFun __attribute__((swift_name("iFun()"))); @@ -212,7 +199,7 @@ __attribute__((swift_name("Enumeration"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TripleVals"))) -@interface ValuesTripleVals : KotlinBase +@interface ValuesTripleVals : ValuesBase - (instancetype)initWithFirst:(id _Nullable)first second:(id _Nullable)second third:(id _Nullable)third __attribute__((swift_name("init(first:second:third:)"))) __attribute__((objc_designated_initializer)); - (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)"))); - (NSUInteger)hash __attribute__((swift_name("hash()"))); @@ -228,7 +215,7 @@ __attribute__((swift_name("TripleVals"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TripleVars"))) -@interface ValuesTripleVars : KotlinBase +@interface ValuesTripleVars : ValuesBase - (instancetype)initWithFirst:(id _Nullable)first second:(id _Nullable)second third:(id _Nullable)third __attribute__((swift_name("init(first:second:third:)"))) __attribute__((objc_designated_initializer)); - (NSString *)description __attribute__((swift_name("description()"))); - (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)"))); @@ -243,14 +230,14 @@ __attribute__((swift_name("TripleVars"))) @end; __attribute__((swift_name("WithCompanionAndObject"))) -@interface ValuesWithCompanionAndObject : KotlinBase +@interface ValuesWithCompanionAndObject : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("WithCompanionAndObject.Companion"))) -@interface ValuesWithCompanionAndObjectCompanion : KotlinBase +@interface ValuesWithCompanionAndObjectCompanion : ValuesBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); + (instancetype)companion __attribute__((swift_name("init()"))); @@ -280,7 +267,7 @@ __attribute__((swift_name("MyException"))) @end; __attribute__((swift_name("BridgeBase"))) -@interface ValuesBridgeBase : KotlinBase +@interface ValuesBridgeBase : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (id _Nullable)foo1AndReturnError:(NSError * _Nullable * _Nullable)error __attribute__((swift_name("foo1()"))); @@ -302,21 +289,21 @@ __attribute__((swift_name("Bridge"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Deeply"))) -@interface ValuesDeeply : KotlinBase +@interface ValuesDeeply : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Deeply.Nested"))) -@interface ValuesDeeplyNested : KotlinBase +@interface ValuesDeeplyNested : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Deeply.NestedType"))) -@interface ValuesDeeplyNestedType : KotlinBase +@interface ValuesDeeplyNestedType : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @property (readonly) int32_t thirtyTwo __attribute__((swift_name("thirtyTwo"))); @@ -324,21 +311,21 @@ __attribute__((swift_name("Deeply.NestedType"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("WithGenericDeeply"))) -@interface ValuesWithGenericDeeply : KotlinBase +@interface ValuesWithGenericDeeply : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("WithGenericDeeply.Nested"))) -@interface ValuesWithGenericDeeplyNested : KotlinBase +@interface ValuesWithGenericDeeplyNested : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("WithGenericDeeply.NestedType"))) -@interface ValuesWithGenericDeeplyNestedType : KotlinBase +@interface ValuesWithGenericDeeplyNestedType : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @property (readonly) int32_t thirtyThree __attribute__((swift_name("thirtyThree"))); @@ -346,14 +333,14 @@ __attribute__((swift_name("WithGenericDeeply.NestedType"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TypeOuter"))) -@interface ValuesTypeOuter : KotlinBase +@interface ValuesTypeOuter : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TypeOuter.Type_"))) -@interface ValuesTypeOuterType_ : KotlinBase +@interface ValuesTypeOuterType_ : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @property (readonly) int32_t thirtyFour __attribute__((swift_name("thirtyFour"))); @@ -361,7 +348,7 @@ __attribute__((swift_name("TypeOuter.Type_"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("CKeywords"))) -@interface ValuesCKeywords : KotlinBase +@interface ValuesCKeywords : ValuesBase - (instancetype)initWithFloat:(float)float_ enum:(int32_t)enum_ goto:(BOOL)goto_ __attribute__((swift_name("init(float:enum:goto:)"))) __attribute__((objc_designated_initializer)); - (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)"))); - (NSUInteger)hash __attribute__((swift_name("hash()"))); @@ -393,7 +380,7 @@ __attribute__((swift_name("Base2"))) @end; __attribute__((swift_name("Base23"))) -@interface ValuesBase23 : KotlinBase +@interface ValuesBase23 : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (ValuesInt *)sameValue:(ValuesInt * _Nullable)value __attribute__((swift_name("same(value:)"))); @@ -412,7 +399,7 @@ __attribute__((swift_name("TransformWithDefault"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TransformInheritingDefault"))) -@interface ValuesTransformInheritingDefault : KotlinBase +@interface ValuesTransformInheritingDefault : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; @@ -424,7 +411,7 @@ __attribute__((swift_name("TransformIntString"))) @end; __attribute__((swift_name("TransformIntToString"))) -@interface ValuesTransformIntToString : KotlinBase +@interface ValuesTransformIntToString : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (NSString *)mapValue:(ValuesInt *)intValue __attribute__((swift_name("map(value:)"))); @@ -440,7 +427,7 @@ __attribute__((swift_name("TransformIntToDecimalString"))) @end; __attribute__((swift_name("TransformIntToLong"))) -@interface ValuesTransformIntToLong : KotlinBase +@interface ValuesTransformIntToLong : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (ValuesLong *)mapValue:(ValuesInt *)value __attribute__((swift_name("map(value:)"))); @@ -448,21 +435,21 @@ __attribute__((swift_name("TransformIntToLong"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("GH2931"))) -@interface ValuesGH2931 : KotlinBase +@interface ValuesGH2931 : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("GH2931.Data"))) -@interface ValuesGH2931Data : KotlinBase +@interface ValuesGH2931Data : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("GH2931.Holder"))) -@interface ValuesGH2931Holder : KotlinBase +@interface ValuesGH2931Holder : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @property (readonly) ValuesGH2931Data *data __attribute__((swift_name("data"))); @@ -470,7 +457,7 @@ __attribute__((swift_name("GH2931.Holder"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("GH2945"))) -@interface ValuesGH2945 : KotlinBase +@interface ValuesGH2945 : ValuesBase - (instancetype)initWithErrno:(int32_t)errno __attribute__((swift_name("init(errno:)"))) __attribute__((objc_designated_initializer)); - (int32_t)testErrnoInSelectorP:(int32_t)p errno:(int32_t)errno __attribute__((swift_name("testErrnoInSelector(p:errno:)"))); @property int32_t errno __attribute__((swift_name("errno"))); @@ -478,7 +465,7 @@ __attribute__((swift_name("GH2945"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("GH2830"))) -@interface ValuesGH2830 : KotlinBase +@interface ValuesGH2830 : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (id)getI __attribute__((swift_name("getI()"))); @@ -491,7 +478,7 @@ __attribute__((swift_name("GH2830I"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("GH2959"))) -@interface ValuesGH2959 : KotlinBase +@interface ValuesGH2959 : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (NSArray> *)getIId:(int32_t)id __attribute__((swift_name("getI(id:)"))); @@ -512,7 +499,7 @@ __attribute__((swift_name("IntBlocks"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("IntBlocksImpl"))) -@interface ValuesIntBlocksImpl : KotlinBase +@interface ValuesIntBlocksImpl : ValuesBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); + (instancetype)intBlocksImpl __attribute__((swift_name("init()"))); @@ -529,7 +516,7 @@ __attribute__((swift_name("UnitBlockCoercion"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("UnitBlockCoercionImpl"))) -@interface ValuesUnitBlockCoercionImpl : KotlinBase +@interface ValuesUnitBlockCoercionImpl : ValuesBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); + (instancetype)unitBlockCoercionImpl __attribute__((swift_name("init()"))); @@ -543,7 +530,7 @@ __attribute__((swift_name("MyAbstractList"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TestKClass"))) -@interface ValuesTestKClass : KotlinBase +@interface ValuesTestKClass : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (id _Nullable)getKotlinClassClazz:(Class)clazz __attribute__((swift_name("getKotlinClass(clazz:)"))); @@ -575,7 +562,7 @@ __attribute__((swift_name("ForwardC2"))) @end; __attribute__((swift_name("ForwardC1"))) -@interface ValuesForwardC1 : KotlinBase +@interface ValuesForwardC1 : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (ValuesForwardC2 *)getForwardC2 __attribute__((swift_name("getForwardC2()"))); @@ -601,7 +588,7 @@ __attribute__((swift_name("TestClashes2"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TestClashesImpl"))) -@interface ValuesTestClashesImpl : KotlinBase +@interface ValuesTestClashesImpl : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @property (readonly) int32_t clashingProperty __attribute__((swift_name("clashingProperty"))); @@ -610,7 +597,7 @@ __attribute__((swift_name("TestClashesImpl"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TestInvalidIdentifiers"))) -@interface ValuesTestInvalidIdentifiers : KotlinBase +@interface ValuesTestInvalidIdentifiers : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (int32_t)a_d_d_1:(int32_t)_1 _2:(int32_t)_2 _3:(int32_t)_3 __attribute__((swift_name("a_d_d(_1:_2:_3:)"))); @@ -621,14 +608,14 @@ __attribute__((swift_name("TestInvalidIdentifiers"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TestInvalidIdentifiers._Foo"))) -@interface ValuesTestInvalidIdentifiers_Foo : KotlinBase +@interface ValuesTestInvalidIdentifiers_Foo : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TestInvalidIdentifiers.Bar_"))) -@interface ValuesTestInvalidIdentifiersBar_ : KotlinBase +@interface ValuesTestInvalidIdentifiersBar_ : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; @@ -649,7 +636,7 @@ __attribute__((swift_name("TestInvalidIdentifiers.E"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TestInvalidIdentifiers.Companion_"))) -@interface ValuesTestInvalidIdentifiersCompanion_ : KotlinBase +@interface ValuesTestInvalidIdentifiersCompanion_ : ValuesBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); + (instancetype)companion_ __attribute__((swift_name("init()"))); @@ -657,7 +644,7 @@ __attribute__((swift_name("TestInvalidIdentifiers.Companion_"))) @end; __attribute__((swift_name("TestDeprecation"))) -@interface ValuesTestDeprecation : KotlinBase +@interface ValuesTestDeprecation : ValuesBase - (instancetype)initWithError:(int16_t)error __attribute__((swift_name("init(error:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable("error"))); - (instancetype)initWithWarning:(int32_t)warning __attribute__((swift_name("init(warning:)"))) __attribute__((objc_designated_initializer)) __attribute__((deprecated("warning"))); - (instancetype)initWithNormal:(int64_t)normal __attribute__((swift_name("init(normal:)"))) __attribute__((objc_designated_initializer)); @@ -720,7 +707,7 @@ __attribute__((swift_name("TestDeprecationHiddenInterface"))) @end; __attribute__((swift_name("TestDeprecation.ImplementingHidden"))) -@interface ValuesTestDeprecationImplementingHidden : KotlinBase +@interface ValuesTestDeprecationImplementingHidden : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (int32_t)effectivelyHidden __attribute__((swift_name("effectivelyHidden()"))); @@ -783,7 +770,7 @@ __attribute__((swift_name("TestDeprecationErrorInterface"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TestDeprecation.ImplementingError"))) -@interface ValuesTestDeprecationImplementingError : KotlinBase +@interface ValuesTestDeprecationImplementingError : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; @@ -821,7 +808,7 @@ __attribute__((swift_name("TestDeprecationWarningInterface"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TestDeprecation.ImplementingWarning"))) -@interface ValuesTestDeprecationImplementingWarning : KotlinBase +@interface ValuesTestDeprecationImplementingWarning : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; @@ -953,7 +940,7 @@ __attribute__((swift_name("TopLevelHidden.InnerInner"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("TestWeakRefs"))) -@interface ValuesTestWeakRefs : KotlinBase +@interface ValuesTestWeakRefs : ValuesBase - (instancetype)initWithFrozen:(BOOL)frozen __attribute__((swift_name("init(frozen:)"))) __attribute__((objc_designated_initializer)); - (id)getObj __attribute__((swift_name("getObj()"))); - (void)clearObj __attribute__((swift_name("clearObj()"))); @@ -962,7 +949,7 @@ __attribute__((swift_name("TestWeakRefs"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("SharedRefs"))) -@interface ValuesSharedRefs : KotlinBase +@interface ValuesSharedRefs : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (ValuesSharedRefsMutableData *)createRegularObject __attribute__((swift_name("createRegularObject()"))); @@ -976,7 +963,7 @@ __attribute__((swift_name("SharedRefs"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("SharedRefs.MutableData"))) -@interface ValuesSharedRefsMutableData : KotlinBase +@interface ValuesSharedRefsMutableData : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (void)update __attribute__((swift_name("update()"))); @@ -984,7 +971,7 @@ __attribute__((swift_name("SharedRefs.MutableData"))) @end; __attribute__((swift_name("ClassForTypeCheck"))) -@interface ValuesClassForTypeCheck : KotlinBase +@interface ValuesClassForTypeCheck : ValuesBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; @@ -1000,7 +987,7 @@ __attribute__((swift_name("InterfaceForTypeCheck"))) __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("ValuesKt"))) -@interface ValuesValuesKt : KotlinBase +@interface ValuesValuesKt : ValuesBase + (ValuesBoolean * _Nullable)boxBooleanValue:(BOOL)booleanValue __attribute__((swift_name("box(booleanValue:)"))); + (ValuesByte * _Nullable)boxByteValue:(int8_t)byteValue __attribute__((swift_name("box(byteValue:)"))); + (ValuesShort * _Nullable)boxShortValue:(int16_t)shortValue __attribute__((swift_name("box(shortValue:)")));