On Wed, Jan 25, 2012 at 2:42 PM, Gaspard Bucher
<gaspard@teti.ch> wrote:
Hi List !
I am trying to prepare an error function before executing a callback from C++. The callback uses it's own lua thread with the following stack (just before the call):
<self> <err_func> <func> <self> <...>
If func(self, ...) fails, I would like to be able to find the "self" table back in the error function. Is this possible ? Do I have to create a different function for each object with an upvalue ?
-- Ideal code
function err(self, msg)
-- ...
end
Just a note to say that I managed to have my error handler work by creating an error function that has my "self" context as upvalue. This means that all objects with Callbacks now have:
- userdata env (to point to lua thread and avoid gc of thread)
- lua thread
- error function
- self table
I will do a little more testing and ensure memory management is correct and then the code will be in Dub 2.1.
Cheers,
Gaspard