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

Function table_to_cson_array

lua/sp.c:5506–5522  ·  view source on GitHub ↗

value to convert is on top of stack

Source from the content-addressed store, hash-verified

5504
5505// value to convert is on top of stack
5506static cson_value *table_to_cson_array(Lua L, int lvl, json_conv *conv)
5507{
5508 cson_value *v = cson_value_new_array();
5509 cson_array *a = cson_value_get_array(v);
5510 int n = luaL_getn(L, -1);
5511 for (int i = 0; i < n; ++i) {
5512 lua_rawgeti(L, -1, i + 1);
5513 cson_value *val = table_to_cson(L, lvl, conv);
5514 if (val == NULL) {
5515 cson_free_value(v);
5516 return NULL;
5517 }
5518 cson_array_append(a, val);
5519 lua_pop(L, 1);
5520 }
5521 return v;
5522}
5523
5524// value to convert is on top of stack
5525static cson_value *table_to_cson_object(Lua L, int lvl, json_conv *conv)

Callers 1

table_to_csonFunction · 0.85

Calls 7

cson_value_new_arrayFunction · 0.85
cson_value_get_arrayFunction · 0.85
luaL_getnFunction · 0.85
lua_rawgetiFunction · 0.85
table_to_csonFunction · 0.85
cson_free_valueFunction · 0.85
cson_array_appendFunction · 0.85

Tested by

no test coverage detected