/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 3.0.2
 *
 * This file is not intended to be easily readable and contains a number of
 * coding conventions designed to improve portability and efficiency. Do not make
 * changes to this file unless you know what you are doing--modify the SWIG
 * interface file instead.
 * ----------------------------------------------------------------------------- */

#define SWIGLUA
#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA
#define SWIG_LUA_MODULE_GLOBAL


#ifdef __cplusplus
/* SwigValueWrapper is described in swig.swg */
template<typename T> class SwigValueWrapper {
  struct SwigMovePointer {
    T *ptr;
    SwigMovePointer(T *p) : ptr(p) { }
    ~SwigMovePointer() { delete ptr; }
    SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
  } pointer;
  SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
  SwigValueWrapper(const SwigValueWrapper<T>& rhs);
public:
  SwigValueWrapper() : pointer(0) { }
  SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
  operator T&() const { return *pointer.ptr; }
  T *operator&() { return pointer.ptr; }
};

template <typename T> T SwigValueInit() {
  return T();
}
#endif

/* -----------------------------------------------------------------------------
 *  This section contains generic SWIG labels for method/variable
 *  declarations/attributes, and other compiler dependent labels.
 * ----------------------------------------------------------------------------- */

/* template workaround for compilers that cannot correctly implement the C++ standard */
#ifndef SWIGTEMPLATEDISAMBIGUATOR
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
#  define SWIGTEMPLATEDISAMBIGUATOR template
# elif defined(__HP_aCC)
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
#  define SWIGTEMPLATEDISAMBIGUATOR template
# else
#  define SWIGTEMPLATEDISAMBIGUATOR
# endif
#endif

/* inline attribute */
#ifndef SWIGINLINE
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
#   define SWIGINLINE inline
# else
#   define SWIGINLINE
# endif
#endif

/* attribute recognised by some compilers to avoid 'unused' warnings */
#ifndef SWIGUNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define SWIGUNUSED __attribute__ ((__unused__))
#   else
#     define SWIGUNUSED
#   endif
# elif defined(__ICC)
#   define SWIGUNUSED __attribute__ ((__unused__))
# else
#   define SWIGUNUSED
# endif
#endif

#ifndef SWIG_MSC_UNSUPPRESS_4505
# if defined(_MSC_VER)
#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
# endif
#endif

#ifndef SWIGUNUSEDPARM
# ifdef __cplusplus
#   define SWIGUNUSEDPARM(p)
# else
#   define SWIGUNUSEDPARM(p) p SWIGUNUSED
# endif
#endif

/* internal SWIG method */
#ifndef SWIGINTERN
# define SWIGINTERN static SWIGUNUSED
#endif

/* internal inline SWIG method */
#ifndef SWIGINTERNINLINE
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
#endif

/* exporting methods */
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#  ifndef GCC_HASCLASSVISIBILITY
#    define GCC_HASCLASSVISIBILITY
#  endif
#endif

#ifndef SWIGEXPORT
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#   if defined(STATIC_LINKED)
#     define SWIGEXPORT
#   else
#     define SWIGEXPORT __declspec(dllexport)
#   endif
# else
#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
#     define SWIGEXPORT __attribute__ ((visibility("default")))
#   else
#     define SWIGEXPORT
#   endif
# endif
#endif

/* calling conventions for Windows */
#ifndef SWIGSTDCALL
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#   define SWIGSTDCALL __stdcall
# else
#   define SWIGSTDCALL
# endif
#endif

/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif

/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
# define _SCL_SECURE_NO_DEPRECATE
#endif


/* -----------------------------------------------------------------------------
 * swigrun.swg
 *
 * This file contains generic C API SWIG runtime support for pointer
 * type checking.
 * ----------------------------------------------------------------------------- */

/* This should only be incremented when either the layout of swig_type_info changes,
   or for whatever reason, the runtime changes incompatibly */
#define SWIG_RUNTIME_VERSION "4"

/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
# define SWIG_QUOTE_STRING(x) #x
# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
#else
# define SWIG_TYPE_TABLE_NAME
#endif

/*
  You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
  creating a static or dynamic library from the SWIG runtime code.
  In 99.9% of the cases, SWIG just needs to declare them as 'static'.

  But only do this if strictly necessary, ie, if you have problems
  with your compiler or suchlike.
*/

#ifndef SWIGRUNTIME
# define SWIGRUNTIME SWIGINTERN
#endif

#ifndef SWIGRUNTIMEINLINE
# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
#endif

/*  Generic buffer size */
#ifndef SWIG_BUFFER_SIZE
# define SWIG_BUFFER_SIZE 1024
#endif

/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN        0x1
#define SWIG_CAST_NEW_MEMORY       0x2

/* Flags for new pointer objects */
#define SWIG_POINTER_OWN           0x1


/*
   Flags/methods for returning states.

   The SWIG conversion methods, as ConvertPtr, return an integer
   that tells if the conversion was successful or not. And if not,
   an error code can be returned (see swigerrors.swg for the codes).

   Use the following macros/flags to set or process the returning
   states.

   In old versions of SWIG, code such as the following was usually written:

     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
       // success code
     } else {
       //fail code
     }

   Now you can be more explicit:

    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
    if (SWIG_IsOK(res)) {
      // success code
    } else {
      // fail code
    }

   which is the same really, but now you can also do

    Type *ptr;
    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
    if (SWIG_IsOK(res)) {
      // success code
      if (SWIG_IsNewObj(res) {
        ...
	delete *ptr;
      } else {
        ...
      }
    } else {
      // fail code
    }

   I.e., now SWIG_ConvertPtr can return new objects and you can
   identify the case and take care of the deallocation. Of course that
   also requires SWIG_ConvertPtr to return new result values, such as

      int SWIG_ConvertPtr(obj, ptr,...) {
        if (<obj is ok>) {
          if (<need new object>) {
            *ptr = <ptr to new allocated object>;
            return SWIG_NEWOBJ;
          } else {
            *ptr = <ptr to old object>;
            return SWIG_OLDOBJ;
          }
        } else {
          return SWIG_BADOBJ;
        }
      }

   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
   SWIG errors code.

   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
   allows to return the 'cast rank', for example, if you have this

       int food(double)
       int fooi(int);

   and you call

      food(1)   // cast rank '1'  (1 -> 1.0)
      fooi(1)   // cast rank '0'

   just use the SWIG_AddCast()/SWIG_CheckState()
*/

#define SWIG_OK                    (0)
#define SWIG_ERROR                 (-1)
#define SWIG_IsOK(r)               (r >= 0)
#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)

/* The CastRankLimit says how many bits are used for the cast rank */
#define SWIG_CASTRANKLIMIT         (1 << 8)
/* The NewMask denotes the object was created (using new/malloc) */
#define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
/* The TmpMask is for in/out typemaps that use temporal objects */
#define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
/* Simple returning values */
#define SWIG_BADOBJ                (SWIG_ERROR)
#define SWIG_OLDOBJ                (SWIG_OK)
#define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
#define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
/* Check, add and del mask methods */
#define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
#define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
#define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
#define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))

/* Cast-Rank Mode */
#if defined(SWIG_CASTRANK_MODE)
#  ifndef SWIG_TypeRank
#    define SWIG_TypeRank             unsigned long
#  endif
#  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
#    define SWIG_MAXCASTRANK          (2)
#  endif
#  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
#  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
SWIGINTERNINLINE int SWIG_AddCast(int r) {
  return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
}
SWIGINTERNINLINE int SWIG_CheckState(int r) {
  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
}
#else /* no cast-rank mode */
#  define SWIG_AddCast(r) (r)
#  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
#endif


#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);

/* Structure to store information on one type */
typedef struct swig_type_info {
  const char             *name;			/* mangled name of this type */
  const char             *str;			/* human readable name of this type */
  swig_dycast_func        dcast;		/* dynamic cast function down a hierarchy */
  struct swig_cast_info  *cast;			/* linked list of types that can cast into this type */
  void                   *clientdata;		/* language specific type data */
  int                    owndata;		/* flag if the structure owns the clientdata */
} swig_type_info;

/* Structure to store a type and conversion function used for casting */
typedef struct swig_cast_info {
  swig_type_info         *type;			/* pointer to type that is equivalent to this type */
  swig_converter_func     converter;		/* function to cast the void pointers */
  struct swig_cast_info  *next;			/* pointer to next cast in linked list */
  struct swig_cast_info  *prev;			/* pointer to the previous cast */
} swig_cast_info;

/* Structure used to store module information
 * Each module generates one structure like this, and the runtime collects
 * all of these structures and stores them in a circularly linked list.*/
typedef struct swig_module_info {
  swig_type_info         **types;		/* Array of pointers to swig_type_info structures that are in this module */
  size_t                 size;		        /* Number of types in this module */
  struct swig_module_info *next;		/* Pointer to next element in circularly linked list */
  swig_type_info         **type_initial;	/* Array of initially generated type structures */
  swig_cast_info         **cast_initial;	/* Array of initially generated casting structures */
  void                    *clientdata;		/* Language specific module data */
} swig_module_info;

/*
  Compare two type names skipping the space characters, therefore
  "char*" == "char *" and "Class<int>" == "Class<int >", etc.

  Return 0 when the two name types are equivalent, as in
  strncmp, but skipping ' '.
*/
SWIGRUNTIME int
SWIG_TypeNameComp(const char *f1, const char *l1,
		  const char *f2, const char *l2) {
  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
    while ((*f1 == ' ') && (f1 != l1)) ++f1;
    while ((*f2 == ' ') && (f2 != l2)) ++f2;
    if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
  }
  return (int)((l1 - f1) - (l2 - f2));
}

/*
  Check type equivalence in a name list like <name1>|<name2>|...
  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
*/
SWIGRUNTIME int
SWIG_TypeCmp(const char *nb, const char *tb) {
  int equiv = 1;
  const char* te = tb + strlen(tb);
  const char* ne = nb;
  while (equiv != 0 && *ne) {
    for (nb = ne; *ne; ++ne) {
      if (*ne == '|') break;
    }
    equiv = SWIG_TypeNameComp(nb, ne, tb, te);
    if (*ne) ++ne;
  }
  return equiv;
}

/*
  Check type equivalence in a name list like <name1>|<name2>|...
  Return 0 if not equal, 1 if equal
*/
SWIGRUNTIME int
SWIG_TypeEquiv(const char *nb, const char *tb) {
  return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
}

/*
  Check the typename
*/
SWIGRUNTIME swig_cast_info *
SWIG_TypeCheck(const char *c, swig_type_info *ty) {
  if (ty) {
    swig_cast_info *iter = ty->cast;
    while (iter) {
      if (strcmp(iter->type->name, c) == 0) {
        if (iter == ty->cast)
          return iter;
        /* Move iter to the top of the linked list */
        iter->prev->next = iter->next;
        if (iter->next)
          iter->next->prev = iter->prev;
        iter->next = ty->cast;
        iter->prev = 0;
        if (ty->cast) ty->cast->prev = iter;
        ty->cast = iter;
        return iter;
      }
      iter = iter->next;
    }
  }
  return 0;
}

/*
  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
*/
SWIGRUNTIME swig_cast_info *
SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
  if (ty) {
    swig_cast_info *iter = ty->cast;
    while (iter) {
      if (iter->type == from) {
        if (iter == ty->cast)
          return iter;
        /* Move iter to the top of the linked list */
        iter->prev->next = iter->next;
        if (iter->next)
          iter->next->prev = iter->prev;
        iter->next = ty->cast;
        iter->prev = 0;
        if (ty->cast) ty->cast->prev = iter;
        ty->cast = iter;
        return iter;
      }
      iter = iter->next;
    }
  }
  return 0;
}

/*
  Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}

/*
   Dynamic pointer casting. Down an inheritance hierarchy
*/
SWIGRUNTIME swig_type_info *
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
  swig_type_info *lastty = ty;
  if (!ty || !ty->dcast) return ty;
  while (ty && (ty->dcast)) {
    ty = (*ty->dcast)(ptr);
    if (ty) lastty = ty;
  }
  return lastty;
}

/*
  Return the name associated with this type
*/
SWIGRUNTIMEINLINE const char *
SWIG_TypeName(const swig_type_info *ty) {
  return ty->name;
}

/*
  Return the pretty name associated with this type,
  that is an unmangled type name in a form presentable to the user.
*/
SWIGRUNTIME const char *
SWIG_TypePrettyName(const swig_type_info *type) {
  /* The "str" field contains the equivalent pretty names of the
     type, separated by vertical-bar characters.  We choose
     to print the last name, as it is often (?) the most
     specific. */
  if (!type) return NULL;
  if (type->str != NULL) {
    const char *last_name = type->str;
    const char *s;
    for (s = type->str; *s; s++)
      if (*s == '|') last_name = s+1;
    return last_name;
  }
  else
    return type->name;
}

/*
   Set the clientdata field for a type
*/
SWIGRUNTIME void
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
  swig_cast_info *cast = ti->cast;
  /* if (ti->clientdata == clientdata) return; */
  ti->clientdata = clientdata;

  while (cast) {
    if (!cast->converter) {
      swig_type_info *tc = cast->type;
      if (!tc->clientdata) {
	SWIG_TypeClientData(tc, clientdata);
      }
    }
    cast = cast->next;
  }
}
SWIGRUNTIME void
SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
  SWIG_TypeClientData(ti, clientdata);
  ti->owndata = 1;
}

/*
  Search for a swig_type_info structure only by mangled name
  Search is a O(log #types)

  We start searching at module start, and finish searching when start == end.
  Note: if start == end at the beginning of the function, we go all the way around
  the circular list.
*/
SWIGRUNTIME swig_type_info *
SWIG_MangledTypeQueryModule(swig_module_info *start,
                            swig_module_info *end,
		            const char *name) {
  swig_module_info *iter = start;
  do {
    if (iter->size) {
      size_t l = 0;
      size_t r = iter->size - 1;
      do {
	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
	size_t i = (l + r) >> 1;
	const char *iname = iter->types[i]->name;
	if (iname) {
	  int compare = strcmp(name, iname);
	  if (compare == 0) {
	    return iter->types[i];
	  } else if (compare < 0) {
	    if (i) {
	      r = i - 1;
	    } else {
	      break;
	    }
	  } else if (compare > 0) {
	    l = i + 1;
	  }
	} else {
	  break; /* should never happen */
	}
      } while (l <= r);
    }
    iter = iter->next;
  } while (iter != end);
  return 0;
}

/*
  Search for a swig_type_info structure for either a mangled name or a human readable name.
  It first searches the mangled names of the types, which is a O(log #types)
  If a type is not found it then searches the human readable names, which is O(#types).

  We start searching at module start, and finish searching when start == end.
  Note: if start == end at the beginning of the function, we go all the way around
  the circular list.
*/
SWIGRUNTIME swig_type_info *
SWIG_TypeQueryModule(swig_module_info *start,
                     swig_module_info *end,
		     const char *name) {
  /* STEP 1: Search the name field using binary search */
  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
  if (ret) {
    return ret;
  } else {
    /* STEP 2: If the type hasn't been found, do a complete search
       of the str field (the human readable name) */
    swig_module_info *iter = start;
    do {
      size_t i = 0;
      for (; i < iter->size; ++i) {
	if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
	  return iter->types[i];
      }
      iter = iter->next;
    } while (iter != end);
  }

  /* neither found a match */
  return 0;
}

/*
   Pack binary data into a string
*/
SWIGRUNTIME char *
SWIG_PackData(char *c, void *ptr, size_t sz) {
  static const char hex[17] = "0123456789abcdef";
  const unsigned char *u = (unsigned char *) ptr;
  const unsigned char *eu =  u + sz;
  for (; u != eu; ++u) {
    unsigned char uu = *u;
    *(c++) = hex[(uu & 0xf0) >> 4];
    *(c++) = hex[uu & 0xf];
  }
  return c;
}

/*
   Unpack binary data from a string
*/
SWIGRUNTIME const char *
SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
  unsigned char *u = (unsigned char *) ptr;
  const unsigned char *eu = u + sz;
  for (; u != eu; ++u) {
    char d = *(c++);
    unsigned char uu;
    if ((d >= '0') && (d <= '9'))
      uu = ((d - '0') << 4);
    else if ((d >= 'a') && (d <= 'f'))
      uu = ((d - ('a'-10)) << 4);
    else
      return (char *) 0;
    d = *(c++);
    if ((d >= '0') && (d <= '9'))
      uu |= (d - '0');
    else if ((d >= 'a') && (d <= 'f'))
      uu |= (d - ('a'-10));
    else
      return (char *) 0;
    *u = uu;
  }
  return c;
}

/*
   Pack 'void *' into a string buffer.
*/
SWIGRUNTIME char *
SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
  char *r = buff;
  if ((2*sizeof(void *) + 2) > bsz) return 0;
  *(r++) = '_';
  r = SWIG_PackData(r,&ptr,sizeof(void *));
  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
  strcpy(r,name);
  return buff;
}

SWIGRUNTIME const char *
SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
  if (*c != '_') {
    if (strcmp(c,"NULL") == 0) {
      *ptr = (void *) 0;
      return name;
    } else {
      return 0;
    }
  }
  return SWIG_UnpackData(++c,ptr,sizeof(void *));
}

SWIGRUNTIME char *
SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
  char *r = buff;
  size_t lname = (name ? strlen(name) : 0);
  if ((2*sz + 2 + lname) > bsz) return 0;
  *(r++) = '_';
  r = SWIG_PackData(r,ptr,sz);
  if (lname) {
    strncpy(r,name,lname+1);
  } else {
    *r = 0;
  }
  return buff;
}

SWIGRUNTIME const char *
SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
  if (*c != '_') {
    if (strcmp(c,"NULL") == 0) {
      memset(ptr,0,sz);
      return name;
    } else {
      return 0;
    }
  }
  return SWIG_UnpackData(++c,ptr,sz);
}

#ifdef __cplusplus
}
#endif

/* -----------------------------------------------------------------------------
 * luarun.swg
 *
 * This file contains the runtime support for Lua modules
 * and includes code for managing global variables and pointer
 * type checking.
 * ----------------------------------------------------------------------------- */

#ifdef __cplusplus
extern "C" {
#endif

#include "lua.h"
#include "lauxlib.h"
#include <stdlib.h>  /* for malloc */
#include <assert.h>  /* for a few sanity tests */

/* -----------------------------------------------------------------------------
 * Lua flavors
 * ----------------------------------------------------------------------------- */

#define SWIG_LUA_FLAVOR_LUA 1
#define SWIG_LUA_FLAVOR_ELUA 2
#define SWIG_LUA_FLAVOR_ELUAC 3

#if !defined(SWIG_LUA_TARGET)
# error SWIG_LUA_TARGET not defined
#endif

#if defined(SWIG_LUA_ELUA_EMULATE)

struct swig_elua_entry;

typedef struct swig_elua_key {
  int type;
  union {
    const char* strkey;
    lua_Number numkey;
  } key;
} swig_elua_key;

typedef struct swig_elua_val {
  int type;
  union {
    lua_Number number;
    const struct swig_elua_entry *table;
    const char *string;
    lua_CFunction function;
    struct {
      char member;
      long lvalue;
      void *pvalue;
      swig_type_info **ptype;
    } userdata;
  } value;
} swig_elua_val;

typedef struct swig_elua_entry {
  swig_elua_key key;
  swig_elua_val value;
} swig_elua_entry;

#define LSTRKEY(x) {LUA_TSTRING, {.strkey = x} }
#define LNUMKEY(x) {LUA_TNUMBER, {.numkey = x} }
#define LNILKEY {LUA_TNIL, {.strkey = 0} }

#define LNUMVAL(x) {LUA_TNUMBER, {.number = x} }
#define LFUNCVAL(x) {LUA_TFUNCTION, {.function = x} }
#define LROVAL(x) {LUA_TTABLE, {.table = x} }
#define LNILVAL {LUA_TNIL, {.string = 0} }
#define LSTRVAL(x) {LUA_TSTRING, {.string = x} }

#define LUA_REG_TYPE swig_elua_entry

#define SWIG_LUA_ELUA_EMUL_METATABLE_KEY "__metatable"

#define lua_pushrotable(L,p)\
  lua_newtable(L);\
  assert(p);\
  SWIG_Lua_elua_emulate_register(L,(swig_elua_entry*)(p));

#define SWIG_LUA_CONSTTAB_POINTER(B,C,D)\
  LSTRKEY(B), {LUA_TUSERDATA, { .userdata={0,0,(void*)(C),&D} } }

#define SWIG_LUA_CONSTTAB_BINARY(B,S,C,D)\
  LSTRKEY(B), {LUA_TUSERDATA, { .userdata={1,S,(void*)(C),&D} } }
#endif

#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
#  define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C)
#  define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C)
#  define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C)
#  define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C)
    /* Those two types of constants are not supported in elua */

#ifndef SWIG_LUA_CONSTTAB_POINTER
#warning eLua does not support pointers as constants. By default, nil will be used as value
#define SWIG_LUA_CONSTTAB_POINTER(B,C,D) LSTRKEY(B), LNILVAL
#endif

#ifndef SWIG_LUA_CONSTTAB_BINARY
#warning eLua does not support pointers to member as constants. By default, nil will be used as value
#define SWIG_LUA_CONSTTAB_BINARY(B, S, C, D) LSTRKEY(B), LNILVAL
#endif
#else /* SWIG_LUA_FLAVOR_LUA */
#  define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0
#  define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0
#  define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0
#  define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0
#  define SWIG_LUA_CONSTTAB_POINTER(B,C,D)\
       SWIG_LUA_POINTER, (char *)B, 0, 0, (void *)C, &D
#  define SWIG_LUA_CONSTTAB_BINARY(B, S, C, D)\
       SWIG_LUA_BINARY,  (char *)B, S, 0, (void *)C, &D
#endif

#ifndef SWIG_LUA_ELUA_EMULATE
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
#  define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING}
#  define LSTRVAL LRO_STRVAL
#endif
#endif /* SWIG_LUA_ELUA_EMULATE*/

#ifndef SWIG_LUA_ELUA_EMULATE
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)

#ifndef MIN_OPT_LEVEL
#define MIN_OPT_LEVEL 2
#endif

#include "lrodefs.h"
#include "lrotable.h"
#endif
#endif /* SWIG_LUA_ELUA_EMULATE*/
/* -----------------------------------------------------------------------------
 * compatibility defines
 * ----------------------------------------------------------------------------- */

/* History of Lua C API length functions:  In Lua 5.0 (and before?)
   there was "lua_strlen".  In Lua 5.1, this was renamed "lua_objlen",
   but a compatibility define of "lua_strlen" was added.  In Lua 5.2,
   this function was again renamed, to "lua_rawlen" (to emphasize that
   it doesn't call the "__len" metamethod), and the compatibility
   define of lua_strlen was removed.  All SWIG uses have been updated
   to "lua_rawlen", and we add our own defines of that here for older
   versions of Lua.  */
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501
# define lua_rawlen lua_strlen
#elif LUA_VERSION_NUM == 501
# define lua_rawlen lua_objlen
#endif


/* lua_pushglobaltable is the recommended "future-proof" way to get
   the global table for Lua 5.2 and later.  Here we define
   lua_pushglobaltable ourselves for Lua versions before 5.2.  */
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
# define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX)
#endif

/* lua_absindex was introduced in Lua 5.2 */
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
# define lua_absindex(L,i) ((i)>0 || (i) <= LUA_REGISTRYINDEX ? (i) : lua_gettop(L) + (i) + 1)
#endif

/* lua_rawsetp was introduced in Lua 5.2 */
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502
#define lua_rawsetp(L,index,ptr)\
  lua_pushlightuserdata(L,(void*)(ptr));\
  lua_insert(L,-2);\
  lua_rawset(L,index);

#define lua_rawgetp(L,index,ptr)\
  lua_pushlightuserdata(L,(void*)(ptr));\
  lua_rawget(L,index);

#endif

/* --------------------------------------------------------------------------
 * Helper functions for error handling
 * -------------------------------------------------------------------------- */

/* Push the string STR on the Lua stack, like lua_pushstring, but
   prefixed with the the location of the innermost Lua call-point
   (as formated by luaL_where).  */
SWIGRUNTIME void
SWIG_Lua_pusherrstring (lua_State *L, const char *str)
{
  luaL_where (L, 1);
  lua_pushstring (L, str);
  lua_concat (L, 2);
}

/* Push a formatted string generated from FMT and following args on
   the Lua stack, like lua_pushfstring, but prefixed with the the
   location of the innermost Lua call-point (as formated by luaL_where).  */
SWIGRUNTIME void
SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...)
{
  va_list argp;
  va_start(argp, fmt);
  luaL_where(L, 1);
  lua_pushvfstring(L, fmt, argp);
  va_end(argp);
  lua_concat(L, 2);
}


/* -----------------------------------------------------------------------------
 * global swig types
 * ----------------------------------------------------------------------------- */
/* Constant table */
#define SWIG_LUA_INT     1
#define SWIG_LUA_FLOAT   2
#define SWIG_LUA_STRING  3
#define SWIG_LUA_POINTER 4
#define SWIG_LUA_BINARY  5
#define SWIG_LUA_CHAR    6

/* Structure for variable linking table */
typedef struct {
  const char *name;
  lua_CFunction get;
  lua_CFunction set;
} swig_lua_var_info;

#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
typedef const LUA_REG_TYPE swig_lua_method;
typedef const LUA_REG_TYPE swig_lua_const_info;
#else /* Normal lua */
typedef luaL_Reg swig_lua_method;

/* Constant information structure */
typedef struct {
    int type;
    char *name;
    long lvalue;
    double dvalue;
    void   *pvalue;
    swig_type_info **ptype;
} swig_lua_const_info;

#endif

typedef struct {
  const char     *name;
  lua_CFunction   getmethod;
  lua_CFunction   setmethod;
} swig_lua_attribute;


struct swig_lua_class;
/* Can be used to create namespaces. Currently used to wrap class static methods/variables/constants */
typedef struct swig_lua_namespace {
  const char            *name;
  swig_lua_method       *ns_methods;
  swig_lua_attribute    *ns_attributes;
  swig_lua_const_info   *ns_constants;
  struct swig_lua_class        **ns_classes;
  struct swig_lua_namespace    **ns_namespaces;
} swig_lua_namespace;

typedef struct swig_lua_class {
  const char    *name; /* Name that this class has in Lua */
  const char    *fqname; /* Fully qualified name - Scope + class name */
  swig_type_info   **type;
  lua_CFunction  constructor;
  void    (*destructor)(void *);
  swig_lua_method   *methods;
  swig_lua_attribute     *attributes;
  swig_lua_namespace    *cls_static;
  swig_lua_method   *metatable; /* 0 for -eluac */
  struct swig_lua_class **bases;
  const char **base_names;
} swig_lua_class;

/* this is the struct for wrapping all pointers in SwigLua
*/
typedef struct {
  swig_type_info   *type;
  int     own;  /* 1 if owned & must be destroyed */
  void        *ptr;
} swig_lua_userdata;

/* this is the struct for wrapping arbitrary packed binary data
(currently it is only used for member function pointers)
the data ordering is similar to swig_lua_userdata, but it is currently not possible
to tell the two structures apart within SWIG, other than by looking at the type
*/
typedef struct {
  swig_type_info   *type;
  int     own;  /* 1 if owned & must be destroyed */
  char data[1];       /* arbitary amount of data */    
} swig_lua_rawdata;

/* Common SWIG API */
#define SWIG_NewPointerObj(L, ptr, type, owner)       SWIG_Lua_NewPointerObj(L, (void *)ptr, type, owner)
#define SWIG_ConvertPtr(L,idx, ptr, type, flags)    SWIG_Lua_ConvertPtr(L,idx,ptr,type,flags)
#define SWIG_MustGetPtr(L,idx, type,flags, argnum,fnname)  SWIG_Lua_MustGetPtr(L,idx, type,flags, argnum,fnname)
/* for C++ member pointers, ie, member methods */
#define SWIG_ConvertMember(L, idx, ptr, sz, ty)       SWIG_Lua_ConvertPacked(L, idx, ptr, sz, ty)
#define SWIG_NewMemberObj(L, ptr, sz, type)      SWIG_Lua_NewPackedObj(L, ptr, sz, type)

/* Runtime API */
#define SWIG_GetModule(clientdata) SWIG_Lua_GetModule((lua_State*)(clientdata))
#define SWIG_SetModule(clientdata, pointer) SWIG_Lua_SetModule((lua_State*) (clientdata), pointer)
#define SWIG_MODULE_CLIENTDATA_TYPE lua_State*

/* Contract support */
#define SWIG_contract_assert(expr, msg)  \
  if (!(expr)) { SWIG_Lua_pusherrstring(L, (char *) msg); goto fail; } else


/* helper #defines */
#define SWIG_fail {goto fail;}
#define SWIG_fail_arg(func_name,argnum,type) \
  {SWIG_Lua_pushferrstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\
  func_name,argnum,type,SWIG_Lua_typename(L,argnum));\
  goto fail;}
#define SWIG_fail_ptr(func_name,argnum,type) \
  SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*")
#define SWIG_check_num_args(func_name,a,b) \
  if (lua_gettop(L)<a || lua_gettop(L)>b) \
  {SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\
  goto fail;}


#define SWIG_Lua_get_table(L,n) \
  (lua_pushstring(L, n), lua_rawget(L,-2))

#define SWIG_Lua_add_function(L,n,f) \
  (lua_pushstring(L, n), \
      lua_pushcfunction(L, f), \
      lua_rawset(L,-3))

#define SWIG_Lua_add_boolean(L,n,b) \
  (lua_pushstring(L, n), \
      lua_pushboolean(L, b), \
      lua_rawset(L,-3))

/* special helper for allowing 'nil' for usertypes */
#define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I))

#ifdef __cplusplus
/* Special helper for member function pointers 
it gets the address, casts it, then dereferences it */
/*#define SWIG_mem_fn_as_voidptr(a)  (*((char**)&(a))) */
#endif

/* storing/access of swig_module_info */
SWIGRUNTIME swig_module_info *
SWIG_Lua_GetModule(lua_State *L) {
  swig_module_info *ret = 0;
  lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
  lua_rawget(L,LUA_REGISTRYINDEX);
  if (lua_islightuserdata(L,-1))
    ret=(swig_module_info*)lua_touserdata(L,-1);
  lua_pop(L,1);  /* tidy */
  return ret;
}

SWIGRUNTIME void
SWIG_Lua_SetModule(lua_State *L, swig_module_info *module) {
  /* add this all into the Lua registry: */
  lua_pushstring(L,"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
  lua_pushlightuserdata(L,(void*)module);
  lua_rawset(L,LUA_REGISTRYINDEX);
}

/* -----------------------------------------------------------------------------
 * global variable support code: modules
 * ----------------------------------------------------------------------------- */

/* this function is called when trying to set an immutable.
default action is to print an error.
This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */
SWIGINTERN int SWIG_Lua_set_immutable(lua_State *L)
{
/*  there should be 1 param passed in: the new value */
#ifndef SWIGLUA_IGNORE_SET_IMMUTABLE
  lua_pop(L,1);  /* remove it */
  luaL_error(L,"This variable is immutable");
#endif
    return 0;   /* should not return anything */
}

#ifdef SWIG_LUA_ELUA_EMULATE

SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State *L,void *ptr,swig_type_info *type, int own);
SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L,void *ptr,size_t size,swig_type_info *type);
static int swig_lua_elua_emulate_unique_key;

/* This function emulates eLua rotables behaviour. It loads a rotable definition into the usual lua table. */
SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_entry *table)
{
  int i, table_parsed, parsed_tables_array, target_table;
  assert(lua_istable(L,-1));
  target_table = lua_gettop(L);
  /* Get the registry where we put all parsed tables to avoid loops */
  lua_rawgetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key);
  if(lua_isnil(L,-1)) {
    lua_pop(L,1);
    lua_newtable(L);
    lua_pushvalue(L,-1);
    lua_rawsetp(L,LUA_REGISTRYINDEX,(void*)(&swig_lua_elua_emulate_unique_key));
  }
  parsed_tables_array = lua_gettop(L);
  lua_pushvalue(L,target_table);
  lua_rawsetp(L, parsed_tables_array, table);
  table_parsed = 0;
  const int SWIGUNUSED pairs_start = lua_gettop(L);
  for(i = 0;table[i].key.type != LUA_TNIL || table[i].value.type != LUA_TNIL;i++)
  {
    const swig_elua_entry *entry = table + i;
    int is_metatable = 0;
    switch(entry->key.type) {
      case LUA_TSTRING:
        lua_pushstring(L,entry->key.key.strkey);
        if(strcmp(entry->key.key.strkey, SWIG_LUA_ELUA_EMUL_METATABLE_KEY) == 0)
          is_metatable = 1;
        break;
      case  LUA_TNUMBER:
        lua_pushnumber(L,entry->key.key.numkey);
        break;
      case LUA_TNIL:
        lua_pushnil(L);
        break;
      default:
        assert(0);
    }
    switch(entry->value.type) {
      case LUA_TSTRING:
        lua_pushstring(L,entry->value.value.string);
        break;
      case  LUA_TNUMBER:
        lua_pushnumber(L,entry->value.value.number);
        break;
      case LUA_TFUNCTION:
        lua_pushcfunction(L,entry->value.value.function);
        break;
      case LUA_TTABLE:
        lua_rawgetp(L,parsed_tables_array, entry->value.value.table);
        table_parsed = !lua_isnil(L,-1);
        if(!table_parsed) {
          lua_pop(L,1); /*remove nil */
          lua_newtable(L);
          SWIG_Lua_elua_emulate_register(L,entry->value.value.table);
        } 
        if(is_metatable) {
          assert(lua_istable(L,-1));
          lua_pushvalue(L,-1);
          lua_setmetatable(L,target_table);
        }

        break;
      case LUA_TUSERDATA:
        if(entry->value.value.userdata.member) 
          SWIG_NewMemberObj(L,entry->value.value.userdata.pvalue,
              entry->value.value.userdata.lvalue,
              *(entry->value.value.userdata.ptype));
        else 
          SWIG_NewPointerObj(L,entry->value.value.userdata.pvalue,
              *(entry->value.value.userdata.ptype),0);
        break;
      case LUA_TNIL:
        lua_pushnil(L);
        break;
      default:
        assert(0);
    }
    assert(lua_gettop(L) == pairs_start + 2);
    lua_rawset(L,target_table);
  }
  lua_pop(L,1); /* Removing parsed tables storage */
  assert(lua_gettop(L) == target_table);
}

SWIGINTERN void SWIG_Lua_elua_emulate_register_clear(lua_State *L)
{
  lua_pushnil(L);
  lua_rawsetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key);
}

SWIGINTERN void SWIG_Lua_get_class_registry(lua_State *L);

SWIGINTERN int SWIG_Lua_emulate_elua_getmetatable(lua_State *L)
{
  SWIG_check_num_args("getmetatable(SWIG eLua emulation)", 1, 1);
  SWIG_Lua_get_class_registry(L);
  lua_getfield(L,-1,"lua_getmetatable");
  lua_remove(L,-2); /* remove the registry*/
  assert(!lua_isnil(L,-1));
  lua_pushvalue(L,1);
  assert(lua_gettop(L) == 3); /* object | function | object again */
  lua_call(L,1,1);
  if(!lua_isnil(L,-1)) /*There is an ordinary metatable */
    return 1;
  /*if it is a table, then emulate elua behaviour - check for __metatable attribute of a table*/
  assert(lua_gettop(L) == 2);
  if(lua_istable(L,-2)) {
    lua_pop(L,1); /*remove the nil*/
    lua_getfield(L,-1, SWIG_LUA_ELUA_EMUL_METATABLE_KEY);
  }
  assert(lua_gettop(L) == 2);
  return 1;
  
fail:
  lua_error(L);
  return 0;
}

SWIGINTERN void SWIG_Lua_emulate_elua_swap_getmetatable(lua_State *L)
{
  SWIG_Lua_get_class_registry(L);
  lua_pushglobaltable(L);
  lua_pushstring(L,"lua_getmetatable");
  lua_getfield(L,-2,"getmetatable");
  assert(!lua_isnil(L,-1));
  lua_rawset(L,-4);
  lua_pushstring(L, "getmetatable");
  lua_pushcfunction(L, SWIG_Lua_emulate_elua_getmetatable);
  lua_rawset(L,-3);
  lua_pop(L,2);
      
}
/* END OF REMOVE */

#endif
/* -----------------------------------------------------------------------------
 * global variable support code: namespaces and modules (which are the same thing)
 * ----------------------------------------------------------------------------- */

SWIGINTERN int SWIG_Lua_namespace_get(lua_State *L)
{
/*  there should be 2 params passed in
  (1) table (not the meta table)
  (2) string name of the attribute
*/
  assert(lua_istable(L,-2));  /* just in case */
  lua_getmetatable(L,-2);
  assert(lua_istable(L,-1));
  SWIG_Lua_get_table(L,".get"); /* find the .get table */
  assert(lua_istable(L,-1));
  /* look for the key in the .get table */
  lua_pushvalue(L,2);  /* key */
  lua_rawget(L,-2);
  lua_remove(L,-2); /* stack tidy, remove .get table */
  if (lua_iscfunction(L,-1))
  {  /* found it so call the fn & return its value */
    lua_call(L,0,1);  /* 1 value in (userdata),1 out (result) */
    lua_remove(L,-2); /* stack tidy, remove metatable */
    return 1;
  }
  lua_pop(L,1);  /* remove whatever was there */
  /* ok, so try the .fn table */
  SWIG_Lua_get_table(L,".fn"); /* find the .get table */
  assert(lua_istable(L,-1));  /* just in case */
  lua_pushvalue(L,2);  /* key */
  lua_rawget(L,-2);  /* look for the fn */
  lua_remove(L,-2); /* stack tidy, remove .fn table */
  if (lua_isfunction(L,-1)) /* note: whether it's a C function or lua function */
  {  /* found it so return the fn & let lua call it */
    lua_remove(L,-2); /* stack tidy, remove metatable */
    return 1;
  }
  lua_pop(L,1);  /* remove whatever was there */
  return 0;
}

SWIGINTERN int SWIG_Lua_namespace_set(lua_State *L)
{
/*  there should be 3 params passed in
  (1) table (not the meta table)
  (2) string name of the attribute
  (3) any for the new value
*/

  assert(lua_istable(L,1));
  lua_getmetatable(L,1);    /* get the meta table */
  assert(lua_istable(L,-1));

  SWIG_Lua_get_table(L,".set"); /* find the .set table */
  if (lua_istable(L,-1))
  {
    /* look for the key in the .set table */
    lua_pushvalue(L,2);  /* key */
    lua_rawget(L,-2);
    if (lua_iscfunction(L,-1))
    {  /* found it so call the fn & return its value */
      lua_pushvalue(L,3);  /* value */
      lua_call(L,1,0);
      return 0;
    }
    lua_pop(L,1);  /* remove the value */
  }
  lua_pop(L,1);  /* remove the value .set table */
  lua_pop(L,1); /* remote metatable */
  lua_rawset(L,-3);
  return 0;
}

#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* In elua this is useless */
SWIGINTERN void SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]); /* forward declaration */
SWIGINTERN void  SWIG_Lua_add_variable(lua_State *L,const char *name,lua_CFunction getFn,lua_CFunction setFn); /* forward declaration */
SWIGINTERN void  SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss);

/* helper function - register namespace methods and attributes into namespace */
SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State *L, swig_lua_namespace *ns)
{
  int i;
  /* There must be namespace table (not metatable) at the top of the stack */
  assert(lua_istable(L,-1));
  SWIG_Lua_InstallConstants(L, ns->ns_constants);

  /* add methods to the namespace/module table */
  for(i=0;ns->ns_methods[i].name;i++){
    SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].func);
  }
  lua_getmetatable(L,-1);

  /* add fns */
  for(i=0;ns->ns_attributes[i].name;i++){
    SWIG_Lua_add_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_attributes[i].setmethod);
  }

  /* clear stack - remove metatble */
  lua_pop(L,1);
  return 0;
}

/* Register all classes in the namespace */
SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace *ns)
{
  swig_lua_class **classes;

  /* There must be a module/namespace table at the top of the stack */
  assert(lua_istable(L,-1));

  classes = ns->ns_classes;

  if( classes != 0 ) {
    while(*classes != 0) {
      SWIG_Lua_class_register(L, *classes);
      classes++;
    }
  }
}

/* Helper function. Creates namespace table and adds it to module table
   if 'reg' is true, then will register namespace table to parent one (must be on top of the stack
   when function is called).
   Function always returns newly registered table on top of the stack.
*/
SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg)
{
  swig_lua_namespace **sub_namespace;
  /* 1 argument - table on the top of the stack */
  const int SWIGUNUSED begin = lua_gettop(L);
  assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table or parent namespace table */
  lua_checkstack(L,5);
  lua_newtable(L); /* namespace itself */
  lua_newtable(L); /* metatable for namespace */

  /* add a table called ".get" */
  lua_pushstring(L,".get");
  lua_newtable(L);
  lua_rawset(L,-3);
  /* add a table called ".set" */
  lua_pushstring(L,".set");
  lua_newtable(L);
  lua_rawset(L,-3);
  /* add a table called ".fn" */
  lua_pushstring(L,".fn");
  lua_newtable(L);
  lua_rawset(L,-3);

  /* add accessor fns for using the .get,.set&.fn */
  SWIG_Lua_add_function(L,"__index",SWIG_Lua_namespace_get);
  SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_namespace_set);

  lua_setmetatable(L,-2); /* set metatable */

  /* Register all functions, variables etc */
  SWIG_Lua_add_namespace_details(L,ns);
  /* Register classes */
  SWIG_Lua_add_namespace_classes(L,ns);

  sub_namespace = ns->ns_namespaces;
  if( sub_namespace != 0) {
    while(*sub_namespace != 0) {
      SWIG_Lua_namespace_register(L, *sub_namespace, 1);
      lua_pop(L,1); /* removing sub-namespace table */
      sub_namespace++;
    }
  }

  if (reg) {
    lua_pushstring(L,ns->name);
    lua_pushvalue(L,-2);
    lua_rawset(L,-4); /* add namespace to module table */
  }
  assert(lua_gettop(L) == begin+1);
}
#endif /* SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA */

/* -----------------------------------------------------------------------------
 * global variable support code: classes
 * ----------------------------------------------------------------------------- */

SWIGINTERN void  SWIG_Lua_get_class_metatable(lua_State *L,const char *cname);

typedef int (*swig_lua_base_iterator_func)(lua_State*,swig_type_info*, int, int *ret);

SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED swig_type,
  int first_arg, swig_lua_base_iterator_func func, int  *const ret)
{
    /* first_arg - position of the object in stack. Everything that is above are arguments
     * and is passed to every evocation of the func */
    int last_arg = lua_gettop(L);/* position of last argument */
    int original_metatable = last_arg + 1;
    size_t bases_count;
    int result = SWIG_ERROR;
    int bases_table;
    (void)swig_type;
    lua_getmetatable(L,first_arg);

    /* initialise base search */
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
    SWIG_Lua_get_table(L,".bases");
    assert(lua_istable(L,-1));
    bases_count = lua_rawlen(L,-1);
    bases_table = lua_gettop(L);
#else
    /* In elua .bases table doesn't exist. Use table from swig_lua_class */
    (void)bases_table;
    assert(swig_type!=0);
    swig_module_info *module=SWIG_GetModule(L);
    swig_lua_class **bases= ((swig_lua_class*)(swig_type->clientdata))->bases;
    const char **base_names= ((swig_lua_class*)(swig_type->clientdata))->base_names;
    bases_count = 0;
    for(;base_names[bases_count];
      bases_count++);/* get length of bases */
#endif

    if(ret)
      *ret = 0;
    if(bases_count>0)
    {
      int to_remove;
      size_t i;
      int j;
      int subcall_last_arg;
      int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */
      int valid = 1;
      swig_type_info *base_swig_type = 0;
      for(j=first_arg;j<=last_arg;j++)
        lua_pushvalue(L,j);
      subcall_last_arg = lua_gettop(L);

      /* Trick: temporarily replacing original metatable with metatable for base class and call getter */
      for(i=0;i<bases_count;i++) {
        /* Iteration through class bases */
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
        lua_rawgeti(L,bases_table,i+1);
        base_swig_type = 0;
        if(lua_isnil(L,-1)) {
          valid = 0;
          lua_pop(L,1);
        } else {
          valid = 1;
        }
#else /* In elua .bases table doesn't exist. Use table from swig_lua_class */
        swig_lua_class *base_class = bases[i];
        if(!base_class) {
          valid = 0;
        } else {
          valid = 1;
          SWIG_Lua_get_class_metatable(L,base_class->fqname);
          base_swig_type = SWIG_TypeQueryModule(module,module,base_names[i]);
          assert(base_swig_type != 0);
        }
#endif

        if(!valid)
          continue;
        assert(lua_isuserdata(L, subcall_first_arg));
        assert(lua_istable(L,-1));
        lua_setmetatable(L,subcall_first_arg); /* Set new metatable */
        assert(lua_gettop(L) == subcall_last_arg);
        result = func(L, base_swig_type,subcall_first_arg, ret); /* Forward call */
        if(result != SWIG_ERROR) {
          break;
        }
      }
      /* Restore original metatable */
      lua_pushvalue(L,original_metatable);
      lua_setmetatable(L,first_arg);
      /* Clear - remove everything between last_arg and subcall_last_arg including */
      to_remove = subcall_last_arg - last_arg;
      for(j=0;j<to_remove;j++)
        lua_remove(L,last_arg+1);
    } else {
      /* Remove everything after last_arg */
      lua_pop(L, lua_gettop(L) - last_arg);
    }
    if(ret) assert(lua_gettop(L) == last_arg + *ret);
    return result;
}

/* The class.get method helper, performs the lookup of class attributes.
 * It returns an error code. Number of function return values is passed inside 'ret'.
 * first_arg is not used in this function because function always has 2 arguments.
 */
SWIGINTERN int  SWIG_Lua_class_do_get(lua_State *L, swig_type_info *type, int SWIGUNUSED first_arg, int *ret)
{
/*  there should be 2 params passed in
  (1) userdata (not the meta table)
  (2) string name of the attribute
*/
  int bases_search_result;
  int substack_start = lua_gettop(L)-2;
  assert(first_arg == substack_start+1);
  lua_checkstack(L,5);
  assert(lua_isuserdata(L,-2));  /* just in case */
  lua_getmetatable(L,-2);    /* get the meta table */
  assert(lua_istable(L,-1));  /* just in case */
  SWIG_Lua_get_table(L,".get"); /* find the .get table */
  assert(lua_istable(L,-1));  /* just in case */
  /* look for the key in the .get table */
  lua_pushvalue(L,substack_start+2);  /* key */
  lua_rawget(L,-2);
  lua_remove(L,-2); /* stack tidy, remove .get table */
  if (lua_iscfunction(L,-1))
  {  /* found it so call the fn & return its value */
    lua_pushvalue(L,substack_start+1);  /* the userdata */
    lua_call(L,1,1);  /* 1 value in (userdata),1 out (result) */
    lua_remove(L,-2); /* stack tidy, remove metatable */
    if(ret)
      *ret = 1;
    return SWIG_OK;
  }
  lua_pop(L,1);  /* remove whatever was there */
  /* ok, so try the .fn table */
  SWIG_Lua_get_table(L,".fn"); /* find the .fn table */
  assert(lua_istable(L,-1));  /* just in case */
  lua_pushvalue(L,substack_start+2);  /* key */
  lua_rawget(L,-2);  /* look for the fn */
  lua_remove(L,-2); /* stack tidy, remove .fn table */
  if (lua_isfunction(L,-1)) /* note: if its a C function or lua function */
  {  /* found it so return the fn & let lua call it */
    lua_remove(L,-2); /* stack tidy, remove metatable */
    if(ret)
      *ret = 1;
    return SWIG_OK;
  }
  lua_pop(L,1);  /* remove whatever was there */
  /* NEW: looks for the __getitem() fn
  this is a user provided get fn */
  SWIG_Lua_get_table(L,"__getitem"); /* find the __getitem fn */
  if (lua_iscfunction(L,-1))  /* if its there */
  {  /* found it so call the fn & return its value */
    lua_pushvalue(L,substack_start+1);  /* the userdata */
    lua_pushvalue(L,substack_start+2);  /* the parameter */
    lua_call(L,2,1);  /* 2 value in (userdata),1 out (result) */
    lua_remove(L,-2); /* stack tidy, remove metatable */
    if(ret) *ret = 1;
    return SWIG_OK;
  }
  lua_pop(L,1);
  /* Remove the metatable */
  lua_pop(L,1);
  /* Search in base classes */
  bases_search_result = SWIG_Lua_iterate_bases(L,type,substack_start+1,SWIG_Lua_class_do_get,ret);
  return bases_search_result;  /* sorry not known */
}

/* the class.get method, performs the lookup of class attributes
 */
SWIGINTERN int  SWIG_Lua_class_get(lua_State *L)
{
/*  there should be 2 params passed in
  (1) userdata (not the meta table)
  (2) string name of the attribute
*/
  int result;
  swig_lua_userdata *usr;
  swig_type_info *type;
  int ret = 0;
  assert(lua_isuserdata(L,1));
  usr=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
  type = usr->type;
  result = SWIG_Lua_class_do_get(L,type,1,&ret);
  if(result == SWIG_OK)
    return ret;

  return 0;
}

/* helper for the class.set method, performs the lookup of class attributes
 * It returns error code. Number of function return values is passed inside 'ret'
 */
SWIGINTERN int  SWIG_Lua_class_do_set(lua_State *L, swig_type_info *type, int first_arg, int *ret)
{
/*  there should be 3 params passed in
  (1) table (not the meta table)
  (2) string name of the attribute
  (3) any for the new value
  */

  int bases_search_result;
  int substack_start = lua_gettop(L) - 3;
  lua_checkstack(L,5);
  assert(lua_isuserdata(L,substack_start+1));  /* just in case */
  lua_getmetatable(L,substack_start+1);    /* get the meta table */
  assert(lua_istable(L,-1));  /* just in case */
  if(ret)
    *ret = 0; /* it is setter - number of return values is always 0 */

  SWIG_Lua_get_table(L,".set"); /* find the .set table */
  if (lua_istable(L,-1))
  {
    /* look for the key in the .set table */
    lua_pushvalue(L,substack_start+2);  /* key */
    lua_rawget(L,-2);
    lua_remove(L,-2); /* tidy stack, remove .set table */
    if (lua_iscfunction(L,-1))
    {  /* found it so call the fn & return its value */
      lua_pushvalue(L,substack_start+1);  /* userdata */
      lua_pushvalue(L,substack_start+3);  /* value */
      lua_call(L,2,0);
      lua_remove(L,substack_start+4); /*remove metatable*/
      return SWIG_OK;
    }
    lua_pop(L,1);  /* remove the value */
  } else {
    lua_pop(L,1);  /* remove the answer for .set table request*/
  }
  /* NEW: looks for the __setitem() fn
  this is a user provided set fn */
  SWIG_Lua_get_table(L,"__setitem"); /* find the fn */
  if (lua_iscfunction(L,-1))  /* if its there */
  {  /* found it so call the fn & return its value */
    lua_pushvalue(L,substack_start+1);  /* the userdata */
    lua_pushvalue(L,substack_start+2);  /* the parameter */
    lua_pushvalue(L,substack_start+3);  /* the value */
    lua_call(L,3,0);  /* 3 values in ,0 out */
    lua_remove(L,-2); /* stack tidy, remove metatable */
    return SWIG_OK;
  }
  lua_pop(L,1); /* remove value */

  lua_pop(L,1); /* remove metatable */
  /* Search among bases */
  bases_search_result = SWIG_Lua_iterate_bases(L,type,first_arg,SWIG_Lua_class_do_set,ret);
  if(ret)
    assert(*ret == 0);
  assert(lua_gettop(L) == substack_start + 3);
  return bases_search_result;
}

/* This is the actual method exported to Lua. It calls SWIG_Lua_class_do_set and correctly
 * handles return values.
 */
SWIGINTERN int  SWIG_Lua_class_set(lua_State *L)
{
/*  There should be 3 params passed in
  (1) table (not the meta table)
  (2) string name of the attribute
  (3) any for the new value
  */
  int ret = 0;
  int result;
  swig_lua_userdata *usr;
  swig_type_info *type;
  assert(lua_isuserdata(L,1));
  usr=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
  type = usr->type;
  result = SWIG_Lua_class_do_set(L,type,1,&ret);
  if(result != SWIG_OK) {
   SWIG_Lua_pushferrstring(L,"Assignment not possible. No setter/member with this name. For custom assignments implement __setitem method.");
   lua_error(L);
  } else {
    assert(ret==0);
  }
  return 0;
}

/* the class.destruct method called by the interpreter */
SWIGINTERN int  SWIG_Lua_class_destruct(lua_State *L)
{
/*  there should be 1 params passed in
  (1) userdata (not the meta table) */
  swig_lua_userdata *usr;
  swig_lua_class *clss;
  assert(lua_isuserdata(L,-1));  /* just in case */
  usr=(swig_lua_userdata*)lua_touserdata(L,-1);  /* get it */
  /* if must be destroyed & has a destructor */
  if (usr->own) /* if must be destroyed */
  {
    clss=(swig_lua_class*)usr->type->clientdata;  /* get the class */
    if (clss && clss->destructor)  /* there is a destroy fn */
    {
      clss->destructor(usr->ptr);  /* bye bye */
    }
  }
  return 0;
}

/* the class.__tostring method called by the interpreter and print */
SWIGINTERN int  SWIG_Lua_class_tostring(lua_State *L)
{
/*  there should be 1 param passed in
  (1) userdata (not the metatable) */
  const char *className;
  void* userData;
  assert(lua_isuserdata(L,1));  /* just in case */
  userData = lua_touserdata(L,1); /* get the userdata address for later */
  lua_getmetatable(L,1);    /* get the meta table */
  assert(lua_istable(L,-1));  /* just in case */

  lua_getfield(L, -1, ".type");
  className = lua_tostring(L, -1);

  lua_pushfstring(L, "<%s userdata: %p>", className, userData);
  return 1;
}

/* to manually disown some userdata */
SWIGINTERN int  SWIG_Lua_class_disown(lua_State *L)
{
/*  there should be 1 params passed in
  (1) userdata (not the meta table) */
  swig_lua_userdata *usr;
  assert(lua_isuserdata(L,-1));  /* just in case */
  usr=(swig_lua_userdata*)lua_touserdata(L,-1);  /* get it */
  
  usr->own = 0; /* clear our ownership */
  return 0;
}

/* lua callable function to compare userdata's value
the issue is that two userdata may point to the same thing
but to lua, they are different objects */
SWIGRUNTIME int SWIG_Lua_class_equal(lua_State *L)
{
  int result;
  swig_lua_userdata *usr1,*usr2;
  if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2))  /* just in case */
    return 0;  /* nil reply */
  usr1=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
  usr2=(swig_lua_userdata*)lua_touserdata(L,2);  /* get data */
  /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/
  result=(usr1->ptr==usr2->ptr);
   lua_pushboolean(L,result);
  return 1;
}

/* populate table at the top of the stack with metamethods that ought to be inherited */
SWIGINTERN void SWIG_Lua_populate_inheritable_metamethods(lua_State *L)
{
  SWIG_Lua_add_boolean(L, "__add", 1);
  SWIG_Lua_add_boolean(L, "__sub", 1);
  SWIG_Lua_add_boolean(L, "__mul", 1);
  SWIG_Lua_add_boolean(L, "__div", 1);
  SWIG_Lua_add_boolean(L, "__mod", 1);
  SWIG_Lua_add_boolean(L, "__pow", 1);
  SWIG_Lua_add_boolean(L, "__unm", 1);
  SWIG_Lua_add_boolean(L, "__len", 1 );
  SWIG_Lua_add_boolean(L, "__concat", 1 );
  SWIG_Lua_add_boolean(L, "__eq", 1);
  SWIG_Lua_add_boolean(L, "__lt", 1);
  SWIG_Lua_add_boolean(L, "__le", 1);
  SWIG_Lua_add_boolean(L, "__call", 1);
  SWIG_Lua_add_boolean(L, "__tostring", 1);
  SWIG_Lua_add_boolean(L, "__gc", 0);
}

/* creates the swig registry */
SWIGINTERN void SWIG_Lua_create_class_registry(lua_State *L)
{
  /* create main SWIG registry table */
  lua_pushstring(L,"SWIG");
  lua_newtable(L);
  /* populate it with some predefined data */

  /* .library table. Placeholder */
  lua_pushstring(L,".library");
  lua_newtable(L);
  {
    /* list of metamethods that class inherits from its bases */
    lua_pushstring(L,"inheritable_metamethods");
    lua_newtable(L);
    /* populate with list of metamethods */
    SWIG_Lua_populate_inheritable_metamethods(L);
    lua_rawset(L,-3);
  }
  lua_rawset(L,-3);

  lua_rawset(L,LUA_REGISTRYINDEX);
}

/* gets the swig registry (or creates it) */
SWIGINTERN void  SWIG_Lua_get_class_registry(lua_State *L)
{
  /* add this all into the swig registry: */
  lua_pushstring(L,"SWIG");
  lua_rawget(L,LUA_REGISTRYINDEX);  /* get the registry */
  if (!lua_istable(L,-1))  /* not there */
  {  /* must be first time, so add it */
    lua_pop(L,1);  /* remove the result */
    SWIG_Lua_create_class_registry(L);
    /* then get it */
    lua_pushstring(L,"SWIG");
    lua_rawget(L,LUA_REGISTRYINDEX);
  }
}

SWIGINTERN void SWIG_Lua_get_inheritable_metamethods(lua_State *L)
{
  SWIG_Lua_get_class_registry(L);
  lua_pushstring(L, ".library");
  lua_rawget(L,-2);
  assert( !lua_isnil(L,-1) );
  lua_pushstring(L, "inheritable_metamethods");
  lua_rawget(L,-2);

  /* Remove class registry and library table */
  lua_remove(L,-2);
  lua_remove(L,-2);
}

/* Helper function to get the classes metatable from the register */
SWIGINTERN void  SWIG_Lua_get_class_metatable(lua_State *L,const char *cname)
{
  SWIG_Lua_get_class_registry(L);  /* get the registry */
  lua_pushstring(L,cname);  /* get the name */
  lua_rawget(L,-2);    /* get it */
  lua_remove(L,-2);    /* tidy up (remove registry) */
}

/* Set up the base classes pointers.
Each class structure has a list of pointers to the base class structures.
This function fills them.
It cannot be done at compile time, as this will not work with hireachies
spread over more than one swig file. 
Therefore it must be done at runtime, querying the SWIG type system.
*/
SWIGINTERN void SWIG_Lua_init_base_class(lua_State *L,swig_lua_class *clss)
{
  int i=0;
  swig_module_info *module=SWIG_GetModule(L);
  for(i=0;clss->base_names[i];i++)
  {
    if (clss->bases[i]==0) /* not found yet */
    {
      /* lookup and cache the base class */
      swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]);
      if (info) clss->bases[i] = (swig_lua_class *) info->clientdata;
    }
  }
}

#if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
/* Merges two tables  */
SWIGINTERN int SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source)
{
  /* iterating */
  lua_pushnil(L);
  while (lua_next(L,source) != 0) {
    /* -1 - value, -2 - index */
    /* have to copy to assign */
    lua_pushvalue(L,-2); /* copy of index */
    lua_pushvalue(L,-2); /* copy of value */
    lua_rawset(L, target);
    lua_pop(L,1);
    /* only key is left */
  }
}

/* Merges two tables with given name. original - index of target metatable, base - index of source metatable */
SWIGINTERN int SWIG_Lua_merge_tables(lua_State *L, const char* name, int original, int base)
{
  /* push original[name], then base[name] */
  lua_pushstring(L,name);
  lua_rawget(L,original);
  int original_table = lua_gettop(L);
  lua_pushstring(L,name);
  lua_rawget(L,base);
  int base_table = lua_gettop(L);
  SWIG_Lua_merge_tables_by_index(L, original_table, base_table);
  /* clearing stack */
  lua_pop(L,2);
}

/* Function takes all symbols from base and adds it to derived class. It's just a helper. */
SWIGINTERN int SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls)
{
  /* There is one parameter - original, i.e. 'derived' class metatable */
  assert(lua_istable(L,-1));
  int original = lua_gettop(L);
  SWIG_Lua_get_class_metatable(L,base_cls->fqname);
  int base = lua_gettop(L);
  SWIG_Lua_merge_tables(L, ".fn", original, base );
  SWIG_Lua_merge_tables(L, ".set", original, base );
  SWIG_Lua_merge_tables(L, ".get", original, base );
  lua_pop(L,1);
}

/* Function squashes all symbols from 'clss' bases into itself */
SWIGINTERN int  SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss)
{
  int i;
  SWIG_Lua_get_class_metatable(L,clss->fqname);
  for(i=0;clss->base_names[i];i++)
  {
    if (clss->bases[i]==0) /* Somehow it's not found. Skip it */
      continue;
    /* Thing is: all bases are already registered. Thus they have already executed
     * this function. So we just need to squash them into us, because their bases
     * are already squashed into them. No need for recursion here!
     */
    SWIG_Lua_class_squash_base(L, clss->bases[i]);
  }
  lua_pop(L,1); /*tidy stack*/
}
#endif

#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA) /* In elua this is useless */
/* helper add a variable to a registered class */
SWIGINTERN void  SWIG_Lua_add_variable(lua_State *L,const char *name,lua_CFunction getFn,lua_CFunction setFn)
{
  assert(lua_istable(L,-1));  /* just in case */
  SWIG_Lua_get_table(L,".get"); /* find the .get table */
  assert(lua_istable(L,-1));  /* just in case */
  SWIG_Lua_add_function(L,name,getFn);
  lua_pop(L,1);       /* tidy stack (remove table) */
  if (setFn)
  {
    SWIG_Lua_get_table(L,".set"); /* find the .set table */
    assert(lua_istable(L,-1));  /* just in case */
    SWIG_Lua_add_function(L,name,setFn);
    lua_pop(L,1);       /* tidy stack (remove table) */
  }
}

/* helper to recursively add class static details (static attributes, operations and constants) */
SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State *L, swig_lua_class *clss)
{
  int i = 0;
  /* The class namespace table must be on the top of the stack */
  assert(lua_istable(L,-1));
  /* call all the base classes first: we can then override these later: */
  for(i=0;clss->bases[i];i++)
  {
    SWIG_Lua_add_class_static_details(L,clss->bases[i]);
  }

  SWIG_Lua_add_namespace_details(L, clss->cls_static);
}

SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss); /* forward declaration */

/* helper to recursively add class details (attributes & operations) */
SWIGINTERN void  SWIG_Lua_add_class_instance_details(lua_State *L, swig_lua_class *clss)
{
  int i;
  size_t bases_count = 0;
  /* Add bases to .bases table */
  SWIG_Lua_get_table(L,".bases");
  assert(lua_istable(L,-1));  /* just in case */
  for(i=0;clss->bases[i];i++)
  {
    SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
    /* Base class must be already registered */
    assert(lua_istable(L,-1));
    lua_rawseti(L,-2,i+1); /* In lua indexing starts from 1 */
    bases_count++;
  }
  assert(lua_rawlen(L,-1) == bases_count);
  lua_pop(L,1); /* remove .bases table */
  /* add attributes */
  for(i=0;clss->attributes[i].name;i++){
    SWIG_Lua_add_variable(L,clss->attributes[i].name,clss->attributes[i].getmethod,clss->attributes[i].setmethod);
  }
  /* add methods to the metatable */
  SWIG_Lua_get_table(L,".fn"); /* find the .fn table */
  assert(lua_istable(L,-1));  /* just in case */
  for(i=0;clss->methods[i].name;i++){
    SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].func);
  }
  lua_pop(L,1);       /* tidy stack (remove table) */
  /* add operator overloads
    This adds methods from metatable array to metatable. Can mess up garbage
    collectind if someone defines __gc method
    */
  if(clss->metatable) {
    for(i=0;clss->metatable[i].name;i++) {
      SWIG_Lua_add_function(L,clss->metatable[i].name,clss->metatable[i].func);
    }
  }

#if !defined(SWIG_LUA_SQUASH_BASES)
  /* Adding metamethods that are defined in base classes. If bases were squashed
   * then it is obviously unnecessary
   */
  SWIG_Lua_add_class_user_metamethods(L, clss);
#endif
}

/* Helpers to add user defined class metamedhods - __add, __sub etc. The helpers are needed
   for the following issue: Lua runtime checks for metamethod existence with rawget function
   ignoring our SWIG-provided __index and __newindex functions. Thus our inheritance-aware method
   search algorithm doesn't work in such case. (Not to say that Lua runtime queries metamethod directly
   in metatable and not in object).
   Current solution is this: if somewhere in hierarchy metamethod __x is defined, then all descendants
   are automatically given a special proxy __x that calls the real __x method.
   Obvious idea - to copy __x instead of creating __x-proxy is wrong because if someone changes __x in runtime,
   those changes must be reflected in all descendants.
*/

SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L); /*forward declaration*/

/* The real function that resolves a metamethod.
 * Function searches given class and all it's bases(recursively) for first instance of something that is
 * not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actual metamethod implementation
 * and it is a SWIG-generated C function.). It returns value on the top of the L and there is no garbage below the
 * answer.
 * Returns 1 if found, 0 otherwise.
 * clss is class which metatable we will search for method
 * metamethod_name_idx is index in L where metamethod name (as string) lies
 * skip_check allows to skip searching metamethod in givel clss and immideatelly go to searching in bases. skip_check
 * is not caried to subsequent recursive calls - false is always passed. It is set to true only at first call from
 * SWIG_Lua_resolve_metamethod
 * */
SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class *clss, int metamethod_name_idx,
    int skip_check)
{
  /* This function is called recursively */
  int result = 0;
  int i = 0;

  if (!skip_check) {
    SWIG_Lua_get_class_metatable(L, clss->fqname);
    lua_pushvalue(L, metamethod_name_idx);
    lua_rawget(L,-2);
    /* If this is cfunction and it is equal to SWIG_Lua_resolve_metamethod then
     * this isn't the function we are looking for :)
     * lua_tocfunction will return NULL if not cfunction
     */
    if (!lua_isnil(L,-1) && lua_tocfunction(L,-1) != SWIG_Lua_resolve_metamethod ) {
      lua_remove(L,-2); /* removing class metatable */
      return 1;
    }
    lua_pop(L,2); /* remove class metatable and query result */
  }

  /* Forwarding calls to bases */
  for(i=0;clss->bases[i];i++)
  {
    result = SWIG_Lua_do_resolve_metamethod(L, clss->bases[i], metamethod_name_idx, 0);
    if (result)
      break;
  }

  return result;
}

/* The proxy function for metamethod. All parameters are passed as cclosure. Searches for actual method
 * and calls it */
SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L)
{
  int numargs;
  int metamethod_name_idx;
  const swig_lua_class* clss;
  int result;

  lua_checkstack(L,5);
  numargs = lua_gettop(L); /* number of arguments to pass to actual metamethod */
  
  /* Get upvalues from closure */
  lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/
  metamethod_name_idx = lua_gettop(L);
  
  lua_pushvalue(L, lua_upvalueindex(2));
  clss = (const swig_lua_class*)(lua_touserdata(L,-1));
  lua_pop(L,1); /* remove lightuserdata with clss from stack */

  /* Actual work */
  result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1);
  if (!result) {
   SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actual metamethod. Memory corruption is most likely explanation.");
   lua_error(L);
   return 0;
  }

  lua_remove(L,-2); /* remove metamethod key */
  lua_insert(L,1); /* move function to correct position */
  lua_call(L, numargs, LUA_MULTRET);
  return lua_gettop(L); /* return all results */
}


/* If given metamethod must be present in given class, then creates appropriate proxy
 * Returns 1 if successfully added, 0 if not added because no base class has it, -1
 * if method is defined in the class metatable itself
 */
SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *clss, const int metatable_index)
{
  int key_index;
  int success = 0;
  int i = 0;

  /* metamethod name - on the top of the stack */
  assert(lua_isstring(L,-1));
  
  key_index = lua_gettop(L);

  /* Check whether method is already defined in metatable */
  lua_pushvalue(L,key_index); /* copy of the key */
  lua_gettable(L,metatable_index);
  if( !lua_isnil(L,-1) ) {
    lua_pop(L,1);
    return -1;
  }
  lua_pop(L,1); 

  /* Iterating over immediate bases */
  for(i=0;clss->bases[i];i++)
  {
    const swig_lua_class *base = clss->bases[i];
    SWIG_Lua_get_class_metatable(L, base->fqname);
    lua_pushvalue(L, key_index);
    lua_rawget(L, -2);
    if( !lua_isnil(L,-1) ) {
      lua_pushvalue(L, key_index); 

      /* Add proxy function */
      lua_pushvalue(L, key_index); /* first closure value is function name */
      lua_pushlightuserdata(L, clss); /* second closure value is swig_lua_class structure */
      lua_pushcclosure(L, SWIG_Lua_resolve_metamethod, 2);
      
      lua_rawset(L, metatable_index);
      success = 1;
    }
    lua_pop(L,1); /* remove function or nil */
    lua_pop(L,1); /* remove base class metatable */

    if( success )
      break;
  }

  return success; 
}

SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss)
{
  int metatable_index;
  int metamethods_info_index;
  int tostring_undefined;
  int eq_undefined = 0;

  SWIG_Lua_get_class_metatable(L, clss->fqname);
  metatable_index = lua_gettop(L);
  SWIG_Lua_get_inheritable_metamethods(L);
  assert(lua_istable(L,-1));
  metamethods_info_index = lua_gettop(L);
  lua_pushnil(L); /* first key */
  while(lua_next(L, metamethods_info_index) != 0 ) {
    /* key at index -2, value at index -1 */
    const int is_inheritable = lua_toboolean(L,-2);
    lua_pop(L,1); /* remove value - we don't need it anymore */

    if(is_inheritable) { /* if metamethod is inheritable */
      SWIG_Lua_add_class_user_metamethod(L,clss,metatable_index);
    }
  }

  lua_pop(L,1); /* remove inheritable metatmethods table */

  /* Special handling for __tostring method */
  lua_pushstring(L, "__tostring");
  lua_pushvalue(L,-1);
  lua_rawget(L,metatable_index);
  tostring_undefined = lua_isnil(L,-1);
  lua_pop(L,1);
  if( tostring_undefined ) {
    lua_pushcfunction(L, SWIG_Lua_class_tostring);
    lua_rawset(L, metatable_index);
  } else {
    lua_pop(L,1); /* remove copy of the key */
  }

  /* Special handling for __eq method */
  lua_pushstring(L, "__eq");
  lua_pushvalue(L,-1);
  lua_rawget(L,metatable_index);
  eq_undefined = lua_isnil(L,-1);
  lua_pop(L,1);
  if( eq_undefined ) {
    lua_pushcfunction(L, SWIG_Lua_class_equal);
    lua_rawset(L, metatable_index);
  } else {
    lua_pop(L,1); /* remove copy of the key */
  }
  /* Warning: __index and __newindex are SWIG-defined. For user-defined operator[]
   * a __getitem/__setitem method should be defined
   */
  lua_pop(L,1); /* pop class metatable */
}

/* Register class static methods,attributes etc as well as constructor proxy */
SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *clss)
{
  const int SWIGUNUSED begin = lua_gettop(L);
  lua_checkstack(L,5); /* just in case */
  assert(lua_istable(L,-1));  /* just in case */
  assert(strcmp(clss->name, clss->cls_static->name) == 0); /* in class those 2 must be equal */

  SWIG_Lua_namespace_register(L,clss->cls_static, 1);

  assert(lua_istable(L,-1)); /* just in case */

  /*  add its constructor to module with the name of the class
  so you can do MyClass(...) as well as new_MyClass(...)
  BUT only if a constructor is defined
  (this overcomes the problem of pure virtual classes without constructors)*/
  if (clss->constructor)
  {
    lua_getmetatable(L,-1);
    assert(lua_istable(L,-1)); /* just in case */
    SWIG_Lua_add_function(L,"__call", clss->constructor);
    lua_pop(L,1);
  }

  assert(lua_istable(L,-1)); /* just in case */
  SWIG_Lua_add_class_static_details(L, clss);

  /* clear stack */
  lua_pop(L,1);
  assert( lua_gettop(L) == begin );
}

/* Performs the instance (non-static) class registration process. Metatable for class is created
 * and added to the class registry.
 */
SWIGINTERN void  SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss)
{
  const int SWIGUNUSED begin = lua_gettop(L);
  int i;
  /* if name already there (class is already registered) then do nothing */
  SWIG_Lua_get_class_registry(L);  /* get the registry */
  lua_pushstring(L,clss->fqname);  /* get the name */
  lua_rawget(L,-2);
  if(!lua_isnil(L,-1)) {
    lua_pop(L,2);
    assert(lua_gettop(L)==begin);
    return;
  }
  lua_pop(L,2); /* tidy stack */
  /* Recursively initialize all bases */
  for(i=0;clss->bases[i];i++)
  {
    SWIG_Lua_class_register_instance(L,clss->bases[i]);
  }
  /* Again, get registry and push name */
  SWIG_Lua_get_class_registry(L);  /* get the registry */
  lua_pushstring(L,clss->fqname);  /* get the name */
  lua_newtable(L);    /* create the metatable */
#if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
  /* If squashing is requested, then merges all bases metatable into this one.
   * It would get us all special methods: __getitem, __add etc.
   * This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away
   */
  {
    int new_metatable_index = lua_absindex(L,-1);
    for(i=0;clss->bases[i];i++)
    {
      int base_metatable;
      SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
      base_metatable = lua_absindex(L,-1);
      SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable);
      lua_pop(L,1);
    }
  }
  /* And now we will overwrite all incorrectly set data */
#endif
  /* add string of class name called ".type" */
  lua_pushstring(L,".type");
  lua_pushstring(L,clss->fqname);
  lua_rawset(L,-3);
  /* add a table called bases */
  lua_pushstring(L,".bases");
  lua_newtable(L);
  lua_rawset(L,-3);
  /* add a table called ".get" */
  lua_pushstring(L,".get");
  lua_newtable(L);
  lua_rawset(L,-3);
  /* add a table called ".set" */
  lua_pushstring(L,".set");
  lua_newtable(L);
  lua_rawset(L,-3);
  /* add a table called ".fn" */
  lua_pushstring(L,".fn");
  lua_newtable(L);
  /* add manual disown method */
  SWIG_Lua_add_function(L,"__disown",SWIG_Lua_class_disown);
  lua_rawset(L,-3);
  /* add accessor fns for using the .get,.set&.fn */
  SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get);
  SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set);
  SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct);
  /* add it */
  lua_rawset(L,-3);  /* metatable into registry */
  lua_pop(L,1);      /* tidy stack (remove registry) */
  assert(lua_gettop(L) == begin);

#if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
  /* Now merge all symbols from .fn, .set, .get etc from bases to our tables */
  SWIG_Lua_class_squash_bases(L,clss);
#endif
  SWIG_Lua_get_class_metatable(L,clss->fqname);
  SWIG_Lua_add_class_instance_details(L,clss);  /* recursive adding of details (atts & ops) */
  lua_pop(L,1);      /* tidy stack (remove class metatable) */
  assert( lua_gettop(L) == begin );
}

SWIGINTERN void  SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss)
{
  int SWIGUNUSED begin;
  assert(lua_istable(L,-1)); /* This is a table (module or namespace) where classes will be added */
  SWIG_Lua_class_register_instance(L,clss);
  SWIG_Lua_class_register_static(L,clss);

  /* Add links from static part to instance part and vice versa */
  /* [SWIG registry]                                   [Module]
   *    "MyClass" ----> [MyClass metatable] <=====     "MyClass" -+> [static part]
   *                     ".get" ----> ...        |                |     getmetatable()----|
   *                     ".set" ----> ...        |                |                       |
   *                     ".static" --------------)----------------/           [static part metatable]
   *                                             |                                ".get" --> ...
   *                                             |                                ".set" --> ....
   *                                             |=============================== ".instance"
   */
  begin = lua_gettop(L);
  lua_pushstring(L,clss->cls_static->name);
  lua_rawget(L,-2); /* get class static table */
  assert(lua_istable(L,-1));
  lua_getmetatable(L,-1);
  assert(lua_istable(L,-1)); /* get class static metatable */
  lua_pushstring(L,".instance"); /* prepare key */

  SWIG_Lua_get_class_metatable(L,clss->fqname); /* get class metatable */
  assert(lua_istable(L,-1));
  lua_pushstring(L,".static"); /* prepare key */
  lua_pushvalue(L, -4); /* push static class TABLE */
  assert(lua_istable(L,-1));
  lua_rawset(L,-3); /* assign static class table(!NOT metatable) as ".static" member of class metatable */
  lua_rawset(L,-3); /* assign class metatable as ".instance" member of class static METATABLE */
  lua_pop(L,2);
  assert(lua_gettop(L) == begin);
}
#endif /* SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA */

#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
SWIGINTERN void SWIG_Lua_elua_class_register_instance(lua_State *L, swig_lua_class *clss)
{
  const int SWIGUNUSED begin = lua_gettop(L);
  int i;
  /* if name already there (class is already registered) then do nothing */
  SWIG_Lua_get_class_registry(L);  /* get the registry */
  lua_pushstring(L,clss->fqname);  /* get the name */
  lua_rawget(L,-2);
  if(!lua_isnil(L,-1)) {
    lua_pop(L,2);
    assert(lua_gettop(L)==begin);
    return;
  }
  lua_pop(L,2); /* tidy stack */
  /* Recursively initialize all bases */
  for(i=0;clss->bases[i];i++)
  {
    SWIG_Lua_elua_class_register_instance(L,clss->bases[i]);
  }
  /* Again, get registry and push name */
  SWIG_Lua_get_class_registry(L);  /* get the registry */
  lua_pushstring(L,clss->fqname);  /* get the name */
  assert(clss->metatable);
  lua_pushrotable(L, (void*)(clss->metatable));    /* create the metatable */
  lua_rawset(L,-3);
  lua_pop(L,1);
  assert(lua_gettop(L) == begin);
}
#endif /* elua && eluac */

/* -----------------------------------------------------------------------------
 * Class/structure conversion fns
 * ----------------------------------------------------------------------------- */

/* helper to add metatable to new lua object */
SWIGINTERN void SWIG_Lua_AddMetatable(lua_State *L,swig_type_info *type)
{
  if (type->clientdata)  /* there is clientdata: so add the metatable */
  {
    SWIG_Lua_get_class_metatable(L,((swig_lua_class*)(type->clientdata))->fqname);
    if (lua_istable(L,-1))
    {
      lua_setmetatable(L,-2);
    }
    else
    {
      lua_pop(L,1);
    }
  }
}

/* pushes a new object into the lua stack */
SWIGRUNTIME void SWIG_Lua_NewPointerObj(lua_State *L,void *ptr,swig_type_info *type, int own)
{
  swig_lua_userdata *usr;
  if (!ptr){
    lua_pushnil(L);
    return;
  }
  usr=(swig_lua_userdata*)lua_newuserdata(L,sizeof(swig_lua_userdata));  /* get data */
  usr->ptr=ptr;  /* set the ptr */
  usr->type=type;
  usr->own=own;
#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
  SWIG_Lua_AddMetatable(L,type); /* add metatable */
#endif
}

/* takes a object from the lua stack & converts it into an object of the correct type
 (if possible) */
SWIGRUNTIME int  SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type_info *type,int flags)
{
  swig_lua_userdata *usr;
  swig_cast_info *cast;
  if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;}    /* special case: lua nil => NULL pointer */
  usr=(swig_lua_userdata*)lua_touserdata(L,index);  /* get data */
  if (usr)
  {
    if (flags & SWIG_POINTER_DISOWN) /* must disown the object */
    {
        usr->own=0;
    }
    if (!type)            /* special cast void*, no casting fn */
    {
      *ptr=usr->ptr;
      return SWIG_OK; /* ok */
    }
    cast=SWIG_TypeCheckStruct(usr->type,type); /* performs normal type checking */
    if (cast)
    {
      int newmemory = 0;
      *ptr=SWIG_TypeCast(cast,usr->ptr,&newmemory);
      assert(!newmemory); /* newmemory handling not yet implemented */
      return SWIG_OK;  /* ok */
    }
  }
  return SWIG_ERROR;  /* error */
}

SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State *L,int index,swig_type_info *type,int flags,
       int argnum,const char *func_name){
  void *result;
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){
    luaL_error (L,"Error in %s, expected a %s at argument number %d\n",
		func_name,(type && type->str)?type->str:"void*",argnum);
  }
  return result;
}

/* pushes a packed userdata. user for member fn pointers only */
SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L,void *ptr,size_t size,swig_type_info *type)
{
  swig_lua_rawdata *raw;
  assert(ptr); /* not acceptable to pass in a NULL value */
  raw=(swig_lua_rawdata*)lua_newuserdata(L,sizeof(swig_lua_rawdata)-1+size);  /* alloc data */
  raw->type=type;
  raw->own=0;
  memcpy(raw->data,ptr,size); /* copy the data */
  SWIG_Lua_AddMetatable(L,type); /* add metatable */
}
    
/* converts a packed userdata. user for member fn pointers only */
SWIGRUNTIME int  SWIG_Lua_ConvertPacked(lua_State *L,int index,void *ptr,size_t size,swig_type_info *type)
{
  swig_lua_rawdata *raw;
  raw=(swig_lua_rawdata*)lua_touserdata(L,index);  /* get data */
  if (!raw) return SWIG_ERROR;  /* error */
  if (type==0 || type==raw->type) /* void* or identical type */
  {
    memcpy(ptr,raw->data,size); /* copy it */
    return SWIG_OK; /* ok */
  }
  return SWIG_ERROR;  /* error */
}

/* a function to get the typestring of a piece of data */
SWIGRUNTIME const char *SWIG_Lua_typename(lua_State *L, int tp)
{
  swig_lua_userdata *usr;
  if (lua_isuserdata(L,tp))
  {
    usr=(swig_lua_userdata*)lua_touserdata(L,tp);  /* get data */
    if (usr && usr->type && usr->type->str)
      return usr->type->str;
    return "userdata (unknown type)";
  }
  return lua_typename(L,lua_type(L,tp));
}

/* lua callable function to get the userdata's type */
SWIGRUNTIME int SWIG_Lua_type(lua_State *L)
{
  lua_pushstring(L,SWIG_Lua_typename(L,1));
  return 1;
}

/* -----------------------------------------------------------------------------
 * global variable support code: class/struct typemap functions
 * ----------------------------------------------------------------------------- */

#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
/* Install Constants */
SWIGINTERN void
SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) {
  int i;
  for (i = 0; constants[i].type; i++) {
    switch(constants[i].type) {
    case SWIG_LUA_INT:
      lua_pushstring(L,constants[i].name);
      lua_pushnumber(L,(lua_Number)constants[i].lvalue);
      lua_rawset(L,-3);
      break;
    case SWIG_LUA_FLOAT:
      lua_pushstring(L,constants[i].name);
      lua_pushnumber(L,(lua_Number)constants[i].dvalue);
      lua_rawset(L,-3);
      break;
    case SWIG_LUA_CHAR:
      lua_pushstring(L,constants[i].name);
      lua_pushfstring(L,"%c",(char)constants[i].lvalue);
      lua_rawset(L,-3);
      break;
    case SWIG_LUA_STRING:
      lua_pushstring(L,constants[i].name);
      lua_pushstring(L,(char *) constants[i].pvalue);
      lua_rawset(L,-3);
      break;
    case SWIG_LUA_POINTER:
      lua_pushstring(L,constants[i].name);
      SWIG_NewPointerObj(L,constants[i].pvalue, *(constants[i]).ptype,0);
      lua_rawset(L,-3);
      break;
    case SWIG_LUA_BINARY:
      lua_pushstring(L,constants[i].name);
      SWIG_NewMemberObj(L,constants[i].pvalue,constants[i].lvalue,*(constants[i]).ptype);
      lua_rawset(L,-3);
      break;
    default:
      break;
    }
  }
}
#endif

/* -----------------------------------------------------------------------------
 * executing lua code from within the wrapper
 * ----------------------------------------------------------------------------- */

#ifndef SWIG_DOSTRING_FAIL /* Allows redefining of error function */
#define SWIG_DOSTRING_FAIL(S) fprintf(stderr,"%s\n",S)
#endif
/* Executes a C string in Lua which is a really simple way of calling lua from C
Unfortunately lua keeps changing its APIs, so we need a conditional compile
In lua 5.0.X it's lua_dostring()
In lua 5.1.X it's luaL_dostring()
*/
SWIGINTERN int 
SWIG_Lua_dostring(lua_State *L, const char *str) {
  int ok,top;
  if (str==0 || str[0]==0) return 0; /* nothing to do */
  top=lua_gettop(L); /* save stack */
#if (defined(LUA_VERSION_NUM) && (LUA_VERSION_NUM>=501))
  ok=luaL_dostring(L,str);	/* looks like this is lua 5.1.X or later, good */
#else
  ok=lua_dostring(L,str);	/* might be lua 5.0.x, using lua_dostring */
#endif
  if (ok!=0) {
    SWIG_DOSTRING_FAIL(lua_tostring(L,-1));
  }
  lua_settop(L,top); /* restore the stack */
  return ok;
}    

#ifdef __cplusplus
}
#endif

/* ------------------------------ end luarun.swg  ------------------------------ */


/* -------- TYPES TABLE (BEGIN) -------- */

#define SWIGTYPE_p_API swig_types[0]
#define SWIGTYPE_p_CoreSession swig_types[1]
#define SWIGTYPE_p_DTMF swig_types[2]
#define SWIGTYPE_p_Event swig_types[3]
#define SWIGTYPE_p_EventConsumer swig_types[4]
#define SWIGTYPE_p_IVRMenu swig_types[5]
#define SWIGTYPE_p_LUA__Dbh swig_types[6]
#define SWIGTYPE_p_LUA__Session swig_types[7]
#define SWIGTYPE_p_SWIGLUA_FN swig_types[8]
#define SWIGTYPE_p_Stream swig_types[9]
#define SWIGTYPE_p_input_callback_state swig_types[10]
#define SWIGTYPE_p_int swig_types[11]
#define SWIGTYPE_p_lua_State swig_types[12]
#define SWIGTYPE_p_p_switch_event_node_t swig_types[13]
#define SWIGTYPE_p_session_flag_t swig_types[14]
#define SWIGTYPE_p_switch_call_cause_t swig_types[15]
#define SWIGTYPE_p_switch_channel_state_t swig_types[16]
#define SWIGTYPE_p_switch_channel_t swig_types[17]
#define SWIGTYPE_p_switch_core_session_t swig_types[18]
#define SWIGTYPE_p_switch_event_t swig_types[19]
#define SWIGTYPE_p_switch_event_types_t swig_types[20]
#define SWIGTYPE_p_switch_input_args_t swig_types[21]
#define SWIGTYPE_p_switch_input_type_t swig_types[22]
#define SWIGTYPE_p_switch_priority_t swig_types[23]
#define SWIGTYPE_p_switch_queue_t swig_types[24]
#define SWIGTYPE_p_switch_state_handler_table_t swig_types[25]
#define SWIGTYPE_p_switch_status_t swig_types[26]
#define SWIGTYPE_p_switch_stream_handle_t swig_types[27]
#define SWIGTYPE_p_uint32_t swig_types[28]
#define SWIGTYPE_p_void swig_types[29]
static swig_type_info *swig_types[31];
static swig_module_info swig_module = {swig_types, 30, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)

/* -------- TYPES TABLE (END) -------- */

#define SWIG_name      "freeswitch"
#define SWIG_init      luaopen_freeswitch
#define SWIG_init_user luaopen_freeswitch_user

#define SWIG_LUACODE   luaopen_freeswitch_luacode

namespace swig {
typedef struct{} LANGUAGE_OBJ;
}


#include "switch.h"
#include "switch_cpp.h"
#include "freeswitch_lua.h"


#ifdef __cplusplus	/* generic alloc/dealloc fns*/
#define SWIG_ALLOC_ARRAY(TYPE,LEN) 	new TYPE[LEN]
#define SWIG_FREE_ARRAY(PTR)		delete[] PTR
#else
#define SWIG_ALLOC_ARRAY(TYPE,LEN) 	(TYPE *)malloc(LEN*sizeof(TYPE))
#define SWIG_FREE_ARRAY(PTR)		free(PTR)
#endif
/* counting the size of arrays:*/
SWIGINTERN int SWIG_itable_size(lua_State* L, int index)
{
	int n=0;
	while(1){
		lua_rawgeti(L,index,n+1);
		if (lua_isnil(L,-1))break;
		++n;
		lua_pop(L,1);
	}
	lua_pop(L,1);
	return n;
}

SWIGINTERN int SWIG_table_size(lua_State* L, int index)
{
	int n=0;
	lua_pushnil(L);  /* first key*/
	while (lua_next(L, index) != 0) {
		++n;
		lua_pop(L, 1);  /* removes `value'; keeps `key' for next iteration*/
	}
	return n;
}

/* super macro to declare array typemap helper fns */
#define SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE)\
	SWIGINTERN int SWIG_read_##NAME##_num_array(lua_State* L,int index,TYPE *array,int size){\
		int i;\
		for (i = 0; i < size; i++) {\
			lua_rawgeti(L,index,i+1);\
			if (lua_isnumber(L,-1)){\
				array[i] = (TYPE)lua_tonumber(L,-1);\
			} else {\
				lua_pop(L,1);\
				return 0;\
			}\
			lua_pop(L,1);\
		}\
		return 1;\
	}\
	SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_fixed(lua_State* L, int index, int size){\
		TYPE *array;\
		if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {\
			SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);\
			return 0;\
		}\
		array=SWIG_ALLOC_ARRAY(TYPE,size);\
		if (!SWIG_read_##NAME##_num_array(L,index,array,size)){\
			SWIG_Lua_pusherrstring(L,"table must contain numbers");\
			SWIG_FREE_ARRAY(array);\
			return 0;\
		}\
		return array;\
	}\
	SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_var(lua_State* L, int index, int* size)\
	{\
		TYPE *array;\
		if (!lua_istable(L,index)) {\
			SWIG_Lua_pusherrstring(L,"expected a table");\
			return 0;\
		}\
		*size=SWIG_itable_size(L,index);\
		if (*size<1){\
			SWIG_Lua_pusherrstring(L,"table appears to be empty");\
			return 0;\
		}\
		array=SWIG_ALLOC_ARRAY(TYPE,*size);\
		if (!SWIG_read_##NAME##_num_array(L,index,array,*size)){\
			SWIG_Lua_pusherrstring(L,"table must contain numbers");\
			SWIG_FREE_ARRAY(array);\
			return 0;\
		}\
		return array;\
	}\
	SWIGINTERN void SWIG_write_##NAME##_num_array(lua_State* L,TYPE *array,int size){\
		int i;\
		lua_newtable(L);\
		for (i = 0; i < size; i++){\
			lua_pushnumber(L,(lua_Number)array[i]);\
			lua_rawseti(L,-2,i+1);/* -1 is the number, -2 is the table*/ \
		}\
	}

SWIG_DECLARE_TYPEMAP_ARR_FN(schar,signed char)
SWIG_DECLARE_TYPEMAP_ARR_FN(uchar,unsigned char)
SWIG_DECLARE_TYPEMAP_ARR_FN(int,int)
SWIG_DECLARE_TYPEMAP_ARR_FN(uint,unsigned int)
SWIG_DECLARE_TYPEMAP_ARR_FN(short,short)
SWIG_DECLARE_TYPEMAP_ARR_FN(ushort,unsigned short)
SWIG_DECLARE_TYPEMAP_ARR_FN(long,long)
SWIG_DECLARE_TYPEMAP_ARR_FN(ulong,unsigned long)
SWIG_DECLARE_TYPEMAP_ARR_FN(float,float)
SWIG_DECLARE_TYPEMAP_ARR_FN(double,double)

SWIGINTERN int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size,swig_type_info *type){
	int i;
	for (i = 0; i < size; i++) {
		lua_rawgeti(L,index,i+1);
		if (!lua_isuserdata(L,-1) || SWIG_ConvertPtr(L,-1,&array[i],type,0)==-1){
			lua_pop(L,1);
			return 0;
		}
		lua_pop(L,1);
	}
	return 1;
}
SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type){
	void **array;
	if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {
		SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);
		return 0;
	}
	array=SWIG_ALLOC_ARRAY(void*,size);
	if (!SWIG_read_ptr_array(L,index,array,size,type)){
		SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name);
		SWIG_FREE_ARRAY(array);
		return 0;
	}
	return array;
}
SWIGINTERN void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type){
	void **array;
	if (!lua_istable(L,index)) {
		SWIG_Lua_pusherrstring(L,"expected a table");
		return 0;
	}
	*size=SWIG_itable_size(L,index);
	if (*size<1){
		SWIG_Lua_pusherrstring(L,"table appears to be empty");
		return 0;
	}
	array=SWIG_ALLOC_ARRAY(void*,*size);
	if (!SWIG_read_ptr_array(L,index,array,*size,type)){
		SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name);
		SWIG_FREE_ARRAY(array);
		return 0;
	}
	return array;
}
SWIGINTERN void SWIG_write_ptr_array(lua_State* L,void **array,int size,swig_type_info *type,int own){
	int i;
	lua_newtable(L);
	for (i = 0; i < size; i++){
		SWIG_NewPointerObj(L,array[i],type,own);
		lua_rawseti(L,-2,i+1);/* -1 is the number, -2 is the table*/
	}
}


SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) {
  int ret = lua_isstring(L, idx);
  if (!ret)
   ret = lua_isnil(L, idx);
  return ret;
}

#ifdef __cplusplus
extern "C" {
#endif
static int _wrap_setGlobalVariable(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("setGlobalVariable",2,2)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("setGlobalVariable",1,"char *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("setGlobalVariable",2,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  arg2 = (char *)lua_tostring(L, 2);
  setGlobalVariable(arg1,arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_getGlobalVariable(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("getGlobalVariable",1,1)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("getGlobalVariable",1,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  result = (char *)getGlobalVariable(arg1);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  free(result);
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_consoleLog(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("consoleLog",2,2)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("consoleLog",1,"char *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("consoleLog",2,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  arg2 = (char *)lua_tostring(L, 2);
  consoleLog(arg1,arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_consoleLog2(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  int arg4 ;
  char *arg5 = (char *) 0 ;
  
  SWIG_check_num_args("consoleLog2",5,5)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("consoleLog2",1,"char *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("consoleLog2",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("consoleLog2",3,"char *");
  if(!lua_isnumber(L,4)) SWIG_fail_arg("consoleLog2",4,"int");
  if(!SWIG_lua_isnilstring(L,5)) SWIG_fail_arg("consoleLog2",5,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (int)lua_tonumber(L, 4);
  arg5 = (char *)lua_tostring(L, 5);
  consoleLog2(arg1,arg2,arg3,arg4,arg5);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_consoleCleanLog(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  
  SWIG_check_num_args("consoleCleanLog",1,1)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("consoleCleanLog",1,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  consoleCleanLog(arg1);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_running(lua_State* L) {
  int SWIG_arg = 0;
  bool result;
  
  SWIG_check_num_args("running",0,0)
  result = (bool)running();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_email(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) NULL ;
  char *arg4 = (char *) NULL ;
  char *arg5 = (char *) NULL ;
  char *arg6 = (char *) NULL ;
  char *arg7 = (char *) NULL ;
  bool result;
  
  SWIG_check_num_args("email",2,7)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("email",1,"char *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("email",2,"char *");
  if(lua_gettop(L)>=3 && !SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("email",3,"char *");
  if(lua_gettop(L)>=4 && !SWIG_lua_isnilstring(L,4)) SWIG_fail_arg("email",4,"char *");
  if(lua_gettop(L)>=5 && !SWIG_lua_isnilstring(L,5)) SWIG_fail_arg("email",5,"char *");
  if(lua_gettop(L)>=6 && !SWIG_lua_isnilstring(L,6)) SWIG_fail_arg("email",6,"char *");
  if(lua_gettop(L)>=7 && !SWIG_lua_isnilstring(L,7)) SWIG_fail_arg("email",7,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  arg2 = (char *)lua_tostring(L, 2);
  if(lua_gettop(L)>=3){
    arg3 = (char *)lua_tostring(L, 3);
  }
  if(lua_gettop(L)>=4){
    arg4 = (char *)lua_tostring(L, 4);
  }
  if(lua_gettop(L)>=5){
    arg5 = (char *)lua_tostring(L, 5);
  }
  if(lua_gettop(L)>=6){
    arg6 = (char *)lua_tostring(L, 6);
  }
  if(lua_gettop(L)>=7){
    arg7 = (char *)lua_tostring(L, 7);
  }
  result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_IVRMenu(lua_State* L) {
  int SWIG_arg = 0;
  IVRMenu *arg1 = (IVRMenu *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  char *arg4 = (char *) 0 ;
  char *arg5 = (char *) 0 ;
  char *arg6 = (char *) 0 ;
  char *arg7 = (char *) 0 ;
  char *arg8 = (char *) 0 ;
  char *arg9 = (char *) 0 ;
  char *arg10 = (char *) 0 ;
  char *arg11 = (char *) 0 ;
  int arg12 ;
  int arg13 ;
  int arg14 ;
  int arg15 ;
  int arg16 ;
  int arg17 ;
  IVRMenu *result = 0 ;
  
  SWIG_check_num_args("IVRMenu::IVRMenu",17,17)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("IVRMenu::IVRMenu",1,"IVRMenu *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("IVRMenu::IVRMenu",2,"char const *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("IVRMenu::IVRMenu",3,"char const *");
  if(!SWIG_lua_isnilstring(L,4)) SWIG_fail_arg("IVRMenu::IVRMenu",4,"char const *");
  if(!SWIG_lua_isnilstring(L,5)) SWIG_fail_arg("IVRMenu::IVRMenu",5,"char const *");
  if(!SWIG_lua_isnilstring(L,6)) SWIG_fail_arg("IVRMenu::IVRMenu",6,"char const *");
  if(!SWIG_lua_isnilstring(L,7)) SWIG_fail_arg("IVRMenu::IVRMenu",7,"char const *");
  if(!SWIG_lua_isnilstring(L,8)) SWIG_fail_arg("IVRMenu::IVRMenu",8,"char const *");
  if(!SWIG_lua_isnilstring(L,9)) SWIG_fail_arg("IVRMenu::IVRMenu",9,"char const *");
  if(!SWIG_lua_isnilstring(L,10)) SWIG_fail_arg("IVRMenu::IVRMenu",10,"char const *");
  if(!SWIG_lua_isnilstring(L,11)) SWIG_fail_arg("IVRMenu::IVRMenu",11,"char const *");
  if(!lua_isnumber(L,12)) SWIG_fail_arg("IVRMenu::IVRMenu",12,"int");
  if(!lua_isnumber(L,13)) SWIG_fail_arg("IVRMenu::IVRMenu",13,"int");
  if(!lua_isnumber(L,14)) SWIG_fail_arg("IVRMenu::IVRMenu",14,"int");
  if(!lua_isnumber(L,15)) SWIG_fail_arg("IVRMenu::IVRMenu",15,"int");
  if(!lua_isnumber(L,16)) SWIG_fail_arg("IVRMenu::IVRMenu",16,"int");
  if(!lua_isnumber(L,17)) SWIG_fail_arg("IVRMenu::IVRMenu",17,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_IVRMenu,0))){
    SWIG_fail_ptr("new_IVRMenu",1,SWIGTYPE_p_IVRMenu);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (char *)lua_tostring(L, 4);
  arg5 = (char *)lua_tostring(L, 5);
  arg6 = (char *)lua_tostring(L, 6);
  arg7 = (char *)lua_tostring(L, 7);
  arg8 = (char *)lua_tostring(L, 8);
  arg9 = (char *)lua_tostring(L, 9);
  arg10 = (char *)lua_tostring(L, 10);
  arg11 = (char *)lua_tostring(L, 11);
  arg12 = (int)lua_tonumber(L, 12);
  arg13 = (int)lua_tonumber(L, 13);
  arg14 = (int)lua_tonumber(L, 14);
  arg15 = (int)lua_tonumber(L, 15);
  arg16 = (int)lua_tonumber(L, 16);
  arg17 = (int)lua_tonumber(L, 17);
  result = (IVRMenu *)new IVRMenu(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,(char const *)arg8,(char const *)arg9,(char const *)arg10,(char const *)arg11,arg12,arg13,arg14,arg15,arg16,arg17);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_IVRMenu,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_IVRMenu_bindAction(lua_State* L) {
  int SWIG_arg = 0;
  IVRMenu *arg1 = (IVRMenu *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  char *arg4 = (char *) 0 ;
  
  SWIG_check_num_args("IVRMenu::bindAction",4,4)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("IVRMenu::bindAction",1,"IVRMenu *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("IVRMenu::bindAction",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("IVRMenu::bindAction",3,"char const *");
  if(!SWIG_lua_isnilstring(L,4)) SWIG_fail_arg("IVRMenu::bindAction",4,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_IVRMenu,0))){
    SWIG_fail_ptr("IVRMenu_bindAction",1,SWIGTYPE_p_IVRMenu);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (char *)lua_tostring(L, 4);
  (arg1)->bindAction(arg2,(char const *)arg3,(char const *)arg4);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_IVRMenu_execute(lua_State* L) {
  int SWIG_arg = 0;
  IVRMenu *arg1 = (IVRMenu *) 0 ;
  CoreSession *arg2 = (CoreSession *) 0 ;
  char *arg3 = (char *) 0 ;
  
  SWIG_check_num_args("IVRMenu::execute",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("IVRMenu::execute",1,"IVRMenu *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("IVRMenu::execute",2,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("IVRMenu::execute",3,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_IVRMenu,0))){
    SWIG_fail_ptr("IVRMenu_execute",1,SWIGTYPE_p_IVRMenu);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("IVRMenu_execute",2,SWIGTYPE_p_CoreSession);
  }
  
  arg3 = (char *)lua_tostring(L, 3);
  (arg1)->execute(arg2,(char const *)arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static void swig_delete_IVRMenu(void *obj) {
IVRMenu *arg1 = (IVRMenu *) obj;
delete arg1;
}
static int _proxy__wrap_new_IVRMenu(lua_State *L) {
    assert(lua_istable(L,1));
    lua_pushcfunction(L,_wrap_new_IVRMenu);
    assert(!lua_isnil(L,-1));
    lua_replace(L,1); /* replace our table with real constructor */
    lua_call(L,lua_gettop(L)-1,1);
    return 1;
}
static swig_lua_attribute swig_IVRMenu_attributes[] = {
    {0,0,0}
};
static swig_lua_method swig_IVRMenu_methods[]= {
    { "bindAction", _wrap_IVRMenu_bindAction},
    { "execute", _wrap_IVRMenu_execute},
    {0,0}
};
static swig_lua_method swig_IVRMenu_meta[] = {
    {0,0}
};

static swig_lua_attribute swig_IVRMenu_Sf_SwigStatic_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_IVRMenu_Sf_SwigStatic_constants[]= {
    {0,0,0,0,0,0}
};
static swig_lua_method swig_IVRMenu_Sf_SwigStatic_methods[]= {
    {0,0}
};
static swig_lua_class* swig_IVRMenu_Sf_SwigStatic_classes[]= {
    0
};

static swig_lua_namespace swig_IVRMenu_Sf_SwigStatic = {
    "IVRMenu",
    swig_IVRMenu_Sf_SwigStatic_methods,
    swig_IVRMenu_Sf_SwigStatic_attributes,
    swig_IVRMenu_Sf_SwigStatic_constants,
    swig_IVRMenu_Sf_SwigStatic_classes,
    0
};
static swig_lua_class *swig_IVRMenu_bases[] = {0};
static const char *swig_IVRMenu_base_names[] = {0};
static swig_lua_class _wrap_class_IVRMenu = { "IVRMenu", "IVRMenu", &SWIGTYPE_p_IVRMenu,_proxy__wrap_new_IVRMenu, swig_delete_IVRMenu, swig_IVRMenu_methods, swig_IVRMenu_attributes, &swig_IVRMenu_Sf_SwigStatic, swig_IVRMenu_meta, swig_IVRMenu_bases, swig_IVRMenu_base_names };

static int _wrap_new_API(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) NULL ;
  API *result = 0 ;
  
  SWIG_check_num_args("API::API",0,1)
  if(lua_gettop(L)>=1 && !SWIG_isptrtype(L,1)) SWIG_fail_arg("API::API",1,"CoreSession *");
  if(lua_gettop(L)>=1){
    if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
      SWIG_fail_ptr("new_API",1,SWIGTYPE_p_CoreSession);
    }
  }
  result = (API *)new API(arg1);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_API,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_API_execute(lua_State* L) {
  int SWIG_arg = 0;
  API *arg1 = (API *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) NULL ;
  char *result = 0 ;
  
  SWIG_check_num_args("API::execute",2,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("API::execute",1,"API *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("API::execute",2,"char const *");
  if(lua_gettop(L)>=3 && !SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("API::execute",3,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_API,0))){
    SWIG_fail_ptr("API_execute",1,SWIGTYPE_p_API);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  if(lua_gettop(L)>=3){
    arg3 = (char *)lua_tostring(L, 3);
  }
  result = (char *)(arg1)->execute((char const *)arg2,(char const *)arg3);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  free(result);
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_API_executeString(lua_State* L) {
  int SWIG_arg = 0;
  API *arg1 = (API *) 0 ;
  char *arg2 = (char *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("API::executeString",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("API::executeString",1,"API *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("API::executeString",2,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_API,0))){
    SWIG_fail_ptr("API_executeString",1,SWIGTYPE_p_API);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (char *)(arg1)->executeString((char const *)arg2);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  free(result);
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_API_getTime(lua_State* L) {
  int SWIG_arg = 0;
  API *arg1 = (API *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("API::getTime",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("API::getTime",1,"API *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_API,0))){
    SWIG_fail_ptr("API_getTime",1,SWIGTYPE_p_API);
  }
  
  result = (char *)(arg1)->getTime();
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static void swig_delete_API(void *obj) {
API *arg1 = (API *) obj;
delete arg1;
}
static int _proxy__wrap_new_API(lua_State *L) {
    assert(lua_istable(L,1));
    lua_pushcfunction(L,_wrap_new_API);
    assert(!lua_isnil(L,-1));
    lua_replace(L,1); /* replace our table with real constructor */
    lua_call(L,lua_gettop(L)-1,1);
    return 1;
}
static swig_lua_attribute swig_API_attributes[] = {
    {0,0,0}
};
static swig_lua_method swig_API_methods[]= {
    { "execute", _wrap_API_execute},
    { "executeString", _wrap_API_executeString},
    { "getTime", _wrap_API_getTime},
    {0,0}
};
static swig_lua_method swig_API_meta[] = {
    {0,0}
};

static swig_lua_attribute swig_API_Sf_SwigStatic_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_API_Sf_SwigStatic_constants[]= {
    {0,0,0,0,0,0}
};
static swig_lua_method swig_API_Sf_SwigStatic_methods[]= {
    {0,0}
};
static swig_lua_class* swig_API_Sf_SwigStatic_classes[]= {
    0
};

static swig_lua_namespace swig_API_Sf_SwigStatic = {
    "API",
    swig_API_Sf_SwigStatic_methods,
    swig_API_Sf_SwigStatic_attributes,
    swig_API_Sf_SwigStatic_constants,
    swig_API_Sf_SwigStatic_classes,
    0
};
static swig_lua_class *swig_API_bases[] = {0};
static const char *swig_API_base_names[] = {0};
static swig_lua_class _wrap_class_API = { "API", "API", &SWIGTYPE_p_API,_proxy__wrap_new_API, swig_delete_API, swig_API_methods, swig_API_attributes, &swig_API_Sf_SwigStatic, swig_API_meta, swig_API_bases, swig_API_base_names };

static int _wrap_input_callback_state_t_c_function_set(lua_State* L) {
  int SWIG_arg = 0;
  input_callback_state *arg1 = (input_callback_state *) 0 ;
  void *arg2 = (void *) 0 ;
  
  SWIG_check_num_args("input_callback_state::function",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("input_callback_state::function",1,"input_callback_state *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("input_callback_state::function",2,"void *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_input_callback_state,0))){
    SWIG_fail_ptr("input_callback_state_t_c_function_set",1,SWIGTYPE_p_input_callback_state);
  }
  
  arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"input_callback_state_t_c_function_set");
  if (arg1) (arg1)->function = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_input_callback_state_t_c_function_get(lua_State* L) {
  int SWIG_arg = 0;
  input_callback_state *arg1 = (input_callback_state *) 0 ;
  void *result = 0 ;
  
  SWIG_check_num_args("input_callback_state::function",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("input_callback_state::function",1,"input_callback_state *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_input_callback_state,0))){
    SWIG_fail_ptr("input_callback_state_t_c_function_get",1,SWIGTYPE_p_input_callback_state);
  }
  
  result = (void *) ((arg1)->function);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_void,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_input_callback_state_t_threadState_set(lua_State* L) {
  int SWIG_arg = 0;
  input_callback_state *arg1 = (input_callback_state *) 0 ;
  void *arg2 = (void *) 0 ;
  
  SWIG_check_num_args("input_callback_state::threadState",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("input_callback_state::threadState",1,"input_callback_state *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("input_callback_state::threadState",2,"void *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_input_callback_state,0))){
    SWIG_fail_ptr("input_callback_state_t_threadState_set",1,SWIGTYPE_p_input_callback_state);
  }
  
  arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"input_callback_state_t_threadState_set");
  if (arg1) (arg1)->threadState = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_input_callback_state_t_threadState_get(lua_State* L) {
  int SWIG_arg = 0;
  input_callback_state *arg1 = (input_callback_state *) 0 ;
  void *result = 0 ;
  
  SWIG_check_num_args("input_callback_state::threadState",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("input_callback_state::threadState",1,"input_callback_state *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_input_callback_state,0))){
    SWIG_fail_ptr("input_callback_state_t_threadState_get",1,SWIGTYPE_p_input_callback_state);
  }
  
  result = (void *) ((arg1)->threadState);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_void,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_input_callback_state_t_extra_set(lua_State* L) {
  int SWIG_arg = 0;
  input_callback_state *arg1 = (input_callback_state *) 0 ;
  void *arg2 = (void *) 0 ;
  
  SWIG_check_num_args("input_callback_state::extra",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("input_callback_state::extra",1,"input_callback_state *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("input_callback_state::extra",2,"void *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_input_callback_state,0))){
    SWIG_fail_ptr("input_callback_state_t_extra_set",1,SWIGTYPE_p_input_callback_state);
  }
  
  arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"input_callback_state_t_extra_set");
  if (arg1) (arg1)->extra = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_input_callback_state_t_extra_get(lua_State* L) {
  int SWIG_arg = 0;
  input_callback_state *arg1 = (input_callback_state *) 0 ;
  void *result = 0 ;
  
  SWIG_check_num_args("input_callback_state::extra",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("input_callback_state::extra",1,"input_callback_state *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_input_callback_state,0))){
    SWIG_fail_ptr("input_callback_state_t_extra_get",1,SWIGTYPE_p_input_callback_state);
  }
  
  result = (void *) ((arg1)->extra);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_void,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_input_callback_state_t_funcargs_set(lua_State* L) {
  int SWIG_arg = 0;
  input_callback_state *arg1 = (input_callback_state *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("input_callback_state::funcargs",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("input_callback_state::funcargs",1,"input_callback_state *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("input_callback_state::funcargs",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_input_callback_state,0))){
    SWIG_fail_ptr("input_callback_state_t_funcargs_set",1,SWIGTYPE_p_input_callback_state);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->funcargs;
    if (arg2) {
      arg1->funcargs = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->funcargs, (const char *)arg2);
    } else {
      arg1->funcargs = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_input_callback_state_t_funcargs_get(lua_State* L) {
  int SWIG_arg = 0;
  input_callback_state *arg1 = (input_callback_state *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("input_callback_state::funcargs",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("input_callback_state::funcargs",1,"input_callback_state *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_input_callback_state,0))){
    SWIG_fail_ptr("input_callback_state_t_funcargs_get",1,SWIGTYPE_p_input_callback_state);
  }
  
  result = (char *) ((arg1)->funcargs);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_input_callback_state_t(lua_State* L) {
  int SWIG_arg = 0;
  input_callback_state *result = 0 ;
  
  SWIG_check_num_args("input_callback_state::input_callback_state",0,0)
  result = (input_callback_state *)new input_callback_state();
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_input_callback_state,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static void swig_delete_input_callback_state_t(void *obj) {
input_callback_state *arg1 = (input_callback_state *) obj;
delete arg1;
}
static int _proxy__wrap_new_input_callback_state_t(lua_State *L) {
    assert(lua_istable(L,1));
    lua_pushcfunction(L,_wrap_new_input_callback_state_t);
    assert(!lua_isnil(L,-1));
    lua_replace(L,1); /* replace our table with real constructor */
    lua_call(L,lua_gettop(L)-1,1);
    return 1;
}
static swig_lua_attribute swig_input_callback_state_t_attributes[] = {
    { "c_function", _wrap_input_callback_state_t_c_function_get, _wrap_input_callback_state_t_c_function_set },
    { "threadState", _wrap_input_callback_state_t_threadState_get, _wrap_input_callback_state_t_threadState_set },
    { "extra", _wrap_input_callback_state_t_extra_get, _wrap_input_callback_state_t_extra_set },
    { "funcargs", _wrap_input_callback_state_t_funcargs_get, _wrap_input_callback_state_t_funcargs_set },
    {0,0,0}
};
static swig_lua_method swig_input_callback_state_t_methods[]= {
    {0,0}
};
static swig_lua_method swig_input_callback_state_t_meta[] = {
    {0,0}
};

static swig_lua_attribute swig_input_callback_state_t_Sf_SwigStatic_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_input_callback_state_t_Sf_SwigStatic_constants[]= {
    {0,0,0,0,0,0}
};
static swig_lua_method swig_input_callback_state_t_Sf_SwigStatic_methods[]= {
    {0,0}
};
static swig_lua_class* swig_input_callback_state_t_Sf_SwigStatic_classes[]= {
    0
};

static swig_lua_namespace swig_input_callback_state_t_Sf_SwigStatic = {
    "input_callback_state_t",
    swig_input_callback_state_t_Sf_SwigStatic_methods,
    swig_input_callback_state_t_Sf_SwigStatic_attributes,
    swig_input_callback_state_t_Sf_SwigStatic_constants,
    swig_input_callback_state_t_Sf_SwigStatic_classes,
    0
};
static swig_lua_class *swig_input_callback_state_t_bases[] = {0};
static const char *swig_input_callback_state_t_base_names[] = {0};
static swig_lua_class _wrap_class_input_callback_state_t = { "input_callback_state_t", "input_callback_state_t", &SWIGTYPE_p_input_callback_state,_proxy__wrap_new_input_callback_state_t, swig_delete_input_callback_state_t, swig_input_callback_state_t_methods, swig_input_callback_state_t_attributes, &swig_input_callback_state_t_Sf_SwigStatic, swig_input_callback_state_t_meta, swig_input_callback_state_t_bases, swig_input_callback_state_t_base_names };

static int _wrap_DTMF_digit_set(lua_State* L) {
  int SWIG_arg = 0;
  DTMF *arg1 = (DTMF *) 0 ;
  char arg2 ;
  
  SWIG_check_num_args("DTMF::digit",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("DTMF::digit",1,"DTMF *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("DTMF::digit",2,"char");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_DTMF,0))){
    SWIG_fail_ptr("DTMF_digit_set",1,SWIGTYPE_p_DTMF);
  }
  
  arg2 = (lua_tostring(L, 2))[0];
  if (arg1) (arg1)->digit = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_DTMF_digit_get(lua_State* L) {
  int SWIG_arg = 0;
  DTMF *arg1 = (DTMF *) 0 ;
  char result;
  
  SWIG_check_num_args("DTMF::digit",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("DTMF::digit",1,"DTMF *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_DTMF,0))){
    SWIG_fail_ptr("DTMF_digit_get",1,SWIGTYPE_p_DTMF);
  }
  
  result = (char) ((arg1)->digit);
  lua_pushfstring(L,"%c",result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_DTMF_duration_set(lua_State* L) {
  int SWIG_arg = 0;
  DTMF *arg1 = (DTMF *) 0 ;
  uint32_t arg2 ;
  uint32_t *argp2 ;
  
  SWIG_check_num_args("DTMF::duration",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("DTMF::duration",1,"DTMF *");
  if(!lua_isuserdata(L,2)) SWIG_fail_arg("DTMF::duration",2,"uint32_t");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_DTMF,0))){
    SWIG_fail_ptr("DTMF_duration_set",1,SWIGTYPE_p_DTMF);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_uint32_t,0))){
    SWIG_fail_ptr("DTMF_duration_set",2,SWIGTYPE_p_uint32_t);
  }
  arg2 = *argp2;
  
  if (arg1) (arg1)->duration = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_DTMF_duration_get(lua_State* L) {
  int SWIG_arg = 0;
  DTMF *arg1 = (DTMF *) 0 ;
  uint32_t result;
  
  SWIG_check_num_args("DTMF::duration",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("DTMF::duration",1,"DTMF *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_DTMF,0))){
    SWIG_fail_ptr("DTMF_duration_get",1,SWIGTYPE_p_DTMF);
  }
  
  result =  ((arg1)->duration);
  {
    uint32_t * resultptr = new uint32_t((const uint32_t &) result);
    SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_uint32_t,1); SWIG_arg++;
  }
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_DTMF(lua_State* L) {
  int SWIG_arg = 0;
  char arg1 ;
  uint32_t arg2 = (uint32_t) SWITCH_DEFAULT_DTMF_DURATION ;
  uint32_t *argp2 ;
  DTMF *result = 0 ;
  
  SWIG_check_num_args("DTMF::DTMF",1,2)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("DTMF::DTMF",1,"char");
  if(lua_gettop(L)>=2 && !lua_isuserdata(L,2)) SWIG_fail_arg("DTMF::DTMF",2,"uint32_t");
  arg1 = (lua_tostring(L, 1))[0];
  if(lua_gettop(L)>=2){
    if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_uint32_t,0))){
      SWIG_fail_ptr("new_DTMF",2,SWIGTYPE_p_uint32_t);
    }
    arg2 = *argp2;
  }
  result = (DTMF *)new DTMF(arg1,arg2);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_DTMF,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static void swig_delete_DTMF(void *obj) {
DTMF *arg1 = (DTMF *) obj;
delete arg1;
}
static int _proxy__wrap_new_DTMF(lua_State *L) {
    assert(lua_istable(L,1));
    lua_pushcfunction(L,_wrap_new_DTMF);
    assert(!lua_isnil(L,-1));
    lua_replace(L,1); /* replace our table with real constructor */
    lua_call(L,lua_gettop(L)-1,1);
    return 1;
}
static swig_lua_attribute swig_DTMF_attributes[] = {
    { "digit", _wrap_DTMF_digit_get, _wrap_DTMF_digit_set },
    { "duration", _wrap_DTMF_duration_get, _wrap_DTMF_duration_set },
    {0,0,0}
};
static swig_lua_method swig_DTMF_methods[]= {
    {0,0}
};
static swig_lua_method swig_DTMF_meta[] = {
    {0,0}
};

static swig_lua_attribute swig_DTMF_Sf_SwigStatic_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_DTMF_Sf_SwigStatic_constants[]= {
    {0,0,0,0,0,0}
};
static swig_lua_method swig_DTMF_Sf_SwigStatic_methods[]= {
    {0,0}
};
static swig_lua_class* swig_DTMF_Sf_SwigStatic_classes[]= {
    0
};

static swig_lua_namespace swig_DTMF_Sf_SwigStatic = {
    "DTMF",
    swig_DTMF_Sf_SwigStatic_methods,
    swig_DTMF_Sf_SwigStatic_attributes,
    swig_DTMF_Sf_SwigStatic_constants,
    swig_DTMF_Sf_SwigStatic_classes,
    0
};
static swig_lua_class *swig_DTMF_bases[] = {0};
static const char *swig_DTMF_base_names[] = {0};
static swig_lua_class _wrap_class_DTMF = { "DTMF", "DTMF", &SWIGTYPE_p_DTMF,_proxy__wrap_new_DTMF, swig_delete_DTMF, swig_DTMF_methods, swig_DTMF_attributes, &swig_DTMF_Sf_SwigStatic, swig_DTMF_meta, swig_DTMF_bases, swig_DTMF_base_names };

static int _wrap_new_Stream__SWIG_0(lua_State* L) {
  int SWIG_arg = 0;
  Stream *result = 0 ;
  
  SWIG_check_num_args("Stream::Stream",0,0)
  result = (Stream *)new Stream();
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Stream,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Stream__SWIG_1(lua_State* L) {
  int SWIG_arg = 0;
  switch_stream_handle_t *arg1 = (switch_stream_handle_t *) 0 ;
  Stream *result = 0 ;
  
  SWIG_check_num_args("Stream::Stream",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Stream::Stream",1,"switch_stream_handle_t *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_switch_stream_handle_t,0))){
    SWIG_fail_ptr("new_Stream",1,SWIGTYPE_p_switch_stream_handle_t);
  }
  
  result = (Stream *)new Stream(arg1);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Stream,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Stream(lua_State* L) {
  int argc;
  int argv[2]={
    1,2
  };
  
  argc = lua_gettop(L);
  if (argc == 0) {
    return _wrap_new_Stream__SWIG_0(L);
  }
  if (argc == 1) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_switch_stream_handle_t, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      return _wrap_new_Stream__SWIG_1(L);
    }
  }
  
  SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_Stream'\n"
    "  Possible C/C++ prototypes are:\n"
    "    Stream::Stream()\n"
    "    Stream::Stream(switch_stream_handle_t *)\n");
  lua_error(L);return 0;
}


static int _wrap_Stream_read(lua_State* L) {
  int SWIG_arg = 0;
  Stream *arg1 = (Stream *) 0 ;
  int *arg2 = (int *) 0 ;
  int temp2 ;
  char *result = 0 ;
  
  arg2 = &temp2; 
  SWIG_check_num_args("Stream::read",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Stream::read",1,"Stream *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Stream,0))){
    SWIG_fail_ptr("Stream_read",1,SWIGTYPE_p_Stream);
  }
  
  result = (char *)(arg1)->read(arg2);
  lua_pushlstring(L,(const char*)result, (*arg2)); SWIG_arg++;
  lua_pushnumber(L, (lua_Number) *arg2); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Stream_write(lua_State* L) {
  int SWIG_arg = 0;
  Stream *arg1 = (Stream *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("Stream::write",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Stream::write",1,"Stream *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Stream::write",2,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Stream,0))){
    SWIG_fail_ptr("Stream_write",1,SWIGTYPE_p_Stream);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  (arg1)->write((char const *)arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Stream_raw_write(lua_State* L) {
  int SWIG_arg = 0;
  Stream *arg1 = (Stream *) 0 ;
  char *arg2 = (char *) 0 ;
  int arg3 ;
  
  SWIG_check_num_args("Stream::raw_write",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Stream::raw_write",1,"Stream *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Stream::raw_write",2,"char const *");
  if(!lua_isnumber(L,3)) SWIG_fail_arg("Stream::raw_write",3,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Stream,0))){
    SWIG_fail_ptr("Stream_raw_write",1,SWIGTYPE_p_Stream);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (int)lua_tonumber(L, 3);
  (arg1)->raw_write((char const *)arg2,arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Stream_get_data(lua_State* L) {
  int SWIG_arg = 0;
  Stream *arg1 = (Stream *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("Stream::get_data",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Stream::get_data",1,"Stream *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Stream,0))){
    SWIG_fail_ptr("Stream_get_data",1,SWIGTYPE_p_Stream);
  }
  
  result = (char *)(arg1)->get_data();
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static void swig_delete_Stream(void *obj) {
Stream *arg1 = (Stream *) obj;
delete arg1;
}
static int _proxy__wrap_new_Stream(lua_State *L) {
    assert(lua_istable(L,1));
    lua_pushcfunction(L,_wrap_new_Stream);
    assert(!lua_isnil(L,-1));
    lua_replace(L,1); /* replace our table with real constructor */
    lua_call(L,lua_gettop(L)-1,1);
    return 1;
}
static swig_lua_attribute swig_Stream_attributes[] = {
    {0,0,0}
};
static swig_lua_method swig_Stream_methods[]= {
    { "read", _wrap_Stream_read},
    { "write", _wrap_Stream_write},
    { "raw_write", _wrap_Stream_raw_write},
    { "get_data", _wrap_Stream_get_data},
    {0,0}
};
static swig_lua_method swig_Stream_meta[] = {
    {0,0}
};

static swig_lua_attribute swig_Stream_Sf_SwigStatic_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_Stream_Sf_SwigStatic_constants[]= {
    {0,0,0,0,0,0}
};
static swig_lua_method swig_Stream_Sf_SwigStatic_methods[]= {
    {0,0}
};
static swig_lua_class* swig_Stream_Sf_SwigStatic_classes[]= {
    0
};

static swig_lua_namespace swig_Stream_Sf_SwigStatic = {
    "Stream",
    swig_Stream_Sf_SwigStatic_methods,
    swig_Stream_Sf_SwigStatic_attributes,
    swig_Stream_Sf_SwigStatic_constants,
    swig_Stream_Sf_SwigStatic_classes,
    0
};
static swig_lua_class *swig_Stream_bases[] = {0};
static const char *swig_Stream_base_names[] = {0};
static swig_lua_class _wrap_class_Stream = { "Stream", "Stream", &SWIGTYPE_p_Stream,_proxy__wrap_new_Stream, swig_delete_Stream, swig_Stream_methods, swig_Stream_attributes, &swig_Stream_Sf_SwigStatic, swig_Stream_meta, swig_Stream_bases, swig_Stream_base_names };

static int _wrap_Event_event_set(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  switch_event_t *arg2 = (switch_event_t *) 0 ;
  
  SWIG_check_num_args("Event::event",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::event",1,"Event *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("Event::event",2,"switch_event_t *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_event_set",1,SWIGTYPE_p_Event);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_switch_event_t,SWIG_POINTER_DISOWN))){
    SWIG_fail_ptr("Event_event_set",2,SWIGTYPE_p_switch_event_t);
  }
  
  if (arg1) (arg1)->event = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_event_get(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  switch_event_t *result = 0 ;
  
  SWIG_check_num_args("Event::event",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::event",1,"Event *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_event_get",1,SWIGTYPE_p_Event);
  }
  
  result = (switch_event_t *) ((arg1)->event);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_switch_event_t,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_serialized_string_set(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("Event::serialized_string",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::serialized_string",1,"Event *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Event::serialized_string",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_serialized_string_set",1,SWIGTYPE_p_Event);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->serialized_string;
    if (arg2) {
      arg1->serialized_string = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->serialized_string, (const char *)arg2);
    } else {
      arg1->serialized_string = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_serialized_string_get(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("Event::serialized_string",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::serialized_string",1,"Event *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_serialized_string_get",1,SWIGTYPE_p_Event);
  }
  
  result = (char *) ((arg1)->serialized_string);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_mine_set(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  int arg2 ;
  
  SWIG_check_num_args("Event::mine",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::mine",1,"Event *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("Event::mine",2,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_mine_set",1,SWIGTYPE_p_Event);
  }
  
  arg2 = (int)lua_tonumber(L, 2);
  if (arg1) (arg1)->mine = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_mine_get(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  int result;
  
  SWIG_check_num_args("Event::mine",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::mine",1,"Event *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_mine_get",1,SWIGTYPE_p_Event);
  }
  
  result = (int) ((arg1)->mine);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Event__SWIG_0(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  char *arg2 = (char *) NULL ;
  Event *result = 0 ;
  
  SWIG_check_num_args("Event::Event",1,2)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("Event::Event",1,"char const *");
  if(lua_gettop(L)>=2 && !SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Event::Event",2,"char const *");
  arg1 = (char *)lua_tostring(L, 1);
  if(lua_gettop(L)>=2){
    arg2 = (char *)lua_tostring(L, 2);
  }
  result = (Event *)new Event((char const *)arg1,(char const *)arg2);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Event,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Event__SWIG_1(lua_State* L) {
  int SWIG_arg = 0;
  switch_event_t *arg1 = (switch_event_t *) 0 ;
  int arg2 = (int) 0 ;
  Event *result = 0 ;
  
  SWIG_check_num_args("Event::Event",1,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::Event",1,"switch_event_t *");
  if(lua_gettop(L)>=2 && !lua_isnumber(L,2)) SWIG_fail_arg("Event::Event",2,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_switch_event_t,0))){
    SWIG_fail_ptr("new_Event",1,SWIGTYPE_p_switch_event_t);
  }
  
  if(lua_gettop(L)>=2){
    arg2 = (int)lua_tonumber(L, 2);
  }
  result = (Event *)new Event(arg1,arg2);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Event,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Event(lua_State* L) {
  int argc;
  int argv[3]={
    1,2,3
  };
  
  argc = lua_gettop(L);
  if ((argc >= 1) && (argc <= 2)) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_switch_event_t, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      if (argc <= 1) {
        return _wrap_new_Event__SWIG_1(L);
      }
      {
        _v = lua_isnumber(L,argv[1]);
      }
      if (_v) {
        return _wrap_new_Event__SWIG_1(L);
      }
    }
  }
  if ((argc >= 1) && (argc <= 2)) {
    int _v;
    {
      _v = SWIG_lua_isnilstring(L,argv[0]);
    }
    if (_v) {
      if (argc <= 1) {
        return _wrap_new_Event__SWIG_0(L);
      }
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        return _wrap_new_Event__SWIG_0(L);
      }
    }
  }
  
  SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_Event'\n"
    "  Possible C/C++ prototypes are:\n"
    "    Event::Event(char const *,char const *)\n"
    "    Event::Event(switch_event_t *,int)\n");
  lua_error(L);return 0;
}


static int _wrap_Event_chat_execute(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) NULL ;
  int result;
  
  SWIG_check_num_args("Event::chat_execute",2,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::chat_execute",1,"Event *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Event::chat_execute",2,"char const *");
  if(lua_gettop(L)>=3 && !SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("Event::chat_execute",3,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_chat_execute",1,SWIGTYPE_p_Event);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  if(lua_gettop(L)>=3){
    arg3 = (char *)lua_tostring(L, 3);
  }
  result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_chat_send(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *arg2 = (char *) NULL ;
  int result;
  
  SWIG_check_num_args("Event::chat_send",1,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::chat_send",1,"Event *");
  if(lua_gettop(L)>=2 && !SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Event::chat_send",2,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_chat_send",1,SWIGTYPE_p_Event);
  }
  
  if(lua_gettop(L)>=2){
    arg2 = (char *)lua_tostring(L, 2);
  }
  result = (int)(arg1)->chat_send((char const *)arg2);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_serialize(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *arg2 = (char *) NULL ;
  char *result = 0 ;
  
  SWIG_check_num_args("Event::serialize",1,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::serialize",1,"Event *");
  if(lua_gettop(L)>=2 && !SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Event::serialize",2,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_serialize",1,SWIGTYPE_p_Event);
  }
  
  if(lua_gettop(L)>=2){
    arg2 = (char *)lua_tostring(L, 2);
  }
  result = (char *)(arg1)->serialize((char const *)arg2);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_setPriority(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  switch_priority_t arg2 = (switch_priority_t) SWITCH_PRIORITY_NORMAL ;
  switch_priority_t *argp2 ;
  bool result;
  
  SWIG_check_num_args("Event::setPriority",1,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::setPriority",1,"Event *");
  if(lua_gettop(L)>=2 && !lua_isuserdata(L,2)) SWIG_fail_arg("Event::setPriority",2,"switch_priority_t");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_setPriority",1,SWIGTYPE_p_Event);
  }
  
  if(lua_gettop(L)>=2){
    if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_switch_priority_t,0))){
      SWIG_fail_ptr("Event_setPriority",2,SWIGTYPE_p_switch_priority_t);
    }
    arg2 = *argp2;
  }
  result = (bool)(arg1)->setPriority(arg2);
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_getHeader(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *arg2 = (char *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("Event::getHeader",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::getHeader",1,"Event *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Event::getHeader",2,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_getHeader",1,SWIGTYPE_p_Event);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (char *)(arg1)->getHeader((char const *)arg2);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_getBody(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("Event::getBody",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::getBody",1,"Event *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_getBody",1,SWIGTYPE_p_Event);
  }
  
  result = (char *)(arg1)->getBody();
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_getType(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("Event::getType",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::getType",1,"Event *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_getType",1,SWIGTYPE_p_Event);
  }
  
  result = (char *)(arg1)->getType();
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_addBody(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *arg2 = (char *) 0 ;
  bool result;
  
  SWIG_check_num_args("Event::addBody",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::addBody",1,"Event *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Event::addBody",2,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_addBody",1,SWIGTYPE_p_Event);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (bool)(arg1)->addBody((char const *)arg2);
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_addHeader(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  bool result;
  
  SWIG_check_num_args("Event::addHeader",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::addHeader",1,"Event *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Event::addHeader",2,"char const *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("Event::addHeader",3,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_addHeader",1,SWIGTYPE_p_Event);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  result = (bool)(arg1)->addHeader((char const *)arg2,(char const *)arg3);
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_delHeader(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  char *arg2 = (char *) 0 ;
  bool result;
  
  SWIG_check_num_args("Event::delHeader",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::delHeader",1,"Event *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("Event::delHeader",2,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_delHeader",1,SWIGTYPE_p_Event);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (bool)(arg1)->delHeader((char const *)arg2);
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Event_fire(lua_State* L) {
  int SWIG_arg = 0;
  Event *arg1 = (Event *) 0 ;
  bool result;
  
  SWIG_check_num_args("Event::fire",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event::fire",1,"Event *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("Event_fire",1,SWIGTYPE_p_Event);
  }
  
  result = (bool)(arg1)->fire();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static void swig_delete_Event(void *obj) {
Event *arg1 = (Event *) obj;
delete arg1;
}
static int _proxy__wrap_new_Event(lua_State *L) {
    assert(lua_istable(L,1));
    lua_pushcfunction(L,_wrap_new_Event);
    assert(!lua_isnil(L,-1));
    lua_replace(L,1); /* replace our table with real constructor */
    lua_call(L,lua_gettop(L)-1,1);
    return 1;
}
static swig_lua_attribute swig_Event_attributes[] = {
    { "event", _wrap_Event_event_get, _wrap_Event_event_set },
    { "serialized_string", _wrap_Event_serialized_string_get, _wrap_Event_serialized_string_set },
    { "mine", _wrap_Event_mine_get, _wrap_Event_mine_set },
    {0,0,0}
};
static swig_lua_method swig_Event_methods[]= {
    { "chat_execute", _wrap_Event_chat_execute},
    { "chat_send", _wrap_Event_chat_send},
    { "serialize", _wrap_Event_serialize},
    { "setPriority", _wrap_Event_setPriority},
    { "getHeader", _wrap_Event_getHeader},
    { "getBody", _wrap_Event_getBody},
    { "getType", _wrap_Event_getType},
    { "addBody", _wrap_Event_addBody},
    { "addHeader", _wrap_Event_addHeader},
    { "delHeader", _wrap_Event_delHeader},
    { "fire", _wrap_Event_fire},
    {0,0}
};
static swig_lua_method swig_Event_meta[] = {
    {0,0}
};

static swig_lua_attribute swig_Event_Sf_SwigStatic_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_Event_Sf_SwigStatic_constants[]= {
    {0,0,0,0,0,0}
};
static swig_lua_method swig_Event_Sf_SwigStatic_methods[]= {
    {0,0}
};
static swig_lua_class* swig_Event_Sf_SwigStatic_classes[]= {
    0
};

static swig_lua_namespace swig_Event_Sf_SwigStatic = {
    "Event",
    swig_Event_Sf_SwigStatic_methods,
    swig_Event_Sf_SwigStatic_attributes,
    swig_Event_Sf_SwigStatic_constants,
    swig_Event_Sf_SwigStatic_classes,
    0
};
static swig_lua_class *swig_Event_bases[] = {0};
static const char *swig_Event_base_names[] = {0};
static swig_lua_class _wrap_class_Event = { "Event", "Event", &SWIGTYPE_p_Event,_proxy__wrap_new_Event, swig_delete_Event, swig_Event_methods, swig_Event_attributes, &swig_Event_Sf_SwigStatic, swig_Event_meta, swig_Event_bases, swig_Event_base_names };

static int _wrap_EventConsumer_events_set(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  switch_queue_t *arg2 = (switch_queue_t *) 0 ;
  
  SWIG_check_num_args("EventConsumer::events",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::events",1,"EventConsumer *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("EventConsumer::events",2,"switch_queue_t *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_events_set",1,SWIGTYPE_p_EventConsumer);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_switch_queue_t,SWIG_POINTER_DISOWN))){
    SWIG_fail_ptr("EventConsumer_events_set",2,SWIGTYPE_p_switch_queue_t);
  }
  
  if (arg1) (arg1)->events = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_events_get(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  switch_queue_t *result = 0 ;
  
  SWIG_check_num_args("EventConsumer::events",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::events",1,"EventConsumer *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_events_get",1,SWIGTYPE_p_EventConsumer);
  }
  
  result = (switch_queue_t *) ((arg1)->events);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_switch_queue_t,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_e_event_id_set(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  switch_event_types_t arg2 ;
  switch_event_types_t *argp2 ;
  
  SWIG_check_num_args("EventConsumer::e_event_id",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::e_event_id",1,"EventConsumer *");
  if(!lua_isuserdata(L,2)) SWIG_fail_arg("EventConsumer::e_event_id",2,"switch_event_types_t");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_e_event_id_set",1,SWIGTYPE_p_EventConsumer);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_switch_event_types_t,0))){
    SWIG_fail_ptr("EventConsumer_e_event_id_set",2,SWIGTYPE_p_switch_event_types_t);
  }
  arg2 = *argp2;
  
  if (arg1) (arg1)->e_event_id = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_e_event_id_get(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  switch_event_types_t result;
  
  SWIG_check_num_args("EventConsumer::e_event_id",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::e_event_id",1,"EventConsumer *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_e_event_id_get",1,SWIGTYPE_p_EventConsumer);
  }
  
  result =  ((arg1)->e_event_id);
  {
    switch_event_types_t * resultptr = new switch_event_types_t((const switch_event_types_t &) result);
    SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_switch_event_types_t,1); SWIG_arg++;
  }
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_e_callback_set(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("EventConsumer::e_callback",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::e_callback",1,"EventConsumer *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("EventConsumer::e_callback",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_e_callback_set",1,SWIGTYPE_p_EventConsumer);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->e_callback;
    if (arg2) {
      arg1->e_callback = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->e_callback, (const char *)arg2);
    } else {
      arg1->e_callback = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_e_callback_get(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("EventConsumer::e_callback",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::e_callback",1,"EventConsumer *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_e_callback_get",1,SWIGTYPE_p_EventConsumer);
  }
  
  result = (char *) ((arg1)->e_callback);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_e_subclass_name_set(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("EventConsumer::e_subclass_name",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::e_subclass_name",1,"EventConsumer *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("EventConsumer::e_subclass_name",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_e_subclass_name_set",1,SWIGTYPE_p_EventConsumer);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->e_subclass_name;
    if (arg2) {
      arg1->e_subclass_name = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->e_subclass_name, (const char *)arg2);
    } else {
      arg1->e_subclass_name = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_e_subclass_name_get(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("EventConsumer::e_subclass_name",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::e_subclass_name",1,"EventConsumer *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_e_subclass_name_get",1,SWIGTYPE_p_EventConsumer);
  }
  
  result = (char *) ((arg1)->e_subclass_name);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_e_cb_arg_set(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("EventConsumer::e_cb_arg",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::e_cb_arg",1,"EventConsumer *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("EventConsumer::e_cb_arg",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_e_cb_arg_set",1,SWIGTYPE_p_EventConsumer);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->e_cb_arg;
    if (arg2) {
      arg1->e_cb_arg = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->e_cb_arg, (const char *)arg2);
    } else {
      arg1->e_cb_arg = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_e_cb_arg_get(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("EventConsumer::e_cb_arg",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::e_cb_arg",1,"EventConsumer *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_e_cb_arg_get",1,SWIGTYPE_p_EventConsumer);
  }
  
  result = (char *) ((arg1)->e_cb_arg);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_enodes_set(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  switch_event_node_t **arg2 ;
  
  SWIG_check_num_args("EventConsumer::enodes",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::enodes",1,"EventConsumer *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("EventConsumer::enodes",2,"switch_event_node_t *[SWITCH_EVENT_ALL+1]");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_enodes_set",1,SWIGTYPE_p_EventConsumer);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_p_switch_event_node_t,0))){
    SWIG_fail_ptr("EventConsumer_enodes_set",2,SWIGTYPE_p_p_switch_event_node_t);
  }
  
  {
    size_t ii;
    switch_event_node_t * *b = (switch_event_node_t * *) arg1->enodes;
    for (ii = 0; ii < (size_t)SWITCH_EVENT_ALL+1; ii++) b[ii] = *((switch_event_node_t * *) arg2 + ii);
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_enodes_get(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  switch_event_node_t **result = 0 ;
  
  SWIG_check_num_args("EventConsumer::enodes",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::enodes",1,"EventConsumer *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_enodes_get",1,SWIGTYPE_p_EventConsumer);
  }
  
  result = (switch_event_node_t **)(switch_event_node_t **) ((arg1)->enodes);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_p_switch_event_node_t,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_node_index_set(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  uint32_t arg2 ;
  uint32_t *argp2 ;
  
  SWIG_check_num_args("EventConsumer::node_index",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::node_index",1,"EventConsumer *");
  if(!lua_isuserdata(L,2)) SWIG_fail_arg("EventConsumer::node_index",2,"uint32_t");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_node_index_set",1,SWIGTYPE_p_EventConsumer);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_uint32_t,0))){
    SWIG_fail_ptr("EventConsumer_node_index_set",2,SWIGTYPE_p_uint32_t);
  }
  arg2 = *argp2;
  
  if (arg1) (arg1)->node_index = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_node_index_get(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  uint32_t result;
  
  SWIG_check_num_args("EventConsumer::node_index",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::node_index",1,"EventConsumer *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_node_index_get",1,SWIGTYPE_p_EventConsumer);
  }
  
  result =  ((arg1)->node_index);
  {
    uint32_t * resultptr = new uint32_t((const uint32_t &) result);
    SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_uint32_t,1); SWIG_arg++;
  }
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_EventConsumer(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) NULL ;
  char *arg2 = (char *) "" ;
  int arg3 = (int) 5000 ;
  EventConsumer *result = 0 ;
  
  SWIG_check_num_args("EventConsumer::EventConsumer",0,3)
  if(lua_gettop(L)>=1 && !SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("EventConsumer::EventConsumer",1,"char const *");
  if(lua_gettop(L)>=2 && !SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("EventConsumer::EventConsumer",2,"char const *");
  if(lua_gettop(L)>=3 && !lua_isnumber(L,3)) SWIG_fail_arg("EventConsumer::EventConsumer",3,"int");
  if(lua_gettop(L)>=1){
    arg1 = (char *)lua_tostring(L, 1);
  }
  if(lua_gettop(L)>=2){
    arg2 = (char *)lua_tostring(L, 2);
  }
  if(lua_gettop(L)>=3){
    arg3 = (int)lua_tonumber(L, 3);
  }
  result = (EventConsumer *)new EventConsumer((char const *)arg1,(char const *)arg2,arg3);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_EventConsumer,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_bind(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) "" ;
  int result;
  
  SWIG_check_num_args("EventConsumer::bind",2,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::bind",1,"EventConsumer *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("EventConsumer::bind",2,"char const *");
  if(lua_gettop(L)>=3 && !SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("EventConsumer::bind",3,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_bind",1,SWIGTYPE_p_EventConsumer);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  if(lua_gettop(L)>=3){
    arg3 = (char *)lua_tostring(L, 3);
  }
  result = (int)(arg1)->bind((char const *)arg2,(char const *)arg3);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_pop(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  int arg2 = (int) 0 ;
  int arg3 = (int) 0 ;
  Event *result = 0 ;
  
  SWIG_check_num_args("EventConsumer::pop",1,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::pop",1,"EventConsumer *");
  if(lua_gettop(L)>=2 && !lua_isnumber(L,2)) SWIG_fail_arg("EventConsumer::pop",2,"int");
  if(lua_gettop(L)>=3 && !lua_isnumber(L,3)) SWIG_fail_arg("EventConsumer::pop",3,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_pop",1,SWIGTYPE_p_EventConsumer);
  }
  
  if(lua_gettop(L)>=2){
    arg2 = (int)lua_tonumber(L, 2);
  }
  if(lua_gettop(L)>=3){
    arg3 = (int)lua_tonumber(L, 3);
  }
  result = (Event *)(arg1)->pop(arg2,arg3);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Event,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_EventConsumer_cleanup(lua_State* L) {
  int SWIG_arg = 0;
  EventConsumer *arg1 = (EventConsumer *) 0 ;
  
  SWIG_check_num_args("EventConsumer::cleanup",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("EventConsumer::cleanup",1,"EventConsumer *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_EventConsumer,0))){
    SWIG_fail_ptr("EventConsumer_cleanup",1,SWIGTYPE_p_EventConsumer);
  }
  
  (arg1)->cleanup();
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static void swig_delete_EventConsumer(void *obj) {
EventConsumer *arg1 = (EventConsumer *) obj;
delete arg1;
}
static int _proxy__wrap_new_EventConsumer(lua_State *L) {
    assert(lua_istable(L,1));
    lua_pushcfunction(L,_wrap_new_EventConsumer);
    assert(!lua_isnil(L,-1));
    lua_replace(L,1); /* replace our table with real constructor */
    lua_call(L,lua_gettop(L)-1,1);
    return 1;
}
static swig_lua_attribute swig_EventConsumer_attributes[] = {
    { "events", _wrap_EventConsumer_events_get, _wrap_EventConsumer_events_set },
    { "e_event_id", _wrap_EventConsumer_e_event_id_get, _wrap_EventConsumer_e_event_id_set },
    { "e_callback", _wrap_EventConsumer_e_callback_get, _wrap_EventConsumer_e_callback_set },
    { "e_subclass_name", _wrap_EventConsumer_e_subclass_name_get, _wrap_EventConsumer_e_subclass_name_set },
    { "e_cb_arg", _wrap_EventConsumer_e_cb_arg_get, _wrap_EventConsumer_e_cb_arg_set },
    { "enodes", _wrap_EventConsumer_enodes_get, _wrap_EventConsumer_enodes_set },
    { "node_index", _wrap_EventConsumer_node_index_get, _wrap_EventConsumer_node_index_set },
    {0,0,0}
};
static swig_lua_method swig_EventConsumer_methods[]= {
    { "bind", _wrap_EventConsumer_bind},
    { "pop", _wrap_EventConsumer_pop},
    { "cleanup", _wrap_EventConsumer_cleanup},
    {0,0}
};
static swig_lua_method swig_EventConsumer_meta[] = {
    {0,0}
};

static swig_lua_attribute swig_EventConsumer_Sf_SwigStatic_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_EventConsumer_Sf_SwigStatic_constants[]= {
    {0,0,0,0,0,0}
};
static swig_lua_method swig_EventConsumer_Sf_SwigStatic_methods[]= {
    {0,0}
};
static swig_lua_class* swig_EventConsumer_Sf_SwigStatic_classes[]= {
    0
};

static swig_lua_namespace swig_EventConsumer_Sf_SwigStatic = {
    "EventConsumer",
    swig_EventConsumer_Sf_SwigStatic_methods,
    swig_EventConsumer_Sf_SwigStatic_attributes,
    swig_EventConsumer_Sf_SwigStatic_constants,
    swig_EventConsumer_Sf_SwigStatic_classes,
    0
};
static swig_lua_class *swig_EventConsumer_bases[] = {0};
static const char *swig_EventConsumer_base_names[] = {0};
static swig_lua_class _wrap_class_EventConsumer = { "EventConsumer", "EventConsumer", &SWIGTYPE_p_EventConsumer,_proxy__wrap_new_EventConsumer, swig_delete_EventConsumer, swig_EventConsumer_methods, swig_EventConsumer_attributes, &swig_EventConsumer_Sf_SwigStatic, swig_EventConsumer_meta, swig_EventConsumer_bases, swig_EventConsumer_base_names };

static int _wrap_CoreSession_session_set(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  switch_core_session_t *arg2 = (switch_core_session_t *) 0 ;
  
  SWIG_check_num_args("CoreSession::session",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::session",1,"CoreSession *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("CoreSession::session",2,"switch_core_session_t *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_session_set",1,SWIGTYPE_p_CoreSession);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_switch_core_session_t,SWIG_POINTER_DISOWN))){
    SWIG_fail_ptr("CoreSession_session_set",2,SWIGTYPE_p_switch_core_session_t);
  }
  
  if (arg1) (arg1)->session = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_session_get(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  switch_core_session_t *result = 0 ;
  
  SWIG_check_num_args("CoreSession::session",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::session",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_session_get",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (switch_core_session_t *) ((arg1)->session);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_switch_core_session_t,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_channel_set(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  switch_channel_t *arg2 = (switch_channel_t *) 0 ;
  
  SWIG_check_num_args("CoreSession::channel",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::channel",1,"CoreSession *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("CoreSession::channel",2,"switch_channel_t *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_channel_set",1,SWIGTYPE_p_CoreSession);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_switch_channel_t,SWIG_POINTER_DISOWN))){
    SWIG_fail_ptr("CoreSession_channel_set",2,SWIGTYPE_p_switch_channel_t);
  }
  
  if (arg1) (arg1)->channel = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_channel_get(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  switch_channel_t *result = 0 ;
  
  SWIG_check_num_args("CoreSession::channel",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::channel",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_channel_get",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (switch_channel_t *) ((arg1)->channel);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_switch_channel_t,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_flags_set(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  unsigned int arg2 ;
  
  SWIG_check_num_args("CoreSession::flags",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::flags",1,"CoreSession *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("CoreSession::flags",2,"unsigned int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_flags_set",1,SWIGTYPE_p_CoreSession);
  }
  
  SWIG_contract_assert((lua_tonumber(L,2)>=0),"number must not be negative")
  arg2 = (unsigned int)lua_tonumber(L, 2);
  if (arg1) (arg1)->flags = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_flags_get(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  unsigned int result;
  
  SWIG_check_num_args("CoreSession::flags",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::flags",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_flags_get",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (unsigned int) ((arg1)->flags);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_allocated_set(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int arg2 ;
  
  SWIG_check_num_args("CoreSession::allocated",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::allocated",1,"CoreSession *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("CoreSession::allocated",2,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_allocated_set",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (int)lua_tonumber(L, 2);
  if (arg1) (arg1)->allocated = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_allocated_get(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int result;
  
  SWIG_check_num_args("CoreSession::allocated",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::allocated",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_allocated_get",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (int) ((arg1)->allocated);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_cb_state_set(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  input_callback_state *arg2 = (input_callback_state *) 0 ;
  
  SWIG_check_num_args("CoreSession::cb_state",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::cb_state",1,"CoreSession *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("CoreSession::cb_state",2,"input_callback_state *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_cb_state_set",1,SWIGTYPE_p_CoreSession);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_input_callback_state,0))){
    SWIG_fail_ptr("CoreSession_cb_state_set",2,SWIGTYPE_p_input_callback_state);
  }
  
  if (arg1) (arg1)->cb_state = *arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_cb_state_get(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  input_callback_state *result = 0 ;
  
  SWIG_check_num_args("CoreSession::cb_state",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::cb_state",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_cb_state_get",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (input_callback_state *)& ((arg1)->cb_state);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_input_callback_state,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_hook_state_set(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  switch_channel_state_t arg2 ;
  switch_channel_state_t *argp2 ;
  
  SWIG_check_num_args("CoreSession::hook_state",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::hook_state",1,"CoreSession *");
  if(!lua_isuserdata(L,2)) SWIG_fail_arg("CoreSession::hook_state",2,"switch_channel_state_t");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_hook_state_set",1,SWIGTYPE_p_CoreSession);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_switch_channel_state_t,0))){
    SWIG_fail_ptr("CoreSession_hook_state_set",2,SWIGTYPE_p_switch_channel_state_t);
  }
  arg2 = *argp2;
  
  if (arg1) (arg1)->hook_state = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_hook_state_get(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  switch_channel_state_t result;
  
  SWIG_check_num_args("CoreSession::hook_state",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::hook_state",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_hook_state_get",1,SWIGTYPE_p_CoreSession);
  }
  
  result =  ((arg1)->hook_state);
  {
    switch_channel_state_t * resultptr = new switch_channel_state_t((const switch_channel_state_t &) result);
    SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_switch_channel_state_t,1); SWIG_arg++;
  }
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_cause_set(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  switch_call_cause_t arg2 ;
  switch_call_cause_t *argp2 ;
  
  SWIG_check_num_args("CoreSession::cause",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::cause",1,"CoreSession *");
  if(!lua_isuserdata(L,2)) SWIG_fail_arg("CoreSession::cause",2,"switch_call_cause_t");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_cause_set",1,SWIGTYPE_p_CoreSession);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_switch_call_cause_t,0))){
    SWIG_fail_ptr("CoreSession_cause_set",2,SWIGTYPE_p_switch_call_cause_t);
  }
  arg2 = *argp2;
  
  if (arg1) (arg1)->cause = arg2;
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_cause_get(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  switch_call_cause_t result;
  
  SWIG_check_num_args("CoreSession::cause",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::cause",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_cause_get",1,SWIGTYPE_p_CoreSession);
  }
  
  result =  ((arg1)->cause);
  {
    switch_call_cause_t * resultptr = new switch_call_cause_t((const switch_call_cause_t &) result);
    SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_switch_call_cause_t,1); SWIG_arg++;
  }
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_uuid_set(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("CoreSession::uuid",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::uuid",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::uuid",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_uuid_set",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->uuid;
    if (arg2) {
      arg1->uuid = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->uuid, (const char *)arg2);
    } else {
      arg1->uuid = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_uuid_get(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::uuid",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::uuid",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_uuid_get",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (char *) ((arg1)->uuid);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_tts_name_set(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("CoreSession::tts_name",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::tts_name",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::tts_name",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_tts_name_set",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->tts_name;
    if (arg2) {
      arg1->tts_name = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->tts_name, (const char *)arg2);
    } else {
      arg1->tts_name = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_tts_name_get(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::tts_name",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::tts_name",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_tts_name_get",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (char *) ((arg1)->tts_name);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_voice_name_set(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("CoreSession::voice_name",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::voice_name",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::voice_name",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_voice_name_set",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->voice_name;
    if (arg2) {
      arg1->voice_name = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->voice_name, (const char *)arg2);
    } else {
      arg1->voice_name = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_voice_name_get(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::voice_name",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::voice_name",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_voice_name_get",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (char *) ((arg1)->voice_name);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_insertFile(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  int arg4 ;
  int result;
  
  SWIG_check_num_args("CoreSession::insertFile",4,4)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::insertFile",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::insertFile",2,"char const *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::insertFile",3,"char const *");
  if(!lua_isnumber(L,4)) SWIG_fail_arg("CoreSession::insertFile",4,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_insertFile",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (int)lua_tonumber(L, 4);
  result = (int)(arg1)->insertFile((char const *)arg2,(char const *)arg3,arg4);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_answer(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int result;
  
  SWIG_check_num_args("CoreSession::answer",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::answer",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_answer",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (int)(arg1)->answer();
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_print(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  int result;
  
  SWIG_check_num_args("CoreSession::print",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::print",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::print",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_print",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (int)(arg1)->print(arg2);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_preAnswer(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int result;
  
  SWIG_check_num_args("CoreSession::preAnswer",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::preAnswer",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_preAnswer",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (int)(arg1)->preAnswer();
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_hangup(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) "normal_clearing" ;
  
  SWIG_check_num_args("CoreSession::hangup",1,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::hangup",1,"CoreSession *");
  if(lua_gettop(L)>=2 && !SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::hangup",2,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_hangup",1,SWIGTYPE_p_CoreSession);
  }
  
  if(lua_gettop(L)>=2){
    arg2 = (char *)lua_tostring(L, 2);
  }
  (arg1)->hangup((char const *)arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_hangupState(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  
  SWIG_check_num_args("CoreSession::hangupState",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::hangupState",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_hangupState",1,SWIGTYPE_p_CoreSession);
  }
  
  (arg1)->hangupState();
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_setVariable(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  
  SWIG_check_num_args("CoreSession::setVariable",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::setVariable",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::setVariable",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::setVariable",3,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_setVariable",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  (arg1)->setVariable(arg2,arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_setPrivate(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  void *arg3 = (void *) 0 ;
  
  SWIG_check_num_args("CoreSession::setPrivate",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::setPrivate",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::setPrivate",2,"char *");
  if(!SWIG_isptrtype(L,3)) SWIG_fail_arg("CoreSession::setPrivate",3,"void *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_setPrivate",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3=(void *)SWIG_MustGetPtr(L,3,0,0,3,"CoreSession_setPrivate");
  (arg1)->setPrivate(arg2,arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_getPrivate(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  void *result = 0 ;
  
  SWIG_check_num_args("CoreSession::getPrivate",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::getPrivate",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::getPrivate",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_getPrivate",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (void *)(arg1)->getPrivate(arg2);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_void,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_getVariable(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::getVariable",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::getVariable",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::getVariable",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_getVariable",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (char *)(arg1)->getVariable(arg2);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_process_callback_result(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  switch_status_t result;
  
  SWIG_check_num_args("CoreSession::process_callback_result",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::process_callback_result",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::process_callback_result",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_process_callback_result",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (arg1)->process_callback_result(arg2);
  {
    switch_status_t * resultptr = new switch_status_t((const switch_status_t &) result);
    SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_switch_status_t,1); SWIG_arg++;
  }
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_say(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  char *arg4 = (char *) 0 ;
  char *arg5 = (char *) 0 ;
  char *arg6 = (char *) NULL ;
  
  SWIG_check_num_args("CoreSession::say",5,6)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::say",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::say",2,"char const *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::say",3,"char const *");
  if(!SWIG_lua_isnilstring(L,4)) SWIG_fail_arg("CoreSession::say",4,"char const *");
  if(!SWIG_lua_isnilstring(L,5)) SWIG_fail_arg("CoreSession::say",5,"char const *");
  if(lua_gettop(L)>=6 && !SWIG_lua_isnilstring(L,6)) SWIG_fail_arg("CoreSession::say",6,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_say",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (char *)lua_tostring(L, 4);
  arg5 = (char *)lua_tostring(L, 5);
  if(lua_gettop(L)>=6){
    arg6 = (char *)lua_tostring(L, 6);
  }
  (arg1)->say((char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_sayPhrase(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) "" ;
  char *arg4 = (char *) NULL ;
  
  SWIG_check_num_args("CoreSession::sayPhrase",2,4)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::sayPhrase",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::sayPhrase",2,"char const *");
  if(lua_gettop(L)>=3 && !SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::sayPhrase",3,"char const *");
  if(lua_gettop(L)>=4 && !SWIG_lua_isnilstring(L,4)) SWIG_fail_arg("CoreSession::sayPhrase",4,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_sayPhrase",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  if(lua_gettop(L)>=3){
    arg3 = (char *)lua_tostring(L, 3);
  }
  if(lua_gettop(L)>=4){
    arg4 = (char *)lua_tostring(L, 4);
  }
  (arg1)->sayPhrase((char const *)arg2,(char const *)arg3,(char const *)arg4);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_hangupCause(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::hangupCause",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::hangupCause",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_hangupCause",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (char *)(arg1)->hangupCause();
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_getState(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::getState",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::getState",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_getState",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (char *)(arg1)->getState();
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_recordFile(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  int arg3 = (int) 0 ;
  int arg4 = (int) 0 ;
  int arg5 = (int) 0 ;
  int result;
  
  SWIG_check_num_args("CoreSession::recordFile",2,5)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::recordFile",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::recordFile",2,"char *");
  if(lua_gettop(L)>=3 && !lua_isnumber(L,3)) SWIG_fail_arg("CoreSession::recordFile",3,"int");
  if(lua_gettop(L)>=4 && !lua_isnumber(L,4)) SWIG_fail_arg("CoreSession::recordFile",4,"int");
  if(lua_gettop(L)>=5 && !lua_isnumber(L,5)) SWIG_fail_arg("CoreSession::recordFile",5,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_recordFile",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  if(lua_gettop(L)>=3){
    arg3 = (int)lua_tonumber(L, 3);
  }
  if(lua_gettop(L)>=4){
    arg4 = (int)lua_tonumber(L, 4);
  }
  if(lua_gettop(L)>=5){
    arg5 = (int)lua_tonumber(L, 5);
  }
  result = (int)(arg1)->recordFile(arg2,arg3,arg4,arg5);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_originate(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  CoreSession *arg2 = (CoreSession *) 0 ;
  char *arg3 = (char *) 0 ;
  int arg4 = (int) 60 ;
  switch_state_handler_table_t *arg5 = (switch_state_handler_table_t *) NULL ;
  int result;
  
  SWIG_check_num_args("CoreSession::originate",3,5)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::originate",1,"CoreSession *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("CoreSession::originate",2,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::originate",3,"char *");
  if(lua_gettop(L)>=4 && !lua_isnumber(L,4)) SWIG_fail_arg("CoreSession::originate",4,"int");
  if(lua_gettop(L)>=5 && !SWIG_isptrtype(L,5)) SWIG_fail_arg("CoreSession::originate",5,"switch_state_handler_table_t *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_originate",1,SWIGTYPE_p_CoreSession);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_originate",2,SWIGTYPE_p_CoreSession);
  }
  
  arg3 = (char *)lua_tostring(L, 3);
  if(lua_gettop(L)>=4){
    arg4 = (int)lua_tonumber(L, 4);
  }
  if(lua_gettop(L)>=5){
    if (!SWIG_IsOK(SWIG_ConvertPtr(L,5,(void**)&arg5,SWIGTYPE_p_switch_state_handler_table_t,0))){
      SWIG_fail_ptr("CoreSession_originate",5,SWIGTYPE_p_switch_state_handler_table_t);
    }
  }
  result = (int)(arg1)->originate(arg2,arg3,arg4,arg5);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_destroy(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  
  SWIG_check_num_args("CoreSession::destroy",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::destroy",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_destroy",1,SWIGTYPE_p_CoreSession);
  }
  
  (arg1)->destroy();
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_setDTMFCallback(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  void *arg2 = (void *) 0 ;
  char *arg3 = (char *) 0 ;
  
  SWIG_check_num_args("CoreSession::setDTMFCallback",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::setDTMFCallback",1,"CoreSession *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("CoreSession::setDTMFCallback",2,"void *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::setDTMFCallback",3,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_setDTMFCallback",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"CoreSession_setDTMFCallback");
  arg3 = (char *)lua_tostring(L, 3);
  (arg1)->setDTMFCallback(arg2,arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_speak(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  int result;
  
  SWIG_check_num_args("CoreSession::speak",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::speak",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::speak",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_speak",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (int)(arg1)->speak(arg2);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_set_tts_parms(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  
  SWIG_check_num_args("CoreSession::set_tts_parms",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::set_tts_parms",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::set_tts_parms",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::set_tts_parms",3,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_set_tts_parms",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  (arg1)->set_tts_parms(arg2,arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_set_tts_params(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  
  SWIG_check_num_args("CoreSession::set_tts_params",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::set_tts_params",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::set_tts_params",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::set_tts_params",3,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_set_tts_params",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  (arg1)->set_tts_params(arg2,arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_collectDigits__SWIG_0(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int arg2 ;
  int result;
  
  SWIG_check_num_args("CoreSession::collectDigits",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::collectDigits",1,"CoreSession *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("CoreSession::collectDigits",2,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_collectDigits",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (int)lua_tonumber(L, 2);
  result = (int)(arg1)->collectDigits(arg2);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_collectDigits__SWIG_1(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int arg2 ;
  int arg3 ;
  int result;
  
  SWIG_check_num_args("CoreSession::collectDigits",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::collectDigits",1,"CoreSession *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("CoreSession::collectDigits",2,"int");
  if(!lua_isnumber(L,3)) SWIG_fail_arg("CoreSession::collectDigits",3,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_collectDigits",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (int)lua_tonumber(L, 2);
  arg3 = (int)lua_tonumber(L, 3);
  result = (int)(arg1)->collectDigits(arg2,arg3);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_collectDigits(lua_State* L) {
  int argc;
  int argv[4]={
    1,2,3,4
  };
  
  argc = lua_gettop(L);
  if (argc == 2) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = lua_isnumber(L,argv[1]);
      }
      if (_v) {
        return _wrap_CoreSession_collectDigits__SWIG_0(L);
      }
    }
  }
  if (argc == 3) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = lua_isnumber(L,argv[1]);
      }
      if (_v) {
        {
          _v = lua_isnumber(L,argv[2]);
        }
        if (_v) {
          return _wrap_CoreSession_collectDigits__SWIG_1(L);
        }
      }
    }
  }
  
  SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'CoreSession_collectDigits'\n"
    "  Possible C/C++ prototypes are:\n"
    "    CoreSession::collectDigits(int)\n"
    "    CoreSession::collectDigits(int,int)\n");
  lua_error(L);return 0;
}


static int _wrap_CoreSession_getDigits__SWIG_0(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int arg2 ;
  char *arg3 = (char *) 0 ;
  int arg4 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::getDigits",4,4)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::getDigits",1,"CoreSession *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("CoreSession::getDigits",2,"int");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::getDigits",3,"char *");
  if(!lua_isnumber(L,4)) SWIG_fail_arg("CoreSession::getDigits",4,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_getDigits",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (int)lua_tonumber(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (int)lua_tonumber(L, 4);
  result = (char *)(arg1)->getDigits(arg2,arg3,arg4);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_getDigits__SWIG_1(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int arg2 ;
  char *arg3 = (char *) 0 ;
  int arg4 ;
  int arg5 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::getDigits",5,5)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::getDigits",1,"CoreSession *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("CoreSession::getDigits",2,"int");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::getDigits",3,"char *");
  if(!lua_isnumber(L,4)) SWIG_fail_arg("CoreSession::getDigits",4,"int");
  if(!lua_isnumber(L,5)) SWIG_fail_arg("CoreSession::getDigits",5,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_getDigits",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (int)lua_tonumber(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (int)lua_tonumber(L, 4);
  arg5 = (int)lua_tonumber(L, 5);
  result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_getDigits__SWIG_2(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int arg2 ;
  char *arg3 = (char *) 0 ;
  int arg4 ;
  int arg5 ;
  int arg6 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::getDigits",6,6)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::getDigits",1,"CoreSession *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("CoreSession::getDigits",2,"int");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::getDigits",3,"char *");
  if(!lua_isnumber(L,4)) SWIG_fail_arg("CoreSession::getDigits",4,"int");
  if(!lua_isnumber(L,5)) SWIG_fail_arg("CoreSession::getDigits",5,"int");
  if(!lua_isnumber(L,6)) SWIG_fail_arg("CoreSession::getDigits",6,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_getDigits",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (int)lua_tonumber(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (int)lua_tonumber(L, 4);
  arg5 = (int)lua_tonumber(L, 5);
  arg6 = (int)lua_tonumber(L, 6);
  result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_getDigits(lua_State* L) {
  int argc;
  int argv[7]={
    1,2,3,4,5,6,7
  };
  
  argc = lua_gettop(L);
  if (argc == 4) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = lua_isnumber(L,argv[1]);
      }
      if (_v) {
        {
          _v = SWIG_lua_isnilstring(L,argv[2]);
        }
        if (_v) {
          {
            _v = lua_isnumber(L,argv[3]);
          }
          if (_v) {
            return _wrap_CoreSession_getDigits__SWIG_0(L);
          }
        }
      }
    }
  }
  if (argc == 5) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = lua_isnumber(L,argv[1]);
      }
      if (_v) {
        {
          _v = SWIG_lua_isnilstring(L,argv[2]);
        }
        if (_v) {
          {
            _v = lua_isnumber(L,argv[3]);
          }
          if (_v) {
            {
              _v = lua_isnumber(L,argv[4]);
            }
            if (_v) {
              return _wrap_CoreSession_getDigits__SWIG_1(L);
            }
          }
        }
      }
    }
  }
  if (argc == 6) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = lua_isnumber(L,argv[1]);
      }
      if (_v) {
        {
          _v = SWIG_lua_isnilstring(L,argv[2]);
        }
        if (_v) {
          {
            _v = lua_isnumber(L,argv[3]);
          }
          if (_v) {
            {
              _v = lua_isnumber(L,argv[4]);
            }
            if (_v) {
              {
                _v = lua_isnumber(L,argv[5]);
              }
              if (_v) {
                return _wrap_CoreSession_getDigits__SWIG_2(L);
              }
            }
          }
        }
      }
    }
  }
  
  SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'CoreSession_getDigits'\n"
    "  Possible C/C++ prototypes are:\n"
    "    CoreSession::getDigits(int,char *,int)\n"
    "    CoreSession::getDigits(int,char *,int,int)\n"
    "    CoreSession::getDigits(int,char *,int,int,int)\n");
  lua_error(L);return 0;
}


static int _wrap_CoreSession_transfer(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) NULL ;
  char *arg4 = (char *) NULL ;
  int result;
  
  SWIG_check_num_args("CoreSession::transfer",2,4)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::transfer",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::transfer",2,"char *");
  if(lua_gettop(L)>=3 && !SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::transfer",3,"char *");
  if(lua_gettop(L)>=4 && !SWIG_lua_isnilstring(L,4)) SWIG_fail_arg("CoreSession::transfer",4,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_transfer",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  if(lua_gettop(L)>=3){
    arg3 = (char *)lua_tostring(L, 3);
  }
  if(lua_gettop(L)>=4){
    arg4 = (char *)lua_tostring(L, 4);
  }
  result = (int)(arg1)->transfer(arg2,arg3,arg4);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_read(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int arg2 ;
  int arg3 ;
  char *arg4 = (char *) 0 ;
  int arg5 ;
  char *arg6 = (char *) 0 ;
  int arg7 = (int) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::read",6,7)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::read",1,"CoreSession *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("CoreSession::read",2,"int");
  if(!lua_isnumber(L,3)) SWIG_fail_arg("CoreSession::read",3,"int");
  if(!SWIG_lua_isnilstring(L,4)) SWIG_fail_arg("CoreSession::read",4,"char const *");
  if(!lua_isnumber(L,5)) SWIG_fail_arg("CoreSession::read",5,"int");
  if(!SWIG_lua_isnilstring(L,6)) SWIG_fail_arg("CoreSession::read",6,"char const *");
  if(lua_gettop(L)>=7 && !lua_isnumber(L,7)) SWIG_fail_arg("CoreSession::read",7,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_read",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (int)lua_tonumber(L, 2);
  arg3 = (int)lua_tonumber(L, 3);
  arg4 = (char *)lua_tostring(L, 4);
  arg5 = (int)lua_tonumber(L, 5);
  arg6 = (char *)lua_tostring(L, 6);
  if(lua_gettop(L)>=7){
    arg7 = (int)lua_tonumber(L, 7);
  }
  result = (char *)(arg1)->read(arg2,arg3,(char const *)arg4,arg5,(char const *)arg6,arg7);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_playAndGetDigits(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int arg2 ;
  int arg3 ;
  int arg4 ;
  int arg5 ;
  char *arg6 = (char *) 0 ;
  char *arg7 = (char *) 0 ;
  char *arg8 = (char *) 0 ;
  char *arg9 = (char *) 0 ;
  char *arg10 = (char *) NULL ;
  int arg11 = (int) 0 ;
  char *arg12 = (char *) NULL ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::playAndGetDigits",9,12)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::playAndGetDigits",1,"CoreSession *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("CoreSession::playAndGetDigits",2,"int");
  if(!lua_isnumber(L,3)) SWIG_fail_arg("CoreSession::playAndGetDigits",3,"int");
  if(!lua_isnumber(L,4)) SWIG_fail_arg("CoreSession::playAndGetDigits",4,"int");
  if(!lua_isnumber(L,5)) SWIG_fail_arg("CoreSession::playAndGetDigits",5,"int");
  if(!SWIG_lua_isnilstring(L,6)) SWIG_fail_arg("CoreSession::playAndGetDigits",6,"char *");
  if(!SWIG_lua_isnilstring(L,7)) SWIG_fail_arg("CoreSession::playAndGetDigits",7,"char *");
  if(!SWIG_lua_isnilstring(L,8)) SWIG_fail_arg("CoreSession::playAndGetDigits",8,"char *");
  if(!SWIG_lua_isnilstring(L,9)) SWIG_fail_arg("CoreSession::playAndGetDigits",9,"char *");
  if(lua_gettop(L)>=10 && !SWIG_lua_isnilstring(L,10)) SWIG_fail_arg("CoreSession::playAndGetDigits",10,"char const *");
  if(lua_gettop(L)>=11 && !lua_isnumber(L,11)) SWIG_fail_arg("CoreSession::playAndGetDigits",11,"int");
  if(lua_gettop(L)>=12 && !SWIG_lua_isnilstring(L,12)) SWIG_fail_arg("CoreSession::playAndGetDigits",12,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_playAndGetDigits",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (int)lua_tonumber(L, 2);
  arg3 = (int)lua_tonumber(L, 3);
  arg4 = (int)lua_tonumber(L, 4);
  arg5 = (int)lua_tonumber(L, 5);
  arg6 = (char *)lua_tostring(L, 6);
  arg7 = (char *)lua_tostring(L, 7);
  arg8 = (char *)lua_tostring(L, 8);
  arg9 = (char *)lua_tostring(L, 9);
  if(lua_gettop(L)>=10){
    arg10 = (char *)lua_tostring(L, 10);
  }
  if(lua_gettop(L)>=11){
    arg11 = (int)lua_tonumber(L, 11);
  }
  if(lua_gettop(L)>=12){
    arg12 = (char *)lua_tostring(L, 12);
  }
  result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,(char const *)arg10,arg11,(char const *)arg12);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_streamFile(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  int arg3 = (int) 0 ;
  int result;
  
  SWIG_check_num_args("CoreSession::streamFile",2,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::streamFile",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::streamFile",2,"char *");
  if(lua_gettop(L)>=3 && !lua_isnumber(L,3)) SWIG_fail_arg("CoreSession::streamFile",3,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_streamFile",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  if(lua_gettop(L)>=3){
    arg3 = (int)lua_tonumber(L, 3);
  }
  result = (int)(arg1)->streamFile(arg2,arg3);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_sleep(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int arg2 ;
  int arg3 = (int) 0 ;
  int result;
  
  SWIG_check_num_args("CoreSession::sleep",2,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::sleep",1,"CoreSession *");
  if(!lua_isnumber(L,2)) SWIG_fail_arg("CoreSession::sleep",2,"int");
  if(lua_gettop(L)>=3 && !lua_isnumber(L,3)) SWIG_fail_arg("CoreSession::sleep",3,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_sleep",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (int)lua_tonumber(L, 2);
  if(lua_gettop(L)>=3){
    arg3 = (int)lua_tonumber(L, 3);
  }
  result = (int)(arg1)->sleep(arg2,arg3);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_flushEvents(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int result;
  
  SWIG_check_num_args("CoreSession::flushEvents",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::flushEvents",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_flushEvents",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (int)(arg1)->flushEvents();
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_flushDigits(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  int result;
  
  SWIG_check_num_args("CoreSession::flushDigits",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::flushDigits",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_flushDigits",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (int)(arg1)->flushDigits();
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_setAutoHangup(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  bool arg2 ;
  int result;
  
  SWIG_check_num_args("CoreSession::setAutoHangup",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::setAutoHangup",1,"CoreSession *");
  if(!lua_isboolean(L,2)) SWIG_fail_arg("CoreSession::setAutoHangup",2,"bool");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_setAutoHangup",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (lua_toboolean(L, 2)!=0);
  result = (int)(arg1)->setAutoHangup(arg2);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_setHangupHook(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  void *arg2 = (void *) 0 ;
  
  SWIG_check_num_args("CoreSession::setHangupHook",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::setHangupHook",1,"CoreSession *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("CoreSession::setHangupHook",2,"void *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_setHangupHook",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"CoreSession_setHangupHook");
  (arg1)->setHangupHook(arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_ready(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  bool result;
  
  SWIG_check_num_args("CoreSession::ready",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::ready",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_ready",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (bool)(arg1)->ready();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_bridged(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  bool result;
  
  SWIG_check_num_args("CoreSession::bridged",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::bridged",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_bridged",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (bool)(arg1)->bridged();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_answered(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  bool result;
  
  SWIG_check_num_args("CoreSession::answered",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::answered",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_answered",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (bool)(arg1)->answered();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_mediaReady(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  bool result;
  
  SWIG_check_num_args("CoreSession::mediaReady",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::mediaReady",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_mediaReady",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (bool)(arg1)->mediaReady();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_waitForAnswer(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  CoreSession *arg2 = (CoreSession *) 0 ;
  
  SWIG_check_num_args("CoreSession::waitForAnswer",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::waitForAnswer",1,"CoreSession *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("CoreSession::waitForAnswer",2,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_waitForAnswer",1,SWIGTYPE_p_CoreSession);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_waitForAnswer",2,SWIGTYPE_p_CoreSession);
  }
  
  (arg1)->waitForAnswer(arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_execute(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) NULL ;
  
  SWIG_check_num_args("CoreSession::execute",2,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::execute",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::execute",2,"char const *");
  if(lua_gettop(L)>=3 && !SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::execute",3,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_execute",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  if(lua_gettop(L)>=3){
    arg3 = (char *)lua_tostring(L, 3);
  }
  (arg1)->execute((char const *)arg2,(char const *)arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_sendEvent(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  Event *arg2 = (Event *) 0 ;
  
  SWIG_check_num_args("CoreSession::sendEvent",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::sendEvent",1,"CoreSession *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("CoreSession::sendEvent",2,"Event *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_sendEvent",1,SWIGTYPE_p_CoreSession);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("CoreSession_sendEvent",2,SWIGTYPE_p_Event);
  }
  
  (arg1)->sendEvent(arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_setEventData(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  Event *arg2 = (Event *) 0 ;
  
  SWIG_check_num_args("CoreSession::setEventData",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::setEventData",1,"CoreSession *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("CoreSession::setEventData",2,"Event *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_setEventData",1,SWIGTYPE_p_CoreSession);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_Event,0))){
    SWIG_fail_ptr("CoreSession_setEventData",2,SWIGTYPE_p_Event);
  }
  
  (arg1)->setEventData(arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_getXMLCDR(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::getXMLCDR",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::getXMLCDR",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_getXMLCDR",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (char *)(arg1)->getXMLCDR();
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_begin_allow_threads(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  bool result;
  
  SWIG_check_num_args("CoreSession::begin_allow_threads",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::begin_allow_threads",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_begin_allow_threads",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (bool)(arg1)->begin_allow_threads();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_end_allow_threads(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  bool result;
  
  SWIG_check_num_args("CoreSession::end_allow_threads",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::end_allow_threads",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_end_allow_threads",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (bool)(arg1)->end_allow_threads();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_get_uuid(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("CoreSession::get_uuid",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::get_uuid",1,"CoreSession const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_get_uuid",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (char *)((CoreSession const *)arg1)->get_uuid();
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_get_cb_args(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  switch_input_args_t *result = 0 ;
  
  SWIG_check_num_args("CoreSession::get_cb_args",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::get_cb_args",1,"CoreSession const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_get_cb_args",1,SWIGTYPE_p_CoreSession);
  }
  
  result = (switch_input_args_t *) &((CoreSession const *)arg1)->get_cb_args();
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_switch_input_args_t,0); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_check_hangup_hook(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  
  SWIG_check_num_args("CoreSession::check_hangup_hook",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::check_hangup_hook",1,"CoreSession *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_check_hangup_hook",1,SWIGTYPE_p_CoreSession);
  }
  
  (arg1)->check_hangup_hook();
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_run_dtmf_callback(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  void *arg2 = (void *) 0 ;
  switch_input_type_t arg3 ;
  switch_input_type_t *argp3 ;
  switch_status_t result;
  
  SWIG_check_num_args("CoreSession::run_dtmf_callback",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::run_dtmf_callback",1,"CoreSession *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("CoreSession::run_dtmf_callback",2,"void *");
  if(!lua_isuserdata(L,3)) SWIG_fail_arg("CoreSession::run_dtmf_callback",3,"switch_input_type_t");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_run_dtmf_callback",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"CoreSession_run_dtmf_callback");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&argp3,SWIGTYPE_p_switch_input_type_t,0))){
    SWIG_fail_ptr("CoreSession_run_dtmf_callback",3,SWIGTYPE_p_switch_input_type_t);
  }
  arg3 = *argp3;
  
  result = (arg1)->run_dtmf_callback(arg2,arg3);
  {
    switch_status_t * resultptr = new switch_status_t((const switch_status_t &) result);
    SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_switch_status_t,1); SWIG_arg++;
  }
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_consoleLog(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  
  SWIG_check_num_args("CoreSession::consoleLog",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::consoleLog",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::consoleLog",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::consoleLog",3,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_consoleLog",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  (arg1)->consoleLog(arg2,arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_CoreSession_consoleLog2(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = (CoreSession *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  char *arg4 = (char *) 0 ;
  int arg5 ;
  char *arg6 = (char *) 0 ;
  
  SWIG_check_num_args("CoreSession::consoleLog2",6,6)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession::consoleLog2",1,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("CoreSession::consoleLog2",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("CoreSession::consoleLog2",3,"char *");
  if(!SWIG_lua_isnilstring(L,4)) SWIG_fail_arg("CoreSession::consoleLog2",4,"char *");
  if(!lua_isnumber(L,5)) SWIG_fail_arg("CoreSession::consoleLog2",5,"int");
  if(!SWIG_lua_isnilstring(L,6)) SWIG_fail_arg("CoreSession::consoleLog2",6,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("CoreSession_consoleLog2",1,SWIGTYPE_p_CoreSession);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (char *)lua_tostring(L, 4);
  arg5 = (int)lua_tonumber(L, 5);
  arg6 = (char *)lua_tostring(L, 6);
  (arg1)->consoleLog2(arg2,arg3,arg4,arg5,arg6);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static void swig_delete_CoreSession(void *obj) {
CoreSession *arg1 = (CoreSession *) obj;
delete arg1;
}
static swig_lua_attribute swig_CoreSession_attributes[] = {
    { "session", _wrap_CoreSession_session_get, _wrap_CoreSession_session_set },
    { "channel", _wrap_CoreSession_channel_get, _wrap_CoreSession_channel_set },
    { "flags", _wrap_CoreSession_flags_get, _wrap_CoreSession_flags_set },
    { "allocated", _wrap_CoreSession_allocated_get, _wrap_CoreSession_allocated_set },
    { "cb_state", _wrap_CoreSession_cb_state_get, _wrap_CoreSession_cb_state_set },
    { "hook_state", _wrap_CoreSession_hook_state_get, _wrap_CoreSession_hook_state_set },
    { "cause", _wrap_CoreSession_cause_get, _wrap_CoreSession_cause_set },
    { "uuid", _wrap_CoreSession_uuid_get, _wrap_CoreSession_uuid_set },
    { "tts_name", _wrap_CoreSession_tts_name_get, _wrap_CoreSession_tts_name_set },
    { "voice_name", _wrap_CoreSession_voice_name_get, _wrap_CoreSession_voice_name_set },
    {0,0,0}
};
static swig_lua_method swig_CoreSession_methods[]= {
    { "insertFile", _wrap_CoreSession_insertFile},
    { "answer", _wrap_CoreSession_answer},
    { "print", _wrap_CoreSession_print},
    { "preAnswer", _wrap_CoreSession_preAnswer},
    { "hangup", _wrap_CoreSession_hangup},
    { "hangupState", _wrap_CoreSession_hangupState},
    { "setVariable", _wrap_CoreSession_setVariable},
    { "setPrivate", _wrap_CoreSession_setPrivate},
    { "getPrivate", _wrap_CoreSession_getPrivate},
    { "getVariable", _wrap_CoreSession_getVariable},
    { "process_callback_result", _wrap_CoreSession_process_callback_result},
    { "say", _wrap_CoreSession_say},
    { "sayPhrase", _wrap_CoreSession_sayPhrase},
    { "hangupCause", _wrap_CoreSession_hangupCause},
    { "getState", _wrap_CoreSession_getState},
    { "recordFile", _wrap_CoreSession_recordFile},
    { "originate", _wrap_CoreSession_originate},
    { "destroy", _wrap_CoreSession_destroy},
    { "setDTMFCallback", _wrap_CoreSession_setDTMFCallback},
    { "speak", _wrap_CoreSession_speak},
    { "set_tts_parms", _wrap_CoreSession_set_tts_parms},
    { "set_tts_params", _wrap_CoreSession_set_tts_params},
    { "collectDigits", _wrap_CoreSession_collectDigits},
    { "getDigits", _wrap_CoreSession_getDigits},
    { "transfer", _wrap_CoreSession_transfer},
    { "read", _wrap_CoreSession_read},
    { "playAndGetDigits", _wrap_CoreSession_playAndGetDigits},
    { "streamFile", _wrap_CoreSession_streamFile},
    { "sleep", _wrap_CoreSession_sleep},
    { "flushEvents", _wrap_CoreSession_flushEvents},
    { "flushDigits", _wrap_CoreSession_flushDigits},
    { "setAutoHangup", _wrap_CoreSession_setAutoHangup},
    { "setHangupHook", _wrap_CoreSession_setHangupHook},
    { "ready", _wrap_CoreSession_ready},
    { "bridged", _wrap_CoreSession_bridged},
    { "answered", _wrap_CoreSession_answered},
    { "mediaReady", _wrap_CoreSession_mediaReady},
    { "waitForAnswer", _wrap_CoreSession_waitForAnswer},
    { "execute", _wrap_CoreSession_execute},
    { "sendEvent", _wrap_CoreSession_sendEvent},
    { "setEventData", _wrap_CoreSession_setEventData},
    { "getXMLCDR", _wrap_CoreSession_getXMLCDR},
    { "begin_allow_threads", _wrap_CoreSession_begin_allow_threads},
    { "end_allow_threads", _wrap_CoreSession_end_allow_threads},
    { "get_uuid", _wrap_CoreSession_get_uuid},
    { "get_cb_args", _wrap_CoreSession_get_cb_args},
    { "check_hangup_hook", _wrap_CoreSession_check_hangup_hook},
    { "run_dtmf_callback", _wrap_CoreSession_run_dtmf_callback},
    { "consoleLog", _wrap_CoreSession_consoleLog},
    { "consoleLog2", _wrap_CoreSession_consoleLog2},
    {0,0}
};
static swig_lua_method swig_CoreSession_meta[] = {
    {0,0}
};

static swig_lua_attribute swig_CoreSession_Sf_SwigStatic_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_CoreSession_Sf_SwigStatic_constants[]= {
    {0,0,0,0,0,0}
};
static swig_lua_method swig_CoreSession_Sf_SwigStatic_methods[]= {
    {0,0}
};
static swig_lua_class* swig_CoreSession_Sf_SwigStatic_classes[]= {
    0
};

static swig_lua_namespace swig_CoreSession_Sf_SwigStatic = {
    "CoreSession",
    swig_CoreSession_Sf_SwigStatic_methods,
    swig_CoreSession_Sf_SwigStatic_attributes,
    swig_CoreSession_Sf_SwigStatic_constants,
    swig_CoreSession_Sf_SwigStatic_classes,
    0
};
static swig_lua_class *swig_CoreSession_bases[] = {0};
static const char *swig_CoreSession_base_names[] = {0};
static swig_lua_class _wrap_class_CoreSession = { "CoreSession", "CoreSession", &SWIGTYPE_p_CoreSession,0, swig_delete_CoreSession, swig_CoreSession_methods, swig_CoreSession_attributes, &swig_CoreSession_Sf_SwigStatic, swig_CoreSession_meta, swig_CoreSession_bases, swig_CoreSession_base_names };

static int _wrap_console_log(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("console_log",2,2)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("console_log",1,"char *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("console_log",2,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  arg2 = (char *)lua_tostring(L, 2);
  console_log(arg1,arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_console_log2(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  int arg4 ;
  char *arg5 = (char *) 0 ;
  
  SWIG_check_num_args("console_log2",5,5)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("console_log2",1,"char *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("console_log2",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("console_log2",3,"char *");
  if(!lua_isnumber(L,4)) SWIG_fail_arg("console_log2",4,"int");
  if(!SWIG_lua_isnilstring(L,5)) SWIG_fail_arg("console_log2",5,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (int)lua_tonumber(L, 4);
  arg5 = (char *)lua_tostring(L, 5);
  console_log2(arg1,arg2,arg3,arg4,arg5);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_console_clean_log(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  
  SWIG_check_num_args("console_clean_log",1,1)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("console_clean_log",1,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  console_clean_log(arg1);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_msleep(lua_State* L) {
  int SWIG_arg = 0;
  unsigned int arg1 ;
  
  SWIG_check_num_args("switch_msleep",1,1)
  if(!lua_isnumber(L,1)) SWIG_fail_arg("switch_msleep",1,"unsigned int");
  SWIG_contract_assert((lua_tonumber(L,1)>=0),"number must not be negative")
  arg1 = (unsigned int)lua_tonumber(L, 1);
  switch_msleep(arg1);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_bridge(lua_State* L) {
  int SWIG_arg = 0;
  CoreSession *arg1 = 0 ;
  CoreSession *arg2 = 0 ;
  
  SWIG_check_num_args("bridge",2,2)
  if(!lua_isuserdata(L,1)) SWIG_fail_arg("bridge",1,"CoreSession &");
  if(!lua_isuserdata(L,2)) SWIG_fail_arg("bridge",2,"CoreSession &");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("bridge",1,SWIGTYPE_p_CoreSession);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("bridge",2,SWIGTYPE_p_CoreSession);
  }
  
  bridge(*arg1,*arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_hanguphook(lua_State* L) {
  int SWIG_arg = 0;
  switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
  switch_status_t result;
  
  SWIG_check_num_args("hanguphook",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("hanguphook",1,"switch_core_session_t *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_switch_core_session_t,0))){
    SWIG_fail_ptr("hanguphook",1,SWIGTYPE_p_switch_core_session_t);
  }
  
  result = hanguphook(arg1);
  {
    switch_status_t * resultptr = new switch_status_t((const switch_status_t &) result);
    SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_switch_status_t,1); SWIG_arg++;
  }
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_dtmf_callback(lua_State* L) {
  int SWIG_arg = 0;
  switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
  void *arg2 = (void *) 0 ;
  switch_input_type_t arg3 ;
  void *arg4 = (void *) 0 ;
  unsigned int arg5 ;
  switch_input_type_t *argp3 ;
  switch_status_t result;
  
  SWIG_check_num_args("dtmf_callback",5,5)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("dtmf_callback",1,"switch_core_session_t *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("dtmf_callback",2,"void *");
  if(!lua_isuserdata(L,3)) SWIG_fail_arg("dtmf_callback",3,"switch_input_type_t");
  if(!SWIG_isptrtype(L,4)) SWIG_fail_arg("dtmf_callback",4,"void *");
  if(!lua_isnumber(L,5)) SWIG_fail_arg("dtmf_callback",5,"unsigned int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_switch_core_session_t,0))){
    SWIG_fail_ptr("dtmf_callback",1,SWIGTYPE_p_switch_core_session_t);
  }
  
  arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"dtmf_callback");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&argp3,SWIGTYPE_p_switch_input_type_t,0))){
    SWIG_fail_ptr("dtmf_callback",3,SWIGTYPE_p_switch_input_type_t);
  }
  arg3 = *argp3;
  
  arg4=(void *)SWIG_MustGetPtr(L,4,0,0,4,"dtmf_callback");
  SWIG_contract_assert((lua_tonumber(L,5)>=0),"number must not be negative")
  arg5 = (unsigned int)lua_tonumber(L, 5);
  result = dtmf_callback(arg1,arg2,arg3,arg4,arg5);
  {
    switch_status_t * resultptr = new switch_status_t((const switch_status_t &) result);
    SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_switch_status_t,1); SWIG_arg++;
  }
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Session__SWIG_0(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *result = 0 ;
  
  SWIG_check_num_args("LUA::Session::Session",0,0)
  result = (LUA::Session *)new LUA::Session();
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++; result->setLUA(L);
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Session__SWIG_1(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  CoreSession *arg2 = (CoreSession *) 0 ;
  LUA::Session *result = 0 ;
  
  SWIG_check_num_args("LUA::Session::Session",2,2)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("LUA::Session::Session",1,"char *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("LUA::Session::Session",2,"CoreSession *");
  arg1 = (char *)lua_tostring(L, 1);
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("new_Session",2,SWIGTYPE_p_CoreSession);
  }
  
  result = (LUA::Session *)new LUA::Session(arg1,arg2);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++;  result->setLUA(L);
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Session__SWIG_2(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  LUA::Session *result = 0 ;
  
  SWIG_check_num_args("LUA::Session::Session",1,1)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("LUA::Session::Session",1,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  result = (LUA::Session *)new LUA::Session(arg1);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++;  result->setLUA(L);
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Session__SWIG_3(lua_State* L) {
  int SWIG_arg = 0;
  switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
  LUA::Session *result = 0 ;
  
  SWIG_check_num_args("LUA::Session::Session",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::Session",1,"switch_core_session_t *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_switch_core_session_t,0))){
    SWIG_fail_ptr("new_Session",1,SWIGTYPE_p_switch_core_session_t);
  }
  
  result = (LUA::Session *)new LUA::Session(arg1);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Session,1); SWIG_arg++;  result->setLUA(L);
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Session(lua_State* L) {
  int argc;
  int argv[3]={
    1,2,3
  };
  
  argc = lua_gettop(L);
  if (argc == 0) {
    return _wrap_new_Session__SWIG_0(L);
  }
  if (argc == 1) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_switch_core_session_t, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      return _wrap_new_Session__SWIG_3(L);
    }
  }
  if (argc == 1) {
    int _v;
    {
      _v = SWIG_lua_isnilstring(L,argv[0]);
    }
    if (_v) {
      return _wrap_new_Session__SWIG_2(L);
    }
  }
  if (argc == 2) {
    int _v;
    {
      _v = SWIG_lua_isnilstring(L,argv[0]);
    }
    if (_v) {
      {
        void *ptr;
        if (SWIG_isptrtype(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_CoreSession, 0)) {
          _v = 0;
        } else {
          _v = 1;
        }
      }
      if (_v) {
        return _wrap_new_Session__SWIG_1(L);
      }
    }
  }
  
  SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_Session'\n"
    "  Possible C/C++ prototypes are:\n"
    "    LUA::Session::Session()\n"
    "    LUA::Session::Session(char *,CoreSession *)\n"
    "    LUA::Session::Session(char *)\n"
    "    LUA::Session::Session(switch_core_session_t *)\n");
  lua_error(L);return 0;
}


static int _wrap_Session_destroy__SWIG_0(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("LUA::Session::destroy",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::destroy",1,"LUA::Session *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Session::destroy",2,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_destroy",1,SWIGTYPE_p_LUA__Session);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  (arg1)->destroy((char const *)arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_destroy__SWIG_1(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  
  SWIG_check_num_args("LUA::Session::destroy",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::destroy",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_destroy",1,SWIGTYPE_p_LUA__Session);
  }
  
  (arg1)->destroy();
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_destroy(lua_State* L) {
  int argc;
  int argv[3]={
    1,2,3
  };
  
  argc = lua_gettop(L);
  if (argc == 1) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Session, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      return _wrap_Session_destroy__SWIG_1(L);
    }
  }
  if (argc == 2) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Session, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        return _wrap_Session_destroy__SWIG_0(L);
      }
    }
  }
  
  SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'Session_destroy'\n"
    "  Possible C/C++ prototypes are:\n"
    "    LUA::Session::destroy(char const *)\n"
    "    LUA::Session::destroy()\n");
  lua_error(L);return 0;
}


static int _wrap_Session_begin_allow_threads(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  bool result;
  
  SWIG_check_num_args("LUA::Session::begin_allow_threads",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::begin_allow_threads",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_begin_allow_threads",1,SWIGTYPE_p_LUA__Session);
  }
  
  result = (bool)(arg1)->begin_allow_threads();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_end_allow_threads(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  bool result;
  
  SWIG_check_num_args("LUA::Session::end_allow_threads",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::end_allow_threads",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_end_allow_threads",1,SWIGTYPE_p_LUA__Session);
  }
  
  result = (bool)(arg1)->end_allow_threads();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_check_hangup_hook(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  
  SWIG_check_num_args("LUA::Session::check_hangup_hook",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::check_hangup_hook",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_check_hangup_hook",1,SWIGTYPE_p_LUA__Session);
  }
  
  (arg1)->check_hangup_hook();
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_run_dtmf_callback(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  void *arg2 = (void *) 0 ;
  switch_input_type_t arg3 ;
  switch_input_type_t *argp3 ;
  switch_status_t result;
  
  SWIG_check_num_args("LUA::Session::run_dtmf_callback",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::run_dtmf_callback",1,"LUA::Session *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("LUA::Session::run_dtmf_callback",2,"void *");
  if(!lua_isuserdata(L,3)) SWIG_fail_arg("LUA::Session::run_dtmf_callback",3,"switch_input_type_t");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_run_dtmf_callback",1,SWIGTYPE_p_LUA__Session);
  }
  
  arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"Session_run_dtmf_callback");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&argp3,SWIGTYPE_p_switch_input_type_t,0))){
    SWIG_fail_ptr("Session_run_dtmf_callback",3,SWIGTYPE_p_switch_input_type_t);
  }
  arg3 = *argp3;
  
  result = (arg1)->run_dtmf_callback(arg2,arg3);
  {
    switch_status_t * resultptr = new switch_status_t((const switch_status_t &) result);
    SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_switch_status_t,1); SWIG_arg++;
  }
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_unsetInputCallback(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  
  SWIG_check_num_args("LUA::Session::unsetInputCallback",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::unsetInputCallback",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_unsetInputCallback",1,SWIGTYPE_p_LUA__Session);
  }
  
  (arg1)->unsetInputCallback();
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_setInputCallback__SWIG_0(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  
  SWIG_check_num_args("LUA::Session::setInputCallback",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::setInputCallback",1,"LUA::Session *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Session::setInputCallback",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("LUA::Session::setInputCallback",3,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_setInputCallback",1,SWIGTYPE_p_LUA__Session);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  (arg1)->setInputCallback(arg2,arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_setInputCallback__SWIG_1(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("LUA::Session::setInputCallback",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::setInputCallback",1,"LUA::Session *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Session::setInputCallback",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_setInputCallback",1,SWIGTYPE_p_LUA__Session);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  (arg1)->setInputCallback(arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_setInputCallback(lua_State* L) {
  int argc;
  int argv[4]={
    1,2,3,4
  };
  
  argc = lua_gettop(L);
  if (argc == 2) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Session, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        return _wrap_Session_setInputCallback__SWIG_1(L);
      }
    }
  }
  if (argc == 3) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Session, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        {
          _v = SWIG_lua_isnilstring(L,argv[2]);
        }
        if (_v) {
          return _wrap_Session_setInputCallback__SWIG_0(L);
        }
      }
    }
  }
  
  SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'Session_setInputCallback'\n"
    "  Possible C/C++ prototypes are:\n"
    "    LUA::Session::setInputCallback(char *,char *)\n"
    "    LUA::Session::setInputCallback(char *)\n");
  lua_error(L);return 0;
}


static int _wrap_Session_setHangupHook__SWIG_0(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  
  SWIG_check_num_args("LUA::Session::setHangupHook",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::setHangupHook",1,"LUA::Session *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Session::setHangupHook",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("LUA::Session::setHangupHook",3,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_setHangupHook",1,SWIGTYPE_p_LUA__Session);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  (arg1)->setHangupHook(arg2,arg3);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_setHangupHook__SWIG_1(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("LUA::Session::setHangupHook",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::setHangupHook",1,"LUA::Session *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Session::setHangupHook",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_setHangupHook",1,SWIGTYPE_p_LUA__Session);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  (arg1)->setHangupHook(arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_setHangupHook(lua_State* L) {
  int argc;
  int argv[4]={
    1,2,3,4
  };
  
  argc = lua_gettop(L);
  if (argc == 2) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Session, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        return _wrap_Session_setHangupHook__SWIG_1(L);
      }
    }
  }
  if (argc == 3) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Session, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        {
          _v = SWIG_lua_isnilstring(L,argv[2]);
        }
        if (_v) {
          return _wrap_Session_setHangupHook__SWIG_0(L);
        }
      }
    }
  }
  
  SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'Session_setHangupHook'\n"
    "  Possible C/C++ prototypes are:\n"
    "    LUA::Session::setHangupHook(char *,char *)\n"
    "    LUA::Session::setHangupHook(char *)\n");
  lua_error(L);return 0;
}


static int _wrap_Session_ready(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  bool result;
  
  SWIG_check_num_args("LUA::Session::ready",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::ready",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_ready",1,SWIGTYPE_p_LUA__Session);
  }
  
  result = (bool)(arg1)->ready();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_originate(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  CoreSession *arg2 = (CoreSession *) 0 ;
  char *arg3 = (char *) 0 ;
  int arg4 ;
  int result;
  
  SWIG_check_num_args("LUA::Session::originate",4,4)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::originate",1,"LUA::Session *");
  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("LUA::Session::originate",2,"CoreSession *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("LUA::Session::originate",3,"char *");
  if(!lua_isnumber(L,4)) SWIG_fail_arg("LUA::Session::originate",4,"int");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_originate",1,SWIGTYPE_p_LUA__Session);
  }
  
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_CoreSession,0))){
    SWIG_fail_ptr("Session_originate",2,SWIGTYPE_p_CoreSession);
  }
  
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (int)lua_tonumber(L, 4);
  result = (int)(arg1)->originate(arg2,arg3,arg4);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_cb_function_set(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("LUA::Session::cb_function",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::cb_function",1,"LUA::Session *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Session::cb_function",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_cb_function_set",1,SWIGTYPE_p_LUA__Session);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->cb_function;
    if (arg2) {
      arg1->cb_function = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->cb_function, (const char *)arg2);
    } else {
      arg1->cb_function = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_cb_function_get(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("LUA::Session::cb_function",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::cb_function",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_cb_function_get",1,SWIGTYPE_p_LUA__Session);
  }
  
  result = (char *) ((arg1)->cb_function);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_cb_arg_set(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("LUA::Session::cb_arg",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::cb_arg",1,"LUA::Session *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Session::cb_arg",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_cb_arg_set",1,SWIGTYPE_p_LUA__Session);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->cb_arg;
    if (arg2) {
      arg1->cb_arg = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->cb_arg, (const char *)arg2);
    } else {
      arg1->cb_arg = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_cb_arg_get(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("LUA::Session::cb_arg",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::cb_arg",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_cb_arg_get",1,SWIGTYPE_p_LUA__Session);
  }
  
  result = (char *) ((arg1)->cb_arg);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_hangup_func_str_set(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("LUA::Session::hangup_func_str",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::hangup_func_str",1,"LUA::Session *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Session::hangup_func_str",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_hangup_func_str_set",1,SWIGTYPE_p_LUA__Session);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->hangup_func_str;
    if (arg2) {
      arg1->hangup_func_str = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->hangup_func_str, (const char *)arg2);
    } else {
      arg1->hangup_func_str = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_hangup_func_str_get(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("LUA::Session::hangup_func_str",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::hangup_func_str",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_hangup_func_str_get",1,SWIGTYPE_p_LUA__Session);
  }
  
  result = (char *) ((arg1)->hangup_func_str);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_hangup_func_arg_set(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *arg2 = (char *) 0 ;
  
  SWIG_check_num_args("LUA::Session::hangup_func_arg",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::hangup_func_arg",1,"LUA::Session *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Session::hangup_func_arg",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_hangup_func_arg_set",1,SWIGTYPE_p_LUA__Session);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  {
    delete [] arg1->hangup_func_arg;
    if (arg2) {
      arg1->hangup_func_arg = (char *) (new char[strlen((const char *)arg2)+1]);
      strcpy((char *)arg1->hangup_func_arg, (const char *)arg2);
    } else {
      arg1->hangup_func_arg = 0;
    }
  }
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_hangup_func_arg_get(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("LUA::Session::hangup_func_arg",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::hangup_func_arg",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_hangup_func_arg_get",1,SWIGTYPE_p_LUA__Session);
  }
  
  result = (char *) ((arg1)->hangup_func_arg);
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Session_setLUA(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Session *arg1 = (LUA::Session *) 0 ;
  lua_State *arg2 = (lua_State *) 0 ;
  
  arg2 = L;
  SWIG_check_num_args("LUA::Session::setLUA",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Session::setLUA",1,"LUA::Session *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
    SWIG_fail_ptr("Session_setLUA",1,SWIGTYPE_p_LUA__Session);
  }
  
  (arg1)->setLUA(arg2);
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static void swig_delete_Session(void *obj) {
LUA::Session *arg1 = (LUA::Session *) obj;
delete arg1;
}
static int _proxy__wrap_new_Session(lua_State *L) {
    assert(lua_istable(L,1));
    lua_pushcfunction(L,_wrap_new_Session);
    assert(!lua_isnil(L,-1));
    lua_replace(L,1); /* replace our table with real constructor */
    lua_call(L,lua_gettop(L)-1,1);
    return 1;
}
static swig_lua_attribute swig_Session_attributes[] = {
    { "cb_function", _wrap_Session_cb_function_get, _wrap_Session_cb_function_set },
    { "cb_arg", _wrap_Session_cb_arg_get, _wrap_Session_cb_arg_set },
    { "hangup_func_str", _wrap_Session_hangup_func_str_get, _wrap_Session_hangup_func_str_set },
    { "hangup_func_arg", _wrap_Session_hangup_func_arg_get, _wrap_Session_hangup_func_arg_set },
    {0,0,0}
};
static swig_lua_method swig_Session_methods[]= {
    { "destroy", _wrap_Session_destroy},
    { "begin_allow_threads", _wrap_Session_begin_allow_threads},
    { "end_allow_threads", _wrap_Session_end_allow_threads},
    { "check_hangup_hook", _wrap_Session_check_hangup_hook},
    { "run_dtmf_callback", _wrap_Session_run_dtmf_callback},
    { "unsetInputCallback", _wrap_Session_unsetInputCallback},
    { "setInputCallback", _wrap_Session_setInputCallback},
    { "setHangupHook", _wrap_Session_setHangupHook},
    { "ready", _wrap_Session_ready},
    { "originate", _wrap_Session_originate},
    { "setLUA", _wrap_Session_setLUA},
    {0,0}
};
static swig_lua_method swig_Session_meta[] = {
    {0,0}
};

static swig_lua_attribute swig_Session_Sf_SwigStatic_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_Session_Sf_SwigStatic_constants[]= {
    {0,0,0,0,0,0}
};
static swig_lua_method swig_Session_Sf_SwigStatic_methods[]= {
    {0,0}
};
static swig_lua_class* swig_Session_Sf_SwigStatic_classes[]= {
    0
};

static swig_lua_namespace swig_Session_Sf_SwigStatic = {
    "Session",
    swig_Session_Sf_SwigStatic_methods,
    swig_Session_Sf_SwigStatic_attributes,
    swig_Session_Sf_SwigStatic_constants,
    swig_Session_Sf_SwigStatic_classes,
    0
};
static swig_lua_class *swig_Session_bases[] = {0,0};
static const char *swig_Session_base_names[] = {"CoreSession *",0};
static swig_lua_class _wrap_class_Session = { "Session", "Session", &SWIGTYPE_p_LUA__Session,_proxy__wrap_new_Session, swig_delete_Session, swig_Session_methods, swig_Session_attributes, &swig_Session_Sf_SwigStatic, swig_Session_meta, swig_Session_bases, swig_Session_base_names };

static int _wrap_new_Dbh__SWIG_0(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  LUA::Dbh *result = 0 ;
  
  SWIG_check_num_args("LUA::Dbh::Dbh",3,3)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("LUA::Dbh::Dbh",1,"char *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Dbh::Dbh",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("LUA::Dbh::Dbh",3,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  result = (LUA::Dbh *)new LUA::Dbh(arg1,arg2,arg3);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Dbh,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Dbh__SWIG_1(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  char *arg2 = (char *) 0 ;
  LUA::Dbh *result = 0 ;
  
  SWIG_check_num_args("LUA::Dbh::Dbh",2,2)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("LUA::Dbh::Dbh",1,"char *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Dbh::Dbh",2,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  arg2 = (char *)lua_tostring(L, 2);
  result = (LUA::Dbh *)new LUA::Dbh(arg1,arg2);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Dbh,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Dbh__SWIG_2(lua_State* L) {
  int SWIG_arg = 0;
  char *arg1 = (char *) 0 ;
  LUA::Dbh *result = 0 ;
  
  SWIG_check_num_args("LUA::Dbh::Dbh",1,1)
  if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("LUA::Dbh::Dbh",1,"char *");
  arg1 = (char *)lua_tostring(L, 1);
  result = (LUA::Dbh *)new LUA::Dbh(arg1);
  SWIG_NewPointerObj(L,result,SWIGTYPE_p_LUA__Dbh,1); SWIG_arg++; 
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_new_Dbh(lua_State* L) {
  int argc;
  int argv[4]={
    1,2,3,4
  };
  
  argc = lua_gettop(L);
  if (argc == 1) {
    int _v;
    {
      _v = SWIG_lua_isnilstring(L,argv[0]);
    }
    if (_v) {
      return _wrap_new_Dbh__SWIG_2(L);
    }
  }
  if (argc == 2) {
    int _v;
    {
      _v = SWIG_lua_isnilstring(L,argv[0]);
    }
    if (_v) {
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        return _wrap_new_Dbh__SWIG_1(L);
      }
    }
  }
  if (argc == 3) {
    int _v;
    {
      _v = SWIG_lua_isnilstring(L,argv[0]);
    }
    if (_v) {
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        {
          _v = SWIG_lua_isnilstring(L,argv[2]);
        }
        if (_v) {
          return _wrap_new_Dbh__SWIG_0(L);
        }
      }
    }
  }
  
  SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_Dbh'\n"
    "  Possible C/C++ prototypes are:\n"
    "    LUA::Dbh::Dbh(char *,char *,char *)\n"
    "    LUA::Dbh::Dbh(char *,char *)\n"
    "    LUA::Dbh::Dbh(char *)\n");
  lua_error(L);return 0;
}


static int _wrap_Dbh_release(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
  bool result;
  
  SWIG_check_num_args("LUA::Dbh::release",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::release",1,"LUA::Dbh *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
    SWIG_fail_ptr("Dbh_release",1,SWIGTYPE_p_LUA__Dbh);
  }
  
  result = (bool)(arg1)->release();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Dbh_connected(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
  bool result;
  
  SWIG_check_num_args("LUA::Dbh::connected",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::connected",1,"LUA::Dbh *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
    SWIG_fail_ptr("Dbh_connected",1,SWIGTYPE_p_LUA__Dbh);
  }
  
  result = (bool)(arg1)->connected();
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Dbh_test_reactive__SWIG_0(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  char *arg4 = (char *) 0 ;
  bool result;
  
  SWIG_check_num_args("LUA::Dbh::test_reactive",4,4)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::test_reactive",1,"LUA::Dbh *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Dbh::test_reactive",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("LUA::Dbh::test_reactive",3,"char *");
  if(!SWIG_lua_isnilstring(L,4)) SWIG_fail_arg("LUA::Dbh::test_reactive",4,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
    SWIG_fail_ptr("Dbh_test_reactive",1,SWIGTYPE_p_LUA__Dbh);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  arg4 = (char *)lua_tostring(L, 4);
  result = (bool)(arg1)->test_reactive(arg2,arg3,arg4);
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Dbh_test_reactive__SWIG_1(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
  char *arg2 = (char *) 0 ;
  char *arg3 = (char *) 0 ;
  bool result;
  
  SWIG_check_num_args("LUA::Dbh::test_reactive",3,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::test_reactive",1,"LUA::Dbh *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Dbh::test_reactive",2,"char *");
  if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("LUA::Dbh::test_reactive",3,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
    SWIG_fail_ptr("Dbh_test_reactive",1,SWIGTYPE_p_LUA__Dbh);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  arg3 = (char *)lua_tostring(L, 3);
  result = (bool)(arg1)->test_reactive(arg2,arg3);
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Dbh_test_reactive__SWIG_2(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
  char *arg2 = (char *) 0 ;
  bool result;
  
  SWIG_check_num_args("LUA::Dbh::test_reactive",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::test_reactive",1,"LUA::Dbh *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Dbh::test_reactive",2,"char *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
    SWIG_fail_ptr("Dbh_test_reactive",1,SWIGTYPE_p_LUA__Dbh);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (bool)(arg1)->test_reactive(arg2);
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Dbh_test_reactive(lua_State* L) {
  int argc;
  int argv[5]={
    1,2,3,4,5
  };
  
  argc = lua_gettop(L);
  if (argc == 2) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Dbh, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        return _wrap_Dbh_test_reactive__SWIG_2(L);
      }
    }
  }
  if (argc == 3) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Dbh, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        {
          _v = SWIG_lua_isnilstring(L,argv[2]);
        }
        if (_v) {
          return _wrap_Dbh_test_reactive__SWIG_1(L);
        }
      }
    }
  }
  if (argc == 4) {
    int _v;
    {
      void *ptr;
      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Dbh, 0)) {
        _v = 0;
      } else {
        _v = 1;
      }
    }
    if (_v) {
      {
        _v = SWIG_lua_isnilstring(L,argv[1]);
      }
      if (_v) {
        {
          _v = SWIG_lua_isnilstring(L,argv[2]);
        }
        if (_v) {
          {
            _v = SWIG_lua_isnilstring(L,argv[3]);
          }
          if (_v) {
            return _wrap_Dbh_test_reactive__SWIG_0(L);
          }
        }
      }
    }
  }
  
  SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'Dbh_test_reactive'\n"
    "  Possible C/C++ prototypes are:\n"
    "    LUA::Dbh::test_reactive(char *,char *,char *)\n"
    "    LUA::Dbh::test_reactive(char *,char *)\n"
    "    LUA::Dbh::test_reactive(char *)\n");
  lua_error(L);return 0;
}


static int _wrap_Dbh_query(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
  char *arg2 = (char *) 0 ;
  SWIGLUA_FN arg3 ;
  bool result;
  
  {
    SWIGLUA_FN default_swiglua_fn = {
      0 
    };
    arg3 = default_swiglua_fn;
  }
  SWIG_check_num_args("LUA::Dbh::query",2,3)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::query",1,"LUA::Dbh *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Dbh::query",2,"char *");
  if(lua_gettop(L)>=3 && !lua_isfunction(L,3)) SWIG_fail_arg("LUA::Dbh::query",3,"SWIGLUA_FN");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
    SWIG_fail_ptr("Dbh_query",1,SWIGTYPE_p_LUA__Dbh);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  if(lua_gettop(L)>=3){
    {
      (&arg3)->L = L;
      (&arg3)->idx = 3;
    }
  }
  result = (bool)(arg1)->query(arg2,arg3);
  lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Dbh_affected_rows(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
  int result;
  
  SWIG_check_num_args("LUA::Dbh::affected_rows",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::affected_rows",1,"LUA::Dbh *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
    SWIG_fail_ptr("Dbh_affected_rows",1,SWIGTYPE_p_LUA__Dbh);
  }
  
  result = (int)(arg1)->affected_rows();
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Dbh_last_error(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
  char *result = 0 ;
  
  SWIG_check_num_args("LUA::Dbh::last_error",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::last_error",1,"LUA::Dbh *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
    SWIG_fail_ptr("Dbh_last_error",1,SWIGTYPE_p_LUA__Dbh);
  }
  
  result = (char *)(arg1)->last_error();
  lua_pushstring(L,(const char *)result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Dbh_clear_error(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
  
  SWIG_check_num_args("LUA::Dbh::clear_error",1,1)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::clear_error",1,"LUA::Dbh *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
    SWIG_fail_ptr("Dbh_clear_error",1,SWIGTYPE_p_LUA__Dbh);
  }
  
  (arg1)->clear_error();
  
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static int _wrap_Dbh_load_extension(lua_State* L) {
  int SWIG_arg = 0;
  LUA::Dbh *arg1 = (LUA::Dbh *) 0 ;
  char *arg2 = (char *) 0 ;
  int result;
  
  SWIG_check_num_args("LUA::Dbh::load_extension",2,2)
  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("LUA::Dbh::load_extension",1,"LUA::Dbh *");
  if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("LUA::Dbh::load_extension",2,"char const *");
  
  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Dbh,0))){
    SWIG_fail_ptr("Dbh_load_extension",1,SWIGTYPE_p_LUA__Dbh);
  }
  
  arg2 = (char *)lua_tostring(L, 2);
  result = (int)(arg1)->load_extension((char const *)arg2);
  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
  return SWIG_arg;
  
  if(0) SWIG_fail;
  
fail:
  lua_error(L);
  return SWIG_arg;
}


static void swig_delete_Dbh(void *obj) {
LUA::Dbh *arg1 = (LUA::Dbh *) obj;
delete arg1;
}
static int _proxy__wrap_new_Dbh(lua_State *L) {
    assert(lua_istable(L,1));
    lua_pushcfunction(L,_wrap_new_Dbh);
    assert(!lua_isnil(L,-1));
    lua_replace(L,1); /* replace our table with real constructor */
    lua_call(L,lua_gettop(L)-1,1);
    return 1;
}
static swig_lua_attribute swig_Dbh_attributes[] = {
    {0,0,0}
};
static swig_lua_method swig_Dbh_methods[]= {
    { "release", _wrap_Dbh_release},
    { "connected", _wrap_Dbh_connected},
    { "test_reactive", _wrap_Dbh_test_reactive},
    { "query", _wrap_Dbh_query},
    { "affected_rows", _wrap_Dbh_affected_rows},
    { "last_error", _wrap_Dbh_last_error},
    { "clear_error", _wrap_Dbh_clear_error},
    { "load_extension", _wrap_Dbh_load_extension},
    {0,0}
};
static swig_lua_method swig_Dbh_meta[] = {
    {0,0}
};

static swig_lua_attribute swig_Dbh_Sf_SwigStatic_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_Dbh_Sf_SwigStatic_constants[]= {
    {0,0,0,0,0,0}
};
static swig_lua_method swig_Dbh_Sf_SwigStatic_methods[]= {
    {0,0}
};
static swig_lua_class* swig_Dbh_Sf_SwigStatic_classes[]= {
    0
};

static swig_lua_namespace swig_Dbh_Sf_SwigStatic = {
    "Dbh",
    swig_Dbh_Sf_SwigStatic_methods,
    swig_Dbh_Sf_SwigStatic_attributes,
    swig_Dbh_Sf_SwigStatic_constants,
    swig_Dbh_Sf_SwigStatic_classes,
    0
};
static swig_lua_class *swig_Dbh_bases[] = {0};
static const char *swig_Dbh_base_names[] = {0};
static swig_lua_class _wrap_class_Dbh = { "Dbh", "Dbh", &SWIGTYPE_p_LUA__Dbh,_proxy__wrap_new_Dbh, swig_delete_Dbh, swig_Dbh_methods, swig_Dbh_attributes, &swig_Dbh_Sf_SwigStatic, swig_Dbh_meta, swig_Dbh_bases, swig_Dbh_base_names };

static swig_lua_attribute swig_SwigModule_attributes[] = {
    {0,0,0}
};
static swig_lua_const_info swig_SwigModule_constants[]= {
    {SWIG_LUA_CONSTTAB_INT("S_HUP", S_HUP)},
    {SWIG_LUA_CONSTTAB_INT("S_FREE", S_FREE)},
    {SWIG_LUA_CONSTTAB_INT("S_RDLOCK", S_RDLOCK)},
    {0,0,0,0,0,0}
};
static swig_lua_method swig_SwigModule_methods[]= {
    { "setGlobalVariable", _wrap_setGlobalVariable},
    { "getGlobalVariable", _wrap_getGlobalVariable},
    { "consoleLog", _wrap_consoleLog},
    { "consoleLog2", _wrap_consoleLog2},
    { "consoleCleanLog", _wrap_consoleCleanLog},
    { "running", _wrap_running},
    { "email", _wrap_email},
    { "console_log", _wrap_console_log},
    { "console_log2", _wrap_console_log2},
    { "console_clean_log", _wrap_console_clean_log},
    { "msleep", _wrap_msleep},
    { "bridge", _wrap_bridge},
    { "hanguphook", _wrap_hanguphook},
    { "dtmf_callback", _wrap_dtmf_callback},
    {0,0}
};
static swig_lua_class* swig_SwigModule_classes[]= {
&_wrap_class_IVRMenu,
&_wrap_class_API,
&_wrap_class_input_callback_state_t,
&_wrap_class_DTMF,
&_wrap_class_Stream,
&_wrap_class_Event,
&_wrap_class_EventConsumer,
&_wrap_class_CoreSession,
&_wrap_class_Session,
&_wrap_class_Dbh,
    0
};
static swig_lua_namespace* swig_SwigModule_namespaces[] = {
    0
};

static swig_lua_namespace swig_SwigModule = {
    "freeswitch",
    swig_SwigModule_methods,
    swig_SwigModule_attributes,
    swig_SwigModule_constants,
    swig_SwigModule_classes,
    swig_SwigModule_namespaces
};
#ifdef __cplusplus
}
#endif

/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */

static void *_p_LUA__SessionTo_p_CoreSession(void *x, int *SWIGUNUSEDPARM(newmemory)) {
    return (void *)((CoreSession *)  ((LUA::Session *) x));
}
static swig_type_info _swigt__p_API = {"_p_API", "API *", 0, 0, (void*)&_wrap_class_API, 0};
static swig_type_info _swigt__p_CoreSession = {"_p_CoreSession", "CoreSession *", 0, 0, (void*)&_wrap_class_CoreSession, 0};
static swig_type_info _swigt__p_DTMF = {"_p_DTMF", "DTMF *", 0, 0, (void*)&_wrap_class_DTMF, 0};
static swig_type_info _swigt__p_Event = {"_p_Event", "Event *", 0, 0, (void*)&_wrap_class_Event, 0};
static swig_type_info _swigt__p_EventConsumer = {"_p_EventConsumer", "EventConsumer *", 0, 0, (void*)&_wrap_class_EventConsumer, 0};
static swig_type_info _swigt__p_IVRMenu = {"_p_IVRMenu", "IVRMenu *", 0, 0, (void*)&_wrap_class_IVRMenu, 0};
static swig_type_info _swigt__p_LUA__Dbh = {"_p_LUA__Dbh", "LUA::Dbh *", 0, 0, (void*)&_wrap_class_Dbh, 0};
static swig_type_info _swigt__p_LUA__Session = {"_p_LUA__Session", "LUA::Session *", 0, 0, (void*)&_wrap_class_Session, 0};
static swig_type_info _swigt__p_SWIGLUA_FN = {"_p_SWIGLUA_FN", "SWIGLUA_FN *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_Stream = {"_p_Stream", "Stream *", 0, 0, (void*)&_wrap_class_Stream, 0};
static swig_type_info _swigt__p_input_callback_state = {"_p_input_callback_state", "input_callback_state_t *|input_callback_state *", 0, 0, (void*)&_wrap_class_input_callback_state_t, 0};
static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_lua_State = {"_p_lua_State", "lua_State *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_switch_event_node_t = {"_p_p_switch_event_node_t", "switch_event_node_t **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_session_flag_t = {"_p_session_flag_t", "enum session_flag_t *|session_flag_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_call_cause_t = {"_p_switch_call_cause_t", "switch_call_cause_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_channel_state_t = {"_p_switch_channel_state_t", "switch_channel_state_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_channel_t = {"_p_switch_channel_t", "switch_channel_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_core_session_t = {"_p_switch_core_session_t", "switch_core_session_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_event_t = {"_p_switch_event_t", "switch_event_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_event_types_t = {"_p_switch_event_types_t", "switch_event_types_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_input_args_t = {"_p_switch_input_args_t", "switch_input_args_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_input_type_t = {"_p_switch_input_type_t", "switch_input_type_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_priority_t = {"_p_switch_priority_t", "switch_priority_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_queue_t = {"_p_switch_queue_t", "switch_queue_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_state_handler_table_t = {"_p_switch_state_handler_table_t", "switch_state_handler_table_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_status_t = {"_p_switch_status_t", "switch_status_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_stream_handle_t = {"_p_switch_stream_handle_t", "switch_stream_handle_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_uint32_t = {"_p_uint32_t", "uint32_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};

static swig_type_info *swig_type_initial[] = {
  &_swigt__p_API,
  &_swigt__p_CoreSession,
  &_swigt__p_DTMF,
  &_swigt__p_Event,
  &_swigt__p_EventConsumer,
  &_swigt__p_IVRMenu,
  &_swigt__p_LUA__Dbh,
  &_swigt__p_LUA__Session,
  &_swigt__p_SWIGLUA_FN,
  &_swigt__p_Stream,
  &_swigt__p_input_callback_state,
  &_swigt__p_int,
  &_swigt__p_lua_State,
  &_swigt__p_p_switch_event_node_t,
  &_swigt__p_session_flag_t,
  &_swigt__p_switch_call_cause_t,
  &_swigt__p_switch_channel_state_t,
  &_swigt__p_switch_channel_t,
  &_swigt__p_switch_core_session_t,
  &_swigt__p_switch_event_t,
  &_swigt__p_switch_event_types_t,
  &_swigt__p_switch_input_args_t,
  &_swigt__p_switch_input_type_t,
  &_swigt__p_switch_priority_t,
  &_swigt__p_switch_queue_t,
  &_swigt__p_switch_state_handler_table_t,
  &_swigt__p_switch_status_t,
  &_swigt__p_switch_stream_handle_t,
  &_swigt__p_uint32_t,
  &_swigt__p_void,
};

static swig_cast_info _swigc__p_API[] = {  {&_swigt__p_API, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_CoreSession[] = {  {&_swigt__p_CoreSession, 0, 0, 0},  {&_swigt__p_LUA__Session, _p_LUA__SessionTo_p_CoreSession, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_DTMF[] = {  {&_swigt__p_DTMF, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Event[] = {  {&_swigt__p_Event, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_EventConsumer[] = {  {&_swigt__p_EventConsumer, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_IVRMenu[] = {  {&_swigt__p_IVRMenu, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_LUA__Dbh[] = {  {&_swigt__p_LUA__Dbh, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_LUA__Session[] = {  {&_swigt__p_LUA__Session, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_SWIGLUA_FN[] = {  {&_swigt__p_SWIGLUA_FN, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Stream[] = {  {&_swigt__p_Stream, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_input_callback_state[] = {  {&_swigt__p_input_callback_state, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_int[] = {  {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lua_State[] = {  {&_swigt__p_lua_State, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_switch_event_node_t[] = {  {&_swigt__p_p_switch_event_node_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_session_flag_t[] = {  {&_swigt__p_session_flag_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_call_cause_t[] = {  {&_swigt__p_switch_call_cause_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_channel_state_t[] = {  {&_swigt__p_switch_channel_state_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_channel_t[] = {  {&_swigt__p_switch_channel_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_core_session_t[] = {  {&_swigt__p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_event_t[] = {  {&_swigt__p_switch_event_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_event_types_t[] = {  {&_swigt__p_switch_event_types_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_input_args_t[] = {  {&_swigt__p_switch_input_args_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_input_type_t[] = {  {&_swigt__p_switch_input_type_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_priority_t[] = {  {&_swigt__p_switch_priority_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_queue_t[] = {  {&_swigt__p_switch_queue_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_state_handler_table_t[] = {  {&_swigt__p_switch_state_handler_table_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_status_t[] = {  {&_swigt__p_switch_status_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_stream_handle_t[] = {  {&_swigt__p_switch_stream_handle_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_uint32_t[] = {  {&_swigt__p_uint32_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = {  {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};

static swig_cast_info *swig_cast_initial[] = {
  _swigc__p_API,
  _swigc__p_CoreSession,
  _swigc__p_DTMF,
  _swigc__p_Event,
  _swigc__p_EventConsumer,
  _swigc__p_IVRMenu,
  _swigc__p_LUA__Dbh,
  _swigc__p_LUA__Session,
  _swigc__p_SWIGLUA_FN,
  _swigc__p_Stream,
  _swigc__p_input_callback_state,
  _swigc__p_int,
  _swigc__p_lua_State,
  _swigc__p_p_switch_event_node_t,
  _swigc__p_session_flag_t,
  _swigc__p_switch_call_cause_t,
  _swigc__p_switch_channel_state_t,
  _swigc__p_switch_channel_t,
  _swigc__p_switch_core_session_t,
  _swigc__p_switch_event_t,
  _swigc__p_switch_event_types_t,
  _swigc__p_switch_input_args_t,
  _swigc__p_switch_input_type_t,
  _swigc__p_switch_priority_t,
  _swigc__p_switch_queue_t,
  _swigc__p_switch_state_handler_table_t,
  _swigc__p_switch_status_t,
  _swigc__p_switch_stream_handle_t,
  _swigc__p_uint32_t,
  _swigc__p_void,
};


/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */

/* -----------------------------------------------------------------------------
 * Type initialization:
 * This problem is tough by the requirement that no dynamic
 * memory is used. Also, since swig_type_info structures store pointers to
 * swig_cast_info structures and swig_cast_info structures store pointers back
 * to swig_type_info structures, we need some lookup code at initialization.
 * The idea is that swig generates all the structures that are needed.
 * The runtime then collects these partially filled structures.
 * The SWIG_InitializeModule function takes these initial arrays out of
 * swig_module, and does all the lookup, filling in the swig_module.types
 * array with the correct data and linking the correct swig_cast_info
 * structures together.
 *
 * The generated swig_type_info structures are assigned statically to an initial
 * array. We just loop through that array, and handle each type individually.
 * First we lookup if this type has been already loaded, and if so, use the
 * loaded structure instead of the generated one. Then we have to fill in the
 * cast linked list. The cast data is initially stored in something like a
 * two-dimensional array. Each row corresponds to a type (there are the same
 * number of rows as there are in the swig_type_initial array). Each entry in
 * a column is one of the swig_cast_info structures for that type.
 * The cast_initial array is actually an array of arrays, because each row has
 * a variable number of columns. So to actually build the cast linked list,
 * we find the array of casts associated with the type, and loop through it
 * adding the casts to the list. The one last trick we need to do is making
 * sure the type pointer in the swig_cast_info struct is correct.
 *
 * First off, we lookup the cast->type name to see if it is already loaded.
 * There are three cases to handle:
 *  1) If the cast->type has already been loaded AND the type we are adding
 *     casting info to has not been loaded (it is in this module), THEN we
 *     replace the cast->type pointer with the type pointer that has already
 *     been loaded.
 *  2) If BOTH types (the one we are adding casting info to, and the
 *     cast->type) are loaded, THEN the cast info has already been loaded by
 *     the previous module so we just ignore it.
 *  3) Finally, if cast->type has not already been loaded, then we add that
 *     swig_cast_info to the linked list (because the cast->type) pointer will
 *     be correct.
 * ----------------------------------------------------------------------------- */

#ifdef __cplusplus
extern "C" {
#if 0
} /* c-mode */
#endif
#endif

#if 0
#define SWIGRUNTIME_DEBUG
#endif


SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
  size_t i;
  swig_module_info *module_head, *iter;
  int found, init;

  /* check to see if the circular list has been setup, if not, set it up */
  if (swig_module.next==0) {
    /* Initialize the swig_module */
    swig_module.type_initial = swig_type_initial;
    swig_module.cast_initial = swig_cast_initial;
    swig_module.next = &swig_module;
    init = 1;
  } else {
    init = 0;
  }

  /* Try and load any already created modules */
  module_head = SWIG_GetModule(clientdata);
  if (!module_head) {
    /* This is the first module loaded for this interpreter */
    /* so set the swig module into the interpreter */
    SWIG_SetModule(clientdata, &swig_module);
    module_head = &swig_module;
  } else {
    /* the interpreter has loaded a SWIG module, but has it loaded this one? */
    found=0;
    iter=module_head;
    do {
      if (iter==&swig_module) {
        found=1;
        break;
      }
      iter=iter->next;
    } while (iter!= module_head);

    /* if the is found in the list, then all is done and we may leave */
    if (found) return;
    /* otherwise we must add out module into the list */
    swig_module.next = module_head->next;
    module_head->next = &swig_module;
  }

  /* When multiple interpreters are used, a module could have already been initialized in
     a different interpreter, but not yet have a pointer in this interpreter.
     In this case, we do not want to continue adding types... everything should be
     set up already */
  if (init == 0) return;

  /* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
  printf("SWIG_InitializeModule: size %d\n", swig_module.size);
#endif
  for (i = 0; i < swig_module.size; ++i) {
    swig_type_info *type = 0;
    swig_type_info *ret;
    swig_cast_info *cast;

#ifdef SWIGRUNTIME_DEBUG
    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
#endif

    /* if there is another module already loaded */
    if (swig_module.next != &swig_module) {
      type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
    }
    if (type) {
      /* Overwrite clientdata field */
#ifdef SWIGRUNTIME_DEBUG
      printf("SWIG_InitializeModule: found type %s\n", type->name);
#endif
      if (swig_module.type_initial[i]->clientdata) {
	type->clientdata = swig_module.type_initial[i]->clientdata;
#ifdef SWIGRUNTIME_DEBUG
      printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
#endif
      }
    } else {
      type = swig_module.type_initial[i];
    }

    /* Insert casting types */
    cast = swig_module.cast_initial[i];
    while (cast->type) {

      /* Don't need to add information already in the list */
      ret = 0;
#ifdef SWIGRUNTIME_DEBUG
      printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
#endif
      if (swig_module.next != &swig_module) {
        ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
#ifdef SWIGRUNTIME_DEBUG
	if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
#endif
      }
      if (ret) {
	if (type == swig_module.type_initial[i]) {
#ifdef SWIGRUNTIME_DEBUG
	  printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
#endif
	  cast->type = ret;
	  ret = 0;
	} else {
	  /* Check for casting already in the list */
	  swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
#ifdef SWIGRUNTIME_DEBUG
	  if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
#endif
	  if (!ocast) ret = 0;
	}
      }

      if (!ret) {
#ifdef SWIGRUNTIME_DEBUG
	printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
#endif
        if (type->cast) {
          type->cast->prev = cast;
          cast->next = type->cast;
        }
        type->cast = cast;
      }
      cast++;
    }
    /* Set entry in modules->types array equal to the type */
    swig_module.types[i] = type;
  }
  swig_module.types[i] = 0;

#ifdef SWIGRUNTIME_DEBUG
  printf("**** SWIG_InitializeModule: Cast List ******\n");
  for (i = 0; i < swig_module.size; ++i) {
    int j = 0;
    swig_cast_info *cast = swig_module.cast_initial[i];
    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
    while (cast->type) {
      printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
      cast++;
      ++j;
    }
  printf("---- Total casts: %d\n",j);
  }
  printf("**** SWIG_InitializeModule: Cast List ******\n");
#endif
}

/* This function will propagate the clientdata field of type to
* any new swig_type_info structures that have been added into the list
* of equivalent types.  It is like calling
* SWIG_TypeClientData(type, clientdata) a second time.
*/
SWIGRUNTIME void
SWIG_PropagateClientData(void) {
  size_t i;
  swig_cast_info *equiv;
  static int init_run = 0;

  if (init_run) return;
  init_run = 1;

  for (i = 0; i < swig_module.size; i++) {
    if (swig_module.types[i]->clientdata) {
      equiv = swig_module.types[i]->cast;
      while (equiv) {
        if (!equiv->converter) {
          if (equiv->type && !equiv->type->clientdata)
            SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
        }
        equiv = equiv->next;
      }
    }
  }
}

#ifdef __cplusplus
#if 0
{ /* c-mode */
#endif
}
#endif



/* Forward declaration of where the user's %init{} gets inserted */
void SWIG_init_user(lua_State* L );
    
#ifdef __cplusplus
extern "C" {
#endif
/* this is the initialization function
  added at the very end of the code
  the function is always called SWIG_init, but an earlier #define will rename it
*/
#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
LUALIB_API int SWIG_init(lua_State* L)
#else
SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
#endif
{
#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */
  int i;
  int globalRegister = 0;
  /* start with global table */
  lua_pushglobaltable (L);
  /* SWIG's internal initialisation */
  SWIG_InitializeModule((void*)L);
  SWIG_PropagateClientData();
#endif

#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) || defined(SWIG_LUA_ELUA_EMULATE)
  /* add a global fn */
  SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);
  SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_class_equal);
#endif

#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
  /* set up base class pointers (the hierarchy) */
  for (i = 0; swig_types[i]; i++){
    if (swig_types[i]->clientdata){
      SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata));
    }
  }
#ifdef SWIG_LUA_MODULE_GLOBAL
  globalRegister = 1;
#endif


#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
  SWIG_Lua_namespace_register(L,&swig_SwigModule, globalRegister);
#endif

#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
  for (i = 0; swig_types[i]; i++){
    if (swig_types[i]->clientdata){
      SWIG_Lua_elua_class_register_instance(L,(swig_lua_class*)(swig_types[i]->clientdata));
    }
  }
#endif

#if defined(SWIG_LUA_ELUA_EMULATE)
  lua_newtable(L);
  SWIG_Lua_elua_emulate_register(L,swig_SwigModule.ns_methods);
  SWIG_Lua_elua_emulate_register_clear(L);
  if(globalRegister) {
    lua_pushstring(L,swig_SwigModule.name);
    lua_pushvalue(L,-2);
    lua_rawset(L,-4);
  }
#endif

#endif

#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
  /* invoke user-specific initialization */
  SWIG_init_user(L);
  /* end module */
  /* Note: We do not clean up the stack here (Lua will do this for us). At this
     point, we have the globals table and out module table on the stack. Returning
     one value makes the module table the result of the require command. */
  return 1;
#else
  return 0;
#endif
}

#ifdef __cplusplus
}
#endif


const char* SWIG_LUACODE=
  "";

void SWIG_init_user(lua_State* L)
{
  /* exec Lua code if applicable */
  SWIG_Lua_dostring(L,SWIG_LUACODE);
}

#include "mod_lua_extra.c"
