summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2021-04-09 06:18:50 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2021-04-15 07:40:48 +0200
commita47a27b44eba8e17b5b48e82b10e651ba1d94e8d (patch)
tree5e2563d38c745c5547804747c9e8ba94e09ea109
parentb74f402b12f8727ad21d1f8a18ef02e3cfdf921d (diff)
downloadgjs-a47a27b44eba8e17b5b48e82b10e651ba1d94e8d.tar.gz
value: Support creating a GType from a GValue holding it
If a GValue holds a GType we should create a GType wrapper for it, currently we were failing this and functions returning GValue's holding GType's couldn't be handled correctly (as we were considering the value a pointer type).
-rw-r--r--gi/value.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/gi/value.cpp b/gi/value.cpp
index bba2702a..75b99041 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -992,6 +992,20 @@ gjs_value_from_g_value_internal(JSContext *context,
g_base_info_unref((GIBaseInfo*)arg_info);
g_base_info_unref((GIBaseInfo*)signal_info);
return res;
+ } else if (gtype == G_TYPE_GTYPE) {
+ GType gvalue_gtype = g_value_get_gtype(gvalue);
+
+ if (gvalue_gtype == 0) {
+ value_p.setNull();
+ return true;
+ }
+
+ JS::RootedObject obj(
+ context, gjs_gtype_create_gtype_wrapper(context, gvalue_gtype));
+ if (!obj)
+ return false;
+
+ value_p.setObject(*obj);
} else if (g_type_is_a(gtype, G_TYPE_POINTER)) {
gpointer pointer;