[gjs: 1/2] gi/arg-cache: Only skip array length parameter once




commit 3ca6720d372e59dc07299a8a5afc0275b269c479
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Nov 18 03:46:41 2020 +0100

    gi/arg-cache: Only skip array length parameter once
    
    If an array-length parameter precedes the corresponding array parameter,
    we skip counting the latter instead of the former. As the parameter type
    isn't relevant for the argument counter, that works fine - provided that
    the length parameter is only used for a single array.
    
    That is usually the case, but there are exceptions (for example Gtk4's
    gtk_accessible_update_property_value()). Address this by only skipping
    array arguments if the corresponding length parameter wasn't already
    marked skip-all previously.

 gi/arg-cache.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gi/arg-cache.cpp b/gi/arg-cache.cpp
index 6afed8e4..a4289cc8 100644
--- a/gi/arg-cache.cpp
+++ b/gi/arg-cache.cpp
@@ -1728,7 +1728,11 @@ bool gjs_arg_cache_build_arg(JSContext* cx, GjsArgumentCache* self,
         int length_pos = g_type_info_get_array_length(&self->type_info);
 
         if (length_pos >= 0) {
-            gjs_arg_cache_set_skip_all(&arguments[length_pos]);
+            GjsArgumentCache *cached_length = &arguments[length_pos];
+            bool skip_length =
+                !(cached_length->skip_in() && cached_length->skip_out());
+            if (skip_length)
+                gjs_arg_cache_set_skip_all(cached_length);
 
             if (direction == GI_DIRECTION_IN) {
                 self->marshallers = &c_array_in_marshallers;
@@ -1752,7 +1756,7 @@ bool gjs_arg_cache_build_arg(JSContext* cx, GjsArgumentCache* self,
             g_arg_info_load_type(&length_arg, &length_type);
             self->contents.array.length_tag = g_type_info_get_tag(&length_type);
 
-            if (length_pos < gi_index) {
+            if (length_pos < gi_index && skip_length) {
                 // we already collected length_pos, remove it
                 *inc_counter_out = false;
             }


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