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

Function copy_state_table

lua/sp.c:2928–2964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2926}
2927
2928static int copy_state_table(lua_State *lua1, lua_State *lua2, int i,
2929 int allow_tmptbl, hash_t *tmptbls)
2930{
2931 int type;
2932 lua_newtable(lua2);
2933 int new_table = lua_gettop(lua2);
2934 lua_pushnil(lua1);
2935 while (lua_next(lua1, i) != 0) {
2936 type = lua_type(lua1, -2);
2937 if (type == LUA_TUSERDATA) {
2938 copy_comdb2_type(lua1, lua2, -2, allow_tmptbl, tmptbls);
2939 } else if (lua_isnumber(lua1, -2)) {
2940 double num = lua_tonumber(lua1, -2);
2941 lua_pushnumber(lua2, num);
2942 } else {
2943 const char *arg = lua_tostring(lua1, -2);
2944 lua_pushstring(lua2, arg);
2945 }
2946
2947 type = lua_type(lua1, -1);
2948 if (type == LUA_TUSERDATA) {
2949 copy_comdb2_type(lua1, lua2, -1, allow_tmptbl, tmptbls);
2950 } else if (lua_isnumber(lua1, -1)) {
2951 double num = lua_tonumber(lua1, -1);
2952 lua_pushnumber(lua2, num);
2953 } else if (lua_istable(lua1, -1)) {
2954 int num = lua_gettop(lua1);
2955 copy_state_table(lua1, lua2, num, allow_tmptbl, tmptbls);
2956 } else {
2957 const char *arg = lua_tostring(lua1, -1);
2958 lua_pushstring(lua2, arg);
2959 }
2960 lua_settable(lua2, new_table);
2961 lua_pop(lua1, 1);
2962 }
2963 return 0;
2964}
2965
2966static int copy_state_stacks(Lua lua1, Lua lua2, int allow_tmptbl)
2967{

Callers 1

copy_state_stacksFunction · 0.85

Calls 10

lua_gettopFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
lua_typeFunction · 0.85
copy_comdb2_typeFunction · 0.85
lua_isnumberFunction · 0.85
lua_tonumberFunction · 0.85
lua_pushnumberFunction · 0.85
lua_pushstringFunction · 0.85
lua_settableFunction · 0.85

Tested by

no test coverage detected