From: Rico Tzschichholz Date: Thu, 1 Apr 2021 13:33:43 +0000 (+0200) Subject: girwriter: Don't use instance-parameter inside callback X-Git-Tag: 0.50.6~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ab094f82ce34a5c36a54897415e9691cb79b3ce;p=thirdparty%2Fvala.git girwriter: Don't use instance-parameter inside callback Fixes https://gitlab.gnome.org/GNOME/vala/issues/1167 --- diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala index 713e923c2..b3f5ad18e 100644 --- a/codegen/valagirwriter.vala +++ b/codegen/valagirwriter.vala @@ -1180,9 +1180,9 @@ public class Vala.GIRWriter : CodeVisitor { } foreach (Parameter param in params) { - write_param_or_return (param.variable_type, "parameter", ref index, get_ccode_array_length (param), param.name, get_parameter_comment (param), param.direction, false, false, param.ellipsis || param.params_array); + write_param_or_return (param.variable_type, "parameter", ref index, get_ccode_array_length (param), get_ccode_name (param), get_parameter_comment (param), param.direction, false, false, param.ellipsis || param.params_array); - write_implicit_params (param.variable_type, ref index, get_ccode_array_length (param), param.name, param.direction); + write_implicit_params (param.variable_type, ref index, get_ccode_array_length (param), get_ccode_name (param), param.direction); } if (ret_is_struct) { @@ -1359,7 +1359,15 @@ public class Vala.GIRWriter : CodeVisitor { write_doc (get_method_comment (m)); } - write_params_and_return (params, m.get_type_parameters (), return_type, get_ccode_array_length (m), return_comment, false, m.this_parameter); + if (tag_name == "callback" && m.this_parameter != null) { + m.this_parameter.set_attribute_string ("CCode", "cname", "self"); + var static_params = new ArrayList (); + static_params.add (m.this_parameter); + static_params.add_all (params); + write_params_and_return (static_params, m.get_type_parameters (), return_type, get_ccode_array_length (m), return_comment, false); + } else { + write_params_and_return (params, m.get_type_parameters (), return_type, get_ccode_array_length (m), return_comment, false, m.this_parameter); + } indent--; write_indent (); diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected index d2e83c8fd..0a342ea5b 100644 --- a/tests/girwriter/GirTest-1.0.gir-expected +++ b/tests/girwriter/GirTest-1.0.gir-expected @@ -1056,9 +1056,9 @@ - + - + @@ -1071,9 +1071,9 @@ - + - + @@ -1086,10 +1086,10 @@ - + - - + + @@ -1104,9 +1104,9 @@ - + - + @@ -1119,13 +1119,13 @@ - + - + - + @@ -1140,9 +1140,9 @@ - + - + @@ -1158,9 +1158,9 @@ - + - + @@ -1170,9 +1170,9 @@ - + - + @@ -1182,10 +1182,10 @@ - + - - + + @@ -1200,9 +1200,9 @@ - + - + @@ -1215,18 +1215,18 @@ - + - + - + - + @@ -1244,9 +1244,9 @@ - + - + @@ -1586,9 +1586,9 @@ - + - + @@ -1601,9 +1601,9 @@ - + - + @@ -1616,9 +1616,9 @@ - + - + @@ -1631,9 +1631,9 @@ - + - + @@ -1643,9 +1643,9 @@ - + - + @@ -1661,13 +1661,13 @@ - + - + - + @@ -1682,9 +1682,9 @@ - + - + @@ -1697,9 +1697,9 @@ - + - + @@ -1712,9 +1712,9 @@ - + - + @@ -1724,10 +1724,10 @@ - + - - + + @@ -1742,9 +1742,9 @@ - + - + @@ -1757,18 +1757,18 @@ - + - + - + - + @@ -2439,9 +2439,9 @@ - + - + @@ -2454,10 +2454,10 @@ - + - - + + @@ -2472,9 +2472,9 @@ - + - + @@ -2487,9 +2487,9 @@ - + - + @@ -2505,13 +2505,13 @@ - + - + - + @@ -2526,9 +2526,9 @@ - + - + @@ -2541,9 +2541,9 @@ - + - + @@ -2553,9 +2553,9 @@ - + - + @@ -2565,10 +2565,10 @@ - + - - + + @@ -2583,9 +2583,9 @@ - + - + @@ -2598,18 +2598,18 @@ - + - + - + - + @@ -2627,9 +2627,9 @@ - + - + @@ -2639,9 +2639,9 @@ - + - + @@ -2654,9 +2654,9 @@ - + - + @@ -2666,9 +2666,9 @@ - + - +