lua-users home
lua-l archive

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


Hello,

I'd love to integrate Travis CI, but they sadly do not support C++14 compilers. Some other CI provider might support C++14 - I have yet to come around and test those.

Catching exceptions by default is not something I plan on adding, but some functionality which allows the user to automatically handle exceptions or convert them to Lua errors is a very good idea.

Ole


On Sun, 8 Nov 2015 at 22:29 Nagaev Boris <bnagaev@gmail.com> wrote:
On Mon, Nov 9, 2015 at 12:04 AM, Ole Krüger <ole@vprsm.de> wrote:
> Hello everybody,
>
> quite a while ago I chose to release the header-only C++14 wrapper I have
> been using. It focuses on minimal overhead, which reflects greatly in terms
> of performance.
>
> On GitHub: https://github.com/vapourismo/luwra
>
> I have been cleaning up some of the internals aswell as the exposed API to
> make things a little easier to use.
>
> I would love to read some feedback.
>
> Ole
>

Hi, Ole

nice work!

1. Please enable Travis CI to run tests automatically.

2. Can you add support of Lua errors vs C++ exceptions conversion?

I use the following wrapper class which converts C++ LuaCfunction
throwing C++ exceptions to LuaCFunction throwing Lua errors:

template<lua_CFunction F>
struct wrap {
    static int func(lua_State* L) {
        try {
            return F(L);
        } catch (std::exception& e) {
            lua_pushstring(L, e.what());
        } catch (...) {
            lua_pushliteral(L, "Unknown exception");
        }
        return lua_error(L);
    }
};

int foo(lua_State* L) {
    throw std::logical_error("I am foo!");
}

luaL_Reg module_functions[] = {
    {"foo", wrap<foo>::func},
    {}
};


--


Best regards,
Boris Nagaev