3 ms·
Yeah, I'm never doing that again. I created a binding for the Irrlicht rendering engine with Lua using swig. There were always parsing errors with the header
by snarfy 3y ago
Yeah, I'm never doing that again. I created a binding for the Irrlicht rendering engine with Lua using swig. There were always parsing errors with the header files so I had to create definition files for almost everything. It was a lot of work, but I did finally get it to function.
And then a new version of Irrlicht came out, and I basically had to start from scratch. All the definition files no longer matched the headers so they had to be recreated.
And then a new version of Lua came out and broke modules. The binding was written as a module so that had to be redone too.
I got way more familiar with the internals of swig than I ever wanted to. Each language it supports has it's own little parser/runtime integration, so I had to learn a lot about how swig and lua interact.
If I were to do it again I'd create a proper C binding to the C++ interface, and then bind that to whatever language I wanted. They almost all support C. C++ is a whole other beast.
- thadt 3y agoAgreed. I had working Swig bindings for Lua to a C data engine. While it worked, it was opaque, required a lot of diving into the Swig code generators, added its own special footguns, and felt like the most dangerous edge in the project. The next time I wanted to bind Lua to a C++ application, I just hand wrote the bindings. Boring, repetitive, shovel code. Once I had a template, it would take me just a few minutes to hook up new interfaces. If there was ever a problem with one, it was usually a typo and took 30 seconds to find and fix.
- TillE 3y ago> create a proper C binding to the C++ interface That's the generally recommended way of exposing your C++ library to any kind of non-C++ code. I'm not aware of any software which directly helps with that, unfortunately. You either do it manually or write a custom script. Here's a recent example of the latter, from Dear ImGui: https://github.com/dearimgui/dear_bindings https://github.com/dearimgui/dear_bindings
- compiler-guy 3y agoBoth pybind11 and CLIF help with this and do it very well.
- fsloth 3y ago“I'm not aware of any software which directly helps with that, unfortunately.” If the API surface is not too large that’s one of the things ChatGPT is usually competent enough to ‘type out’ for you most of the way (delta some errors).