vala r958 - in trunk: . tests vala
- From: rasa svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r958 - in trunk: . tests vala
- Date: Sun, 3 Feb 2008 21:22:28 +0000 (GMT)
Author: rasa
Date: Sun Feb 3 21:22:28 2008
New Revision: 958
URL: http://svn.gnome.org/viewvc/vala?rev=958&view=rev
Log:
2008-02-03 Raffaele Sandrini <raffaele sandrini ch>
* tests/arrays.vala: extend the array test with an array of structs
declared through the "var" keyword
* vala/valasemanticanalyzer.vala: fix a memory management bug with
arrays of struct elements
Modified:
trunk/ChangeLog
trunk/tests/arrays.vala
trunk/vala/valasemanticanalyzer.vala
Modified: trunk/tests/arrays.vala
==============================================================================
--- trunk/tests/arrays.vala (original)
+++ trunk/tests/arrays.vala Sun Feb 3 21:22:28 2008
@@ -166,6 +166,12 @@
stdout.printf ("\n");
}
+ static void test_array_var_creation_with_structs () {
+ var ca = new char[16];
+ ca[5] = 'a';
+ assert (ca[5] == 'a');
+ }
+
static void test_array_creation_side_effects () {
int i = 5;
var arr = new int[i++];
@@ -241,6 +247,8 @@
test_element_access ();
test_array_length_of_array_constants ();
+
+ test_array_var_creation_with_structs ();
}
public static int inc () {
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Sun Feb 3 21:22:28 2008
@@ -1217,12 +1217,18 @@
return;
}
+ /* arrays of struct type elements do not take ownership since they are copied into the array */
+ if (expr.element_type.data_type is Struct) {
+ expr.element_type.takes_ownership = false;
+ } else {
+ expr.element_type.takes_ownership = true;
+ }
+
expr.static_type = new ArrayType (expr.element_type, expr.rank);
expr.static_type.transfers_ownership = true;
expr.static_type.takes_ownership = true;
expr.static_type.add_type_argument (expr.element_type);
- expr.element_type.takes_ownership = true;
}
public override void visit_boolean_literal (BooleanLiteral! expr) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]