UGDK
src/ugdk/script/languages/lua/swigluarun.h
Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  * This file was automatically generated by SWIG (http://www.swig.org).
00003  * Version 2.0.4
00004  * 
00005  * This file is not intended to be easily readable and contains a number of 
00006  * coding conventions designed to improve portability and efficiency. Do not make
00007  * changes to this file unless you know what you are doing--modify the SWIG 
00008  * interface file instead. 
00009  * ----------------------------------------------------------------------------- */
00010 
00011 /* -----------------------------------------------------------------------------
00012  *  This section contains generic SWIG labels for method/variable
00013  *  declarations/attributes, and other compiler dependent labels.
00014  * ----------------------------------------------------------------------------- */
00015 
00016 /* template workaround for compilers that cannot correctly implement the C++ standard */
00017 #ifndef SWIGTEMPLATEDISAMBIGUATOR
00018 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
00019 #  define SWIGTEMPLATEDISAMBIGUATOR template
00020 # elif defined(__HP_aCC)
00021 /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
00022 /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
00023 #  define SWIGTEMPLATEDISAMBIGUATOR template
00024 # else
00025 #  define SWIGTEMPLATEDISAMBIGUATOR
00026 # endif
00027 #endif
00028 
00029 /* inline attribute */
00030 #ifndef SWIGINLINE
00031 # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
00032 #   define SWIGINLINE inline
00033 # else
00034 #   define SWIGINLINE
00035 # endif
00036 #endif
00037 
00038 /* attribute recognised by some compilers to avoid 'unused' warnings */
00039 #ifndef SWIGUNUSED
00040 # if defined(__GNUC__)
00041 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
00042 #     define SWIGUNUSED __attribute__ ((__unused__)) 
00043 #   else
00044 #     define SWIGUNUSED
00045 #   endif
00046 # elif defined(__ICC)
00047 #   define SWIGUNUSED __attribute__ ((__unused__)) 
00048 # else
00049 #   define SWIGUNUSED 
00050 # endif
00051 #endif
00052 
00053 #ifndef SWIG_MSC_UNSUPPRESS_4505
00054 # if defined(_MSC_VER)
00055 #   pragma warning(disable : 4505) /* unreferenced local function has been removed */
00056 # endif 
00057 #endif
00058 
00059 #ifndef SWIGUNUSEDPARM
00060 # ifdef __cplusplus
00061 #   define SWIGUNUSEDPARM(p)
00062 # else
00063 #   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
00064 # endif
00065 #endif
00066 
00067 /* internal SWIG method */
00068 #ifndef SWIGINTERN
00069 # define SWIGINTERN static SWIGUNUSED
00070 #endif
00071 
00072 /* internal inline SWIG method */
00073 #ifndef SWIGINTERNINLINE
00074 # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
00075 #endif
00076 
00077 /* exporting methods */
00078 #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
00079 #  ifndef GCC_HASCLASSVISIBILITY
00080 #    define GCC_HASCLASSVISIBILITY
00081 #  endif
00082 #endif
00083 
00084 #ifndef SWIGEXPORT
00085 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
00086 #   if defined(STATIC_LINKED)
00087 #     define SWIGEXPORT
00088 #   else
00089 #     define SWIGEXPORT __declspec(dllexport)
00090 #   endif
00091 # else
00092 #   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
00093 #     define SWIGEXPORT __attribute__ ((visibility("default")))
00094 #   else
00095 #     define SWIGEXPORT
00096 #   endif
00097 # endif
00098 #endif
00099 
00100 /* calling conventions for Windows */
00101 #ifndef SWIGSTDCALL
00102 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
00103 #   define SWIGSTDCALL __stdcall
00104 # else
00105 #   define SWIGSTDCALL
00106 # endif 
00107 #endif
00108 
00109 /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
00110 #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
00111 # define _CRT_SECURE_NO_DEPRECATE
00112 #endif
00113 
00114 /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
00115 #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
00116 # define _SCL_SECURE_NO_DEPRECATE
00117 #endif
00118 
00119 /*  Errors in SWIG */
00120 #define  SWIG_UnknownError         -1 
00121 #define  SWIG_IOError              -2 
00122 #define  SWIG_RuntimeError         -3 
00123 #define  SWIG_IndexError           -4 
00124 #define  SWIG_TypeError            -5 
00125 #define  SWIG_DivisionByZero       -6 
00126 #define  SWIG_OverflowError        -7 
00127 #define  SWIG_SyntaxError          -8 
00128 #define  SWIG_ValueError           -9 
00129 #define  SWIG_SystemError          -10
00130 #define  SWIG_AttributeError       -11
00131 #define  SWIG_MemoryError          -12 
00132 #define  SWIG_NullReferenceError   -13
00133 
00134 
00135 /*  Errors in SWIG */
00136 #define  SWIG_UnknownError         -1 
00137 #define  SWIG_IOError              -2 
00138 #define  SWIG_RuntimeError         -3 
00139 #define  SWIG_IndexError           -4 
00140 #define  SWIG_TypeError            -5 
00141 #define  SWIG_DivisionByZero       -6 
00142 #define  SWIG_OverflowError        -7 
00143 #define  SWIG_SyntaxError          -8 
00144 #define  SWIG_ValueError           -9 
00145 #define  SWIG_SystemError          -10
00146 #define  SWIG_AttributeError       -11
00147 #define  SWIG_MemoryError          -12 
00148 #define  SWIG_NullReferenceError   -13
00149 
00150 
00151 /* -----------------------------------------------------------------------------
00152  * swigrun.swg
00153  *
00154  * This file contains generic C API SWIG runtime support for pointer
00155  * type checking.
00156  * ----------------------------------------------------------------------------- */
00157 
00158 /* This should only be incremented when either the layout of swig_type_info changes,
00159    or for whatever reason, the runtime changes incompatibly */
00160 #define SWIG_RUNTIME_VERSION "4"
00161 
00162 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
00163 #ifdef SWIG_TYPE_TABLE
00164 # define SWIG_QUOTE_STRING(x) #x
00165 # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
00166 # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
00167 #else
00168 # define SWIG_TYPE_TABLE_NAME
00169 #endif
00170 
00171 /*
00172   You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
00173   creating a static or dynamic library from the SWIG runtime code.
00174   In 99.9% of the cases, SWIG just needs to declare them as 'static'.
00175   
00176   But only do this if strictly necessary, ie, if you have problems
00177   with your compiler or suchlike.
00178 */
00179 
00180 #ifndef SWIGRUNTIME
00181 # define SWIGRUNTIME SWIGINTERN
00182 #endif
00183 
00184 #ifndef SWIGRUNTIMEINLINE
00185 # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
00186 #endif
00187 
00188 /*  Generic buffer size */
00189 #ifndef SWIG_BUFFER_SIZE
00190 # define SWIG_BUFFER_SIZE 1024
00191 #endif
00192 
00193 /* Flags for pointer conversions */
00194 #define SWIG_POINTER_DISOWN        0x1
00195 #define SWIG_CAST_NEW_MEMORY       0x2
00196 
00197 /* Flags for new pointer objects */
00198 #define SWIG_POINTER_OWN           0x1
00199 
00200 
00201 /* 
00202    Flags/methods for returning states.
00203    
00204    The SWIG conversion methods, as ConvertPtr, return an integer 
00205    that tells if the conversion was successful or not. And if not,
00206    an error code can be returned (see swigerrors.swg for the codes).
00207    
00208    Use the following macros/flags to set or process the returning
00209    states.
00210    
00211    In old versions of SWIG, code such as the following was usually written:
00212 
00213      if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
00214        // success code
00215      } else {
00216        //fail code
00217      }
00218 
00219    Now you can be more explicit:
00220 
00221     int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
00222     if (SWIG_IsOK(res)) {
00223       // success code
00224     } else {
00225       // fail code
00226     }
00227 
00228    which is the same really, but now you can also do
00229 
00230     Type *ptr;
00231     int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
00232     if (SWIG_IsOK(res)) {
00233       // success code
00234       if (SWIG_IsNewObj(res) {
00235         ...
00236         delete *ptr;
00237       } else {
00238         ...
00239       }
00240     } else {
00241       // fail code
00242     }
00243     
00244    I.e., now SWIG_ConvertPtr can return new objects and you can
00245    identify the case and take care of the deallocation. Of course that
00246    also requires SWIG_ConvertPtr to return new result values, such as
00247 
00248       int SWIG_ConvertPtr(obj, ptr,...) {         
00249         if (<obj is ok>) {                             
00250           if (<need new object>) {                     
00251             *ptr = <ptr to new allocated object>; 
00252             return SWIG_NEWOBJ;                
00253           } else {                                     
00254             *ptr = <ptr to old object>;        
00255             return SWIG_OLDOBJ;                
00256           }                                    
00257         } else {                                       
00258           return SWIG_BADOBJ;                  
00259         }                                              
00260       }
00261 
00262    Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
00263    more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
00264    SWIG errors code.
00265 
00266    Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
00267    allows to return the 'cast rank', for example, if you have this
00268 
00269        int food(double)
00270        int fooi(int);
00271 
00272    and you call
00273  
00274       food(1)   // cast rank '1'  (1 -> 1.0)
00275       fooi(1)   // cast rank '0'
00276 
00277    just use the SWIG_AddCast()/SWIG_CheckState()
00278 */
00279 
00280 #define SWIG_OK                    (0) 
00281 #define SWIG_ERROR                 (-1)
00282 #define SWIG_IsOK(r)               (r >= 0)
00283 #define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)  
00284 
00285 /* The CastRankLimit says how many bits are used for the cast rank */
00286 #define SWIG_CASTRANKLIMIT         (1 << 8)
00287 /* The NewMask denotes the object was created (using new/malloc) */
00288 #define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
00289 /* The TmpMask is for in/out typemaps that use temporal objects */
00290 #define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
00291 /* Simple returning values */
00292 #define SWIG_BADOBJ                (SWIG_ERROR)
00293 #define SWIG_OLDOBJ                (SWIG_OK)
00294 #define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
00295 #define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
00296 /* Check, add and del mask methods */
00297 #define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
00298 #define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
00299 #define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
00300 #define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
00301 #define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
00302 #define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
00303 
00304 /* Cast-Rank Mode */
00305 #if defined(SWIG_CASTRANK_MODE)
00306 #  ifndef SWIG_TypeRank
00307 #    define SWIG_TypeRank             unsigned long
00308 #  endif
00309 #  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
00310 #    define SWIG_MAXCASTRANK          (2)
00311 #  endif
00312 #  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
00313 #  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
00314 SWIGINTERNINLINE int SWIG_AddCast(int r) { 
00315   return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
00316 }
00317 SWIGINTERNINLINE int SWIG_CheckState(int r) { 
00318   return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 
00319 }
00320 #else /* no cast-rank mode */
00321 #  define SWIG_AddCast
00322 #  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
00323 #endif
00324 
00325 
00326 #include <string.h>
00327 
00328 #ifdef __cplusplus
00329 extern "C" {
00330 #endif
00331 
00332 typedef void *(*swig_converter_func)(void *, int *);
00333 typedef struct swig_type_info *(*swig_dycast_func)(void **);
00334 
00335 /* Structure to store information on one type */
00336 typedef struct swig_type_info {
00337   const char             *name;                 /* mangled name of this type */
00338   const char             *str;                  /* human readable name of this type */
00339   swig_dycast_func        dcast;                /* dynamic cast function down a hierarchy */
00340   struct swig_cast_info  *cast;                 /* linked list of types that can cast into this type */
00341   void                   *clientdata;           /* language specific type data */
00342   int                    owndata;               /* flag if the structure owns the clientdata */
00343 } swig_type_info;
00344 
00345 /* Structure to store a type and conversion function used for casting */
00346 typedef struct swig_cast_info {
00347   swig_type_info         *type;                 /* pointer to type that is equivalent to this type */
00348   swig_converter_func     converter;            /* function to cast the void pointers */
00349   struct swig_cast_info  *next;                 /* pointer to next cast in linked list */
00350   struct swig_cast_info  *prev;                 /* pointer to the previous cast */
00351 } swig_cast_info;
00352 
00353 /* Structure used to store module information
00354  * Each module generates one structure like this, and the runtime collects
00355  * all of these structures and stores them in a circularly linked list.*/
00356 typedef struct swig_module_info {
00357   swig_type_info         **types;               /* Array of pointers to swig_type_info structures that are in this module */
00358   size_t                 size;                  /* Number of types in this module */
00359   struct swig_module_info *next;                /* Pointer to next element in circularly linked list */
00360   swig_type_info         **type_initial;        /* Array of initially generated type structures */
00361   swig_cast_info         **cast_initial;        /* Array of initially generated casting structures */
00362   void                    *clientdata;          /* Language specific module data */
00363 } swig_module_info;
00364 
00365 /* 
00366   Compare two type names skipping the space characters, therefore
00367   "char*" == "char *" and "Class<int>" == "Class<int >", etc.
00368 
00369   Return 0 when the two name types are equivalent, as in
00370   strncmp, but skipping ' '.
00371 */
00372 SWIGRUNTIME int
00373 SWIG_TypeNameComp(const char *f1, const char *l1,
00374                   const char *f2, const char *l2) {
00375   for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
00376     while ((*f1 == ' ') && (f1 != l1)) ++f1;
00377     while ((*f2 == ' ') && (f2 != l2)) ++f2;
00378     if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
00379   }
00380   return (int)((l1 - f1) - (l2 - f2));
00381 }
00382 
00383 /*
00384   Check type equivalence in a name list like <name1>|<name2>|...
00385   Return 0 if not equal, 1 if equal
00386 */
00387 SWIGRUNTIME int
00388 SWIG_TypeEquiv(const char *nb, const char *tb) {
00389   int equiv = 0;
00390   const char* te = tb + strlen(tb);
00391   const char* ne = nb;
00392   while (!equiv && *ne) {
00393     for (nb = ne; *ne; ++ne) {
00394       if (*ne == '|') break;
00395     }
00396     equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
00397     if (*ne) ++ne;
00398   }
00399   return equiv;
00400 }
00401 
00402 /*
00403   Check type equivalence in a name list like <name1>|<name2>|...
00404   Return 0 if equal, -1 if nb < tb, 1 if nb > tb
00405 */
00406 SWIGRUNTIME int
00407 SWIG_TypeCompare(const char *nb, const char *tb) {
00408   int equiv = 0;
00409   const char* te = tb + strlen(tb);
00410   const char* ne = nb;
00411   while (!equiv && *ne) {
00412     for (nb = ne; *ne; ++ne) {
00413       if (*ne == '|') break;
00414     }
00415     equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
00416     if (*ne) ++ne;
00417   }
00418   return equiv;
00419 }
00420 
00421 
00422 /*
00423   Check the typename
00424 */
00425 SWIGRUNTIME swig_cast_info *
00426 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
00427   if (ty) {
00428     swig_cast_info *iter = ty->cast;
00429     while (iter) {
00430       if (strcmp(iter->type->name, c) == 0) {
00431         if (iter == ty->cast)
00432           return iter;
00433         /* Move iter to the top of the linked list */
00434         iter->prev->next = iter->next;
00435         if (iter->next)
00436           iter->next->prev = iter->prev;
00437         iter->next = ty->cast;
00438         iter->prev = 0;
00439         if (ty->cast) ty->cast->prev = iter;
00440         ty->cast = iter;
00441         return iter;
00442       }
00443       iter = iter->next;
00444     }
00445   }
00446   return 0;
00447 }
00448 
00449 /* 
00450   Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
00451 */
00452 SWIGRUNTIME swig_cast_info *
00453 SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
00454   if (ty) {
00455     swig_cast_info *iter = ty->cast;
00456     while (iter) {
00457       if (iter->type == from) {
00458         if (iter == ty->cast)
00459           return iter;
00460         /* Move iter to the top of the linked list */
00461         iter->prev->next = iter->next;
00462         if (iter->next)
00463           iter->next->prev = iter->prev;
00464         iter->next = ty->cast;
00465         iter->prev = 0;
00466         if (ty->cast) ty->cast->prev = iter;
00467         ty->cast = iter;
00468         return iter;
00469       }
00470       iter = iter->next;
00471     }
00472   }
00473   return 0;
00474 }
00475 
00476 /*
00477   Cast a pointer up an inheritance hierarchy
00478 */
00479 SWIGRUNTIMEINLINE void *
00480 SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
00481   return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
00482 }
00483 
00484 /* 
00485    Dynamic pointer casting. Down an inheritance hierarchy
00486 */
00487 SWIGRUNTIME swig_type_info *
00488 SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
00489   swig_type_info *lastty = ty;
00490   if (!ty || !ty->dcast) return ty;
00491   while (ty && (ty->dcast)) {
00492     ty = (*ty->dcast)(ptr);
00493     if (ty) lastty = ty;
00494   }
00495   return lastty;
00496 }
00497 
00498 /*
00499   Return the name associated with this type
00500 */
00501 SWIGRUNTIMEINLINE const char *
00502 SWIG_TypeName(const swig_type_info *ty) {
00503   return ty->name;
00504 }
00505 
00506 /*
00507   Return the pretty name associated with this type,
00508   that is an unmangled type name in a form presentable to the user.
00509 */
00510 SWIGRUNTIME const char *
00511 SWIG_TypePrettyName(const swig_type_info *type) {
00512   /* The "str" field contains the equivalent pretty names of the
00513      type, separated by vertical-bar characters.  We choose
00514      to print the last name, as it is often (?) the most
00515      specific. */
00516   if (!type) return NULL;
00517   if (type->str != NULL) {
00518     const char *last_name = type->str;
00519     const char *s;
00520     for (s = type->str; *s; s++)
00521       if (*s == '|') last_name = s+1;
00522     return last_name;
00523   }
00524   else
00525     return type->name;
00526 }
00527 
00528 /* 
00529    Set the clientdata field for a type
00530 */
00531 SWIGRUNTIME void
00532 SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
00533   swig_cast_info *cast = ti->cast;
00534   /* if (ti->clientdata == clientdata) return; */
00535   ti->clientdata = clientdata;
00536   
00537   while (cast) {
00538     if (!cast->converter) {
00539       swig_type_info *tc = cast->type;
00540       if (!tc->clientdata) {
00541         SWIG_TypeClientData(tc, clientdata);
00542       }
00543     }    
00544     cast = cast->next;
00545   }
00546 }
00547 SWIGRUNTIME void
00548 SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
00549   SWIG_TypeClientData(ti, clientdata);
00550   ti->owndata = 1;
00551 }
00552   
00553 /*
00554   Search for a swig_type_info structure only by mangled name
00555   Search is a O(log #types)
00556   
00557   We start searching at module start, and finish searching when start == end.  
00558   Note: if start == end at the beginning of the function, we go all the way around
00559   the circular list.
00560 */
00561 SWIGRUNTIME swig_type_info *
00562 SWIG_MangledTypeQueryModule(swig_module_info *start, 
00563                             swig_module_info *end, 
00564                             const char *name) {
00565   swig_module_info *iter = start;
00566   do {
00567     if (iter->size) {
00568       register size_t l = 0;
00569       register size_t r = iter->size - 1;
00570       do {
00571         /* since l+r >= 0, we can (>> 1) instead (/ 2) */
00572         register size_t i = (l + r) >> 1; 
00573         const char *iname = iter->types[i]->name;
00574         if (iname) {
00575           register int compare = strcmp(name, iname);
00576           if (compare == 0) {       
00577             return iter->types[i];
00578           } else if (compare < 0) {
00579             if (i) {
00580               r = i - 1;
00581             } else {
00582               break;
00583             }
00584           } else if (compare > 0) {
00585             l = i + 1;
00586           }
00587         } else {
00588           break; /* should never happen */
00589         }
00590       } while (l <= r);
00591     }
00592     iter = iter->next;
00593   } while (iter != end);
00594   return 0;
00595 }
00596 
00597 /*
00598   Search for a swig_type_info structure for either a mangled name or a human readable name.
00599   It first searches the mangled names of the types, which is a O(log #types)
00600   If a type is not found it then searches the human readable names, which is O(#types).
00601   
00602   We start searching at module start, and finish searching when start == end.  
00603   Note: if start == end at the beginning of the function, we go all the way around
00604   the circular list.
00605 */
00606 SWIGRUNTIME swig_type_info *
00607 SWIG_TypeQueryModule(swig_module_info *start, 
00608                      swig_module_info *end, 
00609                      const char *name) {
00610   /* STEP 1: Search the name field using binary search */
00611   swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
00612   if (ret) {
00613     return ret;
00614   } else {
00615     /* STEP 2: If the type hasn't been found, do a complete search
00616        of the str field (the human readable name) */
00617     swig_module_info *iter = start;
00618     do {
00619       register size_t i = 0;
00620       for (; i < iter->size; ++i) {
00621         if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
00622           return iter->types[i];
00623       }
00624       iter = iter->next;
00625     } while (iter != end);
00626   }
00627   
00628   /* neither found a match */
00629   return 0;
00630 }
00631 
00632 /* 
00633    Pack binary data into a string
00634 */
00635 SWIGRUNTIME char *
00636 SWIG_PackData(char *c, void *ptr, size_t sz) {
00637   static const char hex[17] = "0123456789abcdef";
00638   register const unsigned char *u = (unsigned char *) ptr;
00639   register const unsigned char *eu =  u + sz;
00640   for (; u != eu; ++u) {
00641     register unsigned char uu = *u;
00642     *(c++) = hex[(uu & 0xf0) >> 4];
00643     *(c++) = hex[uu & 0xf];
00644   }
00645   return c;
00646 }
00647 
00648 /* 
00649    Unpack binary data from a string
00650 */
00651 SWIGRUNTIME const char *
00652 SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
00653   register unsigned char *u = (unsigned char *) ptr;
00654   register const unsigned char *eu = u + sz;
00655   for (; u != eu; ++u) {
00656     register char d = *(c++);
00657     register unsigned char uu;
00658     if ((d >= '0') && (d <= '9'))
00659       uu = ((d - '0') << 4);
00660     else if ((d >= 'a') && (d <= 'f'))
00661       uu = ((d - ('a'-10)) << 4);
00662     else 
00663       return (char *) 0;
00664     d = *(c++);
00665     if ((d >= '0') && (d <= '9'))
00666       uu |= (d - '0');
00667     else if ((d >= 'a') && (d <= 'f'))
00668       uu |= (d - ('a'-10));
00669     else 
00670       return (char *) 0;
00671     *u = uu;
00672   }
00673   return c;
00674 }
00675 
00676 /* 
00677    Pack 'void *' into a string buffer.
00678 */
00679 SWIGRUNTIME char *
00680 SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
00681   char *r = buff;
00682   if ((2*sizeof(void *) + 2) > bsz) return 0;
00683   *(r++) = '_';
00684   r = SWIG_PackData(r,&ptr,sizeof(void *));
00685   if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
00686   strcpy(r,name);
00687   return buff;
00688 }
00689 
00690 SWIGRUNTIME const char *
00691 SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
00692   if (*c != '_') {
00693     if (strcmp(c,"NULL") == 0) {
00694       *ptr = (void *) 0;
00695       return name;
00696     } else {
00697       return 0;
00698     }
00699   }
00700   return SWIG_UnpackData(++c,ptr,sizeof(void *));
00701 }
00702 
00703 SWIGRUNTIME char *
00704 SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
00705   char *r = buff;
00706   size_t lname = (name ? strlen(name) : 0);
00707   if ((2*sz + 2 + lname) > bsz) return 0;
00708   *(r++) = '_';
00709   r = SWIG_PackData(r,ptr,sz);
00710   if (lname) {
00711     strncpy(r,name,lname+1);
00712   } else {
00713     *r = 0;
00714   }
00715   return buff;
00716 }
00717 
00718 SWIGRUNTIME const char *
00719 SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
00720   if (*c != '_') {
00721     if (strcmp(c,"NULL") == 0) {
00722       memset(ptr,0,sz);
00723       return name;
00724     } else {
00725       return 0;
00726     }
00727   }
00728   return SWIG_UnpackData(++c,ptr,sz);
00729 }
00730 
00731 #ifdef __cplusplus
00732 }
00733 #endif
00734 /* -----------------------------------------------------------------------------
00735  * luarun.swg
00736  *
00737  * This file contains the runtime support for Lua modules
00738  * and includes code for managing global variables and pointer
00739  * type checking.
00740  * ----------------------------------------------------------------------------- */
00741 
00742 #ifdef __cplusplus
00743 extern "C" {
00744 #endif
00745 
00746 #include "lua.h"
00747 #include "lauxlib.h"
00748 #include <stdlib.h>  /* for malloc */
00749 #include <assert.h>  /* for a few sanity tests */
00750 
00751 /* -----------------------------------------------------------------------------
00752  * global swig types
00753  * ----------------------------------------------------------------------------- */
00754 /* Constant table */
00755 #define SWIG_LUA_INT     1
00756 #define SWIG_LUA_FLOAT   2
00757 #define SWIG_LUA_STRING  3
00758 #define SWIG_LUA_POINTER 4
00759 #define SWIG_LUA_BINARY  5
00760 #define SWIG_LUA_CHAR    6
00761 
00762 /* Structure for variable linking table */
00763 typedef struct {
00764   const char *name;
00765   lua_CFunction get;
00766   lua_CFunction set;
00767 } swig_lua_var_info;
00768 
00769 /* Constant information structure */
00770 typedef struct {
00771     int type;
00772     char *name;
00773     long lvalue;
00774     double dvalue;
00775     void   *pvalue;
00776     swig_type_info **ptype;
00777 } swig_lua_const_info;
00778 
00779 typedef struct {
00780   const char     *name;
00781   lua_CFunction   method;
00782 } swig_lua_method;
00783 
00784 typedef struct {
00785   const char     *name;
00786   lua_CFunction   getmethod;
00787   lua_CFunction   setmethod;
00788 } swig_lua_attribute;
00789 
00790 typedef struct swig_lua_class {
00791   const char    *name;
00792   swig_type_info   **type;
00793   lua_CFunction  constructor;
00794   void    (*destructor)(void *);
00795   swig_lua_method   *methods;
00796   swig_lua_attribute     *attributes;
00797   struct swig_lua_class **bases;
00798   const char **base_names;
00799 } swig_lua_class;
00800 
00801 /* this is the struct for wrappering all pointers in SwigLua
00802 */
00803 typedef struct {
00804   swig_type_info   *type;
00805   int     own;  /* 1 if owned & must be destroyed */
00806   void        *ptr;
00807 } swig_lua_userdata;
00808 
00809 /* this is the struct for wrapping arbitary packed binary data
00810 (currently it is only used for member function pointers)
00811 the data ordering is similar to swig_lua_userdata, but it is currently not possible
00812 to tell the two structures apart within SWIG, other than by looking at the type
00813 */
00814 typedef struct {
00815   swig_type_info   *type;
00816   int     own;  /* 1 if owned & must be destroyed */
00817   char data[1];       /* arbitary amount of data */    
00818 } swig_lua_rawdata;
00819 
00820 /* Common SWIG API */
00821 #define SWIG_NewPointerObj(L, ptr, type, owner)       SWIG_Lua_NewPointerObj(L, (void *)ptr, type, owner)
00822 #define SWIG_ConvertPtr(L,idx, ptr, type, flags)    SWIG_Lua_ConvertPtr(L,idx,ptr,type,flags)
00823 #define SWIG_MustGetPtr(L,idx, type,flags, argnum,fnname)  SWIG_Lua_MustGetPtr(L,idx, type,flags, argnum,fnname)
00824 /* for C++ member pointers, ie, member methods */
00825 #define SWIG_ConvertMember(L, idx, ptr, sz, ty)       SWIG_Lua_ConvertPacked(L, idx, ptr, sz, ty)
00826 #define SWIG_NewMemberObj(L, ptr, sz, type)      SWIG_Lua_NewPackedObj(L, ptr, sz, type)
00827 
00828 /* Runtime API */
00829 #define SWIG_GetModule(clientdata) SWIG_Lua_GetModule((lua_State*)(clientdata))
00830 #define SWIG_SetModule(clientdata, pointer) SWIG_Lua_SetModule((lua_State*) (clientdata), pointer)
00831 #define SWIG_MODULE_CLIENTDATA_TYPE lua_State*
00832 
00833 /* Contract support */
00834 #define SWIG_contract_assert(expr, msg)  \
00835   if (!(expr)) { lua_pushstring(L, (char *) msg); goto fail; } else
00836 
00837 /* helper #defines */
00838 #define SWIG_fail {goto fail;}
00839 #define SWIG_fail_arg(func_name,argnum,type) \
00840   {lua_pushfstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\
00841   func_name,argnum,type,SWIG_Lua_typename(L,argnum));\
00842   goto fail;}
00843 #define SWIG_fail_ptr(func_name,argnum,type) \
00844   SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*")
00845 #define SWIG_check_num_args(func_name,a,b) \
00846   if (lua_gettop(L)<a || lua_gettop(L)>b) \
00847   {lua_pushfstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\
00848   goto fail;}
00849 
00850 
00851 #define SWIG_Lua_get_table(L,n) \
00852   (lua_pushstring(L, n), lua_rawget(L,-2))
00853 
00854 #define SWIG_Lua_add_function(L,n,f) \
00855   (lua_pushstring(L, n), \
00856       lua_pushcfunction(L, f), \
00857       lua_rawset(L,-3))
00858 
00859 /* special helper for allowing 'nil' for usertypes */
00860 #define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I))
00861 
00862 #ifdef __cplusplus
00863 /* Special helper for member function pointers 
00864 it gets the address, casts it, then dereferences it */
00865 //#define SWIG_mem_fn_as_voidptr(a)  (*((char**)&(a)))
00866 #endif
00867 
00868 /* storing/access of swig_module_info */
00869 SWIGRUNTIME swig_module_info *
00870 SWIG_Lua_GetModule(lua_State* L) {
00871   swig_module_info *ret = 0;
00872   lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
00873   lua_rawget(L,LUA_REGISTRYINDEX);
00874   if (lua_islightuserdata(L,-1))
00875     ret=(swig_module_info*)lua_touserdata(L,-1);
00876   lua_pop(L,1);  /* tidy */
00877   return ret;
00878 }
00879 
00880 SWIGRUNTIME void
00881 SWIG_Lua_SetModule(lua_State* L, swig_module_info *module) {
00882   /* add this all into the Lua registry: */
00883   lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
00884   lua_pushlightuserdata(L,(void*)module);
00885   lua_rawset(L,LUA_REGISTRYINDEX);
00886 }
00887 
00888 /* -----------------------------------------------------------------------------
00889  * global variable support code: modules
00890  * ----------------------------------------------------------------------------- */
00891 
00892 /* this function is called when trying to set an immutable.
00893 default value is to print an error.
00894 This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */
00895 SWIGINTERN int SWIG_Lua_set_immutable(lua_State* L)
00896 {
00897 /*  there should be 1 param passed in: the new value */
00898 #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE
00899   lua_pop(L,1);  /* remove it */
00900   lua_pushstring(L,"This variable is immutable");
00901   lua_error(L);
00902 #endif
00903     return 0;   /* should not return anything */
00904 }
00905 
00906 /* the module.get method used for getting linked data */
00907 SWIGINTERN int SWIG_Lua_module_get(lua_State* L)
00908 {
00909 /*  there should be 2 params passed in
00910   (1) table (not the meta table)
00911   (2) string name of the attribute
00912   printf("SWIG_Lua_module_get %p(%s) '%s'\n",
00913    lua_topointer(L,1),lua_typename(L,lua_type(L,1)),
00914    lua_tostring(L,2));
00915 */
00916   /* get the metatable */
00917   assert(lua_istable(L,1));  /* just in case */
00918   lua_getmetatable(L,1);  /* get the metatable */
00919   assert(lua_istable(L,-1));  /* just in case */
00920   SWIG_Lua_get_table(L,".get");  /* get the .get table */
00921   lua_remove(L,3);  /* remove metatable */
00922   if (lua_istable(L,-1))
00923   {
00924     /* look for the key in the .get table */
00925     lua_pushvalue(L,2);  /* key */
00926     lua_rawget(L,-2);
00927     lua_remove(L,3);  /* remove .get */
00928     if (lua_iscfunction(L,-1))
00929     {  /* found it so call the fn & return its value */
00930       lua_call(L,0,1);
00931       return 1;
00932     }
00933     lua_pop(L,1);  /* remove the top */
00934   }
00935   lua_pop(L,1);  /* remove the .get */
00936   lua_pushnil(L);  /* return a nil */
00937     return 1;
00938 }
00939 
00940 /* the module.set method used for setting linked data */
00941 SWIGINTERN int SWIG_Lua_module_set(lua_State* L)
00942 {
00943 /*  there should be 3 params passed in
00944   (1) table (not the meta table)
00945   (2) string name of the attribute
00946   (3) any for the new value
00947 */
00948   /* get the metatable */
00949   assert(lua_istable(L,1));  /* just in case */
00950   lua_getmetatable(L,1);  /* get the metatable */
00951   assert(lua_istable(L,-1));  /* just in case */
00952   SWIG_Lua_get_table(L,".set");  /* get the .set table */
00953   lua_remove(L,4);  /* remove metatable */
00954   if (lua_istable(L,-1))
00955   {
00956     /* look for the key in the .set table */
00957     lua_pushvalue(L,2);  /* key */
00958     lua_rawget(L,-2);
00959     lua_remove(L,4);  /* remove .set */
00960     if (lua_iscfunction(L,-1))
00961     {  /* found it so call the fn & return its value */
00962       lua_pushvalue(L,3);  /* value */
00963       lua_call(L,1,0);
00964       return 0;
00965     }
00966   }
00967   lua_settop(L,3);  /* reset back to start */
00968   /* we now have the table, key & new value, so just set directly */
00969   lua_rawset(L,1);  /* add direct */
00970   return 0;
00971 }
00972 
00973 /* registering a module in lua */
00974 SWIGINTERN void  SWIG_Lua_module_begin(lua_State* L,const char* name)
00975 {
00976   assert(lua_istable(L,-1));  /* just in case */
00977   lua_pushstring(L,name);
00978   lua_newtable(L);   /* the table */
00979   /* add meta table */
00980   lua_newtable(L);    /* the meta table */
00981   SWIG_Lua_add_function(L,"__index",SWIG_Lua_module_get);
00982   SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_module_set);
00983   lua_pushstring(L,".get");
00984   lua_newtable(L);    /* the .get table */
00985   lua_rawset(L,-3);  /* add .get into metatable */
00986   lua_pushstring(L,".set");
00987   lua_newtable(L);    /* the .set table */
00988   lua_rawset(L,-3);  /* add .set into metatable */
00989   lua_setmetatable(L,-2);  /* sets meta table in module */
00990   lua_rawset(L,-3);        /* add module into parent */
00991   SWIG_Lua_get_table(L,name);   /* get the table back out */
00992 }
00993 
00994 /* ending the register */
00995 SWIGINTERN void  SWIG_Lua_module_end(lua_State* L)
00996 {
00997   lua_pop(L,1);       /* tidy stack (remove module) */
00998 }
00999 
01000 /* adding a linked variable to the module */
01001 SWIGINTERN void SWIG_Lua_module_add_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn)
01002 {
01003   assert(lua_istable(L,-1));  /* just in case */
01004   lua_getmetatable(L,-1);  /* get the metatable */
01005   assert(lua_istable(L,-1));  /* just in case */
01006   SWIG_Lua_get_table(L,".get"); /* find the .get table */
01007   assert(lua_istable(L,-1));  /* should be a table: */
01008   SWIG_Lua_add_function(L,name,getFn);
01009   lua_pop(L,1);       /* tidy stack (remove table) */
01010   if (setFn)  /* if there is a set fn */
01011   {
01012     SWIG_Lua_get_table(L,".set"); /* find the .set table */
01013     assert(lua_istable(L,-1));  /* should be a table: */
01014     SWIG_Lua_add_function(L,name,setFn);
01015     lua_pop(L,1);       /* tidy stack (remove table) */
01016   }
01017   lua_pop(L,1);       /* tidy stack (remove meta) */
01018 }
01019 
01020 /* adding a function module */
01021 SWIGINTERN void  SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_CFunction fn)
01022 {
01023   SWIG_Lua_add_function(L,name,fn);
01024 }
01025 
01026 /* -----------------------------------------------------------------------------
01027  * global variable support code: classes
01028  * ----------------------------------------------------------------------------- */
01029 
01030 /* the class.get method, performs the lookup of class attributes */
01031 SWIGINTERN int  SWIG_Lua_class_get(lua_State* L)
01032 {
01033 /*  there should be 2 params passed in
01034   (1) userdata (not the meta table)
01035   (2) string name of the attribute
01036 */
01037   assert(lua_isuserdata(L,-2));  /* just in case */
01038   lua_getmetatable(L,-2);    /* get the meta table */
01039   assert(lua_istable(L,-1));  /* just in case */
01040   SWIG_Lua_get_table(L,".get"); /* find the .get table */
01041   assert(lua_istable(L,-1));  /* just in case */
01042   /* look for the key in the .get table */
01043   lua_pushvalue(L,2);  /* key */
01044   lua_rawget(L,-2);
01045   lua_remove(L,-2); /* stack tidy, remove .get table */
01046   if (lua_iscfunction(L,-1))
01047   {  /* found it so call the fn & return its value */
01048     lua_pushvalue(L,1);  /* the userdata */
01049     lua_call(L,1,1);  /* 1 value in (userdata),1 out (result) */
01050     lua_remove(L,-2); /* stack tidy, remove metatable */
01051     return 1;
01052   }
01053   lua_pop(L,1);  /* remove whatever was there */
01054   /* ok, so try the .fn table */
01055   SWIG_Lua_get_table(L,".fn"); /* find the .get table */
01056   assert(lua_istable(L,-1));  /* just in case */
01057   lua_pushvalue(L,2);  /* key */
01058   lua_rawget(L,-2);  /* look for the fn */
01059   lua_remove(L,-2); /* stack tidy, remove .fn table */
01060   if (lua_isfunction(L,-1)) /* note: if its a C function or lua function */
01061   {  /* found it so return the fn & let lua call it */
01062     lua_remove(L,-2); /* stack tidy, remove metatable */
01063     return 1;
01064   }
01065   lua_pop(L,1);  /* remove whatever was there */
01066   /* NEW: looks for the __getitem() fn
01067   this is a user provided get fn */
01068   SWIG_Lua_get_table(L,"__getitem"); /* find the __getitem fn */
01069   if (lua_iscfunction(L,-1))  /* if its there */
01070   {  /* found it so call the fn & return its value */
01071     lua_pushvalue(L,1);  /* the userdata */
01072     lua_pushvalue(L,2);  /* the parameter */
01073     lua_call(L,2,1);  /* 2 value in (userdata),1 out (result) */
01074     lua_remove(L,-2); /* stack tidy, remove metatable */
01075     return 1;
01076   }
01077   return 0;  /* sorry not known */
01078 }
01079 
01080 /* the class.set method, performs the lookup of class attributes */
01081 SWIGINTERN int  SWIG_Lua_class_set(lua_State* L)
01082 {
01083 /*  there should be 3 params passed in
01084   (1) table (not the meta table)
01085   (2) string name of the attribute
01086   (3) any for the new value
01087 printf("SWIG_Lua_class_set %p(%s) '%s' %p(%s)\n",
01088       lua_topointer(L,1),lua_typename(L,lua_type(L,1)),
01089       lua_tostring(L,2),
01090       lua_topointer(L,3),lua_typename(L,lua_type(L,3)));*/
01091 
01092   assert(lua_isuserdata(L,1));  /* just in case */
01093   lua_getmetatable(L,1);    /* get the meta table */
01094   assert(lua_istable(L,-1));  /* just in case */
01095 
01096   SWIG_Lua_get_table(L,".set"); /* find the .set table */
01097   if (lua_istable(L,-1))
01098   {
01099     /* look for the key in the .set table */
01100     lua_pushvalue(L,2);  /* key */
01101     lua_rawget(L,-2);
01102     if (lua_iscfunction(L,-1))
01103     {  /* found it so call the fn & return its value */
01104       lua_pushvalue(L,1);  /* userdata */
01105       lua_pushvalue(L,3);  /* value */
01106       lua_call(L,2,0);
01107       return 0;
01108     }
01109     lua_pop(L,1);  /* remove the value */
01110   }
01111   lua_pop(L,1);  /* remove the value .set table */
01112   /* NEW: looks for the __setitem() fn
01113   this is a user provided set fn */
01114   SWIG_Lua_get_table(L,"__setitem"); /* find the fn */
01115   if (lua_iscfunction(L,-1))  /* if its there */
01116   {  /* found it so call the fn & return its value */
01117     lua_pushvalue(L,1);  /* the userdata */
01118     lua_pushvalue(L,2);  /* the parameter */
01119     lua_pushvalue(L,3);  /* the value */
01120     lua_call(L,3,0);  /* 3 values in ,0 out */
01121     lua_remove(L,-2); /* stack tidy, remove metatable */
01122     return 1;
01123   }
01124   return 0;
01125 }
01126 
01127 /* the class.destruct method called by the interpreter */
01128 SWIGINTERN int  SWIG_Lua_class_destruct(lua_State* L)
01129 {
01130 /*  there should be 1 params passed in
01131   (1) userdata (not the meta table) */
01132   swig_lua_userdata* usr;
01133   swig_lua_class* clss;
01134   assert(lua_isuserdata(L,-1));  /* just in case */
01135   usr=(swig_lua_userdata*)lua_touserdata(L,-1);  /* get it */
01136   /* if must be destroyed & has a destructor */
01137   if (usr->own) /* if must be destroyed */
01138   {
01139     clss=(swig_lua_class*)usr->type->clientdata;  /* get the class */
01140     if (clss && clss->destructor)  /* there is a destroy fn */
01141     {
01142       clss->destructor(usr->ptr);  /* bye bye */
01143     }
01144   }
01145   return 0;
01146 }
01147 
01148 /* gets the swig class registry (or creates it) */
01149 SWIGINTERN void  SWIG_Lua_get_class_registry(lua_State* L)
01150 {
01151   /* add this all into the swig registry: */
01152   lua_pushstring(L,"SWIG");
01153   lua_rawget(L,LUA_REGISTRYINDEX);  /* get the registry */
01154   if (!lua_istable(L,-1))  /* not there */
01155   {  /* must be first time, so add it */
01156     lua_pop(L,1);  /* remove the result */
01157     lua_pushstring(L,"SWIG");
01158     lua_newtable(L);
01159     lua_rawset(L,LUA_REGISTRYINDEX);
01160     /* then get it */
01161     lua_pushstring(L,"SWIG");
01162     lua_rawget(L,LUA_REGISTRYINDEX);
01163   }
01164 }
01165 
01166 /* helper fn to get the classes metatable from the register */
01167 SWIGINTERN void  SWIG_Lua_get_class_metatable(lua_State* L,const char* cname)
01168 {
01169   SWIG_Lua_get_class_registry(L);  /* get the registry */
01170   lua_pushstring(L,cname);  /* get the name */
01171   lua_rawget(L,-2);    /* get it */
01172   lua_remove(L,-2);    /* tidy up (remove registry) */
01173 }
01174 
01175 /* helper add a variable to a registered class */
01176 SWIGINTERN void  SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn)
01177 {
01178   assert(lua_istable(L,-1));  /* just in case */
01179   SWIG_Lua_get_table(L,".get"); /* find the .get table */
01180   assert(lua_istable(L,-1));  /* just in case */
01181   SWIG_Lua_add_function(L,name,getFn);
01182   lua_pop(L,1);       /* tidy stack (remove table) */
01183   if (setFn)
01184   {
01185     SWIG_Lua_get_table(L,".set"); /* find the .set table */
01186     assert(lua_istable(L,-1));  /* just in case */
01187     SWIG_Lua_add_function(L,name,setFn);
01188     lua_pop(L,1);       /* tidy stack (remove table) */
01189   }
01190 }
01191 
01192 /* helper to recursively add class details (attributes & operations) */
01193 SWIGINTERN void  SWIG_Lua_add_class_details(lua_State* L,swig_lua_class* clss)
01194 {
01195   int i;
01196   /* call all the base classes first: we can then override these later: */
01197   for(i=0;clss->bases[i];i++)
01198   {
01199     SWIG_Lua_add_class_details(L,clss->bases[i]);
01200   }
01201   /* add fns */
01202   for(i=0;clss->attributes[i].name;i++){
01203     SWIG_Lua_add_class_variable(L,clss->attributes[i].name,clss->attributes[i].getmethod,clss->attributes[i].setmethod);
01204   }
01205   /* add methods to the metatable */
01206   SWIG_Lua_get_table(L,".fn"); /* find the .fn table */
01207   assert(lua_istable(L,-1));  /* just in case */
01208   for(i=0;clss->methods[i].name;i++){
01209     SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].method);
01210   }
01211   lua_pop(L,1);       /* tidy stack (remove table) */
01212   /*   add operator overloads
01213     these look ANY method which start with "__" and assume they
01214     are operator overloads & add them to the metatable
01215     (this might mess up is someone defines a method __gc (the destructor)*/
01216   for(i=0;clss->methods[i].name;i++){
01217     if (clss->methods[i].name[0]=='_' && clss->methods[i].name[1]=='_'){
01218       SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].method);
01219     }
01220   }
01221 }
01222 
01223 /* set up the base classes pointers.
01224 Each class structure has a list of pointers to the base class structures.
01225 This function fills them.
01226 It cannot be done at compile time, as this will not work with hireachies
01227 spread over more than one swig file. 
01228 Therefore it must be done at runtime, querying the SWIG type system.
01229 */
01230 SWIGINTERN void SWIG_Lua_init_base_class(lua_State* L,swig_lua_class* clss)
01231 {
01232   int i=0;
01233   swig_module_info* module=SWIG_GetModule(L);
01234   for(i=0;clss->base_names[i];i++)
01235   {
01236     if (clss->bases[i]==0) /* not found yet */
01237     {
01238       /* lookup and cache the base class */
01239       swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]);
01240       if (info) clss->bases[i] = (swig_lua_class *) info->clientdata;
01241     }
01242   }     
01243 }
01244 
01245 /* performs the entire class registration process */
01246 SWIGINTERN void  SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss)
01247 {
01248   /*  add its constructor to module with the name of the class
01249   so you can do MyClass(...) as well as new_MyClass(...)
01250   BUT only if a constructor is defined
01251   (this overcomes the problem of pure virtual classes without constructors)*/
01252   if (clss->constructor)
01253     SWIG_Lua_add_function(L,clss->name,clss->constructor);
01254 
01255   SWIG_Lua_get_class_registry(L);  /* get the registry */
01256   lua_pushstring(L,clss->name);  /* get the name */
01257   lua_newtable(L);    /* create the metatable */
01258   /* add string of class name called ".type" */
01259   lua_pushstring(L,".type");
01260   lua_pushstring(L,clss->name);
01261   lua_rawset(L,-3);
01262   /* add a table called ".get" */
01263   lua_pushstring(L,".get");
01264   lua_newtable(L);
01265   lua_rawset(L,-3);
01266   /* add a table called ".set" */
01267   lua_pushstring(L,".set");
01268   lua_newtable(L);
01269   lua_rawset(L,-3);
01270   /* add a table called ".fn" */
01271   lua_pushstring(L,".fn");
01272   lua_newtable(L);
01273   lua_rawset(L,-3);
01274   /* add accessor fns for using the .get,.set&.fn */
01275   SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get);
01276   SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set);
01277   SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct);
01278   /* add it */
01279   lua_rawset(L,-3);  /* metatable into registry */
01280   lua_pop(L,1);      /* tidy stack (remove registry) */
01281 
01282   SWIG_Lua_get_class_metatable(L,clss->name);
01283   SWIG_Lua_add_class_details(L,clss);  /* recursive adding of details (atts & ops) */
01284   lua_pop(L,1);      /* tidy stack (remove class metatable) */
01285 }
01286 
01287 /* -----------------------------------------------------------------------------
01288  * Class/structure conversion fns
01289  * ----------------------------------------------------------------------------- */
01290 
01291 /* helper to add metatable to new lua object */
01292 SWIGINTERN void _SWIG_Lua_AddMetatable(lua_State* L,swig_type_info *type)
01293 {
01294   if (type->clientdata)  /* there is clientdata: so add the metatable */
01295   {
01296     SWIG_Lua_get_class_metatable(L,((swig_lua_class*)(type->clientdata))->name);
01297     if (lua_istable(L,-1))
01298     {
01299       lua_setmetatable(L,-2);
01300     }
01301     else
01302     {
01303       lua_pop(L,1);
01304     }
01305   }
01306 }
01307 
01308 /* pushes a new object into the lua stack */
01309 SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State* L,void* ptr,swig_type_info *type, int own)
01310 {
01311   swig_lua_userdata* usr;
01312   if (!ptr){
01313     lua_pushnil(L);
01314     return;
01315   }
01316   usr=(swig_lua_userdata*)lua_newuserdata(L,sizeof(swig_lua_userdata));  /* get data */
01317   usr->ptr=ptr;  /* set the ptr */
01318   usr->type=type;
01319   usr->own=own;
01320   _SWIG_Lua_AddMetatable(L,type); /* add metatable */
01321 }
01322 
01323 /* takes a object from the lua stack & converts it into an object of the correct type
01324  (if possible) */
01325 SWIGRUNTIME int  SWIG_Lua_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags)
01326 {
01327   swig_lua_userdata* usr;
01328   swig_cast_info *cast;
01329   if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;}    /* special case: lua nil => NULL pointer */
01330   usr=(swig_lua_userdata*)lua_touserdata(L,index);  /* get data */
01331   if (usr)
01332   {
01333     if (flags & SWIG_POINTER_DISOWN) /* must disown the object */
01334     {
01335         usr->own=0;
01336     }
01337     if (!type)            /* special cast void*, no casting fn */
01338     {
01339       *ptr=usr->ptr;
01340       return SWIG_OK; /* ok */
01341     }
01342     cast=SWIG_TypeCheckStruct(usr->type,type); /* performs normal type checking */
01343     if (cast)
01344     {
01345       int newmemory = 0;
01346       *ptr=SWIG_TypeCast(cast,usr->ptr,&newmemory);
01347       assert(!newmemory); /* newmemory handling not yet implemented */
01348       return SWIG_OK;  /* ok */
01349     }
01350   }
01351   return SWIG_ERROR;  /* error */
01352 }
01353 
01354 SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State* L,int index,swig_type_info *type,int flags,
01355        int argnum,const char* func_name){
01356   void* result;
01357   if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){
01358     lua_pushfstring(L,"Error in %s, expected a %s at argument number %d\n",
01359       func_name,(type && type->str)?type->str:"void*",argnum);
01360     lua_error(L);
01361   }
01362   return result;
01363 }
01364 
01365 /* pushes a packed userdata. user for member fn pointers only */
01366 SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State* L,void* ptr,size_t size,swig_type_info *type)
01367 {
01368   swig_lua_rawdata* raw;
01369   assert(ptr); /* not acceptable to pass in a NULL value */
01370   raw=(swig_lua_rawdata*)lua_newuserdata(L,sizeof(swig_lua_rawdata)-1+size);  /* alloc data */
01371   raw->type=type;
01372   raw->own=0;
01373   memcpy(raw->data,ptr,size); /* copy the data */
01374   _SWIG_Lua_AddMetatable(L,type); /* add metatable */
01375 }
01376     
01377 /* converts a packed userdata. user for member fn pointers only */
01378 SWIGRUNTIME int  SWIG_Lua_ConvertPacked(lua_State* L,int index,void* ptr,size_t size,swig_type_info *type)
01379 {
01380   swig_lua_rawdata* raw;
01381   raw=(swig_lua_rawdata*)lua_touserdata(L,index);  /* get data */
01382   if (!raw) return SWIG_ERROR;  /* error */
01383   if (type==0 || type==raw->type) /* void* or identical type */
01384   {
01385     memcpy(ptr,raw->data,size); /* copy it */
01386     return SWIG_OK; /* ok */
01387   }
01388   return SWIG_ERROR;  /* error */
01389 }
01390 
01391 /* a function to get the typestring of a piece of data */
01392 SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp)
01393 {
01394   swig_lua_userdata* usr;
01395   if (lua_isuserdata(L,tp))
01396   {
01397     usr=(swig_lua_userdata*)lua_touserdata(L,tp);  /* get data */
01398     if (usr && usr->type && usr->type->str)
01399       return usr->type->str;
01400     return "userdata (unknown type)";
01401   }
01402   return lua_typename(L,lua_type(L,tp));
01403 }
01404 
01405 /* lua callable function to get the userdata's type */
01406 SWIGRUNTIME int SWIG_Lua_type(lua_State* L)
01407 {
01408   lua_pushstring(L,SWIG_Lua_typename(L,1));
01409   return 1;
01410 }
01411 
01412 /* lua callable function to compare userdata's value
01413 the issue is that two userdata may point to the same thing
01414 but to lua, they are different objects */
01415 SWIGRUNTIME int SWIG_Lua_equal(lua_State* L)
01416 {
01417   int result;
01418   swig_lua_userdata *usr1,*usr2;
01419   if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2))  /* just in case */
01420     return 0;  /* nil reply */
01421   usr1=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
01422   usr2=(swig_lua_userdata*)lua_touserdata(L,2);  /* get data */
01423   /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/
01424   result=(usr1->ptr==usr2->ptr);
01425    lua_pushboolean(L,result);
01426   return 1;
01427 }
01428 
01429 /* -----------------------------------------------------------------------------
01430  * global variable support code: class/struct typemap functions
01431  * ----------------------------------------------------------------------------- */
01432 
01433 /* Install Constants */
01434 SWIGINTERN void
01435 SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]) {
01436   int i;
01437   for (i = 0; constants[i].type; i++) {
01438     switch(constants[i].type) {
01439     case SWIG_LUA_INT:
01440       lua_pushstring(L,constants[i].name);
01441       lua_pushnumber(L,(lua_Number)constants[i].lvalue);
01442       lua_rawset(L,-3);
01443       break;
01444     case SWIG_LUA_FLOAT:
01445       lua_pushstring(L,constants[i].name);
01446       lua_pushnumber(L,(lua_Number)constants[i].dvalue);
01447       lua_rawset(L,-3);
01448       break;
01449     case SWIG_LUA_CHAR:
01450       lua_pushstring(L,constants[i].name);
01451       lua_pushfstring(L,"%c",(char)constants[i].lvalue);
01452       lua_rawset(L,-3);
01453       break;
01454     case SWIG_LUA_STRING:
01455       lua_pushstring(L,constants[i].name);
01456       lua_pushstring(L,(char *) constants[i].pvalue);
01457       lua_rawset(L,-3);
01458       break;
01459     case SWIG_LUA_POINTER:
01460       lua_pushstring(L,constants[i].name);
01461       SWIG_NewPointerObj(L,constants[i].pvalue, *(constants[i]).ptype,0);
01462       lua_rawset(L,-3);
01463       break;
01464     case SWIG_LUA_BINARY:
01465       lua_pushstring(L,constants[i].name);
01466       SWIG_NewMemberObj(L,constants[i].pvalue,constants[i].lvalue,*(constants[i]).ptype);
01467       lua_rawset(L,-3);
01468       break;
01469     default:
01470       break;
01471     }
01472   }
01473 }
01474 
01475 /* -----------------------------------------------------------------------------
01476  * executing lua code from within the wrapper
01477  * ----------------------------------------------------------------------------- */
01478 
01479 #ifndef SWIG_DOSTRING_FAIL /* Allows redefining of error function */
01480 #define SWIG_DOSTRING_FAIL(S) fprintf(stderr,"%s\n",S)
01481 #endif
01482 /* Executes a C string in Lua a really simple way of calling lua from C
01483 Unfortunately lua keeps changing its API's, so we need a conditional compile
01484 In lua 5.0.X its lua_dostring()
01485 In lua 5.1.X its luaL_dostring()
01486 */
01487 SWIGINTERN int 
01488 SWIG_Lua_dostring(lua_State *L, const char* str) {
01489   int ok,top;
01490   if (str==0 || str[0]==0) return 0; /* nothing to do */
01491   top=lua_gettop(L); /* save stack */
01492 #if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501))
01493   ok=luaL_dostring(L,str);      /* looks like this is lua 5.1.X or later, good */
01494 #else
01495   ok=lua_dostring(L,str);       /* might be lua 5.0.x, using lua_dostring */
01496 #endif
01497   if (ok!=0) {
01498     SWIG_DOSTRING_FAIL(lua_tostring(L,-1));
01499   }
01500   lua_settop(L,top); /* restore the stack */
01501   return ok;
01502 }    
01503 
01504 #ifdef __cplusplus
01505 }
01506 #endif
01507 
01508 /* ------------------------------ end luarun.swg  ------------------------------ */
01509 /* -----------------------------------------------------------------------------*
01510    Standard SWIG API for use inside user code.
01511  
01512    Don't include this file directly, run the command
01513    swig -python -external-runtime
01514    Also, read the Modules chapter of the SWIG Manual.
01515  
01516  * -----------------------------------------------------------------------------*/
01517 
01518 #ifdef SWIG_MODULE_CLIENTDATA_TYPE
01519 
01520 SWIGRUNTIMEINLINE swig_type_info *
01521 SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) {
01522   swig_module_info *module = SWIG_GetModule(clientdata);
01523   return SWIG_TypeQueryModule(module, module, name);
01524 }
01525 
01526 SWIGRUNTIMEINLINE swig_type_info *
01527 SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) {
01528   swig_module_info *module = SWIG_GetModule(clientdata);
01529   return SWIG_MangledTypeQueryModule(module, module, name);
01530 }
01531 
01532 #else
01533 
01534 SWIGRUNTIMEINLINE swig_type_info *
01535 SWIG_TypeQuery(const char *name) {
01536   swig_module_info *module = SWIG_GetModule(NULL);
01537   return SWIG_TypeQueryModule(module, module, name);
01538 }
01539 
01540 SWIGRUNTIMEINLINE swig_type_info *
01541 SWIG_MangledTypeQuery(const char *name) {
01542   swig_module_info *module = SWIG_GetModule(NULL);
01543   return SWIG_MangledTypeQueryModule(module, module, name);
01544 }
01545 
01546 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines