SWIG provides a configuration mechanism for modules, %init (Section 5.6.4 of the SWIG 1.3 Documentation). For the Lua language module, the code that the user supplies is executed before a module is initialized (e.g. before any symbols are loaded into the environment). For the Lua language, this means that one can not add code into the "%init" module that makes use of the new symbols, but must instead add further initialization code outside of the module that executes after it has been loaded. For instance, the simple act of defining aliases in Lua for the symbols that are being created, can not be performed until after the symbols have been defined.
It would be useful to do amend the implementation of the %init section for Lua modules to do one of the following: (a) move the invocation of SWIG_init_user() to the bottom of SWIG_init() for Lua such as just before "end module"; (b) add a parameter to %init that allows more than one instance to be specified, and define the point during module initialization at which it is to be inserted; or (c) add a new "%initLate" section to the SWIG configuration language.
Log in to post a comment.