vala r1874 - in trunk: . gobject



Author: juergbi
Date: Thu Oct 23 09:46:45 2008
New Revision: 1874
URL: http://svn.gnome.org/viewvc/vala?rev=1874&view=rev

Log:
2008-10-23  JÃrg Billeter  <j bitron ch>

	* gobject/valaccodegenerator.vala:

	Fix foreach over stacked arrays


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

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Thu Oct 23 09:46:45 2008
@@ -2187,7 +2187,17 @@
 				var cdecl = new CCodeDeclaration (stmt.type_reference.get_cname ());
 				cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer (stmt.variable_name, element_expr));
 				cbody.add_statement (cdecl);
-				
+
+				// add array length variable for stacked arrays
+				if (stmt.type_reference is ArrayType) {
+					var inner_array_type = (ArrayType) stmt.type_reference;
+					for (int dim = 1; dim <= inner_array_type.rank; dim++) {
+						cdecl = new CCodeDeclaration ("int");
+						cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("%s_length%d".printf (stmt.variable_name, dim), new CCodeConstant ("-1")));
+						cbody.add_statement (cdecl);
+					}
+				}
+
 				cbody.add_statement (stmt.body.ccodenode);
 				
 				var ccond = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier ("*%s".printf (it_name)), new CCodeConstant ("NULL"));
@@ -2224,6 +2234,16 @@
 				cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer (stmt.variable_name, element_expr));
 				cbody.add_statement (cdecl);
 
+				// add array length variable for stacked arrays
+				if (stmt.type_reference is ArrayType) {
+					var inner_array_type = (ArrayType) stmt.type_reference;
+					for (int dim = 1; dim <= inner_array_type.rank; dim++) {
+						cdecl = new CCodeDeclaration ("int");
+						cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("%s_length%d".printf (stmt.variable_name, dim), new CCodeConstant ("-1")));
+						cbody.add_statement (cdecl);
+					}
+				}
+
 				cbody.add_statement (stmt.body.ccodenode);
 				
 				var ccond_ind1 = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, array_len, new CCodeConstant ("-1"));



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