[template-glib] eval: improve typeof() to introspect boxed value
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [template-glib] eval: improve typeof() to introspect boxed value
- Date: Mon, 23 Oct 2017 23:36:08 +0000 (UTC)
commit 2b54962455e9c7da8382d361b66d2ce88389171d
Author: Christian Hergert <chergert redhat com>
Date: Mon Oct 23 16:28:24 2017 -0700
eval: improve typeof() to introspect boxed value
src/tmpl-expr-eval.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/src/tmpl-expr-eval.c b/src/tmpl-expr-eval.c
index d456a65..cb61477 100644
--- a/src/tmpl-expr-eval.c
+++ b/src/tmpl-expr-eval.c
@@ -1562,7 +1562,17 @@ builtin_typeof (const GValue *value,
GError **error)
{
g_value_init (return_value, G_TYPE_GTYPE);
- g_value_set_gtype (return_value, G_VALUE_TYPE (value));
+
+ if (G_VALUE_HOLDS (value, TMPL_TYPE_BASE_INFO) &&
+ g_value_get_pointer (value) != NULL)
+ g_value_set_gtype (return_value,
+ g_registered_type_info_get_g_type (g_value_get_pointer (value)));
+ else if (G_VALUE_HOLDS_OBJECT (value) &&
+ g_value_get_object (value) != NULL)
+ g_value_set_gtype (return_value, G_OBJECT_TYPE (g_value_get_object (value)));
+ else
+ g_value_set_gtype (return_value, G_VALUE_TYPE (value));
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]