The value of `key` in a mapping; a null node for none. */
| 97 | |
| 98 | /* The value of `key` in a mapping; a null node for none. */ |
| 99 | static TSNode oa_get(const CBMExtractCtx *ctx, TSNode map, const char *key) { |
| 100 | char k[OA_SCALAR_MAX]; |
| 101 | uint32_t nc = ts_node_is_null(map) ? 0 : ts_node_named_child_count(map); |
| 102 | for (uint32_t i = 0; i < nc; i++) { |
| 103 | TSNode p = ts_node_named_child(map, i); |
| 104 | if (oa_pair(p) && |
| 105 | oa_scalar(ctx, ts_node_child_by_field_name(p, "key", CBM_SZ_3), k, sizeof(k)) && |
| 106 | strcmp(k, key) == 0) { |
| 107 | return ts_node_child_by_field_name(p, "value", CBM_SZ_5); |
| 108 | } |
| 109 | } |
| 110 | return (TSNode){0}; |
| 111 | } |
| 112 | |
| 113 | static const char *oa_dup_scalar(const CBMExtractCtx *ctx, TSNode n) { |
| 114 | char v[OA_SCALAR_MAX]; |
no test coverage detected