[gxml] Renamed to_string to stringify on xNode



commit 9182766cbc4a525caf23b1c5bc5a6d50f86fe8e3
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Apr 15 17:28:48 2015 -0500

    Renamed to_string to stringify on xNode
    
    * This will avoid conflicts with GXml.Node.to_string()
    * Updated GXml.Node API to read only properties
    * GXml.Node.copy () will be equivalent to xNode.copy () signature

 gxml/Node.vala                 |    8 ++++----
 gxml/SerializableJson.vala     |    2 +-
 gxml/Serialization.vala        |    4 ++--
 gxml/libxml-Attr.vala          |    8 +++-----
 gxml/libxml-BackedNode.vala    |    2 +-
 gxml/libxml-ChildNodeList.vala |    2 +-
 gxml/libxml-Document.vala      |    2 +-
 gxml/libxml-DocumentType.vala  |    7 ++-----
 gxml/libxml-Element.vala       |    4 ++--
 gxml/libxml-LinkedList.vala    |    2 +-
 gxml/libxml-Node.vala          |   27 +++++++++++++--------------
 11 files changed, 31 insertions(+), 37 deletions(-)
---
diff --git a/gxml/Node.vala b/gxml/Node.vala
index 462f2a9..c045988 100644
--- a/gxml/Node.vala
+++ b/gxml/Node.vala
@@ -27,11 +27,11 @@ public interface GXml.Node : Object
   public abstract Gee.BidirList<GXml.Namespace> namespaces { get; }
   public abstract Gee.BidirList<GXml.Node> childs { get; }
   public abstract Gee.Map<string,GXml.Node> attrs { get; }
-  public abstract string name { get; construct set; }
+  public abstract string name { get; }
   public abstract string @value { get; set; }
-  public abstract GXml.NodeType type_node { get; construct set; }
-  public abstract GXml.Document document { get; construct set; }
-  public abstract GXml.Node copy ();
+  public abstract GXml.NodeType type_node { get; }
+  public abstract GXml.Document document { get; }
+  public abstract GXml.Node copy (ref GXml.Node node, bool deep);
   public abstract string to_string ();
   public virtual string ns_prefix () { return namespaces.first ().prefix; }
   public virtual string ns_urf () { return namespaces.first ().uri; }
diff --git a/gxml/SerializableJson.vala b/gxml/SerializableJson.vala
index a2b64f7..c6d2698 100644
--- a/gxml/SerializableJson.vala
+++ b/gxml/SerializableJson.vala
@@ -250,7 +250,7 @@ public class GXml.SerializableJson : GLib.Object, GXml.Serializable
       spec = this.find_property_spec (pname);
 
       if (spec == null) {
-        GLib.message ("Deserializing object of type '%s' claimed unknown property named '%s'\nXML [%s]", 
ptype, pname, property_node.to_string ());
+        GLib.message ("Deserializing object of type '%s' claimed unknown property named '%s'\nXML [%s]", 
ptype, pname, property_node.stringify ());
         unknown_serializable_property.set (property_node.node_name, property_node);
       }
       else {
diff --git a/gxml/Serialization.vala b/gxml/Serialization.vala
index 3339524..381536c 100644
--- a/gxml/Serialization.vala
+++ b/gxml/Serialization.vala
@@ -86,7 +86,7 @@ namespace GXml {
         */
        public class Serialization : GLib.Object {
                private static void print_debug (GXml.xDocument doc, GLib.Object object) {
-                       stdout.printf ("Object XML\n---\n%s\n", doc.to_string ());
+                       stdout.printf ("Object XML\n---\n%s\n", doc.stringify ());
 
                        stdout.printf ("object\n---\n");
                        stdout.printf ("get_type (): %s\n", object.get_type ().name ());
@@ -429,7 +429,7 @@ namespace GXml {
                                        spec = obj_class.find_property (pname);
 
                                        if (spec == null) {
-                                               throw new SerializationError.UNKNOWN_PROPERTY ("Unknown 
property '%s' found, for object type '%s'-->XML: [%s]", pname, otype, obj_elem.to_string ());
+                                               throw new SerializationError.UNKNOWN_PROPERTY ("Unknown 
property '%s' found, for object type '%s'-->XML: [%s]", pname, otype, obj_elem.stringify ());
                                        }
                                        Serialization.deserialize_property (spec, prop_elem, out val);
                                        obj.set_property (pname, val);
diff --git a/gxml/libxml-Attr.vala b/gxml/libxml-Attr.vala
index ef89001..aba2db8 100644
--- a/gxml/libxml-Attr.vala
+++ b/gxml/libxml-Attr.vala
@@ -180,13 +180,11 @@ namespace GXml {
                 * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1112119403]]
                 */
-               public string name {
+               public override string name {
                        get {
                                // TODO: make sure that this is the right name, and that ownership is correct
                                return this.node_name;
                        }
-                       private set {
-                       }
                }
 
                /**
@@ -215,7 +213,7 @@ namespace GXml {
                 * Version: DOM Level 1 Core<<BR>>
                 * URL: [[http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-221662474]]
                 */
-               public string value {
+               public override string value {
                        get {
                                return this.node_value;
                        }
@@ -251,7 +249,7 @@ namespace GXml {
                /**
                 * { inheritDoc}
                 */
-               public override string to_string (bool format = false, int level = 0) {
+               public override string stringify (bool format = false, int level = 0) {
                        return "Attr(%s=\"%s\")".printf (this.name, this.value);
                }
        }
diff --git a/gxml/libxml-BackedNode.vala b/gxml/libxml-BackedNode.vala
index d139edd..7ac2790 100644
--- a/gxml/libxml-BackedNode.vala
+++ b/gxml/libxml-BackedNode.vala
@@ -337,7 +337,7 @@ namespace GXml {
                        // TODO: add a better test, as we weren't realising this was just a stub; test for 
memory usage too
                }
 
-               public override string to_string (bool format = true, int level = 0) {
+               public override string stringify (bool format = true, int level = 0) {
                        /* TODO: change from xmlNodeDump and xmlBuffer
                         * to xmlBuf and xmlBufNodeDump; the former
                         * are 'somehow deprecated' (see xmlNodeDump
diff --git a/gxml/libxml-ChildNodeList.vala b/gxml/libxml-ChildNodeList.vala
index 6b8e28b..a514b9c 100644
--- a/gxml/libxml-ChildNodeList.vala
+++ b/gxml/libxml-ChildNodeList.vala
@@ -219,7 +219,7 @@ internal abstract class GXml.ChildNodeList : AbstractBidirList<xNode>, NodeList
                public string to_string (bool in_line = true) {
                        string str = "";
                        foreach (xNode node in this) {
-                               str += node.to_string ();
+                               str += node.stringify ();
                        }
                        return str;
                }
diff --git a/gxml/libxml-Document.vala b/gxml/libxml-Document.vala
index ffda819..d1f8786 100644
--- a/gxml/libxml-Document.vala
+++ b/gxml/libxml-Document.vala
@@ -873,7 +873,7 @@ namespace GXml {
                /**
                 * { inheritDoc}
                 */
-               public override string to_string (bool format = true, int level = 0) {
+               public override string stringify (bool format = true, int level = 0) {
                        string str;
                        int len;
 
diff --git a/gxml/libxml-DocumentType.vala b/gxml/libxml-DocumentType.vala
index 6e866c9..2eb7794 100644
--- a/gxml/libxml-DocumentType.vala
+++ b/gxml/libxml-DocumentType.vala
@@ -1,4 +1,4 @@
-/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
 /* DocumentType.vala
  *
  * Copyright (C) 2011-2013  Richard Schwarting <aquarichy gmail com>
@@ -52,14 +52,11 @@ namespace GXml {
                 * the XML doctype declaration of
                 * {{{ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";> }}}
                 */
-               public string name {
+               public override string name {
                        get {
                                // TODO: is it possible for int_subset and ext_subset to have different names?
                                return this.int_subset->name;
                        }
-                       // TODO: should this match node_name?
-                       private set {
-                       }
                }
 
                /* TODO: make more static methods internal instead of public, if possible */
diff --git a/gxml/libxml-Element.vala b/gxml/libxml-Element.vala
index 9286636..d22b989 100644
--- a/gxml/libxml-Element.vala
+++ b/gxml/libxml-Element.vala
@@ -492,12 +492,12 @@ namespace GXml {
                /**
                 * { inheritDoc}
                 */
-               public override string to_string (bool format = false, int level = 0) {
+               public override string stringify (bool format = false, int level = 0) {
                        /* TODO: may want to determine a way to only sync when
                           attributes have been modified */
 
                        this.owner_document.dirty_elements.append (this);
-                       return base.to_string (format, level);
+                       return base.stringify (format, level);
                }
        }
 }
diff --git a/gxml/libxml-LinkedList.vala b/gxml/libxml-LinkedList.vala
index 9163fa3..3b47fcb 100644
--- a/gxml/libxml-LinkedList.vala
+++ b/gxml/libxml-LinkedList.vala
@@ -85,7 +85,7 @@ internal class GXml.LinkedList : Gee.LinkedList<GXml.xNode>, NodeList
   {
     string str = "";
          foreach (xNode node in this) {
-                 str += node.to_string ();
+                 str += node.stringify ();
          }
          return str;
   }
diff --git a/gxml/libxml-Node.vala b/gxml/libxml-Node.vala
index 7c20895..0039242 100644
--- a/gxml/libxml-Node.vala
+++ b/gxml/libxml-Node.vala
@@ -480,15 +480,6 @@ namespace GXml {
                        return null;
                }
 
-               /**
-                * Creates a copy of node's definition to @node.
-                *
-                * @param node: a { link GXml.xNode} to copy values to.
-                * @param deep: { link true} when you want to copy child nodes too.
-                */
-               public virtual bool copy (ref xNode node, bool deep = false) {
-                       return false;
-               }
 
                // TODO: ask Colin Walters about storing docs in GIR files (might have not been him)
                /**
@@ -506,7 +497,7 @@ namespace GXml {
                 * @return XML string for node, which must be free
                 * this.
                 */
-               public virtual string to_string (bool format = false, int level = 0) {
+               public virtual string stringify (bool format = false, int level = 0) {
                        return "xNode(%d:%s)".printf (this.node_type, this.node_name);
                }
                
@@ -514,12 +505,20 @@ namespace GXml {
                public virtual Gee.BidirList<GXml.Namespace> namespaces { get { return 
_namespace_definitions; } }
                public virtual Gee.BidirList<GXml.Node> childs { get { return (BidirList<GXml.Node>) 
child_nodes; } }
                public virtual Gee.Map<string,GXml.Node> attrs { get { return (Map<string,GXml.Node>) 
_attributes; } }
+               public virtual string name { get { return node_name; } }
+               public virtual string @value { get { return node_value; } set { node_value = value; } }
+               public GXml.NodeType type_node { get { return node_type; } }
+               /**
+                * Creates a copy of node's definition to @node.
+                *
+                * @param node: a { link GXml.xNode} to copy values to.
+                * @param deep: { link true} when you want to copy child nodes too.
+                */
+               public virtual bool copy (ref xNode node, bool deep = false) { // TODO: Change to GXml.Node
+                       return false;
+               }
                /*
-               public string name { get; construct set; }
-               public string @value { get; set; }
-               public GXml.NodeType type_node { get; construct set; }
                public GXml.Document document { get; construct set; }
-               public GXml.Node copy ();
                public string to_string ();*/
        }
 }


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