]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
check in/ref/out arguments
authorJuerg Billeter <j@bitron.ch>
Wed, 9 Jan 2008 23:13:12 +0000 (23:13 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Wed, 9 Jan 2008 23:13:12 +0000 (23:13 +0000)
2008-01-10  Juerg Billeter  <j@bitron.ch>

* vala/valasemanticanalyzer.vala: check in/ref/out arguments

* vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala: fix gtk_init

* vapi/gtk+-2.0.vapi: regenerated

svn path=/trunk/; revision=821

ChangeLog
vala/valasemanticanalyzer.vala
vapi/gtk+-2.0.vapi
vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala

index 91d185d4455b066b43e8240a3018185c185044c9..5a94cca9e85e4ab19c4e1e18f07277938cac3c18 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-01-10  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valasemanticanalyzer.vala: check in/ref/out arguments
+
+       * vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala: fix gtk_init
+
+       * vapi/gtk+-2.0.vapi: regenerated
+
 2008-01-09  Jürg Billeter  <j@bitron.ch>
 
        * vapi/glib-2.0.vapi: add bindings for uri functions
index b7a162cc6d404dbe4e6fe0c59a4d1bdc371adeb3..4dc60ae6195199c52cd61ac251c3100d58d11dad 100644 (file)
@@ -1545,6 +1545,45 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                                        expr.error = true;
                                        Report.error (expr.source_reference, "Argument %d: Cannot convert from `%s' to `%s'".printf (i + 1, arg.static_type.to_string (), param.type_reference.to_string ()));
                                        return false;
+                               } else {
+                                       // 0 => null, 1 => in, 2 => ref, 3 => out
+                                       int arg_type = 1;
+                                       if (arg.static_type is NullType) {
+                                               arg_type = 0;
+                                       } else if (arg is UnaryExpression) {
+                                               var unary = (UnaryExpression) arg;
+                                               if (unary.operator == UnaryOperator.REF) {
+                                                       arg_type = 2;
+                                               } else if (unary.operator == UnaryOperator.OUT) {
+                                                       arg_type = 3;
+                                               }
+                                       }
+
+                                       if (arg_type == 0) {
+                                               if (param.type_reference.is_ref) {
+                                                       expr.error = true;
+                                                       Report.error (expr.source_reference, "Argument %d: Cannot pass null to reference parameter".printf (i + 1));
+                                                       return false;
+                                               }
+                                       } else if (arg_type == 1) {
+                                               if (param.type_reference.is_ref || param.type_reference.is_out) {
+                                                       expr.error = true;
+                                                       Report.error (expr.source_reference, "Argument %d: Cannot pass value to reference or output parameter".printf (i + 1));
+                                                       return false;
+                                               }
+                                       } else if (arg_type == 2) {
+                                               if (!param.type_reference.is_ref) {
+                                                       expr.error = true;
+                                                       Report.error (expr.source_reference, "Argument %d: Cannot pass ref argument to non-reference parameter".printf (i + 1));
+                                                       return false;
+                                               }
+                                       } else if (arg_type == 3) {
+                                               if (!param.type_reference.is_out) {
+                                                       expr.error = true;
+                                                       Report.error (expr.source_reference, "Argument %d: Cannot pass out argument to non-output parameter".printf (i + 1));
+                                                       return false;
+                                               }
+                                       }
                                }
 
                                prev_arg = arg;
index ed9de01250c124ce5f76d04a9e9d48a737c67818..a92173916f8ce6099689ea050724c80ae1b4ba5f 100644 (file)
@@ -6356,7 +6356,7 @@ namespace Gtk {
        public const string STOCK_ZOOM_OUT;
        public const int TEXT_VIEW_PRIORITY_VALIDATE;
        public const int TYPE_FUNDAMENTAL_LAST;
-       public static void init (out string[] args);
+       public static void init (ref string[] args);
        public static bool accel_groups_activate (GLib.Object object, uint accel_key, Gdk.ModifierType accel_mods);
        public static weak GLib.SList accel_groups_from_object (GLib.Object object);
        public static uint accelerator_get_default_mod_mask ();
index c0fce51c2cb1ec4c6748a4f13875f8205807652a..dbcedbde8e074f8f48c4e9e728d296a4cc8d9796 100644 (file)
@@ -1,6 +1,6 @@
 /* gtk+-2.0.vala
  *
- * Copyright (C) 2006-2007  Jürg Billeter
+ * Copyright (C) 2006-2008  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,7 @@
 
 namespace Gtk {
        [Import]
-       public void init (out string[] args);
+       public void init (ref string[] args);
 
        public struct Allocation {
                public int x;