From ed0146e7a990b9bd7f628e37ee7c7383ca133cf7 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 31 Mar 2014 08:26:55 +0900 Subject: [PATCH] add pic_data_type_p --- include/picrin/data.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/picrin/data.h b/include/picrin/data.h index 84c2f580..a80ff209 100644 --- a/include/picrin/data.h +++ b/include/picrin/data.h @@ -24,6 +24,10 @@ struct pic_data { #define pic_data_p(o) (pic_type(o) == PIC_TT_DATA) #define pic_data_ptr(o) ((struct pic_data *)pic_ptr(o)) +static inline bool pic_data_type_p(const pic_value obj, const pic_data_type *type) { + return pic_data_p(obj) && pic_data_ptr(obj)->type == type; +} + struct pic_data *pic_data_alloc(pic_state *, const pic_data_type *, void *); #if defined(__cplusplus)