lua-users home
lua-l archive

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


Hallo,

I'm new to Lua. So bear with me if my questions are a little stupid.
But I have some problems with it for which I couldn't find a proper
solution yet.

First what I have: I have written a library, AKFAvatar, that is based on SDL.
Now I want it to be scriptable with Lua. It already works to a large extent.

One problem is, how can I cause the Lua script to return successfully, ie. without
an error, from within the C code? I don't want to put the burden to check for
conditions on the Lua programmer, so I want to do it from the C code.
My workaround for now is, that I use the function lua_error(), but instead of an 
error message I simply push a nil to the stack, and the calling program checks for
that and reacts accordingly. That works, but there is surely a better solution, 
isn't it?

Then I wanted to compile the language binding as a module. That works fine as 
long as it runs. But I have the problem, that I don't know how to do the 
cleanup afterwards.
In the application I simply register the cleanup function with atexit(3).
But when I use atexit inside the module it just hangs at the end.
Well, the SDL documentation says: "using atexit in a library is a sure way to
crash dynamically loaded code". But what else can I use?

(By the way, that problem already appeared before I did the workaround 
described above. So there is no connection.)


If you want to have a look at my code, the Lua-specific parts are there:
http://git.savannah.gnu.org/cgit/akfavatar.git/tree/lua

Homepage of AKFAvatar:
http://akfavatar.nongnu.org/

-- 
AKFoerster