From 8f047f11f64eab1aa91674ca8a1c40e0027b5f0c Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sat, 29 Jan 2022 17:54:27 -0800 Subject: [PATCH] gitypeinfo: Add GI_TYPE_TAG_IS_CONTAINER macro Like GI_TYPE_TAG_IS_NUMERIC, this is a convenience for bindings that want to perform a similar action for all container types. --- gitypeinfo.h | 12 ++++++++++++ gitypes.h | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gitypeinfo.h b/gitypeinfo.h index 69d0dad60..a8674fd9b 100644 --- a/gitypeinfo.h +++ b/gitypeinfo.h @@ -58,6 +58,18 @@ G_BEGIN_DECLS */ #define GI_TYPE_TAG_IS_NUMERIC(tag) ((tag) >= GI_TYPE_TAG_INT8 && (tag) <= GI_TYPE_TAG_DOUBLE) +/** + * GI_TYPE_TAG_IS_CONTAINER: + * @tag: a type tag + * + * Checks if @tag is a container type. That is, a type which may have a nonnull + * return from g_type_info_get_param_type(). + * + * Since: 1.72 + */ + #define GI_TYPE_TAG_IS_CONTAINER(tag) ((tag) == GI_TYPE_TAG_ARRAY || \ + ((tag) >= GI_TYPE_TAG_GLIST && (tag) <= GI_TYPE_TAG_GHASH)) + GI_AVAILABLE_IN_ALL const gchar* g_type_tag_to_string (GITypeTag type); diff --git a/gitypes.h b/gitypes.h index 47df79039..9c021ff23 100644 --- a/gitypes.h +++ b/gitypes.h @@ -425,11 +425,11 @@ typedef enum { GI_TYPE_TAG_UTF8 = 13, GI_TYPE_TAG_FILENAME = 14, /* Non-basic types; compare with G_TYPE_TAG_IS_BASIC */ - GI_TYPE_TAG_ARRAY = 15, + GI_TYPE_TAG_ARRAY = 15, /* container (see GI_TYPE_TAG_IS_CONTAINER) */ GI_TYPE_TAG_INTERFACE = 16, - GI_TYPE_TAG_GLIST = 17, - GI_TYPE_TAG_GSLIST = 18, - GI_TYPE_TAG_GHASH = 19, + GI_TYPE_TAG_GLIST = 17, /* container */ + GI_TYPE_TAG_GSLIST = 18, /* container */ + GI_TYPE_TAG_GHASH = 19, /* container */ GI_TYPE_TAG_ERROR = 20, /* Another basic type */ GI_TYPE_TAG_UNICHAR = 21