[Freeswitch-svn] [commit] r8211 - in freeswitch/trunk/src/mod/languages/mod_lua: . lua

Freeswitch SVN brian at freeswitch.org
Mon Apr 28 13:34:00 EDT 2008


Author: brian
Date: Mon Apr 28 13:33:58 2008
New Revision: 8211

Added:
   freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
Modified:
   freeswitch/trunk/src/mod/languages/mod_lua/lua/Makefile
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lauxlib.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lauxlib.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lbaselib.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lcode.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lcode.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ldblib.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ldo.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ldo.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ldump.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lfunc.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lfunc.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lgc.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lgc.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/linit.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/liolib.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/llex.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/llex.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/llimits.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lmathlib.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lmem.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lmem.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/loadlib.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lopcodes.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lopcodes.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/loslib.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lparser.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lparser.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lstate.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lstate.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lstring.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lstring.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lstrlib.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ltable.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ltable.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ltablib.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ltm.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/ltm.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/luac.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/luaconf.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lualib.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lvm.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lvm.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lzio.c
   freeswitch/trunk/src/mod/languages/mod_lua/lua/lzio.h
   freeswitch/trunk/src/mod/languages/mod_lua/lua/print.c

Log:
update

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/Makefile	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/Makefile	Mon Apr 28 13:33:58 2008
@@ -20,7 +20,7 @@
 
 # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
 
-PLATS= aix ansi bsd generic linux macosx mingw posix solaris
+PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
 
 LUA_A=	liblua.a
 CORE_O=	lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
@@ -77,10 +77,11 @@
 # convenience targets for popular platforms
 
 none:
-	@echo "Please choose a platform: $(PLATS)"
+	@echo "Please choose a platform:"
+	@echo "   $(PLATS)"
 
 aix:
-	$(MAKE) all CC="xlc" CFLAGS="-O2" MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"
+	$(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"
 
 ansi:
 	$(MAKE) all MYCFLAGS=-DLUA_ANSI
@@ -88,6 +89,9 @@
 bsd:
 	$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
 
+freebsd:
+	$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
+
 generic:
 	$(MAKE) all MYCFLAGS=
 
@@ -95,14 +99,15 @@
 	$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
 
 macosx:
-	$(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
-# use this on Mac OS X 10.4
-#	$(MAKE) all MYCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" MYLIBS="-lreadline"
+	$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
+# use this on Mac OS X 10.3-
+#	$(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
 
 mingw:
 	$(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
 	"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
 	"MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
+	$(MAKE) "LUAC_T=luac.exe" luac.exe
 
 posix:
 	$(MAKE) all MYCFLAGS=-DLUA_USE_POSIX
@@ -121,15 +126,15 @@
 lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h
 lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h
 lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
-  lzio.h lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h \
-  ldo.h lgc.h
+  lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \
+  ltable.h
 ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h
 ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \
-  llex.h lzio.h lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h \
-  ltm.h ldo.h lfunc.h lstring.h lgc.h lvm.h
+  llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \
+  lfunc.h lstring.h lgc.h ltable.h lvm.h
 ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
-  lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h ltable.h \
-  lstring.h lundump.h lvm.h
+  lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \
+  ltable.h lundump.h lvm.h
 ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \
   lzio.h lmem.h lundump.h
 lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \
@@ -139,19 +144,18 @@
 linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h
 liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h
 llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \
-  lzio.h lmem.h llex.h lparser.h ltable.h lstring.h lgc.h
+  lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h
 lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
 lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
   ltm.h lzio.h lmem.h ldo.h
-loadlib.o: loadlib.c lauxlib.h lua.h luaconf.h lobject.h llimits.h \
-  lualib.h
+loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
 lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
   ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
 lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
 loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h
 lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
-  lzio.h lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h \
-  ldo.h lfunc.h lstring.h lgc.h
+  lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \
+  lfunc.h lstring.h lgc.h ltable.h
 lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
   ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h
 lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.c,v 2.53 2006/01/10 12:50:00 roberto Exp $
+** $Id: lapi.c,v 2.55.1.3 2008/01/03 15:20:39 roberto Exp $
 ** Lua API
 ** See Copyright Notice in lua.h
 */
@@ -32,7 +32,7 @@
 
 
 const char lua_ident[] =
-  "$Lua: " LUA_VERSION " " LUA_COPYRIGHT " $\n"
+  "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n"
   "$Authors: " LUA_AUTHORS " $\n"
   "$URL: www.lua.org $\n";
 
@@ -123,6 +123,11 @@
 }
 
 
+LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
+  to->nCcalls = from->nCcalls;
+}
+
+
 LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
   lua_CFunction old;
   lua_lock(L);
@@ -199,6 +204,9 @@
 LUA_API void lua_replace (lua_State *L, int idx) {
   StkId o;
   lua_lock(L);
+  /* explicit test for incompatible code */
+  if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci)
+    luaG_runerror(L, "no calling environment");
   api_checknelems(L, 1);
   o = index2adr(L, idx);
   api_checkvalidindex(L, o);
@@ -746,7 +754,7 @@
       res = 0;
       break;
   }
-  luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
+  if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
   L->top--;
   lua_unlock(L);
   return res;

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.h,v 2.2 2005/04/25 19:24:10 roberto Exp $
+** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Auxiliary functions from Lua API
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lauxlib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lauxlib.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lauxlib.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.c,v 1.158 2006/01/16 12:42:21 roberto Exp $
+** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -123,11 +123,17 @@
 
 LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
   void *p = lua_touserdata(L, ud);
-  lua_getfield(L, LUA_REGISTRYINDEX, tname);  /* get correct metatable */
-  if (p == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2))
-    luaL_typerror(L, ud, tname);
-  lua_pop(L, 2);  /* remove both metatables */
-  return p;
+  if (p != NULL) {  /* value is a userdata? */
+    if (lua_getmetatable(L, ud)) {  /* does it have a metatable? */
+      lua_getfield(L, LUA_REGISTRYINDEX, tname);  /* get correct metatable */
+      if (lua_rawequal(L, -1, -2)) {  /* does it have the correct mt? */
+        lua_pop(L, 2);  /* remove both metatables */
+        return p;
+      }
+    }
+  }
+  luaL_typerror(L, ud, tname);  /* else error */
+  return NULL;  /* to avoid warnings */
 }
 
 
@@ -238,7 +244,7 @@
   if (libname) {
     int size = libsize(l);
     /* check whether lib already exists */
-    luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size);
+    luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
     lua_getfield(L, -1, libname);  /* get _LOADED[libname] */
     if (!lua_istable(L, -1)) {  /* not found? */
       lua_pop(L, 1);  /* remove previous result */
@@ -529,7 +535,7 @@
     return "\n";
   }
   if (feof(lf->f)) return NULL;
-  *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f);
+  *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
   return (*size > 0) ? lf->buff : NULL;
 }
 
@@ -564,9 +570,8 @@
     while ((c = getc(lf.f)) != EOF && c != '\n') ;  /* skip first line */
     if (c == '\n') c = getc(lf.f);
   }
-  if (c == LUA_SIGNATURE[0] && lf.f != stdin) {  /* binary file? */
-    fclose(lf.f);
-    lf.f = fopen(filename, "rb");  /* reopen in binary mode */
+  if (c == LUA_SIGNATURE[0] && filename) {  /* binary file? */
+    lf.f = freopen(filename, "rb", lf.f);  /* reopen in binary mode */
     if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
     /* skip eventual `#!...' */
    while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
@@ -575,7 +580,7 @@
   ungetc(c, lf.f);
   status = lua_load(L, getF, &lf, lua_tostring(L, -1));
   readstatus = ferror(lf.f);
-  if (lf.f != stdin) fclose(lf.f);  /* close file (even in case of errors) */
+  if (filename) fclose(lf.f);  /* close file (even in case of errors) */
   if (readstatus) {
     lua_settop(L, fnameindex);  /* ignore results from `lua_load' */
     return errfile(L, "read", fnameindex);

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lauxlib.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lauxlib.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lauxlib.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lauxlib.h,v 1.87 2005/12/29 15:32:11 roberto Exp $
+** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Auxiliary functions for building Lua libraries
 ** See Copyright Notice in lua.h
 */
@@ -108,9 +108,11 @@
 
 #define luaL_typename(L,i)	lua_typename(L, lua_type(L,(i)))
 
-#define luaL_dofile(L, fn)	(luaL_loadfile(L, fn) || lua_pcall(L, 0, 0, 0))
+#define luaL_dofile(L, fn) \
+	(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
 
-#define luaL_dostring(L, s)	(luaL_loadstring(L, s) || lua_pcall(L, 0, 0, 0))
+#define luaL_dostring(L, s) \
+	(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
 
 #define luaL_getmetatable(L,n)	(lua_getfield(L, LUA_REGISTRYINDEX, (n)))
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lbaselib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lbaselib.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lbaselib.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lbaselib.c,v 1.189 2006/01/18 11:49:12 roberto Exp $
+** $Id: lbaselib.c,v 1.191.1.4 2008/01/20 13:53:22 roberto Exp $
 ** Basic library
 ** See Copyright Notice in lua.h
 */
@@ -114,11 +114,11 @@
 }
 
 
-static void getfunc (lua_State *L) {
+static void getfunc (lua_State *L, int opt) {
   if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
   else {
     lua_Debug ar;
-    int level = luaL_optint(L, 1, 1);
+    int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1);
     luaL_argcheck(L, level >= 0, 1, "level must be non-negative");
     if (lua_getstack(L, level, &ar) == 0)
       luaL_argerror(L, 1, "invalid level");
@@ -131,7 +131,7 @@
 
 
 static int luaB_getfenv (lua_State *L) {
-  getfunc(L);
+  getfunc(L, 1);
   if (lua_iscfunction(L, -1))  /* is a C function? */
     lua_pushvalue(L, LUA_GLOBALSINDEX);  /* return the thread's global env. */
   else
@@ -142,7 +142,7 @@
 
 static int luaB_setfenv (lua_State *L) {
   luaL_checktype(L, 2, LUA_TTABLE);
-  getfunc(L);
+  getfunc(L, 0);
   lua_pushvalue(L, 2);
   if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
     /* change environment of current thread */
@@ -477,15 +477,52 @@
 ** =======================================================
 */
 
+#define CO_RUN	0	/* running */
+#define CO_SUS	1	/* suspended */
+#define CO_NOR	2	/* 'normal' (it resumed another coroutine) */
+#define CO_DEAD	3
+
+static const char *const statnames[] =
+    {"running", "suspended", "normal", "dead"};
+
+static int costatus (lua_State *L, lua_State *co) {
+  if (L == co) return CO_RUN;
+  switch (lua_status(co)) {
+    case LUA_YIELD:
+      return CO_SUS;
+    case 0: {
+      lua_Debug ar;
+      if (lua_getstack(co, 0, &ar) > 0)  /* does it have frames? */
+        return CO_NOR;  /* it is running */
+      else if (lua_gettop(co) == 0)
+          return CO_DEAD;
+      else
+        return CO_SUS;  /* initial state */
+    }
+    default:  /* some error occured */
+      return CO_DEAD;
+  }
+}
+
+
+static int luaB_costatus (lua_State *L) {
+  lua_State *co = lua_tothread(L, 1);
+  luaL_argcheck(L, co, 1, "coroutine expected");
+  lua_pushstring(L, statnames[costatus(L, co)]);
+  return 1;
+}
+
+
 static int auxresume (lua_State *L, lua_State *co, int narg) {
-  int status;
+  int status = costatus(L, co);
   if (!lua_checkstack(co, narg))
     luaL_error(L, "too many arguments to resume");
-  if (lua_status(co) == 0 && lua_gettop(co) == 0) {
-    lua_pushliteral(L, "cannot resume dead coroutine");
+  if (status != CO_SUS) {
+    lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
     return -1;  /* error flag */
   }
   lua_xmove(L, co, narg);
+  lua_setlevel(L, co);
   status = lua_resume(co, narg);
   if (status == 0 || status == LUA_YIELD) {
     int nres = lua_gettop(co);
@@ -556,39 +593,10 @@
 }
 
 
-static int luaB_costatus (lua_State *L) {
-  lua_State *co = lua_tothread(L, 1);
-  luaL_argcheck(L, co, 1, "coroutine expected");
-  if (L == co) lua_pushliteral(L, "running");
-  else {
-    switch (lua_status(co)) {
-      case LUA_YIELD:
-        lua_pushliteral(L, "suspended");
-        break;
-      case 0: {
-        lua_Debug ar;
-        if (lua_getstack(co, 0, &ar) > 0)  /* does it have frames? */
-          lua_pushliteral(L, "normal");  /* it is running */
-        else if (lua_gettop(co) == 0)
-            lua_pushliteral(L, "dead");
-        else
-          lua_pushliteral(L, "suspended");  /* initial state */
-        break;
-      }
-      default:  /* some error occured */
-        lua_pushliteral(L, "dead");
-        break;
-    }
-  }
-  return 1;
-}
-
-
 static int luaB_corunning (lua_State *L) {
   if (lua_pushthread(L))
-    return 0;  /* main thread is not a coroutine */
-  else
-    return 1;
+    lua_pushnil(L);  /* main thread is not a coroutine */
+  return 1;
 }
 
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lcode.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lcode.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lcode.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lcode.c,v 2.24 2005/12/22 16:19:56 roberto Exp $
+** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 */
@@ -35,15 +35,20 @@
 void luaK_nil (FuncState *fs, int from, int n) {
   Instruction *previous;
   if (fs->pc > fs->lasttarget) {  /* no jumps to current position? */
-    if (fs->pc == 0)  /* function start? */
-      return;  /* positions are already clean */
-    if (GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) {
-      int pfrom = GETARG_A(*previous);
-      int pto = GETARG_B(*previous);
-      if (pfrom <= from && from <= pto+1) {  /* can connect both? */
-        if (from+n-1 > pto)
-          SETARG_B(*previous, from+n-1);
-        return;
+    if (fs->pc == 0) {  /* function start? */
+      if (from >= fs->nactvar)
+        return;  /* positions are already clean */
+    }
+    else {
+      previous = &fs->f->code[fs->pc-1];
+      if (GET_OPCODE(*previous) == OP_LOADNIL) {
+        int pfrom = GETARG_A(*previous);
+        int pto = GETARG_B(*previous);
+        if (pfrom <= from && from <= pto+1) {  /* can connect both? */
+          if (from+n-1 > pto)
+            SETARG_B(*previous, from+n-1);
+          return;
+        }
       }
     }
   }
@@ -657,10 +662,16 @@
   if (constfolding(op, e1, e2))
     return;
   else {
-    int o1 = luaK_exp2RK(fs, e1);
     int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
-    freeexp(fs, e2);
-    freeexp(fs, e1);
+    int o1 = luaK_exp2RK(fs, e1);
+    if (o1 > o2) {
+      freeexp(fs, e1);
+      freeexp(fs, e2);
+    }
+    else {
+      freeexp(fs, e2);
+      freeexp(fs, e1);
+    }
     e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2);
     e1->k = VRELOCABLE;
   }
@@ -688,7 +699,7 @@
   e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
   switch (op) {
     case OPR_MINUS: {
-      if (e->k == VK)
+      if (!isnumeral(e))
         luaK_exp2anyreg(fs, e);  /* cannot operate on non-numeric constants */
       codearith(fs, OP_UNM, e, &e2);
       break;
@@ -718,10 +729,15 @@
       luaK_exp2nextreg(fs, v);  /* operand must be on the `stack' */
       break;
     }
-    default: {
+    case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
+    case OPR_MOD: case OPR_POW: {
       if (!isnumeral(v)) luaK_exp2RK(fs, v);
       break;
     }
+    default: {
+      luaK_exp2RK(fs, v);
+      break;
+    }
   }
 }
 
@@ -731,17 +747,15 @@
     case OPR_AND: {
       lua_assert(e1->t == NO_JUMP);  /* list must be closed */
       luaK_dischargevars(fs, e2);
-      luaK_concat(fs, &e1->f, e2->f);
-      e1->k = e2->k; e1->u.s.info = e2->u.s.info;
-      e1->u.s.aux = e2->u.s.aux; e1->t = e2->t;
+      luaK_concat(fs, &e2->f, e1->f);
+      *e1 = *e2;
       break;
     }
     case OPR_OR: {
       lua_assert(e1->f == NO_JUMP);  /* list must be closed */
       luaK_dischargevars(fs, e2);
-      luaK_concat(fs, &e1->t, e2->t);
-      e1->k = e2->k; e1->u.s.info = e2->u.s.info;
-      e1->u.s.aux = e2->u.s.aux; e1->f = e2->f;
+      luaK_concat(fs, &e2->t, e1->t);
+      *e1 = *e2;
       break;
     }
     case OPR_CONCAT: {
@@ -750,7 +764,7 @@
         lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1);
         freeexp(fs, e1);
         SETARG_B(getcode(fs, e2), e1->u.s.info);
-        e1->k = e2->k; e1->u.s.info = e2->u.s.info;
+        e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info;
       }
       else {
         luaK_exp2nextreg(fs, e2);  /* operand must be on the 'stack' */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lcode.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lcode.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lcode.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lcode.h,v 1.47 2005/11/08 19:44:31 roberto Exp $
+** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 */
@@ -32,7 +32,6 @@
   OPR_NOBINOPR
 } BinOpr;
 
-#define binopistest(op)	((op) >= OPR_NE)
 
 typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ldblib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ldblib.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ldblib.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ldblib.c,v 1.104 2005/12/29 15:32:11 roberto Exp $
+** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $
 ** Interface from Lua to its debug API
 ** See Copyright Notice in lua.h
 */
@@ -255,24 +255,25 @@
 
 
 static int db_sethook (lua_State *L) {
-  int arg;
+  int arg, mask, count;
+  lua_Hook func;
   lua_State *L1 = getthread(L, &arg);
   if (lua_isnoneornil(L, arg+1)) {
     lua_settop(L, arg+1);
-    lua_sethook(L1, NULL, 0, 0);  /* turn off hooks */
+    func = NULL; mask = 0; count = 0;  /* turn off hooks */
   }
   else {
     const char *smask = luaL_checkstring(L, arg+2);
-    int count = luaL_optint(L, arg+3, 0);
     luaL_checktype(L, arg+1, LUA_TFUNCTION);
-    lua_sethook(L1, hookf, makemask(smask, count), count);
+    count = luaL_optint(L, arg+3, 0);
+    func = hookf; mask = makemask(smask, count);
   }
-  gethooktable(L1);
-  lua_pushlightuserdata(L1, L1);
+  gethooktable(L);
+  lua_pushlightuserdata(L, L1);
   lua_pushvalue(L, arg+1);
-  lua_xmove(L, L1, 1);
-  lua_rawset(L1, -3);  /* set new hook */
-  lua_pop(L1, 1);  /* remove hook table */
+  lua_rawset(L, -3);  /* set new hook */
+  lua_pop(L, 1);  /* remove hook table */
+  lua_sethook(L1, func, mask, count);  /* set hooks */
   return 0;
 }
 
@@ -286,11 +287,10 @@
   if (hook != NULL && hook != hookf)  /* external hook? */
     lua_pushliteral(L, "external hook");
   else {
-    gethooktable(L1);
-    lua_pushlightuserdata(L1, L1);
-    lua_rawget(L1, -2);   /* get hook */
-    lua_remove(L1, -2);  /* remove hook table */
-    lua_xmove(L1, L, 1);
+    gethooktable(L);
+    lua_pushlightuserdata(L, L1);
+    lua_rawget(L, -2);   /* get hook */
+    lua_remove(L, -2);  /* remove hook table */
   }
   lua_pushstring(L, unmakemask(mask, buff));
   lua_pushinteger(L, lua_gethookcount(L1));

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.c,v 2.29 2005/12/22 16:19:56 roberto Exp $
+** $Id: ldebug.c,v 2.29.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Debug Interface
 ** See Copyright Notice in lua.h
 */
@@ -432,14 +432,16 @@
         break;
       }
       case OP_CLOSURE: {
-        int nup;
+        int nup, j;
         check(b < pt->sizep);
         nup = pt->p[b]->nups;
         check(pc + nup < pt->sizecode);
-        for (; nup>0; nup--) {
-          OpCode op1 = GET_OPCODE(pt->code[pc+nup]);
+        for (j = 1; j <= nup; j++) {
+          OpCode op1 = GET_OPCODE(pt->code[pc + j]);
           check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
         }
+        if (reg != NO_REG)  /* tracing? */
+          pc += nup;  /* do not 'execute' these pseudo-instructions */
         break;
       }
       case OP_VARARG: {
@@ -561,8 +563,8 @@
 
 
 void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
-  if (ttisstring(p1)) p1 = p2;
-  lua_assert(!ttisstring(p1));
+  if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
+  lua_assert(!ttisstring(p1) && !ttisnumber(p1));
   luaG_typeerror(L, p1, "concatenate");
 }
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.h,v 2.3 2005/04/25 19:24:10 roberto Exp $
+** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Auxiliary functions from Debug Interface module
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ldo.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ldo.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ldo.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.c,v 2.37 2005/12/22 16:19:56 roberto Exp $
+** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -83,7 +83,7 @@
   L->base = L->ci->base;
   luaF_close(L, L->base);  /* close eventual pending closures */
   luaD_seterrorobj(L, status, L->base);
-  L->nCcalls = 0;
+  L->nCcalls = L->baseCcalls;
   L->allowhook = 1;
   restore_stack_limit(L);
   L->errfunc = 0;
@@ -332,7 +332,7 @@
   ptrdiff_t fr = savestack(L, firstResult);  /* next call may change stack */
   luaD_callhook(L, LUA_HOOKRET, -1);
   if (f_isLua(L->ci)) {  /* Lua function? */
-    while (L->ci->tailcalls--)  /* call hook for eventual tail calls */
+    while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
       luaD_callhook(L, LUA_HOOKTAILRET, -1);
   }
   return restorestack(L, fr);
@@ -383,12 +383,14 @@
 static void resume (lua_State *L, void *ud) {
   StkId firstArg = cast(StkId, ud);
   CallInfo *ci = L->ci;
-  if (L->status != LUA_YIELD) {  /* start coroutine */
+  if (L->status == 0) {  /* start coroutine? */
     lua_assert(ci == L->base_ci && firstArg > L->base);
     if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA)
       return;
   }
   else {  /* resuming from previous yield */
+    lua_assert(L->status == LUA_YIELD);
+    L->status = 0;
     if (!f_isLua(ci)) {  /* `common' yield? */
       /* finish interrupted execution of `OP_CALL' */
       lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL ||
@@ -399,7 +401,6 @@
     else  /* yielded inside a hook: just continue its execution */
       L->base = L->ci->base;
   }
-  L->status = 0;
   luaV_execute(L, cast_int(L->ci - L->base_ci));
 }
 
@@ -416,22 +417,24 @@
 LUA_API int lua_resume (lua_State *L, int nargs) {
   int status;
   lua_lock(L);
-  if (L->status != LUA_YIELD) {
-    if (L->status != 0)
-      return resume_error(L, "cannot resume dead coroutine");
-    else if (L->ci != L->base_ci)
+  if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
       return resume_error(L, "cannot resume non-suspended coroutine");
-  }
+  if (L->nCcalls >= LUAI_MAXCCALLS)
+    return resume_error(L, "C stack overflow");
   luai_userstateresume(L, nargs);
-  lua_assert(L->errfunc == 0 && L->nCcalls == 0);
+  lua_assert(L->errfunc == 0);
+  L->baseCcalls = ++L->nCcalls;
   status = luaD_rawrunprotected(L, resume, L->top - nargs);
   if (status != 0) {  /* error? */
     L->status = cast_byte(status);  /* mark thread as `dead' */
     luaD_seterrorobj(L, status, L->top);
     L->ci->top = L->top;
   }
-  else
+  else {
+    lua_assert(L->nCcalls == L->baseCcalls);
     status = L->status;
+  }
+  --L->nCcalls;
   lua_unlock(L);
   return status;
 }
@@ -440,7 +443,7 @@
 LUA_API int lua_yield (lua_State *L, int nresults) {
   luai_userstateyield(L, nresults);
   lua_lock(L);
-  if (L->nCcalls > 0)
+  if (L->nCcalls > L->baseCcalls)
     luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
   L->base = L->top - nresults;  /* protect stack slots below */
   L->status = LUA_YIELD;

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ldo.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ldo.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ldo.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.h,v 2.7 2005/08/24 16:15:49 roberto Exp $
+** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ldump.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ldump.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ldump.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ldump.c,v 1.15 2006/02/16 15:53:49 lhf Exp $
+** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
 ** save precompiled Lua chunks
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lfunc.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lfunc.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lfunc.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lfunc.c,v 2.12 2005/12/22 16:19:56 roberto Exp $
+** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 */
@@ -55,7 +55,7 @@
   GCObject **pp = &L->openupval;
   UpVal *p;
   UpVal *uv;
-  while ((p = ngcotouv(*pp)) != NULL && p->v >= level) {
+  while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) {
     lua_assert(p->v != &p->u.value);
     if (p->v == level) {  /* found a corresponding upvalue? */
       if (isdead(g, obj2gco(p)))  /* is it dead? */
@@ -96,7 +96,7 @@
 void luaF_close (lua_State *L, StkId level) {
   UpVal *uv;
   global_State *g = G(L);
-  while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) {
+  while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
     GCObject *o = obj2gco(uv);
     lua_assert(!isblack(o) && uv->v != &uv->u.value);
     L->openupval = uv->next;  /* remove from `open' list */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lfunc.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lfunc.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lfunc.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lfunc.h,v 2.4 2005/04/25 19:24:10 roberto Exp $
+** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lgc.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lgc.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lgc.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.c,v 2.37 2005/12/22 16:19:56 roberto Exp $
+** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
@@ -320,8 +320,10 @@
 }
 
 
-static void propagateall (global_State *g) {
-  while (g->gray) propagatemark(g);
+static size_t propagateall (global_State *g) {
+  size_t m = 0;
+  while (g->gray) m += propagatemark(g);
+  return m;
 }
 
 
@@ -540,7 +542,7 @@
   propagateall(g);
   udsize = luaC_separateudata(L, 0);  /* separate userdata to be finalized */
   marktmu(g);  /* mark `preserved' userdata */
-  propagateall(g);  /* remark, to propagate `preserveness' */
+  udsize += propagateall(g);  /* remark, to propagate `preserveness' */
   cleartable(g->weak);  /* remove collected objects from weak tables */
   /* flip current white */
   g->currentwhite = cast_byte(otherwhite(g));
@@ -590,6 +592,8 @@
     case GCSfinalize: {
       if (g->tmudata) {
         GCTM(L);
+        if (g->estimate > GCFINALIZECOST)
+          g->estimate -= GCFINALIZECOST;
         return GCFINALIZECOST;
       }
       else {

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lgc.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lgc.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lgc.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.h,v 2.15 2005/08/24 16:15:49 roberto Exp $
+** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/linit.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/linit.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/linit.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: linit.c,v 1.14 2005/12/29 15:32:11 roberto Exp $
+** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Initialization of libraries for lua.c
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/liolib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/liolib.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/liolib.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: liolib.c,v 2.72 2006/01/28 12:59:13 roberto Exp $
+** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 */
@@ -51,7 +51,7 @@
 }
 
 
-#define topfile(L)	((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
+#define tofilep(L)	((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
 
 
 static int io_type (lua_State *L) {
@@ -70,7 +70,7 @@
 
 
 static FILE *tofile (lua_State *L) {
-  FILE **f = topfile(L);
+  FILE **f = tofilep(L);
   if (*f == NULL)
     luaL_error(L, "attempt to use a closed file");
   return *f;
@@ -93,21 +93,33 @@
 
 
 /*
-** this function has a separated environment, which defines the
-** correct __close for 'popen' files
+** function to (not) close the standard files stdin, stdout, and stderr
+*/
+static int io_noclose (lua_State *L) {
+  lua_pushnil(L);
+  lua_pushliteral(L, "cannot close standard file");
+  return 2;
+}
+
+
+/*
+** function to close 'popen' files
 */
 static int io_pclose (lua_State *L) {
-  FILE **p = topfile(L);
+  FILE **p = tofilep(L);
   int ok = lua_pclose(L, *p);
-  if (ok) *p = NULL;
+  *p = NULL;
   return pushresult(L, ok, NULL);
 }
 
 
+/*
+** function to close regular files
+*/
 static int io_fclose (lua_State *L) {
-  FILE **p = topfile(L);
+  FILE **p = tofilep(L);
   int ok = (fclose(*p) == 0);
-  if (ok) *p = NULL;
+  *p = NULL;
   return pushresult(L, ok, NULL);
 }
 
@@ -128,18 +140,18 @@
 
 
 static int io_gc (lua_State *L) {
-  FILE *f = *topfile(L);
-  /* ignore closed files and standard files */
-  if (f != NULL && f != stdin && f != stdout && f != stderr)
+  FILE *f = *tofilep(L);
+  /* ignore closed files */
+  if (f != NULL)
     aux_close(L);
   return 0;
 }
 
 
 static int io_tostring (lua_State *L) {
-  FILE *f = *topfile(L);
+  FILE *f = *tofilep(L);
   if (f == NULL)
-    lua_pushstring(L, "file (closed)");
+    lua_pushliteral(L, "file (closed)");
   else
     lua_pushfstring(L, "file (%p)", f);
   return 1;
@@ -155,6 +167,10 @@
 }
 
 
+/*
+** this function has a separated environment, which defines the
+** correct __close for 'popen' files
+*/
 static int io_popen (lua_State *L) {
   const char *filename = luaL_checkstring(L, 1);
   const char *mode = luaL_optstring(L, 2, "r");
@@ -280,7 +296,7 @@
     char *p = luaL_prepbuffer(&b);
     if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) {  /* eof? */
       luaL_pushresult(&b);  /* close buffer */
-      return (lua_strlen(L, -1) > 0);  /* check whether read something */
+      return (lua_objlen(L, -1) > 0);  /* check whether read something */
     }
     l = strlen(p);
     if (l == 0 || p[l-1] != '\n')
@@ -308,7 +324,7 @@
     n -= nr;  /* still have to read `n' chars */
   } while (n > 0 && nr == rlen);  /* until end of count or eof */
   luaL_pushresult(&b);  /* close buffer */
-  return (n == 0 || lua_strlen(L, -1) > 0);
+  return (n == 0 || lua_objlen(L, -1) > 0);
 }
 
 
@@ -502,31 +518,36 @@
     lua_pushvalue(L, -1);
     lua_rawseti(L, LUA_ENVIRONINDEX, k);
   }
-  lua_setfield(L, -2, fname);
+  lua_pushvalue(L, -2);  /* copy environment */
+  lua_setfenv(L, -2);  /* set it */
+  lua_setfield(L, -3, fname);
+}
+
+
+static void newfenv (lua_State *L, lua_CFunction cls) {
+  lua_createtable(L, 0, 1);
+  lua_pushcfunction(L, cls);
+  lua_setfield(L, -2, "__close");
 }
 
 
 LUALIB_API int luaopen_io (lua_State *L) {
   createmeta(L);
   /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
-  lua_createtable(L, 2, 1);
+  newfenv(L, io_fclose);
   lua_replace(L, LUA_ENVIRONINDEX);
   /* open library */
   luaL_register(L, LUA_IOLIBNAME, iolib);
   /* create (and set) default files */
+  newfenv(L, io_noclose);  /* close function for default files */
   createstdfile(L, stdin, IO_INPUT, "stdin");
   createstdfile(L, stdout, IO_OUTPUT, "stdout");
   createstdfile(L, stderr, 0, "stderr");
-  /* create environment for 'popen' */
+  lua_pop(L, 1);  /* pop environment for default files */
   lua_getfield(L, -1, "popen");
-  lua_createtable(L, 0, 1);
-  lua_pushcfunction(L, io_pclose);
-  lua_setfield(L, -2, "__close");
-  lua_setfenv(L, -2);
+  newfenv(L, io_pclose);  /* create environment for 'popen' */
+  lua_setfenv(L, -2);  /* set fenv for 'popen' */
   lua_pop(L, 1);  /* pop 'popen' */
-  /* set default close function */
-  lua_pushcfunction(L, io_fclose);
-  lua_setfield(L, LUA_ENVIRONINDEX, "__close");
   return 1;
 }
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/llex.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/llex.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/llex.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: llex.c,v 2.19 2006/02/06 18:28:16 roberto Exp $
+** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 */
@@ -20,6 +20,7 @@
 #include "lparser.h"
 #include "lstate.h"
 #include "lstring.h"
+#include "ltable.h"
 #include "lzio.h"
 
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/llex.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/llex.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/llex.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: llex.h,v 1.57 2005/12/07 15:43:05 roberto Exp $
+** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lexical Analyzer
 ** See Copyright Notice in lua.h
 */
@@ -68,9 +68,9 @@
 
 
 LUAI_FUNC void luaX_init (lua_State *L);
-LUAI_FUNC void luaX_setinput (lua_State *L, LexState *LS, ZIO *z,
+LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,
                               TString *source);
-LUAI_FUNC TString *luaX_newstring (LexState *LS, const char *str, size_t l);
+LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);
 LUAI_FUNC void luaX_next (LexState *ls);
 LUAI_FUNC void luaX_lookahead (LexState *ls);
 LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token);

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/llimits.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/llimits.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/llimits.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: llimits.h,v 1.69 2005/12/27 17:12:00 roberto Exp $
+** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Limits, basic types, and some other `installation-dependent' definitions
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lmathlib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lmathlib.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lmathlib.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lmathlib.c,v 1.67 2005/08/26 17:36:32 roberto Exp $
+** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Standard mathematical library
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lmem.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lmem.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lmem.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lmem.c,v 1.70 2005/12/26 13:35:47 roberto Exp $
+** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Interface to Memory Manager
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lmem.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lmem.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lmem.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lmem.h,v 1.31 2005/04/25 19:24:10 roberto Exp $
+** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Interface to Memory Manager
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/loadlib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/loadlib.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/loadlib.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: loadlib.c,v 1.51 2005/12/29 15:32:11 roberto Exp $
+** $Id: loadlib.c,v 1.52.1.2 2007/12/28 14:58:43 roberto Exp $
 ** Dynamic library loader for Lua
 ** See Copyright Notice in lua.h
 **
@@ -16,15 +16,11 @@
 #define loadlib_c
 #define LUA_LIB
 
-#include "lauxlib.h"
-#include "lobject.h"
 #include "lua.h"
-#include "lualib.h"
 
+#include "lauxlib.h"
+#include "lualib.h"
 
-/* environment variables that hold the search path for packages */
-#define LUA_PATH	"LUA_PATH"
-#define LUA_CPATH	"LUA_CPATH"
 
 /* prefix for open functions in C libraries */
 #define LUA_POF		"luaopen_"
@@ -102,7 +98,7 @@
   char buff[MAX_PATH + 1];
   char *lb;
   DWORD nsize = sizeof(buff)/sizeof(char);
-  DWORD n = GetModuleFileName(NULL, buff, nsize);
+  DWORD n = GetModuleFileNameA(NULL, buff, nsize);
   if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL)
     luaL_error(L, "unable to get ModuleFileName");
   else {
@@ -116,7 +112,7 @@
 static void pusherror (lua_State *L) {
   int error = GetLastError();
   char buffer[128];
-  if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
+  if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
       NULL, error, 0, buffer, sizeof(buffer), NULL))
     lua_pushstring(L, buffer);
   else
@@ -129,7 +125,7 @@
 
 
 static void *ll_load (lua_State *L, const char *path) {
-  HINSTANCE lib = LoadLibrary(path);
+  HINSTANCE lib = LoadLibraryA(path);
   if (lib == NULL) pusherror(L);
   return lib;
 }
@@ -360,15 +356,16 @@
   path = lua_tostring(L, -1);
   if (path == NULL)
     luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
-  lua_pushstring(L, "");  /* error accumulator */
+  lua_pushliteral(L, "");  /* error accumulator */
   while ((path = pushnexttemplate(L, path)) != NULL) {
     const char *filename;
     filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
+    lua_remove(L, -2);  /* remove path template */
     if (readable(filename))  /* does file exist and is readable? */
       return filename;  /* return that file name */
-    lua_pop(L, 2);  /* remove path template and file name */ 
-    luaO_pushfstring(L, "\n\tno file " LUA_QS, filename);
-    lua_concat(L, 2);
+    lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
+    lua_remove(L, -2);  /* remove file name */
+    lua_concat(L, 2);  /* add entry to possible error message */
   }
   return NULL;  /* not found */
 }
@@ -427,8 +424,8 @@
   funcname = mkfuncname(L, name);
   if ((stat = ll_loadfunc(L, filename, funcname)) != 0) {
     if (stat != ERRFUNC) loaderror(L, filename);  /* real error */
-    luaO_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
-                        name, filename);
+    lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
+                       name, filename);
     return 1;  /* function not found */
   }
   return 1;
@@ -442,7 +439,7 @@
     luaL_error(L, LUA_QL("package.preload") " must be a table");
   lua_getfield(L, -1, name);
   if (lua_isnil(L, -1))  /* not found? */
-    luaO_pushfstring(L, "\n\tno field package.preload['%s']", name);
+    lua_pushfstring(L, "\n\tno field package.preload['%s']", name);
   return 1;
 }
 
@@ -466,7 +463,7 @@
   lua_getfield(L, LUA_ENVIRONINDEX, "loaders");
   if (!lua_istable(L, -1))
     luaL_error(L, LUA_QL("package.loaders") " must be a table");
-  lua_pushstring(L, "");  /* error message accumulator */
+  lua_pushliteral(L, "");  /* error message accumulator */
   for (i=1; ; i++) {
     lua_rawgeti(L, -2, i);  /* get a loader */
     if (lua_isnil(L, -1))
@@ -650,8 +647,8 @@
   setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT);  /* set field `path' */
   setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */
   /* store config information */
-  lua_pushstring(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n"
-                    LUA_EXECDIR "\n" LUA_IGMARK);
+  lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n"
+                     LUA_EXECDIR "\n" LUA_IGMARK);
   lua_setfield(L, -2, "config");
   /* set field `loaded' */
   luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2);

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lobject.c,v 2.22 2006/02/10 17:43:52 roberto Exp $
+** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Some generic functions over Lua objects
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lobject.h,v 2.20 2006/01/18 11:37:34 roberto Exp $
+** $Id: lobject.h,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Type definitions for Lua objects
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lopcodes.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lopcodes.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lopcodes.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lopcodes.c,v 1.37 2005/11/08 19:45:36 roberto Exp $
+** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
 ** See Copyright Notice in lua.h
 */
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lopcodes.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lopcodes.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lopcodes.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lopcodes.h,v 1.124 2005/12/02 18:42:08 roberto Exp $
+** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Opcodes for Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -197,8 +197,8 @@
 			if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
 OP_FORPREP,/*	A sBx	R(A)-=R(A+2); pc+=sBx				*/
 
-OP_TFORLOOP,/*	A C	R(A+3), ... ,R(A+3+C) := R(A)(R(A+1), R(A+2)); 
-                        if R(A+3) ~= nil then { pc++; R(A+2)=R(A+3); }	*/ 
+OP_TFORLOOP,/*	A C	R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); 
+                        if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++	*/ 
 OP_SETLIST,/*	A B C	R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B	*/
 
 OP_CLOSE,/*	A 	close all variables in the stack up to (>=) R(A)*/

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/loslib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/loslib.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/loslib.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: loslib.c,v 1.17 2006/01/27 13:54:31 roberto Exp $
+** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $
 ** Standard Operating System library
 ** See Copyright Notice in lua.h
 */
@@ -28,10 +28,7 @@
   }
   else {
     lua_pushnil(L);
-    if (filename)
-      lua_pushfstring(L, "%s: %s", filename, strerror(en));
-    else
-      lua_pushfstring(L, "%s", strerror(en));
+    lua_pushfstring(L, "%s: %s", filename, strerror(en));
     lua_pushinteger(L, en);
     return 3;
   }
@@ -126,8 +123,7 @@
 
 static int os_date (lua_State *L) {
   const char *s = luaL_optstring(L, 1, "%c");
-  time_t t = lua_isnoneornil(L, 2) ? time(NULL) :
-                                     (time_t)luaL_checknumber(L, 2);
+  time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));
   struct tm *stm;
   if (*s == '!') {  /* UTC? */
     stm = gmtime(&t);
@@ -150,11 +146,22 @@
     setboolfield(L, "isdst", stm->tm_isdst);
   }
   else {
-    char b[256];
-    if (strftime(b, sizeof(b), s, stm))
-      lua_pushstring(L, b);
-    else
-      return luaL_error(L, LUA_QL("date") " format too long");
+    char cc[3];
+    luaL_Buffer b;
+    cc[0] = '%'; cc[2] = '\0';
+    luaL_buffinit(L, &b);
+    for (; *s; s++) {
+      if (*s != '%' || *(s + 1) == '\0')  /* no conversion specifier? */
+        luaL_addchar(&b, *s);
+      else {
+        size_t reslen;
+        char buff[200];  /* should be big enough for any conversion result */
+        cc[1] = *(++s);
+        reslen = strftime(buff, sizeof(buff), cc, stm);
+        luaL_addlstring(&b, buff, reslen);
+      }
+    }
+    luaL_pushresult(&b);
   }
   return 1;
 }
@@ -199,9 +206,8 @@
                       LC_NUMERIC, LC_TIME};
   static const char *const catnames[] = {"all", "collate", "ctype", "monetary",
      "numeric", "time", NULL};
-  const char *l = lua_tostring(L, 1);
+  const char *l = luaL_optstring(L, 1, NULL);
   int op = luaL_checkoption(L, 2, "all", catnames);
-  luaL_argcheck(L, l || lua_isnoneornil(L, 1), 1, "string expected");
   lua_pushstring(L, setlocale(cat[op], l));
   return 1;
 }
@@ -209,7 +215,6 @@
 
 static int os_exit (lua_State *L) {
   exit(luaL_optint(L, 1, EXIT_SUCCESS));
-  return 0;  /* to avoid warnings */
 }
 
 static const luaL_Reg syslib[] = {

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lparser.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lparser.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lparser.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lparser.c,v 2.40 2005/12/22 16:19:56 roberto Exp $
+** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Lua Parser
 ** See Copyright Notice in lua.h
 */
@@ -23,7 +23,7 @@
 #include "lparser.h"
 #include "lstate.h"
 #include "lstring.h"
-
+#include "ltable.h"
 
 
 
@@ -299,7 +299,8 @@
   removevars(fs->ls, bl->nactvar);
   if (bl->upval)
     luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
-  lua_assert(!bl->isbreakable || !bl->upval);  /* loops have no body */
+  /* a block either controls scope or breaks (never both) */
+  lua_assert(!bl->isbreakable || !bl->upval);
   lua_assert(bl->nactvar == fs->nactvar);
   fs->freereg = fs->nactvar;  /* free registers */
   luaK_patchtohere(fs, bl->breaklist);
@@ -444,6 +445,7 @@
   FuncState *fs = ls->fs;
   int reg = ls->fs->freereg;
   expdesc key, val;
+  int rkkey;
   if (ls->t.token == TK_NAME) {
     luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
     checkname(ls, &key);
@@ -452,10 +454,9 @@
     yindex(ls, &key);
   cc->nh++;
   checknext(ls, '=');
-  luaK_exp2RK(fs, &key);
+  rkkey = luaK_exp2RK(fs, &key);
   expr(ls, &val);
-  luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, luaK_exp2RK(fs, &key),
-                                                 luaK_exp2RK(fs, &val));
+  luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val));
   fs->freereg = reg;  /* free registers */
 }
 
@@ -488,7 +489,7 @@
 
 static void listfield (LexState *ls, struct ConsControl *cc) {
   expr(ls, &cc->v);
-  luaY_checklimit(ls->fs, cc->na, MAXARG_Bx, "items in a constructor");
+  luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
   cc->na++;
   cc->tostore++;
 }
@@ -937,6 +938,8 @@
     primaryexp(ls, &nv.v);
     if (nv.v.k == VLOCAL)
       check_conflict(ls, lh, &nv.v);
+    luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
+                    "variables in assignment");
     assignment(ls, &nv, nvars+1);
   }
   else {  /* assignment -> `=' explist1 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lparser.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lparser.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lparser.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lparser.h,v 1.56 2005/10/03 14:02:40 roberto Exp $
+** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lua Parser
 ** See Copyright Notice in lua.h
 */
@@ -9,7 +9,6 @@
 
 #include "llimits.h"
 #include "lobject.h"
-#include "ltable.h"
 #include "lzio.h"
 
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lstate.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lstate.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lstate.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lstate.c,v 2.35 2005/10/06 20:46:25 roberto Exp $
+** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
 ** Global State
 ** See Copyright Notice in lua.h
 */
@@ -93,7 +93,7 @@
   resethookcount(L);
   L->openupval = NULL;
   L->size_ci = 0;
-  L->nCcalls = 0;
+  L->nCcalls = L->baseCcalls = 0;
   L->status = 0;
   L->base_ci = L->ci = NULL;
   L->savedpc = NULL;
@@ -198,7 +198,6 @@
 
 LUA_API void lua_close (lua_State *L) {
   L = G(L)->mainthread;  /* only the main thread can be closed */
-  luai_userstateclose(L);
   lua_lock(L);
   luaF_close(L, L->stack);  /* close all upvalues for this thread */
   luaC_separateudata(L, 1);  /* separate udata that have GC metamethods */
@@ -206,9 +205,10 @@
   do {  /* repeat until no more errors */
     L->ci = L->base_ci;
     L->base = L->top = L->ci->base;
-    L->nCcalls = 0;
+    L->nCcalls = L->baseCcalls = 0;
   } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
   lua_assert(G(L)->tmudata == NULL);
+  luai_userstateclose(L);
   close_state(L);
 }
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lstate.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lstate.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lstate.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lstate.h,v 2.24 2006/02/06 18:27:59 roberto Exp $
+** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
 ** Global State
 ** See Copyright Notice in lua.h
 */
@@ -112,6 +112,7 @@
   int stacksize;
   int size_ci;  /* size of array `base_ci' */
   unsigned short nCcalls;  /* number of nested C calls */
+  unsigned short baseCcalls;  /* nested C calls when resuming coroutine */
   lu_byte hookmask;
   lu_byte allowhook;
   int basehookcount;

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lstring.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lstring.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lstring.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lstring.c,v 2.8 2005/12/22 16:19:56 roberto Exp $
+** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
 ** String table (keeps all strings handled by Lua)
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lstring.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lstring.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lstring.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lstring.h,v 1.43 2005/04/25 19:24:10 roberto Exp $
+** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
 ** String table (keep all strings handled by Lua)
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lstrlib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lstrlib.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lstrlib.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lstrlib.c,v 1.130 2005/12/29 15:32:11 roberto Exp $
+** $Id: lstrlib.c,v 1.132.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Standard library for string operations and pattern-matching
 ** See Copyright Notice in lua.h
 */
@@ -629,10 +629,6 @@
       lua_gettable(L, 3);
       break;
     }
-    default: {
-      luaL_argerror(L, 3, "string/function/table expected"); 
-      return;
-    }
   }
   if (!lua_toboolean(L, -1)) {  /* nil or false? */
     lua_pop(L, 1);
@@ -648,11 +644,15 @@
   size_t srcl;
   const char *src = luaL_checklstring(L, 1, &srcl);
   const char *p = luaL_checkstring(L, 2);
+  int  tr = lua_type(L, 3);
   int max_s = luaL_optint(L, 4, srcl+1);
   int anchor = (*p == '^') ? (p++, 1) : 0;
   int n = 0;
   MatchState ms;
   luaL_Buffer b;
+  luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
+                   tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
+                      "string/function/table expected");
   luaL_buffinit(L, &b);
   ms.L = L;
   ms.src_init = src;
@@ -703,6 +703,10 @@
         luaL_addchar(b, *s);
         break;
       }
+      case '\r': {
+        luaL_addlstring(b, "\\r", 2);
+        break;
+      }
       case '\0': {
         luaL_addlstring(b, "\\000", 4);
         break;
@@ -719,7 +723,7 @@
 
 static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
   const char *p = strfrmt;
-  while (strchr(FLAGS, *p)) p++;  /* skip flags */
+  while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++;  /* skip flags */
   if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
     luaL_error(L, "invalid format (repeated flags)");
   if (isdigit(uchar(*p))) p++;  /* skip width */
@@ -805,7 +809,8 @@
           }
         }
         default: {  /* also treat cases `pnLlh' */
-          return luaL_error(L, "invalid option to " LUA_QL("format"));
+          return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
+                               LUA_QL("format"), *(strfrmt - 1));
         }
       }
       luaL_addlstring(&b, buff, strlen(buff));

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ltable.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ltable.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ltable.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp $
+** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 */
@@ -84,8 +84,8 @@
 static Node *hashnum (const Table *t, lua_Number n) {
   unsigned int a[numints];
   int i;
-  n += 1;  /* normalize number (avoid -0) */
-  lua_assert(sizeof(a) <= sizeof(n));
+  if (luai_numeq(n, 0))  /* avoid problems with -0 */
+    return gnode(t, 0);
   memcpy(a, &n, sizeof(a));
   for (i = 1; i < numints; i++) a[0] += a[i];
   return hashmod(t, a[0]);

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ltable.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ltable.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ltable.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ltable.h,v 2.10 2006/01/10 13:13:06 roberto Exp $
+** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ltablib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ltablib.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ltablib.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ltablib.c,v 1.38 2005/10/23 17:38:15 roberto Exp $
+** $Id: ltablib.c,v 1.38.1.2 2007/12/28 15:32:23 roberto Exp $
 ** Library for Table Manipulation
 ** See Copyright Notice in lua.h
 */
@@ -118,7 +118,8 @@
 static int tremove (lua_State *L) {
   int e = aux_getn(L, 1);
   int pos = luaL_optint(L, 2, e);
-  if (e == 0) return 0;  /* table is `empty' */
+  if (!(1 <= pos && pos <= e))  /* position is outside bounds? */
+   return 0;  /* nothing to remove */
   luaL_setn(L, 1, e - 1);  /* t.n = n-1 */
   lua_rawgeti(L, 1, pos);  /* result = t[pos] */
   for ( ;pos<e; pos++) {

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ltm.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ltm.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ltm.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ltm.c,v 2.8 2006/01/10 12:50:00 roberto Exp $
+** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Tag methods
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ltm.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ltm.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ltm.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: ltm.h,v 2.6 2005/06/06 13:30:25 roberto Exp $
+** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Tag methods
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lua.c,v 1.157 2005/12/29 16:23:32 roberto Exp $
+** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $
 ** Lua stand-alone interpreter
 ** See Copyright Notice in lua.h
 */
@@ -74,6 +74,8 @@
 
 
 static int traceback (lua_State *L) {
+  if (!lua_isstring(L, 1))  /* 'message' not a string? */
+    return 1;  /* keep it intact */
   lua_getfield(L, LUA_GLOBALSINDEX, "debug");
   if (!lua_istable(L, -1)) {
     lua_pop(L, 1);
@@ -107,7 +109,7 @@
 
 
 static void print_version (void) {
-  l_message(NULL, LUA_VERSION "  " LUA_COPYRIGHT);
+  l_message(NULL, LUA_RELEASE "  " LUA_COPYRIGHT);
 }
 
 
@@ -144,7 +146,7 @@
 static int dolibrary (lua_State *L, const char *name) {
   lua_getglobal(L, "require");
   lua_pushstring(L, name);
-  return report(L, lua_pcall(L, 1, 0, 0));
+  return report(L, docall(L, 1, 1));
 }
 
 
@@ -252,17 +254,30 @@
 }
 
 
+/* check that argument has no extra characters at the end */
+#define notail(x)	{if ((x)[2] != '\0') return -1;}
+
+
 static int collectargs (char **argv, int *pi, int *pv, int *pe) {
   int i;
   for (i = 1; argv[i] != NULL; i++) {
     if (argv[i][0] != '-')  /* not an option? */
         return i;
     switch (argv[i][1]) {  /* option */
-      case '-': return (argv[i+1] != NULL ? i+1 : 0);
-      case '\0': return i;
-      case 'i': *pi = 1;  /* go through */
-      case 'v': *pv = 1; break;
-      case 'e': *pe = 1;  /* go through */
+      case '-':
+        notail(argv[i]);
+        return (argv[i+1] != NULL ? i+1 : 0);
+      case '\0':
+        return i;
+      case 'i':
+        notail(argv[i]);
+        *pi = 1;  /* go through */
+      case 'v':
+        notail(argv[i]);
+        *pv = 1;
+        break;
+      case 'e':
+        *pe = 1;  /* go through */
       case 'l':
         if (argv[i][2] == '\0') {
           i++;
@@ -306,12 +321,12 @@
 
 
 static int handle_luainit (lua_State *L) {
-  const char *init = getenv("LUA_INIT");
+  const char *init = getenv(LUA_INIT);
   if (init == NULL) return 0;  /* status OK */
   else if (init[0] == '@')
     return dofile(L, init+1);
   else
-    return dostring(L, init, "=LUA_INIT");
+    return dostring(L, init, "=" LUA_INIT);
 }
 
 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lua.h,v 1.216 2006/01/10 12:50:13 roberto Exp $
+** $Id: lua.h,v 1.218.1.4 2008/01/03 15:41:15 roberto Exp $
 ** Lua - An Extensible Extension Language
 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
 ** See Copyright Notice at the end of this file
@@ -17,8 +17,9 @@
 
 
 #define LUA_VERSION	"Lua 5.1"
+#define LUA_RELEASE	"Lua 5.1.3"
 #define LUA_VERSION_NUM	501
-#define LUA_COPYRIGHT	"Copyright (C) 1994-2006 Lua.org, PUC-Rio"
+#define LUA_COPYRIGHT	"Copyright (C) 1994-2008 Lua.org, PUC-Rio"
 #define LUA_AUTHORS 	"R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
 
 
@@ -293,6 +294,9 @@
 #define lua_Chunkwriter		lua_Writer
 
 
+/* hack */
+LUA_API void lua_setlevel	(lua_State *from, lua_State *to);
+
 
 /*
 ** {======================================================================
@@ -358,7 +362,7 @@
 
 
 /******************************************************************************
-* Copyright (C) 1994-2006 Lua.org, PUC-Rio.  All rights reserved.
+* Copyright (C) 1994-2008 Lua.org, PUC-Rio.  All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/luac.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/luac.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/luac.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: luac.c,v 1.52 2005/11/11 14:03:13 lhf Exp $
+** $Id: luac.c,v 1.54 2006/06/02 17:37:11 lhf Exp $
 ** Lua compiler (saves bytecodes to files; also list bytecodes)
 ** See Copyright Notice in lua.h
 */
@@ -70,6 +70,7 @@
 static int doargs(int argc, char* argv[])
 {
  int i;
+ int version=0;
  if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0];
  for (i=1; i<argc; i++)
  {
@@ -78,6 +79,7 @@
   else if (IS("--"))			/* end of options; skip it */
   {
    ++i;
+   if (version) ++version;
    break;
   }
   else if (IS("-"))			/* end of options; use stdin */
@@ -95,10 +97,7 @@
   else if (IS("-s"))			/* strip debug information */
    stripping=1;
   else if (IS("-v"))			/* show version */
-  {
-   printf("%s  %s\n",LUA_VERSION,LUA_COPYRIGHT);
-   if (argc==2) exit(EXIT_SUCCESS);
-  }
+   ++version;
   else					/* unknown option */
    usage(argv[i]);
  }
@@ -107,12 +106,17 @@
   dumping=0;
   argv[--i]=Output;
  }
+ if (version)
+ {
+  printf("%s  %s\n",LUA_RELEASE,LUA_COPYRIGHT);
+  if (version==argc-1) exit(EXIT_SUCCESS);
+ }
  return i;
 }
 
 #define toproto(L,i) (clvalue(L->top+(i))->l.p)
 
-static Proto* combine(lua_State* L, int n)
+static const Proto* combine(lua_State* L, int n)
 {
  if (n==1)
   return toproto(L,-1);
@@ -156,7 +160,7 @@
  struct Smain* s = (struct Smain*)lua_touserdata(L, 1);
  int argc=s->argc;
  char** argv=s->argv;
- Proto* f;
+ const Proto* f;
  int i;
  if (!lua_checkstack(L,argc)) fatal("too many input files");
  for (i=0; i<argc; i++)

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/luaconf.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/luaconf.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/luaconf.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: luaconf.h,v 1.81 2006/02/10 17:44:06 roberto Exp $
+** $Id: luaconf.h,v 1.82.1.6 2008/01/18 17:07:48 roberto Exp $
 ** Configuration file for Lua
 ** See Copyright Notice in lua.h
 */
@@ -60,6 +60,18 @@
 
 
 /*
+@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
+@* Lua check to set its paths.
+@@ LUA_INIT is the name of the environment variable that Lua
+@* checks for initialization code.
+** CHANGE them if you want different names.
+*/
+#define LUA_PATH        "LUA_PATH"
+#define LUA_CPATH       "LUA_CPATH"
+#define LUA_INIT	"LUA_INIT"
+
+
+/*
 @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
 @* Lua libraries.
 @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
@@ -348,7 +360,7 @@
 /*
 @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
 @* behavior.
-** CHANGE it to undefined as soon as you replace to 'luaL_registry'
+** CHANGE it to undefined as soon as you replace to 'luaL_register'
 ** your uses of 'luaL_openlib'
 */
 #define LUA_COMPAT_OPENLIB
@@ -430,7 +442,8 @@
 ** functions. This limit is arbitrary; its only purpose is to stop C
 ** functions to consume unlimited stack space.
 */
-#define LUAI_MAXCSTACK	2048
+#define LUAI_MCS_AUX	((int)(INT_MAX / (4*sizeof(LUA_NUMBER))))
+#define LUAI_MAXCSTACK	(LUAI_MCS_AUX > SHRT_MAX ? SHRT_MAX : LUAI_MCS_AUX)
 
 
 
@@ -543,11 +556,25 @@
 /* On a Pentium, resort to a trick */
 #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
     (defined(__i386) || defined (_M_IX86) || defined(__i386__))
+
+/* On a Microsoft compiler, use assembler */
+#if defined(_MSC_VER)
+
+#define lua_number2int(i,d)   __asm fld d   __asm fistp i
+#define lua_number2integer(i,n)		lua_number2int(i, n)
+
+/* the next trick should work on any Pentium, but sometimes clashes
+   with a DirectX idiosyncrasy */
+#else
+
 union luai_Cast { double l_d; long l_l; };
 #define lua_number2int(i,d) \
   { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
 #define lua_number2integer(i,n)		lua_number2int(i, n)
 
+#endif
+
+
 /* this option always works, but may be slow */
 #else
 #define lua_number2int(i,d)	((i)=(int)(d))
@@ -640,7 +667,7 @@
 */
 #if defined(LUA_USE_POPEN)
 
-#define lua_popen(L,c,m)	((void)L, popen(c,m))
+#define lua_popen(L,c,m)	((void)L, fflush(NULL), popen(c,m))
 #define lua_pclose(L,file)	((void)L, (pclose(file) != -1))
 
 #elif defined(LUA_WIN)

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lualib.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lualib.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lualib.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lualib.h,v 1.36 2005/12/27 17:12:00 roberto Exp $
+** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lua standard libraries
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lundump.c,v 1.60 2006/02/16 15:53:49 lhf Exp $
+** $Id: lundump.c,v 2.7.1.2 2008/01/18 16:39:11 roberto Exp $
 ** load precompiled Lua chunks
 ** See Copyright Notice in lua.h
 */
@@ -29,6 +29,7 @@
 
 #ifdef LUAC_TRUST_BINARIES
 #define IF(c,s)
+#define error(S,s)
 #else
 #define IF(c,s)		if (c) error(S,s)
 
@@ -47,6 +48,7 @@
 static void LoadBlock(LoadState* S, void* b, size_t size)
 {
  size_t r=luaZ_read(S->Z,b,size);
+ UNUSED(r);
  IF (r!=0, "unexpected end");
 }
 
@@ -122,7 +124,7 @@
 	setsvalue2n(S->L,o,LoadString(S));
 	break;
    default:
-	IF (1, "bad constant");
+	error(S,"bad constant");
 	break;
   }
  }

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lundump.h,v 1.40 2005/11/11 14:03:13 lhf Exp $
+** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
 ** load precompiled Lua chunks
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lvm.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lvm.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lvm.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.c,v 2.62 2006/01/23 19:51:43 roberto Exp $
+** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -61,11 +61,9 @@
   lu_byte mask = L->hookmask;
   const Instruction *oldpc = L->savedpc;
   L->savedpc = pc;
-  if (mask > LUA_MASKLINE) {  /* instruction-hook set? */
-    if (L->hookcount == 0) {
-      resethookcount(L);
-      luaD_callhook(L, LUA_HOOKCOUNT, -1);
-    }
+  if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
+    resethookcount(L);
+    luaD_callhook(L, LUA_HOOKCOUNT, -1);
   }
   if (mask & LUA_MASKLINE) {
     Proto *p = ci_func(L->ci)->l.p;
@@ -165,7 +163,7 @@
   const TValue *tm = luaT_gettmbyobj(L, p1, event);  /* try first operand */
   if (ttisnil(tm))
     tm = luaT_gettmbyobj(L, p2, event);  /* try second operand */
-  if (!ttisfunction(tm)) return 0;
+  if (ttisnil(tm)) return 0;
   callTMres(L, res, tm, p1, p2);
   return 1;
 }
@@ -281,10 +279,12 @@
   do {
     StkId top = L->base + last + 1;
     int n = 2;  /* number of elements handled in this pass (at least 2) */
-    if (!tostring(L, top-2) || !tostring(L, top-1)) {
+    if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
       if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
         luaG_concaterror(L, top-2, top-1);
-    } else if (tsvalue(top-1)->len > 0) {  /* if len=0, do nothing */
+    } else if (tsvalue(top-1)->len == 0)  /* second op is empty? */
+      (void)tostring(L, top - 2);  /* result is first op (as string) */
+    else {
       /* at least two string values; get as many as possible */
       size_t tl = tsvalue(top-1)->len;
       char *buffer;
@@ -376,6 +376,7 @@
   TValue *k;
   const Instruction *pc;
  reentry:  /* entry point */
+  lua_assert(isLua(L->ci));
   pc = L->savedpc;
   cl = &clvalue(L->ci->func)->l;
   base = L->base;

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lvm.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lvm.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lvm.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.h,v 2.5 2005/08/22 18:54:49 roberto Exp $
+** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lzio.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lzio.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lzio.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lzio.c,v 1.31 2005/06/03 20:15:29 roberto Exp $
+** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
 ** a generic input stream interface
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lzio.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lzio.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lzio.h	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: lzio.h,v 1.21 2005/05/17 19:49:15 roberto Exp $
+** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
 ** Buffered streams
 ** See Copyright Notice in lua.h
 */

Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/print.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/print.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/print.c	Mon Apr 28 13:33:58 2008
@@ -1,5 +1,5 @@
 /*
-** $Id: print.c,v 1.54 2006/01/11 22:49:27 lhf Exp $
+** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $
 ** print bytecodes
 ** See Copyright Notice in lua.h
 */
@@ -20,15 +20,18 @@
 #define Sizeof(x)	((int)sizeof(x))
 #define VOID(p)		((const void*)(p))
 
-static void PrintString(const Proto* f, int n)
+static void PrintString(const TString* ts)
 {
- const char* s=svalue(&f->k[n]);
+ const char* s=getstr(ts);
+ size_t i,n=ts->tsv.len;
  putchar('"');
- for (; *s; s++)
+ for (i=0; i<n; i++)
  {
-  switch (*s)
+  int c=s[i];
+  switch (c)
   {
    case '"': printf("\\\""); break;
+   case '\\': printf("\\\\"); break;
    case '\a': printf("\\a"); break;
    case '\b': printf("\\b"); break;
    case '\f': printf("\\f"); break;
@@ -36,10 +39,10 @@
    case '\r': printf("\\r"); break;
    case '\t': printf("\\t"); break;
    case '\v': printf("\\v"); break;
-   default:	if (isprint((unsigned char)*s))
-   			printf("%c",*s);
+   default:	if (isprint((unsigned char)c))
+   			putchar(c);
 		else
-			printf("\\%03u",(unsigned char)*s);
+			printf("\\%03u",(unsigned char)c);
   }
  }
  putchar('"');
@@ -60,7 +63,7 @@
 	printf(LUA_NUMBER_FMT,nvalue(o));
 	break;
   case LUA_TSTRING:
-	PrintString(f,i);
+	PrintString(rawtsvalue(o));
 	break;
   default:				/* cannot happen */
 	printf("? type=%d",ttype(o));

Added: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp	Mon Apr 28 13:33:58 2008
@@ -0,0 +1,4771 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.35
+ * 
+ * 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. 
+ * ----------------------------------------------------------------------------- */
+
+
+#ifdef __cplusplus
+template<typename T> class SwigValueWrapper {
+    T *tt;
+public:
+    SwigValueWrapper() : tt(0) { }
+    SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { }
+    SwigValueWrapper(const T& t) : tt(new T(t)) { }
+    ~SwigValueWrapper() { delete tt; } 
+    SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; }
+    operator T&() const { return *tt; }
+    T *operator&() { return tt; }
+private:
+    SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+};
+
+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 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 CAPI 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 is strictly necessary, ie, if you have problems
+  with your compiler or so.
+*/
+
+#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 and 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 swig versions, you usually write code as:
+
+     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
+       // success code
+     } else {
+       //fail code
+     }
+
+   Now you can be more explicit as:
+
+    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
+    if (SWIG_IsOK(res)) {
+      // success code
+    } else {
+      // fail code
+    }
+
+   that seems to be the same, 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
+   requires also to SWIG_ConvertPtr to return new result values, 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
+#  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 not equal, 1 if equal
+*/
+SWIGRUNTIME int
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+  int equiv = 0;
+  const char* te = tb + strlen(tb);
+  const char* ne = nb;
+  while (!equiv && *ne) {
+    for (nb = ne; *ne; ++ne) {
+      if (*ne == '|') break;
+    }
+    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+    if (*ne) ++ne;
+  }
+  return equiv;
+}
+
+/*
+  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_TypeCompare(const char *nb, const char *tb) {
+  int equiv = 0;
+  const char* te = tb + strlen(tb);
+  const char* ne = nb;
+  while (!equiv && *ne) {
+    for (nb = ne; *ne; ++ne) {
+      if (*ne == '|') break;
+    }
+    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+    if (*ne) ++ne;
+  }
+  return equiv;
+}
+
+
+/* think of this as a c++ template<> or a scheme macro */
+#define SWIG_TypeCheck_Template(comparison, ty)         \
+  if (ty) {                                             \
+    swig_cast_info *iter = ty->cast;                    \
+    while (iter) {                                      \
+      if (comparison) {                                 \
+        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
+
+/*
+  Check the typename
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheck(const char *c, swig_type_info *ty) {
+  SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
+}
+
+/* Same as previous function, except strcmp is replaced with a pointer comparison */
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
+  SWIG_TypeCheck_Template(iter->type == from, into);
+}
+
+/*
+  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) {
+      register size_t l = 0;
+      register size_t r = iter->size - 1;
+      do {
+	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
+	register size_t i = (l + r) >> 1; 
+	const char *iname = iter->types[i]->name;
+	if (iname) {
+	  register 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 {
+      register 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";
+  register const unsigned char *u = (unsigned char *) ptr;
+  register const unsigned char *eu =  u + sz;
+  for (; u != eu; ++u) {
+    register 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) {
+  register unsigned char *u = (unsigned char *) ptr;
+  register const unsigned char *eu = u + sz;
+  for (; u != eu; ++u) {
+    register char d = *(c++);
+    register 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
+
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * 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 */
+
+/* -----------------------------------------------------------------------------
+ * 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;
+
+/* Constant information structure */
+typedef struct {
+    int type;
+    char *name;
+    long lvalue;
+    double dvalue;
+    void   *pvalue;
+    swig_type_info **ptype;
+} swig_lua_const_info;
+
+typedef struct {
+  const char     *name;
+  lua_CFunction   method;
+} swig_lua_method;
+
+typedef struct {
+  const char     *name;
+  lua_CFunction   getmethod;
+  lua_CFunction   setmethod;
+} swig_lua_attribute;
+
+typedef struct swig_lua_class {
+  const char    *name;
+  swig_type_info   **type;
+  lua_CFunction  constructor;
+  void    (*destructor)(void *);
+  swig_lua_method   *methods;
+  swig_lua_attribute     *attributes;
+  struct swig_lua_class **bases;
+  const char **base_names;
+} swig_lua_class;
+
+/* this is the struct for wrappering 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 arbitary 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)) { lua_pushstring(L, (char *) msg); goto fail; } else
+
+/* helper #defines */
+#define SWIG_fail {goto fail;}
+#define SWIG_fail_arg(func_name,argnum,type) \
+  {lua_pushfstring(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) \
+  {lua_pushfstring(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))
+
+/* 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 value 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 */
+  lua_pushstring(L,"This variable is immutable");
+  lua_error(L);
+#endif
+    return 0;   /* should not return anything */
+}
+
+/* the module.get method used for getting linked data */
+SWIGINTERN int SWIG_Lua_module_get(lua_State* L)
+{
+/*  there should be 2 params passed in
+  (1) table (not the meta table)
+  (2) string name of the attribute
+  printf("SWIG_Lua_module_get %p(%s) '%s'\n",
+   lua_topointer(L,1),lua_typename(L,lua_type(L,1)),
+   lua_tostring(L,2));
+*/
+  /* get the metatable */
+  assert(lua_istable(L,1));  /* just in case */
+  lua_getmetatable(L,1);  /* get the metatable */
+  assert(lua_istable(L,-1));  /* just in case */
+  SWIG_Lua_get_table(L,".get");  /* get the .get table */
+  lua_remove(L,3);  /* remove metatable */
+  if (lua_istable(L,-1))
+  {
+    /* look for the key in the .get table */
+    lua_pushvalue(L,2);  /* key */
+    lua_rawget(L,-2);
+    lua_remove(L,3);  /* remove .get */
+    if (lua_iscfunction(L,-1))
+    {  /* found it so call the fn & return its value */
+      lua_call(L,0,1);
+      return 1;
+    }
+    lua_pop(L,1);  /* remove the top */
+  }
+  lua_pop(L,1);  /* remove the .get */
+  lua_pushnil(L);  /* return a nil */
+    return 1;
+}
+
+/* the module.set method used for setting linked data */
+SWIGINTERN int SWIG_Lua_module_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
+*/
+  /* get the metatable */
+  assert(lua_istable(L,1));  /* just in case */
+  lua_getmetatable(L,1);  /* get the metatable */
+  assert(lua_istable(L,-1));  /* just in case */
+  SWIG_Lua_get_table(L,".set");  /* get the .set table */
+  lua_remove(L,4);  /* remove metatable */
+  if (lua_istable(L,-1))
+  {
+    /* look for the key in the .set table */
+    lua_pushvalue(L,2);  /* key */
+    lua_rawget(L,-2);
+    lua_remove(L,4);  /* remove .set */
+    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_settop(L,3);  /* reset back to start */
+  /* we now have the table, key & new value, so just set directly */
+  lua_rawset(L,1);  /* add direct */
+  return 0;
+}
+
+/* registering a module in lua */
+SWIGINTERN void  SWIG_Lua_module_begin(lua_State* L,const char* name)
+{
+  assert(lua_istable(L,-1));  /* just in case */
+  lua_pushstring(L,name);
+  lua_newtable(L);   /* the table */
+  /* add meta table */
+  lua_newtable(L);    /* the meta table */
+  SWIG_Lua_add_function(L,"__index",SWIG_Lua_module_get);
+  SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_module_set);
+  lua_pushstring(L,".get");
+  lua_newtable(L);    /* the .get table */
+  lua_rawset(L,-3);  /* add .get into metatable */
+  lua_pushstring(L,".set");
+  lua_newtable(L);    /* the .set table */
+  lua_rawset(L,-3);  /* add .set into metatable */
+  lua_setmetatable(L,-2);  /* sets meta table in module */
+  lua_rawset(L,-3);        /* add module into parent */
+  SWIG_Lua_get_table(L,name);   /* get the table back out */
+}
+
+/* ending the register */
+SWIGINTERN void  SWIG_Lua_module_end(lua_State* L)
+{
+  lua_pop(L,1);       /* tidy stack (remove module) */
+}
+
+/* adding a linked variable to the module */
+SWIGINTERN void SWIG_Lua_module_add_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn)
+{
+  assert(lua_istable(L,-1));  /* just in case */
+  lua_getmetatable(L,-1);  /* get the metatable */
+  assert(lua_istable(L,-1));  /* just in case */
+  SWIG_Lua_get_table(L,".get"); /* find the .get table */
+  assert(lua_istable(L,-1));  /* should be a table: */
+  SWIG_Lua_add_function(L,name,getFn);
+  lua_pop(L,1);       /* tidy stack (remove table) */
+  if (setFn)  /* if there is a set fn */
+  {
+    SWIG_Lua_get_table(L,".set"); /* find the .set table */
+    assert(lua_istable(L,-1));  /* should be a table: */
+    SWIG_Lua_add_function(L,name,setFn);
+    lua_pop(L,1);       /* tidy stack (remove table) */
+  }
+  lua_pop(L,1);       /* tidy stack (remove meta) */
+}
+
+/* adding a function module */
+SWIGINTERN void  SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_CFunction fn)
+{
+  SWIG_Lua_add_function(L,name,fn);
+}
+
+/* -----------------------------------------------------------------------------
+ * global variable support code: classes
+ * ----------------------------------------------------------------------------- */
+
+/* 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
+*/
+  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,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,1);  /* the userdata */
+    lua_call(L,1,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: 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 */
+    return 1;
+  }
+  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,1);  /* the userdata */
+    lua_pushvalue(L,2);  /* the parameter */
+    lua_call(L,2,1);  /* 2 value in (userdata),1 out (result) */
+    lua_remove(L,-2); /* stack tidy, remove metatable */
+    return 1;
+  }
+  return 0;  /* sorry not known */
+}
+
+/* the class.set method, performs the lookup of class attributes */
+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
+printf("SWIG_Lua_class_set %p(%s) '%s' %p(%s)\n",
+      lua_topointer(L,1),lua_typename(L,lua_type(L,1)),
+      lua_tostring(L,2),
+      lua_topointer(L,3),lua_typename(L,lua_type(L,3)));*/
+
+  assert(lua_isuserdata(L,1));  /* just in case */
+  lua_getmetatable(L,1);    /* get the meta table */
+  assert(lua_istable(L,-1));  /* just in case */
+
+  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,1);  /* userdata */
+      lua_pushvalue(L,3);  /* value */
+      lua_call(L,2,0);
+      return 0;
+    }
+    lua_pop(L,1);  /* remove the value */
+  }
+  lua_pop(L,1);  /* remove the value .set table */
+  /* 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,1);  /* the userdata */
+    lua_pushvalue(L,2);  /* the parameter */
+    lua_pushvalue(L,3);  /* the value */
+    lua_call(L,3,0);  /* 3 values in ,0 out */
+    lua_remove(L,-2); /* stack tidy, remove metatable */
+    return 1;
+  }
+  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;
+}
+
+/* gets the swig class 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 */
+    lua_pushstring(L,"SWIG");
+    lua_newtable(L);
+    lua_rawset(L,LUA_REGISTRYINDEX);
+    /* then get it */
+    lua_pushstring(L,"SWIG");
+    lua_rawget(L,LUA_REGISTRYINDEX);
+  }
+}
+
+/* helper fn 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) */
+}
+
+/* helper add a variable to a registered class */
+SWIGINTERN void  SWIG_Lua_add_class_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 details (attributes & operations) */
+SWIGINTERN void  SWIG_Lua_add_class_details(lua_State* L,swig_lua_class* clss)
+{
+  int i;
+  /* call all the base classes first: we can then override these later: */
+  for(i=0;clss->bases[i];i++)
+  {
+    SWIG_Lua_add_class_details(L,clss->bases[i]);
+  }
+  /* add fns */
+  for(i=0;clss->attributes[i].name;i++){
+    SWIG_Lua_add_class_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].method);
+  }
+  lua_pop(L,1);       /* tidy stack (remove table) */
+  /*   add operator overloads
+    these look ANY method which start with "__" and assume they
+    are operator overloads & add them to the metatable
+    (this might mess up is someone defines a method __gc (the destructor)*/
+  for(i=0;clss->methods[i].name;i++){
+    if (clss->methods[i].name[0]=='_' && clss->methods[i].name[1]=='_'){
+      SWIG_Lua_add_function(L,clss->methods[i].name,clss->methods[i].method);
+    }
+  }
+}
+
+/* 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;
+    }
+  }	
+}
+
+/* performs the entire class registration process */
+SWIGINTERN void  SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss)
+{
+  /*  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)
+    SWIG_Lua_add_function(L,clss->name,clss->constructor);
+
+  SWIG_Lua_get_class_registry(L);  /* get the registry */
+  lua_pushstring(L,clss->name);  /* get the name */
+  lua_newtable(L);    /* create the metatable */
+  /* add string of class name called ".type" */
+  lua_pushstring(L,".type");
+  lua_pushstring(L,clss->name);
+  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);
+  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) */
+
+  SWIG_Lua_get_class_metatable(L,clss->name);
+  SWIG_Lua_add_class_details(L,clss);  /* recursive adding of details (atts & ops) */
+  lua_pop(L,1);      /* tidy stack (remove class metatable) */
+}
+
+/* -----------------------------------------------------------------------------
+ * 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))->name);
+    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;
+  _SWIG_Lua_AddMetatable(L,type); /* add metatable */
+}
+
+/* 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))){
+    lua_pushfstring(L,"Error in %s, expected a %s at argument number %d\n",
+      func_name,(type && type->str)?type->str:"void*",argnum);
+    lua_error(L);
+  }
+  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,1);  /* 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;
+}
+
+/* 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_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;
+}
+
+/* -----------------------------------------------------------------------------
+ * global variable support code: class/struct typemap functions
+ * ----------------------------------------------------------------------------- */
+
+/* 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;
+    }
+  }
+}
+
+/* -----------------------------------------------------------------------------
+ * 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 a really simple way of calling lua from C
+Unfortunately lua keeps changing its API's, so we need a conditional compile
+In lua 5.0.X its lua_dostring()
+In lua 5.1.X its 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_CoreSession swig_types[0]
+#define SWIGTYPE_p_Event swig_types[1]
+#define SWIGTYPE_p_Session swig_types[2]
+#define SWIGTYPE_p_Stream swig_types[3]
+#define SWIGTYPE_p_input_callback_state swig_types[4]
+#define SWIGTYPE_p_session_flag_t swig_types[5]
+#define SWIGTYPE_p_switch_channel_state_t swig_types[6]
+#define SWIGTYPE_p_switch_channel_t swig_types[7]
+#define SWIGTYPE_p_switch_core_session_t swig_types[8]
+#define SWIGTYPE_p_switch_input_args_t swig_types[9]
+#define SWIGTYPE_p_switch_input_type_t swig_types[10]
+#define SWIGTYPE_p_switch_priority_t swig_types[11]
+#define SWIGTYPE_p_switch_size_t swig_types[12]
+#define SWIGTYPE_p_switch_status_t swig_types[13]
+#define SWIGTYPE_p_switch_stream_handle_t swig_types[14]
+#define SWIGTYPE_p_void swig_types[15]
+static swig_type_info *swig_types[17];
+static swig_module_info swig_module = {swig_types, 16, 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_cpp.h"
+#include "freeswitch_lua.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+static int _wrap_console_log(lua_State* L) {
+  int SWIG_arg = -1;
+  char *arg1 = (char *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  SWIG_check_num_args("console_log",2,2)
+  if(!lua_isstring(L,1)) SWIG_fail_arg("console_log",1,"char *");
+  if(!lua_isstring(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);
+  SWIG_arg=0;
+  
+  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 = -1;
+  char *arg1 = (char *) 0 ;
+  
+  SWIG_check_num_args("console_clean_log",1,1)
+  if(!lua_isstring(L,1)) SWIG_fail_arg("console_clean_log",1,"char *");
+  arg1 = (char *)lua_tostring(L, 1);
+  console_clean_log(arg1);
+  SWIG_arg=0;
+  
+  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 = -1;
+  char *arg1 = (char *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("api_execute",2,2)
+  if(!lua_isstring(L,1)) SWIG_fail_arg("api_execute",1,"char *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("api_execute",2,"char *");
+  arg1 = (char *)lua_tostring(L, 1);
+  arg2 = (char *)lua_tostring(L, 2);
+  result = (char *)api_execute(arg1,arg2);
+  SWIG_arg=0;
+  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_api_reply_delete(lua_State* L) {
+  int SWIG_arg = -1;
+  char *arg1 = (char *) 0 ;
+  
+  SWIG_check_num_args("api_reply_delete",1,1)
+  if(!lua_isstring(L,1)) SWIG_fail_arg("api_reply_delete",1,"char *");
+  arg1 = (char *)lua_tostring(L, 1);
+  api_reply_delete(arg1);
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_process_callback_result(lua_State* L) {
+  int SWIG_arg = -1;
+  char *arg1 = (char *) 0 ;
+  input_callback_state *arg2 = (input_callback_state *) 0 ;
+  switch_core_session_t *arg3 = (switch_core_session_t *) 0 ;
+  switch_status_t result;
+  
+  SWIG_check_num_args("process_callback_result",3,3)
+  if(!lua_isstring(L,1)) SWIG_fail_arg("process_callback_result",1,"char *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("process_callback_result",2,"input_callback_state *");
+  if(!SWIG_isptrtype(L,3)) SWIG_fail_arg("process_callback_result",3,"switch_core_session_t *");
+  arg1 = (char *)lua_tostring(L, 1);
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_input_callback_state,0))){
+    SWIG_fail_ptr("process_callback_result",2,SWIGTYPE_p_input_callback_state);
+  }
+  
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_switch_core_session_t,0))){
+    SWIG_fail_ptr("process_callback_result",3,SWIGTYPE_p_switch_core_session_t);
+  }
+  
+  result = process_callback_result(arg1,arg2,arg3);
+  SWIG_arg=0;
+  {
+    switch_status_t * resultptr = new switch_status_t((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_input_callback_state_t_function_set(lua_State* L) {
+  int SWIG_arg = -1;
+  input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
+  void *arg2 = (void *) 0 ;
+  
+  SWIG_check_num_args("function",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("function",1,"input_callback_state_t *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("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_function_set",1,SWIGTYPE_p_input_callback_state);
+  }
+  
+  arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"input_callback_state_t_function_set");
+  if (arg1) (arg1)->function = arg2;
+  
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_input_callback_state_t_function_get(lua_State* L) {
+  int SWIG_arg = -1;
+  input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
+  void *result = 0 ;
+  
+  SWIG_check_num_args("function",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("function",1,"input_callback_state_t *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_input_callback_state,0))){
+    SWIG_fail_ptr("input_callback_state_t_function_get",1,SWIGTYPE_p_input_callback_state);
+  }
+  
+  result = (void *) ((arg1)->function);
+  SWIG_arg=0;
+  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 = -1;
+  input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
+  void *arg2 = (void *) 0 ;
+  
+  SWIG_check_num_args("threadState",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("threadState",1,"input_callback_state_t *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("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;
+  
+  SWIG_arg=0;
+  
+  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 = -1;
+  input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
+  void *result = 0 ;
+  
+  SWIG_check_num_args("threadState",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("threadState",1,"input_callback_state_t *");
+  
+  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_arg=0;
+  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 = -1;
+  input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
+  void *arg2 = (void *) 0 ;
+  
+  SWIG_check_num_args("extra",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("extra",1,"input_callback_state_t *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("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;
+  
+  SWIG_arg=0;
+  
+  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 = -1;
+  input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
+  void *result = 0 ;
+  
+  SWIG_check_num_args("extra",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("extra",1,"input_callback_state_t *");
+  
+  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_arg=0;
+  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 = -1;
+  input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  SWIG_check_num_args("funcargs",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("funcargs",1,"input_callback_state_t *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("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);
+  {
+    if (arg1->funcargs) 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;
+    }
+  }
+  SWIG_arg=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 = -1;
+  input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("funcargs",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("funcargs",1,"input_callback_state_t *");
+  
+  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);
+  SWIG_arg=0;
+  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 = -1;
+  input_callback_state_t *result = 0 ;
+  
+  SWIG_check_num_args("input_callback_state_t::input_callback_state_t",0,0)
+  result = (input_callback_state_t *)new input_callback_state_t();
+  SWIG_arg=0;
+  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 int _wrap_delete_input_callback_state_t(lua_State* L) {
+  int SWIG_arg = -1;
+  input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
+  
+  SWIG_check_num_args("input_callback_state_t::~input_callback_state_t",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("input_callback_state_t::~input_callback_state_t",1,"input_callback_state_t *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_input_callback_state,SWIG_POINTER_DISOWN))){
+    SWIG_fail_ptr("delete_input_callback_state_t",1,SWIGTYPE_p_input_callback_state);
+  }
+  
+  delete arg1;
+  
+  SWIG_arg=0;
+  
+  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_t *arg1 = (input_callback_state_t *) obj;
+delete arg1;
+}
+static swig_lua_method swig_input_callback_state_t_methods[] = {
+    {0,0}
+};
+static swig_lua_attribute swig_input_callback_state_t_attributes[] = {
+    { "function", _wrap_input_callback_state_t_function_get, _wrap_input_callback_state_t_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_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", &SWIGTYPE_p_input_callback_state,_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_bases, swig_input_callback_state_t_base_names };
+
+static int _wrap_new_Stream__SWIG_0(lua_State* L) {
+  int SWIG_arg = -1;
+  Stream *result = 0 ;
+  
+  SWIG_check_num_args("Stream",0,0)
+  result = (Stream *)new Stream();
+  SWIG_arg=0;
+  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 = -1;
+  switch_stream_handle_t *arg1 = (switch_stream_handle_t *) 0 ;
+  Stream *result = 0 ;
+  
+  SWIG_check_num_args("Stream",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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_arg=0;
+  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);
+    }
+  }
+  
+  lua_pushstring(L,"No matching function for overloaded 'new_Stream'");
+  lua_error(L);return 0;
+}
+
+
+static int _wrap_delete_Stream(lua_State* L) {
+  int SWIG_arg = -1;
+  Stream *arg1 = (Stream *) 0 ;
+  
+  SWIG_check_num_args("Stream",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Stream",1,"Stream *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Stream,SWIG_POINTER_DISOWN))){
+    SWIG_fail_ptr("delete_Stream",1,SWIGTYPE_p_Stream);
+  }
+  
+  delete arg1;
+  
+  SWIG_arg=0;
+  
+  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 = -1;
+  Stream *arg1 = (Stream *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  SWIG_check_num_args("write",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("write",1,"Stream *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  
+  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 = -1;
+  Stream *arg1 = (Stream *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("get_data",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  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 swig_lua_method swig_Stream_methods[] = {
+    {"write", _wrap_Stream_write}, 
+    {"get_data", _wrap_Stream_get_data}, 
+    {0,0}
+};
+static swig_lua_attribute swig_Stream_attributes[] = {
+    {0,0,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", &SWIGTYPE_p_Stream,_wrap_new_Stream, swig_delete_Stream, swig_Stream_methods, swig_Stream_attributes, swig_Stream_bases, swig_Stream_base_names };
+
+static int _wrap_new_Event(lua_State* L) {
+  int SWIG_arg = -1;
+  char *arg1 = (char *) 0 ;
+  char *arg2 = (char *) NULL ;
+  Event *result = 0 ;
+  
+  SWIG_check_num_args("Event",1,2)
+  if(!lua_isstring(L,1)) SWIG_fail_arg("Event",1,"char const *");
+  if(lua_gettop(L)>=2 && !lua_isstring(L,2)) SWIG_fail_arg("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_arg=0;
+  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_delete_Event(lua_State* L) {
+  int SWIG_arg = -1;
+  Event *arg1 = (Event *) 0 ;
+  
+  SWIG_check_num_args("Event",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Event",1,"Event *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,SWIG_POINTER_DISOWN))){
+    SWIG_fail_ptr("delete_Event",1,SWIGTYPE_p_Event);
+  }
+  
+  delete arg1;
+  
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Event_set_priority(lua_State* L) {
+  int SWIG_arg = -1;
+  Event *arg1 = (Event *) 0 ;
+  switch_priority_t arg2 = (switch_priority_t) SWITCH_PRIORITY_NORMAL ;
+  bool result;
+  switch_priority_t *argp2 ;
+  
+  SWIG_check_num_args("set_priority",1,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("set_priority",1,"Event *");
+  if(lua_gettop(L)>=2 && !lua_isuserdata(L,2)) SWIG_fail_arg("set_priority",2,"switch_priority_t");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
+    SWIG_fail_ptr("Event_set_priority",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_set_priority",2,SWIGTYPE_p_switch_priority_t);
+    }
+    arg2 = *argp2;
+  }
+  result = (bool)(arg1)->set_priority(arg2);
+  SWIG_arg=0;
+  lua_pushboolean(L,(int)(result==true)); SWIG_arg++;
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Event_get_header(lua_State* L) {
+  int SWIG_arg = -1;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("get_header",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("get_header",1,"Event *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("get_header",2,"char *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
+    SWIG_fail_ptr("Event_get_header",1,SWIGTYPE_p_Event);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  result = (char *)(arg1)->get_header(arg2);
+  SWIG_arg=0;
+  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_get_body(lua_State* L) {
+  int SWIG_arg = -1;
+  Event *arg1 = (Event *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("get_body",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("get_body",1,"Event *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
+    SWIG_fail_ptr("Event_get_body",1,SWIGTYPE_p_Event);
+  }
+  
+  result = (char *)(arg1)->get_body();
+  SWIG_arg=0;
+  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_add_body(lua_State* L) {
+  int SWIG_arg = -1;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) 0 ;
+  bool result;
+  
+  SWIG_check_num_args("add_body",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("add_body",1,"Event *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("add_body",2,"char const *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
+    SWIG_fail_ptr("Event_add_body",1,SWIGTYPE_p_Event);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  result = (bool)(arg1)->add_body((char const *)arg2);
+  SWIG_arg=0;
+  lua_pushboolean(L,(int)(result==true)); SWIG_arg++;
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Event_add_header(lua_State* L) {
+  int SWIG_arg = -1;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) 0 ;
+  bool result;
+  
+  SWIG_check_num_args("add_header",3,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("add_header",1,"Event *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("add_header",2,"char const *");
+  if(!lua_isstring(L,3)) SWIG_fail_arg("add_header",3,"char const *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
+    SWIG_fail_ptr("Event_add_header",1,SWIGTYPE_p_Event);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  arg3 = (char *)lua_tostring(L, 3);
+  result = (bool)(arg1)->add_header((char const *)arg2,(char const *)arg3);
+  SWIG_arg=0;
+  lua_pushboolean(L,(int)(result==true)); SWIG_arg++;
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Event_del_header(lua_State* L) {
+  int SWIG_arg = -1;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) 0 ;
+  bool result;
+  
+  SWIG_check_num_args("del_header",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("del_header",1,"Event *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("del_header",2,"char const *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
+    SWIG_fail_ptr("Event_del_header",1,SWIGTYPE_p_Event);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  result = (bool)(arg1)->del_header((char const *)arg2);
+  SWIG_arg=0;
+  lua_pushboolean(L,(int)(result==true)); 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 = -1;
+  Event *arg1 = (Event *) 0 ;
+  bool result;
+  
+  SWIG_check_num_args("fire",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  lua_pushboolean(L,(int)(result==true)); 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 swig_lua_method swig_Event_methods[] = {
+    {"set_priority", _wrap_Event_set_priority}, 
+    {"get_header", _wrap_Event_get_header}, 
+    {"get_body", _wrap_Event_get_body}, 
+    {"add_body", _wrap_Event_add_body}, 
+    {"add_header", _wrap_Event_add_header}, 
+    {"del_header", _wrap_Event_del_header}, 
+    {"fire", _wrap_Event_fire}, 
+    {0,0}
+};
+static swig_lua_attribute swig_Event_attributes[] = {
+    {0,0,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", &SWIGTYPE_p_Event,_wrap_new_Event, swig_delete_Event, swig_Event_methods, swig_Event_attributes, swig_Event_bases, swig_Event_base_names };
+
+static int _wrap_delete_CoreSession(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  
+  SWIG_check_num_args("CoreSession",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("CoreSession",1,"CoreSession *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,SWIG_POINTER_DISOWN))){
+    SWIG_fail_ptr("delete_CoreSession",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  delete arg1;
+  
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_CoreSession_session_set(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  switch_core_session_t *arg2 = (switch_core_session_t *) 0 ;
+  
+  SWIG_check_num_args("session",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("session",1,"CoreSession *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("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;
+  
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  switch_core_session_t *result = 0 ;
+  
+  SWIG_check_num_args("session",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  switch_channel_t *arg2 = (switch_channel_t *) 0 ;
+  
+  SWIG_check_num_args("channel",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("channel",1,"CoreSession *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("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;
+  
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  switch_channel_t *result = 0 ;
+  
+  SWIG_check_num_args("channel",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  unsigned int arg2 ;
+  
+  SWIG_check_num_args("flags",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("flags",1,"CoreSession *");
+  if(!lua_isnumber(L,2)) SWIG_fail_arg("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);
+  }
+  
+  arg2 = (unsigned int)lua_tonumber(L, 2);
+  if (arg1) (arg1)->flags = arg2;
+  
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  unsigned int result;
+  
+  SWIG_check_num_args("flags",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int arg2 ;
+  
+  SWIG_check_num_args("allocated",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("allocated",1,"CoreSession *");
+  if(!lua_isnumber(L,2)) SWIG_fail_arg("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;
+  
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int result;
+  
+  SWIG_check_num_args("allocated",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  input_callback_state *arg2 = (input_callback_state *) 0 ;
+  
+  SWIG_check_num_args("cb_state",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("cb_state",1,"CoreSession *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("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;
+  
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  input_callback_state *result = 0 ;
+  
+  SWIG_check_num_args("cb_state",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  switch_channel_state_t arg2 ;
+  switch_channel_state_t *argp2 ;
+  
+  SWIG_check_num_args("hook_state",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("hook_state",1,"CoreSession *");
+  if(!lua_isuserdata(L,2)) SWIG_fail_arg("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;
+  
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  switch_channel_state_t result;
+  
+  SWIG_check_num_args("hook_state",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  {
+    switch_channel_state_t * resultptr = new switch_channel_state_t((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_answer(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int result;
+  
+  SWIG_check_num_args("answer",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int result;
+  
+  SWIG_check_num_args("preAnswer",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) "normal_clearing" ;
+  
+  SWIG_check_num_args("hangup",1,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("hangup",1,"CoreSession *");
+  if(lua_gettop(L)>=2 && !lua_isstring(L,2)) SWIG_fail_arg("hangup",2,"char *");
+  
+  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(arg2);
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) 0 ;
+  
+  SWIG_check_num_args("setVariable",3,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("setVariable",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("setVariable",2,"char *");
+  if(!lua_isstring(L,3)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("getVariable",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("getVariable",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  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 = -1;
+  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("recordFile",2,5)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("recordFile",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("recordFile",2,"char *");
+  if(lua_gettop(L)>=3 && !lua_isnumber(L,3)) SWIG_fail_arg("recordFile",3,"int");
+  if(lua_gettop(L)>=4 && !lua_isnumber(L,4)) SWIG_fail_arg("recordFile",4,"int");
+  if(lua_gettop(L)>=5 && !lua_isnumber(L,5)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  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_setCallerData(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) 0 ;
+  
+  SWIG_check_num_args("setCallerData",3,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("setCallerData",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("setCallerData",2,"char *");
+  if(!lua_isstring(L,3)) SWIG_fail_arg("setCallerData",3,"char *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+    SWIG_fail_ptr("CoreSession_setCallerData",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  arg3 = (char *)lua_tostring(L, 3);
+  (arg1)->setCallerData(arg2,arg3);
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  CoreSession *arg2 = (CoreSession *) 0 ;
+  char *arg3 = (char *) 0 ;
+  int arg4 = (int) 60 ;
+  int result;
+  
+  SWIG_check_num_args("originate",3,4)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("originate",1,"CoreSession *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("originate",2,"CoreSession *");
+  if(!lua_isstring(L,3)) SWIG_fail_arg("originate",3,"char *");
+  if(lua_gettop(L)>=4 && !lua_isnumber(L,4)) SWIG_fail_arg("originate",4,"int");
+  
+  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);
+  }
+  result = (int)(arg1)->originate(arg2,arg3,arg4);
+  SWIG_arg=0;
+  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_setDTMFCallback(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  void *arg2 = (void *) 0 ;
+  char *arg3 = (char *) 0 ;
+  
+  SWIG_check_num_args("setDTMFCallback",3,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("setDTMFCallback",1,"CoreSession *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("setDTMFCallback",2,"void *");
+  if(!lua_isstring(L,3)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  int result;
+  
+  SWIG_check_num_args("speak",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("speak",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) 0 ;
+  
+  SWIG_check_num_args("set_tts_parms",3,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("set_tts_parms",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("set_tts_parms",2,"char *");
+  if(!lua_isstring(L,3)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_CoreSession_collectDigits(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int arg2 ;
+  int result;
+  
+  SWIG_check_num_args("collectDigits",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("collectDigits",1,"CoreSession *");
+  if(!lua_isnumber(L,2)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  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_getDigits(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  switch_size_t arg3 ;
+  switch_size_t arg4 ;
+  char *arg5 = (char *) 0 ;
+  char *arg6 = (char *) 0 ;
+  int arg7 ;
+  int result;
+  switch_size_t *argp3 ;
+  switch_size_t *argp4 ;
+  
+  SWIG_check_num_args("getDigits",7,7)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("getDigits",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("getDigits",2,"char *");
+  if(!lua_isuserdata(L,3)) SWIG_fail_arg("getDigits",3,"switch_size_t");
+  if(!lua_isuserdata(L,4)) SWIG_fail_arg("getDigits",4,"switch_size_t");
+  if(!lua_isstring(L,5)) SWIG_fail_arg("getDigits",5,"char *");
+  if(!lua_isstring(L,6)) SWIG_fail_arg("getDigits",6,"char *");
+  if(!lua_isnumber(L,7)) SWIG_fail_arg("getDigits",7,"int");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+    SWIG_fail_ptr("CoreSession_getDigits",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&argp3,SWIGTYPE_p_switch_size_t,0))){
+    SWIG_fail_ptr("CoreSession_getDigits",3,SWIGTYPE_p_switch_size_t);
+  }
+  arg3 = *argp3;
+  
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&argp4,SWIGTYPE_p_switch_size_t,0))){
+    SWIG_fail_ptr("CoreSession_getDigits",4,SWIGTYPE_p_switch_size_t);
+  }
+  arg4 = *argp4;
+  
+  arg5 = (char *)lua_tostring(L, 5);
+  arg6 = (char *)lua_tostring(L, 6);
+  arg7 = (int)lua_tonumber(L, 7);
+  result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6,arg7);
+  SWIG_arg=0;
+  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_transfer(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) 0 ;
+  char *arg4 = (char *) 0 ;
+  int result;
+  
+  SWIG_check_num_args("transfer",4,4)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("transfer",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("transfer",2,"char *");
+  if(!lua_isstring(L,3)) SWIG_fail_arg("transfer",3,"char *");
+  if(!lua_isstring(L,4)) SWIG_fail_arg("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);
+  arg3 = (char *)lua_tostring(L, 3);
+  arg4 = (char *)lua_tostring(L, 4);
+  result = (int)(arg1)->transfer(arg2,arg3,arg4);
+  SWIG_arg=0;
+  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_playAndGetDigits(lua_State* L) {
+  int SWIG_arg = -1;
+  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 *) 0 ;
+  int result;
+  
+  SWIG_check_num_args("playAndGetDigits",10,10)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("playAndGetDigits",1,"CoreSession *");
+  if(!lua_isnumber(L,2)) SWIG_fail_arg("playAndGetDigits",2,"int");
+  if(!lua_isnumber(L,3)) SWIG_fail_arg("playAndGetDigits",3,"int");
+  if(!lua_isnumber(L,4)) SWIG_fail_arg("playAndGetDigits",4,"int");
+  if(!lua_isnumber(L,5)) SWIG_fail_arg("playAndGetDigits",5,"int");
+  if(!lua_isstring(L,6)) SWIG_fail_arg("playAndGetDigits",6,"char *");
+  if(!lua_isstring(L,7)) SWIG_fail_arg("playAndGetDigits",7,"char *");
+  if(!lua_isstring(L,8)) SWIG_fail_arg("playAndGetDigits",8,"char *");
+  if(!lua_isstring(L,9)) SWIG_fail_arg("playAndGetDigits",9,"char *");
+  if(!lua_isstring(L,10)) SWIG_fail_arg("playAndGetDigits",10,"char *");
+  
+  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);
+  arg10 = (char *)lua_tostring(L, 10);
+  result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+  SWIG_arg=0;
+  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_streamFile(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  int arg3 = (int) 0 ;
+  int result;
+  
+  SWIG_check_num_args("streamFile",2,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("streamFile",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("streamFile",2,"char *");
+  if(lua_gettop(L)>=3 && !lua_isnumber(L,3)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int result;
+  
+  SWIG_check_num_args("flushEvents",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int result;
+  
+  SWIG_check_num_args("flushDigits",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  bool arg2 ;
+  int result;
+  
+  SWIG_check_num_args("setAutoHangup",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("setAutoHangup",1,"CoreSession *");
+  if(!lua_isboolean(L,2)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  void *arg2 = (void *) 0 ;
+  
+  SWIG_check_num_args("setHangupHook",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("setHangupHook",1,"CoreSession *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  bool result;
+  
+  SWIG_check_num_args("ready",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  lua_pushboolean(L,(int)(result==true)); SWIG_arg++;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) 0 ;
+  
+  SWIG_check_num_args("execute",3,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("execute",1,"CoreSession *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("execute",2,"char *");
+  if(!lua_isstring(L,3)) SWIG_fail_arg("execute",3,"char *");
+  
+  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);
+  arg3 = (char *)lua_tostring(L, 3);
+  (arg1)->execute(arg2,arg3);
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  bool result;
+  
+  SWIG_check_num_args("begin_allow_threads",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  lua_pushboolean(L,(int)(result==true)); 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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  bool result;
+  
+  SWIG_check_num_args("end_allow_threads",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  lua_pushboolean(L,(int)(result==true)); 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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("get_uuid",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  switch_input_args_t *result = 0 ;
+  
+  SWIG_check_num_args("get_cb_args",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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);
+  }
+  
+  {
+    switch_input_args_t const &_result_ref = ((CoreSession const *)arg1)->get_cb_args();
+    result = (switch_input_args_t *) &_result_ref;
+  }
+  SWIG_arg=0;
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  
+  SWIG_check_num_args("check_hangup_hook",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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();
+  SWIG_arg=0;
+  
+  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 = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  void *arg2 = (void *) 0 ;
+  switch_input_type_t arg3 ;
+  switch_status_t result;
+  switch_input_type_t *argp3 ;
+  
+  SWIG_check_num_args("run_dtmf_callback",3,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("run_dtmf_callback",1,"CoreSession *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("run_dtmf_callback",2,"void *");
+  if(!lua_isuserdata(L,3)) SWIG_fail_arg("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);
+  SWIG_arg=0;
+  {
+    switch_status_t * resultptr = new switch_status_t((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 void swig_delete_CoreSession(void *obj) {
+CoreSession *arg1 = (CoreSession *) obj;
+delete arg1;
+}
+static swig_lua_method swig_CoreSession_methods[] = {
+    {"answer", _wrap_CoreSession_answer}, 
+    {"preAnswer", _wrap_CoreSession_preAnswer}, 
+    {"hangup", _wrap_CoreSession_hangup}, 
+    {"setVariable", _wrap_CoreSession_setVariable}, 
+    {"getVariable", _wrap_CoreSession_getVariable}, 
+    {"recordFile", _wrap_CoreSession_recordFile}, 
+    {"setCallerData", _wrap_CoreSession_setCallerData}, 
+    {"originate", _wrap_CoreSession_originate}, 
+    {"setDTMFCallback", _wrap_CoreSession_setDTMFCallback}, 
+    {"speak", _wrap_CoreSession_speak}, 
+    {"set_tts_parms", _wrap_CoreSession_set_tts_parms}, 
+    {"collectDigits", _wrap_CoreSession_collectDigits}, 
+    {"getDigits", _wrap_CoreSession_getDigits}, 
+    {"transfer", _wrap_CoreSession_transfer}, 
+    {"playAndGetDigits", _wrap_CoreSession_playAndGetDigits}, 
+    {"streamFile", _wrap_CoreSession_streamFile}, 
+    {"flushEvents", _wrap_CoreSession_flushEvents}, 
+    {"flushDigits", _wrap_CoreSession_flushDigits}, 
+    {"setAutoHangup", _wrap_CoreSession_setAutoHangup}, 
+    {"setHangupHook", _wrap_CoreSession_setHangupHook}, 
+    {"ready", _wrap_CoreSession_ready}, 
+    {"execute", _wrap_CoreSession_execute}, 
+    {"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}, 
+    {0,0}
+};
+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},
+    {0,0,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", &SWIGTYPE_p_CoreSession,0, swig_delete_CoreSession, swig_CoreSession_methods, swig_CoreSession_attributes, swig_CoreSession_bases, swig_CoreSession_base_names };
+
+static int _wrap_bridge(lua_State* L) {
+  int SWIG_arg = -1;
+  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);
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_hanguphook(lua_State* L) {
+  int SWIG_arg = -1;
+  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);
+  SWIG_arg=0;
+  {
+    switch_status_t * resultptr = new switch_status_t((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 = -1;
+  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_status_t result;
+  switch_input_type_t *argp3 ;
+  
+  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");
+  arg5 = (unsigned int)lua_tonumber(L, 5);
+  result = dtmf_callback(arg1,arg2,arg3,arg4,arg5);
+  SWIG_arg=0;
+  {
+    switch_status_t * resultptr = new switch_status_t((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 = -1;
+  Session *result = 0 ;
+  
+  SWIG_check_num_args("Session",0,0)
+  result = (Session *)new Session();
+  SWIG_arg=0;
+  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++; 
+  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 = -1;
+  char *arg1 = (char *) 0 ;
+  Session *result = 0 ;
+  
+  SWIG_check_num_args("Session",1,1)
+  if(!lua_isstring(L,1)) SWIG_fail_arg("Session",1,"char *");
+  arg1 = (char *)lua_tostring(L, 1);
+  result = (Session *)new Session(arg1);
+  SWIG_arg=0;
+  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++; 
+  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 = -1;
+  switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+  Session *result = 0 ;
+  
+  SWIG_check_num_args("Session",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("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 = (Session *)new Session(arg1);
+  SWIG_arg=0;
+  SWIG_NewPointerObj(L,result,SWIGTYPE_p_Session,1); SWIG_arg++; 
+  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[2]={
+    1,2
+  };
+  
+  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_2(L);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    {
+      _v = lua_isstring(L,argv[0]);
+    }
+    if (_v) {
+      return _wrap_new_Session__SWIG_1(L);
+    }
+  }
+  
+  lua_pushstring(L,"No matching function for overloaded 'new_Session'");
+  lua_error(L);return 0;
+}
+
+
+static int _wrap_delete_Session(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  
+  SWIG_check_num_args("Session",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("Session",1,"Session *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,SWIG_POINTER_DISOWN))){
+    SWIG_fail_ptr("delete_Session",1,SWIGTYPE_p_Session);
+  }
+  
+  delete arg1;
+  
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Session_begin_allow_threads(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  bool result;
+  
+  SWIG_check_num_args("begin_allow_threads",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("begin_allow_threads",1,"Session *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_begin_allow_threads",1,SWIGTYPE_p_Session);
+  }
+  
+  result = (bool)(arg1)->begin_allow_threads();
+  SWIG_arg=0;
+  lua_pushboolean(L,(int)(result==true)); 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 = -1;
+  Session *arg1 = (Session *) 0 ;
+  bool result;
+  
+  SWIG_check_num_args("end_allow_threads",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("end_allow_threads",1,"Session *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_end_allow_threads",1,SWIGTYPE_p_Session);
+  }
+  
+  result = (bool)(arg1)->end_allow_threads();
+  SWIG_arg=0;
+  lua_pushboolean(L,(int)(result==true)); 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 = -1;
+  Session *arg1 = (Session *) 0 ;
+  
+  SWIG_check_num_args("check_hangup_hook",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("check_hangup_hook",1,"Session *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_check_hangup_hook",1,SWIGTYPE_p_Session);
+  }
+  
+  (arg1)->check_hangup_hook();
+  SWIG_arg=0;
+  
+  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 = -1;
+  Session *arg1 = (Session *) 0 ;
+  void *arg2 = (void *) 0 ;
+  switch_input_type_t arg3 ;
+  switch_status_t result;
+  switch_input_type_t *argp3 ;
+  
+  SWIG_check_num_args("run_dtmf_callback",3,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("run_dtmf_callback",1,"Session *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("run_dtmf_callback",2,"void *");
+  if(!lua_isuserdata(L,3)) SWIG_fail_arg("run_dtmf_callback",3,"switch_input_type_t");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_run_dtmf_callback",1,SWIGTYPE_p_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);
+  SWIG_arg=0;
+  {
+    switch_status_t * resultptr = new switch_status_t((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_session_set(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  switch_core_session_t *arg2 = (switch_core_session_t *) 0 ;
+  
+  SWIG_check_num_args("session",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("session",1,"Session *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("session",2,"switch_core_session_t *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_session_set",1,SWIGTYPE_p_Session);
+  }
+  
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_switch_core_session_t,SWIG_POINTER_DISOWN))){
+    SWIG_fail_ptr("Session_session_set",2,SWIGTYPE_p_switch_core_session_t);
+  }
+  
+  if (arg1) (arg1)->session = arg2;
+  
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Session_session_get(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  switch_core_session_t *result = 0 ;
+  
+  SWIG_check_num_args("session",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("session",1,"Session *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_session_get",1,SWIGTYPE_p_Session);
+  }
+  
+  result = (switch_core_session_t *) ((arg1)->session);
+  SWIG_arg=0;
+  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_Session_channel_set(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  switch_channel_t *arg2 = (switch_channel_t *) 0 ;
+  
+  SWIG_check_num_args("channel",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("channel",1,"Session *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("channel",2,"switch_channel_t *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_channel_set",1,SWIGTYPE_p_Session);
+  }
+  
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_switch_channel_t,SWIG_POINTER_DISOWN))){
+    SWIG_fail_ptr("Session_channel_set",2,SWIGTYPE_p_switch_channel_t);
+  }
+  
+  if (arg1) (arg1)->channel = arg2;
+  
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Session_channel_get(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  switch_channel_t *result = 0 ;
+  
+  SWIG_check_num_args("channel",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("channel",1,"Session *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_channel_get",1,SWIGTYPE_p_Session);
+  }
+  
+  result = (switch_channel_t *) ((arg1)->channel);
+  SWIG_arg=0;
+  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_Session_flags_set(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  unsigned int arg2 ;
+  
+  SWIG_check_num_args("flags",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("flags",1,"Session *");
+  if(!lua_isnumber(L,2)) SWIG_fail_arg("flags",2,"unsigned int");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_flags_set",1,SWIGTYPE_p_Session);
+  }
+  
+  arg2 = (unsigned int)lua_tonumber(L, 2);
+  if (arg1) (arg1)->flags = arg2;
+  
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Session_flags_get(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  unsigned int result;
+  
+  SWIG_check_num_args("flags",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("flags",1,"Session *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_flags_get",1,SWIGTYPE_p_Session);
+  }
+  
+  result = (unsigned int) ((arg1)->flags);
+  SWIG_arg=0;
+  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_allocated_set(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  int arg2 ;
+  
+  SWIG_check_num_args("allocated",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("allocated",1,"Session *");
+  if(!lua_isnumber(L,2)) SWIG_fail_arg("allocated",2,"int");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_allocated_set",1,SWIGTYPE_p_Session);
+  }
+  
+  arg2 = (int)lua_tonumber(L, 2);
+  if (arg1) (arg1)->allocated = arg2;
+  
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Session_allocated_get(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  int result;
+  
+  SWIG_check_num_args("allocated",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("allocated",1,"Session *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_allocated_get",1,SWIGTYPE_p_Session);
+  }
+  
+  result = (int) ((arg1)->allocated);
+  SWIG_arg=0;
+  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_state_set(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  input_callback_state *arg2 = (input_callback_state *) 0 ;
+  
+  SWIG_check_num_args("cb_state",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("cb_state",1,"Session *");
+  if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("cb_state",2,"input_callback_state *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_cb_state_set",1,SWIGTYPE_p_Session);
+  }
+  
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_input_callback_state,0))){
+    SWIG_fail_ptr("Session_cb_state_set",2,SWIGTYPE_p_input_callback_state);
+  }
+  
+  if (arg1) (arg1)->cb_state = *arg2;
+  
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Session_cb_state_get(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  input_callback_state *result = 0 ;
+  
+  SWIG_check_num_args("cb_state",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("cb_state",1,"Session *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_cb_state_get",1,SWIGTYPE_p_Session);
+  }
+  
+  result = (input_callback_state *)& ((arg1)->cb_state);
+  SWIG_arg=0;
+  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_Session_hook_state_set(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  switch_channel_state_t arg2 ;
+  switch_channel_state_t *argp2 ;
+  
+  SWIG_check_num_args("hook_state",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("hook_state",1,"Session *");
+  if(!lua_isuserdata(L,2)) SWIG_fail_arg("hook_state",2,"switch_channel_state_t");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_hook_state_set",1,SWIGTYPE_p_Session);
+  }
+  
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_switch_channel_state_t,0))){
+    SWIG_fail_ptr("Session_hook_state_set",2,SWIGTYPE_p_switch_channel_state_t);
+  }
+  arg2 = *argp2;
+  
+  if (arg1) (arg1)->hook_state = arg2;
+  
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Session_hook_state_get(lua_State* L) {
+  int SWIG_arg = -1;
+  Session *arg1 = (Session *) 0 ;
+  switch_channel_state_t result;
+  
+  SWIG_check_num_args("hook_state",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("hook_state",1,"Session *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Session,0))){
+    SWIG_fail_ptr("Session_hook_state_get",1,SWIGTYPE_p_Session);
+  }
+  
+  result =  ((arg1)->hook_state);
+  SWIG_arg=0;
+  {
+    switch_channel_state_t * resultptr = new switch_channel_state_t((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 void swig_delete_Session(void *obj) {
+Session *arg1 = (Session *) obj;
+delete arg1;
+}
+static swig_lua_method swig_Session_methods[] = {
+    {"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}, 
+    {0,0}
+};
+static swig_lua_attribute swig_Session_attributes[] = {
+    { "session", _wrap_Session_session_get, _wrap_Session_session_set},
+    { "channel", _wrap_Session_channel_get, _wrap_Session_channel_set},
+    { "flags", _wrap_Session_flags_get, _wrap_Session_flags_set},
+    { "allocated", _wrap_Session_allocated_get, _wrap_Session_allocated_set},
+    { "cb_state", _wrap_Session_cb_state_get, _wrap_Session_cb_state_set},
+    { "hook_state", _wrap_Session_hook_state_get, _wrap_Session_hook_state_set},
+    {0,0,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", &SWIGTYPE_p_Session,_wrap_new_Session, swig_delete_Session, swig_Session_methods, swig_Session_attributes, swig_Session_bases, swig_Session_base_names };
+
+#ifdef __cplusplus
+}
+#endif
+
+static const struct luaL_reg swig_commands[] = {
+    { "console_log", _wrap_console_log},
+    { "console_clean_log", _wrap_console_clean_log},
+    { "api_execute", _wrap_api_execute},
+    { "api_reply_delete", _wrap_api_reply_delete},
+    { "process_callback_result", _wrap_process_callback_result},
+    { "bridge", _wrap_bridge},
+    { "hanguphook", _wrap_hanguphook},
+    { "dtmf_callback", _wrap_dtmf_callback},
+    {0,0}
+};
+
+static swig_lua_var_info swig_variables[] = {
+    {0,0,0}
+};
+
+static swig_lua_const_info swig_constants[] = {
+{ SWIG_LUA_INT,     (char *)"S_HUP", (long) S_HUP, 0, 0, 0},
+{ SWIG_LUA_INT,     (char *)"S_FREE", (long) S_FREE, 0, 0, 0},
+{ SWIG_LUA_INT,     (char *)"S_RDLOCK", (long) S_RDLOCK, 0, 0, 0},
+    {0,0,0,0,0,0}
+};
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
+
+static void *_p_SessionTo_p_CoreSession(void *x, int *newmemory) {
+    return (void *)((CoreSession *)  ((Session *) x));
+}
+static swig_type_info _swigt__p_CoreSession = {"_p_CoreSession", "CoreSession *", 0, 0, (void*)&_wrap_class_CoreSession, 0};
+static swig_type_info _swigt__p_Event = {"_p_Event", "Event *", 0, 0, (void*)&_wrap_class_Event, 0};
+static swig_type_info _swigt__p_Session = {"_p_Session", "Session *", 0, 0, (void*)&_wrap_class_Session, 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_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_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_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_size_t = {"_p_switch_size_t", "switch_size_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_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
+
+static swig_type_info *swig_type_initial[] = {
+  &_swigt__p_CoreSession,
+  &_swigt__p_Event,
+  &_swigt__p_Session,
+  &_swigt__p_Stream,
+  &_swigt__p_input_callback_state,
+  &_swigt__p_session_flag_t,
+  &_swigt__p_switch_channel_state_t,
+  &_swigt__p_switch_channel_t,
+  &_swigt__p_switch_core_session_t,
+  &_swigt__p_switch_input_args_t,
+  &_swigt__p_switch_input_type_t,
+  &_swigt__p_switch_priority_t,
+  &_swigt__p_switch_size_t,
+  &_swigt__p_switch_status_t,
+  &_swigt__p_switch_stream_handle_t,
+  &_swigt__p_void,
+};
+
+static swig_cast_info _swigc__p_CoreSession[] = {  {&_swigt__p_CoreSession, 0, 0, 0},  {&_swigt__p_Session, _p_SessionTo_p_CoreSession, 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_Session[] = {  {&_swigt__p_Session, 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_session_flag_t[] = {  {&_swigt__p_session_flag_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_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_size_t[] = {  {&_swigt__p_switch_size_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_void[] = {  {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
+
+static swig_cast_info *swig_cast_initial[] = {
+  _swigc__p_CoreSession,
+  _swigc__p_Event,
+  _swigc__p_Session,
+  _swigc__p_Stream,
+  _swigc__p_input_callback_state,
+  _swigc__p_session_flag_t,
+  _swigc__p_switch_channel_state_t,
+  _swigc__p_switch_channel_t,
+  _swigc__p_switch_core_session_t,
+  _swigc__p_switch_input_args_t,
+  _swigc__p_switch_input_type_t,
+  _swigc__p_switch_priority_t,
+  _swigc__p_switch_size_t,
+  _swigc__p_switch_status_t,
+  _swigc__p_switch_stream_handle_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 staticly 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;
+
+  clientdata = clientdata;
+
+  /* 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 interpeters 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 eariler #define will rename it
+*/
+SWIGEXPORT int SWIG_init(lua_State* L)
+{
+  int i;
+  /* start with global table */
+  lua_pushvalue(L,LUA_GLOBALSINDEX);
+  /* SWIG's internal initalisation */
+  SWIG_InitializeModule((void*)L);
+  SWIG_PropagateClientData();
+  /* add a global fn */
+  SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);
+  SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal);
+  /* begin the module (its a table with the same name as the module) */
+  SWIG_Lua_module_begin(L,SWIG_name);
+  /* add commands/functions */
+  for (i = 0; swig_commands[i].name; i++){
+    SWIG_Lua_module_add_function(L,swig_commands[i].name,swig_commands[i].func);
+  }
+  /* add variables */
+  for (i = 0; swig_variables[i].name; i++){
+    SWIG_Lua_module_add_variable(L,swig_variables[i].name,swig_variables[i].get,swig_variables[i].set);
+  }
+  /* set up base class pointers (the hierachy) */
+  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));
+    }
+  }
+  /* additional registration structs & classes in lua */
+  for (i = 0; swig_types[i]; i++){
+    if (swig_types[i]->clientdata){
+      SWIG_Lua_class_register(L,(swig_lua_class*)(swig_types[i]->clientdata));
+    }
+  }
+  /* constants */
+  SWIG_Lua_InstallConstants(L,swig_constants);
+  /* invoke user-specific initialization */
+  SWIG_init_user(L);
+  /* end module */
+  lua_pop(L,1);  /* tidy stack (remove module table)*/
+  lua_pop(L,1);  /* tidy stack (remove global table)*/
+  return 1;
+}
+
+#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);
+}
+



More information about the Freeswitch-svn mailing list