[vala/wip/transform: 57/93] Fix deserialiation of hash tables



commit 80da971fb65f4141d0de9c0bda9cb7288a6a92c0
Author: Rico Tzschichholz <ricotz t-online de>
Date:   Mon Oct 22 15:03:18 2012 +0200

    Fix deserialiation of hash tables

 codegen/valagvarianttransformer.vala | 7 ++++---
 vala/valacodetransformer.vala        | 9 +++++++--
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valagvarianttransformer.vala b/codegen/valagvarianttransformer.vala
index 8d0f1b923..6a77ea22d 100644
--- a/codegen/valagvarianttransformer.vala
+++ b/codegen/valagvarianttransformer.vala
@@ -405,13 +405,14 @@ public class Vala.GVariantTransformer : CCodeTransformer {
                        var value_type = type_args.get (1);
 
                        Expression hash_table_new;
+                       var hash_table_new_type = copy_type (type, true, false);
                        if (key_type.data_type == context.analyzer.string_type.data_type) {
-                               hash_table_new = expression (@"new $type (GLib.str_hash, GLib.str_equal)");
+                               hash_table_new = expression (@"new $hash_table_new_type (GLib.str_hash, 
GLib.str_equal)");
                        } else {
-                               hash_table_new = expression (@"new $type (GLib.direct_hash, 
GLib.direct_equal)");
+                               hash_table_new = expression (@"new $hash_table_new_type (GLib.direct_hash, 
GLib.direct_equal)");
                        }
 
-                       var hash_table = b.add_temp_declaration (copy_type (type, true), hash_table_new);
+                       var hash_table = b.add_temp_declaration (hash_table_new_type, hash_table_new);
                        var new_variant = b.add_temp_declaration (data_type ("GLib.Variant"));
 
                        b.open_while (expression (@"($new_variant = $iterator.next_value ()) != null"));
diff --git a/vala/valacodetransformer.vala b/vala/valacodetransformer.vala
index 7e6001a08..8ff5b8082 100644
--- a/vala/valacodetransformer.vala
+++ b/vala/valacodetransformer.vala
@@ -58,9 +58,14 @@ public class Vala.CodeTransformer : CodeVisitor {
                }
        }
 
-       public static DataType copy_type (DataType type, bool value_owned) {
+       public static DataType copy_type (DataType type, bool? value_owned = null, bool? nullable = null) {
                var ret = type.copy ();
-               ret.value_owned = value_owned;
+               if (value_owned != null) {
+                       ret.value_owned = value_owned;
+               }
+               if (nullable != null) {
+                       ret.nullable = nullable;
+               }
                return ret;
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]