From: Jürg Billeter Date: Sun, 14 Dec 2008 17:45:55 +0000 (+0000) Subject: Support reading and writing nullable struct values X-Git-Tag: VALA_0_5_3~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f85308c8a04d763e3e930b66baef9099231de5b7;p=thirdparty%2Fvala.git Support reading and writing nullable struct values 2008-12-14 Jürg Billeter * gobject/valadbusmodule.vala: Support reading and writing nullable struct values svn path=/trunk/; revision=2145 --- diff --git a/ChangeLog b/ChangeLog index 995679795..0d05c84a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-12-14 Jürg Billeter + + * gobject/valadbusmodule.vala: + + Support reading and writing nullable struct values + 2008-12-14 Jürg Billeter * gobject/valaccodebasemodule.vala: diff --git a/gobject/valadbusmodule.vala b/gobject/valadbusmodule.vala index 8cc930b1c..f7e29e8ff 100644 --- a/gobject/valadbusmodule.vala +++ b/gobject/valadbusmodule.vala @@ -359,18 +359,19 @@ public class Vala.DBusModule : GAsyncModule { } else if (type is ArrayType) { result = read_array (fragment, (ArrayType) type, iter_expr, expr); } else if (type.data_type is Struct) { + var st = (Struct) type.data_type; if (type.data_type.get_full_name () == "GLib.Value") { result = read_value (fragment, iter_expr); - if (type.nullable) { - var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof")); - csizeof.add_argument (new CCodeIdentifier ("GValue")); - var cdup = new CCodeFunctionCall (new CCodeIdentifier ("g_memdup")); - cdup.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, result)); - cdup.add_argument (csizeof); - result = cdup; - } } else { - result = read_struct (fragment, (Struct) type.data_type, iter_expr); + result = read_struct (fragment, st, iter_expr); + } + if (type.nullable) { + var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof")); + csizeof.add_argument (new CCodeIdentifier (st.get_cname ())); + var cdup = new CCodeFunctionCall (new CCodeIdentifier ("g_memdup")); + cdup.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, result)); + cdup.add_argument (csizeof); + result = cdup; } } else if (type is ObjectType) { if (type.data_type.get_full_name () == "GLib.HashTable") { @@ -607,14 +608,14 @@ public class Vala.DBusModule : GAsyncModule { } else if (type is ArrayType) { write_array (fragment, (ArrayType) type, iter_expr, expr); } else if (type.data_type is Struct) { + var st_expr = expr; + if (type.nullable) { + st_expr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, st_expr); + } if (type.data_type.get_full_name () == "GLib.Value") { - if (type.nullable) { - write_value (fragment, iter_expr, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, expr)); - } else { - write_value (fragment, iter_expr, expr); - } + write_value (fragment, iter_expr, st_expr); } else { - write_struct (fragment, (Struct) type.data_type, iter_expr, expr); + write_struct (fragment, (Struct) type.data_type, iter_expr, st_expr); } } else if (type is ObjectType) { if (type.data_type.get_full_name () == "GLib.HashTable") {