[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [ANN] Objective-C (and C++) Exception Handling for Lua 5.1.5
- From: Eric Wing <ewmailing@...>
- Date: Tue, 17 Apr 2012 16:10:42 -0700
Hi all,
I've posted a cleaned up native exception handling patch for
Objective-C for Lua 5.1.5.
I've recently added this to LuaCocoa, but isolated it out into a
separate Lua repository in case anybody else wants to use it.
This patch modifies Lua so it will use Objective-C's exception handling
mechanism instead of longjmp for pcall.
This is desirable particularly for cases where you may be calling native
platform APIs from Lua which may throw exceptions. With normal longjmp, Lua
has no idea that an exception was thrown and the execution jumped out of the
Lua VM. This may lead to memory leaks and in bad cases, crashes when trying
to reenter the VM.
Switching to Objective-C's exception handling mechansism allows Lua to catch
all exceptions during a lua_pcall also gives the ability for Lua script writers
to trap/handle Obj-C exceptions from their own pcall's.
Finally, on 'modern' Objective-C runtimes where Obj-C and C++ exceptions are
unified, this patch also gives the ability to handle C++ exceptions. And
optionally, this patch may be compiled with additional support to provide
more detail for C++ specific exceptions.
It can be found here.
https://bitbucket.org/ewing/lua-5.1-native-objective-c-exception-handling-mechanisms-for/overview
I include a very detailed README.OSX which includes a discussion of
the changes I needed to make to Lua (mostly to isolate Obj-C from the
Lua core).
Also of possible interest, I forked/updated Peter Shook's Lua5_History
Mercurial repository for Lua 5.1.5 and 5.2.0. My Obj-C patch derives
from this. My Lua 5 History history branch can be found here:
https://bitbucket.org/ewing/lua5_history
And LuaCocoa with the Obj-C patch already incorporated can be found here:
https://bitbucket.org/ewing/luacocoa
Feedback welcome.
Thanks,
Eric
--
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/