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

Function copy_state_stacks

lua/sp.c:2966–2995  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2964}
2965
2966static int copy_state_stacks(Lua lua1, Lua lua2, int allow_tmptbl)
2967{
2968 hash_t *tmptbls = NULL;
2969 if (allow_tmptbl) {
2970 tmptbls = hash_init_str(0);
2971 }
2972 int num_returns = lua_gettop(lua1);
2973 for (int i = 1; i <= num_returns; i++) {
2974 int type = lua_type(lua1, i);
2975 if (type == LUA_TUSERDATA) {
2976 copy_comdb2_type(lua1, lua2, i, allow_tmptbl, tmptbls);
2977 } else if (lua_istable(lua1, i)) {
2978 copy_state_table(lua1, lua2, i, allow_tmptbl, tmptbls);
2979 lua_settop(lua1, num_returns);
2980 } else if (lua_isnumber(lua1, i)) {
2981 double num = lua_tonumber(lua1, i);
2982 lua_pushnumber(lua2, num);
2983 } else {
2984 const char *arg = lua_tostring(lua1, i);
2985 if (arg == NULL)
2986 lua_pushnil(lua2);
2987 else
2988 lua_pushstring(lua2, arg);
2989 }
2990 }
2991 if (tmptbls) {
2992 hash_free(tmptbls);
2993 }
2994 return num_returns;
2995}
2996
2997static int get_func_by_ref(Lua L, const char *entry, char **err)
2998{

Callers 2

db_create_thread_intFunction · 0.85
dbthread_joinFunction · 0.85

Calls 12

hash_init_strFunction · 0.85
lua_gettopFunction · 0.85
lua_typeFunction · 0.85
copy_comdb2_typeFunction · 0.85
copy_state_tableFunction · 0.85
lua_settopFunction · 0.85
lua_isnumberFunction · 0.85
lua_tonumberFunction · 0.85
lua_pushnumberFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushstringFunction · 0.85
hash_freeFunction · 0.85

Tested by

no test coverage detected