Created
November 29, 2016 11:29
-
-
Save moteus/7b8f7b78abb184771b037d785ae39282 to your computer and use it in GitHub Desktop.
Dbh query with params for FS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%module freeswitch | |
%{ | |
#include "freeswitch_lua.h" | |
%} | |
%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; | |
} | |
%typemap(typecheck) SWIGLUA_FN { | |
$1 = lua_isfunction(L, $input); | |
} | |
%typemap(in, checkfn = "lua_istable") SWIGLUA_TABLE { | |
$1.L = L; | |
$1.idx = $input; | |
} | |
%typemap(default) SWIGLUA_TABLE { | |
SWIGLUA_TABLE default_swiglua_table = { 0 }; | |
$1 = default_swiglua_table; | |
} | |
%typemap(typecheck) SWIGLUA_TABLE { | |
$1 = lua_istable(L, $input); | |
} | |
class Dbh { | |
public: | |
Dbh(char *dsn, char *user = NULL, char *pass = NULL); | |
bool query(char *sql, SWIGLUA_FN lua_fun); | |
bool query(char *sql, SWIGLUA_TABLE lua_params); | |
bool query(char *sql, SWIGLUA_TABLE lua_params, SWIGLUA_FN lua_fun); | |
}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dbh:query('1'); -- bool query(char *sql, SWIGLUA_FN lua_fun); | |
dbh:query('2', {}) -- bool query(char *sql, SWIGLUA_TABLE lua_params); | |
dbh:query('3', {}, function() end) -- bool query(char *sql, SWIGLUA_TABLE lua_params, SWIGLUA_FN lua_fun); | |
dbh:query('4', function() end) -- bool query(char *sql, SWIGLUA_FN lua_fun); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment