1/* ----------------------------------------------------------------------------
2 * This file was automatically generated by SWIG (http://www.swig.org).
3 * Version 3.0.12
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 defined(__GNUC__)
79#  if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
80#    ifndef GCC_HASCLASSVISIBILITY
81#      define GCC_HASCLASSVISIBILITY
82#    endif
83#  endif
84#endif
85
86#ifndef SWIGEXPORT
87# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
88#   if defined(STATIC_LINKED)
89#     define SWIGEXPORT
90#   else
91#     define SWIGEXPORT __declspec(dllexport)
92#   endif
93# else
94#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
95#     define SWIGEXPORT __attribute__ ((visibility("default")))
96#   else
97#     define SWIGEXPORT
98#   endif
99# endif
100#endif
101
102/* calling conventions for Windows */
103#ifndef SWIGSTDCALL
104# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
105#   define SWIGSTDCALL __stdcall
106# else
107#   define SWIGSTDCALL
108# endif
109#endif
110
111/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
112#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
113# define _CRT_SECURE_NO_DEPRECATE
114#endif
115
116/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
117#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
118# define _SCL_SECURE_NO_DEPRECATE
119#endif
120
121/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
122#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
123# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
124#endif
125
126/* Intel's compiler complains if a variable which was never initialised is
127 * cast to void, which is a common idiom which we use to indicate that we
128 * are aware a variable isn't used.  So we just silence that warning.
129 * See: https://github.com/swig/swig/issues/192 for more discussion.
130 */
131#ifdef __INTEL_COMPILER
132# pragma warning disable 592
133#endif
134/*  Errors in SWIG */
135#define  SWIG_UnknownError    	   -1
136#define  SWIG_IOError        	   -2
137#define  SWIG_RuntimeError   	   -3
138#define  SWIG_IndexError     	   -4
139#define  SWIG_TypeError      	   -5
140#define  SWIG_DivisionByZero 	   -6
141#define  SWIG_OverflowError  	   -7
142#define  SWIG_SyntaxError    	   -8
143#define  SWIG_ValueError     	   -9
144#define  SWIG_SystemError    	   -10
145#define  SWIG_AttributeError 	   -11
146#define  SWIG_MemoryError    	   -12
147#define  SWIG_NullReferenceError   -13
148
149
150/* -----------------------------------------------------------------------------
151 * swigrun.swg
152 *
153 * This file contains generic C API SWIG runtime support for pointer
154 * type checking.
155 * ----------------------------------------------------------------------------- */
156
157/* This should only be incremented when either the layout of swig_type_info changes,
158   or for whatever reason, the runtime changes incompatibly */
159#define SWIG_RUNTIME_VERSION "4"
160
161/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
162#ifdef SWIG_TYPE_TABLE
163# define SWIG_QUOTE_STRING(x) #x
164# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
165# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
166#else
167# define SWIG_TYPE_TABLE_NAME
168#endif
169
170/*
171  You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
172  creating a static or dynamic library from the SWIG runtime code.
173  In 99.9% of the cases, SWIG just needs to declare them as 'static'.
174
175  But only do this if strictly necessary, ie, if you have problems
176  with your compiler or suchlike.
177*/
178
179#ifndef SWIGRUNTIME
180# define SWIGRUNTIME SWIGINTERN
181#endif
182
183#ifndef SWIGRUNTIMEINLINE
184# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
185#endif
186
187/*  Generic buffer size */
188#ifndef SWIG_BUFFER_SIZE
189# define SWIG_BUFFER_SIZE 1024
190#endif
191
192/* Flags for pointer conversions */
193#define SWIG_POINTER_DISOWN        0x1
194#define SWIG_CAST_NEW_MEMORY       0x2
195
196/* Flags for new pointer objects */
197#define SWIG_POINTER_OWN           0x1
198
199
200/*
201   Flags/methods for returning states.
202
203   The SWIG conversion methods, as ConvertPtr, return an integer
204   that tells if the conversion was successful or not. And if not,
205   an error code can be returned (see swigerrors.swg for the codes).
206
207   Use the following macros/flags to set or process the returning
208   states.
209
210   In old versions of SWIG, code such as the following was usually written:
211
212     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
213       // success code
214     } else {
215       //fail code
216     }
217
218   Now you can be more explicit:
219
220    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
221    if (SWIG_IsOK(res)) {
222      // success code
223    } else {
224      // fail code
225    }
226
227   which is the same really, but now you can also do
228
229    Type *ptr;
230    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
231    if (SWIG_IsOK(res)) {
232      // success code
233      if (SWIG_IsNewObj(res) {
234        ...
235	delete *ptr;
236      } else {
237        ...
238      }
239    } else {
240      // fail code
241    }
242
243   I.e., now SWIG_ConvertPtr can return new objects and you can
244   identify the case and take care of the deallocation. Of course that
245   also requires SWIG_ConvertPtr to return new result values, such as
246
247      int SWIG_ConvertPtr(obj, ptr,...) {
248        if (<obj is ok>) {
249          if (<need new object>) {
250            *ptr = <ptr to new allocated object>;
251            return SWIG_NEWOBJ;
252          } else {
253            *ptr = <ptr to old object>;
254            return SWIG_OLDOBJ;
255          }
256        } else {
257          return SWIG_BADOBJ;
258        }
259      }
260
261   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
262   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
263   SWIG errors code.
264
265   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
266   allows to return the 'cast rank', for example, if you have this
267
268       int food(double)
269       int fooi(int);
270
271   and you call
272
273      food(1)   // cast rank '1'  (1 -> 1.0)
274      fooi(1)   // cast rank '0'
275
276   just use the SWIG_AddCast()/SWIG_CheckState()
277*/
278
279#define SWIG_OK                    (0)
280#define SWIG_ERROR                 (-1)
281#define SWIG_IsOK(r)               (r >= 0)
282#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)
283
284/* The CastRankLimit says how many bits are used for the cast rank */
285#define SWIG_CASTRANKLIMIT         (1 << 8)
286/* The NewMask denotes the object was created (using new/malloc) */
287#define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
288/* The TmpMask is for in/out typemaps that use temporal objects */
289#define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
290/* Simple returning values */
291#define SWIG_BADOBJ                (SWIG_ERROR)
292#define SWIG_OLDOBJ                (SWIG_OK)
293#define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
294#define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
295/* Check, add and del mask methods */
296#define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
297#define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
298#define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
299#define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
300#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
301#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
302
303/* Cast-Rank Mode */
304#if defined(SWIG_CASTRANK_MODE)
305#  ifndef SWIG_TypeRank
306#    define SWIG_TypeRank             unsigned long
307#  endif
308#  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
309#    define SWIG_MAXCASTRANK          (2)
310#  endif
311#  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
312#  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
313SWIGINTERNINLINE int SWIG_AddCast(int r) {
314  return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
315}
316SWIGINTERNINLINE int SWIG_CheckState(int r) {
317  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
318}
319#else /* no cast-rank mode */
320#  define SWIG_AddCast(r) (r)
321#  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
322#endif
323
324
325#include <string.h>
326
327#ifdef __cplusplus
328extern "C" {
329#endif
330
331typedef void *(*swig_converter_func)(void *, int *);
332typedef struct swig_type_info *(*swig_dycast_func)(void **);
333
334/* Structure to store information on one type */
335typedef struct swig_type_info {
336  const char             *name;			/* mangled name of this type */
337  const char             *str;			/* human readable name of this type */
338  swig_dycast_func        dcast;		/* dynamic cast function down a hierarchy */
339  struct swig_cast_info  *cast;			/* linked list of types that can cast into this type */
340  void                   *clientdata;		/* language specific type data */
341  int                    owndata;		/* flag if the structure owns the clientdata */
342} swig_type_info;
343
344/* Structure to store a type and conversion function used for casting */
345typedef struct swig_cast_info {
346  swig_type_info         *type;			/* pointer to type that is equivalent to this type */
347  swig_converter_func     converter;		/* function to cast the void pointers */
348  struct swig_cast_info  *next;			/* pointer to next cast in linked list */
349  struct swig_cast_info  *prev;			/* pointer to the previous cast */
350} swig_cast_info;
351
352/* Structure used to store module information
353 * Each module generates one structure like this, and the runtime collects
354 * all of these structures and stores them in a circularly linked list.*/
355typedef struct swig_module_info {
356  swig_type_info         **types;		/* Array of pointers to swig_type_info structures that are in this module */
357  size_t                 size;		        /* Number of types in this module */
358  struct swig_module_info *next;		/* Pointer to next element in circularly linked list */
359  swig_type_info         **type_initial;	/* Array of initially generated type structures */
360  swig_cast_info         **cast_initial;	/* Array of initially generated casting structures */
361  void                    *clientdata;		/* Language specific module data */
362} swig_module_info;
363
364/*
365  Compare two type names skipping the space characters, therefore
366  "char*" == "char *" and "Class<int>" == "Class<int >", etc.
367
368  Return 0 when the two name types are equivalent, as in
369  strncmp, but skipping ' '.
370*/
371SWIGRUNTIME int
372SWIG_TypeNameComp(const char *f1, const char *l1,
373		  const char *f2, const char *l2) {
374  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
375    while ((*f1 == ' ') && (f1 != l1)) ++f1;
376    while ((*f2 == ' ') && (f2 != l2)) ++f2;
377    if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
378  }
379  return (int)((l1 - f1) - (l2 - f2));
380}
381
382/*
383  Check type equivalence in a name list like <name1>|<name2>|...
384  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
385*/
386SWIGRUNTIME int
387SWIG_TypeCmp(const char *nb, const char *tb) {
388  int equiv = 1;
389  const char* te = tb + strlen(tb);
390  const char* ne = nb;
391  while (equiv != 0 && *ne) {
392    for (nb = ne; *ne; ++ne) {
393      if (*ne == '|') break;
394    }
395    equiv = SWIG_TypeNameComp(nb, ne, tb, te);
396    if (*ne) ++ne;
397  }
398  return equiv;
399}
400
401/*
402  Check type equivalence in a name list like <name1>|<name2>|...
403  Return 0 if not equal, 1 if equal
404*/
405SWIGRUNTIME int
406SWIG_TypeEquiv(const char *nb, const char *tb) {
407  return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
408}
409
410/*
411  Check the typename
412*/
413SWIGRUNTIME swig_cast_info *
414SWIG_TypeCheck(const char *c, swig_type_info *ty) {
415  if (ty) {
416    swig_cast_info *iter = ty->cast;
417    while (iter) {
418      if (strcmp(iter->type->name, c) == 0) {
419        if (iter == ty->cast)
420          return iter;
421        /* Move iter to the top of the linked list */
422        iter->prev->next = iter->next;
423        if (iter->next)
424          iter->next->prev = iter->prev;
425        iter->next = ty->cast;
426        iter->prev = 0;
427        if (ty->cast) ty->cast->prev = iter;
428        ty->cast = iter;
429        return iter;
430      }
431      iter = iter->next;
432    }
433  }
434  return 0;
435}
436
437/*
438  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
439*/
440SWIGRUNTIME swig_cast_info *
441SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
442  if (ty) {
443    swig_cast_info *iter = ty->cast;
444    while (iter) {
445      if (iter->type == from) {
446        if (iter == ty->cast)
447          return iter;
448        /* Move iter to the top of the linked list */
449        iter->prev->next = iter->next;
450        if (iter->next)
451          iter->next->prev = iter->prev;
452        iter->next = ty->cast;
453        iter->prev = 0;
454        if (ty->cast) ty->cast->prev = iter;
455        ty->cast = iter;
456        return iter;
457      }
458      iter = iter->next;
459    }
460  }
461  return 0;
462}
463
464/*
465  Cast a pointer up an inheritance hierarchy
466*/
467SWIGRUNTIMEINLINE void *
468SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
469  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
470}
471
472/*
473   Dynamic pointer casting. Down an inheritance hierarchy
474*/
475SWIGRUNTIME swig_type_info *
476SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
477  swig_type_info *lastty = ty;
478  if (!ty || !ty->dcast) return ty;
479  while (ty && (ty->dcast)) {
480    ty = (*ty->dcast)(ptr);
481    if (ty) lastty = ty;
482  }
483  return lastty;
484}
485
486/*
487  Return the name associated with this type
488*/
489SWIGRUNTIMEINLINE const char *
490SWIG_TypeName(const swig_type_info *ty) {
491  return ty->name;
492}
493
494/*
495  Return the pretty name associated with this type,
496  that is an unmangled type name in a form presentable to the user.
497*/
498SWIGRUNTIME const char *
499SWIG_TypePrettyName(const swig_type_info *type) {
500  /* The "str" field contains the equivalent pretty names of the
501     type, separated by vertical-bar characters.  We choose
502     to print the last name, as it is often (?) the most
503     specific. */
504  if (!type) return NULL;
505  if (type->str != NULL) {
506    const char *last_name = type->str;
507    const char *s;
508    for (s = type->str; *s; s++)
509      if (*s == '|') last_name = s+1;
510    return last_name;
511  }
512  else
513    return type->name;
514}
515
516/*
517   Set the clientdata field for a type
518*/
519SWIGRUNTIME void
520SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
521  swig_cast_info *cast = ti->cast;
522  /* if (ti->clientdata == clientdata) return; */
523  ti->clientdata = clientdata;
524
525  while (cast) {
526    if (!cast->converter) {
527      swig_type_info *tc = cast->type;
528      if (!tc->clientdata) {
529	SWIG_TypeClientData(tc, clientdata);
530      }
531    }
532    cast = cast->next;
533  }
534}
535SWIGRUNTIME void
536SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
537  SWIG_TypeClientData(ti, clientdata);
538  ti->owndata = 1;
539}
540
541/*
542  Search for a swig_type_info structure only by mangled name
543  Search is a O(log #types)
544
545  We start searching at module start, and finish searching when start == end.
546  Note: if start == end at the beginning of the function, we go all the way around
547  the circular list.
548*/
549SWIGRUNTIME swig_type_info *
550SWIG_MangledTypeQueryModule(swig_module_info *start,
551                            swig_module_info *end,
552		            const char *name) {
553  swig_module_info *iter = start;
554  do {
555    if (iter->size) {
556      size_t l = 0;
557      size_t r = iter->size - 1;
558      do {
559	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
560	size_t i = (l + r) >> 1;
561	const char *iname = iter->types[i]->name;
562	if (iname) {
563	  int compare = strcmp(name, iname);
564	  if (compare == 0) {
565	    return iter->types[i];
566	  } else if (compare < 0) {
567	    if (i) {
568	      r = i - 1;
569	    } else {
570	      break;
571	    }
572	  } else if (compare > 0) {
573	    l = i + 1;
574	  }
575	} else {
576	  break; /* should never happen */
577	}
578      } while (l <= r);
579    }
580    iter = iter->next;
581  } while (iter != end);
582  return 0;
583}
584
585/*
586  Search for a swig_type_info structure for either a mangled name or a human readable name.
587  It first searches the mangled names of the types, which is a O(log #types)
588  If a type is not found it then searches the human readable names, which is O(#types).
589
590  We start searching at module start, and finish searching when start == end.
591  Note: if start == end at the beginning of the function, we go all the way around
592  the circular list.
593*/
594SWIGRUNTIME swig_type_info *
595SWIG_TypeQueryModule(swig_module_info *start,
596                     swig_module_info *end,
597		     const char *name) {
598  /* STEP 1: Search the name field using binary search */
599  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
600  if (ret) {
601    return ret;
602  } else {
603    /* STEP 2: If the type hasn't been found, do a complete search
604       of the str field (the human readable name) */
605    swig_module_info *iter = start;
606    do {
607      size_t i = 0;
608      for (; i < iter->size; ++i) {
609	if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
610	  return iter->types[i];
611      }
612      iter = iter->next;
613    } while (iter != end);
614  }
615
616  /* neither found a match */
617  return 0;
618}
619
620/*
621   Pack binary data into a string
622*/
623SWIGRUNTIME char *
624SWIG_PackData(char *c, void *ptr, size_t sz) {
625  static const char hex[17] = "0123456789abcdef";
626  const unsigned char *u = (unsigned char *) ptr;
627  const unsigned char *eu =  u + sz;
628  for (; u != eu; ++u) {
629    unsigned char uu = *u;
630    *(c++) = hex[(uu & 0xf0) >> 4];
631    *(c++) = hex[uu & 0xf];
632  }
633  return c;
634}
635
636/*
637   Unpack binary data from a string
638*/
639SWIGRUNTIME const char *
640SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
641  unsigned char *u = (unsigned char *) ptr;
642  const unsigned char *eu = u + sz;
643  for (; u != eu; ++u) {
644    char d = *(c++);
645    unsigned char uu;
646    if ((d >= '0') && (d <= '9'))
647      uu = (unsigned char)((d - '0') << 4);
648    else if ((d >= 'a') && (d <= 'f'))
649      uu = (unsigned char)((d - ('a'-10)) << 4);
650    else
651      return (char *) 0;
652    d = *(c++);
653    if ((d >= '0') && (d <= '9'))
654      uu |= (unsigned char)(d - '0');
655    else if ((d >= 'a') && (d <= 'f'))
656      uu |= (unsigned char)(d - ('a'-10));
657    else
658      return (char *) 0;
659    *u = uu;
660  }
661  return c;
662}
663
664/*
665   Pack 'void *' into a string buffer.
666*/
667SWIGRUNTIME char *
668SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
669  char *r = buff;
670  if ((2*sizeof(void *) + 2) > bsz) return 0;
671  *(r++) = '_';
672  r = SWIG_PackData(r,&ptr,sizeof(void *));
673  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
674  strcpy(r,name);
675  return buff;
676}
677
678SWIGRUNTIME const char *
679SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
680  if (*c != '_') {
681    if (strcmp(c,"NULL") == 0) {
682      *ptr = (void *) 0;
683      return name;
684    } else {
685      return 0;
686    }
687  }
688  return SWIG_UnpackData(++c,ptr,sizeof(void *));
689}
690
691SWIGRUNTIME char *
692SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
693  char *r = buff;
694  size_t lname = (name ? strlen(name) : 0);
695  if ((2*sz + 2 + lname) > bsz) return 0;
696  *(r++) = '_';
697  r = SWIG_PackData(r,ptr,sz);
698  if (lname) {
699    strncpy(r,name,lname+1);
700  } else {
701    *r = 0;
702  }
703  return buff;
704}
705
706SWIGRUNTIME const char *
707SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
708  if (*c != '_') {
709    if (strcmp(c,"NULL") == 0) {
710      memset(ptr,0,sz);
711      return name;
712    } else {
713      return 0;
714    }
715  }
716  return SWIG_UnpackData(++c,ptr,sz);
717}
718
719#ifdef __cplusplus
720}
721#endif
722#include <ruby.h>
723
724/* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which
725 * breaks using rb_intern as an lvalue, as SWIG does.  We work around this
726 * issue for now by disabling this.
727 * https://sourceforge.net/tracker/?func=detail&aid=2859614&group_id=1645&atid=101645
728 */
729#ifdef rb_intern
730# undef rb_intern
731#endif
732
733/* Remove global macros defined in Ruby's win32.h */
734#ifdef write
735# undef write
736#endif
737#ifdef read
738# undef read
739#endif
740#ifdef bind
741# undef bind
742#endif
743#ifdef close
744# undef close
745#endif
746#ifdef connect
747# undef connect
748#endif
749
750
751/* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */
752#ifndef NUM2LL
753#define NUM2LL(x) NUM2LONG((x))
754#endif
755#ifndef LL2NUM
756#define LL2NUM(x) INT2NUM((long) (x))
757#endif
758#ifndef ULL2NUM
759#define ULL2NUM(x) UINT2NUM((unsigned long) (x))
760#endif
761
762/* Ruby 1.7 doesn't (yet) define NUM2ULL() */
763#ifndef NUM2ULL
764#ifdef HAVE_LONG_LONG
765#define NUM2ULL(x) rb_num2ull((x))
766#else
767#define NUM2ULL(x) NUM2ULONG(x)
768#endif
769#endif
770
771/* RSTRING_LEN, etc are new in Ruby 1.9, but ->ptr and ->len no longer work */
772/* Define these for older versions so we can just write code the new way */
773#ifndef RSTRING_LEN
774# define RSTRING_LEN(x) RSTRING(x)->len
775#endif
776#ifndef RSTRING_PTR
777# define RSTRING_PTR(x) RSTRING(x)->ptr
778#endif
779#ifndef RSTRING_END
780# define RSTRING_END(x) (RSTRING_PTR(x) + RSTRING_LEN(x))
781#endif
782#ifndef RARRAY_LEN
783# define RARRAY_LEN(x) RARRAY(x)->len
784#endif
785#ifndef RARRAY_PTR
786# define RARRAY_PTR(x) RARRAY(x)->ptr
787#endif
788#ifndef RFLOAT_VALUE
789# define RFLOAT_VALUE(x) RFLOAT(x)->value
790#endif
791#ifndef DOUBLE2NUM
792# define DOUBLE2NUM(x) rb_float_new(x)
793#endif
794#ifndef RHASH_TBL
795# define RHASH_TBL(x) (RHASH(x)->tbl)
796#endif
797#ifndef RHASH_ITER_LEV
798# define RHASH_ITER_LEV(x) (RHASH(x)->iter_lev)
799#endif
800#ifndef RHASH_IFNONE
801# define RHASH_IFNONE(x) (RHASH(x)->ifnone)
802#endif
803#ifndef RHASH_SIZE
804# define RHASH_SIZE(x) (RHASH(x)->tbl->num_entries)
805#endif
806#ifndef RHASH_EMPTY_P
807# define RHASH_EMPTY_P(x) (RHASH_SIZE(x) == 0)
808#endif
809#ifndef RSTRUCT_LEN
810# define RSTRUCT_LEN(x) RSTRUCT(x)->len
811#endif
812#ifndef RSTRUCT_PTR
813# define RSTRUCT_PTR(x) RSTRUCT(x)->ptr
814#endif
815
816
817
818/*
819 * Need to be very careful about how these macros are defined, especially
820 * when compiling C++ code or C code with an ANSI C compiler.
821 *
822 * VALUEFUNC(f) is a macro used to typecast a C function that implements
823 * a Ruby method so that it can be passed as an argument to API functions
824 * like rb_define_method() and rb_define_singleton_method().
825 *
826 * VOIDFUNC(f) is a macro used to typecast a C function that implements
827 * either the "mark" or "free" stuff for a Ruby Data object, so that it
828 * can be passed as an argument to API functions like Data_Wrap_Struct()
829 * and Data_Make_Struct().
830 */
831
832#ifdef __cplusplus
833#  ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */
834#    define PROTECTFUNC(f) ((VALUE (*)()) f)
835#    define VALUEFUNC(f) ((VALUE (*)()) f)
836#    define VOIDFUNC(f)  ((void (*)()) f)
837#  else
838#    ifndef ANYARGS /* These definitions should work for Ruby 1.6 */
839#      define PROTECTFUNC(f) ((VALUE (*)()) f)
840#      define VALUEFUNC(f) ((VALUE (*)()) f)
841#      define VOIDFUNC(f)  ((RUBY_DATA_FUNC) f)
842#    else /* These definitions should work for Ruby 1.7+ */
843#      define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
844#      define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
845#      define VOIDFUNC(f)  ((RUBY_DATA_FUNC) f)
846#    endif
847#  endif
848#else
849#  define VALUEFUNC(f) (f)
850#  define VOIDFUNC(f) (f)
851#endif
852
853/* Don't use for expressions have side effect */
854#ifndef RB_STRING_VALUE
855#define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s)))
856#endif
857#ifndef StringValue
858#define StringValue(s) RB_STRING_VALUE(s)
859#endif
860#ifndef StringValuePtr
861#define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s))
862#endif
863#ifndef StringValueLen
864#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
865#endif
866#ifndef SafeStringValue
867#define SafeStringValue(v) do {\
868    StringValue(v);\
869    rb_check_safe_str(v);\
870} while (0)
871#endif
872
873#ifndef HAVE_RB_DEFINE_ALLOC_FUNC
874#define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1)
875#define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new")
876#endif
877
878static VALUE _mSWIG = Qnil;
879/* -----------------------------------------------------------------------------
880 * error manipulation
881 * ----------------------------------------------------------------------------- */
882
883
884/* Define some additional error types */
885#define SWIG_ObjectPreviouslyDeletedError  -100
886
887
888/* Define custom exceptions for errors that do not map to existing Ruby
889   exceptions.  Note this only works for C++ since a global cannot be
890   initialized by a function in C.  For C, fallback to rb_eRuntimeError.*/
891
892SWIGINTERN VALUE
893getNullReferenceError(void) {
894  static int init = 0;
895  static VALUE rb_eNullReferenceError ;
896  if (!init) {
897    init = 1;
898    rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError);
899  }
900  return rb_eNullReferenceError;
901}
902
903SWIGINTERN VALUE
904getObjectPreviouslyDeletedError(void) {
905  static int init = 0;
906  static VALUE rb_eObjectPreviouslyDeleted ;
907  if (!init) {
908    init = 1;
909    rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError);
910  }
911  return rb_eObjectPreviouslyDeleted;
912}
913
914
915SWIGINTERN VALUE
916SWIG_Ruby_ErrorType(int SWIG_code) {
917  VALUE type;
918  switch (SWIG_code) {
919  case SWIG_MemoryError:
920    type = rb_eNoMemError;
921    break;
922  case SWIG_IOError:
923    type = rb_eIOError;
924    break;
925  case SWIG_RuntimeError:
926    type = rb_eRuntimeError;
927    break;
928  case SWIG_IndexError:
929    type = rb_eIndexError;
930    break;
931  case SWIG_TypeError:
932    type = rb_eTypeError;
933    break;
934  case SWIG_DivisionByZero:
935    type = rb_eZeroDivError;
936    break;
937  case SWIG_OverflowError:
938    type = rb_eRangeError;
939    break;
940  case SWIG_SyntaxError:
941    type = rb_eSyntaxError;
942    break;
943  case SWIG_ValueError:
944    type = rb_eArgError;
945    break;
946  case SWIG_SystemError:
947    type = rb_eFatal;
948    break;
949  case SWIG_AttributeError:
950    type = rb_eRuntimeError;
951    break;
952  case SWIG_NullReferenceError:
953    type = getNullReferenceError();
954    break;
955  case SWIG_ObjectPreviouslyDeletedError:
956    type = getObjectPreviouslyDeletedError();
957    break;
958  case SWIG_UnknownError:
959    type = rb_eRuntimeError;
960    break;
961  default:
962    type = rb_eRuntimeError;
963  }
964  return type;
965}
966
967
968/* This function is called when a user inputs a wrong argument to
969   a method.
970 */
971SWIGINTERN
972const char* Ruby_Format_TypeError( const char* msg,
973				   const char* type,
974				   const char* name,
975				   const int argn,
976				   VALUE input )
977{
978  char buf[128];
979  VALUE str;
980  VALUE asStr;
981  if ( msg && *msg )
982    {
983      str = rb_str_new2(msg);
984    }
985  else
986    {
987      str = rb_str_new(NULL, 0);
988    }
989
990  str = rb_str_cat2( str, "Expected argument " );
991  sprintf( buf, "%d of type ", argn-1 );
992  str = rb_str_cat2( str, buf );
993  str = rb_str_cat2( str, type );
994  str = rb_str_cat2( str, ", but got " );
995  str = rb_str_cat2( str, rb_obj_classname(input) );
996  str = rb_str_cat2( str, " " );
997  asStr = rb_inspect(input);
998  if ( RSTRING_LEN(asStr) > 30 )
999    {
1000      str = rb_str_cat( str, StringValuePtr(asStr), 30 );
1001      str = rb_str_cat2( str, "..." );
1002    }
1003  else
1004    {
1005      str = rb_str_append( str, asStr );
1006    }
1007
1008  if ( name )
1009    {
1010      str = rb_str_cat2( str, "\n\tin SWIG method '" );
1011      str = rb_str_cat2( str, name );
1012      str = rb_str_cat2( str, "'" );
1013    }
1014
1015  return StringValuePtr( str );
1016}
1017
1018/* This function is called when an overloaded method fails */
1019SWIGINTERN
1020void Ruby_Format_OverloadedError(
1021				 const int argc,
1022				 const int maxargs,
1023				 const char* method,
1024				 const char* prototypes
1025				 )
1026{
1027  const char* msg = "Wrong # of arguments";
1028  if ( argc <= maxargs ) msg = "Wrong arguments";
1029  rb_raise(rb_eArgError,"%s for overloaded method '%s'.\n"
1030	   "Possible C/C++ prototypes are:\n%s",
1031	   msg, method, prototypes);
1032}
1033/* -----------------------------------------------------------------------------
1034 * rubytracking.swg
1035 *
1036 * This file contains support for tracking mappings from
1037 * Ruby objects to C++ objects.  This functionality is needed
1038 * to implement mark functions for Ruby's mark and sweep
1039 * garbage collector.
1040 * ----------------------------------------------------------------------------- */
1041
1042#ifdef __cplusplus
1043extern "C" {
1044#endif
1045
1046#if !defined(ST_DATA_T_DEFINED)
1047/* Needs to be explicitly included for Ruby 1.8 and earlier */
1048#include <st.h>
1049#endif
1050
1051/* Ruby 1.8 actually assumes the first case. */
1052#if SIZEOF_VOIDP == SIZEOF_LONG
1053#  define SWIG2NUM(v) LONG2NUM((unsigned long)v)
1054#  define NUM2SWIG(x) (unsigned long)NUM2LONG(x)
1055#elif SIZEOF_VOIDP == SIZEOF_LONG_LONG
1056#  define SWIG2NUM(v) LL2NUM((unsigned long long)v)
1057#  define NUM2SWIG(x) (unsigned long long)NUM2LL(x)
1058#else
1059#  error sizeof(void*) is not the same as long or long long
1060#endif
1061
1062/* Global hash table to store Trackings from C/C++
1063   structs to Ruby Objects.
1064*/
1065static st_table* swig_ruby_trackings = NULL;
1066
1067static VALUE swig_ruby_trackings_count(ANYARGS) {
1068  return SWIG2NUM(swig_ruby_trackings->num_entries);
1069}
1070
1071
1072/* Setup a hash table to store Trackings */
1073SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1074  /* Create a hash table to store Trackings from C++
1075     objects to Ruby objects. */
1076
1077  /* Try to see if some other .so has already created a
1078     tracking hash table, which we keep hidden in an instance var
1079     in the SWIG module.
1080     This is done to allow multiple DSOs to share the same
1081     tracking table.
1082  */
1083  VALUE trackings_value = Qnil;
1084  /* change the variable name so that we can mix modules
1085     compiled with older SWIG's - this used to be called "@__trackings__" */
1086  ID trackings_id = rb_intern( "@__safetrackings__" );
1087  VALUE verbose = rb_gv_get("VERBOSE");
1088  rb_gv_set("VERBOSE", Qfalse);
1089  trackings_value = rb_ivar_get( _mSWIG, trackings_id );
1090  rb_gv_set("VERBOSE", verbose);
1091
1092  /* The trick here is that we have to store the hash table
1093  pointer in a Ruby variable. We do not want Ruby's GC to
1094  treat this pointer as a Ruby object, so we convert it to
1095  a Ruby numeric value. */
1096  if (trackings_value == Qnil) {
1097    /* No, it hasn't.  Create one ourselves */
1098    swig_ruby_trackings = st_init_numtable();
1099    rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) );
1100  } else {
1101    swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value);
1102  }
1103
1104  rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", swig_ruby_trackings_count, NULL);
1105}
1106
1107/* Add a Tracking from a C/C++ struct to a Ruby object */
1108SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
1109  /* Store the mapping to the global hash table. */
1110  st_insert(swig_ruby_trackings, (st_data_t)ptr, object);
1111}
1112
1113/* Get the Ruby object that owns the specified C/C++ struct */
1114SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1115  /* Now lookup the value stored in the global hash table */
1116  VALUE value;
1117
1118  if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) {
1119    return value;
1120  } else {
1121    return Qnil;
1122  }
1123}
1124
1125/* Remove a Tracking from a C/C++ struct to a Ruby object.  It
1126   is very important to remove objects once they are destroyed
1127   since the same memory address may be reused later to create
1128   a new object. */
1129SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
1130  /* Delete the object from the hash table */
1131  st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL);
1132}
1133
1134/* This is a helper method that unlinks a Ruby object from its
1135   underlying C++ object.  This is needed if the lifetime of the
1136   Ruby object is longer than the C++ object */
1137SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
1138  VALUE object = SWIG_RubyInstanceFor(ptr);
1139
1140  if (object != Qnil) {
1141    if (TYPE(object) != T_DATA)
1142      abort();
1143    DATA_PTR(object) = 0;
1144  }
1145}
1146
1147/* This is a helper method that iterates over all the trackings
1148   passing the C++ object pointer and its related Ruby object
1149   to the passed callback function. */
1150
1151/* Proxy method to abstract the internal trackings datatype */
1152static int swig_ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) {
1153  (*meth)(ptr, obj);
1154  return ST_CONTINUE;
1155}
1156
1157SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) {
1158  st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&swig_ruby_internal_iterate_callback, (st_data_t)meth);
1159}
1160
1161#ifdef __cplusplus
1162}
1163#endif
1164/* -----------------------------------------------------------------------------
1165 * Ruby API portion that goes into the runtime
1166 * ----------------------------------------------------------------------------- */
1167
1168#ifdef __cplusplus
1169extern "C" {
1170#endif
1171
1172SWIGINTERN VALUE
1173SWIG_Ruby_AppendOutput(VALUE target, VALUE o) {
1174  if (NIL_P(target)) {
1175    target = o;
1176  } else {
1177    if (TYPE(target) != T_ARRAY) {
1178      VALUE o2 = target;
1179      target = rb_ary_new();
1180      rb_ary_push(target, o2);
1181    }
1182    rb_ary_push(target, o);
1183  }
1184  return target;
1185}
1186
1187/* For ruby1.8.4 and earlier. */
1188#ifndef RUBY_INIT_STACK
1189   RUBY_EXTERN void Init_stack(VALUE* addr);
1190#  define RUBY_INIT_STACK \
1191   VALUE variable_in_this_stack_frame; \
1192   Init_stack(&variable_in_this_stack_frame);
1193#endif
1194
1195
1196#ifdef __cplusplus
1197}
1198#endif
1199
1200/* -----------------------------------------------------------------------------
1201 * rubyrun.swg
1202 *
1203 * This file contains the runtime support for Ruby modules
1204 * and includes code for managing global variables and pointer
1205 * type checking.
1206 * ----------------------------------------------------------------------------- */
1207
1208/* For backward compatibility only */
1209#define SWIG_POINTER_EXCEPTION  0
1210
1211/* for raw pointers */
1212#define SWIG_ConvertPtr(obj, pptr, type, flags)         SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
1213#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own)  SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own)
1214#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Ruby_NewPointerObj(ptr, type, flags)
1215#define SWIG_AcquirePtr(ptr, own)                       SWIG_Ruby_AcquirePtr(ptr, own)
1216#define swig_owntype                                    swig_ruby_owntype
1217
1218/* for raw packed data */
1219#define SWIG_ConvertPacked(obj, ptr, sz, ty)            SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags)
1220#define SWIG_NewPackedObj(ptr, sz, type)                SWIG_Ruby_NewPackedObj(ptr, sz, type)
1221
1222/* for class or struct pointers */
1223#define SWIG_ConvertInstance(obj, pptr, type, flags)    SWIG_ConvertPtr(obj, pptr, type, flags)
1224#define SWIG_NewInstanceObj(ptr, type, flags)           SWIG_NewPointerObj(ptr, type, flags)
1225
1226/* for C or C++ function pointers */
1227#define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_ConvertPtr(obj, pptr, type, 0)
1228#define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_NewPointerObj(ptr, type, 0)
1229
1230/* for C++ member pointers, ie, member methods */
1231#define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty)
1232#define SWIG_NewMemberObj(ptr, sz, type)                SWIG_Ruby_NewPackedObj(ptr, sz, type)
1233
1234
1235/* Runtime API */
1236
1237#define SWIG_GetModule(clientdata)                      SWIG_Ruby_GetModule(clientdata)
1238#define SWIG_SetModule(clientdata, pointer) 		SWIG_Ruby_SetModule(pointer)
1239
1240
1241/* Error manipulation */
1242
1243#define SWIG_ErrorType(code)                            SWIG_Ruby_ErrorType(code)
1244#define SWIG_Error(code, msg)            		rb_raise(SWIG_Ruby_ErrorType(code), "%s", msg)
1245#define SWIG_fail                        		goto fail
1246
1247
1248/* Ruby-specific SWIG API */
1249
1250#define SWIG_InitRuntime()                              SWIG_Ruby_InitRuntime()
1251#define SWIG_define_class(ty)                        	SWIG_Ruby_define_class(ty)
1252#define SWIG_NewClassInstance(value, ty)             	SWIG_Ruby_NewClassInstance(value, ty)
1253#define SWIG_MangleStr(value)                        	SWIG_Ruby_MangleStr(value)
1254#define SWIG_CheckConvert(value, ty)                 	SWIG_Ruby_CheckConvert(value, ty)
1255
1256#include "assert.h"
1257
1258/* -----------------------------------------------------------------------------
1259 * pointers/data manipulation
1260 * ----------------------------------------------------------------------------- */
1261
1262#ifdef __cplusplus
1263extern "C" {
1264#endif
1265
1266typedef struct {
1267  VALUE klass;
1268  VALUE mImpl;
1269  void  (*mark)(void *);
1270  void  (*destroy)(void *);
1271  int trackObjects;
1272} swig_class;
1273
1274
1275/* Global pointer used to keep some internal SWIG stuff */
1276static VALUE _cSWIG_Pointer = Qnil;
1277static VALUE swig_runtime_data_type_pointer = Qnil;
1278
1279/* Global IDs used to keep some internal SWIG stuff */
1280static ID swig_arity_id = 0;
1281static ID swig_call_id  = 0;
1282
1283/*
1284  If your swig extension is to be run within an embedded ruby and has
1285  director callbacks, you should set -DRUBY_EMBEDDED during compilation.
1286  This will reset ruby's stack frame on each entry point from the main
1287  program the first time a virtual director function is invoked (in a
1288  non-recursive way).
1289  If this is not done, you run the risk of Ruby trashing the stack.
1290*/
1291
1292#ifdef RUBY_EMBEDDED
1293
1294#  define SWIG_INIT_STACK                            \
1295      if ( !swig_virtual_calls ) { RUBY_INIT_STACK } \
1296      ++swig_virtual_calls;
1297#  define SWIG_RELEASE_STACK --swig_virtual_calls;
1298#  define Ruby_DirectorTypeMismatchException(x) \
1299          rb_raise( rb_eTypeError, "%s", x ); return c_result;
1300
1301      static unsigned int swig_virtual_calls = 0;
1302
1303#else  /* normal non-embedded extension */
1304
1305#  define SWIG_INIT_STACK
1306#  define SWIG_RELEASE_STACK
1307#  define Ruby_DirectorTypeMismatchException(x) \
1308          throw Swig::DirectorTypeMismatchException( x );
1309
1310#endif  /* RUBY_EMBEDDED */
1311
1312
1313SWIGRUNTIME VALUE
1314getExceptionClass(void) {
1315  static int init = 0;
1316  static VALUE rubyExceptionClass ;
1317  if (!init) {
1318    init = 1;
1319    rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception"));
1320  }
1321  return rubyExceptionClass;
1322}
1323
1324/* This code checks to see if the Ruby object being raised as part
1325   of an exception inherits from the Ruby class Exception.  If so,
1326   the object is simply returned.  If not, then a new Ruby exception
1327   object is created and that will be returned to Ruby.*/
1328SWIGRUNTIME VALUE
1329SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) {
1330  VALUE exceptionClass = getExceptionClass();
1331  if (rb_obj_is_kind_of(obj, exceptionClass)) {
1332    return obj;
1333  }  else {
1334    return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj));
1335  }
1336}
1337
1338/* Initialize Ruby runtime support */
1339SWIGRUNTIME void
1340SWIG_Ruby_InitRuntime(void)
1341{
1342  if (_mSWIG == Qnil) {
1343    _mSWIG = rb_define_module("SWIG");
1344    swig_call_id  = rb_intern("call");
1345    swig_arity_id = rb_intern("arity");
1346  }
1347}
1348
1349/* Define Ruby class for C type */
1350SWIGRUNTIME void
1351SWIG_Ruby_define_class(swig_type_info *type)
1352{
1353  char *klass_name = (char *) malloc(4 + strlen(type->name) + 1);
1354  sprintf(klass_name, "TYPE%s", type->name);
1355  if (NIL_P(_cSWIG_Pointer)) {
1356    _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
1357    rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
1358  }
1359  rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
1360  free((void *) klass_name);
1361}
1362
1363/* Create a new pointer object */
1364SWIGRUNTIME VALUE
1365SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1366{
1367  int own =  flags & SWIG_POINTER_OWN;
1368  int track;
1369  char *klass_name;
1370  swig_class *sklass;
1371  VALUE klass;
1372  VALUE obj;
1373
1374  if (!ptr)
1375    return Qnil;
1376
1377  if (type->clientdata) {
1378    sklass = (swig_class *) type->clientdata;
1379
1380    /* Are we tracking this class and have we already returned this Ruby object? */
1381    track = sklass->trackObjects;
1382    if (track) {
1383      obj = SWIG_RubyInstanceFor(ptr);
1384
1385      /* Check the object's type and make sure it has the correct type.
1386        It might not in cases where methods do things like
1387        downcast methods. */
1388      if (obj != Qnil) {
1389        VALUE value = rb_iv_get(obj, "@__swigtype__");
1390        const char* type_name = RSTRING_PTR(value);
1391
1392        if (strcmp(type->name, type_name) == 0) {
1393          return obj;
1394        }
1395      }
1396    }
1397
1398    /* Create a new Ruby object */
1399    obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark),
1400			   ( own ? VOIDFUNC(sklass->destroy) :
1401			     (track ? VOIDFUNC(SWIG_RubyRemoveTracking) : 0 )
1402			     ), ptr);
1403
1404    /* If tracking is on for this class then track this object. */
1405    if (track) {
1406      SWIG_RubyAddTracking(ptr, obj);
1407    }
1408  } else {
1409    klass_name = (char *) malloc(4 + strlen(type->name) + 1);
1410    sprintf(klass_name, "TYPE%s", type->name);
1411    klass = rb_const_get(_mSWIG, rb_intern(klass_name));
1412    free((void *) klass_name);
1413    obj = Data_Wrap_Struct(klass, 0, 0, ptr);
1414  }
1415  rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1416
1417  return obj;
1418}
1419
1420/* Create a new class instance (always owned) */
1421SWIGRUNTIME VALUE
1422SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type)
1423{
1424  VALUE obj;
1425  swig_class *sklass = (swig_class *) type->clientdata;
1426  obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0);
1427  rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1428  return obj;
1429}
1430
1431/* Get type mangle from class name */
1432SWIGRUNTIMEINLINE char *
1433SWIG_Ruby_MangleStr(VALUE obj)
1434{
1435  VALUE stype = rb_iv_get(obj, "@__swigtype__");
1436  return StringValuePtr(stype);
1437}
1438
1439/* Acquire a pointer value */
1440typedef struct {
1441  void (*datafree)(void *);
1442  int own;
1443} swig_ruby_owntype;
1444
1445SWIGRUNTIME swig_ruby_owntype
1446SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) {
1447  swig_ruby_owntype oldown = {0, 0};
1448  if (obj) {
1449    oldown.datafree = RDATA(obj)->dfree;
1450    RDATA(obj)->dfree = own.datafree;
1451  }
1452  return oldown;
1453}
1454
1455/* Convert a pointer value */
1456SWIGRUNTIME int
1457SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own)
1458{
1459  char *c;
1460  swig_cast_info *tc;
1461  void *vptr = 0;
1462
1463  /* Grab the pointer */
1464  if (NIL_P(obj)) {
1465    if (ptr)
1466      *ptr = 0;
1467    return SWIG_OK;
1468  } else {
1469    if (TYPE(obj) != T_DATA) {
1470      return SWIG_ERROR;
1471    }
1472    Data_Get_Struct(obj, void, vptr);
1473  }
1474
1475  if (own) {
1476    own->datafree = RDATA(obj)->dfree;
1477    own->own = 0;
1478  }
1479
1480  /* Check to see if the input object is giving up ownership
1481     of the underlying C struct or C++ object.  If so then we
1482     need to reset the destructor since the Ruby object no
1483     longer owns the underlying C++ object.*/
1484  if (flags & SWIG_POINTER_DISOWN) {
1485    /* Is tracking on for this class? */
1486    int track = 0;
1487    if (ty && ty->clientdata) {
1488      swig_class *sklass = (swig_class *) ty->clientdata;
1489      track = sklass->trackObjects;
1490    }
1491
1492    if (track) {
1493      /* We are tracking objects for this class.  Thus we change the destructor
1494       * to SWIG_RubyRemoveTracking.  This allows us to
1495       * remove the mapping from the C++ to Ruby object
1496       * when the Ruby object is garbage collected.  If we don't
1497       * do this, then it is possible we will return a reference
1498       * to a Ruby object that no longer exists thereby crashing Ruby. */
1499      RDATA(obj)->dfree = SWIG_RubyRemoveTracking;
1500    } else {
1501      RDATA(obj)->dfree = 0;
1502    }
1503  }
1504
1505  /* Do type-checking if type info was provided */
1506  if (ty) {
1507    if (ty->clientdata) {
1508      if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) {
1509        if (vptr == 0) {
1510          /* The object has already been deleted */
1511          return SWIG_ObjectPreviouslyDeletedError;
1512        }
1513      }
1514    }
1515    if ((c = SWIG_MangleStr(obj)) == NULL) {
1516      return SWIG_ERROR;
1517    }
1518    tc = SWIG_TypeCheck(c, ty);
1519    if (!tc) {
1520      return SWIG_ERROR;
1521    } else {
1522      if (ptr) {
1523        if (tc->type == ty) {
1524          *ptr = vptr;
1525        } else {
1526          int newmemory = 0;
1527          *ptr = SWIG_TypeCast(tc, vptr, &newmemory);
1528          if (newmemory == SWIG_CAST_NEW_MEMORY) {
1529            assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
1530            if (own)
1531              own->own = own->own | SWIG_CAST_NEW_MEMORY;
1532          }
1533        }
1534      }
1535    }
1536  } else {
1537    if (ptr)
1538      *ptr = vptr;
1539  }
1540
1541  return SWIG_OK;
1542}
1543
1544/* Check convert */
1545SWIGRUNTIMEINLINE int
1546SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty)
1547{
1548  char *c = SWIG_MangleStr(obj);
1549  if (!c) return 0;
1550  return SWIG_TypeCheck(c,ty) != 0;
1551}
1552
1553SWIGRUNTIME VALUE
1554SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
1555  char result[1024];
1556  char *r = result;
1557  if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
1558  *(r++) = '_';
1559  r = SWIG_PackData(r, ptr, sz);
1560  strcpy(r, type->name);
1561  return rb_str_new2(result);
1562}
1563
1564/* Convert a packed value value */
1565SWIGRUNTIME int
1566SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
1567  swig_cast_info *tc;
1568  const char  *c;
1569
1570  if (TYPE(obj) != T_STRING) goto type_error;
1571  c = StringValuePtr(obj);
1572  /* Pointer values must start with leading underscore */
1573  if (*c != '_') goto type_error;
1574  c++;
1575  c = SWIG_UnpackData(c, ptr, sz);
1576  if (ty) {
1577    tc = SWIG_TypeCheck(c, ty);
1578    if (!tc) goto type_error;
1579  }
1580  return SWIG_OK;
1581
1582 type_error:
1583  return SWIG_ERROR;
1584}
1585
1586SWIGRUNTIME swig_module_info *
1587SWIG_Ruby_GetModule(void *SWIGUNUSEDPARM(clientdata))
1588{
1589  VALUE pointer;
1590  swig_module_info *ret = 0;
1591  VALUE verbose = rb_gv_get("VERBOSE");
1592
1593 /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */
1594  rb_gv_set("VERBOSE", Qfalse);
1595
1596  /* first check if pointer already created */
1597  pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
1598  if (pointer != Qnil) {
1599    Data_Get_Struct(pointer, swig_module_info, ret);
1600  }
1601
1602  /* reinstate warnings */
1603  rb_gv_set("VERBOSE", verbose);
1604  return ret;
1605}
1606
1607SWIGRUNTIME void
1608SWIG_Ruby_SetModule(swig_module_info *pointer)
1609{
1610  /* register a new class */
1611  VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
1612  /* create and store the structure pointer to a global variable */
1613  swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer);
1614  rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
1615}
1616
1617/* This function can be used to check whether a proc or method or similarly
1618   callable function has been passed.  Usually used in a %typecheck, like:
1619
1620   %typecheck(c_callback_t, precedence=SWIG_TYPECHECK_POINTER) {
1621        $result = SWIG_Ruby_isCallable( $input );
1622   }
1623 */
1624SWIGINTERN
1625int SWIG_Ruby_isCallable( VALUE proc )
1626{
1627  if ( rb_respond_to( proc, swig_call_id ) )
1628    return 1;
1629  return 0;
1630}
1631
1632/* This function can be used to check the arity (number of arguments)
1633   a proc or method can take.  Usually used in a %typecheck.
1634   Valid arities will be that equal to minimal or those < 0
1635   which indicate a variable number of parameters at the end.
1636 */
1637SWIGINTERN
1638int SWIG_Ruby_arity( VALUE proc, int minimal )
1639{
1640  if ( rb_respond_to( proc, swig_arity_id ) )
1641    {
1642      VALUE num = rb_funcall( proc, swig_arity_id, 0 );
1643      int arity = NUM2INT(num);
1644      if ( arity < 0 && (arity+1) < -minimal ) return 1;
1645      if ( arity == minimal ) return 1;
1646      return 1;
1647    }
1648  return 0;
1649}
1650
1651
1652#ifdef __cplusplus
1653}
1654#endif
1655/* -----------------------------------------------------------------------------*
1656   Standard SWIG API for use inside user code.
1657
1658   Don't include this file directly, run the command
1659   swig -python -external-runtime
1660   Also, read the Modules chapter of the SWIG Manual.
1661
1662 * -----------------------------------------------------------------------------*/
1663
1664#ifdef SWIG_MODULE_CLIENTDATA_TYPE
1665
1666SWIGRUNTIMEINLINE swig_type_info *
1667SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) {
1668  swig_module_info *module = SWIG_GetModule(clientdata);
1669  return SWIG_TypeQueryModule(module, module, name);
1670}
1671
1672SWIGRUNTIMEINLINE swig_type_info *
1673SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) {
1674  swig_module_info *module = SWIG_GetModule(clientdata);
1675  return SWIG_MangledTypeQueryModule(module, module, name);
1676}
1677
1678#else
1679
1680SWIGRUNTIMEINLINE swig_type_info *
1681SWIG_TypeQuery(const char *name) {
1682  swig_module_info *module = SWIG_GetModule(NULL);
1683  return SWIG_TypeQueryModule(module, module, name);
1684}
1685
1686SWIGRUNTIMEINLINE swig_type_info *
1687SWIG_MangledTypeQuery(const char *name) {
1688  swig_module_info *module = SWIG_GetModule(NULL);
1689  return SWIG_MangledTypeQueryModule(module, module, name);
1690}
1691
1692#endif
1693