[template-glib] eval: add name() function to GType
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [template-glib] eval: add name() function to GType
- Date: Thu, 19 May 2022 00:47:34 +0000 (UTC)
commit e4db4cb5b9279545ad205fdc5092cab149e03709
Author: Christian Hergert <chergert redhat com>
Date: Wed May 18 17:47:29 2022 -0700
eval: add name() function to GType
src/tmpl-expr-eval.c | 7 +++++++
tests/test1.script | 1 +
2 files changed, 8 insertions(+)
---
diff --git a/src/tmpl-expr-eval.c b/src/tmpl-expr-eval.c
index 9cf8b5e..2e07fcf 100644
--- a/src/tmpl-expr-eval.c
+++ b/src/tmpl-expr-eval.c
@@ -956,6 +956,13 @@ tmpl_expr_gi_call_eval (TmplExprGiCall *node,
if (G_VALUE_HOLDS_GTYPE (&left))
{
if (FALSE) {}
+ else if (g_str_equal (node->name, "name"))
+ {
+ g_value_init (return_value, G_TYPE_STRING);
+ g_value_set_static_string (return_value, g_type_name (g_value_get_gtype (&left)));
+ ret = TRUE;
+ goto cleanup;
+ }
else if (g_str_equal (node->name, "is_a"))
{
if (node->params != NULL)
diff --git a/tests/test1.script b/tests/test1.script
index 3056ee5..759856d 100644
--- a/tests/test1.script
+++ b/tests/test1.script
@@ -63,6 +63,7 @@ assert(group != null)
assert(typeof(group).is_a(typeof(Gio.ActionGroup)))
assert(typeof(group).is_a(typeof(Gio.ActionMap)))
assert(!typeof(group).is_a(typeof(Gio.Action)))
+assert(typeof(group).name() == "GSimpleActionGroup")
t1 = typeof(group)
t2 = typeof(Gio.SimpleActionGroup)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]