[K/N] Modularise :kotlin-native:native.backend to extract objc header generation (2/2)
^KT-63905 Fixed
This commit is contained in:
committed by
Space Team
parent
ae9f3d66c2
commit
0713866c1e
@@ -0,0 +1,2 @@
|
||||
[*]
|
||||
ij_continuation_indent_size = 4
|
||||
@@ -0,0 +1,33 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(intellijCore())
|
||||
implementation(project(":compiler:cli-base"))
|
||||
implementation(project(":compiler:cli-common"))
|
||||
implementation(project(":compiler:ir.objcinterop"))
|
||||
implementation(project(":compiler:ir.serialization.native"))
|
||||
implementation(project(":core:compiler.common.native"))
|
||||
implementation(project(":core:descriptors"))
|
||||
implementation(project(":native:base"))
|
||||
implementation(project(":native:kotlin-native-utils"))
|
||||
|
||||
testImplementation(libs.junit.jupiter.api)
|
||||
testImplementation(libs.junit.jupiter.params)
|
||||
testImplementation(project(":compiler:tests-common", "tests-jar"))
|
||||
|
||||
testRuntimeOnly(libs.junit.jupiter.engine)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
optIn.add("org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi")
|
||||
}
|
||||
}
|
||||
|
||||
nativeTest("test", tag = null) {
|
||||
useJUnitPlatform()
|
||||
systemProperty("projectDir", projectDir.absolutePath)
|
||||
workingDir(rootProject.projectDir)
|
||||
}
|
||||
+7
-4
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright 2010-2018 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.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionTypeKind
|
||||
import org.jetbrains.kotlin.builtins.getFunctionTypeKind
|
||||
@@ -15,12 +16,14 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
internal fun ClassDescriptor.isMappedFunctionClass() =
|
||||
@InternalKotlinNativeApi
|
||||
fun ClassDescriptor.isMappedFunctionClass() =
|
||||
this.getFunctionTypeKind() == FunctionTypeKind.Function &&
|
||||
// Type parameters include return type.
|
||||
declaredTypeParameters.size - 1 < CustomTypeMappers.functionTypeMappersArityLimit
|
||||
|
||||
internal interface CustomTypeMapper {
|
||||
@InternalKotlinNativeApi
|
||||
interface CustomTypeMapper {
|
||||
val mappedClassId: ClassId
|
||||
fun mapType(mappedSuperType: KotlinType, translator: ObjCExportTranslatorImpl, objCExportScope: ObjCExportScope): ObjCNonNullReferenceType
|
||||
}
|
||||
|
||||
+3
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.getPackageFragments
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -14,7 +15,8 @@ import org.jetbrains.kotlin.name.isSubpackageOf
|
||||
* Tries to infer a main package name that can be used
|
||||
* for bundle ID of a framework.
|
||||
*/
|
||||
internal class MainPackageGuesser {
|
||||
@InternalKotlinNativeApi
|
||||
class MainPackageGuesser {
|
||||
fun guess(
|
||||
moduleDescriptor: ModuleDescriptor,
|
||||
includedLibraryDescriptors: List<ModuleDescriptor>,
|
||||
|
||||
+24
-35
@@ -1,44 +1,55 @@
|
||||
/*
|
||||
* Copyright 2010-2018 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.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.descriptors.allParameters
|
||||
import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.util.allParameters
|
||||
|
||||
internal sealed class TypeBridge
|
||||
internal object ReferenceBridge : TypeBridge()
|
||||
@InternalKotlinNativeApi
|
||||
sealed class TypeBridge
|
||||
|
||||
internal data class BlockPointerBridge(
|
||||
@InternalKotlinNativeApi
|
||||
object ReferenceBridge : TypeBridge()
|
||||
|
||||
@InternalKotlinNativeApi
|
||||
data class BlockPointerBridge(
|
||||
val numberOfParameters: Int,
|
||||
val returnsVoid: Boolean
|
||||
) : TypeBridge()
|
||||
|
||||
internal data class ValueTypeBridge(val objCValueType: ObjCValueType) : TypeBridge()
|
||||
@InternalKotlinNativeApi
|
||||
data class ValueTypeBridge(val objCValueType: ObjCValueType) : TypeBridge()
|
||||
|
||||
internal sealed class MethodBridgeParameter
|
||||
@InternalKotlinNativeApi
|
||||
sealed class MethodBridgeParameter
|
||||
|
||||
internal sealed class MethodBridgeReceiver : MethodBridgeParameter() {
|
||||
@InternalKotlinNativeApi
|
||||
sealed class MethodBridgeReceiver : MethodBridgeParameter() {
|
||||
object Static : MethodBridgeReceiver()
|
||||
object Factory : MethodBridgeReceiver()
|
||||
object Instance : MethodBridgeReceiver()
|
||||
}
|
||||
|
||||
internal object MethodBridgeSelector : MethodBridgeParameter()
|
||||
@InternalKotlinNativeApi
|
||||
object MethodBridgeSelector : MethodBridgeParameter()
|
||||
|
||||
internal sealed class MethodBridgeValueParameter : MethodBridgeParameter() {
|
||||
@InternalKotlinNativeApi
|
||||
sealed class MethodBridgeValueParameter : MethodBridgeParameter() {
|
||||
data class Mapped(val bridge: TypeBridge) : MethodBridgeValueParameter()
|
||||
object ErrorOutParameter : MethodBridgeValueParameter()
|
||||
data class SuspendCompletion(val useUnitCompletion: Boolean) : MethodBridgeValueParameter()
|
||||
}
|
||||
|
||||
internal data class MethodBridge(
|
||||
@InternalKotlinNativeApi
|
||||
data class MethodBridge(
|
||||
val returnBridge: ReturnValue,
|
||||
val receiver: MethodBridgeReceiver,
|
||||
val valueParameters: List<MethodBridgeValueParameter>
|
||||
@@ -76,7 +87,8 @@ internal data class MethodBridge(
|
||||
get() = returnBridge is ReturnValue.WithError
|
||||
}
|
||||
|
||||
internal fun MethodBridge.valueParametersAssociated(
|
||||
@InternalKotlinNativeApi
|
||||
fun MethodBridge.valueParametersAssociated(
|
||||
descriptor: FunctionDescriptor
|
||||
): List<Pair<MethodBridgeValueParameter, ParameterDescriptor?>> {
|
||||
val kotlinParameters = descriptor.allParameters.iterator()
|
||||
@@ -97,26 +109,3 @@ internal fun MethodBridge.valueParametersAssociated(
|
||||
}
|
||||
}.also { assert(!kotlinParameters.hasNext()) }
|
||||
}
|
||||
|
||||
internal fun MethodBridge.parametersAssociated(
|
||||
irFunction: IrFunction
|
||||
): List<Pair<MethodBridgeParameter, IrValueParameter?>> {
|
||||
val kotlinParameters = irFunction.allParameters.iterator()
|
||||
|
||||
return this.paramBridges.map {
|
||||
when (it) {
|
||||
is MethodBridgeValueParameter.Mapped,
|
||||
MethodBridgeReceiver.Instance,
|
||||
is MethodBridgeValueParameter.SuspendCompletion ->
|
||||
it to kotlinParameters.next()
|
||||
|
||||
MethodBridgeReceiver.Static, MethodBridgeSelector, MethodBridgeValueParameter.ErrorOutParameter ->
|
||||
it to null
|
||||
|
||||
MethodBridgeReceiver.Factory -> {
|
||||
kotlinParameters.next()
|
||||
it to null
|
||||
}
|
||||
}
|
||||
}.also { assert(!kotlinParameters.hasNext()) }
|
||||
}
|
||||
|
||||
+31
-16
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2018 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.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
@@ -52,12 +52,13 @@ interface ObjCExportProblemCollector {
|
||||
}
|
||||
}
|
||||
|
||||
internal class ObjCExportTranslatorImpl(
|
||||
private val generator: ObjCExportHeaderGenerator?,
|
||||
val mapper: ObjCExportMapper,
|
||||
val namer: ObjCExportNamer,
|
||||
val problemCollector: ObjCExportProblemCollector,
|
||||
val objcGenerics: Boolean
|
||||
@InternalKotlinNativeApi
|
||||
class ObjCExportTranslatorImpl(
|
||||
private val generator: ObjCExportHeaderGenerator?,
|
||||
val mapper: ObjCExportMapper,
|
||||
val namer: ObjCExportNamer,
|
||||
val problemCollector: ObjCExportProblemCollector,
|
||||
val objcGenerics: Boolean
|
||||
) : ObjCExportTranslator {
|
||||
|
||||
private val kotlinAnyName = namer.kotlinAnyName
|
||||
@@ -1096,12 +1097,12 @@ internal class ObjCExportTranslatorImpl(
|
||||
StubBuilder<S>(problemCollector).apply(block).build()
|
||||
}
|
||||
|
||||
abstract class ObjCExportHeaderGenerator internal constructor(
|
||||
val moduleDescriptors: List<ModuleDescriptor>,
|
||||
internal val mapper: ObjCExportMapper,
|
||||
val namer: ObjCExportNamer,
|
||||
val objcGenerics: Boolean,
|
||||
problemCollector: ObjCExportProblemCollector
|
||||
abstract class ObjCExportHeaderGenerator @InternalKotlinNativeApi constructor(
|
||||
val moduleDescriptors: List<ModuleDescriptor>,
|
||||
internal val mapper: ObjCExportMapper,
|
||||
val namer: ObjCExportNamer,
|
||||
val objcGenerics: Boolean,
|
||||
problemCollector: ObjCExportProblemCollector
|
||||
) {
|
||||
private val stubs = mutableListOf<Stub<*>>()
|
||||
|
||||
@@ -1173,7 +1174,8 @@ abstract class ObjCExportHeaderGenerator internal constructor(
|
||||
add("NS_ASSUME_NONNULL_END")
|
||||
}
|
||||
|
||||
internal fun buildInterface(): ObjCExportedInterface {
|
||||
@InternalKotlinNativeApi
|
||||
fun buildInterface(): ObjCExportedInterface {
|
||||
val headerLines = build()
|
||||
return ObjCExportedInterface(generatedClasses, extensions, topLevel, headerLines, namer, mapper)
|
||||
}
|
||||
@@ -1356,6 +1358,18 @@ abstract class ObjCExportHeaderGenerator internal constructor(
|
||||
add("#import <$it>")
|
||||
}
|
||||
}
|
||||
|
||||
fun createInstance(
|
||||
moduleDescriptors: List<ModuleDescriptor>,
|
||||
mapper: ObjCExportMapper,
|
||||
namer: ObjCExportNamer,
|
||||
problemCollector: ObjCExportProblemCollector,
|
||||
objcGenerics: Boolean,
|
||||
shouldExportKDoc: Boolean,
|
||||
additionalImports: List<String>,
|
||||
): ObjCExportHeaderGenerator = ObjCExportHeaderGeneratorImpl(
|
||||
moduleDescriptors, mapper, namer, problemCollector, objcGenerics, shouldExportKDoc, additionalImports
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1423,7 +1437,8 @@ private fun computeSuperClassType(descriptor: ClassDescriptor): KotlinType? =
|
||||
|
||||
internal const val OBJC_SUBCLASSING_RESTRICTED = "objc_subclassing_restricted"
|
||||
|
||||
internal fun ClassDescriptor.needCompanionObjectProperty(namer: ObjCExportNamer, mapper: ObjCExportMapper): Boolean {
|
||||
@InternalKotlinNativeApi
|
||||
fun ClassDescriptor.needCompanionObjectProperty(namer: ObjCExportNamer, mapper: ObjCExportMapper): Boolean {
|
||||
val companionObject = companionObjectDescriptor
|
||||
if (companionObject == null || !mapper.shouldBeExposed(companionObject)) return false
|
||||
|
||||
|
||||
+6
-39
@@ -1,54 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2018 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.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys
|
||||
import org.jetbrains.kotlin.backend.konan.driver.PhaseContext
|
||||
import org.jetbrains.kotlin.backend.konan.reportCompilationWarning
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageUtil
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
|
||||
internal class ObjCExportHeaderGeneratorImpl(
|
||||
val context: PhaseContext,
|
||||
moduleDescriptors: List<ModuleDescriptor>,
|
||||
mapper: ObjCExportMapper,
|
||||
namer: ObjCExportNamer,
|
||||
problemCollector: ObjCExportProblemCollector,
|
||||
objcGenerics: Boolean
|
||||
objcGenerics: Boolean,
|
||||
override val shouldExportKDoc: Boolean,
|
||||
private val additionalImports: List<String>,
|
||||
) : ObjCExportHeaderGenerator(moduleDescriptors, mapper, namer, objcGenerics, problemCollector) {
|
||||
|
||||
override val shouldExportKDoc = context.shouldExportKDoc()
|
||||
|
||||
internal class ProblemCollector(val context: PhaseContext) : ObjCExportProblemCollector {
|
||||
override fun reportWarning(text: String) {
|
||||
context.reportCompilationWarning(text)
|
||||
}
|
||||
|
||||
override fun reportWarning(declaration: DeclarationDescriptor, text: String) {
|
||||
val psi = (declaration as? DeclarationDescriptorWithSource)?.source?.getPsi()
|
||||
?: return reportWarning(
|
||||
"$text\n (at ${DescriptorRenderer.COMPACT_WITH_SHORT_TYPES.render(declaration)})"
|
||||
)
|
||||
|
||||
val location = MessageUtil.psiElementToMessageLocation(psi)
|
||||
|
||||
context.messageCollector.report(CompilerMessageSeverity.WARNING, text, location)
|
||||
}
|
||||
|
||||
override fun reportException(throwable: Throwable) {
|
||||
throw throwable
|
||||
}
|
||||
}
|
||||
|
||||
override fun getAdditionalImports(): List<String> =
|
||||
context.config.configuration.getNotNull(KonanConfigKeys.FRAMEWORK_IMPORT_HEADERS)
|
||||
additionalImports
|
||||
}
|
||||
|
||||
+5
-3
@@ -1,12 +1,13 @@
|
||||
/*
|
||||
* 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.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi
|
||||
import org.jetbrains.kotlin.backend.konan.UnitSuspendFunctionObjCExport
|
||||
import org.jetbrains.kotlin.descriptors.konan.isNativeStdlib
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
@@ -79,7 +80,8 @@ fun createObjCExportLazy(
|
||||
deprecationResolver
|
||||
)
|
||||
|
||||
internal class ObjCExportLazyImpl(
|
||||
@InternalKotlinNativeApi
|
||||
class ObjCExportLazyImpl(
|
||||
private val configuration: ObjCExportLazy.Configuration,
|
||||
problemCollector: ObjCExportProblemCollector,
|
||||
private val codeAnalyzer: KotlinCodeAnalyzer,
|
||||
|
||||
+5
-3
@@ -1,14 +1,16 @@
|
||||
/*
|
||||
* 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.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi
|
||||
import org.jetbrains.kotlin.konan.file.File
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
internal fun ObjCExportLazy.dumpObjCHeader(files: Collection<KtFile>, outputFile: String, shouldExportKDoc: Boolean) {
|
||||
@InternalKotlinNativeApi
|
||||
fun ObjCExportLazy.dumpObjCHeader(files: Collection<KtFile>, outputFile: String, shouldExportKDoc: Boolean) {
|
||||
val lines = (this.generateBase() + files.flatMap { this.translate(it) })
|
||||
.flatMap { StubRenderer.render(it, shouldExportKDoc) + listOf("") }
|
||||
|
||||
|
||||
+40
-31
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2018 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.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
@@ -25,10 +25,11 @@ import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.typeUtil.isNothing
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
|
||||
internal class ObjCExportMapper(
|
||||
internal val deprecationResolver: DeprecationResolver? = null,
|
||||
private val local: Boolean = false,
|
||||
internal val unitSuspendFunctionExport: UnitSuspendFunctionObjCExport
|
||||
@InternalKotlinNativeApi
|
||||
class ObjCExportMapper(
|
||||
internal val deprecationResolver: DeprecationResolver? = null,
|
||||
private val local: Boolean = false,
|
||||
internal val unitSuspendFunctionExport: UnitSuspendFunctionObjCExport
|
||||
) {
|
||||
fun getCustomTypeMapper(descriptor: ClassDescriptor): CustomTypeMapper? = CustomTypeMappers.getMapper(descriptor)
|
||||
|
||||
@@ -89,7 +90,8 @@ private fun isComponentNMethod(method: CallableMemberDescriptor): Boolean {
|
||||
}
|
||||
|
||||
// Note: partially duplicated in ObjCExportLazyImpl.translateTopLevels.
|
||||
internal fun ObjCExportMapper.shouldBeExposed(descriptor: CallableMemberDescriptor): Boolean = when {
|
||||
@InternalKotlinNativeApi
|
||||
fun ObjCExportMapper.shouldBeExposed(descriptor: CallableMemberDescriptor): Boolean = when {
|
||||
!descriptor.isEffectivelyPublicApi -> false
|
||||
descriptor.isExpect -> false
|
||||
isHiddenByDeprecation(descriptor) -> false
|
||||
@@ -208,29 +210,33 @@ private fun ObjCExportMapper.isBase(descriptor: CallableMemberDescriptor): Boole
|
||||
* ```
|
||||
* Interface `I` is not exposed to the generated header, so C#f is considered to be a base method even though it has an "override" keyword.
|
||||
*/
|
||||
internal fun ObjCExportMapper.isBaseMethod(descriptor: FunctionDescriptor) =
|
||||
this.isBase(descriptor)
|
||||
@InternalKotlinNativeApi
|
||||
fun ObjCExportMapper.isBaseMethod(descriptor: FunctionDescriptor) =
|
||||
this.isBase(descriptor)
|
||||
|
||||
internal fun ObjCExportMapper.getBaseMethods(descriptor: FunctionDescriptor): List<FunctionDescriptor> =
|
||||
if (isBaseMethod(descriptor)) {
|
||||
listOf(descriptor)
|
||||
} else {
|
||||
descriptor.overriddenDescriptors.filter { shouldBeExposed(it) }
|
||||
.flatMap { getBaseMethods(it.original)}
|
||||
.distinct()
|
||||
}
|
||||
@InternalKotlinNativeApi
|
||||
fun ObjCExportMapper.getBaseMethods(descriptor: FunctionDescriptor): List<FunctionDescriptor> =
|
||||
if (isBaseMethod(descriptor)) {
|
||||
listOf(descriptor)
|
||||
} else {
|
||||
descriptor.overriddenDescriptors.filter { shouldBeExposed(it) }
|
||||
.flatMap { getBaseMethods(it.original) }
|
||||
.distinct()
|
||||
}
|
||||
|
||||
internal fun ObjCExportMapper.isBaseProperty(descriptor: PropertyDescriptor) =
|
||||
isBase(descriptor)
|
||||
@InternalKotlinNativeApi
|
||||
fun ObjCExportMapper.isBaseProperty(descriptor: PropertyDescriptor) =
|
||||
isBase(descriptor)
|
||||
|
||||
internal fun ObjCExportMapper.getBaseProperties(descriptor: PropertyDescriptor): List<PropertyDescriptor> =
|
||||
if (isBaseProperty(descriptor)) {
|
||||
listOf(descriptor)
|
||||
} else {
|
||||
descriptor.overriddenDescriptors
|
||||
.flatMap { getBaseProperties(it.original) }
|
||||
.distinct()
|
||||
}
|
||||
@InternalKotlinNativeApi
|
||||
fun ObjCExportMapper.getBaseProperties(descriptor: PropertyDescriptor): List<PropertyDescriptor> =
|
||||
if (isBaseProperty(descriptor)) {
|
||||
listOf(descriptor)
|
||||
} else {
|
||||
descriptor.overriddenDescriptors
|
||||
.flatMap { getBaseProperties(it.original) }
|
||||
.distinct()
|
||||
}
|
||||
|
||||
@Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472
|
||||
internal tailrec fun KotlinType.getErasedTypeClass(): ClassDescriptor =
|
||||
@@ -242,7 +248,8 @@ internal fun ObjCExportMapper.isTopLevel(descriptor: CallableMemberDescriptor):
|
||||
internal fun ObjCExportMapper.isObjCProperty(property: PropertyDescriptor): Boolean =
|
||||
property.extensionReceiverParameter == null || getClassIfCategory(property) != null
|
||||
|
||||
internal fun ClassDescriptor.getEnumValuesFunctionDescriptor(): SimpleFunctionDescriptor? {
|
||||
@InternalKotlinNativeApi
|
||||
fun ClassDescriptor.getEnumValuesFunctionDescriptor(): SimpleFunctionDescriptor? {
|
||||
require(this.kind == ClassKind.ENUM_CLASS)
|
||||
|
||||
return this.staticScope.getContributedFunctions(
|
||||
@@ -251,7 +258,8 @@ internal fun ClassDescriptor.getEnumValuesFunctionDescriptor(): SimpleFunctionDe
|
||||
).singleOrNull { it.extensionReceiverParameter == null && it.valueParameters.size == 0 }
|
||||
}
|
||||
|
||||
internal fun ClassDescriptor.getEnumEntriesPropertyDescriptor(): PropertyDescriptor? {
|
||||
@InternalKotlinNativeApi
|
||||
fun ClassDescriptor.getEnumEntriesPropertyDescriptor(): PropertyDescriptor? {
|
||||
require(this.kind == ClassKind.ENUM_CLASS)
|
||||
|
||||
return this.staticScope.getContributedVariables(
|
||||
@@ -312,7 +320,7 @@ private fun ObjCExportMapper.bridgeFunctionType(kotlinType: KotlinType): TypeBri
|
||||
}
|
||||
|
||||
private fun ObjCExportMapper.bridgeParameter(parameter: ParameterDescriptor): MethodBridgeValueParameter =
|
||||
MethodBridgeValueParameter.Mapped(bridgeType(parameter.type))
|
||||
MethodBridgeValueParameter.Mapped(bridgeType(parameter.type))
|
||||
|
||||
private fun ObjCExportMapper.bridgeReturnType(
|
||||
descriptor: FunctionDescriptor,
|
||||
@@ -427,7 +435,8 @@ internal fun ObjCExportMapper.bridgePropertyType(descriptor: PropertyDescriptor)
|
||||
return bridgeType(descriptor.type)
|
||||
}
|
||||
|
||||
internal enum class NSNumberKind(val mappedKotlinClassId: ClassId?, val objCType: ObjCType) {
|
||||
@InternalKotlinNativeApi
|
||||
enum class NSNumberKind(val mappedKotlinClassId: ClassId?, val objCType: ObjCType) {
|
||||
CHAR(PrimitiveType.BYTE, ObjCPrimitiveType.char),
|
||||
UNSIGNED_CHAR(UnsignedType.UBYTE, ObjCPrimitiveType.unsigned_char),
|
||||
SHORT(PrimitiveType.SHORT, ObjCPrimitiveType.short),
|
||||
|
||||
+17
-16
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2018 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.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.serialization.findSourceFile
|
||||
import org.jetbrains.kotlin.backend.konan.*
|
||||
import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi
|
||||
import org.jetbrains.kotlin.backend.konan.KonanFqNames
|
||||
import org.jetbrains.kotlin.backend.konan.UnitSuspendFunctionObjCExport
|
||||
import org.jetbrains.kotlin.backend.konan.cKeywords
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.isArray
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.isInterface
|
||||
import org.jetbrains.kotlin.backend.konan.driver.PhaseContext
|
||||
import org.jetbrains.kotlin.descriptors.konan.isNativeStdlib
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.konan.*
|
||||
import org.jetbrains.kotlin.descriptors.konan.isNativeStdlib
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.library.metadata.CurrentKlibModuleOrigin
|
||||
import org.jetbrains.kotlin.library.metadata.DeserializedKlibModuleOrigin
|
||||
@@ -88,9 +88,12 @@ interface ObjCExportNamer {
|
||||
fun getCompanionObjectPropertySelector(descriptor: ClassDescriptor): String
|
||||
|
||||
companion object {
|
||||
internal const val kotlinThrowableAsErrorMethodName: String = "asError"
|
||||
internal const val objectPropertyName: String = "shared"
|
||||
internal const val companionObjectPropertyName: String = "companion"
|
||||
@InternalKotlinNativeApi
|
||||
const val kotlinThrowableAsErrorMethodName: String = "asError"
|
||||
@InternalKotlinNativeApi
|
||||
const val objectPropertyName: String = "shared"
|
||||
@InternalKotlinNativeApi
|
||||
const val companionObjectPropertyName: String = "companion"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,14 +276,14 @@ private class ObjCExportNamingHelper(
|
||||
"char", "long", "float", "double", "int32_t", "int64_t", "int16_t", "int8_t", "unichar")
|
||||
}
|
||||
|
||||
internal class ObjCExportNamerImpl(
|
||||
@InternalKotlinNativeApi
|
||||
class ObjCExportNamerImpl(
|
||||
private val configuration: ObjCExportNamer.Configuration,
|
||||
builtIns: KotlinBuiltIns,
|
||||
private val mapper: ObjCExportMapper,
|
||||
private val problemCollector: ObjCExportProblemCollector,
|
||||
private val local: Boolean
|
||||
) : ObjCExportNamer {
|
||||
|
||||
constructor(
|
||||
moduleDescriptors: Set<ModuleDescriptor>,
|
||||
builtIns: KotlinBuiltIns,
|
||||
@@ -703,7 +706,7 @@ internal class ObjCExportNamerImpl(
|
||||
builtIns.mutableMap to mutableMapName
|
||||
)
|
||||
|
||||
predefinedClassNames.forEach { descriptor, name ->
|
||||
predefinedClassNames.forEach { (descriptor, name) ->
|
||||
objCClassNames.forceAssign(descriptor, name.objCName)
|
||||
swiftClassAndProtocolNames.forceAssign(descriptor, name.swiftName)
|
||||
}
|
||||
@@ -714,11 +717,11 @@ internal class ObjCExportNamerImpl(
|
||||
NoLookupLocation.FROM_BACKEND
|
||||
).single()
|
||||
|
||||
Predefined.anyMethodSelectors.forEach { name, selector ->
|
||||
Predefined.anyMethodSelectors.forEach { (name, selector) ->
|
||||
methodSelectors.forceAssign(any.method(name), selector)
|
||||
}
|
||||
|
||||
Predefined.anyMethodSwiftNames.forEach { name, swiftName ->
|
||||
Predefined.anyMethodSwiftNames.forEach { (name, swiftName) ->
|
||||
methodSwiftNames.forceAssign(any.method(name), swiftName)
|
||||
}
|
||||
}
|
||||
@@ -1082,8 +1085,6 @@ internal val ModuleDescriptor.objCExportAdditionalNamePrefix: String get() {
|
||||
return abbreviate(fullPrefix)
|
||||
}
|
||||
|
||||
internal val PhaseContext.objCExportTopLevelNamePrefix: String
|
||||
get() = abbreviate(config.fullExportedNamePrefix)
|
||||
|
||||
fun abbreviate(name: String): String {
|
||||
val normalizedName = name
|
||||
|
||||
+4
-2
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.isInterface
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
@@ -35,7 +36,8 @@ internal inline fun <reified T : ObjCExportScope> ObjCExportScope.nearestScopeOf
|
||||
return null
|
||||
}
|
||||
|
||||
internal object ObjCRootExportScope : ObjCExportScope
|
||||
@InternalKotlinNativeApi
|
||||
object ObjCRootExportScope : ObjCExportScope
|
||||
|
||||
interface ObjCClassExportScope : ObjCExportScope {
|
||||
fun getGenericTypeUsage(typeParameterDescriptor: TypeParameterDescriptor?): ObjCGenericTypeUsage?
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SourceFile
|
||||
|
||||
@InternalKotlinNativeApi
|
||||
class ObjCExportedInterface internal constructor(
|
||||
val generatedClasses: Set<ClassDescriptor>,
|
||||
val categoryMembers: Map<ClassDescriptor, List<CallableMemberDescriptor>>,
|
||||
val topLevel: Map<SourceFile, List<CallableMemberDescriptor>>,
|
||||
val headerLines: List<String>,
|
||||
val namer: ObjCExportNamer,
|
||||
val mapper: ObjCExportMapper
|
||||
)
|
||||
+11
-9
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.llvm.LlvmParameterAttribute
|
||||
import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
@@ -154,16 +154,17 @@ object ObjCVoidType : ObjCType() {
|
||||
override fun render(attrsAndName: String) = "void".withAttrsAndName(attrsAndName)
|
||||
}
|
||||
|
||||
internal enum class ObjCValueType(val encoding: String, val defaultParameterAttributes: List<LlvmParameterAttribute> = emptyList()) {
|
||||
BOOL("c", listOf(LlvmParameterAttribute.SignExt)),
|
||||
UNICHAR("S", listOf(LlvmParameterAttribute.ZeroExt)),
|
||||
@InternalKotlinNativeApi
|
||||
enum class ObjCValueType(val encoding: String) {
|
||||
BOOL("c"),
|
||||
UNICHAR("S"),
|
||||
// TODO: Switch to explicit SIGNED_CHAR
|
||||
CHAR("c", listOf(LlvmParameterAttribute.SignExt)),
|
||||
SHORT("s", listOf(LlvmParameterAttribute.SignExt)),
|
||||
CHAR("c"),
|
||||
SHORT("s"),
|
||||
INT("i"),
|
||||
LONG_LONG("q"),
|
||||
UNSIGNED_CHAR("C", listOf(LlvmParameterAttribute.ZeroExt)),
|
||||
UNSIGNED_SHORT("S", listOf(LlvmParameterAttribute.ZeroExt)),
|
||||
UNSIGNED_CHAR("C"),
|
||||
UNSIGNED_SHORT("S"),
|
||||
UNSIGNED_INT("I"),
|
||||
UNSIGNED_LONG_LONG("Q"),
|
||||
FLOAT("f"),
|
||||
@@ -206,7 +207,8 @@ data class ObjCGenericTypeParameterDeclaration(
|
||||
get() = ObjCVariance.fromKotlinVariance(typeParameterDescriptor.variance)
|
||||
}
|
||||
|
||||
internal fun ObjCType.makeNullableIfReferenceOrPointer(): ObjCType = when (this) {
|
||||
@InternalKotlinNativeApi
|
||||
fun ObjCType.makeNullableIfReferenceOrPointer(): ObjCType = when (this) {
|
||||
is ObjCPointerType -> ObjCPointerType(this.pointee, nullable = true)
|
||||
|
||||
is ObjCNonNullReferenceType -> ObjCNullableReferenceType(this)
|
||||
|
||||
+3
-37
@@ -6,43 +6,11 @@
|
||||
package org.jetbrains.kotlin.backend.konan.testUtils
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.common.CommonDependenciesContainer
|
||||
import org.jetbrains.kotlin.analyzer.common.CommonResolverForModuleFactory
|
||||
import org.jetbrains.kotlin.backend.konan.KlibFactories
|
||||
import org.jetbrains.kotlin.backend.konan.KonanConfig
|
||||
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys
|
||||
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys.Companion.KONAN_HOME
|
||||
import org.jetbrains.kotlin.backend.konan.UnitSuspendFunctionObjCExport
|
||||
import org.jetbrains.kotlin.backend.konan.driver.BasicPhaseContext
|
||||
import org.jetbrains.kotlin.backend.konan.objcexport.*
|
||||
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportHeaderGeneratorImpl
|
||||
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportMapper
|
||||
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportNamerImpl
|
||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.createFlexiblePhaseConfig
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.library.resolveSingleFileKlib
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.CommonPlatforms
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.konan.NativePlatforms
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import org.jetbrains.kotlin.resolve.CompilerEnvironment
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
|
||||
import org.jetbrains.kotlin.resolve.konan.platform.NativePlatformAnalyzerServices
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.testFramework.MockProjectEx
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import java.io.File
|
||||
|
||||
object Fe10ObjCExportHeaderGenerator : AbstractObjCExportHeaderGeneratorTest.ObjCExportHeaderGenerator {
|
||||
@@ -70,19 +38,17 @@ object Fe10ObjCExportHeaderGenerator : AbstractObjCExportHeaderGeneratorTest.Obj
|
||||
)
|
||||
|
||||
val environment: KotlinCoreEnvironment = createKotlinCoreEnvironment(disposable)
|
||||
val phaseContext = BasicPhaseContext(
|
||||
KonanConfig(environment.project, environment.configuration)
|
||||
)
|
||||
|
||||
val kotlinFiles = root.walkTopDown().filter { it.isFile }.filter { it.extension == "kt" }.toList()
|
||||
|
||||
return ObjCExportHeaderGeneratorImpl(
|
||||
context = phaseContext,
|
||||
moduleDescriptors = listOf(createModuleDescriptor(environment, kotlinFiles)),
|
||||
mapper = mapper,
|
||||
namer = namer,
|
||||
problemCollector = ObjCExportProblemCollector.SILENT,
|
||||
objcGenerics = true
|
||||
objcGenerics = true,
|
||||
shouldExportKDoc = true,
|
||||
additionalImports = emptyList()
|
||||
)
|
||||
}
|
||||
}
|
||||
+6
-11
@@ -9,9 +9,9 @@ import com.intellij.openapi.Disposable
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.common.CommonDependenciesContainer
|
||||
import org.jetbrains.kotlin.analyzer.common.CommonResolverForModuleFactory
|
||||
import org.jetbrains.kotlin.backend.konan.KlibFactories
|
||||
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys
|
||||
import org.jetbrains.kotlin.backend.common.serialization.metadata.DynamicTypeDeserializer
|
||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.konan.KonanBuiltIns
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.createFlexiblePhaseConfig
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataFactories
|
||||
import org.jetbrains.kotlin.library.resolveSingleFileKlib
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.CommonPlatforms
|
||||
@@ -87,13 +87,6 @@ private fun createCompilerConfiguration(): CompilerConfiguration {
|
||||
val configuration = KotlinTestUtils.newConfiguration()
|
||||
configuration.put(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, createLanguageVersionSettings())
|
||||
configuration.put(CLIConfigurationKeys.FLEXIBLE_PHASE_CONFIG, createFlexiblePhaseConfig(K2NativeCompilerArguments()))
|
||||
configuration.put(KonanConfigKeys.KONAN_HOME, konanHomePath)
|
||||
configuration.put(KonanConfigKeys.PRODUCE, CompilerOutputKind.FRAMEWORK)
|
||||
configuration.put(KonanConfigKeys.AUTO_CACHEABLE_FROM, emptyList())
|
||||
configuration.put(KonanConfigKeys.CACHE_DIRECTORIES, emptyList())
|
||||
configuration.put(KonanConfigKeys.CACHED_LIBRARIES, emptyMap())
|
||||
configuration.put(KonanConfigKeys.FRAMEWORK_IMPORT_HEADERS, emptyList())
|
||||
configuration.put(KonanConfigKeys.EXPORT_KDOC, true)
|
||||
return configuration
|
||||
}
|
||||
|
||||
@@ -109,7 +102,9 @@ private object DependenciesContainerImpl : CommonDependenciesContainer {
|
||||
override fun registerDependencyForAllModules(moduleInfo: ModuleInfo, descriptorForModule: ModuleDescriptorImpl) = Unit
|
||||
override fun packageFragmentProviderForModuleInfo(moduleInfo: ModuleInfo): PackageFragmentProvider? = null
|
||||
|
||||
private val stdlibModuleDescriptor = KlibFactories.DefaultDeserializedDescriptorFactory.createDescriptor(
|
||||
private val klibFactory = KlibMetadataFactories(::KonanBuiltIns, DynamicTypeDeserializer)
|
||||
|
||||
private val stdlibModuleDescriptor = klibFactory.DefaultDeserializedDescriptorFactory.createDescriptor(
|
||||
library = resolveSingleFileKlib(org.jetbrains.kotlin.konan.file.File("$konanHomePath/klib/common/stdlib")),
|
||||
languageVersionSettings = createLanguageVersionSettings(),
|
||||
builtIns = DefaultBuiltIns.Instance,
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.testUtils
|
||||
|
||||
private const val konanHomePropertyKey = "org.jetbrains.kotlin.native.home"
|
||||
private const val konanHomePropertyKey = "kotlin.internal.native.test.nativeHome"
|
||||
|
||||
val konanHomePath: String
|
||||
get() = System.getProperty(konanHomePropertyKey) ?: error("Missing System property: '$konanHomePropertyKey'")
|
||||
+2
-2
@@ -7,5 +7,5 @@ package org.jetbrains.kotlin.backend.konan.testUtils
|
||||
|
||||
import java.io.File
|
||||
|
||||
val projectDir = File("kotlin-native/backend.native")
|
||||
val testDataDir = projectDir.resolve("functionalTest/testData")
|
||||
val projectDir = File(System.getProperty("projectDir"))
|
||||
val testDataDir = projectDir.resolve("src/test/testData")
|
||||
+3
-6
@@ -6,8 +6,6 @@
|
||||
package org.jetbrains.kotlin.backend.konan.tests
|
||||
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import org.jetbrains.kotlin.backend.konan.KonanConfig
|
||||
import org.jetbrains.kotlin.backend.konan.driver.BasicPhaseContext
|
||||
import org.jetbrains.kotlin.backend.konan.objcexport.*
|
||||
import org.jetbrains.kotlin.backend.konan.testUtils.*
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
@@ -68,14 +66,13 @@ class ObjCExportMapperTest : InlineSourceTestEnvironment {
|
||||
|
||||
val objcExportTranslator = ObjCExportTranslatorImpl(
|
||||
generator = ObjCExportHeaderGeneratorImpl(
|
||||
context = BasicPhaseContext(
|
||||
KonanConfig(kotlinCoreEnvironment.project, kotlinCoreEnvironment.configuration)
|
||||
),
|
||||
moduleDescriptors = listOf(module),
|
||||
mapper = objcExportMapper,
|
||||
namer = objcExportNamer,
|
||||
problemCollector = ObjCExportProblemCollector.SILENT,
|
||||
objcGenerics = true
|
||||
objcGenerics = true,
|
||||
shouldExportKDoc = false,
|
||||
additionalImports = emptyList()
|
||||
),
|
||||
mapper = objcExportMapper,
|
||||
namer = objcExportNamer,
|
||||
|
||||
Reference in New Issue
Block a user