Objc header generation public api

* Implement Obj-C header generator for public use
* Fix duplicated top level functions in an exported obj-c header

Co-authored-by: Aydar Mukhametzyanov <aydar.mukhametzyanov@jetbrains.com>
This commit is contained in:
Aydar Mukhametzyanov
2020-08-03 13:33:44 +02:00
committed by GitHub
parent dac52df6fd
commit 34c48f69e3
3 changed files with 47 additions and 2 deletions
@@ -140,7 +140,7 @@ private fun getPackagesFqNames(module: ModuleDescriptor): Set<FqName> {
fun ModuleDescriptor.getPackageFragments(): List<PackageFragmentDescriptor> =
getPackagesFqNames(this).flatMap {
getPackage(it).fragments.filter { it.module == this }
getPackage(it).fragments.filter { it.module == this }.toSet()
}
val ClassDescriptor.enumEntries: List<ClassDescriptor>
@@ -426,7 +426,7 @@ private abstract class LazyObjCProtocol(
get() = realStub.superProtocols
}
private fun createNamerConfiguration(configuration: ObjCExportLazy.Configuration): ObjCExportNamer.Configuration {
internal fun createNamerConfiguration(configuration: ObjCExportLazy.Configuration): ObjCExportNamer.Configuration {
return object : ObjCExportNamer.Configuration {
override val topLevelNamePrefix = abbreviate(configuration.frameworkName)
@@ -0,0 +1,45 @@
package org.jetbrains.kotlin.backend.konan.objcexport
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
class ObjcExportHeaderGeneratorMobile internal constructor(
moduleDescriptors: List<ModuleDescriptor>,
mapper: ObjCExportMapper,
namer: ObjCExportNamer,
private val warningCollector: ObjCExportWarningCollector,
objcGenerics: Boolean
) : ObjCExportHeaderGenerator(moduleDescriptors, mapper, namer, objcGenerics) {
companion object {
fun createInstance(
configuration: ObjCExportLazy.Configuration,
warningCollector: ObjCExportWarningCollector,
builtIns: KotlinBuiltIns,
moduleDescriptors: List<ModuleDescriptor>,
deprecationResolver: DeprecationResolver? = null): ObjCExportHeaderGenerator {
val mapper = ObjCExportMapper(deprecationResolver, local = true)
val namerConfiguration = createNamerConfiguration(configuration)
val namer = ObjCExportNamerImpl(namerConfiguration, builtIns, mapper, local = true)
return ObjcExportHeaderGeneratorMobile(
moduleDescriptors,
mapper,
namer,
warningCollector,
configuration.objcGenerics)
}
}
override fun reportWarning(text: String) {
warningCollector.reportWarning(text)
}
override fun reportWarning(method: FunctionDescriptor, text: String) {
warningCollector.reportWarning(method, text)
}
}