Commit 0577d6b8 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

convert integer to pointer for generic parameters to reduce the number of

2006-10-26  Jürg Billeter  <j@bitron.ch>

	* vala/valacodegenerator.vala: convert integer to pointer for generic
	  parameters to reduce the number of warnings during C compilation

svn path=/trunk/; revision=154
parent 295a2e96
2006-10-26 Jürg Billeter <j@bitron.ch>
* vala/valacodegenerator.vala: convert integer to pointer for generic
parameters to reduce the number of warnings during C compilation
2006-10-26 Jürg Billeter <j@bitron.ch>
* vala/valacodegenerator.vala: cast object instances in return
......
......@@ -2755,21 +2755,31 @@ public class Vala.CodeGenerator : CodeVisitor {
if (params != null) {
var param = (FormalParameter) params.data;
ellipsis = param.ellipsis;
if (!param.ellipsis
&& param.type_reference.data_type != null
&& param.type_reference.data_type.is_reference_type ()
&& arg.static_type.data_type != null) {
if (!param.no_array_length && param.type_reference.data_type is Array) {
var arr = (Array) param.type_reference.data_type;
for (int dim = 1; dim <= arr.rank; dim++) {
ccall.add_argument (get_array_length_cexpression (arg, dim));
if (!ellipsis) {
if (param.type_reference.data_type != null
&& param.type_reference.data_type.is_reference_type ()
&& arg.static_type.data_type != null) {
if (!param.no_array_length && param.type_reference.data_type is Array) {
var arr = (Array) param.type_reference.data_type;
for (int dim = 1; dim <= arr.rank; dim++) {
ccall.add_argument (get_array_length_cexpression (arg, dim));
}
}
if (param.type_reference.data_type != arg.static_type.data_type) {
// FIXME: use C cast if debugging disabled
var ccall = new CCodeFunctionCall (new CCodeIdentifier (param.type_reference.data_type.get_upper_case_cname (null)));
ccall.add_argument (cexpr);
cexpr = ccall;
}
} else if (param.type_reference.data_type == null
&& arg.static_type.data_type is Struct) {
/* convert integer to pointer if this is a generic method parameter */
var st = (Struct) arg.static_type.data_type;
if (st == bool_type.data_type || st.is_integer_type ()) {
var cconv = new CCodeFunctionCall (new CCodeIdentifier ("GINT_TO_POINTER"));
cconv.add_argument (cexpr);
cexpr = cconv;
}
}
if (param.type_reference.data_type != arg.static_type.data_type) {
// FIXME: use C cast if debugging disabled
var ccall = new CCodeFunctionCall (new CCodeIdentifier (param.type_reference.data_type.get_upper_case_cname (null)));
ccall.add_argument (cexpr);
cexpr = ccall;
}
}
}
......
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