UGDK  0.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
swigluarun.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 2.0.4
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 /* -----------------------------------------------------------------------------
12  * This section contains generic SWIG labels for method/variable
13  * declarations/attributes, and other compiler dependent labels.
14  * ----------------------------------------------------------------------------- */
15 
16 /* template workaround for compilers that cannot correctly implement the C++ standard */
17 #ifndef SWIGTEMPLATEDISAMBIGUATOR
18 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
19 # define SWIGTEMPLATEDISAMBIGUATOR template
20 # elif defined(__HP_aCC)
21 /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
22 /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
23 # define SWIGTEMPLATEDISAMBIGUATOR template
24 # else
25 # define SWIGTEMPLATEDISAMBIGUATOR
26 # endif
27 #endif
28 
29 /* inline attribute */
30 #ifndef SWIGINLINE
31 # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
32 # define SWIGINLINE inline
33 # else
34 # define SWIGINLINE
35 # endif
36 #endif
37 
38 /* attribute recognised by some compilers to avoid 'unused' warnings */
39 #ifndef SWIGUNUSED
40 # if defined(__GNUC__)
41 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
42 # define SWIGUNUSED __attribute__ ((__unused__))
43 # else
44 # define SWIGUNUSED
45 # endif
46 # elif defined(__ICC)
47 # define SWIGUNUSED __attribute__ ((__unused__))
48 # else
49 # define SWIGUNUSED
50 # endif
51 #endif
52 
53 #ifndef SWIG_MSC_UNSUPPRESS_4505
54 # if defined(_MSC_VER)
55 # pragma warning(disable : 4505) /* unreferenced local function has been removed */
56 # endif
57 #endif
58 
59 #ifndef SWIGUNUSEDPARM
60 # ifdef __cplusplus
61 # define SWIGUNUSEDPARM(p)
62 # else
63 # define SWIGUNUSEDPARM(p) p SWIGUNUSED
64 # endif
65 #endif
66 
67 /* internal SWIG method */
68 #ifndef SWIGINTERN
69 # define SWIGINTERN static SWIGUNUSED
70 #endif
71 
72 /* internal inline SWIG method */
73 #ifndef SWIGINTERNINLINE
74 # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
75 #endif
76 
77 /* exporting methods */
78 #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
79 # ifndef GCC_HASCLASSVISIBILITY
80 # define GCC_HASCLASSVISIBILITY
81 # endif
82 #endif
83 
84 #ifndef SWIGEXPORT
85 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
86 # if defined(STATIC_LINKED)
87 # define SWIGEXPORT
88 # else
89 # define SWIGEXPORT __declspec(dllexport)
90 # endif
91 # else
92 # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
93 # define SWIGEXPORT __attribute__ ((visibility("default")))
94 # else
95 # define SWIGEXPORT
96 # endif
97 # endif
98 #endif
99 
100 /* calling conventions for Windows */
101 #ifndef SWIGSTDCALL
102 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
103 # define SWIGSTDCALL __stdcall
104 # else
105 # define SWIGSTDCALL
106 # endif
107 #endif
108 
109 /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
110 #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
111 # define _CRT_SECURE_NO_DEPRECATE
112 #endif
113 
114 /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
115 #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
116 # define _SCL_SECURE_NO_DEPRECATE
117 #endif
118 
119 /* Errors in SWIG */
120 #define SWIG_UnknownError -1
121 #define SWIG_IOError -2
122 #define SWIG_RuntimeError -3
123 #define SWIG_IndexError -4
124 #define SWIG_TypeError -5
125 #define SWIG_DivisionByZero -6
126 #define SWIG_OverflowError -7
127 #define SWIG_SyntaxError -8
128 #define SWIG_ValueError -9
129 #define SWIG_SystemError -10
130 #define SWIG_AttributeError -11
131 #define SWIG_MemoryError -12
132 #define SWIG_NullReferenceError -13
133 
134 
135 /* Errors in SWIG */
136 #define SWIG_UnknownError -1
137 #define SWIG_IOError -2
138 #define SWIG_RuntimeError -3
139 #define SWIG_IndexError -4
140 #define SWIG_TypeError -5
141 #define SWIG_DivisionByZero -6
142 #define SWIG_OverflowError -7
143 #define SWIG_SyntaxError -8
144 #define SWIG_ValueError -9
145 #define SWIG_SystemError -10
146 #define SWIG_AttributeError -11
147 #define SWIG_MemoryError -12
148 #define SWIG_NullReferenceError -13
149 
150 
151 /* -----------------------------------------------------------------------------
152  * swigrun.swg
153  *
154  * This file contains generic C API SWIG runtime support for pointer
155  * type checking.
156  * ----------------------------------------------------------------------------- */
157 
158 /* This should only be incremented when either the layout of swig_type_info changes,
159  or for whatever reason, the runtime changes incompatibly */
160 #define SWIG_RUNTIME_VERSION "4"
161 
162 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
163 #ifdef SWIG_TYPE_TABLE
164 # define SWIG_QUOTE_STRING(x) #x
165 # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
166 # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
167 #else
168 # define SWIG_TYPE_TABLE_NAME
169 #endif
170 
171 /*
172  You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
173  creating a static or dynamic library from the SWIG runtime code.
174  In 99.9% of the cases, SWIG just needs to declare them as 'static'.
175 
176  But only do this if strictly necessary, ie, if you have problems
177  with your compiler or suchlike.
178 */
179 
180 #ifndef SWIGRUNTIME
181 # define SWIGRUNTIME SWIGINTERN
182 #endif
183 
184 #ifndef SWIGRUNTIMEINLINE
185 # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
186 #endif
187 
188 /* Generic buffer size */
189 #ifndef SWIG_BUFFER_SIZE
190 # define SWIG_BUFFER_SIZE 1024
191 #endif
192 
193 /* Flags for pointer conversions */
194 #define SWIG_POINTER_DISOWN 0x1
195 #define SWIG_CAST_NEW_MEMORY 0x2
196 
197 /* Flags for new pointer objects */
198 #define SWIG_POINTER_OWN 0x1
199 
200 
201 /*
202  Flags/methods for returning states.
203 
204  The SWIG conversion methods, as ConvertPtr, return an integer
205  that tells if the conversion was successful or not. And if not,
206  an error code can be returned (see swigerrors.swg for the codes).
207 
208  Use the following macros/flags to set or process the returning
209  states.
210 
211  In old versions of SWIG, code such as the following was usually written:
212 
213  if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
214  // success code
215  } else {
216  //fail code
217  }
218 
219  Now you can be more explicit:
220 
221  int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
222  if (SWIG_IsOK(res)) {
223  // success code
224  } else {
225  // fail code
226  }
227 
228  which is the same really, but now you can also do
229 
230  Type *ptr;
231  int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
232  if (SWIG_IsOK(res)) {
233  // success code
234  if (SWIG_IsNewObj(res) {
235  ...
236  delete *ptr;
237  } else {
238  ...
239  }
240  } else {
241  // fail code
242  }
243 
244  I.e., now SWIG_ConvertPtr can return new objects and you can
245  identify the case and take care of the deallocation. Of course that
246  also requires SWIG_ConvertPtr to return new result values, such as
247 
248  int SWIG_ConvertPtr(obj, ptr,...) {
249  if (<obj is ok>) {
250  if (<need new object>) {
251  *ptr = <ptr to new allocated object>;
252  return SWIG_NEWOBJ;
253  } else {
254  *ptr = <ptr to old object>;
255  return SWIG_OLDOBJ;
256  }
257  } else {
258  return SWIG_BADOBJ;
259  }
260  }
261 
262  Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
263  more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
264  SWIG errors code.
265 
266  Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
267  allows to return the 'cast rank', for example, if you have this
268 
269  int food(double)
270  int fooi(int);
271 
272  and you call
273 
274  food(1) // cast rank '1' (1 -> 1.0)
275  fooi(1) // cast rank '0'
276 
277  just use the SWIG_AddCast()/SWIG_CheckState()
278 */
279 
280 #define SWIG_OK (0)
281 #define SWIG_ERROR (-1)
282 #define SWIG_IsOK(r) (r >= 0)
283 #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
284 
285 /* The CastRankLimit says how many bits are used for the cast rank */
286 #define SWIG_CASTRANKLIMIT (1 << 8)
287 /* The NewMask denotes the object was created (using new/malloc) */
288 #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
289 /* The TmpMask is for in/out typemaps that use temporal objects */
290 #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
291 /* Simple returning values */
292 #define SWIG_BADOBJ (SWIG_ERROR)
293 #define SWIG_OLDOBJ (SWIG_OK)
294 #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
295 #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
296 /* Check, add and del mask methods */
297 #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
298 #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
299 #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
300 #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
301 #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
302 #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
303 
304 /* Cast-Rank Mode */
305 #if defined(SWIG_CASTRANK_MODE)
306 # ifndef SWIG_TypeRank
307 # define SWIG_TypeRank unsigned long
308 # endif
309 # ifndef SWIG_MAXCASTRANK /* Default cast allowed */
310 # define SWIG_MAXCASTRANK (2)
311 # endif
312 # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
313 # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
314 SWIGINTERNINLINE int SWIG_AddCast(int r) {
315  return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
316 }
317 SWIGINTERNINLINE int SWIG_CheckState(int r) {
318  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
319 }
320 #else /* no cast-rank mode */
321 # define SWIG_AddCast
322 # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
323 #endif
324 
325 
326 #include <string.h>
327 
328 #ifdef __cplusplus
329 extern "C" {
330 #endif
331 
332 typedef void *(*swig_converter_func)(void *, int *);
333 typedef struct swig_type_info *(*swig_dycast_func)(void **);
334 
335 /* Structure to store information on one type */
336 typedef struct swig_type_info {
337  const char *name; /* mangled name of this type */
338  const char *str; /* human readable name of this type */
339  swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
340  struct swig_cast_info *cast; /* linked list of types that can cast into this type */
341  void *clientdata; /* language specific type data */
342  int owndata; /* flag if the structure owns the clientdata */
344 
345 /* Structure to store a type and conversion function used for casting */
346 typedef struct swig_cast_info {
347  swig_type_info *type; /* pointer to type that is equivalent to this type */
348  swig_converter_func converter; /* function to cast the void pointers */
349  struct swig_cast_info *next; /* pointer to next cast in linked list */
350  struct swig_cast_info *prev; /* pointer to the previous cast */
352 
353 /* Structure used to store module information
354  * Each module generates one structure like this, and the runtime collects
355  * all of these structures and stores them in a circularly linked list.*/
356 typedef struct swig_module_info {
357  swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
358  size_t size; /* Number of types in this module */
359  struct swig_module_info *next; /* Pointer to next element in circularly linked list */
360  swig_type_info **type_initial; /* Array of initially generated type structures */
361  swig_cast_info **cast_initial; /* Array of initially generated casting structures */
362  void *clientdata; /* Language specific module data */
364 
365 /*
366  Compare two type names skipping the space characters, therefore
367  "char*" == "char *" and "Class<int>" == "Class<int >", etc.
368 
369  Return 0 when the two name types are equivalent, as in
370  strncmp, but skipping ' '.
371 */
372 SWIGRUNTIME int
373 SWIG_TypeNameComp(const char *f1, const char *l1,
374  const char *f2, const char *l2) {
375  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
376  while ((*f1 == ' ') && (f1 != l1)) ++f1;
377  while ((*f2 == ' ') && (f2 != l2)) ++f2;
378  if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
379  }
380  return (int)((l1 - f1) - (l2 - f2));
381 }
382 
383 /*
384  Check type equivalence in a name list like <name1>|<name2>|...
385  Return 0 if not equal, 1 if equal
386 */
387 SWIGRUNTIME int
388 SWIG_TypeEquiv(const char *nb, const char *tb) {
389  int equiv = 0;
390  const char* te = tb + strlen(tb);
391  const char* ne = nb;
392  while (!equiv && *ne) {
393  for (nb = ne; *ne; ++ne) {
394  if (*ne == '|') break;
395  }
396  equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
397  if (*ne) ++ne;
398  }
399  return equiv;
400 }
401 
402 /*
403  Check type equivalence in a name list like <name1>|<name2>|...
404  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
405 */
406 SWIGRUNTIME int
407 SWIG_TypeCompare(const char *nb, const char *tb) {
408  int equiv = 0;
409  const char* te = tb + strlen(tb);
410  const char* ne = nb;
411  while (!equiv && *ne) {
412  for (nb = ne; *ne; ++ne) {
413  if (*ne == '|') break;
414  }
415  equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
416  if (*ne) ++ne;
417  }
418  return equiv;
419 }
420 
421 
422 /*
423  Check the typename
424 */
426 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
427  if (ty) {
428  swig_cast_info *iter = ty->cast;
429  while (iter) {
430  if (strcmp(iter->type->name, c) == 0) {
431  if (iter == ty->cast)
432  return iter;
433  /* Move iter to the top of the linked list */
434  iter->prev->next = iter->next;
435  if (iter->next)
436  iter->next->prev = iter->prev;
437  iter->next = ty->cast;
438  iter->prev = 0;
439  if (ty->cast) ty->cast->prev = iter;
440  ty->cast = iter;
441  return iter;
442  }
443  iter = iter->next;
444  }
445  }
446  return 0;
447 }
448 
449 /*
450  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
451 */
454  if (ty) {
455  swig_cast_info *iter = ty->cast;
456  while (iter) {
457  if (iter->type == from) {
458  if (iter == ty->cast)
459  return iter;
460  /* Move iter to the top of the linked list */
461  iter->prev->next = iter->next;
462  if (iter->next)
463  iter->next->prev = iter->prev;
464  iter->next = ty->cast;
465  iter->prev = 0;
466  if (ty->cast) ty->cast->prev = iter;
467  ty->cast = iter;
468  return iter;
469  }
470  iter = iter->next;
471  }
472  }
473  return 0;
474 }
475 
476 /*
477  Cast a pointer up an inheritance hierarchy
478 */
479 SWIGRUNTIMEINLINE void *
480 SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
481  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
482 }
483 
484 /*
485  Dynamic pointer casting. Down an inheritance hierarchy
486 */
489  swig_type_info *lastty = ty;
490  if (!ty || !ty->dcast) return ty;
491  while (ty && (ty->dcast)) {
492  ty = (*ty->dcast)(ptr);
493  if (ty) lastty = ty;
494  }
495  return lastty;
496 }
497 
498 /*
499  Return the name associated with this type
500 */
501 SWIGRUNTIMEINLINE const char *
503  return ty->name;
504 }
505 
506 /*
507  Return the pretty name associated with this type,
508  that is an unmangled type name in a form presentable to the user.
509 */
510 SWIGRUNTIME const char *
512  /* The "str" field contains the equivalent pretty names of the
513  type, separated by vertical-bar characters. We choose
514  to print the last name, as it is often (?) the most
515  specific. */
516  if (!type) return NULL;
517  if (type->str != NULL) {
518  const char *last_name = type->str;
519  const char *s;
520  for (s = type->str; *s; s++)
521  if (*s == '|') last_name = s+1;
522  return last_name;
523  }
524  else
525  return type->name;
526 }
527 
528 /*
529  Set the clientdata field for a type
530 */
531 SWIGRUNTIME void
533  swig_cast_info *cast = ti->cast;
534  /* if (ti->clientdata == clientdata) return; */
535  ti->clientdata = clientdata;
536 
537  while (cast) {
538  if (!cast->converter) {
539  swig_type_info *tc = cast->type;
540  if (!tc->clientdata) {
541  SWIG_TypeClientData(tc, clientdata);
542  }
543  }
544  cast = cast->next;
545  }
546 }
547 SWIGRUNTIME void
549  SWIG_TypeClientData(ti, clientdata);
550  ti->owndata = 1;
551 }
552 
553 /*
554  Search for a swig_type_info structure only by mangled name
555  Search is a O(log #types)
556 
557  We start searching at module start, and finish searching when start == end.
558  Note: if start == end at the beginning of the function, we go all the way around
559  the circular list.
560 */
563  swig_module_info *end,
564  const char *name) {
565  swig_module_info *iter = start;
566  do {
567  if (iter->size) {
568  register size_t l = 0;
569  register size_t r = iter->size - 1;
570  do {
571  /* since l+r >= 0, we can (>> 1) instead (/ 2) */
572  register size_t i = (l + r) >> 1;
573  const char *iname = iter->types[i]->name;
574  if (iname) {
575  register int compare = strcmp(name, iname);
576  if (compare == 0) {
577  return iter->types[i];
578  } else if (compare < 0) {
579  if (i) {
580  r = i - 1;
581  } else {
582  break;
583  }
584  } else if (compare > 0) {
585  l = i + 1;
586  }
587  } else {
588  break; /* should never happen */
589  }
590  } while (l <= r);
591  }
592  iter = iter->next;
593  } while (iter != end);
594  return 0;
595 }
596 
597 /*
598  Search for a swig_type_info structure for either a mangled name or a human readable name.
599  It first searches the mangled names of the types, which is a O(log #types)
600  If a type is not found it then searches the human readable names, which is O(#types).
601 
602  We start searching at module start, and finish searching when start == end.
603  Note: if start == end at the beginning of the function, we go all the way around
604  the circular list.
605 */
608  swig_module_info *end,
609  const char *name) {
610  /* STEP 1: Search the name field using binary search */
611  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
612  if (ret) {
613  return ret;
614  } else {
615  /* STEP 2: If the type hasn't been found, do a complete search
616  of the str field (the human readable name) */
617  swig_module_info *iter = start;
618  do {
619  register size_t i = 0;
620  for (; i < iter->size; ++i) {
621  if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
622  return iter->types[i];
623  }
624  iter = iter->next;
625  } while (iter != end);
626  }
627 
628  /* neither found a match */
629  return 0;
630 }
631 
632 /*
633  Pack binary data into a string
634 */
635 SWIGRUNTIME char *
636 SWIG_PackData(char *c, void *ptr, size_t sz) {
637  static const char hex[17] = "0123456789abcdef";
638  register const unsigned char *u = (unsigned char *) ptr;
639  register const unsigned char *eu = u + sz;
640  for (; u != eu; ++u) {
641  register unsigned char uu = *u;
642  *(c++) = hex[(uu & 0xf0) >> 4];
643  *(c++) = hex[uu & 0xf];
644  }
645  return c;
646 }
647 
648 /*
649  Unpack binary data from a string
650 */
651 SWIGRUNTIME const char *
652 SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
653  register unsigned char *u = (unsigned char *) ptr;
654  register const unsigned char *eu = u + sz;
655  for (; u != eu; ++u) {
656  register char d = *(c++);
657  register unsigned char uu;
658  if ((d >= '0') && (d <= '9'))
659  uu = ((d - '0') << 4);
660  else if ((d >= 'a') && (d <= 'f'))
661  uu = ((d - ('a'-10)) << 4);
662  else
663  return (char *) 0;
664  d = *(c++);
665  if ((d >= '0') && (d <= '9'))
666  uu |= (d - '0');
667  else if ((d >= 'a') && (d <= 'f'))
668  uu |= (d - ('a'-10));
669  else
670  return (char *) 0;
671  *u = uu;
672  }
673  return c;
674 }
675 
676 /*
677  Pack 'void *' into a string buffer.
678 */
679 SWIGRUNTIME char *
680 SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
681  char *r = buff;
682  if ((2*sizeof(void *) + 2) > bsz) return 0;
683  *(r++) = '_';
684  r = SWIG_PackData(r,&ptr,sizeof(void *));
685  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
686  strcpy(r,name);
687  return buff;
688 }
689 
690 SWIGRUNTIME const char *
691 SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
692  if (*c != '_') {
693  if (strcmp(c,"NULL") == 0) {
694  *ptr = (void *) 0;
695  return name;
696  } else {
697  return 0;
698  }
699  }
700  return SWIG_UnpackData(++c,ptr,sizeof(void *));
701 }
702 
703 SWIGRUNTIME char *
704 SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
705  char *r = buff;
706  size_t lname = (name ? strlen(name) : 0);
707  if ((2*sz + 2 + lname) > bsz) return 0;
708  *(r++) = '_';
709  r = SWIG_PackData(r,ptr,sz);
710  if (lname) {
711  strncpy(r,name,lname+1);
712  } else {
713  *r = 0;
714  }
715  return buff;
716 }
717 
718 SWIGRUNTIME const char *
719 SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
720  if (*c != '_') {
721  if (strcmp(c,"NULL") == 0) {
722  memset(ptr,0,sz);
723  return name;
724  } else {
725  return 0;
726  }
727  }
728  return SWIG_UnpackData(++c,ptr,sz);
729 }
730 
731 #ifdef __cplusplus
732 }
733 #endif
734 /* -----------------------------------------------------------------------------
735  * luarun.swg
736  *
737  * This file contains the runtime support for Lua modules
738  * and includes code for managing global variables and pointer
739  * type checking.
740  * ----------------------------------------------------------------------------- */
741 
742 #ifdef __cplusplus
743 extern "C" {
744 #endif
745 
746 #include "lua.h"
747 #include "lauxlib.h"
748 #include <stdlib.h> /* for malloc */
749 #include <assert.h> /* for a few sanity tests */
750 
751 /* -----------------------------------------------------------------------------
752  * global swig types
753  * ----------------------------------------------------------------------------- */
754 /* Constant table */
755 #define SWIG_LUA_INT 1
756 #define SWIG_LUA_FLOAT 2
757 #define SWIG_LUA_STRING 3
758 #define SWIG_LUA_POINTER 4
759 #define SWIG_LUA_BINARY 5
760 #define SWIG_LUA_CHAR 6
761 
762 /* Structure for variable linking table */
763 typedef struct {
764  const char *name;
768 
769 /* Constant information structure */
770 typedef struct {
771  int type;
772  char *name;
773  long lvalue;
774  double dvalue;
775  void *pvalue;
778 
779 typedef struct {
780  const char *name;
783 
784 typedef struct {
785  const char *name;
789 
790 typedef struct swig_lua_class {
791  const char *name;
794  void (*destructor)(void *);
798  const char **base_names;
800 
801 /* this is the struct for wrappering all pointers in SwigLua
802 */
803 typedef struct {
805  int own; /* 1 if owned & must be destroyed */
806  void *ptr;
808 
809 /* this is the struct for wrapping arbitary packed binary data
810 (currently it is only used for member function pointers)
811 the data ordering is similar to swig_lua_userdata, but it is currently not possible
812 to tell the two structures apart within SWIG, other than by looking at the type
813 */
814 typedef struct {
816  int own; /* 1 if owned & must be destroyed */
817  char data[1]; /* arbitary amount of data */
819 
820 /* Common SWIG API */
821 #define SWIG_NewPointerObj(L, ptr, type, owner) SWIG_Lua_NewPointerObj(L, (void *)ptr, type, owner)
822 #define SWIG_ConvertPtr(L,idx, ptr, type, flags) SWIG_Lua_ConvertPtr(L,idx,ptr,type,flags)
823 #define SWIG_MustGetPtr(L,idx, type,flags, argnum,fnname) SWIG_Lua_MustGetPtr(L,idx, type,flags, argnum,fnname)
824 /* for C++ member pointers, ie, member methods */
825 #define SWIG_ConvertMember(L, idx, ptr, sz, ty) SWIG_Lua_ConvertPacked(L, idx, ptr, sz, ty)
826 #define SWIG_NewMemberObj(L, ptr, sz, type) SWIG_Lua_NewPackedObj(L, ptr, sz, type)
827 
828 /* Runtime API */
829 #define SWIG_GetModule(clientdata) SWIG_Lua_GetModule((lua_State*)(clientdata))
830 #define SWIG_SetModule(clientdata, pointer) SWIG_Lua_SetModule((lua_State*) (clientdata), pointer)
831 #define SWIG_MODULE_CLIENTDATA_TYPE lua_State*
832 
833 /* Contract support */
834 #define SWIG_contract_assert(expr, msg) \
835  if (!(expr)) { lua_pushstring(L, (char *) msg); goto fail; } else
836 
837 /* helper #defines */
838 #define SWIG_fail {goto fail;}
839 #define SWIG_fail_arg(func_name,argnum,type) \
840  {lua_pushfstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\
841  func_name,argnum,type,SWIG_Lua_typename(L,argnum));\
842  goto fail;}
843 #define SWIG_fail_ptr(func_name,argnum,type) \
844  SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*")
845 #define SWIG_check_num_args(func_name,a,b) \
846  if (lua_gettop(L)<a || lua_gettop(L)>b) \
847  {lua_pushfstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\
848  goto fail;}
849 
850 
851 #define SWIG_Lua_get_table(L,n) \
852  (lua_pushstring(L, n), lua_rawget(L,-2))
853 
854 #define SWIG_Lua_add_function(L,n,f) \
855  (lua_pushstring(L, n), \
856  lua_pushcfunction(L, f), \
857  lua_rawset(L,-3))
858 
859 /* special helper for allowing 'nil' for usertypes */
860 #define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I))
861 
862 #ifdef __cplusplus
863 /* Special helper for member function pointers
864 it gets the address, casts it, then dereferences it */
865 //#define SWIG_mem_fn_as_voidptr(a) (*((char**)&(a)))
866 #endif
867 
868 /* storing/access of swig_module_info */
871  swig_module_info *ret = 0;
872  lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
873  lua_rawget(L,LUA_REGISTRYINDEX);
874  if (lua_islightuserdata(L,-1))
875  ret=(swig_module_info*)lua_touserdata(L,-1);
876  lua_pop(L,1); /* tidy */
877  return ret;
878 }
879 
880 SWIGRUNTIME void
882  /* add this all into the Lua registry: */
883  lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
884  lua_pushlightuserdata(L,(void*)module);
885  lua_rawset(L,LUA_REGISTRYINDEX);
886 }
887 
888 /* -----------------------------------------------------------------------------
889  * global variable support code: modules
890  * ----------------------------------------------------------------------------- */
891 
892 /* this function is called when trying to set an immutable.
893 default value is to print an error.
894 This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */
896 {
897 /* there should be 1 param passed in: the new value */
898 #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE
899  lua_pop(L,1); /* remove it */
900  lua_pushstring(L,"This variable is immutable");
901  lua_error(L);
902 #endif
903  return 0; /* should not return anything */
904 }
905 
906 /* the module.get method used for getting linked data */
908 {
909 /* there should be 2 params passed in
910  (1) table (not the meta table)
911  (2) string name of the attribute
912  printf("SWIG_Lua_module_get %p(%s) '%s'\n",
913  lua_topointer(L,1),lua_typename(L,lua_type(L,1)),
914  lua_tostring(L,2));
915 */
916  /* get the metatable */
917  assert(lua_istable(L,1)); /* just in case */
918  lua_getmetatable(L,1); /* get the metatable */
919  assert(lua_istable(L,-1)); /* just in case */
920  SWIG_Lua_get_table(L,".get"); /* get the .get table */
921  lua_remove(L,3); /* remove metatable */
922  if (lua_istable(L,-1))
923  {
924  /* look for the key in the .get table */
925  lua_pushvalue(L,2); /* key */
926  lua_rawget(L,-2);
927  lua_remove(L,3); /* remove .get */
928  if (lua_iscfunction(L,-1))
929  { /* found it so call the fn & return its value */
930  lua_call(L,0,1);
931  return 1;
932  }
933  lua_pop(L,1); /* remove the top */
934  }
935  lua_pop(L,1); /* remove the .get */
936  lua_pushnil(L); /* return a nil */
937  return 1;
938 }
939 
940 /* the module.set method used for setting linked data */
942 {
943 /* there should be 3 params passed in
944  (1) table (not the meta table)
945  (2) string name of the attribute
946  (3) any for the new value
947 */
948  /* get the metatable */
949  assert(lua_istable(L,1)); /* just in case */
950  lua_getmetatable(L,1); /* get the metatable */
951  assert(lua_istable(L,-1)); /* just in case */
952  SWIG_Lua_get_table(L,".set"); /* get the .set table */
953  lua_remove(L,4); /* remove metatable */
954  if (lua_istable(L,-1))
955  {
956  /* look for the key in the .set table */
957  lua_pushvalue(L,2); /* key */
958  lua_rawget(L,-2);
959  lua_remove(L,4); /* remove .set */
960  if (lua_iscfunction(L,-1))
961  { /* found it so call the fn & return its value */
962  lua_pushvalue(L,3); /* value */
963  lua_call(L,1,0);
964  return 0;
965  }
966  }
967  lua_settop(L,3); /* reset back to start */
968  /* we now have the table, key & new value, so just set directly */
969  lua_rawset(L,1); /* add direct */
970  return 0;
971 }
972 
973 /* registering a module in lua */
974 SWIGINTERN void SWIG_Lua_module_begin(lua_State* L,const char* name)
975 {
976  assert(lua_istable(L,-1)); /* just in case */
977  lua_pushstring(L,name);
978  lua_newtable(L); /* the table */
979  /* add meta table */
980  lua_newtable(L); /* the meta table */
983  lua_pushstring(L,".get");
984  lua_newtable(L); /* the .get table */
985  lua_rawset(L,-3); /* add .get into metatable */
986  lua_pushstring(L,".set");
987  lua_newtable(L); /* the .set table */
988  lua_rawset(L,-3); /* add .set into metatable */
989  lua_setmetatable(L,-2); /* sets meta table in module */
990  lua_rawset(L,-3); /* add module into parent */
991  SWIG_Lua_get_table(L,name); /* get the table back out */
992 }
993 
994 /* ending the register */
996 {
997  lua_pop(L,1); /* tidy stack (remove module) */
998 }
999 
1000 /* adding a linked variable to the module */
1002 {
1003  assert(lua_istable(L,-1)); /* just in case */
1004  lua_getmetatable(L,-1); /* get the metatable */
1005  assert(lua_istable(L,-1)); /* just in case */
1006  SWIG_Lua_get_table(L,".get"); /* find the .get table */
1007  assert(lua_istable(L,-1)); /* should be a table: */
1008  SWIG_Lua_add_function(L,name,getFn);
1009  lua_pop(L,1); /* tidy stack (remove table) */
1010  if (setFn) /* if there is a set fn */
1011  {
1012  SWIG_Lua_get_table(L,".set"); /* find the .set table */
1013  assert(lua_istable(L,-1)); /* should be a table: */
1014  SWIG_Lua_add_function(L,name,setFn);
1015  lua_pop(L,1); /* tidy stack (remove table) */
1016  }
1017  lua_pop(L,1); /* tidy stack (remove meta) */
1018 }
1019 
1020 /* adding a function module */
1022 {
1023  SWIG_Lua_add_function(L,name,fn);
1024 }
1025 
1026 /* -----------------------------------------------------------------------------
1027  * global variable support code: classes
1028  * ----------------------------------------------------------------------------- */
1029 
1030 /* the class.get method, performs the lookup of class attributes */
1032 {
1033 /* there should be 2 params passed in
1034  (1) userdata (not the meta table)
1035  (2) string name of the attribute
1036 */
1037  assert(lua_isuserdata(L,-2)); /* just in case */
1038  lua_getmetatable(L,-2); /* get the meta table */
1039  assert(lua_istable(L,-1)); /* just in case */
1040  SWIG_Lua_get_table(L,".get"); /* find the .get table */
1041  assert(lua_istable(L,-1)); /* just in case */
1042  /* look for the key in the .get table */
1043  lua_pushvalue(L,2); /* key */
1044  lua_rawget(L,-2);
1045  lua_remove(L,-2); /* stack tidy, remove .get table */
1046  if (lua_iscfunction(L,-1))
1047  { /* found it so call the fn & return its value */
1048  lua_pushvalue(L,1); /* the userdata */
1049  lua_call(L,1,1); /* 1 value in (userdata),1 out (result) */
1050  lua_remove(L,-2); /* stack tidy, remove metatable */
1051  return 1;
1052  }
1053  lua_pop(L,1); /* remove whatever was there */
1054  /* ok, so try the .fn table */
1055  SWIG_Lua_get_table(L,".fn"); /* find the .get table */
1056  assert(lua_istable(L,-1)); /* just in case */
1057  lua_pushvalue(L,2); /* key */
1058  lua_rawget(L,-2); /* look for the fn */
1059  lua_remove(L,-2); /* stack tidy, remove .fn table */
1060  if (lua_isfunction(L,-1)) /* note: if its a C function or lua function */
1061  { /* found it so return the fn & let lua call it */
1062  lua_remove(L,-2); /* stack tidy, remove metatable */
1063  return 1;
1064  }
1065  lua_pop(L,1); /* remove whatever was there */
1066  /* NEW: looks for the __getitem() fn
1067  this is a user provided get fn */
1068  SWIG_Lua_get_table(L,"__getitem"); /* find the __getitem fn */
1069  if (lua_iscfunction(L,-1)) /* if its there */
1070  { /* found it so call the fn & return its value */
1071  lua_pushvalue(L,1); /* the userdata */
1072  lua_pushvalue(L,2); /* the parameter */
1073  lua_call(L,2,1); /* 2 value in (userdata),1 out (result) */
1074  lua_remove(L,-2); /* stack tidy, remove metatable */
1075  return 1;
1076  }
1077  return 0; /* sorry not known */
1078 }
1079 
1080 /* the class.set method, performs the lookup of class attributes */
1082 {
1083 /* there should be 3 params passed in
1084  (1) table (not the meta table)
1085  (2) string name of the attribute
1086  (3) any for the new value
1087 printf("SWIG_Lua_class_set %p(%s) '%s' %p(%s)\n",
1088  lua_topointer(L,1),lua_typename(L,lua_type(L,1)),
1089  lua_tostring(L,2),
1090  lua_topointer(L,3),lua_typename(L,lua_type(L,3)));*/
1091 
1092  assert(lua_isuserdata(L,1)); /* just in case */
1093  lua_getmetatable(L,1); /* get the meta table */
1094  assert(lua_istable(L,-1)); /* just in case */
1095 
1096  SWIG_Lua_get_table(L,".set"); /* find the .set table */
1097  if (lua_istable(L,-1))
1098  {
1099  /* look for the key in the .set table */
1100  lua_pushvalue(L,2); /* key */
1101  lua_rawget(L,-2);
1102  if (lua_iscfunction(L,-1))
1103  { /* found it so call the fn & return its value */
1104  lua_pushvalue(L,1); /* userdata */
1105  lua_pushvalue(L,3); /* value */
1106  lua_call(L,2,0);
1107  return 0;
1108  }
1109  lua_pop(L,1); /* remove the value */
1110  }
1111  lua_pop(L,1); /* remove the value .set table */
1112  /* NEW: looks for the __setitem() fn
1113  this is a user provided set fn */
1114  SWIG_Lua_get_table(L,"__setitem"); /* find the fn */
1115  if (lua_iscfunction(L,-1)) /* if its there */
1116  { /* found it so call the fn & return its value */
1117  lua_pushvalue(L,1); /* the userdata */
1118  lua_pushvalue(L,2); /* the parameter */
1119  lua_pushvalue(L,3); /* the value */
1120  lua_call(L,3,0); /* 3 values in ,0 out */
1121  lua_remove(L,-2); /* stack tidy, remove metatable */
1122  return 1;
1123  }
1124  return 0;
1125 }
1126 
1127 /* the class.destruct method called by the interpreter */
1129 {
1130 /* there should be 1 params passed in
1131  (1) userdata (not the meta table) */
1132  swig_lua_userdata* usr;
1133  swig_lua_class* clss;
1134  assert(lua_isuserdata(L,-1)); /* just in case */
1135  usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */
1136  /* if must be destroyed & has a destructor */
1137  if (usr->own) /* if must be destroyed */
1138  {
1139  clss=(swig_lua_class*)usr->type->clientdata; /* get the class */
1140  if (clss && clss->destructor) /* there is a destroy fn */
1141  {
1142  clss->destructor(usr->ptr); /* bye bye */
1143  }
1144  }
1145  return 0;
1146 }
1147 
1148 /* gets the swig class registry (or creates it) */
1150 {
1151  /* add this all into the swig registry: */
1152  lua_pushstring(L,"SWIG");
1153  lua_rawget(L,LUA_REGISTRYINDEX); /* get the registry */
1154  if (!lua_istable(L,-1)) /* not there */
1155  { /* must be first time, so add it */
1156  lua_pop(L,1); /* remove the result */
1157  lua_pushstring(L,"SWIG");
1158  lua_newtable(L);
1159  lua_rawset(L,LUA_REGISTRYINDEX);
1160  /* then get it */
1161  lua_pushstring(L,"SWIG");
1162  lua_rawget(L,LUA_REGISTRYINDEX);
1163  }
1164 }
1165 
1166 /* helper fn to get the classes metatable from the register */
1168 {
1169  SWIG_Lua_get_class_registry(L); /* get the registry */
1170  lua_pushstring(L,cname); /* get the name */
1171  lua_rawget(L,-2); /* get it */
1172  lua_remove(L,-2); /* tidy up (remove registry) */
1173 }
1174 
1175 /* helper add a variable to a registered class */
1177 {
1178  assert(lua_istable(L,-1)); /* just in case */
1179  SWIG_Lua_get_table(L,".get"); /* find the .get table */
1180  assert(lua_istable(L,-1)); /* just in case */
1181  SWIG_Lua_add_function(L,name,getFn);
1182  lua_pop(L,1); /* tidy stack (remove table) */
1183  if (setFn)
1184  {
1185  SWIG_Lua_get_table(L,".set"); /* find the .set table */
1186  assert(lua_istable(L,-1)); /* just in case */
1187  SWIG_Lua_add_function(L,name,setFn);
1188  lua_pop(L,1); /* tidy stack (remove table) */
1189  }
1190 }
1191 
1192 /* helper to recursively add class details (attributes & operations) */
1194 {
1195  int i;
1196  /* call all the base classes first: we can then override these later: */
1197  for(i=0;clss->bases[i];i++)
1198  {
1199  SWIG_Lua_add_class_details(L,clss->bases[i]);
1200  }
1201  /* add fns */
1202  for(i=0;clss->attributes[i].name;i++){
1204  }
1205  /* add methods to the metatable */
1206  SWIG_Lua_get_table(L,".fn"); /* find the .fn table */
1207  assert(lua_istable(L,-1)); /* just in case */
1208  for(i=0;clss->methods[i].name;i++){
1209  SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].method);
1210  }
1211  lua_pop(L,1); /* tidy stack (remove table) */
1212  /* add operator overloads
1213  these look ANY method which start with "__" and assume they
1214  are operator overloads & add them to the metatable
1215  (this might mess up is someone defines a method __gc (the destructor)*/
1216  for(i=0;clss->methods[i].name;i++){
1217  if (clss->methods[i].name[0]=='_' && clss->methods[i].name[1]=='_'){
1218  SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].method);
1219  }
1220  }
1221 }
1222 
1223 /* set up the base classes pointers.
1224 Each class structure has a list of pointers to the base class structures.
1225 This function fills them.
1226 It cannot be done at compile time, as this will not work with hireachies
1227 spread over more than one swig file.
1228 Therefore it must be done at runtime, querying the SWIG type system.
1229 */
1231 {
1232  int i=0;
1233  swig_module_info* module=SWIG_GetModule(L);
1234  for(i=0;clss->base_names[i];i++)
1235  {
1236  if (clss->bases[i]==0) /* not found yet */
1237  {
1238  /* lookup and cache the base class */
1239  swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]);
1240  if (info) clss->bases[i] = (swig_lua_class *) info->clientdata;
1241  }
1242  }
1243 }
1244 
1245 /* performs the entire class registration process */
1247 {
1248  /* add its constructor to module with the name of the class
1249  so you can do MyClass(...) as well as new_MyClass(...)
1250  BUT only if a constructor is defined
1251  (this overcomes the problem of pure virtual classes without constructors)*/
1252  if (clss->constructor)
1253  SWIG_Lua_add_function(L,clss->name,clss->constructor);
1254 
1255  SWIG_Lua_get_class_registry(L); /* get the registry */
1256  lua_pushstring(L,clss->name); /* get the name */
1257  lua_newtable(L); /* create the metatable */
1258  /* add string of class name called ".type" */
1259  lua_pushstring(L,".type");
1260  lua_pushstring(L,clss->name);
1261  lua_rawset(L,-3);
1262  /* add a table called ".get" */
1263  lua_pushstring(L,".get");
1264  lua_newtable(L);
1265  lua_rawset(L,-3);
1266  /* add a table called ".set" */
1267  lua_pushstring(L,".set");
1268  lua_newtable(L);
1269  lua_rawset(L,-3);
1270  /* add a table called ".fn" */
1271  lua_pushstring(L,".fn");
1272  lua_newtable(L);
1273  lua_rawset(L,-3);
1274  /* add accessor fns for using the .get,.set&.fn */
1276  SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set);
1278  /* add it */
1279  lua_rawset(L,-3); /* metatable into registry */
1280  lua_pop(L,1); /* tidy stack (remove registry) */
1281 
1283  SWIG_Lua_add_class_details(L,clss); /* recursive adding of details (atts & ops) */
1284  lua_pop(L,1); /* tidy stack (remove class metatable) */
1285 }
1286 
1287 /* -----------------------------------------------------------------------------
1288  * Class/structure conversion fns
1289  * ----------------------------------------------------------------------------- */
1290 
1291 /* helper to add metatable to new lua object */
1293 {
1294  if (type->clientdata) /* there is clientdata: so add the metatable */
1295  {
1297  if (lua_istable(L,-1))
1298  {
1299  lua_setmetatable(L,-2);
1300  }
1301  else
1302  {
1303  lua_pop(L,1);
1304  }
1305  }
1306 }
1307 
1308 /* pushes a new object into the lua stack */
1310 {
1311  swig_lua_userdata* usr;
1312  if (!ptr){
1313  lua_pushnil(L);
1314  return;
1315  }
1316  usr=(swig_lua_userdata*)lua_newuserdata(L,sizeof(swig_lua_userdata)); /* get data */
1317  usr->ptr=ptr; /* set the ptr */
1318  usr->type=type;
1319  usr->own=own;
1320  _SWIG_Lua_AddMetatable(L,type); /* add metatable */
1321 }
1322 
1323 /* takes a object from the lua stack & converts it into an object of the correct type
1324  (if possible) */
1325 SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags)
1326 {
1327  swig_lua_userdata* usr;
1328  swig_cast_info *cast;
1329  if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;} /* special case: lua nil => NULL pointer */
1330  usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */
1331  if (usr)
1332  {
1333  if (flags & SWIG_POINTER_DISOWN) /* must disown the object */
1334  {
1335  usr->own=0;
1336  }
1337  if (!type) /* special cast void*, no casting fn */
1338  {
1339  *ptr=usr->ptr;
1340  return SWIG_OK; /* ok */
1341  }
1342  cast=SWIG_TypeCheckStruct(usr->type,type); /* performs normal type checking */
1343  if (cast)
1344  {
1345  int newmemory = 0;
1346  *ptr=SWIG_TypeCast(cast,usr->ptr,&newmemory);
1347  assert(!newmemory); /* newmemory handling not yet implemented */
1348  return SWIG_OK; /* ok */
1349  }
1350  }
1351  return SWIG_ERROR; /* error */
1352 }
1353 
1354 SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State* L,int index,swig_type_info *type,int flags,
1355  int argnum,const char* func_name){
1356  void* result;
1357  if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){
1358  lua_pushfstring(L,"Error in %s, expected a %s at argument number %d\n",
1359  func_name,(type && type->str)?type->str:"void*",argnum);
1360  lua_error(L);
1361  }
1362  return result;
1363 }
1364 
1365 /* pushes a packed userdata. user for member fn pointers only */
1366 SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State* L,void* ptr,size_t size,swig_type_info *type)
1367 {
1368  swig_lua_rawdata* raw;
1369  assert(ptr); /* not acceptable to pass in a NULL value */
1370  raw=(swig_lua_rawdata*)lua_newuserdata(L,sizeof(swig_lua_rawdata)-1+size); /* alloc data */
1371  raw->type=type;
1372  raw->own=0;
1373  memcpy(raw->data,ptr,size); /* copy the data */
1374  _SWIG_Lua_AddMetatable(L,type); /* add metatable */
1375 }
1376 
1377 /* converts a packed userdata. user for member fn pointers only */
1378 SWIGRUNTIME int SWIG_Lua_ConvertPacked(lua_State* L,int index,void* ptr,size_t size,swig_type_info *type)
1379 {
1380  swig_lua_rawdata* raw;
1381  raw=(swig_lua_rawdata*)lua_touserdata(L,index); /* get data */
1382  if (!raw) return SWIG_ERROR; /* error */
1383  if (type==0 || type==raw->type) /* void* or identical type */
1384  {
1385  memcpy(ptr,raw->data,size); /* copy it */
1386  return SWIG_OK; /* ok */
1387  }
1388  return SWIG_ERROR; /* error */
1389 }
1390 
1391 /* a function to get the typestring of a piece of data */
1392 SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp)
1393 {
1394  swig_lua_userdata* usr;
1395  if (lua_isuserdata(L,tp))
1396  {
1397  usr=(swig_lua_userdata*)lua_touserdata(L,tp); /* get data */
1398  if (usr && usr->type && usr->type->str)
1399  return usr->type->str;
1400  return "userdata (unknown type)";
1401  }
1402  return lua_typename(L,lua_type(L,tp));
1403 }
1404 
1405 /* lua callable function to get the userdata's type */
1407 {
1408  lua_pushstring(L,SWIG_Lua_typename(L,1));
1409  return 1;
1410 }
1411 
1412 /* lua callable function to compare userdata's value
1413 the issue is that two userdata may point to the same thing
1414 but to lua, they are different objects */
1416 {
1417  int result;
1418  swig_lua_userdata *usr1,*usr2;
1419  if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2)) /* just in case */
1420  return 0; /* nil reply */
1421  usr1=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */
1422  usr2=(swig_lua_userdata*)lua_touserdata(L,2); /* get data */
1423  /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/
1424  result=(usr1->ptr==usr2->ptr);
1425  lua_pushboolean(L,result);
1426  return 1;
1427 }
1428 
1429 /* -----------------------------------------------------------------------------
1430  * global variable support code: class/struct typemap functions
1431  * ----------------------------------------------------------------------------- */
1432 
1433 /* Install Constants */
1434 SWIGINTERN void
1436  int i;
1437  for (i = 0; constants[i].type; i++) {
1438  switch(constants[i].type) {
1439  case SWIG_LUA_INT:
1440  lua_pushstring(L,constants[i].name);
1441  lua_pushnumber(L,(lua_Number)constants[i].lvalue);
1442  lua_rawset(L,-3);
1443  break;
1444  case SWIG_LUA_FLOAT:
1445  lua_pushstring(L,constants[i].name);
1446  lua_pushnumber(L,(lua_Number)constants[i].dvalue);
1447  lua_rawset(L,-3);
1448  break;
1449  case SWIG_LUA_CHAR:
1450  lua_pushstring(L,constants[i].name);
1451  lua_pushfstring(L,"%c",(char)constants[i].lvalue);
1452  lua_rawset(L,-3);
1453  break;
1454  case SWIG_LUA_STRING:
1455  lua_pushstring(L,constants[i].name);
1456  lua_pushstring(L,(char *) constants[i].pvalue);
1457  lua_rawset(L,-3);
1458  break;
1459  case SWIG_LUA_POINTER:
1460  lua_pushstring(L,constants[i].name);
1461  SWIG_NewPointerObj(L,constants[i].pvalue, *(constants[i]).ptype,0);
1462  lua_rawset(L,-3);
1463  break;
1464  case SWIG_LUA_BINARY:
1465  lua_pushstring(L,constants[i].name);
1466  SWIG_NewMemberObj(L,constants[i].pvalue,constants[i].lvalue,*(constants[i]).ptype);
1467  lua_rawset(L,-3);
1468  break;
1469  default:
1470  break;
1471  }
1472  }
1473 }
1474 
1475 /* -----------------------------------------------------------------------------
1476  * executing lua code from within the wrapper
1477  * ----------------------------------------------------------------------------- */
1478 
1479 #ifndef SWIG_DOSTRING_FAIL /* Allows redefining of error function */
1480 #define SWIG_DOSTRING_FAIL(S) fprintf(stderr,"%s\n",S)
1481 #endif
1482 /* Executes a C string in Lua a really simple way of calling lua from C
1483 Unfortunately lua keeps changing its API's, so we need a conditional compile
1484 In lua 5.0.X its lua_dostring()
1485 In lua 5.1.X its luaL_dostring()
1486 */
1487 SWIGINTERN int
1488 SWIG_Lua_dostring(lua_State *L, const char* str) {
1489  int ok,top;
1490  if (str==0 || str[0]==0) return 0; /* nothing to do */
1491  top=lua_gettop(L); /* save stack */
1492 #if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501))
1493  ok=luaL_dostring(L,str); /* looks like this is lua 5.1.X or later, good */
1494 #else
1495  ok=lua_dostring(L,str); /* might be lua 5.0.x, using lua_dostring */
1496 #endif
1497  if (ok!=0) {
1498  SWIG_DOSTRING_FAIL(lua_tostring(L,-1));
1499  }
1500  lua_settop(L,top); /* restore the stack */
1501  return ok;
1502 }
1503 
1504 #ifdef __cplusplus
1505 }
1506 #endif
1507 
1508 /* ------------------------------ end luarun.swg ------------------------------ */
1509 /* -----------------------------------------------------------------------------*
1510  Standard SWIG API for use inside user code.
1511 
1512  Don't include this file directly, run the command
1513  swig -python -external-runtime
1514  Also, read the Modules chapter of the SWIG Manual.
1515 
1516  * -----------------------------------------------------------------------------*/
1517 
1518 #ifdef SWIG_MODULE_CLIENTDATA_TYPE
1519 
1521 SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) {
1522  swig_module_info *module = SWIG_GetModule(clientdata);
1523  return SWIG_TypeQueryModule(module, module, name);
1524 }
1525 
1528  swig_module_info *module = SWIG_GetModule(clientdata);
1529  return SWIG_MangledTypeQueryModule(module, module, name);
1530 }
1531 
1532 #else
1533 
1535 SWIG_TypeQuery(const char *name) {
1536  swig_module_info *module = SWIG_GetModule(NULL);
1537  return SWIG_TypeQueryModule(module, module, name);
1538 }
1539 
1541 SWIG_MangledTypeQuery(const char *name) {
1542  swig_module_info *module = SWIG_GetModule(NULL);
1543  return SWIG_MangledTypeQueryModule(module, module, name);
1544 }
1545 
1546 #endif