Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial3/src/external/tolua/MANUAL @ 10087

Last change on this file since 10087 was 5738, checked in by landauf, 15 years ago

merged libraries2 back to trunk

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1This tolua++ is modified with support for exception handling, and more will
2likely come over time.
3
4So to avoid forgetting how it works and what's new, all added features will
5be documented in full in this file:
6
7***********************
8* Exception handling: *
9***********************
10A new function modifier 'tolua_throws' has been added. It goes the same place
11as 'tolua_outside' etc. - so before the function name and return type.
12
13Two "types" of exceptions are supported internally, but they can be customized
14by making the tolua++ binary execute a Lua script before parsing with the '-L'
15command line option.
16Look in '../LuaScriptModule/package/exceptions.lua' to see the format. It's
17fairly simple and gives you alot of control.
18
19You always have 'std::exception' and 'any' (which means ...) available.
20
21This first example would be valid in a .pkg file for tolua++, and would ensure
22that any exceptions based on 'std::exception' thrown by the real C++ function
23would result in return value of 'nil' in Lua:
24
25        tolua_throws|std::exception,nil| void I_Throw:StdException();
26
27Inside the pipes the exception name follow by return values (or actions) are
28listed. The syntax is like so:
29
30        tolua_throws|<exceptionName>[,<ret1>[,<ret2> ... [, <retN>]]]|[<exceptionName>...|]
31
32The return values can by any of the following:
33* nil
34* message (the exception message, or 'Unknown' if not possible.
35* true
36* false
37* error (can only be used alone, will contain the exception is possible)
38
39In case no return values are specified, it will default to: 'nil, message'.
40
41Example 1:
42----------
43Returns 'nil, false' for all exceptions:
44
45        tolua_throws|any,nil,false|
46
47Example 2:
48----------
49Returns 'nil, message' if a 'std::exception' is thrown:
50
51        tolua_throws|std::exception,nil,message|
52
53Example 3:
54----------
55If a CEGUI::Exception is thrown, return 'nil, message'.
56If any other kind of exception is thrown abort (error).
57
58        tolua_throws|CEGUI::Exception|any,error|
Note: See TracBrowser for help on using the repository browser.