From: Rico Tzschichholz Date: Wed, 31 Oct 2018 09:21:52 +0000 (+0100) Subject: codegen: Support marshalling ArrayType.length_type in signals X-Git-Tag: 0.43.1~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7dc69101822b7d0836c072ba3dd0007ca6fe7c0e;p=thirdparty%2Fvala.git codegen: Support marshalling ArrayType.length_type in signals --- diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala index b6f60498c..dc1e87b49 100644 --- a/codegen/valaccodeattribute.vala +++ b/codegen/valaccodeattribute.vala @@ -1044,12 +1044,14 @@ public class Vala.CCodeAttribute : AttributeCache { } else if (node is ErrorType) { return "POINTER"; } else if (node is ArrayType) { - if (((ArrayType) node).element_type.data_type.get_full_name () == "string") { - return "BOXED,INT"; + unowned ArrayType array_type = (ArrayType) node; + if (array_type.element_type.data_type.get_full_name () == "string") { + return "BOXED,%s".printf (get_ccode_marshaller_type_name (array_type.length_type.data_type)); } else { var ret = "POINTER"; - for (var i = 0; i < ((ArrayType) node).rank; i++) { - ret = "%s,INT".printf (ret); + var length_marshaller_type_name = get_ccode_marshaller_type_name (array_type.length_type.data_type); + for (var i = 0; i < array_type.rank; i++) { + ret = "%s,%s".printf (ret, length_marshaller_type_name); } return ret; } diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala index fc8a03bbe..966deef44 100644 --- a/codegen/valagsignalmodule.vala +++ b/codegen/valagsignalmodule.vala @@ -194,9 +194,7 @@ public class Vala.GSignalModule : GObjectModule { n_params++; if (p.variable_type is ArrayType) { var array_type = (ArrayType) p.variable_type; - //FIXME Only int length-type - //var length_ctype = get_ccode_array_length_type (array_type); - var length_ctype = get_ccode_name (int_type); + var length_ctype = get_ccode_array_length_type (array_type); for (var j = 0; j < array_type.rank; j++) { callback_decl.add_parameter (new CCodeParameter ("arg_%d".printf (n_params), length_ctype)); n_params++; @@ -270,9 +268,10 @@ public class Vala.GSignalModule : GObjectModule { i++; if (p.variable_type is ArrayType) { var array_type = (ArrayType) p.variable_type; + var length_value_function = get_ccode_get_value_function (array_type.length_type.data_type); + assert (length_value_function != null && length_value_function != ""); for (var j = 0; j < array_type.rank; j++) { - //FIXME Only int length-type - inner_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_get_int")); + inner_fc = new CCodeFunctionCall (new CCodeIdentifier (length_value_function)); inner_fc.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier ("param_values"), new CCodeIdentifier (i.to_string ()))); fc.add_argument (inner_fc); i++; @@ -399,13 +398,16 @@ public class Vala.GSignalModule : GObjectModule { csignew.add_argument (new CCodeConstant ("%d".printf (params_len))); foreach (Parameter param in params) { if (param.variable_type is ArrayType) { - if (((ArrayType) param.variable_type).element_type.data_type == string_type.data_type) { + var array_type = (ArrayType) param.variable_type; + if (array_type.element_type.data_type == string_type.data_type) { csignew.add_argument (new CCodeConstant ("G_TYPE_STRV")); } else { csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER")); } - for (var i = 0; i < ((ArrayType) param.variable_type).rank; i++) { - csignew.add_argument (new CCodeConstant ("G_TYPE_INT")); + assert (get_ccode_has_type_id (array_type.length_type.data_type)); + var length_type_id = get_ccode_type_id (array_type.length_type.data_type); + for (var i = 0; i < array_type.rank; i++) { + csignew.add_argument (new CCodeConstant (length_type_id)); } } else if (param.variable_type is PointerType || param.variable_type is GenericType || param.direction != ParameterDirection.IN) { csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));