[gxml/gsoc2013] Memory: Node.vala, BackedNode.vala, Element.vala, NodeList.vala, Attr.vala, Entity.vala, Document.va



commit ac18ab2c896c87bbba755e51b36c149bc30e104b
Author: Richard Schwarting <aquarichy gmail com>
Date:   Sun Jul 28 01:30:11 2013 -0400

    Memory: Node.vala, BackedNode.vala, Element.vala, NodeList.vala, Attr.vala, Entity.vala, Document.vala: 
change ownership of return value to unowned for a bunch of methods (insert_before, 
append/remove/replace_child); references will be handled by the Document

 gxml/Attr.vala       |    8 ++++----
 gxml/BackedNode.vala |    8 ++++----
 gxml/Document.vala   |    2 +-
 gxml/Element.vala    |   16 ++++++++--------
 gxml/Entity.vala     |    8 ++++----
 gxml/Node.vala       |    8 ++++----
 gxml/NodeList.vala   |   24 ++++++++++++------------
 7 files changed, 37 insertions(+), 37 deletions(-)
---
diff --git a/gxml/Attr.vala b/gxml/Attr.vala
index e69bbda..111df9d 100644
--- a/gxml/Attr.vala
+++ b/gxml/Attr.vala
@@ -220,25 +220,25 @@ namespace GXml {
                /**
                 * { inheritDoc}
                 */
-               public override Node? insert_before (Node new_child, Node? ref_child) {
+               public override unowned Node? insert_before (Node new_child, Node? ref_child) {
                        return this.child_nodes.insert_before (new_child, ref_child);
                }
                /**
                 * { inheritDoc}
                 */
-               public override Node? replace_child (Node new_child, Node old_child) {
+               public override unowned Node? replace_child (Node new_child, Node old_child) {
                        return this.child_nodes.replace_child (new_child, old_child);
                }
                /**
                 * { inheritDoc}
                 */
-               public override Node? remove_child (Node old_child) {
+               public override unowned Node? remove_child (Node old_child) {
                        return this.child_nodes.remove_child (old_child);
                }
                /**
                 * { inheritDoc}
                 */
-               public override Node? append_child (Node new_child) {
+               public override unowned Node? append_child (Node new_child) {
                        return this.child_nodes.append_child (new_child);
                }
                /**
diff --git a/gxml/BackedNode.vala b/gxml/BackedNode.vala
index b81cbc7..0b9fbfb 100644
--- a/gxml/BackedNode.vala
+++ b/gxml/BackedNode.vala
@@ -250,25 +250,25 @@ namespace GXml {
                /**
                 * { inheritDoc}
                 */
-               public override Node? insert_before (Node new_child, Node? ref_child) {
+               public override unowned Node? insert_before (Node new_child, Node? ref_child) {
                        return this.child_nodes.insert_before (new_child, ref_child);
                }
                /**
                 * { inheritDoc}
                 */
-               public override Node? replace_child (Node new_child, Node old_child) {
+               public override unowned Node? replace_child (Node new_child, Node old_child) {
                        return this.child_nodes.replace_child (new_child, old_child);
                }
                /**
                 * { inheritDoc}
                 */
-               public override Node? remove_child (Node old_child) /*throws DomError*/ {
+               public override unowned Node? remove_child (Node old_child) /*throws DomError*/ {
                        return this.child_nodes.remove_child (old_child);
                }
                /**
                 * { inheritDoc}
                 */
-               public override Node? append_child (Node new_child) /*throws DomError*/ {
+               public override unowned Node? append_child (Node new_child) /*throws DomError*/ {
                        if (new_child.owner_document != this.owner_document && new_child.get_type ().is_a 
(typeof (GXml.BackedNode))) {
                                /* The point here is that a node from another document should
                                   have a copy made to be integrated into this one, so we don't
diff --git a/gxml/Document.vala b/gxml/Document.vala
index ad8f3be..5ed12cd 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -686,7 +686,7 @@ namespace GXml {
                 *
                 * @return The newly added child.
                 */
-               public override Node? append_child (Node new_child) {
+               public override unowned Node? append_child (Node new_child) {
                        this.check_wrong_document (new_child);
                        this.check_read_only ();
 
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 1a317a0..8b74824 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -371,24 +371,24 @@ namespace GXml {
                }
 
                /* ** Node methods ** */
-               public override Node? insert_before (Node new_child, Node? ref_child) {
-                       Node ret = base.insert_before (new_child, ref_child);
+               public override unowned Node? insert_before (Node new_child, Node? ref_child) {
+                       unowned Node ret = base.insert_before (new_child, ref_child);
                        check_add_tag_name (this, new_child);
                        return ret;
                }
-               public override Node? replace_child (Node new_child, Node old_child) {
+               public override unowned Node? replace_child (Node new_child, Node old_child) {
                        check_remove_tag_name (this, old_child);
-                       Node ret = base.replace_child (new_child, old_child);
+                       unowned Node ret = base.replace_child (new_child, old_child);
                        check_add_tag_name (this, new_child);
                        return ret;
                }
-               public override Node? remove_child (Node old_child) {
+               public override unowned Node? remove_child (Node old_child) {
                        check_remove_tag_name (this, old_child);
-                       Node ret = base.remove_child (old_child);
+                       unowned Node ret = base.remove_child (old_child);
                        return ret;
                }
-               public override Node? append_child (Node new_child) {
-                       Node ret = base.append_child (new_child);
+               public override unowned Node? append_child (Node new_child) {
+                       unowned Node ret = base.append_child (new_child);
                        check_add_tag_name (this, new_child);
                        return ret;
                }
diff --git a/gxml/Entity.vala b/gxml/Entity.vala
index bebd0f0..22260b9 100644
--- a/gxml/Entity.vala
+++ b/gxml/Entity.vala
@@ -109,16 +109,16 @@ namespace GXml {
                }
 
                /* Public methods (Node-specific) */
-               public override Node? insert_before (Node new_child, Node? ref_child) {
+               public override unowned Node? insert_before (Node new_child, Node? ref_child) {
                        return this.child_nodes.insert_before (new_child, ref_child);
                }
-               public override Node? replace_child (Node new_child, Node old_child) {
+               public override unowned Node? replace_child (Node new_child, Node old_child) {
                        return this.child_nodes.replace_child (new_child, old_child);
                }
-               public override Node? remove_child (Node old_child) {
+               public override unowned Node? remove_child (Node old_child) {
                        return this.child_nodes.remove_child (old_child);
                }
-               public override Node? append_child (Node new_child) {
+               public override unowned Node? append_child (Node new_child) {
                        return this.child_nodes.append_child (new_child);
                }
                public override bool has_child_nodes () {
diff --git a/gxml/Node.vala b/gxml/Node.vala
index bbb2788..bbde992 100644
--- a/gxml/Node.vala
+++ b/gxml/Node.vala
@@ -325,7 +325,7 @@ namespace GXml {
                 *
                 * @return `new_child`, the node that has been inserted
                 */
-               public virtual Node? insert_before (Node new_child, Node? ref_child) {
+               public virtual unowned Node? insert_before (Node new_child, Node? ref_child) {
                        return null;
                }
                /**
@@ -336,7 +336,7 @@ namespace GXml {
                 *
                 * @return The removed node `old_child`.
                 */
-               public virtual Node? replace_child (Node new_child, Node old_child) {
+               public virtual unowned Node? replace_child (Node new_child, Node old_child) {
                        return null;
                }
                /**
@@ -347,7 +347,7 @@ namespace GXml {
                 *
                 * @return The removed node `old_child`.
                 */
-               public virtual Node? remove_child (Node old_child) {
+               public virtual unowned Node? remove_child (Node old_child) {
                        return null;
                }
                /**
@@ -358,7 +358,7 @@ namespace GXml {
                 *
                 * @return The newly added child.
                 */
-               public virtual Node? append_child (Node new_child) {
+               public virtual unowned Node? append_child (Node new_child) {
                        return null;
                }
                /**
diff --git a/gxml/NodeList.vala b/gxml/NodeList.vala
index 2303517..f609ab6 100644
--- a/gxml/NodeList.vala
+++ b/gxml/NodeList.vala
@@ -119,10 +119,10 @@ namespace GXml {
 
 
                /* These exist to support management of a node's children */
-               internal abstract Node? insert_before (Node new_child, Node? ref_child);
-               internal abstract Node? replace_child (Node new_child, Node old_child);
-               internal abstract Node? remove_child (Node old_child);
-               internal abstract Node? append_child (Node new_child);
+               internal abstract unowned Node? insert_before (Node new_child, Node? ref_child);
+               internal abstract unowned Node? replace_child (Node new_child, Node old_child);
+               internal abstract unowned Node? remove_child (Node old_child);
+               internal abstract unowned Node? append_child (Node new_child);
 
                /**
                 * Creates an XML string representation of the nodes in the list.
@@ -232,21 +232,21 @@ namespace GXml {
                        return this.nodes.index (target);
                }
 
-               internal Node? insert_before (Node new_child, Node? ref_child) {
+               internal unowned Node? insert_before (Node new_child, Node? ref_child) {
                        this.nodes.insert_before (this.nodes.find (ref_child), new_child);
                        return new_child;
                }
-               internal Node? replace_child (Node new_child, Node old_child) {
+               internal unowned Node? replace_child (Node new_child, Node old_child) {
                        int pos = this.index (old_child);
                        this.remove_child (old_child);
                        this.nodes.insert (new_child, pos);
                        return old_child;
                }
-               internal Node? remove_child (Node old_child) /*throws DomError*/ {
+               internal unowned Node? remove_child (Node old_child) /*throws DomError*/ {
                        this.nodes.remove (old_child);
                        return old_child;
                }
-               internal Node? append_child (Node new_child) /*throws DomError*/ {
+               internal unowned Node? append_child (Node new_child) /*throws DomError*/ {
                        this.nodes.append (new_child);
                        return new_child;
                }
@@ -545,7 +545,7 @@ namespace GXml {
                }
 
                /** Node's child methods, implemented here **/
-               internal new Node? insert_before (Node new_child, Node? ref_child) {
+               internal new unowned Node? insert_before (Node new_child, Node? ref_child) {
                        Xml.Node *child = head;
 
                        if (ref_child == null) {
@@ -570,7 +570,7 @@ namespace GXml {
                        return new_child;
                }
 
-               internal new Node? replace_child (Node new_child, Node old_child) {
+               internal new unowned Node? replace_child (Node new_child, Node old_child) {
                        // TODO: verify that libxml2 already removes
                        // new_child first if it is found elsewhere in
                        // the tree.
@@ -600,14 +600,14 @@ namespace GXml {
 
                        return old_child;
                }
-               internal new Node? remove_child (Node old_child) /* throws DomError */ {
+               internal new unowned Node? remove_child (Node old_child) /* throws DomError */ {
                        // TODO: verify that old_child is a valid child here and then unlink
 
                        ((BackedNode)old_child).node->unlink (); // TODO: do we need to free libxml2 stuff 
manually?
                        return old_child;
                }
 
-               internal virtual Node? append_child (Node new_child) /* throws DomError */ {
+               internal virtual unowned Node? append_child (Node new_child) /* throws DomError */ {
                        // TODO: verify that libxml2 will first remove
                        // new_child if it already exists elsewhere in
                        // the tree.


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