]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Support chaining up to constructors in generic classes, fixes bug 567319
authorJürg Billeter <j@bitron.ch>
Tue, 17 Feb 2009 19:33:24 +0000 (19:33 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Tue, 17 Feb 2009 19:33:24 +0000 (19:33 +0000)
2009-02-17  Jürg Billeter  <j@bitron.ch>

* gobject/valaccodemethodcallmodule.vala:

Support chaining up to constructors in generic classes,
fixes bug 567319

svn path=/trunk/; revision=2450

ChangeLog
gobject/valaccodemethodcallmodule.vala

index 7cef3ea41668dfee8ce6fe73c2a5e748ff1bd1e7..a12acc43e11fecafb7331d18528ba5eb0d4d39aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-02-17  Jürg Billeter  <j@bitron.ch>
+
+       * gobject/valaccodemethodcallmodule.vala:
+
+       Support chaining up to constructors in generic classes,
+       fixes bug 567319
+
 2009-02-17  Ali Sabil  <ali.sabil@gmail.com>
 
        * vapigen/valagidlparser.vala:
index 25e9eb7254789c6b958376c3ae2d21fce5bc9714..f77aaaf644c423770753421ab64fcbe1a3b16e34 100644 (file)
@@ -91,6 +91,37 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                if (m is CreationMethod) {
                        ccall.add_argument (new CCodeIdentifier ("object_type"));
+
+                       foreach (DataType base_type in current_class.get_base_types ()) {
+                               if (base_type.data_type is Class) {
+                                       foreach (DataType type_arg in base_type.get_type_arguments ()) {
+                                               if (type_arg is GenericType) {
+                                                       // map generic type parameter
+                                                       string type_param = type_arg.type_parameter.name.down ();
+                                                       ccall.add_argument (new CCodeIdentifier ("%s_type".printf (type_param)));
+                                                       ccall.add_argument (new CCodeIdentifier ("%s_dup_func".printf (type_param)));
+                                                       ccall.add_argument (new CCodeIdentifier ("%s_destroy_func".printf (type_param)));
+                                               } else {
+                                                       ccall.add_argument (new CCodeIdentifier (type_arg.get_type_id ()));
+                                                       if (requires_copy (type_arg)) {
+                                                               var dup_func = get_dup_func_expression (type_arg, type_arg.source_reference);
+                                                               if (dup_func == null) {
+                                                                       // type doesn't contain a copy function
+                                                                       expr.error = true;
+                                                                       return;
+                                                               }
+                                                               ccall.add_argument (new CCodeCastExpression (dup_func, "GBoxedCopyFunc"));
+                                                               ccall.add_argument (get_destroy_func_expression (type_arg));
+                                                       } else {
+                                                               ccall.add_argument (new CCodeConstant ("NULL"));
+                                                               ccall.add_argument (new CCodeConstant ("NULL"));
+                                                       }
+                                               }
+                                       }
+
+                                       break;
+                               }
+                       }
                }
 
                // the complete call expression, might include casts, comma expressions, and/or assignments