From 5c90f6abc21c58f7f7111dc3135ee934c40160c2 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Tue, 7 Feb 2017 13:14:47 +0700 Subject: [PATCH] Interop/StubGenerator: support anonymous structs --- .../kotlin/native/interop/gen/jvm/StubGenerator.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt index 8cbd4841acb..6ea76d9ed62 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt @@ -27,11 +27,23 @@ class StubGenerator( (functionNames + fieldNames).toSet() } + val StructDecl.isAnonymous: Boolean + get() = spelling.contains("(anonymous ") // TODO: it is a hack + + val anonymousStructKotlinNames = mutableMapOf() + /** * The name to be used for this struct in Kotlin */ val StructDecl.kotlinName: String get() { + if (this.isAnonymous) { + val names = anonymousStructKotlinNames + return names.getOrPut(this) { + "anonymousStruct${names.size + 1}" + } + } + val strippedCName = if (spelling.startsWith("struct ") || spelling.startsWith("union ")) { spelling.substringAfter(' ') } else {