[gobject-introspection] gitypeinfo: Add GI_TYPE_TAG_IS_CONTAINER macro
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] gitypeinfo: Add GI_TYPE_TAG_IS_CONTAINER macro
- Date: Sun, 13 Feb 2022 12:32:17 +0000 (UTC)
commit 37b1f4dad7a495d45fe93d0849e02e59372f9700
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Jan 29 17:54:27 2022 -0800
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.
girepository/gitypeinfo.h | 12 ++++++++++++
girepository/gitypes.h | 8 ++++----
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]