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



commit bfda2a8e24f6b940474492d703a43c3537ab03ea
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 dba7c5f2b..e8c255810 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1506,7 +1506,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);
@@ -1516,6 +1515,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 ()) {
@@ -1523,17 +1523,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]