[vala/switch-to-gir: 28/34] girparser: Guess array length index from n_param parameters



commit 25fbf81152ec54395083228eb1aa11edb17b520e
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Aug 29 15:32:37 2010 +0200

    girparser: Guess array length index from n_param parameters

 vala/valagirparser.vala |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index a3dd364..890f66d 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -2127,6 +2127,19 @@ public class Vala.GirParser : CodeVisitor {
 
 		int last = -1;
 		foreach (MethodInfo info in parameters) {
+			if (info.param.name != null && info.param.name.has_prefix ("n_")) {
+				unowned string array_name = info.param.name.offset (2);
+				// maybe a length for another parameter
+				foreach (var array_info in parameters) {
+					if (array_info.param.name == array_name) {
+						array_info.param.variable_type = new ArrayType (array_info.param.variable_type, 1, array_info.param.source_reference);
+						array_info.array_length_idx = i + add;
+						array_length_parameters.add (array_info.array_length_idx);
+						break;
+					}
+				}
+			}
+
 			if (s is Delegate && info.closure_idx == i + add) {
 				var d = (Delegate) s;
 				d.has_target = true;



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