[template-glib: 3/4] Improved docs, NULL strv when emptied
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [template-glib: 3/4] Improved docs, NULL strv when emptied
- Date: Mon, 5 Feb 2018 04:07:44 +0000 (UTC)
commit 19a1f1e4bfe042474ca9192a8801e0f4b9603d34
Author: Zander Brown <ajhb2001 outlook com>
Date: Sun Feb 4 12:30:58 2018 +0000
Improved docs, NULL strv when emptied
src/tmpl-iterator.c | 8 +++++---
src/tmpl-scope.c | 2 ++
src/tmpl-symbol.c | 9 +++++++++
3 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/tmpl-iterator.c b/src/tmpl-iterator.c
index f7cc97d..d7e3323 100644
--- a/src/tmpl-iterator.c
+++ b/src/tmpl-iterator.c
@@ -67,6 +67,10 @@ strv_move_next (TmplIterator *iter)
{
gchar **strv = iter->instance;
iter->data1 = GINT_TO_POINTER (index);
+ if (!strv[index])
+ {
+ iter->instance = NULL;
+ }
return strv[index] != 0;
}
@@ -174,10 +178,8 @@ tmpl_iterator_init (TmplIterator *iter,
iter->destroy = NULL;
iter->data1 = GINT_TO_POINTER (-1);
}
- else if (G_VALUE_HOLDS_BOXED(value))
+ else if (G_VALUE_HOLDS (value, G_TYPE_STRV))
{
- // TODO: On the basis more than just strv can be boxed there
- // should be more checks here
iter->instance = (const gchar **) g_value_get_boxed (value);
iter->move_next = strv_move_next;
iter->get_value = strv_get_value;
diff --git a/src/tmpl-scope.c b/src/tmpl-scope.c
index 7488ab2..2b62acf 100644
--- a/src/tmpl-scope.c
+++ b/src/tmpl-scope.c
@@ -307,6 +307,8 @@ tmpl_scope_set_object (TmplScope *self,
* @value: (nullable): the variant to set it to, or %NULL
*
* Sets the value of the symbol named @name to the variant @value.
+ *
+ * If @value has a floating reference, it is consumed.
*/
void
tmpl_scope_set_variant (TmplScope *self,
diff --git a/src/tmpl-symbol.c b/src/tmpl-symbol.c
index 2dd05d1..2c9e694 100644
--- a/src/tmpl-symbol.c
+++ b/src/tmpl-symbol.c
@@ -243,6 +243,15 @@ tmpl_symbol_assign_object (TmplSymbol *self,
g_value_unset (&value);
}
+/**
+ * tmpl_symbol_assign_variant:
+ * @self: A #TmplSymbol
+ * @v_object: (nullable): a #GVariant or %NULL.
+ *
+ * Sets the value to the #GVariant @v_variant.
+ *
+ * If @v_variant has a floating reference, it is consumed.
+ */
void
tmpl_symbol_assign_variant (TmplSymbol *self,
GVariant *v_variant)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]