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 f51370d..e5ba85a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 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
          members of outer classes
 
index 4655f36..2da1cfa 100644 (file)
@@ -67,6 +67,15 @@ public class Vala.Interface : DataType {
        }
 
        /**
+        * 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 a011a42..0ee3e39 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) {