[gjs/gnome-3-34] function: Pass the deferenced callback out pointer value to JS



commit 3b70c6aeb2483ae42ae31f33232cab9df8f03a30
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Mon Mar 16 23:24:44 2020 +0100

    function: Pass the deferenced callback out pointer value to JS
    
    When a callback function (vfunc) uses inout arguments, we used to
    compute the JS::Value from the argument as is (and so computing the
    value from the pointer value), however in such case the argument itself is
    a pointer and so we need to get its actual value by deferencing the GIArgument
    pointer.

 gi/function.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 10e87aee..9ca00048 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -310,16 +310,19 @@ static void gjs_callback_closure(ffi_cif* cif G_GNUC_UNUSED, void* result,
                     goto out;
                 break;
             }
-            case PARAM_NORMAL:
+            case PARAM_NORMAL: {
                 if (!jsargs.growBy(1))
                     g_error("Unable to grow vector");
 
+                GIArgument* arg = args[i + c_args_offset];
+                if (g_arg_info_get_direction(&arg_info) == GI_DIRECTION_INOUT)
+                    arg = *reinterpret_cast<GIArgument**>(arg);
+
                 if (!gjs_value_from_g_argument(context, jsargs[n_jsargs++],
-                                               &type_info,
-                                               args[i + c_args_offset],
-                                               false))
+                                               &type_info, arg, false))
                     goto out;
                 break;
+            }
             case PARAM_CALLBACK:
                 /* Callbacks that accept another callback as a parameter are not
                  * supported, see gjs_callback_trampoline_new() */


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