[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: SWIG, C++ Exceptions, and Lua
- From: Miles Bader <miles@...>
- Date: Thu, 06 Mar 2008 09:55:23 +0900
Joey Mukherjee <joey@swri.edu> writes:
> Is it possible to make SWIG and Lua work well with C++ exceptions? If
> so, what is the best way?
>
> Really, the only thing I need is for Lua to not swallow my exceptions
> and allow the exception to pass through to main program.
Hmm maybe I mis-understand the problem, but everything seems to work ok
for me...
swig just throws a normal lua error for its errors, and in my program,
my "top-level" calls into Lua use a function like this:
static void
do_call (lua_State *L, int nargs, int nres)
{
int err = lua_pcall (L, nargs, nres, 0);
if (err)
{
string err_str = lua_tostring (L, -1);
throw file_error (err_str);
}
}
So any error swig signals will cause that pcall to return an error, and
the above function will turn that into a C++ exception...
-Miles
--
Religion, n. A daughter of Hope and Fear, explaining to Ignorance the nature
of the Unknowable.