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.
This commit is contained in:
Philip Chimento 2022-01-29 17:54:27 -08:00 committed by Emmanuele Bassi
parent 75b48f1dbe
commit 8f047f11f6
2 changed files with 16 additions and 4 deletions

View File

@ -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);

View File

@ -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