[glib/gobject-speedups2: 22/23] value: Add G_VALUE_COLLECT_INIT2
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/gobject-speedups2: 22/23] value: Add G_VALUE_COLLECT_INIT2
- Date: Sat, 21 May 2022 11:31:00 +0000 (UTC)
commit fc30eacc8fa94b3e6685ce391e5ed377c53914d1
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 20 07:53:42 2022 -0400
value: Add G_VALUE_COLLECT_INIT2
Add a variant of the G_VALUE_COLLECT_INIT() macro
that provides the GTypeValueTable to the caller.
gobject/gvaluecollector.h | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/gobject/gvaluecollector.h b/gobject/gvaluecollector.h
index 82e675cdd9..5846d77a76 100644
--- a/gobject/gvaluecollector.h
+++ b/gobject/gvaluecollector.h
@@ -87,15 +87,38 @@ union _GTypeCValue
*
* Since: 2.24
*/
-#define G_VALUE_COLLECT_INIT(value, _value_type, var_args, flags, __error) \
+#define G_VALUE_COLLECT_INIT(value, _value_type, var_args, flags, __error) \
+ G_STMT_START { \
+ GTypeValueTable *g_vci_vtab; \
+ G_VALUE_COLLECT_INIT2(value, g_vci_vtab, _value_type, var_args, flags, __error); \
+} G_STMT_END
+
+/**
+ * G_VALUE_COLLECT_INIT2:
+ * @value: a #GValue return location. @value must contain only 0 bytes.
+ * @g_vci_vtab: a #GTypeValueTable pointer that will be set to the value table
+ * for @_value_type
+ * @_value_type: the #GType to use for @value.
+ * @var_args: the va_list variable; it may be evaluated multiple times
+ * @flags: flags which are passed on to the collect_value() function of
+ * the #GTypeValueTable of @value.
+ * @__error: a #gchar** variable that will be modified to hold a g_new()
+ * allocated error messages if something fails
+ *
+ * A variant of G_VALUE_COLLECT_INIT() that provides the #GTypeValueTable
+ * to the caller.
+ *
+ * Since: 2.74
+ */
+#define G_VALUE_COLLECT_INIT2(value, g_vci_vtab, _value_type, var_args, flags, __error) \
G_STMT_START { \
GValue *g_vci_val = (value); \
guint g_vci_flags = (flags); \
- GTypeValueTable *g_vci_vtab = g_type_value_table_peek (_value_type); \
- const gchar *g_vci_collect_format = g_vci_vtab->collect_format; \
+ const gchar *g_vci_collect_format; \
GTypeCValue g_vci_cvalues[G_VALUE_COLLECT_FORMAT_MAX_LENGTH] = { { 0, }, }; \
guint g_vci_n_values = 0; \
- \
+ g_vci_vtab = g_type_value_table_peek (_value_type); \
+ g_vci_collect_format = g_vci_vtab->collect_format; \
g_vci_val->g_type = _value_type; /* value_meminit() from gvalue.c */ \
while (*g_vci_collect_format) \
{ \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]