lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> hi,
> I am using SWIG with LUA5.1, can i define multiple modules in a *.i file. 
> I tried it, but SWIG does not registe other modules but the first one.
Hello YouZhi,
Sorry, SWIG cannot do that.
A module in SWIG represents a single collection of functions which are wrappered together. Under Lua, they are all stored within a single table entry.
If you want two modules, then use two files.

---ModA.i ---
%module ModA;
%include "somefile.h"
---ModB.i ---
%module ModB;
%include "someotherfile.h"
Then SWIG and compile the two files separately.
Then you load each on their own.

require "ModA"
require "ModB"

Hope this helps.