[glib/param-speedups2: 2/4] param: Add g_param_value_is_valid
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/param-speedups2: 2/4] param: Add g_param_value_is_valid
- Date: Fri, 20 May 2022 12:54:32 +0000 (UTC)
commit ebec3625b32f0d4bcd656d9e95e14177ef597e82
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 20 08:46:39 2022 -0400
param: Add g_param_value_is_valid
This is wrapper for the new value_is_valid vfunc.
gobject/gparam.c | 27 +++++++++++++++++++++++++++
gobject/gparam.h | 3 +++
2 files changed, 30 insertions(+)
---
diff --git a/gobject/gparam.c b/gobject/gparam.c
index e9d9eacb07..5c75f2781f 100644
--- a/gobject/gparam.c
+++ b/gobject/gparam.c
@@ -705,6 +705,33 @@ g_param_value_validate (GParamSpec *pspec,
return FALSE;
}
+/**
+ * g_param_value_is_valid:
+ * @pspec: a valid #GParamSpec
+ * @value: a #GValue of correct type for @pspec
+ *
+ * Return whether the contents of @value comply with the specifications
+ * set out by @pspec.
+ *
+ * Returns: whether the contents of @value comply with the specifications
+ * set out by @pspec.
+ *
+ * Since: 2.74
+ */
+gboolean
+g_param_value_is_valid (GParamSpec *pspec,
+ const GValue *value)
+{
+ g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), TRUE);
+ g_return_val_if_fail (G_IS_VALUE (value), TRUE);
+ g_return_val_if_fail (PSPEC_APPLIES_TO_VALUE (pspec, value), TRUE);
+
+ if (G_PARAM_SPEC_GET_CLASS (pspec)->value_is_valid)
+ return G_PARAM_SPEC_GET_CLASS (pspec)->value_is_valid (pspec, value);
+
+ return TRUE;
+}
+
/**
* g_param_value_convert:
* @pspec: a valid #GParamSpec
diff --git a/gobject/gparam.h b/gobject/gparam.h
index fea6e502c8..8eae66b663 100644
--- a/gobject/gparam.h
+++ b/gobject/gparam.h
@@ -320,6 +320,9 @@ gboolean g_param_value_defaults (GParamSpec *pspec,
GLIB_AVAILABLE_IN_ALL
gboolean g_param_value_validate (GParamSpec *pspec,
GValue *value);
+GLIB_AVAILABLE_IN_2_74
+gboolean g_param_value_is_valid (GParamSpec *pspec,
+ const GValue *value);
GLIB_AVAILABLE_IN_ALL
gboolean g_param_value_convert (GParamSpec *pspec,
const GValue *src_value,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]