From 6f6cd375ad0f11488d7ccc951f5376c6547e9999 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 11 Aug 2008 18:47:30 +0000 Subject: [PATCH] tweak for MODLANG-77 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9244 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/languages/mod_lua/freeswitch_lua.cpp | 11 ++++-- src/mod/languages/mod_lua/freeswitch_lua.h | 1 + src/mod/languages/mod_lua/mod_lua_wrap.cpp | 38 +++++++++++++++++++ .../languages/mod_perl/freeswitch_perl.cpp | 2 +- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/mod/languages/mod_lua/freeswitch_lua.cpp b/src/mod/languages/mod_lua/freeswitch_lua.cpp index eb86e66d48..1e5b8ef2c8 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.cpp +++ b/src/mod/languages/mod_lua/freeswitch_lua.cpp @@ -50,16 +50,21 @@ bool Session::end_allow_threads() void Session::setLUA(lua_State * state) { - sanity_check_noreturn; - L = state; - if (uuid) { + + if (session && allocated && uuid) { lua_setglobal(L, uuid); lua_getfield(L, LUA_GLOBALSINDEX, uuid); } } +void Session::originate(CoreSession *a_leg_session, char *dest, int timeout) +{ + CoreSession::originate(a_leg_session, dest, timeout); + setLUA(L); +} + lua_State *Session::getLUA() { if (!L) { diff --git a/src/mod/languages/mod_lua/freeswitch_lua.h b/src/mod/languages/mod_lua/freeswitch_lua.h index 0b9b6dbbcd..63f5490db9 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.h +++ b/src/mod/languages/mod_lua/freeswitch_lua.h @@ -32,6 +32,7 @@ class Session : public CoreSession { void setInputCallback(char *cbfunc, char *funcargs = NULL); void setHangupHook(char *func, char *arg = NULL); bool ready(); + void originate(CoreSession *a_leg_session, char *dest, int timeout); char *cb_function; char *cb_arg; diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp index b8430e5db8..6b0bc44e0b 100644 --- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp +++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp @@ -7264,6 +7264,43 @@ fail: } +static int _wrap_Session_originate(lua_State* L) { + int SWIG_arg = -1; + LUA::Session *arg1 = (LUA::Session *) 0 ; + CoreSession *arg2 = (CoreSession *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + + SWIG_check_num_args("originate",4,4) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("originate",1,"LUA::Session *"); + if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("originate",2,"CoreSession *"); + if(!lua_isstring(L,3)) SWIG_fail_arg("originate",3,"char *"); + if(!lua_isnumber(L,4)) SWIG_fail_arg("originate",4,"int"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){ + SWIG_fail_ptr("Session_originate",1,SWIGTYPE_p_LUA__Session); + } + + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_CoreSession,0))){ + SWIG_fail_ptr("Session_originate",2,SWIGTYPE_p_CoreSession); + } + + arg3 = (char *)lua_tostring(L, 3); + arg4 = (int)lua_tonumber(L, 4); + (arg1)->originate(arg2,arg3,arg4); + SWIG_arg=0; + + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static int _wrap_Session_cb_function_set(lua_State* L) { int SWIG_arg = -1; LUA::Session *arg1 = (LUA::Session *) 0 ; @@ -7542,6 +7579,7 @@ static swig_lua_method swig_LUA_Session_methods[] = { {"setInputCallback", _wrap_Session_setInputCallback}, {"setHangupHook", _wrap_Session_setHangupHook}, {"ready", _wrap_Session_ready}, + {"originate", _wrap_Session_originate}, {"setLUA", _wrap_Session_setLUA}, {0,0} }; diff --git a/src/mod/languages/mod_perl/freeswitch_perl.cpp b/src/mod/languages/mod_perl/freeswitch_perl.cpp index 795aa2bec2..ef252fccea 100644 --- a/src/mod/languages/mod_perl/freeswitch_perl.cpp +++ b/src/mod/languages/mod_perl/freeswitch_perl.cpp @@ -72,7 +72,7 @@ bool Session::end_allow_threads() void Session::setPERL(PerlInterpreter * pi) { - sanity_check_noreturn; + my_perl = pi; }