+2007-11-04 Jürg Billeter <j@bitron.ch>
+
+ * vala/valatypereference.vala, gobject/valaccodegenerator.vala: use
+ gconstpointer where appropriate for generics
+
2007-11-03 Jürg Billeter <j@bitron.ch>
* gobject/valaccodegenerator.vala, ccode/valaccodemacroreplacement.vala:
var cdupisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, get_dup_func_expression (expr.static_type), new CCodeConstant ("NULL"));
cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.OR, cisnull, cdupisnull);
}
-
- ccall.add_argument (ctemp);
-
+
+ if (expr.static_type.data_type != null) {
+ ccall.add_argument (ctemp);
+ } else {
+ // cast from gconstpointer to gpointer as GBoxedCopyFunc expects gpointer
+ ccall.add_argument (new CCodeCastExpression (ctemp, "gpointer"));
+ }
+
var ccomma = new CCodeCommaExpression ();
ccomma.append_expression (new CCodeAssignment (ctemp, (CCodeExpression) expr.ccodenode));
} else {
// the value might be non-null even when the dup function is null,
// so we may not just use NULL for type parameters
- cifnull = ctemp;
+
+ // cast from gconstpointer to gpointer as methods in
+ // generic classes may not return gconstpointer
+ cifnull = new CCodeCastExpression (ctemp, "gpointer");
}
ccomma.append_expression (new CCodeConditionalExpression (cisnull, cifnull, ccall));
}
string ptr;
- string arr;
if (type_parameter != null || (!data_type.is_reference_type () && !is_ref && !is_out)) {
ptr = "";
} else if ((data_type.is_reference_type () && !is_ref && !is_out) || (!data_type.is_reference_type () && (is_ref || is_out))) {
ptr = "**";
}
if (data_type != null) {
- return data_type.get_cname (const_type).concat (ptr, arr, null);
+ return data_type.get_cname (const_type) + ptr;
} else if (type_parameter != null) {
- return "gpointer".concat (ptr, arr, null);
+ if (const_type) {
+ return "gconstpointer";
+ } else {
+ return "gpointer";
+ }
} else {
/* raise error */
Report.error (source_reference, "unresolved type reference");