Skip to content

Commit 1c285c2

Browse files
committed
Map Java functional interfaces to a Lua function
1 parent d16e9e5 commit 1c285c2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/kotlin/util/TypeMapping.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ fun mapJavaTypeToLua(javaType: String): String {
6161
javaType in listOf("java.lang.Boolean", "boolean") -> "boolean"
6262
javaType in listOf("java.lang.Character", "java.lang.String", "char", "String") -> "string"
6363
javaType == "void" -> "nil"
64+
65+
// Check for common Java functional interfaces
66+
javaType in listOf(
67+
"java.util.function.Function",
68+
"java.util.function.BiFunction",
69+
"java.util.function.Consumer",
70+
"java.util.function.BiConsumer",
71+
"java.util.function.Supplier",
72+
"java.util.function.Predicate",
73+
"java.util.function.BiPredicate",
74+
"java.lang.Runnable",
75+
"java.util.concurrent.Callable"
76+
) || javaType.endsWith("Function") || javaType.endsWith("Consumer") || javaType.endsWith("Supplier") || javaType.endsWith("Predicate") -> "function"
77+
6478
else -> javaType // Default case for other types
6579
}
6680
}

0 commit comments

Comments
 (0)