vala r927 - in trunk: . vala



Author: juergbi
Date: Wed Jan 30 10:29:19 2008
New Revision: 927
URL: http://svn.gnome.org/viewvc/vala?rev=927&view=rev

Log:
2008-01-30  Juerg Billeter  <j bitron ch>

	* vala/valacreationmethod.vala: default cname should be _init instead
	  of _new for creation methods in structs


Modified:
   trunk/ChangeLog
   trunk/vala/valacreationmethod.vala

Modified: trunk/vala/valacreationmethod.vala
==============================================================================
--- trunk/vala/valacreationmethod.vala	(original)
+++ trunk/vala/valacreationmethod.vala	Wed Jan 30 10:29:19 2008
@@ -1,6 +1,6 @@
 /* valacreationmethod.vala
  *
- * Copyright (C) 2007  Raffaele Sandrini, JÃrg Billeter
+ * Copyright (C) 2007-2008  Raffaele Sandrini, 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
@@ -67,12 +67,17 @@
 	}
 
 	public override string! get_default_cname () {
-		var parent = parent_symbol;
-		assert (parent is Typesymbol);
+		var parent = parent_symbol as Typesymbol;
+
+		string infix = "new";
+		if (parent is Struct) {
+			infix = "init";
+		}
+
 		if (name.len () == ".new".len ()) {
-			return "%snew".printf (((Typesymbol) parent).get_lower_case_cprefix ());
+			return "%s%s".printf (parent.get_lower_case_cprefix (), infix);
 		} else {
-			return "%snew_%s".printf (((Typesymbol) parent).get_lower_case_cprefix (), name.offset (".new.".len ()));
+			return "%s%s_%s".printf (parent.get_lower_case_cprefix (), infix, name.offset (".new.".len ()));
 		}
 	}
 }



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