MCPcopy Create free account
hub / github.com/boostorg/leaf / wrap_lua_CFunction

Function wrap_lua_CFunction

example/lua_callback_exceptions.cpp:49–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47// std::current_exception and wrap it in a e_lua_exception object.
48template <int (*F)( lua_State * L )>
49int wrap_lua_CFunction( lua_State * L ) noexcept
50{
51 return leaf::try_catch(
52 [&]
53 {
54 return F(L);
55 },
56 [&]( leaf::error_info const & ei )
57 {
58 ei.error().load( e_lua_exception{std::current_exception()} );
59 return luaL_error(L, "C++ Exception"); // luaL_error does not return (longjmp).
60 } );
61}
62
63
64// This is a C callback with a specific signature, callable from programs

Callers

nothing calls this directly

Calls 2

try_catchFunction · 0.85
loadMethod · 0.80

Tested by

no test coverage detected