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



commit bab67ffdc9c507158d7c914a0c2b62d0c7539dc1
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 3aef3e1dc..1484483e4 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1576,7 +1576,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);
@@ -1586,6 +1585,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 ()) {
@@ -1593,17 +1593,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]