Commit 123f7049 authored by Jürg Billeter's avatar Jürg Billeter

Add Variable class

parent c866eed9
......@@ -1034,12 +1034,12 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
}
public override void generate_parameter (FormalParameter param, CCodeDeclarationSpace decl_space, Map<int,CCodeFormalParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
if (!(param.parameter_type is ArrayType)) {
if (!(param.variable_type is ArrayType)) {
base.generate_parameter (param, decl_space, cparam_map, carg_map);
return;
}
string ctypename = param.parameter_type.get_cname ();
string ctypename = param.variable_type.get_cname ();
if (param.direction != ParameterDirection.IN) {
ctypename += "*";
......@@ -1047,7 +1047,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
param.ccodenode = new CCodeFormalParameter (get_variable_cname (param.name), ctypename);
var array_type = (ArrayType) param.parameter_type;
var array_type = (ArrayType) param.variable_type;
generate_type_declaration (array_type.element_type, decl_space);
......
This diff is collapsed.
......@@ -57,8 +57,8 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
cfundecl.add_parameter ((CCodeFormalParameter) param.ccodenode);
// handle array parameters
if (!param.no_array_length && param.parameter_type is ArrayType) {
var array_type = (ArrayType) param.parameter_type;
if (!param.no_array_length && param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
var length_ctype = "int";
if (param.direction != ParameterDirection.IN) {
......@@ -71,8 +71,8 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
}
}
// handle delegate parameters
if (param.parameter_type is DelegateType) {
var deleg_type = (DelegateType) param.parameter_type;
if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
var param_d = deleg_type.delegate_symbol;
if (param_d.has_target) {
var cparam = new CCodeFormalParameter (get_delegate_target_cname (get_variable_cname (param.name)), "void*");
......@@ -398,8 +398,8 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
var d_params = d.get_parameters ();
foreach (FormalParameter param in d_params) {
if (dynamic_sig != null
&& param.parameter_type is ArrayType
&& ((ArrayType) param.parameter_type).element_type.data_type == string_type.data_type) {
&& param.variable_type is ArrayType
&& ((ArrayType) param.variable_type).element_type.data_type == string_type.data_type) {
// use null-terminated string arrays for dynamic signals for compatibility reasons
param.no_array_length = true;
param.array_null_terminated = true;
......@@ -489,8 +489,8 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
carg_map.set (get_param_pos (param.cparameter_position), arg);
// handle array arguments
if (!param.no_array_length && param.parameter_type is ArrayType) {
var array_type = (ArrayType) param.parameter_type;
if (!param.no_array_length && param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
CCodeExpression clength;
if (d_params.get (i).array_null_terminated) {
......@@ -505,8 +505,8 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
}
carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), clength);
}
} else if (param.parameter_type is DelegateType) {
var deleg_type = (DelegateType) param.parameter_type;
} else if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
if (deleg_type.delegate_symbol.has_target) {
var ctarget = new CCodeIdentifier (get_delegate_target_cname (d_params.get (i).name));
......@@ -613,17 +613,17 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
}
public override void generate_parameter (FormalParameter param, CCodeDeclarationSpace decl_space, Map<int,CCodeFormalParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
if (!(param.parameter_type is DelegateType || param.parameter_type is MethodType)) {
if (!(param.variable_type is DelegateType || param.variable_type is MethodType)) {
base.generate_parameter (param, decl_space, cparam_map, carg_map);
return;
}
string ctypename = param.parameter_type.get_cname ();
string ctypename = param.variable_type.get_cname ();
string target_ctypename = "void*";
string target_destroy_notify_ctypename = "GDestroyNotify";
if (param.parent_symbol is Delegate
&& param.parameter_type.get_cname () == ((Delegate) param.parent_symbol).get_cname ()) {
&& param.variable_type.get_cname () == ((Delegate) param.parent_symbol).get_cname ()) {
// recursive delegate
ctypename = "GCallback";
}
......@@ -641,8 +641,8 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
carg_map.set (get_param_pos (param.cparameter_position), get_variable_cexpression (param.name));
}
if (param.parameter_type is DelegateType) {
var deleg_type = (DelegateType) param.parameter_type;
if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
var d = deleg_type.delegate_symbol;
generate_delegate_declaration (d, decl_space);
......@@ -661,7 +661,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
}
}
}
} else if (param.parameter_type is MethodType) {
} else if (param.variable_type is MethodType) {
var cparam = new CCodeFormalParameter (get_delegate_target_cname (get_variable_cname (param.name)), target_ctypename);
cparam_map.set (get_param_pos (param.cdelegate_target_parameter_position), cparam);
if (carg_map != null) {
......
......@@ -395,9 +395,9 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
// use closure
expr.ccodenode = get_variable_cexpression (p.name);
} else {
var type_as_struct = p.parameter_type.data_type as Struct;
var type_as_struct = p.variable_type.data_type as Struct;
if (p.direction != ParameterDirection.IN
|| (type_as_struct != null && !type_as_struct.is_simple_type () && !p.parameter_type.nullable)) {
|| (type_as_struct != null && !type_as_struct.is_simple_type () && !p.variable_type.nullable)) {
expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier (get_variable_cname (p.name)));
} else {
// Property setters of non simple structs shall replace all occurences
......
......@@ -347,8 +347,8 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
carg_map = out_arg_map;
}
if (!param.no_array_length && param.parameter_type is ArrayType) {
var array_type = (ArrayType) param.parameter_type;
if (!param.no_array_length && param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
CCodeExpression? array_length_expr = null;
if (param.array_length_type != null) {
......@@ -381,8 +381,8 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), array_length_expr);
}
multiple_cargs = true;
} else if (param.parameter_type is DelegateType) {
var deleg_type = (DelegateType) param.parameter_type;
} else if (param.variable_type is DelegateType) {
var deleg_type = (DelegateType) param.variable_type;
var d = deleg_type.delegate_symbol;
if (d.has_target) {
CCodeExpression delegate_target_destroy_notify;
......@@ -402,14 +402,14 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
multiple_cargs = true;
}
}
} else if (param.parameter_type is MethodType) {
} else if (param.variable_type is MethodType) {
// callbacks in dynamic method calls
CCodeExpression delegate_target_destroy_notify;
carg_map.set (get_param_pos (param.cdelegate_target_parameter_position), get_delegate_target_cexpression (arg, out delegate_target_destroy_notify));
multiple_cargs = true;
} else if (param.parameter_type is GenericType) {
} else if (param.variable_type is GenericType) {
if (m != null && m.simple_generics) {
var generic_type = (GenericType) param.parameter_type;
var generic_type = (GenericType) param.variable_type;
int type_param_index = m.get_type_parameter_index (generic_type.type_parameter.name);
var type_arg = ma.get_type_arguments ().get (type_param_index);
if (requires_copy (type_arg)) {
......@@ -445,13 +445,13 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
// disabled for arrays for now as that requires special handling
// (ret_tmp = call (&tmp), var1 = (assign_tmp = dup (tmp), free (var1), assign_tmp), ret_tmp)
if (param.direction != ParameterDirection.IN && requires_destroy (arg.value_type)
&& (param.direction == ParameterDirection.OUT || !param.parameter_type.value_owned)
&& !(param.parameter_type is ArrayType) && !(param.parameter_type is DelegateType)) {
&& (param.direction == ParameterDirection.OUT || !param.variable_type.value_owned)
&& !(param.variable_type is ArrayType) && !(param.variable_type is DelegateType)) {
var unary = (UnaryExpression) arg;
var ccomma = new CCodeCommaExpression ();
var temp_var = get_temp_variable (param.parameter_type, param.parameter_type.value_owned);
var temp_var = get_temp_variable (param.variable_type, param.variable_type.value_owned);
temp_vars.insert (0, temp_var);
cexpr = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression (temp_var.name));
......@@ -478,7 +478,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
var assign_temp_var = get_temp_variable (unary.inner.value_type, unary.inner.value_type.value_owned, null, false);
temp_vars.insert (0, assign_temp_var);
cassign_comma.append_expression (new CCodeAssignment (get_variable_cexpression (assign_temp_var.name), transform_expression (get_variable_cexpression (temp_var.name), param.parameter_type, unary.inner.value_type, arg)));
cassign_comma.append_expression (new CCodeAssignment (get_variable_cexpression (assign_temp_var.name), transform_expression (get_variable_cexpression (temp_var.name), param.variable_type, unary.inner.value_type, arg)));
// unref old value
cassign_comma.append_expression (get_unref_expression ((CCodeExpression) unary.inner.ccodenode, arg.value_type, arg));
......
......@@ -544,17 +544,17 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
}
if (param.direction != ParameterDirection.OUT) {
var t = param.parameter_type.data_type;
var t = param.variable_type.data_type;
if (t != null && t.is_reference_type ()) {
var type_check = create_method_type_check_statement (m, creturn_type, t, !param.parameter_type.nullable, get_variable_cname (param.name));
var type_check = create_method_type_check_statement (m, creturn_type, t, !param.variable_type.nullable, get_variable_cname (param.name));
if (type_check != null) {
type_check.line = function.line;
cinit.append (type_check);
}
}
} else if (!m.coroutine) {
var t = param.parameter_type.data_type;
if ((t != null && t.is_reference_type ()) || param.parameter_type is ArrayType) {
var t = param.variable_type.data_type;
if ((t != null && t.is_reference_type ()) || param.variable_type is ArrayType) {
// ensure that the passed reference for output parameter is cleared
var a = new CCodeAssignment (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, get_variable_cexpression (param.name)), new CCodeConstant ("NULL"));
var cblock = new CCodeBlock ();
......@@ -815,19 +815,19 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
public virtual void generate_parameter (FormalParameter param, CCodeDeclarationSpace decl_space, Map<int,CCodeFormalParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
if (!param.ellipsis) {
string ctypename = param.parameter_type.get_cname ();
string ctypename = param.variable_type.get_cname ();
generate_type_declaration (param.parameter_type, decl_space);
generate_type_declaration (param.variable_type, decl_space);
// pass non-simple structs always by reference
if (param.parameter_type.data_type is Struct) {
var st = (Struct) param.parameter_type.data_type;
if (param.variable_type.data_type is Struct) {
var st = (Struct) param.variable_type.data_type;
if (!st.is_simple_type () && param.direction == ParameterDirection.IN) {
if (st.is_immutable && !param.parameter_type.value_owned) {
if (st.is_immutable && !param.variable_type.value_owned) {
ctypename = "const " + ctypename;
}
if (!param.parameter_type.nullable) {
if (!param.variable_type.nullable) {
ctypename += "*";
}
}
......
......@@ -66,18 +66,18 @@ public class Vala.CCodeStructModule : CCodeBaseModule {
instance_struct.deprecated = st.deprecated;
foreach (Field f in st.get_fields ()) {
string field_ctype = f.field_type.get_cname ();
string field_ctype = f.variable_type.get_cname ();
if (f.is_volatile) {
field_ctype = "volatile " + field_ctype;
}
if (f.binding == MemberBinding.INSTANCE) {
generate_type_declaration (f.field_type, decl_space);
generate_type_declaration (f.variable_type, decl_space);
instance_struct.add_field (field_ctype, f.get_cname () + f.field_type.get_cdeclarator_suffix (), f.deprecated ? " G_GNUC_DEPRECATED" : null);
if (f.field_type is ArrayType && !f.no_array_length) {
instance_struct.add_field (field_ctype, f.get_cname () + f.variable_type.get_cdeclarator_suffix (), f.deprecated ? " G_GNUC_DEPRECATED" : null);
if (f.variable_type is ArrayType && !f.no_array_length) {
// create fields to store array dimensions
var array_type = (ArrayType) f.field_type;
var array_type = (ArrayType) f.variable_type;
if (!array_type.fixed_length) {
var len_type = int_type.copy ();
......@@ -90,8 +90,8 @@ public class Vala.CCodeStructModule : CCodeBaseModule {
instance_struct.add_field (len_type.get_cname (), head.get_array_size_cname (f.name));
}
}
} else if (f.field_type is DelegateType) {
var delegate_type = (DelegateType) f.field_type;
} else if (f.variable_type is DelegateType) {
var delegate_type = (DelegateType) f.variable_type;
if (delegate_type.delegate_symbol.has_target) {
// create field to store delegate target
instance_struct.add_field ("gpointer", get_delegate_target_cname (f.name));
......@@ -259,17 +259,17 @@ public class Vala.CCodeStructModule : CCodeBaseModule {
foreach (var f in st.get_fields ()) {
if (f.binding == MemberBinding.INSTANCE) {
CCodeExpression copy = new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), f.name);
if (requires_copy (f.field_type)) {
if (requires_copy (f.variable_type)) {
var this_access = new MemberAccess.simple ("this");
this_access.value_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
this_access.ccodenode = new CCodeIdentifier ("(*self)");
var ma = new MemberAccess (this_access, f.name);
ma.symbol_reference = f;
copy = get_ref_cexpression (f.field_type, copy, ma, f);
copy = get_ref_cexpression (f.variable_type, copy, ma, f);
}
var dest = new CCodeMemberAccess.pointer (new CCodeIdentifier ("dest"), f.name);
var array_type = f.field_type as ArrayType;
var array_type = f.variable_type as ArrayType;
if (array_type != null && array_type.fixed_length) {
// fixed-length (stack-allocated) arrays
source_declarations.add_include ("string.h");
......
......@@ -173,15 +173,15 @@ public class Vala.DBusClientModule : DBusModule {
int i = 0;
foreach (FormalParameter param in reply_method.get_parameters ()) {
if ((++i) == param_count) {
if (!(param.parameter_type is ErrorType)) {
if (!(param.variable_type is ErrorType)) {
Report.error (null, "DBus reply callbacks must end with GLib.Error argument");
return;
}
break;
}
if (param.parameter_type is ArrayType && ((ArrayType) param.parameter_type).element_type.data_type != string_type.data_type) {
var array_type = (ArrayType) param.parameter_type;
if (param.variable_type is ArrayType && ((ArrayType) param.variable_type).element_type.data_type != string_type.data_type) {
var array_type = (ArrayType) param.variable_type;
CCodeDeclaration cdecl;
if (dbus_use_ptr_array (array_type)) {
cdecl = new CCodeDeclaration ("GPtrArray*");
......@@ -195,14 +195,14 @@ public class Vala.DBusClientModule : DBusModule {
creply_call.add_argument (new CCodeCastExpression (new CCodeMemberAccess.pointer (new CCodeIdentifier (param.name), dbus_use_ptr_array (array_type) ? "pdata" : "data"), array_type.get_cname ()));
creply_call.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier (param.name), "len"));
} else {
var cdecl = new CCodeDeclaration (param.parameter_type.get_cname ());
var cdecl = new CCodeDeclaration (param.variable_type.get_cname ());
cdecl.add_declarator (new CCodeVariableDeclarator (param.name));
cb_fun.block.add_statement (cdecl);
cend_call.add_argument (get_dbus_g_type (param.parameter_type));
cend_call.add_argument (get_dbus_g_type (param.variable_type));
cend_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param.name)));
creply_call.add_argument (new CCodeIdentifier (param.name));
if (param.parameter_type is ArrayType && ((ArrayType) param.parameter_type).element_type.data_type == string_type.data_type) {
if (param.variable_type is ArrayType && ((ArrayType) param.variable_type).element_type.data_type == string_type.data_type) {
var cstrvlen = new CCodeFunctionCall (new CCodeIdentifier ("g_strv_length"));
cstrvlen.add_argument (new CCodeIdentifier (param.name));
creply_call.add_argument (cstrvlen);
......@@ -244,8 +244,8 @@ public class Vala.DBusClientModule : DBusModule {
}
foreach (FormalParameter param in method.get_parameters ()) {
if (param.parameter_type is MethodType
|| param.parameter_type is DelegateType) {
if (param.variable_type is MethodType
|| param.variable_type is DelegateType) {
// callback parameter
break;
}
......@@ -254,7 +254,7 @@ public class Vala.DBusClientModule : DBusModule {
continue;
}
var array_type = param.parameter_type as ArrayType;
var array_type = param.variable_type as ArrayType;
if (array_type != null) {
// array parameter
if (array_type.element_type.data_type != string_type.data_type) {
......@@ -308,9 +308,9 @@ public class Vala.DBusClientModule : DBusModule {
ccall.add_argument (new CCodeIdentifier ("G_TYPE_STRV"));
ccall.add_argument (new CCodeIdentifier (param.name));
}
} else if (get_type_signature (param.parameter_type).has_prefix ("(")) {
} else if (get_type_signature (param.variable_type).has_prefix ("(")) {
// struct parameter
var st = (Struct) param.parameter_type.data_type;
var st = (Struct) param.variable_type.data_type;
var array_construct = new CCodeFunctionCall (new CCodeIdentifier ("g_value_array_new"));
array_construct.add_argument (new CCodeConstant ("0"));
......@@ -338,10 +338,10 @@ public class Vala.DBusClientModule : DBusModule {
var cinit_call = new CCodeFunctionCall (new CCodeIdentifier ("g_value_init"));
cinit_call.add_argument (val_ptr);
cinit_call.add_argument (new CCodeIdentifier (f.field_type.data_type.get_type_id ()));
cinit_call.add_argument (new CCodeIdentifier (f.variable_type.data_type.get_type_id ()));
block.add_statement (new CCodeExpressionStatement (cinit_call));
var cset_call = new CCodeFunctionCall (new CCodeIdentifier (f.field_type.data_type.get_set_value_function ()));
var cset_call = new CCodeFunctionCall (new CCodeIdentifier (f.variable_type.data_type.get_set_value_function ()));
cset_call.add_argument (val_ptr);
cset_call.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier (param.name), f.name));
block.add_statement (new CCodeExpressionStatement (cset_call));
......@@ -352,10 +352,10 @@ public class Vala.DBusClientModule : DBusModule {
block.add_statement (new CCodeExpressionStatement (cappend_call));
}
ccall.add_argument (get_dbus_g_type (param.parameter_type));
ccall.add_argument (get_dbus_g_type (param.variable_type));
ccall.add_argument (new CCodeIdentifier ("dbus_%s".printf (param.name)));
} else {
ccall.add_argument (get_dbus_g_type (param.parameter_type));
ccall.add_argument (get_dbus_g_type (param.variable_type));
ccall.add_argument (new CCodeIdentifier (param.name));
}
}
......@@ -365,7 +365,7 @@ public class Vala.DBusClientModule : DBusModule {
var out_marshalling_fragment = new CCodeFragment ();
foreach (FormalParameter param in method.get_parameters ()) {
if (param.parameter_type is MethodType) {
if (param.variable_type is MethodType) {
// callback parameter
break;
}
......@@ -374,9 +374,9 @@ public class Vala.DBusClientModule : DBusModule {
continue;
}
if (get_type_signature (param.parameter_type).has_prefix ("(")) {
if (get_type_signature (param.variable_type).has_prefix ("(")) {
// struct output parameter
var st = (Struct) param.parameter_type.data_type;
var st = (Struct) param.variable_type.data_type;
var cdecl = new CCodeDeclaration ("GValueArray*");
cdecl.add_declarator (new CCodeVariableDeclarator ("dbus_%s".printf (param.name)));
......@@ -388,13 +388,13 @@ public class Vala.DBusClientModule : DBusModule {
continue;
}
var cget_call = new CCodeFunctionCall (new CCodeIdentifier (f.field_type.data_type.get_get_value_function ()));
var cget_call = new CCodeFunctionCall (new CCodeIdentifier (f.variable_type.data_type.get_get_value_function ()));
cget_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeElementAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier ("dbus_%s".printf (param.name)), "values"), new CCodeConstant (i.to_string ()))));
var converted_value = cget_call;
if (requires_copy (f.field_type)) {
var dupexpr = get_dup_func_expression (f.field_type, expr.source_reference);
if (requires_copy (f.variable_type)) {
var dupexpr = get_dup_func_expression (f.variable_type, expr.source_reference);
converted_value = new CCodeFunctionCall (dupexpr);
converted_value.add_argument (cget_call);
}
......@@ -405,10 +405,10 @@ public class Vala.DBusClientModule : DBusModule {
i++;
}
ccall.add_argument (get_dbus_g_type (param.parameter_type));
ccall.add_argument (get_dbus_g_type (param.variable_type));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("dbus_%s".printf (param.name))));
} else {
ccall.add_argument (get_dbus_g_type (param.parameter_type));
ccall.add_argument (get_dbus_g_type (param.variable_type));
ccall.add_argument (new CCodeIdentifier (param.name));
}
}
......@@ -470,13 +470,13 @@ public class Vala.DBusClientModule : DBusModule {
continue;
}
var cget_call = new CCodeFunctionCall (new CCodeIdentifier (f.field_type.data_type.get_get_value_function ()));
var cget_call = new CCodeFunctionCall (new CCodeIdentifier (f.variable_type.data_type.get_get_value_function ()));
cget_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeElementAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier ("dbus_result"), "values"), new CCodeConstant (i.to_string ()))));
var converted_value = cget_call;
if (requires_copy (f.field_type)) {
var dupexpr = get_dup_func_expression (f.field_type, expr.source_reference);
if (requires_copy (f.variable_type)) {
var dupexpr = get_dup_func_expression (f.variable_type, expr.source_reference);
converted_value = new CCodeFunctionCall (dupexpr);
converted_value.add_argument (cget_call);
}
......@@ -594,7 +594,7 @@ public class Vala.DBusClientModule : DBusModule {
continue;
}
type_call.add_argument (get_dbus_g_type (f.field_type));
type_call.add_argument (get_dbus_g_type (f.variable_type));
}
type_call.add_argument (new CCodeConstant ("G_TYPE_INVALID"));
......@@ -877,8 +877,8 @@ public class Vala.DBusClientModule : DBusModule {
continue;
}
register_call.add_argument (get_dbus_g_type (param.parameter_type));
add_call.add_argument (get_dbus_g_type (param.parameter_type));
register_call.add_argument (get_dbus_g_type (param.variable_type));
add_call.add_argument (get_dbus_g_type (param.variable_type));
}
register_call.add_argument (new CCodeIdentifier ("G_TYPE_INVALID"));
add_call.add_argument (new CCodeIdentifier ("G_TYPE_INVALID"));
......@@ -1540,27 +1540,27 @@ public class Vala.DBusClientModule : DBusModule {
string type_signature = "";
foreach (FormalParameter param in sig.get_parameters ()) {
var owned_type = param.parameter_type.copy ();
var owned_type = param.variable_type.copy ();
owned_type.value_owned = true;
cdecl = new CCodeDeclaration (owned_type.get_cname ());
cdecl.add_declarator (new CCodeVariableDeclarator.zero (param.name, default_value_for_type (param.parameter_type, true)));
cdecl.add_declarator (new CCodeVariableDeclarator.zero (param.name, default_value_for_type (param.variable_type, true)));
prefragment.append (cdecl);
if (get_type_signature (param.parameter_type) == null) {
Report.error (param.parameter_type.source_reference, "D-Bus serialization of type `%s' is not supported".printf (param.parameter_type.to_string ()));
if (get_type_signature (param.variable_type) == null) {
Report.error (param.variable_type.source_reference, "D-Bus serialization of type `%s' is not supported".printf (param.variable_type.to_string ()));
continue;
}
var st = param.parameter_type.data_type as Struct;
var st = param.variable_type.data_type as Struct;
if (st != null && !st.is_simple_type ()) {
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param.name)));
} else {
ccall.add_argument (new CCodeIdentifier (param.name));
}
if (param.parameter_type is ArrayType) {
var array_type = (ArrayType) param.parameter_type;
if (param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
string length_cname = get_array_length_cname (param.name, dim);
......@@ -1572,10 +1572,10 @@ public class Vala.DBusClientModule : DBusModule {
}
}
type_signature += get_type_signature (param.parameter_type);
type_signature += get_type_signature (param.variable_type);
var target = new CCodeIdentifier (param.name);
var expr = read_expression (prefragment, param.parameter_type, new CCodeIdentifier ("iter"), target);
var expr = read_expression (prefragment, param.variable_type, new CCodeIdentifier ("iter"), target);
prefragment.append (new CCodeExpressionStatement (new CCodeAssignment (target, expr)));
if (requires_destroy (owned_type)) {
......@@ -1682,26 +1682,26 @@ public class Vala.DBusClientModule : DBusModule {
foreach (FormalParameter param in m.get_parameters ()) {
if (param.direction == ParameterDirection.IN) {
if (param.parameter_type.data_type != null
&& param.parameter_type.data_type.get_full_name () == "DBus.BusName") {
if (param.variable_type.data_type != null
&& param.variable_type.data_type.get_full_name () == "DBus.BusName") {
// ignore BusName sender parameters
continue;
}
CCodeExpression expr = new CCodeIdentifier (param.name);
if (param.parameter_type.is_real_struct_type ()) {
if (param.variable_type.is_real_struct_type ()) {
expr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, expr);
}
write_expression (prefragment, param.parameter_type, new CCodeIdentifier ("_iter"), expr);
write_expression (prefragment, param.variable_type, new CCodeIdentifier ("_iter"), expr);
} else {
if (no_reply) {
Report.error (param.source_reference, "No-reply DBus methods must not have out parameters");
break;
}
cdecl = new CCodeDeclaration (param.parameter_type.get_cname ());
cdecl = new CCodeDeclaration (param.variable_type.get_cname ());
cdecl.add_declarator (new CCodeVariableDeclarator ("_" + param.name));
postfragment.append (cdecl);
var array_type = param.parameter_type as ArrayType;
var array_type = param.variable_type as ArrayType;
if (array_type != null) {
for (int dim = 1; dim <= array_type.rank; dim++) {
......@@ -1712,7 +1712,7 @@ public class Vala.DBusClientModule : DBusModule {
}
var target = new CCodeIdentifier ("_" + param.name);
var expr = read_expression (postfragment, param.parameter_type, new CCodeIdentifier ("_iter"), target);
var expr = read_expression (postfragment, param.variable_type, new CCodeIdentifier ("_iter"), target);
postfragment.append (new CCodeExpressionStatement (new CCodeAssignment (target, expr)));
// TODO check that parameter is not NULL (out parameters are optional)
......@@ -2266,7 +2266,7 @@ public class Vala.DBusClientModule : DBusModule {
foreach (FormalParameter param in m.get_parameters ()) {
if (param.direction == ParameterDirection.OUT) {
type_signature += get_type_signature (param.parameter_type);
type_signature += get_type_signature (param.variable_type);
}
}
......
......@@ -126,7 +126,7 @@ public class Vala.DBusModule : GAsyncModule {
str.append_c ('(');
foreach (Field f in st.get_fields ()) {
if (f.binding == MemberBinding.INSTANCE) {
str.append (get_type_signature (f.field_type));
str.append (get_type_signature (f.variable_type));
}
}
str.append_c (')');
......@@ -418,7 +418,7 @@ public class Vala.DBusModule : GAsyncModule {
continue;
}
var field_expr = read_expression (fragment, f.field_type, new CCodeIdentifier (subiter_name), new CCodeMemberAccess (new CCodeIdentifier (temp_name), f.get_cname ()));
var field_expr = read_expression (fragment, f.variable_type, new CCodeIdentifier (subiter_name), new CCodeMemberAccess (new CCodeIdentifier (temp_name), f.get_cname ()));
fragment.append (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess (new CCodeIdentifier (temp_name), f.get_cname ()), field_expr)));
}
......@@ -783,7 +783,7 @@ public class Vala.DBusModule : GAsyncModule {
continue;
}
write_expression (fragment, f.field_type, new CCodeIdentifier (subiter_name), new CCodeMemberAccess (struct_expr, f.get_cname ()));
write_expression (fragment, f.variable_type, new CCodeIdentifier (subiter_name), new CCodeMemberAccess (struct_expr, f.get_cname ()));
}
iter_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_message_iter_close_container"));
......
......@@ -181,11 +181,11 @@ public class Vala.DBusServerModule : DBusClientModule {
string type_signature = "";
foreach (FormalParameter param in m.get_parameters ()) {
var owned_type = param.parameter_type.copy ();
var owned_type = param.variable_type.copy ();
owned_type.value_owned = true;
cdecl = new CCodeDeclaration (owned_type.get_cname ());
cdecl.add_declarator (new CCodeVariableDeclarator.zero (param.name, default_value_for_type (param.parameter_type, true)));
cdecl.add_declarator (new CCodeVariableDeclarator.zero (param.name, default_value_for_type (param.variable_type, true)));
if (param.direction == ParameterDirection.IN) {
in_prefragment.append (cdecl);
} else {
......@@ -193,8 +193,8 @@ public class Vala.DBusServerModule : DBusClientModule {
}
if (type_signature == ""
&& param.direction == ParameterDirection.IN
&& param.parameter_type.data_type != null
&& param.parameter_type.data_type.get_full_name () == "DBus.BusName") {
&& param.variable_type.data_type != null
&& param.variable_type.data_type.get_full_name () == "DBus.BusName") {
// first parameter is a string parameter called 'sender'
// pass bus name of sender
var get_sender = new CCodeFunctionCall (new CCodeIdentifier ("dbus_message_get_sender"));
......@@ -203,13 +203,13 @@ public class Vala.DBusServerModule : DBusClientModule {
continue;
}
if (get_type_signature (param.parameter_type) == null) {
Report.error (param.parameter_type.source_reference, "D-Bus serialization of type `%s' is not supported".printf (param.parameter_type.to_string ()));
if (get_type_signature (param.variable_type) == null) {
Report.error (param.variable_type.source_reference, "D-Bus serialization of type `%s' is not supported".printf (param.variable_type.to_string ()));
continue;
}
if (!m.coroutine || param.direction == ParameterDirection.IN) {
var st = param.parameter_type.data_type as Struct;
var st = param.variable_type.data_type as Struct;
if (param.direction != ParameterDirection.IN
|| (st != null && !st.is_simple_type ())) {
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param.name)));
......@@ -220,8 +220,8 @@ public class Vala.DBusServerModule : DBusClientModule {
finish_ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param.name)));
}
if (param.parameter_type is ArrayType) {
var array_type = (ArrayType) param.parameter_type;
if (param.variable_type is ArrayType) {
var array_type = (ArrayType) param.variable_type;
for (int dim = 1; dim <= array_type.rank; dim++) {
string length_cname = get_array_length_cname (param.name, dim);
......@@ -244,13 +244,13 @@ public class Vala.DBusServerModule : DBusClientModule {
}
if (param.direction == ParameterDirection.IN) {
type_signature += get_type_signature (param.parameter_type);
type_signature += get_type_signature (param.variable_type);
var target = new CCodeIdentifier (param.name);
var expr = read_expression (in_prefragment, param.parameter_type, new CCodeIdentifier ("iter"), target);
var expr = read_expression (in_prefragment, param.variable_type, new CCodeIdentifier ("iter"), target);
in_prefragment.append (new CCodeExpressionStatement (new CCodeAssignment (target, expr)));