[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: wxLua at Sourceforge
- From: Rici Lake <lua@...>
- Date: Wed, 30 Nov 2005 11:31:03 -0500
On 30-Nov-05, at 11:15 AM, Chris Marrin wrote:
It's a little disconcerting that lua_dostring and lua_dobuffer are
missing in 5.1. I hope there's a suitable replacement.
There is. I will look at our source and let you know how we did it.
Again, I will do that later this morning...
if (luaL_loadbuffer(L, buff, lbuff, "Script foo") != 0) {
/* syntax error. The error message is on top of the stack */
// printf("%s\n", lua_tostring(L, -1));
// lua_pop(L, 1);
// or whatever
}
if (lua_pcall(L, 0, 0, 0) != 0) {
/* runtime error. The error message is on top of the stack */
// printf("%s\n", lua_tostring(L, -1));
// lua_pop(L, 1);
// or whatever
}
If you don't need to do error reporting at the point of call, you can
throw the error message back to a pcall by just doing lua_error(L); in
the first error clause, and replacing the lua_pcall with a lua_call.
You can (and probably should) adjust the lua_pcall to provide a
traceback function (the one in the debug library is handy) and/or
provide arguments and receive return values.