1899
|
1 /* ----------------------------------------------------------------------------
|
|
2 * This file was automatically generated by SWIG (http://www.swig.org).
|
|
3 * Version 2.0.11
|
|
4 *
|
|
5 * This file is not intended to be easily readable and contains a number of
|
|
6 * coding conventions designed to improve portability and efficiency. Do not make
|
|
7 * changes to this file unless you know what you are doing--modify the SWIG
|
|
8 * interface file instead.
|
|
9 * ----------------------------------------------------------------------------- */
|
|
10
|
|
11 #define SWIGLUA
|
|
12 #define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA
|
|
13 #define SWIG_LUA_MODULE_GLOBAL
|
|
14
|
|
15
|
|
16 #ifdef __cplusplus
|
|
17 /* SwigValueWrapper is described in swig.swg */
|
|
18 template<typename T> class SwigValueWrapper {
|
|
19 struct SwigMovePointer {
|
|
20 T *ptr;
|
|
21 SwigMovePointer(T *p) : ptr(p) { }
|
|
22 ~SwigMovePointer() { delete ptr; }
|
|
23 SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
|
|
24 } pointer;
|
|
25 SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
|
|
26 SwigValueWrapper(const SwigValueWrapper<T>& rhs);
|
|
27 public:
|
|
28 SwigValueWrapper() : pointer(0) { }
|
|
29 SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
|
|
30 operator T&() const { return *pointer.ptr; }
|
|
31 T *operator&() { return pointer.ptr; }
|
|
32 };
|
|
33
|
|
34 template <typename T> T SwigValueInit() {
|
|
35 return T();
|
|
36 }
|
|
37 #endif
|
|
38
|
|
39 /* -----------------------------------------------------------------------------
|
|
40 * This section contains generic SWIG labels for method/variable
|
|
41 * declarations/attributes, and other compiler dependent labels.
|
|
42 * ----------------------------------------------------------------------------- */
|
|
43
|
|
44 /* template workaround for compilers that cannot correctly implement the C++ standard */
|
|
45 #ifndef SWIGTEMPLATEDISAMBIGUATOR
|
|
46 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
|
|
47 # define SWIGTEMPLATEDISAMBIGUATOR template
|
|
48 # elif defined(__HP_aCC)
|
|
49 /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
|
|
50 /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
|
|
51 # define SWIGTEMPLATEDISAMBIGUATOR template
|
|
52 # else
|
|
53 # define SWIGTEMPLATEDISAMBIGUATOR
|
|
54 # endif
|
|
55 #endif
|
|
56
|
|
57 /* inline attribute */
|
|
58 #ifndef SWIGINLINE
|
|
59 # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
|
|
60 # define SWIGINLINE inline
|
|
61 # else
|
|
62 # define SWIGINLINE
|
|
63 # endif
|
|
64 #endif
|
|
65
|
|
66 /* attribute recognised by some compilers to avoid 'unused' warnings */
|
|
67 #ifndef SWIGUNUSED
|
|
68 # if defined(__GNUC__)
|
|
69 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
|
70 # define SWIGUNUSED __attribute__ ((__unused__))
|
|
71 # else
|
|
72 # define SWIGUNUSED
|
|
73 # endif
|
|
74 # elif defined(__ICC)
|
|
75 # define SWIGUNUSED __attribute__ ((__unused__))
|
|
76 # else
|
|
77 # define SWIGUNUSED
|
|
78 # endif
|
|
79 #endif
|
|
80
|
|
81 #ifndef SWIG_MSC_UNSUPPRESS_4505
|
|
82 # if defined(_MSC_VER)
|
|
83 # pragma warning(disable : 4505) /* unreferenced local function has been removed */
|
|
84 # endif
|
|
85 #endif
|
|
86
|
|
87 #ifndef SWIGUNUSEDPARM
|
|
88 # ifdef __cplusplus
|
|
89 # define SWIGUNUSEDPARM(p)
|
|
90 # else
|
|
91 # define SWIGUNUSEDPARM(p) p SWIGUNUSED
|
|
92 # endif
|
|
93 #endif
|
|
94
|
|
95 /* internal SWIG method */
|
|
96 #ifndef SWIGINTERN
|
|
97 # define SWIGINTERN static SWIGUNUSED
|
|
98 #endif
|
|
99
|
|
100 /* internal inline SWIG method */
|
|
101 #ifndef SWIGINTERNINLINE
|
|
102 # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
|
|
103 #endif
|
|
104
|
|
105 /* exporting methods */
|
|
106 #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
|
|
107 # ifndef GCC_HASCLASSVISIBILITY
|
|
108 # define GCC_HASCLASSVISIBILITY
|
|
109 # endif
|
|
110 #endif
|
|
111
|
|
112 #ifndef SWIGEXPORT
|
|
113 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
|
114 # if defined(STATIC_LINKED)
|
|
115 # define SWIGEXPORT
|
|
116 # else
|
|
117 # define SWIGEXPORT __declspec(dllexport)
|
|
118 # endif
|
|
119 # else
|
|
120 # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
|
|
121 # define SWIGEXPORT __attribute__ ((visibility("default")))
|
|
122 # else
|
|
123 # define SWIGEXPORT
|
|
124 # endif
|
|
125 # endif
|
|
126 #endif
|
|
127
|
|
128 /* calling conventions for Windows */
|
|
129 #ifndef SWIGSTDCALL
|
|
130 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
|
131 # define SWIGSTDCALL __stdcall
|
|
132 # else
|
|
133 # define SWIGSTDCALL
|
|
134 # endif
|
|
135 #endif
|
|
136
|
|
137 /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
|
|
138 #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
|
139 # define _CRT_SECURE_NO_DEPRECATE
|
|
140 #endif
|
|
141
|
|
142 /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
|
|
143 #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
|
|
144 # define _SCL_SECURE_NO_DEPRECATE
|
|
145 #endif
|
|
146
|
|
147
|
|
148 /* -----------------------------------------------------------------------------
|
|
149 * swigrun.swg
|
|
150 *
|
|
151 * This file contains generic C API SWIG runtime support for pointer
|
|
152 * type checking.
|
|
153 * ----------------------------------------------------------------------------- */
|
|
154
|
|
155 /* This should only be incremented when either the layout of swig_type_info changes,
|
|
156 or for whatever reason, the runtime changes incompatibly */
|
|
157 #define SWIG_RUNTIME_VERSION "4"
|
|
158
|
|
159 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
|
|
160 #ifdef SWIG_TYPE_TABLE
|
|
161 # define SWIG_QUOTE_STRING(x) #x
|
|
162 # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
|
|
163 # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
|
|
164 #else
|
|
165 # define SWIG_TYPE_TABLE_NAME
|
|
166 #endif
|
|
167
|
|
168 /*
|
|
169 You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
|
|
170 creating a static or dynamic library from the SWIG runtime code.
|
|
171 In 99.9% of the cases, SWIG just needs to declare them as 'static'.
|
|
172
|
|
173 But only do this if strictly necessary, ie, if you have problems
|
|
174 with your compiler or suchlike.
|
|
175 */
|
|
176
|
|
177 #ifndef SWIGRUNTIME
|
|
178 # define SWIGRUNTIME SWIGINTERN
|
|
179 #endif
|
|
180
|
|
181 #ifndef SWIGRUNTIMEINLINE
|
|
182 # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
|
|
183 #endif
|
|
184
|
|
185 /* Generic buffer size */
|
|
186 #ifndef SWIG_BUFFER_SIZE
|
|
187 # define SWIG_BUFFER_SIZE 1024
|
|
188 #endif
|
|
189
|
|
190 /* Flags for pointer conversions */
|
|
191 #define SWIG_POINTER_DISOWN 0x1
|
|
192 #define SWIG_CAST_NEW_MEMORY 0x2
|
|
193
|
|
194 /* Flags for new pointer objects */
|
|
195 #define SWIG_POINTER_OWN 0x1
|
|
196
|
|
197
|
|
198 /*
|
|
199 Flags/methods for returning states.
|
|
200
|
|
201 The SWIG conversion methods, as ConvertPtr, return an integer
|
|
202 that tells if the conversion was successful or not. And if not,
|
|
203 an error code can be returned (see swigerrors.swg for the codes).
|
|
204
|
|
205 Use the following macros/flags to set or process the returning
|
|
206 states.
|
|
207
|
|
208 In old versions of SWIG, code such as the following was usually written:
|
|
209
|
|
210 if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
|
|
211 // success code
|
|
212 } else {
|
|
213 //fail code
|
|
214 }
|
|
215
|
|
216 Now you can be more explicit:
|
|
217
|
|
218 int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
|
|
219 if (SWIG_IsOK(res)) {
|
|
220 // success code
|
|
221 } else {
|
|
222 // fail code
|
|
223 }
|
|
224
|
|
225 which is the same really, but now you can also do
|
|
226
|
|
227 Type *ptr;
|
|
228 int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
|
|
229 if (SWIG_IsOK(res)) {
|
|
230 // success code
|
|
231 if (SWIG_IsNewObj(res) {
|
|
232 ...
|
|
233 delete *ptr;
|
|
234 } else {
|
|
235 ...
|
|
236 }
|
|
237 } else {
|
|
238 // fail code
|
|
239 }
|
|
240
|
|
241 I.e., now SWIG_ConvertPtr can return new objects and you can
|
|
242 identify the case and take care of the deallocation. Of course that
|
|
243 also requires SWIG_ConvertPtr to return new result values, such as
|
|
244
|
|
245 int SWIG_ConvertPtr(obj, ptr,...) {
|
|
246 if (<obj is ok>) {
|
|
247 if (<need new object>) {
|
|
248 *ptr = <ptr to new allocated object>;
|
|
249 return SWIG_NEWOBJ;
|
|
250 } else {
|
|
251 *ptr = <ptr to old object>;
|
|
252 return SWIG_OLDOBJ;
|
|
253 }
|
|
254 } else {
|
|
255 return SWIG_BADOBJ;
|
|
256 }
|
|
257 }
|
|
258
|
|
259 Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
|
|
260 more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
|
|
261 SWIG errors code.
|
|
262
|
|
263 Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
|
|
264 allows to return the 'cast rank', for example, if you have this
|
|
265
|
|
266 int food(double)
|
|
267 int fooi(int);
|
|
268
|
|
269 and you call
|
|
270
|
|
271 food(1) // cast rank '1' (1 -> 1.0)
|
|
272 fooi(1) // cast rank '0'
|
|
273
|
|
274 just use the SWIG_AddCast()/SWIG_CheckState()
|
|
275 */
|
|
276
|
|
277 #define SWIG_OK (0)
|
|
278 #define SWIG_ERROR (-1)
|
|
279 #define SWIG_IsOK(r) (r >= 0)
|
|
280 #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
|
|
281
|
|
282 /* The CastRankLimit says how many bits are used for the cast rank */
|
|
283 #define SWIG_CASTRANKLIMIT (1 << 8)
|
|
284 /* The NewMask denotes the object was created (using new/malloc) */
|
|
285 #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
|
|
286 /* The TmpMask is for in/out typemaps that use temporal objects */
|
|
287 #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
|
|
288 /* Simple returning values */
|
|
289 #define SWIG_BADOBJ (SWIG_ERROR)
|
|
290 #define SWIG_OLDOBJ (SWIG_OK)
|
|
291 #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
|
|
292 #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
|
|
293 /* Check, add and del mask methods */
|
|
294 #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
|
|
295 #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
|
|
296 #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
|
|
297 #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
|
|
298 #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
|
|
299 #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
|
|
300
|
|
301 /* Cast-Rank Mode */
|
|
302 #if defined(SWIG_CASTRANK_MODE)
|
|
303 # ifndef SWIG_TypeRank
|
|
304 # define SWIG_TypeRank unsigned long
|
|
305 # endif
|
|
306 # ifndef SWIG_MAXCASTRANK /* Default cast allowed */
|
|
307 # define SWIG_MAXCASTRANK (2)
|
|
308 # endif
|
|
309 # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
|
|
310 # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
|
|
311 SWIGINTERNINLINE int SWIG_AddCast(int r) {
|
|
312 return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
|
|
313 }
|
|
314 SWIGINTERNINLINE int SWIG_CheckState(int r) {
|
|
315 return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
|
|
316 }
|
|
317 #else /* no cast-rank mode */
|
|
318 # define SWIG_AddCast(r) (r)
|
|
319 # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
|
|
320 #endif
|
|
321
|
|
322
|
|
323 #include <string.h>
|
|
324
|
|
325 #ifdef __cplusplus
|
|
326 extern "C" {
|
|
327 #endif
|
|
328
|
|
329 typedef void *(*swig_converter_func)(void *, int *);
|
|
330 typedef struct swig_type_info *(*swig_dycast_func)(void **);
|
|
331
|
|
332 /* Structure to store information on one type */
|
|
333 typedef struct swig_type_info {
|
|
334 const char *name; /* mangled name of this type */
|
|
335 const char *str; /* human readable name of this type */
|
|
336 swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
|
|
337 struct swig_cast_info *cast; /* linked list of types that can cast into this type */
|
|
338 void *clientdata; /* language specific type data */
|
|
339 int owndata; /* flag if the structure owns the clientdata */
|
|
340 } swig_type_info;
|
|
341
|
|
342 /* Structure to store a type and conversion function used for casting */
|
|
343 typedef struct swig_cast_info {
|
|
344 swig_type_info *type; /* pointer to type that is equivalent to this type */
|
|
345 swig_converter_func converter; /* function to cast the void pointers */
|
|
346 struct swig_cast_info *next; /* pointer to next cast in linked list */
|
|
347 struct swig_cast_info *prev; /* pointer to the previous cast */
|
|
348 } swig_cast_info;
|
|
349
|
|
350 /* Structure used to store module information
|
|
351 * Each module generates one structure like this, and the runtime collects
|
|
352 * all of these structures and stores them in a circularly linked list.*/
|
|
353 typedef struct swig_module_info {
|
|
354 swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
|
|
355 size_t size; /* Number of types in this module */
|
|
356 struct swig_module_info *next; /* Pointer to next element in circularly linked list */
|
|
357 swig_type_info **type_initial; /* Array of initially generated type structures */
|
|
358 swig_cast_info **cast_initial; /* Array of initially generated casting structures */
|
|
359 void *clientdata; /* Language specific module data */
|
|
360 } swig_module_info;
|
|
361
|
|
362 /*
|
|
363 Compare two type names skipping the space characters, therefore
|
|
364 "char*" == "char *" and "Class<int>" == "Class<int >", etc.
|
|
365
|
|
366 Return 0 when the two name types are equivalent, as in
|
|
367 strncmp, but skipping ' '.
|
|
368 */
|
|
369 SWIGRUNTIME int
|
|
370 SWIG_TypeNameComp(const char *f1, const char *l1,
|
|
371 const char *f2, const char *l2) {
|
|
372 for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
|
|
373 while ((*f1 == ' ') && (f1 != l1)) ++f1;
|
|
374 while ((*f2 == ' ') && (f2 != l2)) ++f2;
|
|
375 if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
|
|
376 }
|
|
377 return (int)((l1 - f1) - (l2 - f2));
|
|
378 }
|
|
379
|
|
380 /*
|
|
381 Check type equivalence in a name list like <name1>|<name2>|...
|
|
382 Return 0 if equal, -1 if nb < tb, 1 if nb > tb
|
|
383 */
|
|
384 SWIGRUNTIME int
|
|
385 SWIG_TypeCmp(const char *nb, const char *tb) {
|
|
386 int equiv = 1;
|
|
387 const char* te = tb + strlen(tb);
|
|
388 const char* ne = nb;
|
|
389 while (equiv != 0 && *ne) {
|
|
390 for (nb = ne; *ne; ++ne) {
|
|
391 if (*ne == '|') break;
|
|
392 }
|
|
393 equiv = SWIG_TypeNameComp(nb, ne, tb, te);
|
|
394 if (*ne) ++ne;
|
|
395 }
|
|
396 return equiv;
|
|
397 }
|
|
398
|
|
399 /*
|
|
400 Check type equivalence in a name list like <name1>|<name2>|...
|
|
401 Return 0 if not equal, 1 if equal
|
|
402 */
|
|
403 SWIGRUNTIME int
|
|
404 SWIG_TypeEquiv(const char *nb, const char *tb) {
|
|
405 return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
|
|
406 }
|
|
407
|
|
408 /*
|
|
409 Check the typename
|
|
410 */
|
|
411 SWIGRUNTIME swig_cast_info *
|
|
412 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
|
|
413 if (ty) {
|
|
414 swig_cast_info *iter = ty->cast;
|
|
415 while (iter) {
|
|
416 if (strcmp(iter->type->name, c) == 0) {
|
|
417 if (iter == ty->cast)
|
|
418 return iter;
|
|
419 /* Move iter to the top of the linked list */
|
|
420 iter->prev->next = iter->next;
|
|
421 if (iter->next)
|
|
422 iter->next->prev = iter->prev;
|
|
423 iter->next = ty->cast;
|
|
424 iter->prev = 0;
|
|
425 if (ty->cast) ty->cast->prev = iter;
|
|
426 ty->cast = iter;
|
|
427 return iter;
|
|
428 }
|
|
429 iter = iter->next;
|
|
430 }
|
|
431 }
|
|
432 return 0;
|
|
433 }
|
|
434
|
|
435 /*
|
|
436 Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
|
|
437 */
|
|
438 SWIGRUNTIME swig_cast_info *
|
|
439 SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
|
|
440 if (ty) {
|
|
441 swig_cast_info *iter = ty->cast;
|
|
442 while (iter) {
|
|
443 if (iter->type == from) {
|
|
444 if (iter == ty->cast)
|
|
445 return iter;
|
|
446 /* Move iter to the top of the linked list */
|
|
447 iter->prev->next = iter->next;
|
|
448 if (iter->next)
|
|
449 iter->next->prev = iter->prev;
|
|
450 iter->next = ty->cast;
|
|
451 iter->prev = 0;
|
|
452 if (ty->cast) ty->cast->prev = iter;
|
|
453 ty->cast = iter;
|
|
454 return iter;
|
|
455 }
|
|
456 iter = iter->next;
|
|
457 }
|
|
458 }
|
|
459 return 0;
|
|
460 }
|
|
461
|
|
462 /*
|
|
463 Cast a pointer up an inheritance hierarchy
|
|
464 */
|
|
465 SWIGRUNTIMEINLINE void *
|
|
466 SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
|
|
467 return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
|
|
468 }
|
|
469
|
|
470 /*
|
|
471 Dynamic pointer casting. Down an inheritance hierarchy
|
|
472 */
|
|
473 SWIGRUNTIME swig_type_info *
|
|
474 SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
|
|
475 swig_type_info *lastty = ty;
|
|
476 if (!ty || !ty->dcast) return ty;
|
|
477 while (ty && (ty->dcast)) {
|
|
478 ty = (*ty->dcast)(ptr);
|
|
479 if (ty) lastty = ty;
|
|
480 }
|
|
481 return lastty;
|
|
482 }
|
|
483
|
|
484 /*
|
|
485 Return the name associated with this type
|
|
486 */
|
|
487 SWIGRUNTIMEINLINE const char *
|
|
488 SWIG_TypeName(const swig_type_info *ty) {
|
|
489 return ty->name;
|
|
490 }
|
|
491
|
|
492 /*
|
|
493 Return the pretty name associated with this type,
|
|
494 that is an unmangled type name in a form presentable to the user.
|
|
495 */
|
|
496 SWIGRUNTIME const char *
|
|
497 SWIG_TypePrettyName(const swig_type_info *type) {
|
|
498 /* The "str" field contains the equivalent pretty names of the
|
|
499 type, separated by vertical-bar characters. We choose
|
|
500 to print the last name, as it is often (?) the most
|
|
501 specific. */
|
|
502 if (!type) return NULL;
|
|
503 if (type->str != NULL) {
|
|
504 const char *last_name = type->str;
|
|
505 const char *s;
|
|
506 for (s = type->str; *s; s++)
|
|
507 if (*s == '|') last_name = s+1;
|
|
508 return last_name;
|
|
509 }
|
|
510 else
|
|
511 return type->name;
|
|
512 }
|
|
513
|
|
514 /*
|
|
515 Set the clientdata field for a type
|
|
516 */
|
|
517 SWIGRUNTIME void
|
|
518 SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
|
|
519 swig_cast_info *cast = ti->cast;
|
|
520 /* if (ti->clientdata == clientdata) return; */
|
|
521 ti->clientdata = clientdata;
|
|
522
|
|
523 while (cast) {
|
|
524 if (!cast->converter) {
|
|
525 swig_type_info *tc = cast->type;
|
|
526 if (!tc->clientdata) {
|
|
527 SWIG_TypeClientData(tc, clientdata);
|
|
528 }
|
|
529 }
|
|
530 cast = cast->next;
|
|
531 }
|
|
532 }
|
|
533 SWIGRUNTIME void
|
|
534 SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
|
|
535 SWIG_TypeClientData(ti, clientdata);
|
|
536 ti->owndata = 1;
|
|
537 }
|
|
538
|
|
539 /*
|
|
540 Search for a swig_type_info structure only by mangled name
|
|
541 Search is a O(log #types)
|
|
542
|
|
543 We start searching at module start, and finish searching when start == end.
|
|
544 Note: if start == end at the beginning of the function, we go all the way around
|
|
545 the circular list.
|
|
546 */
|
|
547 SWIGRUNTIME swig_type_info *
|
|
548 SWIG_MangledTypeQueryModule(swig_module_info *start,
|
|
549 swig_module_info *end,
|
|
550 const char *name) {
|
|
551 swig_module_info *iter = start;
|
|
552 do {
|
|
553 if (iter->size) {
|
|
554 register size_t l = 0;
|
|
555 register size_t r = iter->size - 1;
|
|
556 do {
|
|
557 /* since l+r >= 0, we can (>> 1) instead (/ 2) */
|
|
558 register size_t i = (l + r) >> 1;
|
|
559 const char *iname = iter->types[i]->name;
|
|
560 if (iname) {
|
|
561 register int compare = strcmp(name, iname);
|
|
562 if (compare == 0) {
|
|
563 return iter->types[i];
|
|
564 } else if (compare < 0) {
|
|
565 if (i) {
|
|
566 r = i - 1;
|
|
567 } else {
|
|
568 break;
|
|
569 }
|
|
570 } else if (compare > 0) {
|
|
571 l = i + 1;
|
|
572 }
|
|
573 } else {
|
|
574 break; /* should never happen */
|
|
575 }
|
|
576 } while (l <= r);
|
|
577 }
|
|
578 iter = iter->next;
|
|
579 } while (iter != end);
|
|
580 return 0;
|
|
581 }
|
|
582
|
|
583 /*
|
|
584 Search for a swig_type_info structure for either a mangled name or a human readable name.
|
|
585 It first searches the mangled names of the types, which is a O(log #types)
|
|
586 If a type is not found it then searches the human readable names, which is O(#types).
|
|
587
|
|
588 We start searching at module start, and finish searching when start == end.
|
|
589 Note: if start == end at the beginning of the function, we go all the way around
|
|
590 the circular list.
|
|
591 */
|
|
592 SWIGRUNTIME swig_type_info *
|
|
593 SWIG_TypeQueryModule(swig_module_info *start,
|
|
594 swig_module_info *end,
|
|
595 const char *name) {
|
|
596 /* STEP 1: Search the name field using binary search */
|
|
597 swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
|
|
598 if (ret) {
|
|
599 return ret;
|
|
600 } else {
|
|
601 /* STEP 2: If the type hasn't been found, do a complete search
|
|
602 of the str field (the human readable name) */
|
|
603 swig_module_info *iter = start;
|
|
604 do {
|
|
605 register size_t i = 0;
|
|
606 for (; i < iter->size; ++i) {
|
|
607 if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
|
|
608 return iter->types[i];
|
|
609 }
|
|
610 iter = iter->next;
|
|
611 } while (iter != end);
|
|
612 }
|
|
613
|
|
614 /* neither found a match */
|
|
615 return 0;
|
|
616 }
|
|
617
|
|
618 /*
|
|
619 Pack binary data into a string
|
|
620 */
|
|
621 SWIGRUNTIME char *
|
|
622 SWIG_PackData(char *c, void *ptr, size_t sz) {
|
|
623 static const char hex[17] = "0123456789abcdef";
|
|
624 register const unsigned char *u = (unsigned char *) ptr;
|
|
625 register const unsigned char *eu = u + sz;
|
|
626 for (; u != eu; ++u) {
|
|
627 register unsigned char uu = *u;
|
|
628 *(c++) = hex[(uu & 0xf0) >> 4];
|
|
629 *(c++) = hex[uu & 0xf];
|
|
630 }
|
|
631 return c;
|
|
632 }
|
|
633
|
|
634 /*
|
|
635 Unpack binary data from a string
|
|
636 */
|
|
637 SWIGRUNTIME const char *
|
|
638 SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|
639 register unsigned char *u = (unsigned char *) ptr;
|
|
640 register const unsigned char *eu = u + sz;
|
|
641 for (; u != eu; ++u) {
|
|
642 register char d = *(c++);
|
|
643 register unsigned char uu;
|
|
644 if ((d >= '0') && (d <= '9'))
|
|
645 uu = ((d - '0') << 4);
|
|
646 else if ((d >= 'a') && (d <= 'f'))
|
|
647 uu = ((d - ('a'-10)) << 4);
|
|
648 else
|
|
649 return (char *) 0;
|
|
650 d = *(c++);
|
|
651 if ((d >= '0') && (d <= '9'))
|
|
652 uu |= (d - '0');
|
|
653 else if ((d >= 'a') && (d <= 'f'))
|
|
654 uu |= (d - ('a'-10));
|
|
655 else
|
|
656 return (char *) 0;
|
|
657 *u = uu;
|
|
658 }
|
|
659 return c;
|
|
660 }
|
|
661
|
|
662 /*
|
|
663 Pack 'void *' into a string buffer.
|
|
664 */
|
|
665 SWIGRUNTIME char *
|
|
666 SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
|
|
667 char *r = buff;
|
|
668 if ((2*sizeof(void *) + 2) > bsz) return 0;
|
|
669 *(r++) = '_';
|
|
670 r = SWIG_PackData(r,&ptr,sizeof(void *));
|
|
671 if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
|
|
672 strcpy(r,name);
|
|
673 return buff;
|
|
674 }
|
|
675
|
|
676 SWIGRUNTIME const char *
|
|
677 SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
|
|
678 if (*c != '_') {
|
|
679 if (strcmp(c,"NULL") == 0) {
|
|
680 *ptr = (void *) 0;
|
|
681 return name;
|
|
682 } else {
|
|
683 return 0;
|
|
684 }
|
|
685 }
|
|
686 return SWIG_UnpackData(++c,ptr,sizeof(void *));
|
|
687 }
|
|
688
|
|
689 SWIGRUNTIME char *
|
|
690 SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
|
|
691 char *r = buff;
|
|
692 size_t lname = (name ? strlen(name) : 0);
|
|
693 if ((2*sz + 2 + lname) > bsz) return 0;
|
|
694 *(r++) = '_';
|
|
695 r = SWIG_PackData(r,ptr,sz);
|
|
696 if (lname) {
|
|
697 strncpy(r,name,lname+1);
|
|
698 } else {
|
|
699 *r = 0;
|
|
700 }
|
|
701 return buff;
|
|
702 }
|
|
703
|
|
704 SWIGRUNTIME const char *
|
|
705 SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
|
|
706 if (*c != '_') {
|
|
707 if (strcmp(c,"NULL") == 0) {
|
|
708 memset(ptr,0,sz);
|
|
709 return name;
|
|
710 } else {
|
|
711 return 0;
|
|
712 }
|
|
713 }
|
|
714 return SWIG_UnpackData(++c,ptr,sz);
|
|
715 }
|
|
716
|
|
717 #ifdef __cplusplus
|
|
718 }
|
|
719 #endif
|
|
720
|
|
721 /* -----------------------------------------------------------------------------
|
|
722 * luarun.swg
|
|
723 *
|
|
724 * This file contains the runtime support for Lua modules
|
|
725 * and includes code for managing global variables and pointer
|
|
726 * type checking.
|
|
727 * ----------------------------------------------------------------------------- */
|
|
728
|
|
729 #ifdef __cplusplus
|
|
730 extern "C" {
|
|
731 #endif
|
|
732
|
|
733 #include "lua.h"
|
|
734 #include "lauxlib.h"
|
|
735 #include <stdlib.h> /* for malloc */
|
|
736 #include <assert.h> /* for a few sanity tests */
|
|
737
|
|
738 /* -----------------------------------------------------------------------------
|
|
739 * Lua flavors
|
|
740 * ----------------------------------------------------------------------------- */
|
|
741
|
|
742 #define SWIG_LUA_FLAVOR_LUA 1
|
|
743 #define SWIG_LUA_FLAVOR_ELUA 2
|
|
744 #define SWIG_LUA_FLAVOR_ELUAC 3
|
|
745
|
|
746 #if !defined(SWIG_LUA_TARGET)
|
|
747 # error SWIG_LUA_TARGET not defined
|
|
748 #endif
|
|
749
|
|
750 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
|
|
751 # define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C)
|
|
752 # define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C)
|
|
753 # define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C)
|
|
754 # define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C)
|
|
755 #else /* SWIG_LUA_FLAVOR_LUA */
|
|
756 # define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0
|
|
757 # define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0
|
|
758 # define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0
|
|
759 # define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0
|
|
760 #endif
|
|
761
|
|
762 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
|
|
763 # define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING}
|
|
764 # define LSTRVAL LRO_STRVAL
|
|
765 #endif
|
|
766
|
|
767 /* -----------------------------------------------------------------------------
|
|
768 * compatibility defines
|
|
769 * ----------------------------------------------------------------------------- */
|
|
770
|
|
771 /* History of Lua C API length functions: In Lua 5.0 (and before?)
|
|
772 there was "lua_strlen". In Lua 5.1, this was renamed "lua_objlen",
|
|
773 but a compatibility define of "lua_strlen" was added. In Lua 5.2,
|
|
774 this function was again renamed, to "lua_rawlen" (to emphasize that
|
|
775 it doesn't call the "__len" metamethod), and the compatibility
|
|
776 define of lua_strlen was removed. All SWIG uses have been updated
|
|
777 to "lua_rawlen", and we add our own defines of that here for older
|
|
778 versions of Lua. */
|
|
779 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501
|
|
780 # define lua_rawlen lua_strlen
|
|
781 #elif LUA_VERSION_NUM == 501
|
|
782 # define lua_rawlen lua_objlen
|
|
783 #endif
|
|
784
|
|
785
|
|
786 /* lua_pushglobaltable is the recommended "future-proof" way to get
|
|
787 the global table for Lua 5.2 and later. Here we define
|
|
788 lua_pushglobaltable ourselves for Lua versions before 5.2. */
|
|
789 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
|
|
790 # define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX)
|
|
791 #endif
|
|
792
|
|
793
|
|
794 /* --------------------------------------------------------------------------
|
|
795 * Helper functions for error handling
|
|
796 * -------------------------------------------------------------------------- */
|
|
797
|
|
798 /* Push the string STR on the Lua stack, like lua_pushstring, but
|
|
799 prefixed with the the location of the innermost Lua call-point
|
|
800 (as formated by luaL_where). */
|
|
801 SWIGRUNTIME void
|
|
802 SWIG_Lua_pusherrstring (lua_State *L, const char *str)
|
|
803 {
|
|
804 luaL_where (L, 1);
|
|
805 lua_pushstring (L, str);
|
|
806 lua_concat (L, 2);
|
|
807 }
|
|
808
|
|
809 /* Push a formatted string generated from FMT and following args on
|
|
810 the Lua stack, like lua_pushfstring, but prefixed with the the
|
|
811 location of the innermost Lua call-point (as formated by luaL_where). */
|
|
812 SWIGRUNTIME void
|
|
813 SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...)
|
|
814 {
|
|
815 va_list argp;
|
|
816 va_start(argp, fmt);
|
|
817 luaL_where(L, 1);
|
|
818 lua_pushvfstring(L, fmt, argp);
|
|
819 va_end(argp);
|
|
820 lua_concat(L, 2);
|
|
821 }
|
|
822
|
|
823
|
|
824 /* -----------------------------------------------------------------------------
|
|
825 * global swig types
|
|
826 * ----------------------------------------------------------------------------- */
|
|
827 /* Constant table */
|
|
828 #define SWIG_LUA_INT 1
|
|
829 #define SWIG_LUA_FLOAT 2
|
|
830 #define SWIG_LUA_STRING 3
|
|
831 #define SWIG_LUA_POINTER 4
|
|
832 #define SWIG_LUA_BINARY 5
|
|
833 #define SWIG_LUA_CHAR 6
|
|
834
|
|
835 /* Structure for variable linking table */
|
|
836 typedef struct {
|
|
837 const char *name;
|
|
838 lua_CFunction get;
|
|
839 lua_CFunction set;
|
|
840 } swig_lua_var_info;
|
|
841
|
|
842 /* Constant information structure */
|
|
843 typedef struct {
|
|
844 int type;
|
|
845 char *name;
|
|
846 long lvalue;
|
|
847 double dvalue;
|
|
848 void *pvalue;
|
|
849 swig_type_info **ptype;
|
|
850 } swig_lua_const_info;
|
|
851
|
|
852 typedef struct {
|
|
853 const char *name;
|
|
854 lua_CFunction method;
|
|
855 } swig_lua_method;
|
|
856
|
|
857 typedef struct {
|
|
858 const char *name;
|
|
859 lua_CFunction getmethod;
|
|
860 lua_CFunction setmethod;
|
|
861 } swig_lua_attribute;
|
|
862
|
|
863 // Can be used to create namespaces. Currently used to
|
|
864 // wrap class static methods/variables/constants
|
|
865 typedef struct {
|
|
866 const char *name;
|
|
867 swig_lua_method *ns_methods;
|
|
868 swig_lua_attribute *ns_attributes;
|
|
869 swig_lua_const_info *ns_constants;
|
|
870 } swig_lua_namespace;
|
|
871
|
|
872 typedef struct swig_lua_class {
|
|
873 const char *name;
|
|
874 swig_type_info **type;
|
|
875 lua_CFunction constructor;
|
|
876 void (*destructor)(void *);
|
|
877 swig_lua_method *methods;
|
|
878 swig_lua_attribute *attributes;
|
|
879 swig_lua_namespace cls_static;
|
|
880 struct swig_lua_class **bases;
|
|
881 const char **base_names;
|
|
882 } swig_lua_class;
|
|
883
|
|
884 /* this is the struct for wrapping all pointers in SwigLua
|
|
885 */
|
|
886 typedef struct {
|
|
887 swig_type_info *type;
|
|
888 int own; /* 1 if owned & must be destroyed */
|
|
889 void *ptr;
|
|
890 } swig_lua_userdata;
|
|
891
|
|
892 /* this is the struct for wrapping arbitrary packed binary data
|
|
893 (currently it is only used for member function pointers)
|
|
894 the data ordering is similar to swig_lua_userdata, but it is currently not possible
|
|
895 to tell the two structures apart within SWIG, other than by looking at the type
|
|
896 */
|
|
897 typedef struct {
|
|
898 swig_type_info *type;
|
|
899 int own; /* 1 if owned & must be destroyed */
|
|
900 char data[1]; /* arbitary amount of data */
|
|
901 } swig_lua_rawdata;
|
|
902
|
|
903 /* Common SWIG API */
|
|
904 #define SWIG_NewPointerObj(L, ptr, type, owner) SWIG_Lua_NewPointerObj(L, (void *)ptr, type, owner)
|
|
905 #define SWIG_ConvertPtr(L,idx, ptr, type, flags) SWIG_Lua_ConvertPtr(L,idx,ptr,type,flags)
|
|
906 #define SWIG_MustGetPtr(L,idx, type,flags, argnum,fnname) SWIG_Lua_MustGetPtr(L,idx, type,flags, argnum,fnname)
|
|
907 /* for C++ member pointers, ie, member methods */
|
|
908 #define SWIG_ConvertMember(L, idx, ptr, sz, ty) SWIG_Lua_ConvertPacked(L, idx, ptr, sz, ty)
|
|
909 #define SWIG_NewMemberObj(L, ptr, sz, type) SWIG_Lua_NewPackedObj(L, ptr, sz, type)
|
|
910
|
|
911 /* Runtime API */
|
|
912 #define SWIG_GetModule(clientdata) SWIG_Lua_GetModule((lua_State*)(clientdata))
|
|
913 #define SWIG_SetModule(clientdata, pointer) SWIG_Lua_SetModule((lua_State*) (clientdata), pointer)
|
|
914 #define SWIG_MODULE_CLIENTDATA_TYPE lua_State*
|
|
915
|
|
916 /* Contract support */
|
|
917 #define SWIG_contract_assert(expr, msg) \
|
|
918 if (!(expr)) { SWIG_Lua_pusherrstring(L, (char *) msg); goto fail; } else
|
|
919
|
|
920
|
|
921 /* helper #defines */
|
|
922 #define SWIG_fail {goto fail;}
|
|
923 #define SWIG_fail_arg(func_name,argnum,type) \
|
|
924 {SWIG_Lua_pushferrstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\
|
|
925 func_name,argnum,type,SWIG_Lua_typename(L,argnum));\
|
|
926 goto fail;}
|
|
927 #define SWIG_fail_ptr(func_name,argnum,type) \
|
|
928 SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*")
|
|
929 #define SWIG_check_num_args(func_name,a,b) \
|
|
930 if (lua_gettop(L)<a || lua_gettop(L)>b) \
|
|
931 {SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\
|
|
932 goto fail;}
|
|
933
|
|
934
|
|
935 #define SWIG_Lua_get_table(L,n) \
|
|
936 (lua_pushstring(L, n), lua_rawget(L,-2))
|
|
937
|
|
938 #define SWIG_Lua_add_function(L,n,f) \
|
|
939 (lua_pushstring(L, n), \
|
|
940 lua_pushcfunction(L, f), \
|
|
941 lua_rawset(L,-3))
|
|
942
|
|
943 /* special helper for allowing 'nil' for usertypes */
|
|
944 #define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I))
|
|
945
|
|
946 #ifdef __cplusplus
|
|
947 /* Special helper for member function pointers
|
|
948 it gets the address, casts it, then dereferences it */
|
|
949 //#define SWIG_mem_fn_as_voidptr(a) (*((char**)&(a)))
|
|
950 #endif
|
|
951
|
|
952 /* storing/access of swig_module_info */
|
|
953 SWIGRUNTIME swig_module_info *
|
|
954 SWIG_Lua_GetModule(lua_State* L) {
|
|
955 swig_module_info *ret = 0;
|
|
956 lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
|
|
957 lua_rawget(L,LUA_REGISTRYINDEX);
|
|
958 if (lua_islightuserdata(L,-1))
|
|
959 ret=(swig_module_info*)lua_touserdata(L,-1);
|
|
960 lua_pop(L,1); /* tidy */
|
|
961 return ret;
|
|
962 }
|
|
963
|
|
964 SWIGRUNTIME void
|
|
965 SWIG_Lua_SetModule(lua_State* L, swig_module_info *module) {
|
|
966 /* add this all into the Lua registry: */
|
|
967 lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
|
|
968 lua_pushlightuserdata(L,(void*)module);
|
|
969 lua_rawset(L,LUA_REGISTRYINDEX);
|
|
970 }
|
|
971
|
|
972 /* -----------------------------------------------------------------------------
|
|
973 * global variable support code: modules
|
|
974 * ----------------------------------------------------------------------------- */
|
|
975
|
|
976 /* this function is called when trying to set an immutable.
|
|
977 default action is to print an error.
|
|
978 This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */
|
|
979 SWIGINTERN int SWIG_Lua_set_immutable(lua_State* L)
|
|
980 {
|
|
981 /* there should be 1 param passed in: the new value */
|
|
982 #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE
|
|
983 lua_pop(L,1); /* remove it */
|
|
984 luaL_error(L,"This variable is immutable");
|
|
985 #endif
|
|
986 return 0; /* should not return anything */
|
|
987 }
|
|
988
|
|
989 /* the module.get method used for getting linked data */
|
|
990 SWIGINTERN int SWIG_Lua_module_get(lua_State* L)
|
|
991 {
|
|
992 /* there should be 2 params passed in
|
|
993 (1) table (not the meta table)
|
|
994 (2) string name of the attribute
|
|
995 printf("SWIG_Lua_module_get %p(%s) '%s'\n",
|
|
996 lua_topointer(L,1),lua_typename(L,lua_type(L,1)),
|
|
997 lua_tostring(L,2));
|
|
998 */
|
|
999 /* get the metatable */
|
|
1000 #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
|
|
1001 assert(lua_isrotable(L,1)); /* just in case */
|
|
1002 #else
|
|
1003 assert(lua_istable(L,1)); /* default Lua action */
|
|
1004 #endif
|
|
1005 lua_getmetatable(L,1); /* get the metatable */
|
|
1006 #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
|
|
1007 assert(lua_isrotable(L,-1)); /* just in case */
|
|
1008 #else
|
|
1009 assert(lua_istable(L,-1));
|
|
1010 #endif
|
|
1011 SWIG_Lua_get_table(L,".get"); /* get the .get table */
|
|
1012 lua_remove(L,3); /* remove metatable */
|
|
1013 #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
|
|
1014 if (lua_isrotable(L,-1))
|
|
1015 #else
|
|
1016 if (lua_istable(L,-1))
|
|
1017 #endif
|
|
1018 {
|
|
1019 /* look for the key in the .get table */
|
|
1020 lua_pushvalue(L,2); /* key */
|
|
1021 lua_rawget(L,-2);
|
|
1022 lua_remove(L,3); /* remove .get */
|
|
1023 if (lua_iscfunction(L,-1))
|
|
1024 { /* found it so call the fn & return its value */
|
|
1025 lua_call(L,0,1);
|
|
1026 return 1;
|
|
1027 }
|
|
1028 lua_pop(L,1); /* remove the top */
|
|
1029 }
|
|
1030 lua_pop(L,1); /* remove the .get */
|
|
1031 lua_pushnil(L); /* return a nil */
|
|
1032 return 1;
|
|
1033 }
|
|
1034
|
|
1035 /* the module.set method used for setting linked data */
|
|
1036 SWIGINTERN int SWIG_Lua_module_set(lua_State* L)
|
|
1037 {
|
|
1038 /* there should be 3 params passed in
|
|
1039 (1) table (not the meta table)
|
|
1040 (2) string name of the attribute
|
|
1041 (3) any for the new value
|
|
1042 */
|
|
1043 /* get the metatable */
|
|
1044 #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
|
|
1045 assert(lua_isrotable(L,1)); /* just in case */
|
|
1046 #else
|
|
1047 assert(lua_istable(L,1)); /* default Lua action */
|
|
1048 #endif
|
|
1049 lua_getmetatable(L,1); /* get the metatable */
|
|
1050 #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
|
|
1051 assert(lua_isrotable(L,-1)); /* just in case */
|
|
1052 #else
|
|
1053 assert(lua_istable(L,-1));
|
|
1054 #endif
|
|
1055 SWIG_Lua_get_table(L,".set"); /* get the .set table */
|
|
1056 lua_remove(L,4); /* remove metatable */
|
|
1057 #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
|
|
1058 if (lua_isrotable(L,-1))
|
|
1059 #else
|
|
1060 if (lua_istable(L,-1))
|
|
1061 #endif
|
|
1062 {
|
|
1063 /* look for the key in the .set table */
|
|
1064 lua_pushvalue(L,2); /* key */
|
|
1065 lua_rawget(L,-2);
|
|
1066 lua_remove(L,4); /* remove .set */
|
|
1067 if (lua_iscfunction(L,-1))
|
|
1068 { /* found it so call the fn & return its value */
|
|
1069 lua_pushvalue(L,3); /* value */
|
|
1070 lua_call(L,1,0);
|
|
1071 return 0;
|
|
1072 }
|
|
1073 #if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA)
|
|
1074 else {
|
|
1075 return 0; // Exits stoically if an invalid key is initialized.
|
|
1076 }
|
|
1077 #endif
|
|
1078 }
|
|
1079 lua_settop(L,3); /* reset back to start */
|
|
1080 /* we now have the table, key & new value, so just set directly */
|
|
1081 lua_rawset(L,1); /* add direct */
|
|
1082 return 0;
|
|
1083 }
|
|
1084
|
|
1085 #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
|
|
1086 /* registering a module in lua. Pushes the module table on the stack. */
|
|
1087 SWIGINTERN void SWIG_Lua_module_begin(lua_State* L,const char* name)
|
|
1088 {
|
|
1089 assert(lua_istable(L,-1)); /* just in case */
|
|
1090 lua_pushstring(L,name);
|
|
1091 lua_newtable(L); /* the table */
|
|
1092 /* add meta table */
|
|
1093 lua_newtable(L); /* the meta table */
|
|
1094 SWIG_Lua_add_function(L,"__index",SWIG_Lua_module_get);
|
|
1095 SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_module_set);
|
|
1096 lua_pushstring(L,".get");
|
|
1097 lua_newtable(L); /* the .get table */
|
|
1098 lua_rawset(L,-3); /* add .get into metatable */
|
|
1099 lua_pushstring(L,".set");
|
|
1100 lua_newtable(L); /* the .set table */
|
|
1101 lua_rawset(L,-3); /* add .set into metatable */
|
|
1102 lua_setmetatable(L,-2); /* sets meta table in module */
|
|
1103 #ifdef SWIG_LUA_MODULE_GLOBAL
|
|
1104 /* If requested, install the module directly into the global namespace. */
|
|
1105 lua_rawset(L,-3); /* add module into parent */
|
|
1106 SWIG_Lua_get_table(L,name); /* get the table back out */
|
|
1107 #else
|
|
1108 /* Do not install the module table as global name. The stack top has
|
|
1109 the module table with the name below. We pop the top and replace
|
|
1110 the name with it. */
|
|
1111 lua_replace(L,-2);
|
|
1112 #endif
|
|
1113 }
|
|
1114
|
|
1115 /* ending the register */
|
|
1116 SWIGINTERN void SWIG_Lua_module_end(lua_State* L)
|
|
1117 {
|
|
1118 lua_pop(L,1); /* tidy stack (remove module) */
|
|
1119 }
|
|
1120
|
|
1121 /* adding a linked variable to the module */
|
|
1122 SWIGINTERN void SWIG_Lua_module_add_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn)
|
|
1123 {
|
|
1124 assert(lua_istable(L,-1)); /* just in case */
|
|
1125 lua_getmetatable(L,-1); /* get the metatable */
|
|
1126 assert(lua_istable(L,-1)); /* just in case */
|
|
1127 SWIG_Lua_get_table(L,".get"); /* find the .get table */
|
|
1128 assert(lua_istable(L,-1)); /* should be a table: */
|
|
1129 SWIG_Lua_add_function(L,name,getFn);
|
|
1130 lua_pop(L,1); /* tidy stack (remove table) */
|
|
1131 if (setFn) /* if there is a set fn */
|
|
1132 {
|
|
1133 SWIG_Lua_get_table(L,".set"); /* find the .set table */
|
|
1134 assert(lua_istable(L,-1)); /* should be a table: */
|
|
1135 SWIG_Lua_add_function(L,name,setFn);
|
|
1136 lua_pop(L,1); /* tidy stack (remove table) */
|
|
1137 }
|
|
1138 lua_pop(L,1); /* tidy stack (remove meta) */
|
|
1139 }
|
|
1140 #endif
|
|
1141
|
|
1142 /* adding a function module */
|
|
1143 SWIGINTERN void SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_CFunction fn)
|
|
1144 {
|
|
1145 SWIG_Lua_add_function(L,name,fn);
|
|
1146 }
|
|
1147
|
|
1148 /* -----------------------------------------------------------------------------
|
|
1149 * global variable support code: namespaces
|
|
1150 * ----------------------------------------------------------------------------- */
|
|
1151
|
|
1152 SWIGINTERN int SWIG_Lua_namespace_get(lua_State* L)
|
|
1153 {
|
|
1154 /* there should be 2 params passed in
|
|
1155 (1) table (not the meta table)
|
|
1156 (2) string name of the attribute
|
|
1157 */
|
|
1158 assert(lua_istable(L,-2)); /* just in case */
|
|
1159 lua_getmetatable(L,-2);
|
|
1160 assert(lua_istable(L,-1));
|
|
1161 SWIG_Lua_get_table(L,".get"); /* find the .get table */
|
|
1162 assert(lua_istable(L,-1));
|
|
1163 /* look for the key in the .get table */
|
|
1164 lua_pushvalue(L,2); /* key */
|
|
1165 lua_rawget(L,-2);
|
|
1166 lua_remove(L,-2); /* stack tidy, remove .get table */
|
|
1167 if (lua_iscfunction(L,-1))
|
|
1168 { /* found it so call the fn & return its value */
|
|
1169 lua_call(L,0,1); /* 1 value in (userdata),1 out (result) */
|
|
1170 lua_remove(L,-2); /* stack tidy, remove metatable */
|
|
1171 return 1;
|
|
1172 }
|
|
1173 lua_pop(L,1); /* remove whatever was there */
|
|
1174 /* ok, so try the .fn table */
|
|
1175 SWIG_Lua_get_table(L,".fn"); /* find the .get table */
|
|
1176 assert(lua_istable(L,-1)); /* just in case */
|
|
1177 lua_pushvalue(L,2); /* key */
|
|
1178 lua_rawget(L,-2); /* look for the fn */
|
|
1179 lua_remove(L,-2); /* stack tidy, remove .fn table */
|
|
1180 if (lua_isfunction(L,-1)) /* note: whether it's a C function or lua function */
|
|
1181 { /* found it so return the fn & let lua call it */
|
|
1182 lua_remove(L,-2); /* stack tidy, remove metatable */
|
|
1183 return 1;
|
|
1184 }
|
|
1185 lua_pop(L,1); /* remove whatever was there */
|
|
1186 return 0;
|
|
1187 }
|
|
1188
|
|
1189 SWIGINTERN int SWIG_Lua_namespace_set(lua_State* L)
|
|
1190 {
|
|
1191 /* there should be 3 params passed in
|
|
1192 (1) table (not the meta table)
|
|
1193 (2) string name of the attribute
|
|
1194 (3) any for the new value
|
|
1195 */
|
|
1196
|
|
1197 assert(lua_istable(L,1));
|
|
1198 lua_getmetatable(L,1); /* get the meta table */
|
|
1199 assert(lua_istable(L,-1));
|
|
1200
|
|
1201 SWIG_Lua_get_table(L,".set"); /* find the .set table */
|
|
1202 if (lua_istable(L,-1))
|
|
1203 {
|
|
1204 /* look for the key in the .set table */
|
|
1205 lua_pushvalue(L,2); /* key */
|
|
1206 lua_rawget(L,-2);
|
|
1207 if (lua_iscfunction(L,-1))
|
|
1208 { /* found it so call the fn & return its value */
|
|
1209 lua_pushvalue(L,3); /* value */
|
|
1210 lua_call(L,1,0);
|
|
1211 return 0;
|
|
1212 }
|
|
1213 lua_pop(L,1); /* remove the value */
|
|
1214 }
|
|
1215 lua_pop(L,1); /* remove the value .set table */
|
|
1216 return 0;
|
|
1217 }
|
|
1218
|
|
1219 SWIGINTERN void SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]); // forward declaration
|
|
1220 SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn); // forward declaration
|
|
1221
|
|
1222 /* helper function - register namespace methods and attributes into namespace */
|
|
1223 SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State* L, swig_lua_namespace* ns)
|
|
1224 {
|
|
1225 int i = 0;
|
|
1226 assert(lua_istable(L,-1));
|
|
1227 /* There must be table at the top of the stack */
|
|
1228 SWIG_Lua_InstallConstants(L, ns->ns_constants);
|
|
1229
|
|
1230 lua_getmetatable(L,-1);
|
|
1231
|
|
1232 /* add fns */
|
|
1233 for(i=0;ns->ns_attributes[i].name;i++){
|
|
1234 SWIG_Lua_add_class_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_attributes[i].setmethod);
|
|
1235 }
|
|
1236
|
|
1237 /* add methods to the metatable */
|
|
1238 SWIG_Lua_get_table(L,".fn"); /* find the .fn table */
|
|
1239 assert(lua_istable(L,-1)); /* just in case */
|
|
1240 for(i=0;ns->ns_methods[i].name;i++){
|
|
1241 SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].method);
|
|
1242 }
|
|
1243 lua_pop(L,1);
|
|
1244
|
|
1245 /* clear stack - remove metatble */
|
|
1246 lua_pop(L,1);
|
|
1247
|
|
1248 }
|
|
1249
|
|
1250 /* helper function. creates namespace table and add it to module table */
|
|
1251 SWIGINTERN int SWIG_Lua_namespace_register(lua_State* L, swig_lua_namespace* ns)
|
|
1252 {
|
|
1253 assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table */
|
|
1254 lua_checkstack(L,5);
|
|
1255 lua_pushstring(L, ns->name);
|
|
1256 lua_newtable(L); /* namespace itself */
|
|
1257 lua_newtable(L); /* metatable for namespace */
|
|
1258
|
|
1259 /* add a table called ".get" */
|
|
1260 lua_pushstring(L,".get");
|
|
1261 lua_newtable(L);
|
|
1262 lua_rawset(L,-3);
|
|
1263 /* add a table called ".set" */
|
|
1264 lua_pushstring(L,".set");
|
|
1265 lua_newtable(L);
|
|
1266 lua_rawset(L,-3);
|
|
1267 /* add a table called ".fn" */
|
|
1268 lua_pushstring(L,".fn");
|
|
1269 lua_newtable(L);
|
|
1270 lua_rawset(L,-3);
|
|
1271
|
|
1272 /* add accessor fns for using the .get,.set&.fn */
|
|
1273 SWIG_Lua_add_function(L,"__index",SWIG_Lua_namespace_get);
|
|
1274 SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_namespace_set);
|
|
1275
|
|
1276 lua_setmetatable(L,-2); /* set metatable */
|
|
1277 lua_rawset(L,-3); /* add namespace to module table */
|
|
1278 }
|
|
1279 /* -----------------------------------------------------------------------------
|
|
1280 * global variable support code: classes
|
|
1281 * ----------------------------------------------------------------------------- */
|
|
1282
|
|
1283 /* the class.get method, performs the lookup of class attributes */
|
|
1284 SWIGINTERN int SWIG_Lua_class_get(lua_State* L)
|
|
1285 {
|
|
1286 /* there should be 2 params passed in
|
|
1287 (1) userdata (not the meta table)
|
|
1288 (2) string name of the attribute
|
|
1289 */
|
|
1290 assert(lua_isuserdata(L,-2)); /* just in case */
|
|
1291 lua_getmetatable(L,-2); /* get the meta table */
|
|
1292 assert(lua_istable(L,-1)); /* just in case */
|
|
1293 SWIG_Lua_get_table(L,".get"); /* find the .get table */
|
|
1294 assert(lua_istable(L,-1)); /* just in case */
|
|
1295 /* look for the key in the .get table */
|
|
1296 lua_pushvalue(L,2); /* key */
|
|
1297 lua_rawget(L,-2);
|
|
1298 lua_remove(L,-2); /* stack tidy, remove .get table */
|
|
1299 if (lua_iscfunction(L,-1))
|
|
1300 { /* found it so call the fn & return its value */
|
|
1301 lua_pushvalue(L,1); /* the userdata */
|
|
1302 lua_call(L,1,1); /* 1 value in (userdata),1 out (result) */
|
|
1303 lua_remove(L,-2); /* stack tidy, remove metatable */
|
|
1304 return 1;
|
|
1305 }
|
|
1306 lua_pop(L,1); /* remove whatever was there */
|
|
1307 /* ok, so try the .fn table */
|
|
1308 SWIG_Lua_get_table(L,".fn"); /* find the .get table */
|
|
1309 assert(lua_istable(L,-1)); /* just in case */
|
|
1310 lua_pushvalue(L,2); /* key */
|
|
1311 lua_rawget(L,-2); /* look for the fn */
|
|
1312 lua_remove(L,-2); /* stack tidy, remove .fn table */
|
|
1313 if (lua_isfunction(L,-1)) /* note: if its a C function or lua function */
|
|
1314 { /* found it so return the fn & let lua call it */
|
|
1315 lua_remove(L,-2); /* stack tidy, remove metatable */
|
|
1316 return 1;
|
|
1317 }
|
|
1318 lua_pop(L,1); /* remove whatever was there */
|
|
1319 /* NEW: looks for the __getitem() fn
|
|
1320 this is a user provided get fn */
|
|
1321 SWIG_Lua_get_table(L,"__getitem"); /* find the __getitem fn */
|
|
1322 if (lua_iscfunction(L,-1)) /* if its there */
|
|
1323 { /* found it so call the fn & return its value */
|
|
1324 lua_pushvalue(L,1); /* the userdata */
|
|
1325 lua_pushvalue(L,2); /* the parameter */
|
|
1326 lua_call(L,2,1); /* 2 value in (userdata),1 out (result) */
|
|
1327 lua_remove(L,-2); /* stack tidy, remove metatable */
|
|
1328 return 1;
|
|
1329 }
|
|
1330 return 0; /* sorry not known */
|
|
1331 }
|
|
1332
|
|
1333 /* the class.set method, performs the lookup of class attributes */
|
|
1334 SWIGINTERN int SWIG_Lua_class_set(lua_State* L)
|
|
1335 {
|
|
1336 /* there should be 3 params passed in
|
|
1337 (1) table (not the meta table)
|
|
1338 (2) string name of the attribute
|
|
1339 (3) any for the new value
|
|
1340 printf("SWIG_Lua_class_set %p(%s) '%s' %p(%s)\n",
|
|
1341 lua_topointer(L,1),lua_typename(L,lua_type(L,1)),
|
|
1342 lua_tostring(L,2),
|
|
1343 lua_topointer(L,3),lua_typename(L,lua_type(L,3)));*/
|
|
1344
|
|
1345 assert(lua_isuserdata(L,1)); /* just in case */
|
|
1346 lua_getmetatable(L,1); /* get the meta table */
|
|
1347 assert(lua_istable(L,-1)); /* just in case */
|
|
1348
|
|
1349 SWIG_Lua_get_table(L,".set"); /* find the .set table */
|
|
1350 if (lua_istable(L,-1))
|
|
1351 {
|
|
1352 /* look for the key in the .set table */
|
|
1353 lua_pushvalue(L,2); /* key */
|
|
1354 lua_rawget(L,-2);
|
|
1355 if (lua_iscfunction(L,-1))
|
|
1356 { /* found it so call the fn & return its value */
|
|
1357 lua_pushvalue(L,1); /* userdata */
|
|
1358 lua_pushvalue(L,3); /* value */
|
|
1359 lua_call(L,2,0);
|
|
1360 return 0;
|
|
1361 }
|
|
1362 lua_pop(L,1); /* remove the value */
|
|
1363 }
|
|
1364 lua_pop(L,1); /* remove the value .set table */
|
|
1365 /* NEW: looks for the __setitem() fn
|
|
1366 this is a user provided set fn */
|
|
1367 SWIG_Lua_get_table(L,"__setitem"); /* find the fn */
|
|
1368 if (lua_iscfunction(L,-1)) /* if its there */
|
|
1369 { /* found it so call the fn & return its value */
|
|
1370 lua_pushvalue(L,1); /* the userdata */
|
|
1371 lua_pushvalue(L,2); /* the parameter */
|
|
1372 lua_pushvalue(L,3); /* the value */
|
|
1373 lua_call(L,3,0); /* 3 values in ,0 out */
|
|
1374 lua_remove(L,-2); /* stack tidy, remove metatable */
|
|
1375 return 1;
|
|
1376 }
|
|
1377 return 0;
|
|
1378 }
|
|
1379
|
|
1380 /* the class.destruct method called by the interpreter */
|
|
1381 SWIGINTERN int SWIG_Lua_class_destruct(lua_State* L)
|
|
1382 {
|
|
1383 /* there should be 1 params passed in
|
|
1384 (1) userdata (not the meta table) */
|
|
1385 swig_lua_userdata* usr;
|
|
1386 swig_lua_class* clss;
|
|
1387 assert(lua_isuserdata(L,-1)); /* just in case */
|
|
1388 usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */
|
|
1389 /* if must be destroyed & has a destructor */
|
|
1390 if (usr->own) /* if must be destroyed */
|
|
1391 {
|
|
1392 clss=(swig_lua_class*)usr->type->clientdata; /* get the class */
|
|
1393 if (clss && clss->destructor) /* there is a destroy fn */
|
|
1394 {
|
|
1395 clss->destructor(usr->ptr); /* bye bye */
|
|
1396 }
|
|
1397 }
|
|
1398 return 0;
|
|
1399 }
|
|
1400
|
|
1401 /* the class.__tostring method called by the interpreter and print */
|
|
1402 SWIGINTERN int SWIG_Lua_class_tostring(lua_State* L)
|
|
1403 {
|
|
1404 /* there should be 1 param passed in
|
|
1405 (1) userdata (not the metatable) */
|
|
1406 assert(lua_isuserdata(L,1)); /* just in case */
|
|
1407 unsigned long userData = (unsigned long)lua_touserdata(L,1); /* get the userdata address for later */
|
|
1408 lua_getmetatable(L,1); /* get the meta table */
|
|
1409 assert(lua_istable(L,-1)); /* just in case */
|
|
1410
|
|
1411 lua_getfield(L, -1, ".type");
|
|
1412 const char* className = lua_tostring(L, -1);
|
|
1413
|
|
1414 char output[256];
|
|
1415 sprintf(output, "<%s userdata: %lX>", className, userData);
|
|
1416
|
|
1417 lua_pushstring(L, (const char*)output);
|
|
1418 return 1;
|
|
1419 }
|
|
1420
|
|
1421 /* to manually disown some userdata */
|
|
1422 SWIGINTERN int SWIG_Lua_class_disown(lua_State* L)
|
|
1423 {
|
|
1424 /* there should be 1 params passed in
|
|
1425 (1) userdata (not the meta table) */
|
|
1426 swig_lua_userdata* usr;
|
|
1427 assert(lua_isuserdata(L,-1)); /* just in case */
|
|
1428 usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */
|
|
1429
|
|
1430 usr->own = 0; /* clear our ownership */
|
|
1431 return 0;
|
|
1432 }
|
|
1433
|
|
1434 /* Constructor proxy. Used when class name entry in module is not class constructor,
|
|
1435 but special table instead. */
|
|
1436 SWIGINTERN int SWIG_Lua_constructor_proxy(lua_State* L)
|
|
1437 {
|
|
1438 /* unlimited number of parameters
|
|
1439 First one is our proxy table and we should remove it
|
|
1440 Other we should pass to real constructor
|
|
1441 */
|
|
1442 assert(lua_istable(L,1));
|
|
1443 lua_pushstring(L,".constructor");
|
|
1444 lua_rawget(L,1);
|
|
1445 assert(!lua_isnil(L,-1));
|
|
1446 lua_replace(L,1); /* replace our table with real constructor */
|
|
1447 lua_call(L,lua_gettop(L)-1,1);
|
|
1448 return 1;
|
|
1449 }
|
|
1450
|
|
1451 /* gets the swig class registry (or creates it) */
|
|
1452 SWIGINTERN void SWIG_Lua_get_class_registry(lua_State* L)
|
|
1453 {
|
|
1454 /* add this all into the swig registry: */
|
|
1455 lua_pushstring(L,"SWIG");
|
|
1456 lua_rawget(L,LUA_REGISTRYINDEX); /* get the registry */
|
|
1457 if (!lua_istable(L,-1)) /* not there */
|
|
1458 { /* must be first time, so add it */
|
|
1459 lua_pop(L,1); /* remove the result */
|
|
1460 lua_pushstring(L,"SWIG");
|
|
1461 lua_newtable(L);
|
|
1462 lua_rawset(L,LUA_REGISTRYINDEX);
|
|
1463 /* then get it */
|
|
1464 lua_pushstring(L,"SWIG");
|
|
1465 lua_rawget(L,LUA_REGISTRYINDEX);
|
|
1466 }
|
|
1467 }
|
|
1468
|
|
1469 /* helper fn to get the classes metatable from the register */
|
|
1470 SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State* L,const char* cname)
|
|
1471 {
|
|
1472 SWIG_Lua_get_class_registry(L); /* get the registry */
|
|
1473 lua_pushstring(L,cname); /* get the name */
|
|
1474 lua_rawget(L,-2); /* get it */
|
|
1475 lua_remove(L,-2); /* tidy up (remove registry) */
|
|
1476 }
|
|
1477
|
|
1478 /* helper add a variable to a registered class */
|
|
1479 SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn)
|
|
1480 {
|
|
1481 assert(lua_istable(L,-1)); /* just in case */
|
|
1482 SWIG_Lua_get_table(L,".get"); /* find the .get table */
|
|
1483 assert(lua_istable(L,-1)); /* just in case */
|
|
1484 SWIG_Lua_add_function(L,name,getFn);
|
|
1485 lua_pop(L,1); /* tidy stack (remove table) */
|
|
1486 if (setFn)
|
|
1487 {
|
|
1488 SWIG_Lua_get_table(L,".set"); /* find the .set table */
|
|
1489 assert(lua_istable(L,-1)); /* just in case */
|
|
1490 SWIG_Lua_add_function(L,name,setFn);
|
|
1491 lua_pop(L,1); /* tidy stack (remove table) */
|
|
1492 }
|
|
1493 }
|
|
1494
|
|
1495 /* helper to recursively add class static details (static attributes, operations and constants) */
|
|
1496 SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State* L, swig_lua_class* clss)
|
|
1497 {
|
|
1498 int i = 0;
|
|
1499 /* The class namespace table must be on the top of the stack */
|
|
1500 assert(lua_istable(L,-1));
|
|
1501 /* call all the base classes first: we can then override these later: */
|
|
1502 for(i=0;clss->bases[i];i++)
|
|
1503 {
|
|
1504 SWIG_Lua_add_class_static_details(L,clss->bases[i]);
|
|
1505 }
|
|
1506
|
|
1507 SWIG_Lua_add_namespace_details(L, &clss->cls_static);
|
|
1508 }
|
|
1509
|
|
1510 /* helper to recursively add class details (attributes & operations) */
|
|
1511 SWIGINTERN void SWIG_Lua_add_class_details(lua_State* L,swig_lua_class* clss)
|
|
1512 {
|
|
1513 int i;
|
|
1514 /* call all the base classes first: we can then override these later: */
|
|
1515 for(i=0;clss->bases[i];i++)
|
|
1516 {
|
|
1517 SWIG_Lua_add_class_details(L,clss->bases[i]);
|
|
1518 }
|
|
1519 /* add fns */
|
|
1520 for(i=0;clss->attributes[i].name;i++){
|
|
1521 SWIG_Lua_add_class_variable(L,clss->attributes[i].name,clss->attributes[i].getmethod,clss->attributes[i].setmethod);
|
|
1522 }
|
|
1523 /* add methods to the metatable */
|
|
1524 SWIG_Lua_get_table(L,".fn"); /* find the .fn table */
|
|
1525 assert(lua_istable(L,-1)); /* just in case */
|
|
1526 for(i=0;clss->methods[i].name;i++){
|
|
1527 SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].method);
|
|
1528 }
|
|
1529 lua_pop(L,1); /* tidy stack (remove table) */
|
|
1530 /* add operator overloads
|
|
1531 these look ANY method which start with "__" and assume they
|
|
1532 are operator overloads & add them to the metatable
|
|
1533 (this might mess up is someone defines a method __gc (the destructor)*/
|
|
1534 for(i=0;clss->methods[i].name;i++){
|
|
1535 if (clss->methods[i].name[0]=='_' && clss->methods[i].name[1]=='_'){
|
|
1536 SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].method);
|
|
1537 }
|
|
1538 }
|
|
1539 }
|
|
1540
|
|
1541 /* set up the base classes pointers.
|
|
1542 Each class structure has a list of pointers to the base class structures.
|
|
1543 This function fills them.
|
|
1544 It cannot be done at compile time, as this will not work with hireachies
|
|
1545 spread over more than one swig file.
|
|
1546 Therefore it must be done at runtime, querying the SWIG type system.
|
|
1547 */
|
|
1548 SWIGINTERN void SWIG_Lua_init_base_class(lua_State* L,swig_lua_class* clss)
|
|
1549 {
|
|
1550 int i=0;
|
|
1551 swig_module_info* module=SWIG_GetModule(L);
|
|
1552 for(i=0;clss->base_names[i];i++)
|
|
1553 {
|
|
1554 if (clss->bases[i]==0) /* not found yet */
|
|
1555 {
|
|
1556 /* lookup and cache the base class */
|
|
1557 swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]);
|
|
1558 if (info) clss->bases[i] = (swig_lua_class *) info->clientdata;
|
|
1559 }
|
|
1560 }
|
|
1561 }
|
|
1562
|
|
1563 /* Register class static methods,attributes etc as well as constructor proxy */
|
|
1564 SWIGINTERN void SWIG_Lua_class_register_static(lua_State* L, swig_lua_class* clss)
|
|
1565 {
|
|
1566 lua_checkstack(L,5); /* just in case */
|
|
1567 assert(lua_istable(L,-1)); /* just in case */
|
|
1568 assert(strcmp(clss->name, clss->cls_static.name) == 0); /* in class those 2 must be equal */
|
|
1569
|
|
1570 SWIG_Lua_namespace_register(L,&clss->cls_static);
|
|
1571
|
|
1572 SWIG_Lua_get_table(L,clss->name); // Get namespace table back
|
|
1573 assert(lua_istable(L,-1)); /* just in case */
|
|
1574
|
|
1575 /* add its constructor to module with the name of the class
|
|
1576 so you can do MyClass(...) as well as new_MyClass(...)
|
|
1577 BUT only if a constructor is defined
|
|
1578 (this overcomes the problem of pure virtual classes without constructors)*/
|
|
1579 if (clss->constructor)
|
|
1580 {
|
|
1581 SWIG_Lua_add_function(L,".constructor", clss->constructor);
|
|
1582 lua_getmetatable(L,-1);
|
|
1583 assert(lua_istable(L,-1)); /* just in case */
|
|
1584 SWIG_Lua_add_function(L,"__call", SWIG_Lua_constructor_proxy);
|
|
1585 lua_pop(L,1);
|
|
1586 }
|
|
1587
|
|
1588 assert(lua_istable(L,-1)); /* just in case */
|
|
1589 SWIG_Lua_add_class_static_details(L, clss);
|
|
1590
|
|
1591 /* clear stack */
|
|
1592 lua_pop(L,1);
|
|
1593 }
|
|
1594
|
|
1595 /* performs the entire class registration process */
|
|
1596 SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss)
|
|
1597 {
|
|
1598 SWIG_Lua_class_register_static(L,clss);
|
|
1599
|
|
1600 SWIG_Lua_get_class_registry(L); /* get the registry */
|
|
1601 lua_pushstring(L,clss->name); /* get the name */
|
|
1602 lua_newtable(L); /* create the metatable */
|
|
1603 /* add string of class name called ".type" */
|
|
1604 lua_pushstring(L,".type");
|
|
1605 lua_pushstring(L,clss->name);
|
|
1606 lua_rawset(L,-3);
|
|
1607 /* add a table called ".get" */
|
|
1608 lua_pushstring(L,".get");
|
|
1609 lua_newtable(L);
|
|
1610 lua_rawset(L,-3);
|
|
1611 /* add a table called ".set" */
|
|
1612 lua_pushstring(L,".set");
|
|
1613 lua_newtable(L);
|
|
1614 lua_rawset(L,-3);
|
|
1615 /* add a table called ".fn" */
|
|
1616 lua_pushstring(L,".fn");
|
|
1617 lua_newtable(L);
|
|
1618 /* add manual disown method */
|
|
1619 SWIG_Lua_add_function(L,"__disown",SWIG_Lua_class_disown);
|
|
1620 lua_rawset(L,-3);
|
|
1621 /* add accessor fns for using the .get,.set&.fn */
|
|
1622 SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get);
|
|
1623 SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set);
|
|
1624 SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct);
|
|
1625 /* add tostring method for better output */
|
|
1626 SWIG_Lua_add_function(L,"__tostring",SWIG_Lua_class_tostring);
|
|
1627 /* add it */
|
|
1628 lua_rawset(L,-3); /* metatable into registry */
|
|
1629 lua_pop(L,1); /* tidy stack (remove registry) */
|
|
1630
|
|
1631 SWIG_Lua_get_class_metatable(L,clss->name);
|
|
1632 SWIG_Lua_add_class_details(L,clss); /* recursive adding of details (atts & ops) */
|
|
1633 lua_pop(L,1); /* tidy stack (remove class metatable) */
|
|
1634 }
|
|
1635
|
|
1636 /* -----------------------------------------------------------------------------
|
|
1637 * Class/structure conversion fns
|
|
1638 * ----------------------------------------------------------------------------- */
|
|
1639
|
|
1640 /* helper to add metatable to new lua object */
|
|
1641 SWIGINTERN void _SWIG_Lua_AddMetatable(lua_State* L,swig_type_info *type)
|
|
1642 {
|
|
1643 if (type->clientdata) /* there is clientdata: so add the metatable */
|
|
1644 {
|
|
1645 SWIG_Lua_get_class_metatable(L,((swig_lua_class*)(type->clientdata))->name);
|
|
1646 if (lua_istable(L,-1))
|
|
1647 {
|
|
1648 lua_setmetatable(L,-2);
|
|
1649 }
|
|
1650 else
|
|
1651 {
|
|
1652 lua_pop(L,1);
|
|
1653 }
|
|
1654 }
|
|
1655 }
|
|
1656
|
|
1657 /* pushes a new object into the lua stack */
|
|
1658 SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State* L,void* ptr,swig_type_info *type, int own)
|
|
1659 {
|
|
1660 swig_lua_userdata* usr;
|
|
1661 if (!ptr){
|
|
1662 lua_pushnil(L);
|
|
1663 return;
|
|
1664 }
|
|
1665 usr=(swig_lua_userdata*)lua_newuserdata(L,sizeof(swig_lua_userdata)); /* get data */
|
|
1666 usr->ptr=ptr; /* set the ptr */
|
|
1667 usr->type=type;
|
|
1668 usr->own=own;
|
|
1669 #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
|
|
1670 _SWIG_Lua_AddMetatable(L,type); /* add metatable */
|
|
1671 #endif
|
|
1672 }
|
|
1673
|
|
1674 /* takes a object from the lua stack & converts it into an object of the correct type
|
|
1675 (if possible) */
|
|
1676 SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags)
|
|
1677 {
|
|
1678 swig_lua_userdata* usr;
|
|
1679 swig_cast_info *cast;
|
|
1680 if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;} /* special case: lua nil => NULL pointer */
|
|
1681 usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */
|
|
1682 if (usr)
|
|
1683 {
|
|
1684 if (flags & SWIG_POINTER_DISOWN) /* must disown the object */
|
|
1685 {
|
|
1686 usr->own=0;
|
|
1687 }
|
|
1688 if (!type) /* special cast void*, no casting fn */
|
|
1689 {
|
|
1690 *ptr=usr->ptr;
|
|
1691 return SWIG_OK; /* ok */
|
|
1692 }
|
|
1693 cast=SWIG_TypeCheckStruct(usr->type,type); /* performs normal type checking */
|
|
1694 if (cast)
|
|
1695 {
|
|
1696 int newmemory = 0;
|
|
1697 *ptr=SWIG_TypeCast(cast,usr->ptr,&newmemory);
|
|
1698 assert(!newmemory); /* newmemory handling not yet implemented */
|
|
1699 return SWIG_OK; /* ok */
|
|
1700 }
|
|
1701 }
|
|
1702 return SWIG_ERROR; /* error */
|
|
1703 }
|
|
1704
|
|
1705 SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State* L,int index,swig_type_info *type,int flags,
|
|
1706 int argnum,const char* func_name){
|
|
1707 void* result;
|
|
1708 if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){
|
|
1709 luaL_error (L,"Error in %s, expected a %s at argument number %d\n",
|
|
1710 func_name,(type && type->str)?type->str:"void*",argnum);
|
|
1711 }
|
|
1712 return result;
|
|
1713 }
|
|
1714
|
|
1715 /* pushes a packed userdata. user for member fn pointers only */
|
|
1716 SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State* L,void* ptr,size_t size,swig_type_info *type)
|
|
1717 {
|
|
1718 swig_lua_rawdata* raw;
|
|
1719 assert(ptr); /* not acceptable to pass in a NULL value */
|
|
1720 raw=(swig_lua_rawdata*)lua_newuserdata(L,sizeof(swig_lua_rawdata)-1+size); /* alloc data */
|
|
1721 raw->type=type;
|
|
1722 raw->own=0;
|
|
1723 memcpy(raw->data,ptr,size); /* copy the data */
|
|
1724 _SWIG_Lua_AddMetatable(L,type); /* add metatable */
|
|
1725 }
|
|
1726
|
|
1727 /* converts a packed userdata. user for member fn pointers only */
|
|
1728 SWIGRUNTIME int SWIG_Lua_ConvertPacked(lua_State* L,int index,void* ptr,size_t size,swig_type_info *type)
|
|
1729 {
|
|
1730 swig_lua_rawdata* raw;
|
|
1731 raw=(swig_lua_rawdata*)lua_touserdata(L,index); /* get data */
|
|
1732 if (!raw) return SWIG_ERROR; /* error */
|
|
1733 if (type==0 || type==raw->type) /* void* or identical type */
|
|
1734 {
|
|
1735 memcpy(ptr,raw->data,size); /* copy it */
|
|
1736 return SWIG_OK; /* ok */
|
|
1737 }
|
|
1738 return SWIG_ERROR; /* error */
|
|
1739 }
|
|
1740
|
|
1741 /* a function to get the typestring of a piece of data */
|
|
1742 SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp)
|
|
1743 {
|
|
1744 swig_lua_userdata* usr;
|
|
1745 if (lua_isuserdata(L,tp))
|
|
1746 {
|
|
1747 usr=(swig_lua_userdata*)lua_touserdata(L,tp); /* get data */
|
|
1748 if (usr && usr->type && usr->type->str)
|
|
1749 return usr->type->str;
|
|
1750 return "userdata (unknown type)";
|
|
1751 }
|
|
1752 return lua_typename(L,lua_type(L,tp));
|
|
1753 }
|
|
1754
|
|
1755 /* lua callable function to get the userdata's type */
|
|
1756 SWIGRUNTIME int SWIG_Lua_type(lua_State* L)
|
|
1757 {
|
|
1758 lua_pushstring(L,SWIG_Lua_typename(L,1));
|
|
1759 return 1;
|
|
1760 }
|
|
1761
|
|
1762 /* lua callable function to compare userdata's value
|
|
1763 the issue is that two userdata may point to the same thing
|
|
1764 but to lua, they are different objects */
|
|
1765 SWIGRUNTIME int SWIG_Lua_equal(lua_State* L)
|
|
1766 {
|
|
1767 int result;
|
|
1768 swig_lua_userdata *usr1,*usr2;
|
|
1769 if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2)) /* just in case */
|
|
1770 return 0; /* nil reply */
|
|
1771 usr1=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */
|
|
1772 usr2=(swig_lua_userdata*)lua_touserdata(L,2); /* get data */
|
|
1773 /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/
|
|
1774 result=(usr1->ptr==usr2->ptr);
|
|
1775 lua_pushboolean(L,result);
|
|
1776 return 1;
|
|
1777 }
|
|
1778
|
|
1779 /* -----------------------------------------------------------------------------
|
|
1780 * global variable support code: class/struct typemap functions
|
|
1781 * ----------------------------------------------------------------------------- */
|
|
1782
|
|
1783 #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
|
|
1784 /* Install Constants */
|
|
1785 SWIGINTERN void
|
|
1786 SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]) {
|
|
1787 int i;
|
|
1788 for (i = 0; constants[i].type; i++) {
|
|
1789 switch(constants[i].type) {
|
|
1790 case SWIG_LUA_INT:
|
|
1791 lua_pushstring(L,constants[i].name);
|
|
1792 lua_pushnumber(L,(lua_Number)constants[i].lvalue);
|
|
1793 lua_rawset(L,-3);
|
|
1794 break;
|
|
1795 case SWIG_LUA_FLOAT:
|
|
1796 lua_pushstring(L,constants[i].name);
|
|
1797 lua_pushnumber(L,(lua_Number)constants[i].dvalue);
|
|
1798 lua_rawset(L,-3);
|
|
1799 break;
|
|
1800 case SWIG_LUA_CHAR:
|
|
1801 lua_pushstring(L,constants[i].name);
|
|
1802 lua_pushfstring(L,"%c",(char)constants[i].lvalue);
|
|
1803 lua_rawset(L,-3);
|
|
1804 break;
|
|
1805 case SWIG_LUA_STRING:
|
|
1806 lua_pushstring(L,constants[i].name);
|
|
1807 lua_pushstring(L,(char *) constants[i].pvalue);
|
|
1808 lua_rawset(L,-3);
|
|
1809 break;
|
|
1810 case SWIG_LUA_POINTER:
|
|
1811 lua_pushstring(L,constants[i].name);
|
|
1812 SWIG_NewPointerObj(L,constants[i].pvalue, *(constants[i]).ptype,0);
|
|
1813 lua_rawset(L,-3);
|
|
1814 break;
|
|
1815 case SWIG_LUA_BINARY:
|
|
1816 lua_pushstring(L,constants[i].name);
|
|
1817 SWIG_NewMemberObj(L,constants[i].pvalue,constants[i].lvalue,*(constants[i]).ptype);
|
|
1818 lua_rawset(L,-3);
|
|
1819 break;
|
|
1820 default:
|
|
1821 break;
|
|
1822 }
|
|
1823 }
|
|
1824 }
|
|
1825 #endif
|
|
1826
|
|
1827 /* -----------------------------------------------------------------------------
|
|
1828 * executing lua code from within the wrapper
|
|
1829 * ----------------------------------------------------------------------------- */
|
|
1830
|
|
1831 #ifndef SWIG_DOSTRING_FAIL /* Allows redefining of error function */
|
|
1832 #define SWIG_DOSTRING_FAIL(S) fprintf(stderr,"%s\n",S)
|
|
1833 #endif
|
|
1834 /* Executes a C string in Lua which is a really simple way of calling lua from C
|
|
1835 Unfortunately lua keeps changing its APIs, so we need a conditional compile
|
|
1836 In lua 5.0.X its lua_dostring()
|
|
1837 In lua 5.1.X its luaL_dostring()
|
|
1838 */
|
|
1839 SWIGINTERN int
|
|
1840 SWIG_Lua_dostring(lua_State *L, const char* str) {
|
|
1841 int ok,top;
|
|
1842 if (str==0 || str[0]==0) return 0; /* nothing to do */
|
|
1843 top=lua_gettop(L); /* save stack */
|
|
1844 #if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501))
|
|
1845 ok=luaL_dostring(L,str); /* looks like this is lua 5.1.X or later, good */
|
|
1846 #else
|
|
1847 ok=lua_dostring(L,str); /* might be lua 5.0.x, using lua_dostring */
|
|
1848 #endif
|
|
1849 if (ok!=0) {
|
|
1850 SWIG_DOSTRING_FAIL(lua_tostring(L,-1));
|
|
1851 }
|
|
1852 lua_settop(L,top); /* restore the stack */
|
|
1853 return ok;
|
|
1854 }
|
|
1855
|
|
1856 #ifdef __cplusplus
|
|
1857 }
|
|
1858 #endif
|
|
1859
|
|
1860 /* ------------------------------ end luarun.swg ------------------------------ */
|
|
1861
|
|
1862
|
|
1863 /* -------- TYPES TABLE (BEGIN) -------- */
|
|
1864
|
|
1865 static swig_type_info *swig_types[1];
|
|
1866 static swig_module_info swig_module = {swig_types, 0, 0, 0, 0, 0};
|
|
1867 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
|
|
1868 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
|
|
1869
|
|
1870 /* -------- TYPES TABLE (END) -------- */
|
|
1871
|
|
1872 #define SWIG_name "example"
|
|
1873 #define SWIG_init luaopen_example
|
|
1874 #define SWIG_init_user luaopen_example_user
|
|
1875
|
|
1876 #define SWIG_LUACODE luaopen_example_luacode
|
|
1877
|
|
1878 namespace swig {
|
|
1879 typedef struct{} LANGUAGE_OBJ;
|
|
1880 }
|
|
1881
|
|
1882
|
|
1883 #include "example.h"
|
|
1884
|
|
1885 #ifdef __cplusplus
|
|
1886 extern "C" {
|
|
1887 #endif
|
|
1888 static int _wrap_gcd(lua_State* L) {
|
|
1889 int SWIG_arg = 0;
|
|
1890 int arg1 ;
|
|
1891 int arg2 ;
|
|
1892 int result;
|
|
1893
|
|
1894 SWIG_check_num_args("gcd",2,2)
|
|
1895 if(!lua_isnumber(L,1)) SWIG_fail_arg("gcd",1,"int");
|
|
1896 if(!lua_isnumber(L,2)) SWIG_fail_arg("gcd",2,"int");
|
|
1897 arg1 = (int)lua_tonumber(L, 1);
|
|
1898 arg2 = (int)lua_tonumber(L, 2);
|
|
1899 result = (int)gcd(arg1,arg2);
|
|
1900 lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
|
|
1901 return SWIG_arg;
|
|
1902
|
|
1903 if(0) SWIG_fail;
|
|
1904
|
|
1905 fail:
|
|
1906 lua_error(L);
|
|
1907 return SWIG_arg;
|
|
1908 }
|
|
1909
|
|
1910
|
|
1911 static int _wrap_Foo_set(lua_State* L) {
|
|
1912 int SWIG_arg = 0;
|
|
1913 double arg1 ;
|
|
1914
|
|
1915 SWIG_check_num_args("Foo",1,1)
|
|
1916 if(!lua_isnumber(L,1)) SWIG_fail_arg("Foo",1,"double");
|
|
1917 arg1 = (double)lua_tonumber(L, 1);
|
|
1918 Foo = arg1;
|
|
1919
|
|
1920 return SWIG_arg;
|
|
1921
|
|
1922 if(0) SWIG_fail;
|
|
1923
|
|
1924 fail:
|
|
1925 lua_error(L);
|
|
1926 return SWIG_arg;
|
|
1927 }
|
|
1928
|
|
1929
|
|
1930 static int _wrap_Foo_get(lua_State* L) {
|
|
1931 int SWIG_arg = 0;
|
|
1932 double result;
|
|
1933
|
|
1934 SWIG_check_num_args("Foo",0,0)
|
|
1935 result = (double)Foo;
|
|
1936 lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
|
|
1937 return SWIG_arg;
|
|
1938
|
|
1939 if(0) SWIG_fail;
|
|
1940
|
|
1941 fail:
|
|
1942 lua_error(L);
|
|
1943 return SWIG_arg;
|
|
1944 }
|
|
1945
|
|
1946
|
|
1947 #ifdef __cplusplus
|
|
1948 }
|
|
1949 #endif
|
|
1950
|
|
1951 static const struct luaL_Reg swig_commands[] = {
|
|
1952 { "gcd", _wrap_gcd},
|
|
1953 {0,0}
|
|
1954 };
|
|
1955
|
|
1956 static swig_lua_var_info swig_variables[] = {
|
|
1957 { "Foo", _wrap_Foo_get, _wrap_Foo_set },
|
|
1958 {0,0,0}
|
|
1959 };
|
|
1960
|
|
1961 static swig_lua_const_info swig_constants[] = {
|
|
1962 {0,0,0,0,0,0}
|
|
1963 };
|
|
1964
|
|
1965 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
|
|
1966
|
|
1967
|
|
1968 static swig_type_info *swig_type_initial[] = {
|
|
1969 NULL
|
|
1970 };
|
|
1971
|
|
1972
|
|
1973 static swig_cast_info *swig_cast_initial[] = {
|
|
1974 NULL
|
|
1975 };
|
|
1976
|
|
1977
|
|
1978 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
|
|
1979
|
|
1980 /* -----------------------------------------------------------------------------
|
|
1981 * Type initialization:
|
|
1982 * This problem is tough by the requirement that no dynamic
|
|
1983 * memory is used. Also, since swig_type_info structures store pointers to
|
|
1984 * swig_cast_info structures and swig_cast_info structures store pointers back
|
|
1985 * to swig_type_info structures, we need some lookup code at initialization.
|
|
1986 * The idea is that swig generates all the structures that are needed.
|
|
1987 * The runtime then collects these partially filled structures.
|
|
1988 * The SWIG_InitializeModule function takes these initial arrays out of
|
|
1989 * swig_module, and does all the lookup, filling in the swig_module.types
|
|
1990 * array with the correct data and linking the correct swig_cast_info
|
|
1991 * structures together.
|
|
1992 *
|
|
1993 * The generated swig_type_info structures are assigned staticly to an initial
|
|
1994 * array. We just loop through that array, and handle each type individually.
|
|
1995 * First we lookup if this type has been already loaded, and if so, use the
|
|
1996 * loaded structure instead of the generated one. Then we have to fill in the
|
|
1997 * cast linked list. The cast data is initially stored in something like a
|
|
1998 * two-dimensional array. Each row corresponds to a type (there are the same
|
|
1999 * number of rows as there are in the swig_type_initial array). Each entry in
|
|
2000 * a column is one of the swig_cast_info structures for that type.
|
|
2001 * The cast_initial array is actually an array of arrays, because each row has
|
|
2002 * a variable number of columns. So to actually build the cast linked list,
|
|
2003 * we find the array of casts associated with the type, and loop through it
|
|
2004 * adding the casts to the list. The one last trick we need to do is making
|
|
2005 * sure the type pointer in the swig_cast_info struct is correct.
|
|
2006 *
|
|
2007 * First off, we lookup the cast->type name to see if it is already loaded.
|
|
2008 * There are three cases to handle:
|
|
2009 * 1) If the cast->type has already been loaded AND the type we are adding
|
|
2010 * casting info to has not been loaded (it is in this module), THEN we
|
|
2011 * replace the cast->type pointer with the type pointer that has already
|
|
2012 * been loaded.
|
|
2013 * 2) If BOTH types (the one we are adding casting info to, and the
|
|
2014 * cast->type) are loaded, THEN the cast info has already been loaded by
|
|
2015 * the previous module so we just ignore it.
|
|
2016 * 3) Finally, if cast->type has not already been loaded, then we add that
|
|
2017 * swig_cast_info to the linked list (because the cast->type) pointer will
|
|
2018 * be correct.
|
|
2019 * ----------------------------------------------------------------------------- */
|
|
2020
|
|
2021 #ifdef __cplusplus
|
|
2022 extern "C" {
|
|
2023 #if 0
|
|
2024 } /* c-mode */
|
|
2025 #endif
|
|
2026 #endif
|
|
2027
|
|
2028 #if 0
|
|
2029 #define SWIGRUNTIME_DEBUG
|
|
2030 #endif
|
|
2031
|
|
2032
|
|
2033 SWIGRUNTIME void
|
|
2034 SWIG_InitializeModule(void *clientdata) {
|
|
2035 size_t i;
|
|
2036 swig_module_info *module_head, *iter;
|
|
2037 int found, init;
|
|
2038
|
|
2039 /* check to see if the circular list has been setup, if not, set it up */
|
|
2040 if (swig_module.next==0) {
|
|
2041 /* Initialize the swig_module */
|
|
2042 swig_module.type_initial = swig_type_initial;
|
|
2043 swig_module.cast_initial = swig_cast_initial;
|
|
2044 swig_module.next = &swig_module;
|
|
2045 init = 1;
|
|
2046 } else {
|
|
2047 init = 0;
|
|
2048 }
|
|
2049
|
|
2050 /* Try and load any already created modules */
|
|
2051 module_head = SWIG_GetModule(clientdata);
|
|
2052 if (!module_head) {
|
|
2053 /* This is the first module loaded for this interpreter */
|
|
2054 /* so set the swig module into the interpreter */
|
|
2055 SWIG_SetModule(clientdata, &swig_module);
|
|
2056 module_head = &swig_module;
|
|
2057 } else {
|
|
2058 /* the interpreter has loaded a SWIG module, but has it loaded this one? */
|
|
2059 found=0;
|
|
2060 iter=module_head;
|
|
2061 do {
|
|
2062 if (iter==&swig_module) {
|
|
2063 found=1;
|
|
2064 break;
|
|
2065 }
|
|
2066 iter=iter->next;
|
|
2067 } while (iter!= module_head);
|
|
2068
|
|
2069 /* if the is found in the list, then all is done and we may leave */
|
|
2070 if (found) return;
|
|
2071 /* otherwise we must add out module into the list */
|
|
2072 swig_module.next = module_head->next;
|
|
2073 module_head->next = &swig_module;
|
|
2074 }
|
|
2075
|
|
2076 /* When multiple interpreters are used, a module could have already been initialized in
|
|
2077 a different interpreter, but not yet have a pointer in this interpreter.
|
|
2078 In this case, we do not want to continue adding types... everything should be
|
|
2079 set up already */
|
|
2080 if (init == 0) return;
|
|
2081
|
|
2082 /* Now work on filling in swig_module.types */
|
|
2083 #ifdef SWIGRUNTIME_DEBUG
|
|
2084 printf("SWIG_InitializeModule: size %d\n", swig_module.size);
|
|
2085 #endif
|
|
2086 for (i = 0; i < swig_module.size; ++i) {
|
|
2087 swig_type_info *type = 0;
|
|
2088 swig_type_info *ret;
|
|
2089 swig_cast_info *cast;
|
|
2090
|
|
2091 #ifdef SWIGRUNTIME_DEBUG
|
|
2092 printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
|
|
2093 #endif
|
|
2094
|
|
2095 /* if there is another module already loaded */
|
|
2096 if (swig_module.next != &swig_module) {
|
|
2097 type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
|
|
2098 }
|
|
2099 if (type) {
|
|
2100 /* Overwrite clientdata field */
|
|
2101 #ifdef SWIGRUNTIME_DEBUG
|
|
2102 printf("SWIG_InitializeModule: found type %s\n", type->name);
|
|
2103 #endif
|
|
2104 if (swig_module.type_initial[i]->clientdata) {
|
|
2105 type->clientdata = swig_module.type_initial[i]->clientdata;
|
|
2106 #ifdef SWIGRUNTIME_DEBUG
|
|
2107 printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
|
|
2108 #endif
|
|
2109 }
|
|
2110 } else {
|
|
2111 type = swig_module.type_initial[i];
|
|
2112 }
|
|
2113
|
|
2114 /* Insert casting types */
|
|
2115 cast = swig_module.cast_initial[i];
|
|
2116 while (cast->type) {
|
|
2117
|
|
2118 /* Don't need to add information already in the list */
|
|
2119 ret = 0;
|
|
2120 #ifdef SWIGRUNTIME_DEBUG
|
|
2121 printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
|
|
2122 #endif
|
|
2123 if (swig_module.next != &swig_module) {
|
|
2124 ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
|
|
2125 #ifdef SWIGRUNTIME_DEBUG
|
|
2126 if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
|
|
2127 #endif
|
|
2128 }
|
|
2129 if (ret) {
|
|
2130 if (type == swig_module.type_initial[i]) {
|
|
2131 #ifdef SWIGRUNTIME_DEBUG
|
|
2132 printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
|
|
2133 #endif
|
|
2134 cast->type = ret;
|
|
2135 ret = 0;
|
|
2136 } else {
|
|
2137 /* Check for casting already in the list */
|
|
2138 swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
|
|
2139 #ifdef SWIGRUNTIME_DEBUG
|
|
2140 if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
|
|
2141 #endif
|
|
2142 if (!ocast) ret = 0;
|
|
2143 }
|
|
2144 }
|
|
2145
|
|
2146 if (!ret) {
|
|
2147 #ifdef SWIGRUNTIME_DEBUG
|
|
2148 printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
|
|
2149 #endif
|
|
2150 if (type->cast) {
|
|
2151 type->cast->prev = cast;
|
|
2152 cast->next = type->cast;
|
|
2153 }
|
|
2154 type->cast = cast;
|
|
2155 }
|
|
2156 cast++;
|
|
2157 }
|
|
2158 /* Set entry in modules->types array equal to the type */
|
|
2159 swig_module.types[i] = type;
|
|
2160 }
|
|
2161 swig_module.types[i] = 0;
|
|
2162
|
|
2163 #ifdef SWIGRUNTIME_DEBUG
|
|
2164 printf("**** SWIG_InitializeModule: Cast List ******\n");
|
|
2165 for (i = 0; i < swig_module.size; ++i) {
|
|
2166 int j = 0;
|
|
2167 swig_cast_info *cast = swig_module.cast_initial[i];
|
|
2168 printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
|
|
2169 while (cast->type) {
|
|
2170 printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
|
|
2171 cast++;
|
|
2172 ++j;
|
|
2173 }
|
|
2174 printf("---- Total casts: %d\n",j);
|
|
2175 }
|
|
2176 printf("**** SWIG_InitializeModule: Cast List ******\n");
|
|
2177 #endif
|
|
2178 }
|
|
2179
|
|
2180 /* This function will propagate the clientdata field of type to
|
|
2181 * any new swig_type_info structures that have been added into the list
|
|
2182 * of equivalent types. It is like calling
|
|
2183 * SWIG_TypeClientData(type, clientdata) a second time.
|
|
2184 */
|
|
2185 SWIGRUNTIME void
|
|
2186 SWIG_PropagateClientData(void) {
|
|
2187 size_t i;
|
|
2188 swig_cast_info *equiv;
|
|
2189 static int init_run = 0;
|
|
2190
|
|
2191 if (init_run) return;
|
|
2192 init_run = 1;
|
|
2193
|
|
2194 for (i = 0; i < swig_module.size; i++) {
|
|
2195 if (swig_module.types[i]->clientdata) {
|
|
2196 equiv = swig_module.types[i]->cast;
|
|
2197 while (equiv) {
|
|
2198 if (!equiv->converter) {
|
|
2199 if (equiv->type && !equiv->type->clientdata)
|
|
2200 SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
|
|
2201 }
|
|
2202 equiv = equiv->next;
|
|
2203 }
|
|
2204 }
|
|
2205 }
|
|
2206 }
|
|
2207
|
|
2208 #ifdef __cplusplus
|
|
2209 #if 0
|
|
2210 { /* c-mode */
|
|
2211 #endif
|
|
2212 }
|
|
2213 #endif
|
|
2214
|
|
2215
|
|
2216
|
|
2217 /* Forward declaration of where the user's %init{} gets inserted */
|
|
2218 void SWIG_init_user(lua_State* L );
|
|
2219
|
|
2220 #ifdef __cplusplus
|
|
2221 extern "C" {
|
|
2222 #endif
|
|
2223 /* this is the initialization function
|
|
2224 added at the very end of the code
|
|
2225 the function is always called SWIG_init, but an earlier #define will rename it
|
|
2226 */
|
|
2227 #if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
|
|
2228 LUALIB_API int SWIG_init(lua_State* L)
|
|
2229 #else
|
|
2230 SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
|
|
2231 #endif
|
|
2232 {
|
|
2233 #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */
|
|
2234 int i;
|
|
2235 /* start with global table */
|
|
2236 lua_pushglobaltable (L);
|
|
2237 /* SWIG's internal initalisation */
|
|
2238 SWIG_InitializeModule((void*)L);
|
|
2239 SWIG_PropagateClientData();
|
|
2240 #endif
|
|
2241
|
|
2242 #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
|
|
2243 /* add a global fn */
|
|
2244 SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);
|
|
2245 SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal);
|
|
2246 /* begin the module (its a table with the same name as the module) */
|
|
2247 SWIG_Lua_module_begin(L,SWIG_name);
|
|
2248 /* add commands/functions */
|
|
2249 for (i = 0; swig_commands[i].name; i++){
|
|
2250 SWIG_Lua_module_add_function(L,swig_commands[i].name,swig_commands[i].func);
|
|
2251 }
|
|
2252 /* add variables */
|
|
2253 for (i = 0; swig_variables[i].name; i++){
|
|
2254 SWIG_Lua_module_add_variable(L,swig_variables[i].name,swig_variables[i].get,swig_variables[i].set);
|
|
2255 }
|
|
2256 #endif
|
|
2257
|
|
2258 #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
|
|
2259 /* set up base class pointers (the hierarchy) */
|
|
2260 for (i = 0; swig_types[i]; i++){
|
|
2261 if (swig_types[i]->clientdata){
|
|
2262 SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata));
|
|
2263 }
|
|
2264 }
|
|
2265 /* additional registration structs & classes in lua */
|
|
2266 for (i = 0; swig_types[i]; i++){
|
|
2267 if (swig_types[i]->clientdata){
|
|
2268 SWIG_Lua_class_register(L,(swig_lua_class*)(swig_types[i]->clientdata));
|
|
2269 }
|
|
2270 }
|
|
2271 #endif
|
|
2272
|
|
2273 #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
|
|
2274 /* constants */
|
|
2275 SWIG_Lua_InstallConstants(L,swig_constants);
|
|
2276 #endif
|
|
2277
|
|
2278 #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
|
|
2279 /* invoke user-specific initialization */
|
|
2280 SWIG_init_user(L);
|
|
2281 /* end module */
|
|
2282 /* Note: We do not clean up the stack here (Lua will do this for us). At this
|
|
2283 point, we have the globals table and out module table on the stack. Returning
|
|
2284 one value makes the module table the result of the require command. */
|
|
2285 return 1;
|
|
2286 #else
|
|
2287 return 0;
|
|
2288 #endif
|
|
2289 }
|
|
2290
|
|
2291 #ifdef __cplusplus
|
|
2292 }
|
|
2293 #endif
|
|
2294
|
|
2295
|
|
2296 const char* SWIG_LUACODE=
|
|
2297 "";
|
|
2298
|
|
2299 void SWIG_init_user(lua_State* L)
|
|
2300 {
|
|
2301 /* exec Lua code if applicable */
|
|
2302 SWIG_Lua_dostring(L,SWIG_LUACODE);
|
|
2303 }
|
|
2304
|