Fixes bug 607558.
/* valadbusclientmodule.vala
*
- * Copyright (C) 2007-2009 Jürg Billeter
+ * Copyright (C) 2007-2010 Jürg Billeter
* Copyright (C) 2008 Philip Van Hoof
*
* This library is free software; you can redistribute it and/or
iter_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_message_iter_open_container"));
iter_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_iter")));
iter_call.add_argument (new CCodeIdentifier ("DBUS_TYPE_VARIANT"));
- iter_call.add_argument (new CCodeConstant ("\"%s\"".printf (prop.property_type.get_type_signature ())));
+ iter_call.add_argument (new CCodeConstant ("\"%s\"".printf (get_type_signature (prop.property_type))));
iter_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_subiter")));
prefragment.append (new CCodeExpressionStatement (iter_call));
/* valadbusmodule.vala
*
- * Copyright (C) 2008-2009 Jürg Billeter
+ * Copyright (C) 2008-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
return false;
}
- public static string get_type_signature (DataType datatype) {
- if (is_string_marshalled_enum (datatype.data_type)) {
+ public static string? get_type_signature (DataType datatype) {
+ var array_type = datatype as ArrayType;
+
+ if (array_type != null) {
+ string element_type_signature = get_type_signature (array_type.element_type);
+
+ if (element_type_signature == null) {
+ return null;
+ }
+
+ return string.nfill (array_type.rank, 'a') + element_type_signature;
+ } else if (is_string_marshalled_enum (datatype.data_type)) {
return "s";
+ } else if (datatype.data_type != null) {
+ string sig = null;
+
+ var ccode = datatype.data_type.get_attribute ("CCode");
+ if (ccode != null) {
+ sig = ccode.get_string ("type_signature");
+ }
+
+ var st = datatype.data_type as Struct;
+ var en = datatype.data_type as Enum;
+ if (sig == null && st != null) {
+ var str = new StringBuilder ();
+ 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_c (')');
+ sig = str.str;
+ } else if (sig == null && en != null) {
+ if (en.is_flags) {
+ return "u";
+ } else {
+ return "i";
+ }
+ }
+
+ var type_args = datatype.get_type_arguments ();
+ if (sig != null && sig.str ("%s") != null && type_args.size > 0) {
+ string element_sig = "";
+ foreach (DataType type_arg in type_args) {
+ var s = get_type_signature (type_arg);
+ if (s != null) {
+ element_sig += s;
+ }
+ }
+
+ sig = sig.printf (element_sig);
+ }
+
+ return sig;
} else {
- return datatype.get_type_signature ();
+ return null;
}
}
return true;
}
- public override string? get_type_signature () {
- string element_type_signature = element_type.get_type_signature ();
-
- if (element_type_signature == null) {
- return null;
- }
-
- return string.nfill (rank, 'a') + element_type_signature;
- }
-
public override void accept_children (CodeVisitor visitor) {
element_type.accept (visitor);
}
private string marshaller_type_name;
private string get_value_function;
private string set_value_function;
- private string? type_signature;
private bool _is_compact;
private bool _is_immutable;
return get_lower_case_cname (infix).up ();
}
- public override string? get_type_signature () {
- return type_signature;
- }
-
public override bool is_reference_type () {
return true;
}
add_cheader_filename (filename);
}
}
- if (a.has_argument ("type_signature")) {
- type_signature = a.get_string ("type_signature");
- }
if (a.has_argument ("type_check_function")) {
type_check_function = a.get_string ("type_check_function");
}
}
}
- /**
- * Returns type signature as used for GVariant and D-Bus.
- */
- public virtual string? get_type_signature () {
- if (data_type != null) {
- string sig = data_type.get_type_signature ();
-
- var type_args = get_type_arguments ();
- if (sig != null && sig.str ("%s") != null && type_args.size > 0) {
- string element_sig = "";
- foreach (DataType type_arg in type_args) {
- var s = type_arg.get_type_signature ();
- if (s != null) {
- element_sig += s;
- }
- }
-
- sig = sig.printf (element_sig);
- }
-
- return sig;
- } else {
- return null;
- }
- }
-
/**
* Returns whether the value needs to be disposed, i.e. whether
* allocated memory or other resources need to be released when
return "0";
}
- public override string? get_type_signature () {
- if (is_flags) {
- return "u";
- } else {
- return "i";
- }
- }
-
public override bool check (SemanticAnalyzer analyzer) {
if (checked) {
return !error;
private string get_value_function;
private string set_value_function;
private string default_value = null;
- private string? type_signature;
private string copy_function;
private string destroy_function;
return get_lower_case_cname (infix).up ();
}
- public override string? get_type_signature () {
- if (type_signature == null) {
- var str = new StringBuilder ();
- str.append_c ('(');
- foreach (Field f in fields) {
- if (f.binding == MemberBinding.INSTANCE) {
- str.append (f.field_type.get_type_signature ());
- }
- }
- str.append_c (')');
- return str.str;
- }
- return type_signature;
- }
-
/**
* Returns whether this is a boolean type.
*
if (a.has_argument ("default_value")) {
set_default_value (a.get_string ("default_value"));
}
- if (a.has_argument ("type_signature")) {
- type_signature = a.get_string ("type_signature");
- }
if (a.has_argument ("copy_function")) {
set_copy_function (a.get_string ("copy_function"));
}
public virtual int get_type_parameter_index (string name) {
return -1;
}
-
- /**
- * Returns type signature as used for GVariant and D-Bus
- */
- public virtual string? get_type_signature () {
- return null;
- }
}