diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-02-28 13:49:20 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-02-28 15:01:38 +0100 |
commit | 0c1bd0a018f5fa57194d259202656609ad271975 (patch) | |
tree | e7fd50b8bbbeb053f569e40588152ddbe8a4a163 /codegen | |
parent | ae629fa7e52f01babc678f7607ed876081413eff (diff) | |
download | vala-0c1bd0a018f5fa57194d259202656609ad271975.tar.gz |
codegen: Fix vfunc pointer cast for async method implementation/override
Diffstat (limited to 'codegen')
-rw-r--r-- | codegen/valagtypemodule.vala | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index 6b0c4daa8..8945d0766 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -1213,12 +1213,14 @@ public class Vala.GTypeModule : GErrorModule { // there is currently no default handler for abstract async methods if (!m.is_abstract || !m.coroutine) { CCodeExpression cfunc = new CCodeIdentifier (get_ccode_real_name (m)); - cfunc = cast_method_pointer (m.base_method, cfunc, base_type); + cfunc = cast_method_pointer (m.base_method, cfunc, base_type, (m.coroutine ? 1 : 3)); var ccast = new CCodeCastExpression (new CCodeIdentifier ("klass"), "%sClass *".printf (get_ccode_name (base_type))); ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, get_ccode_vfunc_name (m.base_method)), cfunc); if (m.coroutine) { - ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, get_ccode_finish_vfunc_name (m.base_method)), new CCodeIdentifier (get_ccode_finish_real_name (m))); + cfunc = new CCodeIdentifier (get_ccode_finish_real_name (m)); + cfunc = cast_method_pointer (m.base_method, cfunc, base_type, 2); + ccode.add_assignment (new CCodeMemberAccess.pointer (ccast, get_ccode_finish_vfunc_name (m.base_method)), cfunc); } } } @@ -1332,7 +1334,7 @@ public class Vala.GTypeModule : GErrorModule { } else { cfunc = new CCodeIdentifier (get_ccode_real_name (m)); } - cfunc = cast_method_pointer (m.base_interface_method, cfunc, iface); + cfunc = cast_method_pointer (m.base_interface_method, cfunc, iface, (m.coroutine ? 1 : 3)); ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_vfunc_name (m.base_interface_method)), cfunc); if (m.coroutine) { @@ -1341,6 +1343,7 @@ public class Vala.GTypeModule : GErrorModule { } else { cfunc = new CCodeIdentifier (get_ccode_finish_real_name (m)); } + cfunc = cast_method_pointer (m.base_interface_method, cfunc, iface, 2); ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_finish_vfunc_name (m.base_interface_method)), cfunc); } } @@ -1496,7 +1499,7 @@ public class Vala.GTypeModule : GErrorModule { return new CCodeCastExpression (cfunc, cast); } - CCodeExpression cast_method_pointer (Method m, CCodeExpression cfunc, ObjectTypeSymbol base_type) { + CCodeExpression cast_method_pointer (Method m, CCodeExpression cfunc, ObjectTypeSymbol base_type, int direction = 3) { // Cast the function pointer to match the interface string cast; if (m.return_type.is_real_non_null_struct_type ()) { @@ -1509,7 +1512,7 @@ public class Vala.GTypeModule : GErrorModule { var vdeclarator = new CCodeFunctionDeclarator (get_ccode_vfunc_name (m)); var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal); - generate_cparameters (m, cfile, cparam_map, new CCodeFunction ("fake"), vdeclarator); + generate_cparameters (m, cfile, cparam_map, new CCodeFunction ("fake"), vdeclarator, null, null, direction); // append C arguments in the right order int last_pos = -1; |