From: Jürg Billeter Date: Sat, 13 Dec 2008 19:37:29 +0000 (+0000) Subject: Support reading and writing nullable GLib.Value values X-Git-Tag: VALA_0_5_3~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82b05520b889a1584489cc9b20ee6ca9cc219123;p=thirdparty%2Fvala.git Support reading and writing nullable GLib.Value values 2008-12-13 Jürg Billeter * gobject/valadbusmodule.vala: Support reading and writing nullable GLib.Value values svn path=/trunk/; revision=2142 --- diff --git a/ChangeLog b/ChangeLog index 6afa5a0d4..c137f2250 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-12-13 Jürg Billeter + + * gobject/valadbusmodule.vala: + + Support reading and writing nullable GLib.Value values + 2008-12-13 Jürg Billeter * vapi/gsl.vapi: diff --git a/gobject/valadbusmodule.vala b/gobject/valadbusmodule.vala index 1e96ddb09..8cc930b1c 100644 --- a/gobject/valadbusmodule.vala +++ b/gobject/valadbusmodule.vala @@ -361,6 +361,14 @@ public class Vala.DBusModule : GAsyncModule { } else if (type.data_type is Struct) { 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); } @@ -600,7 +608,11 @@ public class Vala.DBusModule : GAsyncModule { write_array (fragment, (ArrayType) type, iter_expr, expr); } else if (type.data_type is Struct) { if (type.data_type.get_full_name () == "GLib.Value") { - write_value (fragment, iter_expr, expr); + if (type.nullable) { + write_value (fragment, iter_expr, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, expr)); + } else { + write_value (fragment, iter_expr, expr); + } } else { write_struct (fragment, (Struct) type.data_type, iter_expr, expr); }