[vala] GIR writer: Fix virtual method generation



commit 5c56cb48b9b2ef10f9cd32d972c205fe221b1220
Author: Didier 'Ptitjes <ptitjes free fr>
Date:   Fri Mar 20 17:45:56 2009 +0100

    GIR writer: Fix virtual method generation
    
    Generate virtual and abstract methods correctly (method +
    virtual-method + callback in type struct).
    
    Signed-off-by: Didier 'Ptitjes <ptitjes free fr>
---
 gobject/valagirwriter.vala |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/gobject/valagirwriter.vala b/gobject/valagirwriter.vala
index c4ed73d..5bf6ba7 100644
--- a/gobject/valagirwriter.vala
+++ b/gobject/valagirwriter.vala
@@ -175,6 +175,12 @@ public class Vala.GIRWriter : CodeVisitor {
 			stream.printf (">\n");
 			indent++;
 
+			foreach (Method m in cl.get_methods ()) {
+				if (m.is_abstract || m.is_virtual) {
+					write_signature(m, "callback", true);
+				}
+			}
+
 			indent--;
 			write_indent ();
 			stream.printf ("</record>\n");
@@ -268,6 +274,12 @@ public class Vala.GIRWriter : CodeVisitor {
 		stream.printf (">\n");
 		indent++;
 
+		foreach (Method m in iface.get_methods ()) {
+			if (m.is_abstract || m.is_virtual) {
+				write_signature(m, "callback", true);
+			}
+		}
+
 		indent--;
 		write_indent ();
 		stream.printf ("</record>\n");
@@ -456,11 +468,20 @@ public class Vala.GIRWriter : CodeVisitor {
 		}
 
 		write_signature (m, tag_name);
+
+		if (m.is_abstract || m.is_virtual) {
+			write_signature (m, "virtual-method", false, true);
+		}
 	}
 
-	private void write_signature (Method m, string tag_name, bool instance = false) {
+	private void write_signature (Method m, string tag_name, bool instance = false, bool is_virtual = false) {
 		write_indent ();
-		stream.printf ("<%s name=\"%s\" c:identifier=\"%s\"", tag_name, m.name, m.get_cname ());
+		stream.printf ("<%s name=\"%s\"", tag_name, m.name);
+		if (is_virtual) {
+			stream.printf (" invoker=\"%s\"", m.name);
+		} else {
+			stream.printf (" c:identifier=\"%s\"", m.get_cname ());
+		}
 		stream.printf (">\n");
 		indent++;
 



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