[gjs: 8/14] value: Support creating a GType from a GValue holding it
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 8/14] value: Support creating a GType from a GValue holding it
- Date: Sat, 17 Apr 2021 04:36:48 +0000 (UTC)
commit a47a27b44eba8e17b5b48e82b10e651ba1d94e8d
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Fri Apr 9 06:18:50 2021 +0200
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).
gi/value.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]