lua-users home
lua-l archive

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


Hello, I'm looking for help integrating an open-source library (lua-icxx.sourceforge.net) with SWIG. If anyone is interested in participating in a little bit of C++ work to extend lua-icxx, let me know; details follow. 

I created lua-icxx so I would not have to manipulate the Lua stack when embedding a Lua interpreter in my C++ apps. Then, to enable the Lua script to call C++ functions in my app, I used SWIG: 

myAppOrDLL <--> lua-icxx <--> Lua interpreter  ----\
      ^\-------------SWIG export DLL --------------/

A current limitation of lua-icxx is that it only supports bidirectional transfer (the lines with two arrows) of basic types like int and string. So whereas a Lua script can easily call a C++ function that takes a C++ Foo by calling a SWIG-generated Lua function that takes a Lua Foo (that wraps the C++ Foo); lua-icxx currently does not support the reverse ie C++ app to push a C++ Foo to the Lua interpreter as a Lua Foo (generated via SWIG). Not a huge deal, because there is an acceptable workaround: if I really need to transfer a Foo from C++ to Lua, I can create a C++ function that returns a Foo, export it to Lua via SWIG, and get the script to call it. This essentially changes a push into pull, which is not bad, but not great either. 

Since SWIG already generates wrapper classes for my C++ classes, it is likely possible to extend lua-icxx so it can also transfer user data types via SWIG. A lua-icxx API call that accepted a Foo* (via C++ template function) would have to find the SWIG-generated Foo wrapper, and push it onto the Lua stack. Similarly for returning a Lua Foo to the caller in the C++ layer.  

Anyone interested in giving that a shot? I'm currently focussed on updating another open-source project I have (pubsub) so I won't have time for this any time soon, thought  I should ask, just in case. Cheers, 

Oliver