lua-users home
lua-l archive

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


On Mon, Dec 3, 2012 at 2:14 AM, Philipp Kraus
<philipp.kraus@flashpixx.de> wrote:
>
> Am 03.12.2012 um 04:05 schrieb Coda Highland:
>
>> On Sun, Dec 2, 2012 at 4:46 PM, Philipp Kraus
>> <philipp.kraus@flashpixx.de> wrote:
>>> Hello,
>>>
>>> I would like to write a panic function, that throws an exception if a panic is occured.
>>> Which signature must set for the method mypanic( lua_state* ) ?
>>> How can I call a private class method on the lua_panic function?
>>>
>>> Thanks
>>>
>>> Phil
>>
>> You can't.
>>
>> You can only pass a C function (or a C++ "static" function) as a panic
>> handler. If you want to map that to an instance method, you'll need to
>> map the Lua state to a pointer to the instance (a global pointer
>> variable suffices if you only have one Lua state) and invoke the
>> method from within the panic handler.
>
> I can use a static method: static mypanic( lua_state* ) is this the correct
> signature for the panic function?
>
> Phil

http://pgl.yoyo.org/luai/i/lua_atpanic

http://pgl.yoyo.org/luai/i/lua_CFunction

/s/ Adam