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

Function table_to_cson_object

lua/sp.c:5525–5544  ·  view source on GitHub ↗

value to convert is on top of stack

Source from the content-addressed store, hash-verified

5523
5524// value to convert is on top of stack
5525static cson_value *table_to_cson_object(Lua L, int lvl, json_conv *conv)
5526{
5527 cson_value *v = cson_value_new_object();
5528 cson_object *o = cson_value_get_object(v);
5529 lua_pushnil(L);
5530 while (lua_next(L, -2)) {
5531 cson_value *val = table_to_cson(L, lvl, conv); // get value
5532 if (val == NULL) {
5533 cson_free_value(v);
5534 return NULL;
5535 }
5536 lua_pop(L, 1); // remove value
5537
5538 lua_pushvalue(L, -1); // push copy of key
5539 const char *key = luabb_tostring(L, -1); // conv key to str
5540 cson_object_set(o, key, val);
5541 lua_pop(L, 1); // pop copy of key (now a string)
5542 }
5543 return v;
5544}
5545
5546static int is_array(Lua L)
5547{

Callers 1

table_to_csonFunction · 0.85

Calls 9

cson_value_new_objectFunction · 0.85
cson_value_get_objectFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
table_to_csonFunction · 0.85
cson_free_valueFunction · 0.85
lua_pushvalueFunction · 0.85
luabb_tostringFunction · 0.85
cson_object_setFunction · 0.85

Tested by

no test coverage detected