1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-28 17:09:10 +00:00

Add: [Scripts] "_typeof" metamethod

This commit is contained in:
glx22
2025-02-17 16:39:14 +01:00
committed by Loïc Guilloux
parent 35e58f68e4
commit d7bd67cda3
6 changed files with 16 additions and 19 deletions

View File

@@ -340,7 +340,7 @@ foreach(LINE IN LISTS SOURCE_LINES)
endif()
string(APPEND SQUIRREL_EXPORT "\n")
string(APPEND SQUIRREL_EXPORT "\ntemplate <> const char *GetClassName<${CLS}, ScriptType::${APIUC}>() { return \"${API_CLS}\"; }")
string(APPEND SQUIRREL_EXPORT "\ntemplate <> SQInteger PushClassName<${CLS}, ScriptType::${APIUC}>(HSQUIRRELVM vm) { sq_pushstring(vm, \"${API_CLS}\", -1); return 1; }")
string(APPEND SQUIRREL_EXPORT "\n")
# Then do the registration functions of the class.
@@ -484,9 +484,8 @@ foreach(LINE IN LISTS SOURCE_LINES)
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQStaticMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\",${SPACES}${ARGC}, \"${TYPES}\");")
endif()
endforeach()
if(MLEN)
string(APPEND SQUIRREL_EXPORT "\n")
endif()
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQAdvancedStaticMethod(engine, &PushClassName<${CLS}, ScriptType::${APIUC}>, \"_typeof\");")
string(APPEND SQUIRREL_EXPORT "\n")
# Non-static methods
set(MLEN 0)