[gxml] SerializableProperty removing unnecesary property name methods



commit 430a73a2b573f7bd517bc0df12349e4ecd9edb43
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Oct 21 19:18:15 2015 -0500

    SerializableProperty removing unnecesary property name methods

 gxml/SerializableDouble.vala             |    1 -
 gxml/SerializableEnum.vala               |    7 +------
 gxml/SerializableFloat.vala              |    1 -
 gxml/SerializableInt.vala                |    1 -
 gxml/SerializableProperty.vala           |   14 --------------
 test/SerializablePropertyDoubleTest.vala |    3 ++-
 test/SerializablePropertyEnumTest.vala   |   12 +++++++-----
 test/SerializablePropertyFloatTest.vala  |    3 ++-
 test/SerializablePropertyIntTest.vala    |    3 ++-
 9 files changed, 14 insertions(+), 31 deletions(-)
---
diff --git a/gxml/SerializableDouble.vala b/gxml/SerializableDouble.vala
index 38703f4..47fed0e 100644
--- a/gxml/SerializableDouble.vala
+++ b/gxml/SerializableDouble.vala
@@ -30,7 +30,6 @@ public class GXml.SerializableDouble : SerializableObjectModel, SerializableProp
   protected string _val = null;
   protected string _name = null;
   protected int _fraction = -1;
-  public SerializableDouble (string name) { _name = name; }
   public int get_fraction () { return _fraction; }
   public void set_fraction (int fraction) {
     int v = fraction;
diff --git a/gxml/SerializableEnum.vala b/gxml/SerializableEnum.vala
index 64c1df7..bd6a507 100644
--- a/gxml/SerializableEnum.vala
+++ b/gxml/SerializableEnum.vala
@@ -40,12 +40,9 @@ public errordomain GXml.SerializableEnumError {
 public class GXml.SerializableEnum : SerializableObjectModel, SerializableProperty
 {
   protected string _val = null;
-  protected string _name = null;
   protected GLib.Type _enumtype;
-  public SerializableEnum.with_name (string name) { _name = name; }
-  public SerializableEnum.with_enum (string name, GLib.Type type)
+  public SerializableEnum.with_enum (GLib.Type type)
   {
-    _name = name;
     _enumtype = type;
   }
   public void set_enum_type (GLib.Type type)
@@ -77,7 +74,5 @@ public class GXml.SerializableEnum : SerializableObjectModel, SerializableProper
   }
   public string get_serializable_property_value () { return _val; }
   public void set_serializable_property_value (string? val) { _val = val; }
-  public string get_serializable_property_name () { return _name; }
-  public void set_serializable_property_name (string name) { _name = name; }
   public override string to_string () { return _val; }
 }
\ No newline at end of file
diff --git a/gxml/SerializableFloat.vala b/gxml/SerializableFloat.vala
index 48153de..bb53521 100644
--- a/gxml/SerializableFloat.vala
+++ b/gxml/SerializableFloat.vala
@@ -22,7 +22,6 @@
 
 public class GXml.SerializableFloat : GXml.SerializableDouble
 {
-  public SerializableFloat (string name) { base (name); }
   public new float get_value () { return (float) double.parse (_val); }
   public new void set_value (float val) { _val = val.to_string (); }
 }
\ No newline at end of file
diff --git a/gxml/SerializableInt.vala b/gxml/SerializableInt.vala
index e81bbe4..4244f57 100644
--- a/gxml/SerializableInt.vala
+++ b/gxml/SerializableInt.vala
@@ -27,7 +27,6 @@ using Gee;
  */
 public class GXml.SerializableInt : GXml.SerializableDouble
 {
-  public SerializableInt (string name) { base (name); }
   public new int get_value () { return (int) double.parse (_val); }
   public new void set_value (int val) { _val = val.to_string (); }
   public override string to_string () {
diff --git a/gxml/SerializableProperty.vala b/gxml/SerializableProperty.vala
index 564de9d..128301d 100644
--- a/gxml/SerializableProperty.vala
+++ b/gxml/SerializableProperty.vala
@@ -44,14 +44,6 @@ public interface GXml.SerializableProperty : Object, Serializable
   */
   public abstract void set_serializable_property_value (string? val);
   /**
-   * Name to be set to a { link GXml.Attr}, to be added to a { link GXml.Element}
-   */
-  public abstract string get_serializable_property_name ();
-  /**
-   * Sets name to be set to a { link GXml.Attr}, to be added to a { link GXml.Element}
-   */
-  public abstract void set_serializable_property_name (string name);
-  /**
    * Tryies to deserialize from a { link GXml.Node} searching a { link GXml.Attr}
    * with the name returned by { link GXml.SerializableProperty.get_serializable_property_name},
    * if not set, then { link GLib.ParamSpec} name should used. If { param nick} is set to true,
@@ -108,18 +100,12 @@ public interface GXml.SerializableProperty : Object, Serializable
     GXml.Attribute attr = null;
     if (property_node is GXml.Attribute)
       attr = (GXml.Attribute) property_node;
-    if (property_node is GXml.Element)
-      attr = (GXml.Attribute) ((GXml.Element) property_node).attrs.get (get_serializable_property_name ());
     if (attr == null) {
 #if DEBUG
       GLib.warning ("No attribute found to deserialize from");
 #endif
       return false;
     }
-    if (get_serializable_property_name () != null) {
-      if (attr.name.down () == get_serializable_property_name ().down ())
-        set_serializable_property_value (attr.value);
-    }
     if (attr.name == null) {
       GLib.warning ("XML Attribute name is not set, when deserializing to: "+this.get_type ().name ());
       return false;
diff --git a/test/SerializablePropertyDoubleTest.vala b/test/SerializablePropertyDoubleTest.vala
index 21a0ec4..0626153 100644
--- a/test/SerializablePropertyDoubleTest.vala
+++ b/test/SerializablePropertyDoubleTest.vala
@@ -28,7 +28,7 @@ class SerializablePropertyDoubleTest : GXmlTest {
   public class DoubleNode : SerializableObjectModel
   {
     [Description (nick="DoubleValue")]
-    public SerializableDouble  double_value { get; set; default = new SerializableDouble ("DoubleValue"); }
+    public SerializableDouble  double_value { get; set; }
     public string name { get; set; }
     public override string node_name () { return "DoubleNode"; }
     public override string to_string () { return get_type ().name (); }
@@ -66,6 +66,7 @@ class SerializablePropertyDoubleTest : GXmlTest {
         assert (s == null);
         // Change values
         // set to 233.014
+        bn.double_value = new SerializableDouble ();
         bn.double_value.set_value (233.014);
         var doc2 = new xDocument ();
         bn.serialize (doc2);
diff --git a/test/SerializablePropertyEnumTest.vala b/test/SerializablePropertyEnumTest.vala
index f52e595..6ac2fac 100644
--- a/test/SerializablePropertyEnumTest.vala
+++ b/test/SerializablePropertyEnumTest.vala
@@ -27,9 +27,7 @@ using GXml;
 class SerializablePropertyEnumTest : GXmlTest {
   public class Enum : SerializableEnum
   {
-    public Enum (string name)
-    {
-      _name = name;
+    construct {
       _enumtype = typeof (Enum.Values);
     }
     public Enum.Values get_value () throws GLib.Error { return (Enum.Values) to_integer (); }
@@ -46,13 +44,14 @@ class SerializablePropertyEnumTest : GXmlTest {
   }
   public class EnumerationValues : SerializableObjectModel
   {
-    public Enum values { get; set; default = new Enum ("values"); }
+    public Enum values { get; set; }
     [Description(nick="OptionalValues", blurb="Optional values")]
-    public Enum optional_values { get; set; default = new Enum ("OptionalValues"); }
+    public Enum optional_values { get; set; }
     public int  integer { get; set; default = 0; }
     public string name { get; set; }
     public override string node_name () { return "Enum"; }
     public override string to_string () { return get_type ().name (); }
+    public override bool property_use_nick () { return true; }
   }
   public static void add_tests () {
     Test.add_func ("/gxml/serializable/Enum/basic",
@@ -90,6 +89,7 @@ class SerializablePropertyEnumTest : GXmlTest {
         assert (i1.value == "0");
         // Getting value
         Enum.Values v = Enum.Values.SER_ONE;
+        e.values = new Enum ();
         try { v = e.values.get_value (); }
         catch (GLib.Error e) {
           Test.message ("Error cough correctly: "+e.message);
@@ -133,6 +133,7 @@ class SerializablePropertyEnumTest : GXmlTest {
     () => {
       try {
         var e = new EnumerationValues ();
+        e.values = new Enum ();
         e.values.set_string ("SERONE");
         assert (e.values.get_value () == Enum.Values.SER_ONE);
       } catch (GLib.Error e) {
@@ -144,6 +145,7 @@ class SerializablePropertyEnumTest : GXmlTest {
     () => {
       try {
         var e = new EnumerationValues ();
+        e.values = new Enum ();
         e.values.set_value (Enum.Values.AP);
         var d1 = new xDocument ();
         e.serialize (d1);
diff --git a/test/SerializablePropertyFloatTest.vala b/test/SerializablePropertyFloatTest.vala
index 31c18f8..f14aeea 100644
--- a/test/SerializablePropertyFloatTest.vala
+++ b/test/SerializablePropertyFloatTest.vala
@@ -28,7 +28,7 @@ class SerializablePropertyFloatTest : GXmlTest {
   public class FloatNode : SerializableObjectModel
   {
     [Description (nick="FloatValue")]
-    public SerializableFloat  float_value { get; set; default = new SerializableFloat ("FloatValue"); }
+    public SerializableFloat  float_value { get; set; }
     public string name { get; set; }
     public override string node_name () { return "FloatNode"; }
     public override string to_string () { return get_type ().name (); }
@@ -65,6 +65,7 @@ class SerializablePropertyFloatTest : GXmlTest {
         var s = element.get_attribute_node ("name");
         assert (s == null);
         // Change values
+        bn.float_value = new SerializableFloat ();
         // set to 233.014
         bn.float_value.set_value ((float) 233.014);
         var doc2 = new xDocument ();
diff --git a/test/SerializablePropertyIntTest.vala b/test/SerializablePropertyIntTest.vala
index 22817d5..b617413 100644
--- a/test/SerializablePropertyIntTest.vala
+++ b/test/SerializablePropertyIntTest.vala
@@ -28,7 +28,7 @@ class SerializablePropertyIntTest : GXmlTest {
   public class IntNode : SerializableObjectModel
   {
     [Description (nick="IntegerValue")]
-    public SerializableInt  integer { get; set; default = new SerializableInt ("IntegerValue"); }
+    public SerializableInt  integer { get; set; }
     public string name { get; set; }
     public override string node_name () { return "IntNode"; }
     public override string to_string () { return get_type ().name (); }
@@ -65,6 +65,7 @@ class SerializablePropertyIntTest : GXmlTest {
         var s = element.get_attribute_node ("name");
         assert (s == null);
         // Change values
+        bn.integer = new SerializableInt ();
         // set to 233
         bn.integer.set_value (233);
         var doc2 = new xDocument ();


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