[vala] Generate type attributes for all enum|class|interface tags



commit 97159d6894896d149c69776e3277ae03db420cec
Author: Didier 'Ptitjes <ptitjes free fr>
Date:   Fri Mar 20 16:20:04 2009 +0100

    Generate type attributes for all enum|class|interface tags
    
    Generate c:type, glib:type-name and glib:get-type attributes for all
    enum|class|interface tags.
    
    Signed-off-by: Didier 'Ptitjes <ptitjes free fr>
---
 gobject/valagirwriter.vala |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/gobject/valagirwriter.vala b/gobject/valagirwriter.vala
index 0c13c3e..c873ef3 100644
--- a/gobject/valagirwriter.vala
+++ b/gobject/valagirwriter.vala
@@ -133,9 +133,8 @@ public class Vala.GIRWriter : CodeVisitor {
 		if (cl.is_subtype_of (gobject_type)) {
 			write_indent ();
 			stream.printf ("<class name=\"%s\"", cl.name);
+			write_gtype_attributes (cl);
 			stream.printf (" parent=\"%s\"", cl.base_class.get_full_name ());
-			stream.printf (" glib:type-name=\"%s\"", cl.get_cname ());
-			stream.printf (" glib:get-type=\"%sget_type\"", cl.get_lower_case_cprefix ());
 			stream.printf (">\n");
 			indent++;
 
@@ -211,7 +210,7 @@ public class Vala.GIRWriter : CodeVisitor {
 
 		write_indent ();
 		stream.printf ("<interface name=\"%s\"", iface.name);
-		stream.printf (" glib:get-type=\"%sget_type\"", iface.get_lower_case_cprefix ());
+		write_gtype_attributes (iface);
 		stream.printf (">\n");
 		indent++;
 
@@ -257,8 +256,7 @@ public class Vala.GIRWriter : CodeVisitor {
 
 		write_indent ();
 		stream.printf ("<enumeration name=\"%s\"", en.name);
-		stream.printf (" c:type=\"%s\"", en.get_cname ());
-		stream.printf (" glib:get-type=\"%sget_type\"", en.get_lower_case_cprefix ());
+		write_gtype_attributes (en);
 		stream.printf (">\n");
 		indent++;
 
@@ -527,6 +525,16 @@ public class Vala.GIRWriter : CodeVisitor {
 		stream.printf ("</return-value>\n");
 	}
 
+	private void write_ctype_attributes (TypeSymbol symbol) {
+		stream.printf (" c:type=\"%s\"", symbol.get_cname ());
+	}
+
+	private void write_gtype_attributes (TypeSymbol symbol) {
+		write_ctype_attributes(symbol);
+		stream.printf (" glib:type-name=\"%s\"", symbol.get_cname ());
+		stream.printf (" glib:get-type=\"%sget_type\"", symbol.get_lower_case_cprefix ());
+	}
+
 	private void write_type (DataType type) {
 		if (type is ArrayType) {
 			var array_type = (ArrayType) type;



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