summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-09-16 13:19:56 +0200
committernea <nea@nea.moe>2023-09-16 13:19:56 +0200
commite0696227c435ae09fc33d0820ff9757cdbccd706 (patch)
tree702c9856f9f5dc5558ef9a8df6424343a07d98c1
parente19b7e8198c771c6d9c533765b5a68c4a52080f7 (diff)
downloadwowheadscraper-master.tar.gz
wowheadscraper-master.tar.bz2
wowheadscraper-master.zip
Better definitionsHEADmaster
-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()