diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-09-11 17:13:27 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-09-11 17:13:27 +0200 |
commit | 4c93881a1e1d0da4f2125735c9d0de4387c92046 (patch) | |
tree | c32fb001547644c806b51bf0e79898745ae390fe | |
parent | 8ed4e3457904eb4dacc193d0152e690ab3b2ffdb (diff) |
ast: implement inline ut_is_type() helper
The ut_is_type() function simplifies checking the extended tag type of a
given JSON object value.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | ast.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -109,6 +109,12 @@ static inline uint32_t ut_get_off(struct ut_state *s, struct ut_op *op) { return op ? (op - s->pool + 1) : 0; }; +static inline bool ut_is_type(struct json_object *val, int type) { + struct ut_op *tag = json_object_get_userdata(val); + + return (tag && tag->type == type); +}; + uint32_t ut_new_op(struct ut_state *s, int type, struct json_object *val, ...); uint32_t ut_wrap_op(struct ut_state *s, uint32_t parent, ...); uint32_t ut_append_op(struct ut_state *s, uint32_t a, uint32_t b); |