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