[gxml] Fixed read GomProperty and create new object
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Fixed read GomProperty and create new object
- Date: Wed, 1 Feb 2017 00:51:41 +0000 (UTC)
commit 87db8c7e063cc79b659e747a2aab9e7f5ad211a1
Author: Daniel Espinosa <esodan gmail com>
Date: Tue Jan 31 18:51:09 2017 -0600
Fixed read GomProperty and create new object
gxml/GomElement.vala | 6 +++++-
gxml/GomObject.vala | 15 ++++++++++-----
gxml/XParser.vala | 2 +-
test/GomSerializationTest.vala | 10 ++++++++++
4 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/gxml/GomElement.vala b/gxml/GomElement.vala
index 1572ae9..242f2e2 100644
--- a/gxml/GomElement.vala
+++ b/gxml/GomElement.vala
@@ -473,9 +473,13 @@ public class GXml.GomElement : GomNode,
}
public DomNamedNodeMap attributes { owned get { return (DomNamedNodeMap) _attributes; } }
public string? get_attribute (string name) {
+#if DEBUG
message ("Searching attribute: "+name);
+#endif
string s = (this as GomObject).get_attribute (name);
- message ("Found as GomProperty?: "+(s != null).to_string ());
+#if DEBUG
+ message ("Found as GomObject Property?: "+(s != null).to_string ());
+#endif
if (s != null) return s;
return _attributes.get (name);
}
diff --git a/gxml/GomObject.vala b/gxml/GomObject.vala
index eb75b03..fcd0835 100644
--- a/gxml/GomObject.vala
+++ b/gxml/GomObject.vala
@@ -106,7 +106,7 @@ public interface GXml.GomObject : GLib.Object,
#if DEBUG
GLib.message ("Getting GomProperty attribute: "+prop.name);
#endif
- GomProperty so = (Object) v as GomProperty;
+ var so = v.get_object ();
if (so == null) {
#if DEBUG
GLib.message ("GomProperty is Null");
@@ -114,13 +114,13 @@ public interface GXml.GomObject : GLib.Object,
return null;
}
#if DEBUG
- if (so.value != null) {
- message ("GomProperty Value: "+so.value);
+ if ((so as GomProperty).value != null) {
+ message ("GomProperty Value: "+(so as GomProperty).value);
} else {
message ("GomProperty Value Is Null");
}
- return so.value;
#endif
+ return (so as GomProperty).value;
}
if (prop.value_type.is_a (typeof (string))) {
return (string) v;
@@ -196,7 +196,12 @@ public interface GXml.GomObject : GLib.Object,
if (prop.value_type.is_a (typeof(GomProperty))) {
get_property (prop.name, ref v);
GomProperty so = (Object) v as GomProperty;
- if (so == null) return false;
+ if (so == null) {
+ var obj = Object.new (prop.value_type);
+ v.set_object (obj);
+ set_property (prop.name, v);
+ so = obj as GomProperty;
+ }
so.value = val;
return true;
}
diff --git a/gxml/XParser.vala b/gxml/XParser.vala
index 1dca454..7f3be63 100644
--- a/gxml/XParser.vala
+++ b/gxml/XParser.vala
@@ -448,7 +448,7 @@ public class GXml.XParser : Object, GXml.Parser {
* read node, only if parent: have a property as {@link DomElement} type and current
* node have same local name as property element.
*
- * Returns: true if element is set to a new object, it is set as a child of parent:
+ * Returns: true if element is set to a new object and it is set as a child of parent:
* as a property.
*/
public bool read_element_property (DomNode parent,
diff --git a/test/GomSerializationTest.vala b/test/GomSerializationTest.vala
index a29f019..5ae1cdc 100644
--- a/test/GomSerializationTest.vala
+++ b/test/GomSerializationTest.vala
@@ -681,6 +681,16 @@ class GomSerializationTest : GXmlTest {
assert ("TensionType=\"dc\"" in s);
assert ("Tension=\"125\"" in s);
assert ("/>" in s);
+ assert (m.is_on != null);
+ assert (m.is_on.get_boolean() == true);
+ assert (m.torque != null);
+ assert (m.torque.get_double () == 3.1416);
+ assert (m.speed != null);
+ assert (m.speed.get_double () == 3600.1011);
+ assert (m.tension != null);
+ assert (m.tension.get_integer () == 125);
+ assert (m.tension_type != null);
+ assert (m.tension_type.value == "dc");
} catch (GLib.Error e) {
GLib.message ("Error: "+e.message);
assert_not_reached ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]