[gxml] GOM: Serializable of double types added
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] GOM: Serializable of double types added
- Date: Thu, 3 Nov 2016 23:18:22 +0000 (UTC)
commit ada5076d11d45ace12db90108d4642eeece9ee56
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Nov 3 17:13:24 2016 -0600
GOM: Serializable of double types added
Support for double types properties has been added
with long name use. To access your properties you
need to use Canonalized name this is:
double long_name { get; set; }
will be accessible using .get_property ("long-name")
gxml/GomObject.vala | 3 +++
test/GomSerializationTest.vala | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gxml/GomObject.vala b/gxml/GomObject.vala
index 7a4acf5..9fd7084 100644
--- a/gxml/GomObject.vala
+++ b/gxml/GomObject.vala
@@ -86,6 +86,9 @@ public interface GXml.GomObject : GLib.Object,
if (prop.value_type.is_a (typeof (uint))) {
return ((uint) v).to_string ();
}
+ if (prop.value_type.is_a (typeof (double))) {
+ return ((double) v).to_string ();
+ }
}
return null;
}
diff --git a/test/GomSerializationTest.vala b/test/GomSerializationTest.vala
index d81b92c..2ba5edc 100644
--- a/test/GomSerializationTest.vala
+++ b/test/GomSerializationTest.vala
@@ -40,6 +40,14 @@ class GomSerializationTest : GXmlTest {
}
public string to_string () { return (_document as GomDocument).to_string (); }
}
+ public class Taxes : GomElement {
+ [Description (nick="::monthRate")]
+ public double month_rate { get; set; }
+ construct {
+ _local_name = "Taxes";
+ }
+ public string to_string () { return (_document as GomDocument).to_string (); }
+ }
public static void add_tests () {
Test.add_func ("/gxml/gom-serialization/write/properties", () => {
var b = new Book ();
@@ -65,5 +73,16 @@ class GomSerializationTest : GXmlTest {
s = c.to_string ();
GLib.message ("DOC:"+s);
});
+ Test.add_func ("/gxml/gom-serialization/write/property-long-name", () => {
+ var t = new Taxes ();
+ string s = t.to_string ();
+ assert (s != null);
+ assert ("<Taxes monthRate=\"0\"/>" in s);
+ t.month_rate = 16.5;
+ assert ("16.5" in "%.2f".printf (t.month_rate));
+ assert ("16.5" in t.get_attribute ("month-rate"));
+ s = t.to_string ();
+ GLib.message ("DOC:"+s);
+ });
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]