[vala] girparser: Fix owned by default assumption for parameter types



commit 445cc4384961730e097a7cb74c4de0ccccdfdb42
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Apr 17 12:47:34 2011 +0200

    girparser: Fix owned by default assumption for parameter types

 vala/valagirparser.vala |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index a0c0167..0aa9eca 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -223,7 +223,7 @@ public class Vala.GirParser : CodeVisitor {
 		 * metadata ::= [ rule [ '\n' relativerule ]* ]
 		 * rule ::= pattern ' ' [ args ]
 		 * relativerule ::= '.' rule
-		 * pattern ::= glob [ '#' selector ] [ '.' glob ]*
+		 * pattern ::= glob [ '#' selector ] [ '.' pattern ]
 		 */
 		private Metadata tree = new Metadata ("");
 		private Scanner scanner;
@@ -1269,7 +1269,6 @@ public class Vala.GirParser : CodeVisitor {
 
 	/*
 	 * The changed is a faster way to check whether the type has changed and it may affect the C declaration.
-	 * If type arguments change, the C declaration is not affected.
 	 */
 	DataType? element_get_type (DataType orig_type, bool owned_by_default, out bool changed = null) {
 		changed = false;
@@ -1295,11 +1294,11 @@ public class Vala.GirParser : CodeVisitor {
 			changed = true;
 		}
 
-		if (owned_by_default || type.value_owned) {
+		if (type.value_owned) {
 			if (metadata.has_argument (ArgumentType.UNOWNED)) {
 				type.value_owned = !metadata.get_bool (ArgumentType.UNOWNED);
 			}
-		} else if (!owned_by_default || !type.value_owned) {
+		} else {
 			if (metadata.has_argument (ArgumentType.OWNED)) {
 				type.value_owned = metadata.get_bool (ArgumentType.OWNED);
 			}
@@ -1784,7 +1783,7 @@ public class Vala.GirParser : CodeVisitor {
 			}
 
 			bool changed;
-			type = element_get_type (type, false, out changed);
+			type = element_get_type (type, direction == "out" || direction == "ref", out changed);
 			if (!changed) {
 				// discard ctype, duplicated information
 				ctype = null;
@@ -1818,8 +1817,7 @@ public class Vala.GirParser : CodeVisitor {
 			start_element ("array");
 
 			if (type_name == null) {
-				if (reader.get_attribute ("length") != null
-				    && &array_length_index != null) {
+				if (reader.get_attribute ("length") != null) {
 					array_length_index = int.parse (reader.get_attribute ("length"));
 				}
 				next ();



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