Made 2nd arg to freeswitch.Dbh:query (cb func) optional

This commit is contained in:
Leon de Rooij 2010-09-10 01:36:27 +02:00
parent 5a6f0f5c37
commit 87db11afe0
3 changed files with 1508 additions and 2703 deletions

View File

@ -19,8 +19,15 @@
/* Lua function typemap */
%typemap(in,checkfn="lua_isfunction") SWIGLUA_FN
%{ $1.L=L; $1.idx=$input; %}
%typemap(in, checkfn = "lua_isfunction") SWIGLUA_FN {
$1.L = L;
$1.idx = $input;
}
%typemap(default) SWIGLUA_FN {
SWIGLUA_FN default_swiglua_fn = { 0 };
$1 = default_swiglua_fn;
}
%ignore SwitchToMempool;

View File

@ -367,10 +367,15 @@ int Dbh::query_callback(void *pArg, int argc, char **argv, char **cargv)
bool Dbh::query(char *sql, SWIGLUA_FN lua_fun)
{
if (connected) {
if (switch_cache_db_execute_sql_callback(dbh, sql, query_callback, &lua_fun, NULL) == SWITCH_STATUS_SUCCESS) {
return true;
if (lua_fun.L && lua_fun.idx != 0) {
if (switch_cache_db_execute_sql_callback(dbh, sql, query_callback, &lua_fun, NULL) == SWITCH_STATUS_SUCCESS) {
return true;
}
} else { /* if no lua_fun arg is passed from Lua, an empty initialized struct will be sent - see freeswitch.i */
if (switch_cache_db_execute_sql(dbh, sql, NULL) == SWITCH_STATUS_SUCCESS) {
return true;
}
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "no workie workie :(\n");
return false;
}

File diff suppressed because it is too large Load Diff