Home | History | Annotate | Download | only in 2.0.11
      1 /* -----------------------------------------------------------------------------
      2  * swigrun.swg
      3  *
      4  * This file contains generic C API SWIG runtime support for pointer
      5  * type checking.
      6  * ----------------------------------------------------------------------------- */
      7 
      8 /* This should only be incremented when either the layout of swig_type_info changes,
      9    or for whatever reason, the runtime changes incompatibly */
     10 #define SWIG_RUNTIME_VERSION "4"
     11 
     12 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
     13 #ifdef SWIG_TYPE_TABLE
     14 # define SWIG_QUOTE_STRING(x) #x
     15 # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
     16 # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
     17 #else
     18 # define SWIG_TYPE_TABLE_NAME
     19 #endif
     20 
     21 /*
     22   You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
     23   creating a static or dynamic library from the SWIG runtime code.
     24   In 99.9% of the cases, SWIG just needs to declare them as 'static'.
     25 
     26   But only do this if strictly necessary, ie, if you have problems
     27   with your compiler or suchlike.
     28 */
     29 
     30 #ifndef SWIGRUNTIME
     31 # define SWIGRUNTIME SWIGINTERN
     32 #endif
     33 
     34 #ifndef SWIGRUNTIMEINLINE
     35 # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
     36 #endif
     37 
     38 /*  Generic buffer size */
     39 #ifndef SWIG_BUFFER_SIZE
     40 # define SWIG_BUFFER_SIZE 1024
     41 #endif
     42 
     43 /* Flags for pointer conversions */
     44 #define SWIG_POINTER_DISOWN        0x1
     45 #define SWIG_CAST_NEW_MEMORY       0x2
     46 
     47 /* Flags for new pointer objects */
     48 #define SWIG_POINTER_OWN           0x1
     49 
     50 
     51 /*
     52    Flags/methods for returning states.
     53 
     54    The SWIG conversion methods, as ConvertPtr, return an integer
     55    that tells if the conversion was successful or not. And if not,
     56    an error code can be returned (see swigerrors.swg for the codes).
     57 
     58    Use the following macros/flags to set or process the returning
     59    states.
     60 
     61    In old versions of SWIG, code such as the following was usually written:
     62 
     63      if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
     64        // success code
     65      } else {
     66        //fail code
     67      }
     68 
     69    Now you can be more explicit:
     70 
     71     int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
     72     if (SWIG_IsOK(res)) {
     73       // success code
     74     } else {
     75       // fail code
     76     }
     77 
     78    which is the same really, but now you can also do
     79 
     80     Type *ptr;
     81     int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
     82     if (SWIG_IsOK(res)) {
     83       // success code
     84       if (SWIG_IsNewObj(res) {
     85         ...
     86 	delete *ptr;
     87       } else {
     88         ...
     89       }
     90     } else {
     91       // fail code
     92     }
     93 
     94    I.e., now SWIG_ConvertPtr can return new objects and you can
     95    identify the case and take care of the deallocation. Of course that
     96    also requires SWIG_ConvertPtr to return new result values, such as
     97 
     98       int SWIG_ConvertPtr(obj, ptr,...) {
     99         if (<obj is ok>) {
    100           if (<need new object>) {
    101             *ptr = <ptr to new allocated object>;
    102             return SWIG_NEWOBJ;
    103           } else {
    104             *ptr = <ptr to old object>;
    105             return SWIG_OLDOBJ;
    106           }
    107         } else {
    108           return SWIG_BADOBJ;
    109         }
    110       }
    111 
    112    Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
    113    more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
    114    SWIG errors code.
    115 
    116    Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
    117    allows to return the 'cast rank', for example, if you have this
    118 
    119        int food(double)
    120        int fooi(int);
    121 
    122    and you call
    123 
    124       food(1)   // cast rank '1'  (1 -> 1.0)
    125       fooi(1)   // cast rank '0'
    126 
    127    just use the SWIG_AddCast()/SWIG_CheckState()
    128 */
    129 
    130 #define SWIG_OK                    (0)
    131 #define SWIG_ERROR                 (-1)
    132 #define SWIG_IsOK(r)               (r >= 0)
    133 #define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)
    134 
    135 /* The CastRankLimit says how many bits are used for the cast rank */
    136 #define SWIG_CASTRANKLIMIT         (1 << 8)
    137 /* The NewMask denotes the object was created (using new/malloc) */
    138 #define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
    139 /* The TmpMask is for in/out typemaps that use temporal objects */
    140 #define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
    141 /* Simple returning values */
    142 #define SWIG_BADOBJ                (SWIG_ERROR)
    143 #define SWIG_OLDOBJ                (SWIG_OK)
    144 #define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
    145 #define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
    146 /* Check, add and del mask methods */
    147 #define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
    148 #define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
    149 #define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
    150 #define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
    151 #define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
    152 #define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
    153 
    154 /* Cast-Rank Mode */
    155 #if defined(SWIG_CASTRANK_MODE)
    156 #  ifndef SWIG_TypeRank
    157 #    define SWIG_TypeRank             unsigned long
    158 #  endif
    159 #  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
    160 #    define SWIG_MAXCASTRANK          (2)
    161 #  endif
    162 #  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
    163 #  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
    164 SWIGINTERNINLINE int SWIG_AddCast(int r) {
    165   return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
    166 }
    167 SWIGINTERNINLINE int SWIG_CheckState(int r) {
    168   return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
    169 }
    170 #else /* no cast-rank mode */
    171 #  define SWIG_AddCast(r) (r)
    172 #  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
    173 #endif
    174 
    175 
    176 #include <string.h>
    177 
    178 #ifdef __cplusplus
    179 extern "C" {
    180 #endif
    181 
    182 typedef void *(*swig_converter_func)(void *, int *);
    183 typedef struct swig_type_info *(*swig_dycast_func)(void **);
    184 
    185 /* Structure to store information on one type */
    186 typedef struct swig_type_info {
    187   const char             *name;			/* mangled name of this type */
    188   const char             *str;			/* human readable name of this type */
    189   swig_dycast_func        dcast;		/* dynamic cast function down a hierarchy */
    190   struct swig_cast_info  *cast;			/* linked list of types that can cast into this type */
    191   void                   *clientdata;		/* language specific type data */
    192   int                    owndata;		/* flag if the structure owns the clientdata */
    193 } swig_type_info;
    194 
    195 /* Structure to store a type and conversion function used for casting */
    196 typedef struct swig_cast_info {
    197   swig_type_info         *type;			/* pointer to type that is equivalent to this type */
    198   swig_converter_func     converter;		/* function to cast the void pointers */
    199   struct swig_cast_info  *next;			/* pointer to next cast in linked list */
    200   struct swig_cast_info  *prev;			/* pointer to the previous cast */
    201 } swig_cast_info;
    202 
    203 /* Structure used to store module information
    204  * Each module generates one structure like this, and the runtime collects
    205  * all of these structures and stores them in a circularly linked list.*/
    206 typedef struct swig_module_info {
    207   swig_type_info         **types;		/* Array of pointers to swig_type_info structures that are in this module */
    208   size_t                 size;		        /* Number of types in this module */
    209   struct swig_module_info *next;		/* Pointer to next element in circularly linked list */
    210   swig_type_info         **type_initial;	/* Array of initially generated type structures */
    211   swig_cast_info         **cast_initial;	/* Array of initially generated casting structures */
    212   void                    *clientdata;		/* Language specific module data */
    213 } swig_module_info;
    214 
    215 /*
    216   Compare two type names skipping the space characters, therefore
    217   "char*" == "char *" and "Class<int>" == "Class<int >", etc.
    218 
    219   Return 0 when the two name types are equivalent, as in
    220   strncmp, but skipping ' '.
    221 */
    222 SWIGRUNTIME int
    223 SWIG_TypeNameComp(const char *f1, const char *l1,
    224 		  const char *f2, const char *l2) {
    225   for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
    226     while ((*f1 == ' ') && (f1 != l1)) ++f1;
    227     while ((*f2 == ' ') && (f2 != l2)) ++f2;
    228     if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
    229   }
    230   return (int)((l1 - f1) - (l2 - f2));
    231 }
    232 
    233 /*
    234   Check type equivalence in a name list like <name1>|<name2>|...
    235   Return 0 if equal, -1 if nb < tb, 1 if nb > tb
    236 */
    237 SWIGRUNTIME int
    238 SWIG_TypeCmp(const char *nb, const char *tb) {
    239   int equiv = 1;
    240   const char* te = tb + strlen(tb);
    241   const char* ne = nb;
    242   while (equiv != 0 && *ne) {
    243     for (nb = ne; *ne; ++ne) {
    244       if (*ne == '|') break;
    245     }
    246     equiv = SWIG_TypeNameComp(nb, ne, tb, te);
    247     if (*ne) ++ne;
    248   }
    249   return equiv;
    250 }
    251 
    252 /*
    253   Check type equivalence in a name list like <name1>|<name2>|...
    254   Return 0 if not equal, 1 if equal
    255 */
    256 SWIGRUNTIME int
    257 SWIG_TypeEquiv(const char *nb, const char *tb) {
    258   return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
    259 }
    260 
    261 /*
    262   Check the typename
    263 */
    264 SWIGRUNTIME swig_cast_info *
    265 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
    266   if (ty) {
    267     swig_cast_info *iter = ty->cast;
    268     while (iter) {
    269       if (strcmp(iter->type->name, c) == 0) {
    270         if (iter == ty->cast)
    271           return iter;
    272         /* Move iter to the top of the linked list */
    273         iter->prev->next = iter->next;
    274         if (iter->next)
    275           iter->next->prev = iter->prev;
    276         iter->next = ty->cast;
    277         iter->prev = 0;
    278         if (ty->cast) ty->cast->prev = iter;
    279         ty->cast = iter;
    280         return iter;
    281       }
    282       iter = iter->next;
    283     }
    284   }
    285   return 0;
    286 }
    287 
    288 /*
    289   Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
    290 */
    291 SWIGRUNTIME swig_cast_info *
    292 SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
    293   if (ty) {
    294     swig_cast_info *iter = ty->cast;
    295     while (iter) {
    296       if (iter->type == from) {
    297         if (iter == ty->cast)
    298           return iter;
    299         /* Move iter to the top of the linked list */
    300         iter->prev->next = iter->next;
    301         if (iter->next)
    302           iter->next->prev = iter->prev;
    303         iter->next = ty->cast;
    304         iter->prev = 0;
    305         if (ty->cast) ty->cast->prev = iter;
    306         ty->cast = iter;
    307         return iter;
    308       }
    309       iter = iter->next;
    310     }
    311   }
    312   return 0;
    313 }
    314 
    315 /*
    316   Cast a pointer up an inheritance hierarchy
    317 */
    318 SWIGRUNTIMEINLINE void *
    319 SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
    320   return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
    321 }
    322 
    323 /*
    324    Dynamic pointer casting. Down an inheritance hierarchy
    325 */
    326 SWIGRUNTIME swig_type_info *
    327 SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
    328   swig_type_info *lastty = ty;
    329   if (!ty || !ty->dcast) return ty;
    330   while (ty && (ty->dcast)) {
    331     ty = (*ty->dcast)(ptr);
    332     if (ty) lastty = ty;
    333   }
    334   return lastty;
    335 }
    336 
    337 /*
    338   Return the name associated with this type
    339 */
    340 SWIGRUNTIMEINLINE const char *
    341 SWIG_TypeName(const swig_type_info *ty) {
    342   return ty->name;
    343 }
    344 
    345 /*
    346   Return the pretty name associated with this type,
    347   that is an unmangled type name in a form presentable to the user.
    348 */
    349 SWIGRUNTIME const char *
    350 SWIG_TypePrettyName(const swig_type_info *type) {
    351   /* The "str" field contains the equivalent pretty names of the
    352      type, separated by vertical-bar characters.  We choose
    353      to print the last name, as it is often (?) the most
    354      specific. */
    355   if (!type) return NULL;
    356   if (type->str != NULL) {
    357     const char *last_name = type->str;
    358     const char *s;
    359     for (s = type->str; *s; s++)
    360       if (*s == '|') last_name = s+1;
    361     return last_name;
    362   }
    363   else
    364     return type->name;
    365 }
    366 
    367 /*
    368    Set the clientdata field for a type
    369 */
    370 SWIGRUNTIME void
    371 SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
    372   swig_cast_info *cast = ti->cast;
    373   /* if (ti->clientdata == clientdata) return; */
    374   ti->clientdata = clientdata;
    375 
    376   while (cast) {
    377     if (!cast->converter) {
    378       swig_type_info *tc = cast->type;
    379       if (!tc->clientdata) {
    380 	SWIG_TypeClientData(tc, clientdata);
    381       }
    382     }
    383     cast = cast->next;
    384   }
    385 }
    386 SWIGRUNTIME void
    387 SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
    388   SWIG_TypeClientData(ti, clientdata);
    389   ti->owndata = 1;
    390 }
    391 
    392 /*
    393   Search for a swig_type_info structure only by mangled name
    394   Search is a O(log #types)
    395 
    396   We start searching at module start, and finish searching when start == end.
    397   Note: if start == end at the beginning of the function, we go all the way around
    398   the circular list.
    399 */
    400 SWIGRUNTIME swig_type_info *
    401 SWIG_MangledTypeQueryModule(swig_module_info *start,
    402                             swig_module_info *end,
    403 		            const char *name) {
    404   swig_module_info *iter = start;
    405   do {
    406     if (iter->size) {
    407       register size_t l = 0;
    408       register size_t r = iter->size - 1;
    409       do {
    410 	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
    411 	register size_t i = (l + r) >> 1;
    412 	const char *iname = iter->types[i]->name;
    413 	if (iname) {
    414 	  register int compare = strcmp(name, iname);
    415 	  if (compare == 0) {
    416 	    return iter->types[i];
    417 	  } else if (compare < 0) {
    418 	    if (i) {
    419 	      r = i - 1;
    420 	    } else {
    421 	      break;
    422 	    }
    423 	  } else if (compare > 0) {
    424 	    l = i + 1;
    425 	  }
    426 	} else {
    427 	  break; /* should never happen */
    428 	}
    429       } while (l <= r);
    430     }
    431     iter = iter->next;
    432   } while (iter != end);
    433   return 0;
    434 }
    435 
    436 /*
    437   Search for a swig_type_info structure for either a mangled name or a human readable name.
    438   It first searches the mangled names of the types, which is a O(log #types)
    439   If a type is not found it then searches the human readable names, which is O(#types).
    440 
    441   We start searching at module start, and finish searching when start == end.
    442   Note: if start == end at the beginning of the function, we go all the way around
    443   the circular list.
    444 */
    445 SWIGRUNTIME swig_type_info *
    446 SWIG_TypeQueryModule(swig_module_info *start,
    447                      swig_module_info *end,
    448 		     const char *name) {
    449   /* STEP 1: Search the name field using binary search */
    450   swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
    451   if (ret) {
    452     return ret;
    453   } else {
    454     /* STEP 2: If the type hasn't been found, do a complete search
    455        of the str field (the human readable name) */
    456     swig_module_info *iter = start;
    457     do {
    458       register size_t i = 0;
    459       for (; i < iter->size; ++i) {
    460 	if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
    461 	  return iter->types[i];
    462       }
    463       iter = iter->next;
    464     } while (iter != end);
    465   }
    466 
    467   /* neither found a match */
    468   return 0;
    469 }
    470 
    471 /*
    472    Pack binary data into a string
    473 */
    474 SWIGRUNTIME char *
    475 SWIG_PackData(char *c, void *ptr, size_t sz) {
    476   static const char hex[17] = "0123456789abcdef";
    477   register const unsigned char *u = (unsigned char *) ptr;
    478   register const unsigned char *eu =  u + sz;
    479   for (; u != eu; ++u) {
    480     register unsigned char uu = *u;
    481     *(c++) = hex[(uu & 0xf0) >> 4];
    482     *(c++) = hex[uu & 0xf];
    483   }
    484   return c;
    485 }
    486 
    487 /*
    488    Unpack binary data from a string
    489 */
    490 SWIGRUNTIME const char *
    491 SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
    492   register unsigned char *u = (unsigned char *) ptr;
    493   register const unsigned char *eu = u + sz;
    494   for (; u != eu; ++u) {
    495     register char d = *(c++);
    496     register unsigned char uu;
    497     if ((d >= '0') && (d <= '9'))
    498       uu = ((d - '0') << 4);
    499     else if ((d >= 'a') && (d <= 'f'))
    500       uu = ((d - ('a'-10)) << 4);
    501     else
    502       return (char *) 0;
    503     d = *(c++);
    504     if ((d >= '0') && (d <= '9'))
    505       uu |= (d - '0');
    506     else if ((d >= 'a') && (d <= 'f'))
    507       uu |= (d - ('a'-10));
    508     else
    509       return (char *) 0;
    510     *u = uu;
    511   }
    512   return c;
    513 }
    514 
    515 /*
    516    Pack 'void *' into a string buffer.
    517 */
    518 SWIGRUNTIME char *
    519 SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
    520   char *r = buff;
    521   if ((2*sizeof(void *) + 2) > bsz) return 0;
    522   *(r++) = '_';
    523   r = SWIG_PackData(r,&ptr,sizeof(void *));
    524   if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
    525   strcpy(r,name);
    526   return buff;
    527 }
    528 
    529 SWIGRUNTIME const char *
    530 SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
    531   if (*c != '_') {
    532     if (strcmp(c,"NULL") == 0) {
    533       *ptr = (void *) 0;
    534       return name;
    535     } else {
    536       return 0;
    537     }
    538   }
    539   return SWIG_UnpackData(++c,ptr,sizeof(void *));
    540 }
    541 
    542 SWIGRUNTIME char *
    543 SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
    544   char *r = buff;
    545   size_t lname = (name ? strlen(name) : 0);
    546   if ((2*sz + 2 + lname) > bsz) return 0;
    547   *(r++) = '_';
    548   r = SWIG_PackData(r,ptr,sz);
    549   if (lname) {
    550     strncpy(r,name,lname+1);
    551   } else {
    552     *r = 0;
    553   }
    554   return buff;
    555 }
    556 
    557 SWIGRUNTIME const char *
    558 SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
    559   if (*c != '_') {
    560     if (strcmp(c,"NULL") == 0) {
    561       memset(ptr,0,sz);
    562       return name;
    563     } else {
    564       return 0;
    565     }
    566   }
    567   return SWIG_UnpackData(++c,ptr,sz);
    568 }
    569 
    570 #ifdef __cplusplus
    571 }
    572 #endif
    573