From: Jürg Billeter Date: Tue, 17 Feb 2009 19:33:24 +0000 (+0000) Subject: Support chaining up to constructors in generic classes, fixes bug 567319 X-Git-Tag: 0.5.7~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b8b6ef1c6c6d18fb00957e5d52a4e01779fba3b;p=thirdparty%2Fvala.git Support chaining up to constructors in generic classes, fixes bug 567319 2009-02-17 Jürg Billeter * gobject/valaccodemethodcallmodule.vala: Support chaining up to constructors in generic classes, fixes bug 567319 svn path=/trunk/; revision=2450 --- diff --git a/ChangeLog b/ChangeLog index 7cef3ea41..a12acc43e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-02-17 Jürg Billeter + + * gobject/valaccodemethodcallmodule.vala: + + Support chaining up to constructors in generic classes, + fixes bug 567319 + 2009-02-17 Ali Sabil * vapigen/valagidlparser.vala: diff --git a/gobject/valaccodemethodcallmodule.vala b/gobject/valaccodemethodcallmodule.vala index 25e9eb725..f77aaaf64 100644 --- a/gobject/valaccodemethodcallmodule.vala +++ b/gobject/valaccodemethodcallmodule.vala @@ -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