Commit graph

6 commits

Author SHA1 Message Date
Leonardo de Moura
7b77863507 refactor(lua/name): improve name bindings for Lua
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 18:44:20 -08:00
Leonardo de Moura
543aea65c9 chore(lua): rename init_* functions to open_*
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-04 13:54:51 -08:00
Leonardo de Moura
fd7e85f0bb feat(lua): add safe_function template that catches Lean and C++ exceptions and convert them into Lua errors
I'm using the approach described at:
http://stackoverflow.com/questions/4615890/how-to-handle-c-exceptions-when-calling-functions-from-lua

BTW, in some Lua versions, the C++ exceptions are correctly propagated.
I think we should not rely on features of particular implementations.
For example, LuaJIT does not propagate C++ exceptions.
Whenever an exception is thrown from C++ code invoked from LuaJit, LuaJit interrupts the execution and converts it to an error "C++ exception".
On the other hand, Lua 5.2 PUC-Rio interpreter (for Ubuntu) seem to propagate the C++ exceptions.
The template safe_function solves the issue. It will also produce a Lua error whenever the function being wrapped throws an exception. The error message is based on the "what()" method.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-03 14:42:57 -08:00
Leonardo de Moura
df7dbe17b5 feat(lua/util): remove dependency on luaL_setfuncs
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-03 12:16:23 -08:00
Leonardo de Moura
ccd95a9b66 fix(lua/name): fix memory leak
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-02 20:57:41 -07:00
Leonardo de Moura
dbf2d56c77 feat(lua/name): expose hierarchical names in the Lua bindings
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2013-11-02 20:49:42 -07:00