summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2022-01-29 17:54:27 -0800
committerEmmanuele Bassi <ebassi@gmail.com>2022-02-13 12:25:18 +0000
commit37b1f4dad7a495d45fe93d0849e02e59372f9700 (patch)
tree32283d3ad1ceaf839339e9d26f820b4cbe6f7828
parentd553ef85919732f8f79401f77ac5bd7a00ae3fb9 (diff)
downloadgobject-introspection-37b1f4dad7a495d45fe93d0849e02e59372f9700.tar.gz
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.
-rw-r--r--girepository/gitypeinfo.h12
-rw-r--r--girepository/gitypes.h8
2 files changed, 16 insertions, 4 deletions
diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h
index 69d0dad6..a8674fd9 100644
--- a/girepository/gitypeinfo.h
+++ b/girepository/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/girepository/gitypes.h b/girepository/gitypes.h
index 47df7903..9c021ff2 100644
--- a/girepository/gitypes.h
+++ b/girepository/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