#53 Provide more control of %init section for Lua modules


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.


  • Mark Gossage
    Mark Gossage

    • status: open --> closed
  • Mark Gossage
    Mark Gossage

    Logged In: YES
    Originator: NO

    Its already been done! (Update 07/10/2007)

    The SWIG_init_user() function has been moved to the end of SWIG_init().
    The change is in SVN, and will appear in the next release of SWIG.