]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix default value of get_ccode_destroy_notify_pos() and make use of it
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 6 Apr 2021 11:00:16 +0000 (13:00 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 8 Apr 2021 06:33:16 +0000 (08:33 +0200)
codegen/valaccode.vala
codegen/valaccodebasemodule.vala
codegen/valaccodedelegatemodule.vala
codegen/valaccodemethodcallmodule.vala
codegen/valaccodemethodmodule.vala

index 7671b2c50ecb7d67b9d5e9dde2132eb27d37adbe..9b1da33f757a35dcfa3e862d0e87e6e441062069 100644 (file)
@@ -365,12 +365,7 @@ namespace Vala {
                if (a != null && a.has_argument ("destroy_notify_pos")) {
                        return a.get_double ("destroy_notify_pos");
                }
-               if (node is Parameter) {
-                       unowned Parameter param = (Parameter) node;
-                       return get_ccode_pos (param) + 0.1;
-               } else {
-                       return -3;
-               }
+               return get_ccode_delegate_target_pos (node) + 0.01;
        }
 
        public static bool get_ccode_delegate_target (CodeNode node) {
index 94d16e3b12e22be125f519a8926404e4b96cfd68..4d44d0a7e6b5c9703eab5d584c1edb9160023d70 100644 (file)
@@ -4979,7 +4979,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                                                var delegate_target = get_delegate_target_cexpression (arg, out delegate_target_destroy_notify);
                                                                carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), delegate_target);
                                                                if (deleg_type.is_disposable ()) {
-                                                                       carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), delegate_target_destroy_notify);
+                                                                       carg_map.set (get_param_pos (get_ccode_destroy_notify_pos (param)), delegate_target_destroy_notify);
                                                                }
                                                        }
                                                }
index b0770a5a03543c1d5b9843ffd563466330a86323..dc54d636c19b1e605126b06fb14b15ccf3699cf8 100644 (file)
@@ -77,7 +77,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
                                if (deleg_type.is_disposable ()) {
                                        generate_type_declaration (delegate_target_destroy_type, decl_space);
                                        cparam = new CCodeParameter (get_delegate_target_destroy_notify_cname ("result"), get_ccode_name (delegate_target_destroy_type) + "*");
-                                       cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (d) + 0.01), cparam);
+                                       cparam_map.set (get_param_pos (get_ccode_destroy_notify_pos (d)), cparam);
                                }
                        }
                }
@@ -244,7 +244,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
                                cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (d)), cparam);
                                if (deleg_type.is_disposable ()) {
                                        cparam = new CCodeParameter (get_delegate_target_destroy_notify_cname ("result"), get_ccode_name (delegate_target_destroy_type) + "*");
-                                       cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (d) + 0.01), cparam);
+                                       cparam_map.set (get_param_pos (get_ccode_destroy_notify_pos (d)), cparam);
                                }
                        }
                } else if (d.return_type.is_real_non_null_struct_type ()) {
@@ -343,7 +343,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
                                        carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), ctarget);
                                        if (deleg_type.is_disposable ()) {
                                                var ctarget_destroy_notify = new CCodeIdentifier (get_ccode_delegate_target_destroy_notify_name (d_params.get (i)));
-                                               carg_map.set (get_param_pos (get_ccode_delegate_target_pos (m) + 0.01), ctarget_destroy_notify);
+                                               carg_map.set (get_param_pos (get_ccode_destroy_notify_pos (m)), ctarget_destroy_notify);
                                        }
                                }
                        }
@@ -369,7 +369,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
                                carg_map.set (get_param_pos (get_ccode_delegate_target_pos (m)), ctarget);
                                if (deleg_type.is_disposable ()) {
                                        var ctarget_destroy_notify = new CCodeIdentifier (get_delegate_target_destroy_notify_cname ("result"));
-                                       carg_map.set (get_param_pos (get_ccode_delegate_target_pos (m) + 0.01), ctarget_destroy_notify);
+                                       carg_map.set (get_param_pos (get_ccode_destroy_notify_pos (m)), ctarget_destroy_notify);
                                }
                        }
                } else if (m.return_type.is_real_non_null_struct_type ()) {
@@ -488,9 +488,9 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
                                }
                                if (deleg_type.is_disposable ()) {
                                        cparam = new CCodeParameter (get_ccode_delegate_target_destroy_notify_name (param), target_destroy_notify_ctypename);
-                                       cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), cparam);
+                                       cparam_map.set (get_param_pos (get_ccode_destroy_notify_pos (param)), cparam);
                                        if (carg_map != null) {
-                                               carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), get_cexpression (cparam.name));
+                                               carg_map.set (get_param_pos (get_ccode_destroy_notify_pos (param)), get_cexpression (cparam.name));
                                        }
                                }
                        }
index 461e89735f4b5898f6c8dd57a44f1a1a875b6275..66f2d88185751836bc0f8ad8da60aed189d4007d 100644 (file)
@@ -437,7 +437,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                                                        carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), delegate_target);
                                                                        if (deleg_type.is_disposable ()) {
                                                                                assert (delegate_target_destroy_notify != null);
-                                                                               carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), delegate_target_destroy_notify);
+                                                                               carg_map.set (get_param_pos (get_ccode_destroy_notify_pos (param)), delegate_target_destroy_notify);
                                                                        }
                                                                }
                                                        }
@@ -491,7 +491,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                                                        temp_var = get_temp_variable (delegate_target_destroy_type, true, null, true);
                                                                        emit_temp_var (temp_var);
                                                                        set_delegate_target_destroy_notify (arg, get_variable_cexpression (temp_var.name));
-                                                                       carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_delegate_target_destroy_notify (arg)));
+                                                                       carg_map.set (get_param_pos (get_ccode_destroy_notify_pos (param)), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_delegate_target_destroy_notify (arg)));
                                                                }
                                                        }
                                                }
@@ -612,7 +612,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                                        emit_temp_var (temp_var);
 
-                                       out_arg_map.set (get_param_pos (get_ccode_delegate_target_pos (m) + 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
+                                       out_arg_map.set (get_param_pos (get_ccode_destroy_notify_pos (m)), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
 
                                        set_delegate_target_destroy_notify (expr, temp_ref);
                                } else {
@@ -677,7 +677,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                                        emit_temp_var (temp_var);
 
-                                       out_arg_map.set (get_param_pos (get_ccode_delegate_target_pos (deleg) + 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
+                                       out_arg_map.set (get_param_pos (get_ccode_destroy_notify_pos (deleg)), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref));
 
                                        set_delegate_target_destroy_notify (expr, temp_ref);
                                }
index e6841275562754e3fc971bbdac4d0a4538181e7e..3c26c198eeea49b893a6dc48fd2346a28a4a127c 100644 (file)
@@ -89,9 +89,9 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                                }
                                if (deleg_type.is_disposable ()) {
                                        cparam = new CCodeParameter (get_delegate_target_destroy_notify_cname ("result"), get_ccode_name (delegate_target_destroy_type) + "*");
-                                       cparam_map.set (get_param_pos (get_ccode_delegate_target_pos (m) + 0.01), cparam);
+                                       cparam_map.set (get_param_pos (get_ccode_destroy_notify_pos (m)), cparam);
                                        if (carg_map != null) {
-                                               carg_map.set (get_param_pos (get_ccode_delegate_target_pos (m) + 0.01), get_cexpression (cparam.name));
+                                               carg_map.set (get_param_pos (get_ccode_destroy_notify_pos (m)), get_cexpression (cparam.name));
                                        }
                                }
                        }