vala r886 - in trunk: . gobject tests



Author: juergbi
Date: Tue Jan 22 17:27:31 2008
New Revision: 886
URL: http://svn.gnome.org/viewvc/vala?rev=886&view=rev

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

	* gobject/valaccodegenerator.vala: support length field for array
	  constants

	* tests/arrays.vala: test length field of array constants


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

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Tue Jan 22 17:27:31 2008
@@ -2218,6 +2218,11 @@
 						return length_expr;
 					}
 				}
+			} else if (array_expr.symbol_reference is Constant) {
+				var constant = (Constant) array_expr.symbol_reference;
+				var ccall = new CCodeFunctionCall (new CCodeIdentifier ("G_N_ELEMENTS"));
+				ccall.add_argument (new CCodeIdentifier (constant.get_cname ()));
+				return ccall;
 			}
 		}
 

Modified: trunk/tests/arrays.vala
==============================================================================
--- trunk/tests/arrays.vala	(original)
+++ trunk/tests/arrays.vala	Tue Jan 22 17:27:31 2008
@@ -216,6 +216,12 @@
 		stdout.printf (" 13\n");
 	}
 
+	const int[] const_array = { 1, 2, 3 };
+
+	static void test_array_length_of_array_constants () {
+		assert (const_array.length == 3);
+	}
+
 	static void main (string[] args) {
 		test_integer_array ();
 		test_string_array ();
@@ -233,6 +239,8 @@
 		test_array_creation_side_effects ();
 
 		test_element_access ();
+
+		test_array_length_of_array_constants ();
 	}
 	
 	public static int inc () {



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