]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix method pointer cast if instance isn't at first position
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 7 Nov 2018 22:00:18 +0000 (23:00 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 8 Nov 2018 07:04:53 +0000 (08:04 +0100)
By unconditionally putting the instance at first position the CCode
instance_pos attribute was not accounted for.

codegen/valagtypemodule.vala

index 99f38452a9458348722411c635bb548ce725e61d..01d3e5e9783baa9c82abf72cf289382d26431ea6 100644 (file)
@@ -1611,7 +1611,6 @@ public class Vala.GTypeModule : GErrorModule {
                } else {
                        cast = "%s (*)".printf (get_ccode_name (m.return_type));
                }
-               string cast_args = "%s *".printf (get_ccode_name (base_type));
 
                var vdeclarator = new CCodeFunctionDeclarator (get_ccode_vfunc_name (m));
                var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
@@ -1621,6 +1620,7 @@ public class Vala.GTypeModule : GErrorModule {
                // append C arguments in the right order
                int last_pos = -1;
                int min_pos;
+               string cast_args = "";
                while (true) {
                        min_pos = -1;
                        foreach (int pos in cparam_map.get_keys ()) {
@@ -1628,17 +1628,17 @@ public class Vala.GTypeModule : GErrorModule {
                                        min_pos = pos;
                                }
                        }
-                       if (last_pos != -1) { // Skip the 1st parameter
-                               if (min_pos == -1) {
-                                       break;
-                               }
-
-                               var tmp = cparam_map.get (min_pos);
-                               if (tmp.ellipsis) {
-                                       cast_args = "%s, ...".printf (cast_args);
-                               } else {
-                                       cast_args = "%s, %s".printf (cast_args, tmp.type_name);
-                               }
+                       if (min_pos == -1) {
+                               break;
+                       }
+                       if (last_pos != -1) {
+                               cast_args = "%s, ".printf (cast_args);
+                       }
+                       var cparam = cparam_map.get (min_pos);
+                       if (cparam.ellipsis) {
+                               cast_args = "%s...".printf (cast_args);
+                       } else {
+                               cast_args = "%s%s".printf (cast_args, cparam.type_name);
                        }
                        last_pos = min_pos;
                }