plugin is NULL if we're just doing --print-docs */
| 2034 | |
| 2035 | /* plugin is NULL if we're just doing --print-docs */ |
| 2036 | static void init_tablemap(struct plugin *plugin, tablemap *tablemap) |
| 2037 | { |
| 2038 | const jsmntok_t *toks, *t; |
| 2039 | const tal_t *ctx; |
| 2040 | size_t i; |
| 2041 | |
| 2042 | if (plugin) |
| 2043 | ctx = plugin; |
| 2044 | else |
| 2045 | ctx = tmpctx; |
| 2046 | |
| 2047 | strmap_init(tablemap); |
| 2048 | |
| 2049 | toks = json_parse_simple(tmpctx, schemas, strlen(schemas)); |
| 2050 | json_for_each_obj(i, t, toks) { |
| 2051 | struct table_desc *td; |
| 2052 | const jsmntok_t *cmd, *items, *type; |
| 2053 | |
| 2054 | /* First member of properties object is command. */ |
| 2055 | cmd = json_get_member(schemas, t+1, "properties") + 1; |
| 2056 | |
| 2057 | /* We assume it's an object containing an array of objects */ |
| 2058 | items = json_get_member(schemas, cmd + 1, "items"); |
| 2059 | type = json_get_member(schemas, items, "type"); |
| 2060 | assert(json_tok_streq(schemas, type, "object")); |
| 2061 | |
| 2062 | td = new_table_desc(ctx, tablemap, NULL, t, cmd, false); |
| 2063 | add_table_object(tablemap, td, items); |
| 2064 | td->has_created_index = find_column(td, "created_index"); |
| 2065 | |
| 2066 | if (plugin) |
| 2067 | finish_td(plugin, td); |
| 2068 | } |
| 2069 | } |
| 2070 | |
| 2071 | static void memleak_mark_tablemap(struct plugin *p, struct htable *memtable) |
| 2072 | { |
no test coverage detected