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()
|
(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
|
* The name to be used for this struct in Kotlin
|
||||||
*/
|
*/
|
||||||
val StructDecl.kotlinName: String
|
val StructDecl.kotlinName: String
|
||||||
get() {
|
get() {
|
||||||
|
if (this.isAnonymous) {
|
||||||
|
val names = anonymousStructKotlinNames
|
||||||
|
return names.getOrPut(this) {
|
||||||
|
"anonymousStruct${names.size + 1}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val strippedCName = if (spelling.startsWith("struct ") || spelling.startsWith("union ")) {
|
val strippedCName = if (spelling.startsWith("struct ") || spelling.startsWith("union ")) {
|
||||||
spelling.substringAfter(' ')
|
spelling.substringAfter(' ')
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user