[glib] g_type_check_value, g_type_check_value_holds: accept const argument
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] g_type_check_value, g_type_check_value_holds: accept const argument
- Date: Wed, 13 Dec 2017 17:15:49 +0000 (UTC)
commit 0c0b1bdd0a5a30caba8682dd49c81c072f9ffa29
Author: Simon McVittie <simon mcvittie collabora co uk>
Date: Fri Aug 8 12:01:10 2014 +0100
g_type_check_value, g_type_check_value_holds: accept const argument
Conceptually, these functions clearly ought to be fine for a const
structure. This avoids _G_TYPE_CVH (the implementation of
G_TYPE_CHECK_VALUE_TYPE, G_VALUE_HOLDS, G_VALUE_HOLDS_BOXED etc.)
needing to cast to a mutable GValue, which causes
G_VALUE_HOLDS (cv, type) to issue warnings under gcc -Wcast-qual if
cv is a const GValue *.
https://bugzilla.gnome.org/show_bug.cgi?id=734479
gobject/gtype.c | 6 +++---
gobject/gtype.h | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/gobject/gtype.c b/gobject/gtype.c
index b0f12f6..275a8b6 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -4193,14 +4193,14 @@ g_type_check_is_value_type (GType type)
}
gboolean
-g_type_check_value (GValue *value)
+g_type_check_value (const GValue *value)
{
return value && type_check_is_value_type_U (value->g_type);
}
gboolean
-g_type_check_value_holds (GValue *value,
- GType type)
+g_type_check_value_holds (const GValue *value,
+ GType type)
{
return value && type_check_is_value_type_U (value->g_type) && g_type_is_a (value->g_type, type);
}
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 89c1bec..f771c07 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -2202,9 +2202,9 @@ gboolean g_type_check_class_is_a (GTypeClass *g_class,
GLIB_AVAILABLE_IN_ALL
gboolean g_type_check_is_value_type (GType type) G_GNUC_CONST;
GLIB_AVAILABLE_IN_ALL
-gboolean g_type_check_value (GValue *value) G_GNUC_PURE;
+gboolean g_type_check_value (const GValue *value) G_GNUC_PURE;
GLIB_AVAILABLE_IN_ALL
-gboolean g_type_check_value_holds (GValue *value,
+gboolean g_type_check_value_holds (const GValue *value,
GType type) G_GNUC_PURE;
GLIB_AVAILABLE_IN_ALL
gboolean g_type_test_flags (GType type,
@@ -2255,7 +2255,7 @@ const gchar * g_type_name_from_class (GTypeClass *g_class);
__r; \
}))
# define _G_TYPE_CVH(vl, gt) (G_GNUC_EXTENSION ({ \
- GValue *__val = (GValue*) vl; GType __t = gt; gboolean __r; \
+ const GValue *__val = (const GValue*) vl; GType __t = gt; gboolean __r; \
if (!__val) \
__r = FALSE; \
else if (__val->g_type == __t) \
@@ -2267,7 +2267,7 @@ const gchar * g_type_name_from_class (GTypeClass *g_class);
#else /* !__GNUC__ */
# define _G_TYPE_CIT(ip, gt) (g_type_check_instance_is_a ((GTypeInstance*) ip, gt))
# define _G_TYPE_CCT(cp, gt) (g_type_check_class_is_a ((GTypeClass*) cp, gt))
-# define _G_TYPE_CVH(vl, gt) (g_type_check_value_holds ((GValue*) vl, gt))
+# define _G_TYPE_CVH(vl, gt) (g_type_check_value_holds ((const GValue*) vl, gt))
#endif /* !__GNUC__ */
/**
* G_TYPE_FLAG_RESERVED_ID_BIT:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]