[gxml/serialization: 3/10] Serializable now use nick for properties name. Fiexed segfault. * serialized_property_use_blurb rena



commit 82fbfc1d5e99d3c9eda1ea533683d11916c7ec62
Author: Daniel Espinosa <esodan gmail com>
Date:   Mon Jul 22 17:28:27 2013 -0500

    Serializable now use nick for properties name. Fiexed segfault.
    * serialized_property_use_blurb renamed to serialized_property_use_nick
    * serialized_xml_node_value default to null

 gxml/Serializable.vala     |   16 ++++++++--------
 gxml/Serialization.vala    |    2 +-
 test/SerializableTest.vala |   14 +++++++-------
 3 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/gxml/Serializable.vala b/gxml/Serializable.vala
index 965a625..303b890 100644
--- a/gxml/Serializable.vala
+++ b/gxml/Serializable.vala
@@ -71,7 +71,7 @@ namespace GXml {
         * For an example, look in tests/XmlSerializableTest
         */
        public interface Serializable : GLib.Object {
-               public abstract bool serializable_property_use_blurb { get; set; }
+               public abstract bool serializable_property_use_nick { get; set; }
                /**
                 * Store all properties to be ignored on serialization.
                 *
@@ -99,7 +99,7 @@ namespace GXml {
                 *
                 * This property must be ignored on serialisation.
                 */
-               public abstract string                            serialized_xml_node_value { get; protected 
set; }
+               public abstract string  serialized_xml_node_value { get; protected set; default = null; }
 
                /**
                 * Serialize this object.
@@ -121,7 +121,8 @@ namespace GXml {
                                serialize_property (spec);
                                GLib.message ("Done");
                        }
-                       serialized_xml_node.node_value = serialized_xml_node_value;
+                       if (serialized_xml_node_value != null)
+                               serialized_xml_node.content = serialized_xml_node_value;
                        node.append_child (serialized_xml_node);
                        return serialized_xml_node;
                }
@@ -211,7 +212,6 @@ namespace GXml {
                public virtual GXml.DomNode? serialize_property (GLib.ParamSpec spec)
                                                                 throws DomError
                {
-                       Document doc = serialized_xml_node.owner_document;
                        var prop = find_property_spec (spec.name);
                        if (prop == null) {
                                GLib.warning ("No such property: " + spec.name);
@@ -235,8 +235,8 @@ namespace GXml {
                                val = rval.dup_string ();
                        }
                        string attr_name = spec.name;
-                       if (serializable_property_use_blurb)
-                               attr_name = spec.get_blurb ();
+                       if (serializable_property_use_nick)
+                               attr_name = spec.get_nick ();
                        serialized_xml_node.set_attribute (attr_name, val);
                        return (DomNode) serialized_xml_node.get_attribute_node (attr_name);
                }
@@ -295,8 +295,8 @@ namespace GXml {
                                                                                                              
                                                                  get_class 
().find_property("serialized-xml-node"));
                                ignored_serializable_properties.set ("serialized-xml-node-value",
                                                                                                              
                                                                  get_class 
().find_property("serialized-xml-node-value"));
-                               ignored_serializable_properties.set ("serializable-property-use-blurb",
-                                                                                                             
                                                                  get_class 
().find_property("serializable-property-use-blurb"));
+                               ignored_serializable_properties.set ("serializable-property-use-nick",
+                                                                                                             
                                                                  get_class 
().find_property("serializable-property-use-nick"));
                        }
                        if (unknown_serializable_property == null) {
                                unknown_serializable_property = new HashTable<string,GXml.DomNode> (str_hash, 
str_equal);
diff --git a/gxml/Serialization.vala b/gxml/Serialization.vala
index 0bfd732..6a04eb0 100644
--- a/gxml/Serialization.vala
+++ b/gxml/Serialization.vala
@@ -91,7 +91,7 @@ namespace GXml {
                private static GXml.DomNode serialize_property (GLib.Object object,
                                                                ParamSpec prop_spec,
                                                                GXml.Document doc)
-                                                               throws Error, 
+                                                               throws Error,
                                                                       SerializationError,
                                                                       DomError
                {
diff --git a/test/SerializableTest.vala b/test/SerializableTest.vala
index 34e9af8..2964cb9 100644
--- a/test/SerializableTest.vala
+++ b/test/SerializableTest.vala
@@ -29,7 +29,7 @@ public class SerializableTomato : GLib.Object, GXml.Serializable
 {
        /*  Serializable abstract properties */
        public GLib.HashTable<string,GLib.ParamSpec> ignored_serializable_properties { get; private set; }
-       public bool serializable_property_use_blurb { get; set; }
+       public bool serializable_property_use_nick { get; set; }
        public GXml.Element serialized_xml_node { get; protected set; }
        public string serialized_xml_node_value { get; protected set; }
        public GLib.HashTable<string,GXml.DomNode> unknown_serializable_property { get; private set; }
@@ -67,7 +67,7 @@ public class SerializableCapsicum : GLib.Object, GXml.Serializable
 {
        /*  Serializable abstract properties */
        public GLib.HashTable<string,GLib.ParamSpec> ignored_serializable_properties { get; private set; }
-       public bool serializable_property_use_blurb { get; set; }
+       public bool serializable_property_use_nick { get; set; }
        public GXml.Element serialized_xml_node { get; protected set; }
        public string serialized_xml_node_value { get; protected set; }
        public GLib.HashTable<string,GXml.DomNode> unknown_serializable_property { get; private set; }
@@ -123,10 +123,10 @@ public class SerializableCapsicum : GLib.Object, GXml.Serializable
 
                return false;
        }
-       public GXml.DomNode? serialize_property (GLib.ParamSpec spec,
-                                                GXml.Document doc)
+       public GXml.DomNode? serialize_property (GLib.ParamSpec spec)
                                                 throws GXml.DomError
        {
+               GXml.Document doc = serialized_xml_node.owner_document;
                GXml.Element c_prop;
                GXml.Element rating;
 
@@ -161,7 +161,7 @@ public class SerializableBanana : GLib.Object, GXml.Serializable
 {
        /*  Serializable abstract properties */
        public GLib.HashTable<string,GLib.ParamSpec> ignored_serializable_properties { get; private set; }
-       public bool serializable_property_use_blurb { get; set; }
+       public bool serializable_property_use_nick { get; set; }
        public GXml.Element serialized_xml_node { get; protected set; }
        public string serialized_xml_node_value { get; protected set; }
        public GLib.HashTable<string,GXml.DomNode> unknown_serializable_property { get; private set; }
@@ -268,7 +268,7 @@ class XmlObjectModel : Object, Serializable
 {
        /* Serializable interface properties */
        public GLib.HashTable<string,GLib.ParamSpec> ignored_serializable_properties { get; protected set; }
-       public bool serializable_property_use_blurb { get; set; }
+       public bool serializable_property_use_nick { get; set; }
        public GXml.Element serialized_xml_node { get; protected set; }
        public string serialized_xml_node_value { get; protected set; }
        public GLib.HashTable<string,GXml.DomNode> unknown_serializable_property { get; protected set; }
@@ -277,7 +277,7 @@ class XmlObjectModel : Object, Serializable
        public string @value { get; set; }
        public XmlObjectModel ()
        {
-               serializable_property_use_blurb = true;
+               serializable_property_use_nick = true;
                var pvalue = find_property_spec ("value");
                ignored_serializable_properties.set ("value", pvalue);
        }


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