Skip to content

Commit

Permalink
Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky committed Oct 10, 2023
1 parent b12acde commit db29d44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions buildSrc/src/main/kotlin/karakum/actions/Converter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ private fun convertClass(
.replace("/*`", "/ *`")
.trimIndent()

var allMembers = memberSource
val allMembers = memberSource
.split(";\n")
.mapNotNull { convertMember(it) }

var members = allMembers
val members = allMembers
.filter { STATIC_MARKER !in it }
.joinToString("\n")

var staticMembers = allMembers
val staticMembers = allMembers
.filter { STATIC_MARKER in it }
.map { it.replace(STATIC_MARKER, "") }
.joinToString("\n")
Expand Down Expand Up @@ -494,6 +494,9 @@ private fun methodDeclaration(
private fun convertMethod(
source: String,
): String {
if (source == "readBodyBuffer?(): Promise<Buffer>")
return "val readBodyBuffer: (() -> Promise<Buffer>)?"

if (source.startsWith("static "))
return STATIC_MARKER + convertMethod(source.removePrefix("static "))

Expand All @@ -504,8 +507,7 @@ private fun convertMethod(
.substringBeforeLast("): ")
).joinToString(",\n")

val returnType = kotlinType(source.substringAfter("): "))
val returns = when (returnType) {
val returns = when (val returnType = kotlinType(source.substringAfter("): "))) {
"void" -> ""
else -> ": $returnType"
}
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/karakum/actions/KotlinType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ private val STANDARD_TYPE_MAP = mapOf(
"Promise<void>" to "Promise<Void>",

"AsyncGenerator<string, void>" to "Any /* AsyncGenerator<string, void> */",
"ProxyAgent" to "Any /* ProxyAgent */",

"Map<number_string>" to "ReadonlyMap<Int, String>",

Expand Down

0 comments on commit db29d44

Please sign in to comment.