[vala/0.42] codegen: Fix method pointer cast if instance isn't at first position



commit d825fd7a42d96250c500cae988c23a8e80008ff3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Nov 7 23:00:18 2018 +0100

    codegen: Fix method pointer cast if instance isn't at first position
    
    By unconditionally putting the instance at first position the CCode
    instance_pos attribute was not accounted for.

 codegen/valagtypemodule.vala | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index dcc51a107..62a8e4459 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1591,7 +1591,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);
@@ -1601,6 +1600,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 ()) {
@@ -1608,17 +1608,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;
                }


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