[gxml] XNode: renamed from GNode
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] XNode: renamed from GNode
- Date: Fri, 5 Jul 2019 05:09:58 +0000 (UTC)
commit 29f0eee1ecbf0417cbef9a605aa0d64553fa1049
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Jul 4 23:29:39 2019 -0500
XNode: renamed from GNode
gxml/GXmlParser.vala | 2 +-
gxml/XAttribute.vala | 4 ++--
gxml/XChildNode.vala | 2 +-
gxml/XDocument.vala | 2 +-
gxml/XElement.vala | 14 +++++++-------
gxml/XHashMapAttr.vala | 38 +++++++++++++++++++-------------------
gxml/XListChildren.vala | 24 ++++++++++++------------
gxml/{GXmlNode.vala => XNode.vala} | 20 ++++++++++----------
gxml/meson.build | 2 +-
9 files changed, 54 insertions(+), 54 deletions(-)
---
diff --git a/gxml/GXmlParser.vala b/gxml/GXmlParser.vala
index bf68e0d..7e702fe 100644
--- a/gxml/GXmlParser.vala
+++ b/gxml/GXmlParser.vala
@@ -70,7 +70,7 @@ private class GXml.GParser : Object, Parser {
var e = Xml.get_last_error ();
if (e != null) {
var errmsg = _("Parser Error for string");
- string s = GNode.libxml2_error_to_string (e);
+ string s = XNode.libxml2_error_to_string (e);
if (s != null)
errmsg = ". ";
throw new GXml.Error.PARSER (errmsg);
diff --git a/gxml/XAttribute.vala b/gxml/XAttribute.vala
index cfbf2f1..398d71b 100644
--- a/gxml/XAttribute.vala
+++ b/gxml/XAttribute.vala
@@ -24,7 +24,7 @@ using Gee;
/**
* Class implemeting {@link GXml.DomAttr} interface, not tied to libxml-2.0 library.
*/
-public class GXml.XAttribute : GXml.GNode, GXml.DomAttr
+public class GXml.XAttribute : GXml.XNode, GXml.DomAttr
{
private Xml.Attr* _attr;
public XAttribute (XDocument doc, Xml.Attr *node)
@@ -114,7 +114,7 @@ public class GXml.XAttribute : GXml.GNode, GXml.DomAttr
return namespace.prefix;
}
}*/
- public string local_name { owned get { return (this as GXml.GNode).name; } }
+ public string local_name { owned get { return (this as GXml.XNode).name; } }
/*public string GXml.DomAttr.name {
get {
if (namespace == null) return (this as GXml.DomNode).name;
diff --git a/gxml/XChildNode.vala b/gxml/XChildNode.vala
index 43e3cbe..1e5d19a 100644
--- a/gxml/XChildNode.vala
+++ b/gxml/XChildNode.vala
@@ -23,7 +23,7 @@
/**
* DOM4 class for child nodes, powered by libxml2 library.
*/
-public class GXml.XChildNode : GXml.GNode,
+public class GXml.XChildNode : GXml.XNode,
GXml.DomChildNode
{
// DomChildNode
diff --git a/gxml/XDocument.vala b/gxml/XDocument.vala
index 53452da..04cfde2 100644
--- a/gxml/XDocument.vala
+++ b/gxml/XDocument.vala
@@ -30,7 +30,7 @@ using Xml;
* This class use {@link Xml.TextWriter} to write down XML documents using
* its contained {@link GXml.DomNode} children or other XML structures.
*/
-public class GXml.XDocument : GXml.GNode,
+public class GXml.XDocument : GXml.XNode,
GXml.DomParentNode,
GXml.DomNonElementParentNode,
GXml.DomDocument,
diff --git a/gxml/XElement.vala b/gxml/XElement.vala
index c2c09bd..215bd9e 100644
--- a/gxml/XElement.vala
+++ b/gxml/XElement.vala
@@ -190,28 +190,28 @@ public class GXml.XElement : GXml.XNonDocumentChildNode,
owned get {
var p = attrs.get ("id");
if (p == null) return null;
- return (p as GNode).value;
+ return (p as XNode).value;
}
set {
var p = attrs.get ("id");
if (p == null)
set_attr ("id",value);
else
- (p as GNode).value = value;
+ (p as XNode).value = value;
}
}
public string? class_name {
owned get {
var p = attrs.get ("class");
if (p == null) return null;
- return (p as GNode).value;
+ return (p as XNode).value;
}
set {
var p = attrs.get ("class");
if (p == null)
set_attr ("class",value);
else
- (p as GNode).value = value;
+ (p as XNode).value = value;
}
}
public DomTokenList class_list {
@@ -224,12 +224,12 @@ public class GXml.XElement : GXml.XNonDocumentChildNode,
public string? get_attribute (string name) {
var p = attrs.get (name);
if (p == null) return null;
- return (p as GNode).value;
+ return (p as XNode).value;
}
public string? get_attribute_ns (string? namespace, string local_name) {
var p = get_ns_attr (local_name, namespace);
if (p == null) return null;
- return (p as GNode).value;
+ return (p as XNode).value;
}
public void set_attribute (string name, string value) throws GLib.Error { set_attr (name, value); }
public void set_attribute_ns (string? namespace, string name, string value) throws GLib.Error {
@@ -336,7 +336,7 @@ public class GXml.XElement : GXml.XNonDocumentChildNode,
GXml.XPathObject nullobj = null;
if (!(this is GXml.DomNode))
return nullobj;
- string data = (this as GXml.GNode).to_string();
+ string data = (this as GXml.XNode).to_string();
var ndoc = Xml.Parser.read_memory (data, data.length);
var gdoc = new GXml.XDocument.from_doc (ndoc);
var context = new Xml.XPath.Context (ndoc);
diff --git a/gxml/XHashMapAttr.vala b/gxml/XHashMapAttr.vala
index 0fe2fa3..c1bfce7 100644
--- a/gxml/XHashMapAttr.vala
+++ b/gxml/XHashMapAttr.vala
@@ -26,7 +26,7 @@ using Gee;
* Implementation of {@link Gee.AbstractMap} to handle {@link Xml.Node} attributes,
* powered by libxml2 library.
*/
-public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
+public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.XNode>,
GXml.DomNamedNodeMap
{
private XDocument _doc;
@@ -36,7 +36,7 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
_doc = doc;
}
- public class Entry : Gee.Map.Entry<string,GXml.GNode> {
+ public class Entry : Gee.Map.Entry<string,GXml.XNode> {
private GXml.XDocument _doc;
private Xml.Attr *_attr;
private XAttribute oattr;
@@ -47,7 +47,7 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
}
public override string key { get { return _attr->name; } }
public override bool read_only { get { return true; } }
- public override GXml.GNode value {
+ public override GXml.XNode value {
get { return oattr; }
set {}
}
@@ -61,8 +61,8 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
pn->remove ();
}
}
- public override GXml.GNode @get (string key) {
- GXml.GNode nullnode = null;
+ public override GXml.XNode @get (string key) {
+ GXml.XNode nullnode = null;
if (_node == null) return nullnode;
if (":" in key) {
string[] pp = key.split (":");
@@ -89,7 +89,7 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
}
return new XAttribute (_doc, p);
}
- public override bool has (string key, GXml.GNode value) { return has_key (key); }
+ public override bool has (string key, GXml.XNode value) { return has_key (key); }
public override bool has_key (string key) {
if (_node == null) return false;
var p = _node->properties;
@@ -99,12 +99,12 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
}
return false;
}
- public override Gee.MapIterator<string,GXml.GNode> map_iterator () { return new Iterator (_doc, _node); }
- public override void @set (string key, GXml.GNode value) {
+ public override Gee.MapIterator<string,GXml.XNode> map_iterator () { return new Iterator (_doc, _node); }
+ public override void @set (string key, GXml.XNode value) {
if (_node == null) return;
_node->new_prop (key, value.@value);
}
- public override bool unset (string key, out GXml.GNode value = null) {
+ public override bool unset (string key, out GXml.XNode value = null) {
value = null;
if (_node == null) return false;
var p = _node->has_prop (key);
@@ -112,7 +112,7 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
p->remove ();
return true;
}
- public override Gee.Set<Gee.Map.Entry<string,GXml.GNode>> entries {
+ public override Gee.Set<Gee.Map.Entry<string,GXml.XNode>> entries {
owned get {
var l = new Gee.HashSet<Entry> ();
if (_node == null) return l;
@@ -149,9 +149,9 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
return i;
}
}
- public override Gee.Collection<GXml.GNode> values {
+ public override Gee.Collection<GXml.XNode> values {
owned get {
- var l = new ArrayList<GXml.GNode> ();
+ var l = new ArrayList<GXml.XNode> ();
var p = _node->properties;
while (p != null) {
l.add (new XAttribute (_doc, p));
@@ -160,7 +160,7 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
return l;
}
}
- public class Iterator : Object, MapIterator<string,GXml.GNode> {
+ public class Iterator : Object, MapIterator<string,GXml.XNode> {
private GXml.XDocument _doc;
private Xml.Node *_node;
private Xml.Attr *_current;
@@ -176,7 +176,7 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
if (_current != null) _current->name.dup ();
return nullstr;
}
- public GXml.GNode get_value () {
+ public GXml.XNode get_value () {
return new XAttribute (_doc, _current);
}
public bool has_next () {
@@ -193,7 +193,7 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
_current = _current->next;
return true;
}
- public void set_value (GXml.GNode value) {
+ public void set_value (GXml.XNode value) {
if (_current == null) return;
if (_current->name == value.name) {
var p = _node->properties;
@@ -231,7 +231,7 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
public DomNode? item (int index) {
int i = 0;
if (index > size) return null;
- foreach (GXml.GNode node in values) {
+ foreach (GXml.XNode node in values) {
if (i == index) return (DomNode?) node;
}
return null;
@@ -263,7 +263,7 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
throw new GXml.DomError.NO_MODIFICATION_ALLOWED_ERROR (_("Node collection is read only"));
if (_parent is DomElement) {
var a = _parent.attributes.get_named_item (name);
- (_parent as GNode).get_internal_node ()->set_prop (name, null);
+ (_parent as XNode).get_internal_node ()->set_prop (name, null);
return a;
}
return null;
@@ -319,9 +319,9 @@ public class GXml.XHashMapAttr : Gee.AbstractMap<string,GXml.GNode>,
throw new GXml.DomError.NO_MODIFICATION_ALLOWED_ERROR (_("Node collection is read only"));
// FIXME: Detects if no namespace is supported to rise exception NOT_SUPPORTED_ERROR
if (_parent is DomElement) {
- var ns = (_parent as GNode).get_internal_node ()->doc->search_ns_by_href ((_parent as
GNode).get_internal_node (),
+ var ns = (_parent as XNode).get_internal_node ()->doc->search_ns_by_href ((_parent as
XNode).get_internal_node (),
namespace_uri);
- (_parent as GNode).get_internal_node ()->set_ns_prop (ns, local_name, null);
+ (_parent as XNode).get_internal_node ()->set_ns_prop (ns, local_name, null);
return n;
}
return null;
diff --git a/gxml/XListChildren.vala b/gxml/XListChildren.vala
index a37697f..971afe4 100644
--- a/gxml/XListChildren.vala
+++ b/gxml/XListChildren.vala
@@ -45,7 +45,7 @@ public class GXml.XListChildren : AbstractBidirList<GXml.DomNode>,
int i = 0;
while (n != null) {
if (i == index) {
- return GNode.to_gnode (_doc, n);
+ return XNode.to_gnode (_doc, n);
}
i++;
n = n->next;
@@ -54,11 +54,11 @@ public class GXml.XListChildren : AbstractBidirList<GXml.DomNode>,
}
public override int index_of (GXml.DomNode item) {
if (_node == null) return -1;
- if (!(item is GNode)) return -1;
+ if (!(item is XNode)) return -1;
var n = _node->children;
int i = 0;
while (n != null) {
- if (n == ((GNode) item).get_internal_node ()) return i;
+ if (n == ((XNode) item).get_internal_node ()) return i;
n = n->next;
i++;
}
@@ -70,7 +70,7 @@ public class GXml.XListChildren : AbstractBidirList<GXml.DomNode>,
public override void insert (int index, GXml.DomNode item) {
var n = @get (index);
if (n == null) return;
- (n as GXml.GNode).get_internal_node ()->add_prev_sibling ((item as GXml.GNode).get_internal_node ());
+ (n as GXml.XNode).get_internal_node ()->add_prev_sibling ((item as GXml.XNode).get_internal_node ());
}
public override Gee.ListIterator<GXml.DomNode> list_iterator () { return new Iterator (_doc, _node); }
/**
@@ -81,7 +81,7 @@ public class GXml.XListChildren : AbstractBidirList<GXml.DomNode>,
if (index > size || index < 0) return nullnode;
var n = @get (index);
if (n == null) return nullnode;
- var np = (n as GXml.GNode).get_internal_node ();
+ var np = (n as GXml.XNode).get_internal_node ();
np->unlink ();
delete np;
return nullnode;
@@ -97,7 +97,7 @@ public class GXml.XListChildren : AbstractBidirList<GXml.DomNode>,
int i = 0;
while (n != null) {
if (i >= start && i <= stop) {
- l.add (GNode.to_gnode (_doc, n));
+ l.add (XNode.to_gnode (_doc, n));
}
n = n->next;
i++;
@@ -107,7 +107,7 @@ public class GXml.XListChildren : AbstractBidirList<GXml.DomNode>,
public override bool add (GXml.DomNode item) {
if (_node == null) return false;
if (!(item is GNamespace))
- return (_node->add_child (((GNode) item).get_internal_node ())) != null;
+ return (_node->add_child (((XNode) item).get_internal_node ())) != null;
var ns = (GXml.Namespace) item;
return (_node->new_ns (ns.uri, ns.prefix)) != null;
}
@@ -117,10 +117,10 @@ public class GXml.XListChildren : AbstractBidirList<GXml.DomNode>,
}
public override bool contains (GXml.DomNode item) {
if (_node == null) return false;
- if (!(item is GXml.GNode)) return false;
+ if (!(item is GXml.XNode)) return false;
var n = _node->children;
while (n != null) {
- if (n == ((GXml.GNode) item).get_internal_node ()) return true;
+ if (n == ((GXml.XNode) item).get_internal_node ()) return true;
n = n->next;
}
return false;
@@ -128,10 +128,10 @@ public class GXml.XListChildren : AbstractBidirList<GXml.DomNode>,
public override Gee.Iterator<GXml.DomNode> iterator () { return new Iterator (_doc, _node); }
public override bool remove (GXml.DomNode item) {
if (_node == null) return false;
- if (!(item is GXml.GNode)) return false;
+ if (!(item is GXml.XNode)) return false;
var n = _node->children;
while (n != null) {
- if (n == ((GXml.GNode) item).get_internal_node ()) {
+ if (n == ((GXml.XNode) item).get_internal_node ()) {
n->unlink ();
delete n;
return true;
@@ -183,7 +183,7 @@ public class GXml.XListChildren : AbstractBidirList<GXml.DomNode>,
*/
public new void @set (GXml.DomNode item) {}
// Iterator
- public new GXml.DomNode @get () { return GNode.to_gnode (_doc, _node); }
+ public new GXml.DomNode @get () { return XNode.to_gnode (_doc, _node); }
public bool has_next () {
if (_node == null) return false;
if (_node->children == null) return false;
diff --git a/gxml/GXmlNode.vala b/gxml/XNode.vala
similarity index 96%
rename from gxml/GXmlNode.vala
rename to gxml/XNode.vala
index 9c94df6..25cec5a 100644
--- a/gxml/GXmlNode.vala
+++ b/gxml/XNode.vala
@@ -32,7 +32,7 @@ public errordomain GXml.Error {
/**
* DOM4 Base interface providing basic functionalities to all libxml2 DOM4 implementations.
*/
-public abstract class GXml.GNode : Object,
+public abstract class GXml.XNode : Object,
GXml.DomEventTarget,
GXml.DomNode
{
@@ -179,14 +179,14 @@ public abstract class GXml.GNode : Object,
owned get {
if (_node == null) return null;
if (_node->prev == null) return null;
- return GNode.to_gnode (_doc, _node->prev) as DomNode?;
+ return XNode.to_gnode (_doc, _node->prev) as DomNode?;
}
}
public DomNode? next_sibling {
owned get {
if (_node == null) return null;
if (_node->next == null) return null;
- return GNode.to_gnode (_doc, _node->next) as DomNode?;
+ return XNode.to_gnode (_doc, _node->next) as DomNode?;
}
}
@@ -201,8 +201,8 @@ public abstract class GXml.GNode : Object,
message ("Is Element");
foreach (GXml.DomNode n in children_nodes) {
if (n is GXml.DomText) {
- if (t == null) t = (n as GNode).value;
- else t += (n as GNode).value;
+ if (t == null) t = (n as XNode).value;
+ else t += (n as XNode).value;
}
}
}
@@ -240,15 +240,15 @@ public abstract class GXml.GNode : Object,
else
n = _node->copy (2);
if (n == null) return nullnode;
- return (DomNode) GNode.to_gnode (_doc, n);
+ return (DomNode) XNode.to_gnode (_doc, n);
}
public bool is_equal_node (DomNode? node) {
if (!(node is GXml.DomNode)) return false;
if (node == null) return false;
if (this.children_nodes.size != node.child_nodes.size) return false;
foreach (GXml.DomNode a in attrs.values) {
- if (!(node as GXml.GNode?).attrs.has_key (a.node_name)) return false;
- if ((a as GNode).value != ((node as GXml.GNode).attrs.get (a.node_name) as GNode).value) return false;
+ if (!(node as GXml.XNode?).attrs.has_key (a.node_name)) return false;
+ if ((a as XNode).value != ((node as GXml.XNode).attrs.get (a.node_name) as XNode).value) return false;
}
for (int i=0; i < children_nodes.size; i++) {
if (!(children_nodes[i] as GXml.DomNode).is_equal_node ((node as GXml.DomNode?).child_nodes[i] as
GXml.DomNode?)) return false;
@@ -307,7 +307,7 @@ public abstract class GXml.GNode : Object,
}
public DomNode insert_before (DomNode node, DomNode? child) throws GLib.Error {
- if (!(node is GXml.GNode))
+ if (!(node is GXml.XNode))
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid attempt to add invalid node type"));
if (child != null && !this.contains (child))
throw new DomError.NOT_FOUND_ERROR (_("Can't find child to insert node before"));
@@ -338,7 +338,7 @@ public abstract class GXml.GNode : Object,
return insert_before (node, null);
}
public DomNode replace_child (DomNode node, DomNode child) throws GLib.Error {
- if (!(node is GXml.GNode))
+ if (!(node is GXml.XNode))
throw new DomError.INVALID_NODE_TYPE_ERROR (_("Invalid attempt to add invalid node type"));
if (child == null || !this.contains (child))
throw new DomError.NOT_FOUND_ERROR (_("Can't find child node to replace or child have a different
parent"));
diff --git a/gxml/meson.build b/gxml/meson.build
index 95fc410..b0337c0 100644
--- a/gxml/meson.build
+++ b/gxml/meson.build
@@ -70,7 +70,6 @@ valasources = files ([
'gxml-init.vala',
'GXmlListNamespaces.vala',
'GXmlNamespace.vala',
- 'GXmlNode.vala',
'GXmlParser.vala',
'GXPathObject.vala',
'Namespace.vala',
@@ -85,6 +84,7 @@ valasources = files ([
'XElement.vala',
'XHashMapAttr.vala',
'XListChildren.vala',
+ 'XNode.vala',
'XParser.vala',
'XPath.vala',
'XProcessingInstruction.vala',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]