[gjs/ewlsh/gtk4-a11y: 1/3] gi: Allow GObject.Value boxed type in all contexts




commit 5a39fa6dd3083e3b385d78a2d991f63ed7367659
Author: Evan Welsh <contact evanwelsh com>
Date:   Thu Aug 26 21:28:26 2021 -0700

    gi: Allow GObject.Value boxed type in all contexts
    
    Previously we only handled this conversion in the arg cache.

 gi/value.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/gi/value.cpp b/gi/value.cpp
index ec64f0ac..93e2962a 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -355,6 +355,21 @@ gjs_value_to_g_value_internal(JSContext      *context,
                               GValue         *gvalue,
                               bool            no_copy)
 {
+    if (value.isObject()) {
+        JS::RootedObject obj(context, &value.toObject());
+        GType gtype;
+
+        if (!gjs_gtype_get_actual_gtype(context, obj, &gtype))
+            return false;
+
+        if (gtype == G_TYPE_VALUE) {
+            GValue* source = BoxedBase::to_c_ptr<GValue>(context, obj);
+            g_value_init(gvalue, G_VALUE_TYPE(source));
+            g_value_copy(source, gvalue);
+            return true;
+        }
+    }
+
     GType gtype;
     bool out_of_range = false;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]