Commit 16014285 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

Fix crash when using signals with array parameters, fixes bug 538212

2008-06-15  Jürg Billeter  <j@bitron.ch>

	* gobject/valaccodegeneratorsignal.vala:
	* gobject/valaccodetypesymbolbinding.vala:

	Fix crash when using signals with array parameters,
	fixes bug 538212

svn path=/trunk/; revision=1583
parent 23f211fb
2008-06-15 Jürg Billeter <j@bitron.ch>
* gobject/valaccodegeneratorsignal.vala:
* gobject/valaccodetypesymbolbinding.vala:
Fix crash when using signals with array parameters,
fixes bug 538212
2008-06-15 Jürg Billeter <j@bitron.ch>
* vapi/packages/vte/:
......
......@@ -30,10 +30,18 @@ public class Vala.CCodeGenerator {
} else if (t is ErrorType) {
return ("POINTER");
} else if (t is ArrayType) {
if (((ArrayType) t).element_type.data_type == string_type.data_type) {
return ("BOXED");
if (dbus) {
if (((ArrayType) t).element_type.data_type == string_type.data_type) {
return ("BOXED");
} else {
return ("POINTER");
}
} else {
return ("POINTER");
if (((ArrayType) t).element_type.data_type == string_type.data_type) {
return ("BOXED_INT");
} else {
return ("POINTER_INT");
}
}
} else if (t is VoidType) {
return ("VOID");
......@@ -179,6 +187,10 @@ public class Vala.CCodeGenerator {
foreach (FormalParameter p in params) {
callback_decl.add_parameter (new CCodeFormalParameter ("arg_%d".printf (n_params), get_value_type_name_from_parameter (p)));
n_params++;
if (p.parameter_type.is_array () && !dbus) {
callback_decl.add_parameter (new CCodeFormalParameter ("arg_%d".printf (n_params), "gint"));
n_params++;
}
}
callback_decl.add_parameter (new CCodeFormalParameter ("data2", "gpointer"));
marshaller_body.add_statement (new CCodeTypeDefinition (get_value_type_name_from_type_reference (return_type), callback_decl));
......@@ -235,7 +247,14 @@ public class Vala.CCodeGenerator {
i = 1;
foreach (FormalParameter p in params) {
string get_value_function;
if (p.parameter_type is PointerType || p.parameter_type.type_parameter != null || p.direction != ParameterDirection.IN) {
bool is_array = p.parameter_type.is_array ();
if (is_array) {
if (((ArrayType) p.parameter_type).element_type.data_type == string_type.data_type) {
get_value_function = "g_value_get_boxed";
} else {
get_value_function = "g_value_get_pointer";
}
} else if (p.parameter_type is PointerType || p.parameter_type.type_parameter != null || p.direction != ParameterDirection.IN) {
get_value_function = "g_value_get_pointer";
} else if (p.parameter_type is ErrorType) {
get_value_function = "g_value_get_pointer";
......@@ -248,6 +267,12 @@ public class Vala.CCodeGenerator {
inner_fc.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("param_values"), new CCodeIdentifier (i.to_string ())));
fc.add_argument (inner_fc);
i++;
if (is_array && !dbus) {
inner_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_get_int"));
inner_fc.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("param_values"), new CCodeIdentifier (i.to_string ())));
fc.add_argument (inner_fc);
i++;
}
}
fc.add_argument (new CCodeIdentifier ("data2"));
......@@ -256,7 +281,7 @@ public class Vala.CCodeGenerator {
CCodeFunctionCall set_fc;
if (return_type.is_array ()) {
if (((ArrayType)return_type).element_type.data_type == string_type.data_type) {
if (((ArrayType) return_type).element_type.data_type == string_type.data_type) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_boxed"));
} else {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
......
......@@ -181,7 +181,6 @@ public abstract class Vala.CCodeTypeSymbolBinding : CCodeBinding {
csignew.add_argument (marshal_arg);
var params = sig.get_parameters ();
var params_len = params.size;
if (sig.return_type is PointerType || sig.return_type.type_parameter != null) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (sig.return_type is ErrorType) {
......@@ -191,9 +190,25 @@ public abstract class Vala.CCodeTypeSymbolBinding : CCodeBinding {
} else {
csignew.add_argument (new CCodeConstant (sig.return_type.data_type.get_type_id ()));
}
int params_len = 0;
foreach (FormalParameter param in params) {
params_len++;
if (param.parameter_type.is_array ()) {
params_len++;
}
}
csignew.add_argument (new CCodeConstant ("%d".printf (params_len)));
foreach (FormalParameter param in params) {
if (param.parameter_type is PointerType || param.parameter_type.type_parameter != null || param.direction != ParameterDirection.IN) {
if (param.parameter_type.is_array ()) {
if (((ArrayType) param.parameter_type).element_type.data_type == codegen.string_type.data_type) {
csignew.add_argument (new CCodeConstant ("G_TYPE_STRV"));
} else {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
}
csignew.add_argument (new CCodeConstant ("G_TYPE_INT"));
} else if (param.parameter_type is PointerType || param.parameter_type.type_parameter != null || param.direction != ParameterDirection.IN) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (param.parameter_type is ErrorType) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
......
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