MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / mp_encode_lua_table_as_array

Function mp_encode_lua_table_as_array

deps/lua/src/lua_cmsgpack.c:380–394  ·  view source on GitHub ↗

Convert a lua table into a message pack list. */

Source from the content-addressed store, hash-verified

378
379/* Convert a lua table into a message pack list. */
380void mp_encode_lua_table_as_array(lua_State *L, mp_buf *buf, int level) {
381#if LUA_VERSION_NUM < 502
382 size_t len = lua_objlen(L,-1), j;
383#else
384 size_t len = lua_rawlen(L,-1), j;
385#endif
386
387 mp_encode_array(L,buf,len);
388 luaL_checkstack(L, 1, "in function mp_encode_lua_table_as_array");
389 for (j = 1; j <= len; j++) {
390 lua_pushnumber(L,j);
391 lua_gettable(L,-2);
392 mp_encode_lua_type(L,buf,level+1);
393 }
394}
395
396/* Convert a lua table into a message pack key-value map. */
397void mp_encode_lua_table_as_map(lua_State *L, mp_buf *buf, int level) {

Callers 1

mp_encode_lua_tableFunction · 0.85

Calls 6

lua_objlenFunction · 0.85
mp_encode_arrayFunction · 0.85
luaL_checkstackFunction · 0.85
lua_pushnumberFunction · 0.85
lua_gettableFunction · 0.85
mp_encode_lua_typeFunction · 0.85

Tested by

no test coverage detected