[vala/wip/transform: 55/98] Fix deserialiation of hash tables
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 55/98] Fix deserialiation of hash tables
- Date: Sun, 25 Sep 2016 19:38:49 +0000 (UTC)
commit 51e20804d00b5a178c190f126ba1d79f98a9d871
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 9b40155..7cc974b 100644
--- a/codegen/valagvarianttransformer.vala
+++ b/codegen/valagvarianttransformer.vala
@@ -403,13 +403,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 7e6001a..8ff5b80 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]