vala r821 - in trunk: . vala vapi vapi/packages/gtk+-2.0



Author: juergbi
Date: Wed Jan  9 23:13:12 2008
New Revision: 821
URL: http://svn.gnome.org/viewvc/vala?rev=821&view=rev

Log:
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


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

Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala	(original)
+++ trunk/vala/valasemanticanalyzer.vala	Wed Jan  9 23:13:12 2008
@@ -1545,6 +1545,45 @@
 					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;

Modified: trunk/vapi/gtk+-2.0.vapi
==============================================================================
--- trunk/vapi/gtk+-2.0.vapi	(original)
+++ trunk/vapi/gtk+-2.0.vapi	Wed Jan  9 23:13:12 2008
@@ -6356,7 +6356,7 @@
 	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 ();

Modified: trunk/vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala
==============================================================================
--- trunk/vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala	(original)
+++ trunk/vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala	Wed Jan  9 23:13:12 2008
@@ -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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]