]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Support reading and writing nullable struct values
authorJürg Billeter <j@bitron.ch>
Sun, 14 Dec 2008 17:45:55 +0000 (17:45 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 14 Dec 2008 17:45:55 +0000 (17:45 +0000)
2008-12-14  Jürg Billeter  <j@bitron.ch>

* gobject/valadbusmodule.vala:

Support reading and writing nullable struct values

svn path=/trunk/; revision=2145

ChangeLog
gobject/valadbusmodule.vala

index 9956797951fb73e9da84339c6559398f5709cda2..0d05c84a98cfcb2071024819db4fc2e28b780d33 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-12-14  Jürg Billeter  <j@bitron.ch>
+
+       * gobject/valadbusmodule.vala:
+
+       Support reading and writing nullable struct values
+
 2008-12-14  Jürg Billeter  <j@bitron.ch>
 
        * gobject/valaccodebasemodule.vala:
index 8cc930b1c277e1373212c98252f65659e455470d..f7e29e8ffddef6d731da8e39e84c91d3195df85e 100644 (file)
@@ -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") {