There is a long standing request in Debian to make SWIG wrapped Lua modules return the module table when importing the module:
As it turns out, this is not too hard to fix. While looking at it, I also noticed that loading a SWIG-generated Lua module will also clobber a global variable of the same name (often not a problem, but who knows).
The attached patch adds a new option -nomoduleglobal to disable installing the module table into the global namespace _G.
There is a slight change in behaviour: In any case, the require call to load a module will now return the module table. Originally, the name of the module was returned (as a string), which does not seem very useful for me.
I included a unit test with the patch.
Please consider applying the patch,
Log in to post a comment.