]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
support libraries with generic types
authorJuerg Billeter <j@bitron.ch>
Sun, 22 Jul 2007 18:06:26 +0000 (18:06 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 22 Jul 2007 18:06:26 +0000 (18:06 +0000)
2007-07-22  Juerg Billeter  <j@bitron.ch>

* vala/valainterface.vala, vala/valainterfacewriter.vala: support
  libraries with generic types

svn path=/trunk/; revision=368

ChangeLog
vala/valainterface.vala
vala/valainterfacewriter.vala

index f51370d0def448daa12f8948cf181ac60e306f30..e5ba85afe356b00e8c5ecd8a03b3691f77be8ba3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-22  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valainterface.vala, vala/valainterfacewriter.vala: support
+         libraries with generic types
+
 2007-07-22  Jürg Billeter  <j@bitron.ch>
 
        * vala/valasemanticanalyzer.vala: allow inner classes to access private
index 4655f364ab8d271e1cc7b65969a8a6180ce2dc68..2da1cfa48efb1ea103dd70924dfb254681e2419d 100644 (file)
@@ -66,6 +66,15 @@ public class Vala.Interface : DataType {
                scope.add (p.name, p);
        }
 
+       /**
+        * Returns a copy of the type parameter list.
+        *
+        * @return list of type parameters
+        */
+       public List<weak TypeParameter> get_type_parameters () {
+               return type_parameters.copy ();
+       }
+
        /**
         * Adds the specified interface or class to the list of prerequisites of
         * this interface.
index a011a42f1633feb4c1793b235bc7b468f6fbc490..0ee3e394d4bbdd78410f6cc90df7b827a4e70ae7 100644 (file)
@@ -110,7 +110,22 @@ public class Vala.InterfaceWriter : CodeVisitor {
                }
                write_string ("class ");
                write_identifier (cl.name);
-               
+
+               var type_params = cl.get_type_parameters ();
+               if (type_params != null) {
+                       write_string ("<");
+                       bool first = true;
+                       foreach (TypeParameter type_param in type_params) {
+                               if (first) {
+                                       first = false;
+                               } else {
+                                       write_string (",");
+                               }
+                               write_identifier (type_param.name);
+                       }
+                       write_string (">");
+               }
+
                var base_types = cl.get_base_types ();
                if (base_types != null) {
                        write_string (" : ");
@@ -202,6 +217,22 @@ public class Vala.InterfaceWriter : CodeVisitor {
                write_string ("interface ");
                write_identifier (iface.name);
 
+               var type_params = iface.get_type_parameters ();
+               if (type_params != null) {
+                       write_string ("<");
+                       bool first = true;
+                       foreach (TypeParameter type_param in type_params) {
+                               if (first) {
+                                       first = false;
+                               } else {
+                                       write_string (",");
+                               }
+                               write_identifier (type_param.name);
+                       }
+                       write_string (">");
+               }
+
+
                write_begin_block ();
 
                iface.accept_children (this);
@@ -323,7 +354,11 @@ public class Vala.InterfaceWriter : CodeVisitor {
                        } else if (param.type_reference.is_out) {
                                write_string ("out ");
                        }
-                       write_string (param.type_reference.data_type.get_full_name ());
+                       if (param.type_reference.data_type != null) {
+                               write_string (param.type_reference.data_type.get_full_name ());
+                       } else {
+                               write_string (param.type_reference.type_parameter.name);
+                       }
                        
                        var type_args = param.type_reference.get_type_arguments ();
                        if (!(param.type_reference.data_type is Array) && type_args != null) {