KMA-51 Create API to use ObjCExportTranslator to translate functions in IDE
This commit is contained in:
+8
-6
@@ -283,11 +283,7 @@ internal class ObjCExportTranslatorImpl(
|
||||
return translateUnexposedClassAsUnavailableStub(descriptor)
|
||||
}
|
||||
|
||||
val genericExportScope = if (objcGenerics) {
|
||||
ObjCClassExportScope(descriptor, namer)
|
||||
} else {
|
||||
ObjCNoneExportScope
|
||||
}
|
||||
val genericExportScope = createGenericExportScope(descriptor)
|
||||
|
||||
fun superClassGenerics(genericExportScope: ObjCExportScope): List<ObjCNonNullReferenceType> {
|
||||
if (objcGenerics) {
|
||||
@@ -431,6 +427,12 @@ internal class ObjCExportTranslatorImpl(
|
||||
)
|
||||
}
|
||||
|
||||
internal fun createGenericExportScope(descriptor: ClassDescriptor): ObjCExportScope = if (objcGenerics) {
|
||||
ObjCClassExportScope(descriptor, namer)
|
||||
} else {
|
||||
ObjCNoneExportScope
|
||||
}
|
||||
|
||||
private fun buildThrowableAsErrorMethod(): ObjCMethod {
|
||||
val asError = ObjCExportNamer.kotlinThrowableAsErrorMethodName
|
||||
return ObjCMethod(
|
||||
@@ -610,7 +612,7 @@ internal class ObjCExportTranslatorImpl(
|
||||
return ObjCProperty(name, property, type, attributes, setterName, getterName, declarationAttributes)
|
||||
}
|
||||
|
||||
private fun buildMethod(
|
||||
internal fun buildMethod(
|
||||
method: FunctionDescriptor,
|
||||
baseMethod: FunctionDescriptor,
|
||||
objCExportScope: ObjCExportScope,
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
|
||||
class ObjCExportTranslatorMobile internal constructor(private val delegate: ObjCExportTranslatorImpl) : ObjCExportTranslator by delegate {
|
||||
companion object {
|
||||
fun create(namer: ObjCExportNamer): ObjCExportTranslatorMobile {
|
||||
return ObjCExportTranslatorMobile(ObjCExportTranslatorImpl(null, ObjCExportMapper(), namer, ObjCExportProblemCollector.SILENT, false))
|
||||
}
|
||||
}
|
||||
|
||||
fun translateBaseFunction(descriptor: FunctionDescriptor): ObjCMethod {
|
||||
val classDescriptor = descriptor.containingDeclaration as? ClassDescriptor
|
||||
val scope = classDescriptor?.let { delegate.createGenericExportScope(it) } ?: ObjCNoneExportScope
|
||||
return delegate.buildMethod(descriptor, descriptor, scope)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user