Tool idea: generate definition files using C API #659
Replies: 4 comments
-
That's a super interesting topic! One could actually do the opposite even: a Off the top of my head one missing bit for this to be feasible is userdata support in Teal, which at this time is pretty much nonexistent (I haven't looked at this at all yet! *) I'm wondering what would be the absolute minimum necessary for the above-described tool to be possible. Without thinking too much, I'm thinking some way to declare a userdata newtype, which the tool would then translate into a pointer argument. * I sidestepped userdata support at first by declaring |
Beta Was this translation helpful? Give feedback.
-
I wasn't aware of LuaAutoC (really cool!), and reading about it, it does sound like it could do it, yes, since it stores all type-related information in the Lua registry. Since it builds it dynamically at runtime, though, it might be a bit clumsy to extract .d.tl files out of it for offline typechecking (at code editing time), but it could collect the data and trigger typechecking when loading .tl files at runtime.
That's also a possible avenue: using SWIG .i files to generate both Lua/C bindings and a .d.tl file. Don't know about SWIG internals to tell how tricky it would be to do this from SWIG itself, or if it's easier to parse the .i format from an external tool. |
Beta Was this translation helpful? Give feedback.
-
for what its worth, I made a rust library that is able to create a .d.tl file based on the types that rlua exposes to lua https://github.com/lenscas/tealr/ right now it (ab)uses the record type though. |
Beta Was this translation helpful? Give feedback.
-
Moving this to Discussions for better visibility -- someone might be inspired to work on it! |
Beta Was this translation helpful? Give feedback.
-
Using Lua + Teal inside a C application is kinda cumbersome. First, we need to expose C functions to Lua. Then, we need to create definition files for these functions. That's a lot of boilerplate :(
I think it would be nice if there was a tool to combine both steps into one. Perhaps LuaAutoC could be adapted for this use case... Something like SWIG could probably be used as well.
Beta Was this translation helpful? Give feedback.
All reactions