| 2964 | } |
| 2965 | |
| 2966 | static 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 | |
| 2997 | static int get_func_by_ref(Lua L, const char *entry, char **err) |
| 2998 | { |
no test coverage detected