summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/DefMain.kt28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/kotlin/DefMain.kt b/src/main/kotlin/DefMain.kt
index 6d58a99..843b2a2 100644
--- a/src/main/kotlin/DefMain.kt
+++ b/src/main/kotlin/DefMain.kt
@@ -6,9 +6,11 @@ import java.io.PrintWriter
@Serializable
data class LModule(
+ val Name: String? = null,
val Namespace: String? = null,
val Functions: List<LFunction> = listOf(),
val Tables: List<LTable> = listOf(),
+ val Type: String = "System"
)
@Serializable
@@ -125,6 +127,32 @@ fun main() {
for (module in json1.decodeFromString<List<LModule>>(File("generated.json").readText())) {
luaMeta.println()
+ if (module.Type == "ScriptObject") {
+ val interfaceName = module.Name!!.removeSuffix("API")
+ luaMeta.println("---@class $interfaceName")
+ luaMeta.println("$interfaceName = {}")
+ luaMeta.println()
+ for (function in module.Functions) {
+ luaMeta.println("---@param self $interfaceName")
+ for (par in function.Arguments) {
+ luaMeta.println("---@param ${par.Name}${if (par.Nilable) "?" else ""} ${compositeTypeStr(module, par)}")
+ require(par.Name != "self")
+ }
+ for (ret in function.Returns) {
+ luaMeta.println(
+ "---@return ${
+ compositeTypeStr(
+ module,
+ ret
+ )
+ }${if (ret.Nilable) "|nil" else ""} ${ret.Name}"
+ )
+ }
+ luaMeta.println("function $interfaceName.${function.Name}(${(listOf("self") + function.Arguments.map { it.Name }).joinToString()}) end")
+ luaMeta.println()
+ }
+ continue
+ }
if (module.Namespace != null) {
luaMeta.println("${module.Namespace} = {}")
luaMeta.println()