vala r1132 - in trunk: . gobject



Author: juergbi
Date: Sun Mar 16 22:14:20 2008
New Revision: 1132
URL: http://svn.gnome.org/viewvc/vala?rev=1132&view=rev

Log:
2008-03-16  Juerg Billeter  <j bitron ch>

	* gobject/valaccodegenerator.vala,
	  gobject/valaccodegeneratormethod.vala: fix variable
	  initialization for array types


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodegenerator.vala
   trunk/gobject/valaccodegeneratormethod.vala

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Sun Mar 16 22:14:20 2008
@@ -959,16 +959,8 @@
 			}
 
 			/* try to initialize uninitialized variables */
-			if (decl.initializer == null && decl.type_reference.data_type is Struct) {
-				if (decl.type_reference.data_type.get_default_value () != null) {
-					((CCodeVariableDeclarator) decl.ccodenode).initializer = new CCodeConstant (decl.type_reference.data_type.get_default_value ());
-				} else {
-					// 0-initialize struct with struct initializer { 0 }
-					var clist = new CCodeInitializerList ();
-					clist.append (new CCodeConstant ("0"));
-
-					((CCodeVariableDeclarator) decl.ccodenode).initializer = clist;
-				}
+			if (decl.initializer == null) {
+				((CCodeVariableDeclarator) decl.ccodenode).initializer = default_value_for_type (decl.type_reference);
 			}
 		}
 		

Modified: trunk/gobject/valaccodegeneratormethod.vala
==============================================================================
--- trunk/gobject/valaccodegeneratormethod.vala	(original)
+++ trunk/gobject/valaccodegeneratormethod.vala	Sun Mar 16 22:14:20 2008
@@ -724,6 +724,11 @@
 			return new CCodeConstant ("NULL");
 		} else if (type.data_type != null && type.data_type.get_default_value () != null) {
 			return new CCodeConstant (type.data_type.get_default_value ());
+		} else if (type.data_type is Struct) {
+			// 0-initialize struct with struct initializer { 0 }
+			var clist = new CCodeInitializerList ();
+			clist.append (new CCodeConstant ("0"));
+			return clist;
 		} else if (type.type_parameter != null) {
 			return new CCodeConstant ("NULL");
 		} else if (type is ErrorType) {



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