[interop][c][reverse] avoid generating empty structures for leaf packages without exportable declations

- fixes KT-42796
This commit is contained in:
Vasily Levchenko
2021-04-08 16:46:17 +02:00
committed by Space
parent 0d7eb971ca
commit c68ac4f6b6
@@ -763,7 +763,11 @@ internal class CAdapterGenerator(val context: Context) : DeclarationDescriptorVi
}
}
private fun ExportedElementScope.hasNonEmptySubScopes(): Boolean = elements.isNotEmpty() || scopes.any { it.hasNonEmptySubScopes() }
private fun makeScopeDefinitions(scope: ExportedElementScope, kind: DefinitionKind, indent: Int) {
if (!scope.hasNonEmptySubScopes())
return
if (kind == DefinitionKind.C_HEADER_STRUCT) output("struct {", indent)
if (kind == DefinitionKind.C_SOURCE_STRUCT) output(".${scope.name} = {", indent)
scope.elements.forEach { makeElementDefinition(it, kind, indent + 1) }