[vala/switch-to-gir] girparser: Let signals assume the parameter names of related methods



commit a9ea37f0de23c31cfc583189cba6a0e5b09d781e
Author: Luca Bruno <lucabru src gnome org>
Date:   Sat Aug 28 19:13:34 2010 +0200

    girparser: Let signals assume the parameter names of related methods

 vala/valagirparser.vala |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 733c6b5..c737fd2 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -952,6 +952,22 @@ public class Vala.GirParser : CodeVisitor {
 		return info;
 	}
 
+	void assume_parameter_names (Signal sig, Symbol sym) {
+		Iterator<FormalParameter> iter;
+		if (sym is Method) {
+			iter = ((Method) sym).get_parameters ().iterator ();
+		} else {
+			iter = ((Delegate) sym).get_parameters ().iterator ();
+		}
+		foreach (var param in sig.get_parameters ()) {
+			if (!iter.next ()) {
+				// unreachable for valid GIR
+				break;
+			}
+			param.name = iter.get ().name;
+		}
+	}
+
 	bool merge (Symbol container, SymbolInfo info, ArrayList<SymbolInfo> colliding) {
 		if (info.symbol is Signal) {
 			foreach (var cinfo in colliding) {
@@ -981,7 +997,9 @@ public class Vala.GirParser : CodeVisitor {
 				foreach (var cinfo in colliding) {
 					var sym = cinfo.symbol;
 					if (sym is Signal) {
-						((Signal) sym).is_virtual = true;
+						var sig = (Signal) sym;
+						sig.is_virtual = true;
+						assume_parameter_names (sig, method);
 						return true;
 					} else if (sym is Property || sym is Field) {
 						// assume method is getter for property/field ignore method
@@ -993,7 +1011,9 @@ public class Vala.GirParser : CodeVisitor {
 				foreach (var cinfo in colliding) {
 					var sym = cinfo.symbol;
 					if (sym is Signal) {
-						((Signal) sym).has_emitter = true;
+						var sig = (Signal) sym;
+						sig.has_emitter = true;
+						assume_parameter_names (sig, method);
 						return true;
 					} else if (sym is Property || sym is Field) {
 						// assume method is getter for property/field ignore method
@@ -2504,6 +2524,7 @@ public class Vala.GirParser : CodeVisitor {
 				} else if (symbol is Signal) {
 					var sig = (Signal) symbol;
 					sig.is_virtual = true;
+					assume_parameter_names (sig, d);
 				} else if (symbol is Property) {
 					var prop = (Property) symbol;
 					prop.is_virtual = true;



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