]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girwriter: Fix position of "result" parameter for struct constructor
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 5 Aug 2021 15:14:48 +0000 (17:14 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 9 Aug 2021 05:50:45 +0000 (07:50 +0200)
Thanks to Princeton Ferro

codegen/valagirwriter.vala

index ef0cd5f07e9325692c4eedb981cfb5f5d621a1b8..07b6f1e4ccb47de671b4a1f404cc6262951570bd 100644 (file)
@@ -1202,6 +1202,11 @@ public class Vala.GIRWriter : CodeVisitor {
                                }
                        }
 
+                       if (constructor && ret_is_struct) {
+                               // struct constructor has its result as first parameter
+                               write_param_or_return (return_type, "parameter", ref index, false, "result", return_comment, ParameterDirection.OUT, constructor, true);
+                       }
+
                        if (type_params != null) {
                                foreach (var p in type_params) {
                                        write_type_parameter (p, "parameter");
@@ -1215,10 +1220,10 @@ public class Vala.GIRWriter : CodeVisitor {
                                write_implicit_params (param.variable_type, ref index, get_ccode_array_length (param), get_ccode_name (param), param.direction);
                        }
 
-                       if (ret_is_struct) {
+                       if (!constructor && ret_is_struct) {
                                // struct returns are converted to parameters
                                write_param_or_return (return_type, "parameter", ref index, false, "result", return_comment, ParameterDirection.OUT, constructor, true);
-                       } else {
+                       } else if (!constructor) {
                                write_implicit_params (return_type, ref index, return_array_length, "result", ParameterDirection.OUT);
                        }