Commit 0f9181b4 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

use gconstpointer where appropriate for generics

2007-11-04  Juerg Billeter  <j@bitron.ch>

	* vala/valatypereference.vala, gobject/valaccodegenerator.vala: use
	  gconstpointer where appropriate for generics

svn path=/trunk/; revision=678
parent 8b48ec9a
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:
......
......@@ -2257,9 +2257,14 @@ public class Vala.CCodeGenerator : CodeGenerator {
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));
......@@ -2291,7 +2296,10 @@ public class Vala.CCodeGenerator : CodeGenerator {
} 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));
......
......@@ -211,7 +211,6 @@ public class Vala.TypeReference : CodeNode {
}
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))) {
......@@ -220,9 +219,13 @@ public class Vala.TypeReference : CodeNode {
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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment