Open vallode opened 6 months ago
Some basic generation is taking place already, mostly via searching the LuaApi.cpp file in dfhack and parsing basic function signatures. This covers a lot of ground but misses some more abstract lua state manipulation functions that would at least be nice to expose a return type of.
On the DFHack Discord there was some discussion about adding type comments (akin to JSDoc) to the relevant cpp files and read that in the type generation. The example Thyrus was quite neat, slightly modifying it gives an example of a c++ function like so:
/*lua
@param base dfhack.pen|dfhack.color
@param pen_or_fg? dfhack.pen|dfhack.color
@param bg? dfhack.color
@param bold? boolean
@return dfhack.pen
*/
static int dfhack_pen_parse(lua_State *L) {}
We can do some simple sanity checking for this (correct @ tag, non reserved name, maybe even checking if the type exists) and output that to the relevant files instead.
Placeholder issue to gather my thoughts on how we should go about exposing the C++ modules to Lua language server.