[gxml] SerializableArrayList: some deserialize code moved to deserialize_property
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] SerializableArrayList: some deserialize code moved to deserialize_property
- Date: Wed, 24 Feb 2016 19:48:07 +0000 (UTC)
commit bec3555c6a33ab73d92e67e94e777777d68d3460
Author: Daniel Espinosa <esodan gmail com>
Date: Mon Feb 22 18:06:23 2016 -0600
SerializableArrayList: some deserialize code moved to deserialize_property
gxml/SerializableGeeArrayList.vala | 28 ++++++++++++----------------
gxml/SerializableObjectModel.vala | 9 ++++++++-
2 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/gxml/SerializableGeeArrayList.vala b/gxml/SerializableGeeArrayList.vala
index f232343..c4f5c9b 100644
--- a/gxml/SerializableGeeArrayList.vala
+++ b/gxml/SerializableGeeArrayList.vala
@@ -119,22 +119,7 @@ public class GXml.SerializableArrayList<G> : Gee.ArrayList<G>, Serializable, Ser
GLib.message (@"Deserializing ArrayList on Element: $(node.name)");
#endif
foreach (GXml.Node n in node.childs) {
- if (n is Element) {
-#if DEBUG
- GLib.message (@"Checking Node $(n.name) on ArrayList in Element: $(node.name)");
-#endif
- var obj = (Serializable) Object.new (element_type);
-#if DEBUG
- GLib.message (@"Creating a new Object to add: '$(obj.node_name ())' from Node: '$(node.name)'");
-#endif
- if (n.name.down () == ((Serializable) obj).node_name ().down ()) {
- obj.deserialize (n);
-#if DEBUG
- GLib.message (@"SerializableArrayList: Adding object: '$(obj.node_name ())' from Node:
'$(node.name)'");
-#endif
- add (obj);
- }
- }
+ deserialize_property (n);
}
}
return node;
@@ -147,6 +132,17 @@ public class GXml.SerializableArrayList<G> : Gee.ArrayList<G>, Serializable, Ser
public bool default_deserialize_property (GXml.Node property_node)
throws GLib.Error
{
+ if (!element_type.is_a (typeof (GXml.Serializable))) {
+ throw new SerializableError.UNSUPPORTED_TYPE_ERROR (_("%s: Value type '%s' is unsupported"),
+ this.get_type ().name (), element_type.name ());
+ }
+ if (property_node is Element) {
+ var obj = Object.new (element_type) as Serializable;
+ if (property_node.name.down () == obj.node_name ().down ()) {
+ obj.deserialize (property_node);
+ add (obj);
+ }
+ }
return true;
}
}
diff --git a/gxml/SerializableObjectModel.vala b/gxml/SerializableObjectModel.vala
index f15a2c5..54c65f9 100644
--- a/gxml/SerializableObjectModel.vala
+++ b/gxml/SerializableObjectModel.vala
@@ -338,6 +338,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
((SerializableContainer) this).init_containers ();
}
var cnodes = new Gee.HashMap<string,ParamSpec> ();
+ var cns = new Gee.HashMap<string,SerializableCollection> ();
foreach (ParamSpec spec in list_serializable_properties ())
{
if (spec.value_type.is_a (typeof (Serializable)))
@@ -348,8 +349,10 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
get_property (spec.name, ref vo);
var objv = vo.get_object ();
if (objv != null) {
+ string nname = (objv as Serializable).node_name ();
((Serializable) objv).deserialize (element);
- cnodes set (((Serializable) objv).node_name (), spec);
+ cnodes set (nname, spec);
+ cns set (nname.down (), objv as SerializableCollection);
// GLib.message (@"Added Key for container node as: $(((Serializable) objv).node_name ())\n");
}
}
@@ -372,6 +375,10 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
GLib.message ("Checking for Element type? "+(n is GXml.Element).to_string ());
#endif
if (cnodes.has_key (n.name)) continue;
+ /*var cname = cns.get (n.name.down ());
+ if (cname != null) {
+ (cname as Serializable).deserialize_property (n);
+ }*/
#if DEBUG
GLib.message ("Before Deserialize Node");
GLib.message (@"$(get_type ().name ()): DESERIALIZING Node type: $(n.get_type ().name ()) Name:
'$(n.name)':'$(n.value)'");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]