MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / emit_result

Function emit_result

lua/sp.c:6832–6861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6830}
6831
6832static int emit_result(Lua L, long long *sprc, char **err)
6833{
6834 const char *retstr = NULL;
6835 dbtable_t *rettab = NULL;
6836 long long retnum = 0;
6837 int retargs = lua_gettop(L);
6838 for (int i = 1; i <= retargs; ++i) {
6839 switch (luabb_dbtype(L, i)) {
6840 case DBTYPES_LSTRING:
6841 case DBTYPES_CSTRING: retstr = luabb_tostring(L, i); break;
6842 case DBTYPES_LNUMBER:
6843 case DBTYPES_INTEGER: luabb_tointeger(L, i, &retnum); break;
6844 case DBTYPES_DBTABLE: rettab = lua_touserdata(L, i); break;
6845 default:
6846 // TODO FIXME XXX: silently ignore other types??
6847 break;
6848 }
6849 }
6850 // lua_settop(L, 0); -- not necessary, right??
6851
6852 if (rettab) dbtable_emit_int(L, rettab);
6853
6854 if (retnum && (retnum < -299 || retnum > -200)) retnum = -200;
6855 *sprc = retnum;
6856
6857 if (retstr) retstr = strdup(retstr);
6858 *err = (char *)retstr;
6859
6860 return 0;
6861}
6862
6863struct sp_state {
6864 SP sp;

Callers 1

exec_procedure_intFunction · 0.85

Calls 6

lua_gettopFunction · 0.85
luabb_tostringFunction · 0.85
luabb_tointegerFunction · 0.85
lua_touserdataFunction · 0.85
dbtable_emit_intFunction · 0.85
strdupFunction · 0.50

Tested by

no test coverage detected