[vala] girparser: Fix setting ownership for parameters.



commit 56c3ab5f49d0242a9c445f79e5153cf443b137aa
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu Jan 6 11:47:27 2011 +0100

    girparser: Fix setting ownership for parameters.

 vala/valagirparser.vala |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 53a6db1..81d5abb 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1317,11 +1317,11 @@ public class Vala.GirParser : CodeVisitor {
 			changed = true;
 		}
 
-		if (owned_by_default) {
+		if (owned_by_default || type.value_owned) {
 			if (metadata.has_argument (ArgumentType.UNOWNED)) {
 				type.value_owned = !metadata.get_bool (ArgumentType.UNOWNED);
 			}
-		} else {
+		} else if (!owned_by_default || !type.value_owned) {
 			if (metadata.has_argument (ArgumentType.OWNED)) {
 				type.value_owned = metadata.get_bool (ArgumentType.OWNED);
 			}
@@ -1798,6 +1798,13 @@ public class Vala.GirParser : CodeVisitor {
 		} else {
 			string ctype;
 			var type = parse_type (out ctype, out array_length_idx, transfer == "full");
+			if (transfer == "full" || transfer == "container" || destroy != null) {
+				type.value_owned = true;
+			}
+			if (allow_none == "1") {
+				type.nullable = true;
+			}
+
 			bool changed;
 			type = element_get_type (type, false, out changed);
 			if (!changed) {
@@ -1809,12 +1816,6 @@ public class Vala.GirParser : CodeVisitor {
 				array_length_idx = metadata.get_integer (ArgumentType.ARRAY_LENGTH_IDX);
 			}
 
-			if (transfer == "full" || transfer == "container" || destroy != null) {
-				type.value_owned = true;
-			}
-			if (allow_none == "1") {
-				type.nullable = true;
-			}
 			param = new Parameter (name, type, get_current_src ());
 			param.ctype = ctype;
 			if (direction == "out") {



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