annotate lib/swig/swigwin-2.0.11/Lib/lua/lua.swg @ 2194:d0e321190c86

Merge
author Grumpy7
date Thu, 30 Jan 2014 22:11:28 +0100
parents b3009adc0e2f
children
rev   line source
1899
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
1 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
2 * lua.swg
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
3 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
4 * SWIG Configuration File for Lua.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
5 * This file is parsed by SWIG before reading any other interface file.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
6 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
7
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
8 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
9 * includes
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
10 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
11
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
12 %include <luatypemaps.swg> /* The typemaps */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
13 %include <luaruntime.swg> /* The runtime stuff */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
14
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
15 //%include <typemaps/swigmacros.swg>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
16 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
17 * constants typemaps
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
18 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
19 // this basically adds to a table of constants
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
20 %typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
21 {SWIG_LUA_CONSTTAB_INT("$symname", $value)}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
22
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
23 %typemap(consttab) float, double
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
24 {SWIG_LUA_CONSTTAB_FLOAT("$symname", $value)}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
25
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
26 %typemap(consttab) long long, unsigned long long, signed long long
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
27 {SWIG_LUA_CONSTTAB_FLOAT("$symname", $value)}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
28
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
29 %typemap(consttab) const long long&, const unsigned long long&, const signed long long&
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
30 {SWIG_LUA_CONSTTAB_FLOAT("$symname", *$value)}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
31
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
32 %typemap(consttab) char *, const char *, char [], const char []
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
33 {SWIG_LUA_CONSTTAB_STRING("$symname", $value)}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
34
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
35 // note: char is treated as a seperate special type
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
36 // signed char & unsigned char are numbers
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
37 %typemap(consttab) char
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
38 {SWIG_LUA_CONSTTAB_CHAR("$symname", $value)}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
39
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
40 %typemap(consttab) long long, unsigned long long
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
41 {SWIG_LUA_CONSTTAB_STRING("$symname", "$value")}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
42
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
43 %typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE []
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
44 { SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
45
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
46 // member function pointers
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
47 %typemap(consttab) SWIGTYPE (CLASS::*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
48 { SWIG_LUA_BINARY, (char *)"$symname", sizeof($type), 0, (void *)&$value, &$1_descriptor}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
49
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
50
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
51 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
52 * Overloaded operator support
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
53 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
54 // lua calls the + operator '__add'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
55 // python likes to call it '__add__'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
56 // Assuming most SWIGers will probably use the __add__ if they extend their classes
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
57 // we have two sets of renames
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
58 // one to rename the operator+() to __add()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
59 // (this lets SWIG rename the operator overloads)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
60 // another is to rename __add__() to __add()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
61 // (this means that people who wrote SWIG code to do that add will also work)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
62
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
63 #ifdef __cplusplus
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
64 // this is extra renaming for lua
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
65 // not all operators are supported, so only those that are, are listed
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
66 %rename(__add) *::operator+;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
67 %rename(__sub) *::operator-;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
68 %rename(__mul) *::operator*;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
69 %rename(__div) *::operator/;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
70 %rename(__unm) *::operator-();
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
71 %rename(__unm) *::operator-() const;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
72
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
73 %rename(__eq) *::operator==;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
74 %ignore *::operator!=; // note: Lua does not have a notequal operator
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
75 // it just uses 'not (a==b)'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
76 %rename(__lt) *::operator<;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
77 %ignore *::operator>; // ditto less than vs greater than
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
78 %rename(__le) *::operator<=;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
79 %ignore *::operator>=; // ditto less than vs greater than
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
80 %ignore *::operator!; // does not support not
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
81
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
82 %rename(__call) *::operator(); // the fn call operator
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
83
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
84 // lua does not support overloading of:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
85 // logical/bitwise operators
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
86 // assign operator
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
87 // +=,-=,*=, etc
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
88 // therefore ignoring them for now
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
89 // it also doesn't support non class operators
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
90 // eg friends or XX operator+(XX,XX)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
91 // also ignoring
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
92 // note: some of these might be better to rename, but not doing that for now
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
93 %ignore *::operator&&; %ignore operator&&;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
94 %ignore *::operator||; %ignore operator||;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
95 %ignore *::operator+=;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
96 %ignore *::operator-=;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
97 %ignore *::operator*=;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
98 %ignore *::operator/=;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
99 %ignore *::operator%=;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
100 %ignore *::operator++; %ignore *::operator--;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
101
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
102 %ignore *::operator=; // note: this might be better to rename to assign() or similar
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
103
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
104 %ignore operator+;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
105 %ignore operator-;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
106 %ignore operator*;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
107 %ignore operator/;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
108 %ignore operator%;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
109 %ignore operator[];
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
110 %ignore operator>; %ignore operator>=;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
111 %ignore operator<; %ignore operator<=;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
112 %ignore operator==; %ignore operator!=;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
113
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
114
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
115 // renaming the python operators to be compatible with lua
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
116 // this means that if a developer has written a fn __add__()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
117 // it will be used for the lua +
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
118 %rename(__add) *::__add__;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
119 %rename(__sub) *::__sub__;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
120 %rename(__mul) *::__mul__;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
121 %rename(__div) *::__div__;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
122 %rename(__unm) *::__neg__; // lua calls unary minus,'unm' not 'neg'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
123 %rename(__tostring) *::__str__; // both map to __tostring
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
124 %rename(__tostring) *::__repr__; // both map to __tostring
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
125
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
126
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
127 %rename(__pow) *::__pow__; // lua power '^' operator
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
128 %rename(__concat) *::__concat__; // lua concat '..' operator
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
129 %rename(__eq) *::__eq__;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
130 %rename(__lt) *::__lt__;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
131 %rename(__le) *::__le__;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
132 %rename(__call) *::__call__; // the fn call operator()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
133
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
134 // the [] operator has two parts, the get & the set
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
135 %rename(__getitem) *::__getitem__; // the v=X[i] (get operator)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
136 %rename(__setitem) *::__setitem__; // the X[i]=v (set operator)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
137
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
138
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
139 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
140
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
141
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
142 /* ------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
143 * Exceptions
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
144 * ------------------------------------------------------------ */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
145 /* Confession: I don't really like C++ exceptions
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
146 The python/lua ones are great, but C++ ones I don't like
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
147 (mainly because I cannot get the stack trace out of it)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
148 Therefore I have not bothered to try doing much in this
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
149
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
150 Therefore currently its just enough to get a few test cases running ok
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
151
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
152 note: if you wish to throw anything related to std::exception
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
153 use %include <std_except.i> instead
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
154 */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
155
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
156 // number as number+error
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
157 %typemap(throws) int,unsigned int,signed int,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
158 long,unsigned long,signed long,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
159 short,unsigned short,signed short,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
160 float,double,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
161 long long,unsigned long long,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
162 unsigned char, signed char,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
163 int&,unsigned int&,signed int&,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
164 long&,unsigned long&,signed long&,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
165 short&,unsigned short&,signed short&,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
166 float&,double&,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
167 long long&,unsigned long long&,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
168 unsigned char&, signed char&
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
169 %{lua_pushnumber(L,(lua_Number)$1);SWIG_fail; %}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
170
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
171 %typemap(throws) bool,bool&
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
172 %{lua_pushboolean(L,(int)($1==true));SWIG_fail; %}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
173
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
174 // enum as number+error
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
175 %typemap(throws) enum SWIGTYPE
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
176 %{lua_pushnumber(L,(lua_Number)(int)$1);SWIG_fail; %}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
177
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
178 // strings are just sent as errors
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
179 %typemap(throws) char *, const char *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
180 %{lua_pushstring(L,$1);SWIG_fail;%}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
181
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
182 // char is changed to a string
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
183 %typemap(throws) char
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
184 %{lua_pushfstring(L,"%c",$1);SWIG_fail;%}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
185
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
186 /*
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
187 Throwing object is a serious problem:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
188 Assuming some code throws a 'FooBar'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
189 There are a few options:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
190 - return a pointer to it: but its unclear how long this will last for.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
191 - return a copy of it: but not all objects are copyable
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
192 (see exception_partial_info in the test suite for a case where you cannot do this)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
193 - convert to a string & throw that
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
194 it's not so useful, but it works (this is more lua like).
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
195 The third option (though not nice) is used
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
196 For a more useful solution: see std_except for more details
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
197 */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
198
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
199 // basic typemap for structs, classes, pointers & references
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
200 // convert to string and error
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
201 %typemap(throws) SWIGTYPE
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
202 %{(void)$1; /* ignore it */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
203 lua_pushfstring(L,"object exception:%s",SWIG_TypePrettyName($1_descriptor));
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
204 SWIG_fail;%}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
205
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
206 // code to make a copy of the object and return this
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
207 // if you have a function which throws a FooBar & you want SWIG to return a copy of the object as its error
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
208 // then use one of the below
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
209 // %apply SWIGTYPE EXCEPTION_BY_VAL {FooBar};
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
210 // %apply SWIGTYPE& EXCEPTION_BY_VAL {FooBar&}; // note: need & twice
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
211 %typemap(throws) SWIGTYPE EXCEPTION_BY_VAL
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
212 %{SWIG_NewPointerObj(L,(void *)new $1_ltype(($1_ltype &) $1),$&1_descriptor,1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
213 SWIG_fail;%}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
214
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
215 // similar for object reference
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
216 // note: swig typemaps seem a little confused around here, therefore we use $basetype
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
217 %typemap(throws) SWIGTYPE& EXCEPTION_BY_VAL
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
218 %{SWIG_NewPointerObj(L,(void *)new $basetype($1),$1_descriptor,1);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
219 SWIG_fail;%}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
220
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
221
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
222 // note: no support for object pointers
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
223 // its not clear how long the pointer is valid for, therefore not supporting it
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
224
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
225 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
226 * extras
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
227 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
228 // this %define is to allow insertion of lua source code into the wrapper file
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
229 #define %luacode %insert("luacode")
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
230
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
231
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
232 /* ------------------------------ end lua.swg ------------------------------ */