[gxml] Fixes on make check for GDocument, GElement and xDocument
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Fixes on make check for GDocument, GElement and xDocument
- Date: Wed, 10 Feb 2016 00:35:24 +0000 (UTC)
commit 86e4071f7f77ce3c6d6d13ce0bccdd3e486c5f7a
Author: Daniel Espinosa <esodan gmail com>
Date: Tue Feb 9 18:34:25 2016 -0600
Fixes on make check for GDocument, GElement and xDocument
gxml/GXmlDocument.vala | 6 +++---
gxml/SerializableObjectModel.vala | 22 +++++++++++-----------
gxml/libxml-Document.vala | 4 ++--
test/GDocumentTest.vala | 18 +++++++++++++++---
test/GElementTest.vala | 4 +++-
5 files changed, 34 insertions(+), 20 deletions(-)
---
diff --git a/gxml/GXmlDocument.vala b/gxml/GXmlDocument.vala
index 8758118..c9cdbb7 100644
--- a/gxml/GXmlDocument.vala
+++ b/gxml/GXmlDocument.vala
@@ -85,9 +85,9 @@ public class GXml.GDocument : GXml.GNode, GXml.Document
return false;
}
// GXml.Node
- public override Gee.Map<string,GXml.Node> attrs { owned get { return new GHashMapAttr (this,
doc->get_root_element ()); } }
- public override Gee.BidirList<GXml.Node> children { owned get { return new GListChildren (this,
doc->get_root_element ()); } }
- public override Gee.List<GXml.Namespace> namespaces { owned get { return new GListNamespaces (this,
doc->get_root_element ()); } }
+ public override Gee.Map<string,GXml.Node> attrs { owned get { return new GHashMapAttr (this, (Xml.Node*)
doc); } }
+ public override Gee.BidirList<GXml.Node> children { owned get { return new GListChildren (this,
(Xml.Node*) doc); } }
+ public override Gee.List<GXml.Namespace> namespaces { owned get { return new GListNamespaces (this,
(Xml.Node*) doc); } }
public override GXml.Document document { get { return this; } }
// GXml.Document
public bool indent { get; set; default = false; }
diff --git a/gxml/SerializableObjectModel.vala b/gxml/SerializableObjectModel.vala
index 1ed66cc..c390a0b 100644
--- a/gxml/SerializableObjectModel.vala
+++ b/gxml/SerializableObjectModel.vala
@@ -62,7 +62,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
{
owned get {
if (_doc == null) init_unknown_doc ();
- return _doc.root.childs;
+ return _doc.root.children;
}
}
@@ -70,7 +70,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
{
_doc = new TwDocument ();
var r = _doc.create_element ("root");
- _doc.childs.add (r);
+ _doc.children.add (r);
}
public virtual bool serialize_use_xml_node_value () { return false; }
@@ -135,7 +135,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
{
assert (node.name != null);
#if DEBUG
- stdout.printf (@"$(get_type ().name ()): Serializing on node: $(node.name)\n");
+ GLib.message (@"$(get_type ().name ()): Serializing on node: $(node.name) : type: @$(node.get_type
().name ())\n");
#endif
Document doc;
if (node is GXml.Document)
@@ -143,7 +143,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
else
doc = node.document;
var element = (Element) doc.create_element (node_name ());
- node.childs.add (element);
+ node.children.add (element);
set_namespace (element);
foreach (ParamSpec spec in list_serializable_properties ()) {
serialize_property (element, spec);
@@ -167,16 +167,16 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
#if DEBUG
GLib.message (@"Serialized Unknown Element NODE AS: $(e.to_string ())");
#endif
- element.childs.add (e);
+ element.children.add (e);
}
if (n is Text) {
if (n.value == null) GLib.warning (_("Text node with NULL or none text"));
if (n.value == "") continue;
var t = doc.create_text (n.value);
- element.childs.add (t);
+ element.children.add (t);
#if DEBUG
- GLib.message (@"Serializing Unknown Text Node: '$(n.value)' to '$(element.name)' : Size
$(element.childs.size.to_string ())");
- GLib.message (@"Added Text: $(element.childs.get (element.childs.size - 1))");
+ GLib.message (@"Serializing Unknown Text Node: '$(n.value)' to '$(element.name)' : Size
$(element.children.size.to_string ())");
+ GLib.message (@"Added Text: $(element.children.get (element.children.size - 1))");
#endif
}
}
@@ -309,7 +309,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
{
deserialize_property (attr);
}
- if (element.childs.size > 0)
+ if (element.children.size > 0)
{
if (get_type ().is_a (typeof (SerializableContainer)))
{
@@ -339,7 +339,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
#if DEBUG
stdout.printf (@"Elements Nodes in Node: $(element.name)\n");
#endif
- foreach (Node n in element.childs)
+ foreach (Node n in element.children)
{
if (n is Text) {
if (serialize_use_xml_node_value ()) {
@@ -390,7 +390,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
}
else {
var e = _doc.create_element (property_node.name);
- _doc.root.childs.add (e);
+ _doc.root.children.add (e);
GXml.Node.copy (_doc, e, property_node, true);
#if DEBUG
GLib.message (@"Adding unknown node $(property_node.name) to $(get_type ().name ()):
Size=$(unknown_serializable_nodes.size.to_string ())");
diff --git a/gxml/libxml-Document.vala b/gxml/libxml-Document.vala
index 127fc7b..ee525d7 100644
--- a/gxml/libxml-Document.vala
+++ b/gxml/libxml-Document.vala
@@ -277,7 +277,7 @@ namespace GXml {
this.doctype = new xDocumentType (doc->int_subset, doc->ext_subset, this);
}
this.implementation = new Implementation ();
- _node_list = new NodeChildNodeList (this.xmldoc->get_root_element (),
this.owner_document);
+ _node_list = new NodeChildNodeList ((Xml.Node*) this.xmldoc, this.owner_document);
}
/**
@@ -426,7 +426,7 @@ namespace GXml {
doc = new Xml.Doc ();
this.from_libxml2 (doc, false);
- _node_list = new NodeChildNodeList (this.xmldoc->get_root_element (),
this.owner_document);
+ _node_list = new NodeChildNodeList ((Xml.Node*) this.xmldoc, this.owner_document);
}
/**
diff --git a/test/GDocumentTest.vala b/test/GDocumentTest.vala
index d745e4f..e294a4e 100644
--- a/test/GDocumentTest.vala
+++ b/test/GDocumentTest.vala
@@ -26,6 +26,18 @@ using GXml;
class GDocumentTest : GXmlTest {
public static void add_tests () {
+ Test.add_func ("/gxml/gdocument/construct_api", () => {
+ try {
+ var d = new GDocument ();
+ var root = d.create_element ("root");
+ d.children.add (root);
+ assert (d.root != null);
+ Test.message ("Root name: "+d.root.name);
+ assert (d.root.name == "root");
+ Test.message ("Root string: "+d.root.to_string ());
+ assert (d.root.to_string () == "<root/>");
+ } catch {assert_not_reached ();}
+ });
Test.add_func ("/gxml/gdocument/construct_from_path_error", () => {
GDocument doc;
try {
@@ -120,7 +132,7 @@ class GDocumentTest : GXmlTest {
doc = new GDocument.from_stream (iostream.input_stream);
GLib.message ("Passed parse error stream");
assert_not_reached ();
- } catch { assert_not_reached (); }
+ } catch {}
});
Test.add_func ("/gxml/gdocument/construct_from_string", () => {
try {
@@ -148,7 +160,7 @@ class GDocumentTest : GXmlTest {
xml = """<?xml version="1.0"?>""";
doc = new GDocument.from_string (xml);
assert_not_reached ();
- } catch { assert_not_reached (); }
+ } catch {}
});
Test.add_func ("/gxml/gdocument/construct_from_string_invalid", () => {
try {
@@ -182,7 +194,7 @@ class GDocumentTest : GXmlTest {
doc = new GDocument.from_string ("<root />");
doc.save_as (GLib.File.new_for_path ("/tmp/a/b/c/d/e/f/g/h/i"));
assert_not_reached ();
- } catch { assert_not_reached (); }
+ } catch {}
});
Test.add_func ("/gxml/gdocument/create_element", () => {
diff --git a/test/GElementTest.vala b/test/GElementTest.vala
index 06b2b61..713b752 100644
--- a/test/GElementTest.vala
+++ b/test/GElementTest.vala
@@ -115,8 +115,10 @@ class GElementTest : GXmlTest {
doc.children.add (root);
var n = (GElement) doc.create_element ("child");
root.children.add (n);
- root.content = "TEXT1";
+ var t = doc.create_text ("TEXT1");
+ root.children.add (t);
string s = doc.to_string ().split ("\n")[1];
+ Test.message ("root="+root.to_string ());
assert (s == "<root><child/>TEXT1</root>");
} catch (GLib.Error e) {
Test.message (e.message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]