lua-users home
lua-l archive

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


On Wed, Dec 17, 2008 at 9:15 AM, Michael Mzik <M.Mzik@cs-group.de> wrote:

 Hi there !

I am rather new to Lua and currently trying to integrate Lua into our C++ applications.

Welcome.

 Although there are good documentation resources around, I would like to ask two beginner-questions:

-          what is the best way to use Lua from C++ (Wrappers, exception-handling, etc)?

I would recommend Luaxx header only C++ wrapper around the Lua C API, if you are writing them yourself. This will allow you to use try/catch around your code to catch the 'exit()' function for you. Also as a tip you should not throw from you modules. It just doesn't work well and makes it  very hard to code right.'

Here is a copy that I updated from the original creator of Luaxx[1] that has much more bound and covers many of the standard containers (e.g. vector, map, pair). [2]

Now if you want a decent binding library I suggest toLua++[3][4] I have had good success using it.

-          and how may I intercept "exit"-statements in Lua-Script in C++ to prevent my whole application from closing?

See above.

Hope this helps. If you use svn the latest source of Lua and Luaxx can be found at the GoogleCode project called luasvnrepo. [5]

[1] http://matt-land.com/luaxx/
[2] http://code.google.com/p/luasvnrepo/source/browse/libraries/lua/trunk/src/luaxx.h
[3] http://www.codenix.com/~tolua/
[4] http://luasvnrepo.googlecode.com/svn/libraries/tolua++/trunk
[5] http://luasvnrepo.googlecode.com
--
Regards,
Ryan