Skip C overloads (#3821)
This commit is contained in:
+6
-1
@@ -123,6 +123,8 @@ interface StubsBuildingContext {
|
||||
fun getKotlinClassFor(objCClassOrProtocol: ObjCClassOrProtocol, isMeta: Boolean = false): Classifier
|
||||
|
||||
fun getKotlinClassForPointed(structDecl: StructDecl): Classifier
|
||||
|
||||
fun isOverloading(func: FunctionDecl): Boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,6 +148,9 @@ class StubsBuildingContextImpl(
|
||||
|
||||
private var theCounter = 0
|
||||
|
||||
private val uniqFunctions = mutableSetOf<String>()
|
||||
override fun isOverloading(func: FunctionDecl) = !uniqFunctions.add(func.name) // TODO: params & return type.
|
||||
|
||||
override fun generateNextUniqueId(prefix: String) =
|
||||
prefix + pkgName.replace('.', '_') + theCounter++
|
||||
|
||||
@@ -358,7 +363,7 @@ class StubIrBuilder(private val context: StubIrContext) {
|
||||
|
||||
private fun generateStubsForFunction(func: FunctionDecl) {
|
||||
try {
|
||||
addStubs(FunctionStubBuilder(buildingContext, func).build())
|
||||
addStubs(FunctionStubBuilder(buildingContext, func, skipOverloads = true).build())
|
||||
} catch (e: Throwable) {
|
||||
context.log("Warning: cannot generate stubs for function ${func.name}")
|
||||
}
|
||||
|
||||
+5
-1
@@ -454,8 +454,10 @@ internal class EnumStubBuilder(
|
||||
|
||||
internal class FunctionStubBuilder(
|
||||
override val context: StubsBuildingContext,
|
||||
private val func: FunctionDecl
|
||||
private val func: FunctionDecl,
|
||||
private val skipOverloads: Boolean = false
|
||||
) : StubElementBuilder {
|
||||
|
||||
override fun build(): List<StubIrElement> {
|
||||
val platform = context.platform
|
||||
val parameters = mutableListOf<FunctionParameterStub>()
|
||||
@@ -508,6 +510,8 @@ internal class FunctionStubBuilder(
|
||||
context.mirror(func.returnType).argType
|
||||
}.toStubIrType()
|
||||
|
||||
if (skipOverloads && context.isOverloading(func))
|
||||
return emptyList()
|
||||
|
||||
val annotations: List<AnnotationStub>
|
||||
val mustBeExternal: Boolean
|
||||
|
||||
Reference in New Issue
Block a user