Interop/StubGenerator: support anonymous structs
This commit is contained in:
committed by
SvyatoslavScherbina
parent
a127f0f1ef
commit
5c90f6abc2
+12
@@ -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<StructDecl, String>()
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
Reference in New Issue
Block a user