]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Generate type attributes for all enum|class|interface tags
authorDidier 'Ptitjes <ptitjes@free.fr>
Fri, 20 Mar 2009 15:20:04 +0000 (16:20 +0100)
committerJürg Billeter <j@bitron.ch>
Thu, 30 Apr 2009 18:58:55 +0000 (20:58 +0200)
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

index 0c13c3e3408033ed812d1594d80dca99d6412a8e..c873ef31ef78a63837e515144b529e780c324458 100644 (file)
@@ -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;