vala r2450 - in trunk: . gobject



Author: juergbi
Date: Tue Feb 17 19:33:24 2009
New Revision: 2450
URL: http://svn.gnome.org/viewvc/vala?rev=2450&view=rev

Log:
2009-02-17  JÃrg Billeter  <j bitron ch>

	* gobject/valaccodemethodcallmodule.vala:

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


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodemethodcallmodule.vala

Modified: trunk/gobject/valaccodemethodcallmodule.vala
==============================================================================
--- trunk/gobject/valaccodemethodcallmodule.vala	(original)
+++ trunk/gobject/valaccodemethodcallmodule.vala	Tue Feb 17 19:33:24 2009
@@ -91,6 +91,37 @@
 
 		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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]