[gxml] Removing build warnings



commit db7733123441ab07caee03a46de4a422531e9ac0
Author: Daniel Espinosa <esodan gmail com>
Date:   Fri Jan 20 13:50:18 2017 -0600

    Removing build warnings

 gxml/DomNode.vala                                |    7 +++++--
 gxml/GXmlAttribute.vala                          |    6 ++++--
 gxml/GXmlDocument.vala                           |    6 ++++--
 gxml/GXmlDomCollections.vala                     |    3 ++-
 gxml/GXmlElement.vala                            |   19 +++++++++----------
 gxml/GXmlHashMapAttr.vala                        |   10 ++++++----
 gxml/GXmlListChildren.vala                       |   12 +++++++-----
 gxml/GXmlListNamespaces.vala                     |   10 +++++++---
 gxml/GXmlNamespace.vala                          |    4 ++--
 gxml/GXmlNode.vala                               |    8 ++++----
 gxml/GomDocument.vala                            |    3 ++-
 gxml/GomElement.vala                             |    8 ++++++--
 gxml/GomNode.vala                                |    8 ++++----
 gxml/Namespace.vala                              |    4 ++--
 gxml/TNamespace.vala                             |    4 ++--
 gxml/TNode.vala                                  |    3 ++-
 gxml/XParser.vala                                |    3 +--
 test/SerializableObjectModel-TDocument-Test.vala |    6 +++---
 test/SerializableObjectModelTest.vala            |    1 -
 test/SerializablePropertyEnumTest.vala           |    2 +-
 20 files changed, 73 insertions(+), 54 deletions(-)
---
diff --git a/gxml/DomNode.vala b/gxml/DomNode.vala
index 2dbda1d..32509fb 100644
--- a/gxml/DomNode.vala
+++ b/gxml/DomNode.vala
@@ -79,7 +79,7 @@ public interface GXml.DomNode : GLib.Object, GXml.DomEventTarget {
   public abstract DomNode append_child (DomNode node) throws GLib.Error;
   public abstract DomNode replace_child (DomNode node, DomNode child) throws GLib.Error;
   public abstract DomNode remove_child (DomNode child) throws GLib.Error;
-  public virtual DomNode clone_node (bool deep = false) {
+  public virtual DomNode clone_node (bool deep = false) throws GLib.Error {
     DomNode n = new GomNode ();
     if (owner_document == null) return new GomNode ();
     switch (node_type) {
@@ -109,7 +109,10 @@ public interface GXml.DomNode : GLib.Object, GXml.DomEventTarget {
    * @param node a {@link GXml.DomElement} to copy nodes to
    * @param source a {@link GXml.DomElement} to copy nodes from, it could be holded by different {@link 
GXml.DomDocument}
    */
-  public static bool copy (GXml.DomDocument doc, GXml.DomNode node, GXml.DomNode source, bool deep)
+  public static bool copy (GXml.DomDocument doc,
+                          GXml.DomNode node,
+                          GXml.DomNode source,
+                          bool deep) throws GLib.Error
   {
 #if DEBUG
     GLib.message ("Copying GXml.Node");
diff --git a/gxml/GXmlAttribute.vala b/gxml/GXmlAttribute.vala
index 6872458..bee36e5 100644
--- a/gxml/GXmlAttribute.vala
+++ b/gxml/GXmlAttribute.vala
@@ -71,7 +71,8 @@ public class GXml.GAttribute : GXml.GNode, GXml.Attribute, GXml.DomAttr
   }
   public override string value {
     owned get {
-      if (_node == null) return  null;
+      string nullstr = null;
+      if (_node == null) return  nullstr;
       if (_attr->ns == null) {
         return _node->get_no_ns_prop (_attr->name);
       }
@@ -95,7 +96,8 @@ public class GXml.GAttribute : GXml.GNode, GXml.Attribute, GXml.DomAttr
   }
   public override GXml.Node parent {
     owned get {
-      if (_attr == null) return null;
+      GXml.Node nullnode = null;
+      if (_attr == null) return nullnode;
       return to_gnode (document as GDocument, _node);
     }
   }
diff --git a/gxml/GXmlDocument.vala b/gxml/GXmlDocument.vala
index 06f028f..48bae9b 100644
--- a/gxml/GXmlDocument.vala
+++ b/gxml/GXmlDocument.vala
@@ -349,7 +349,8 @@ public class GXml.GDocument : GXml.GNode,
     return null; // FIXME
   }
   public DomNodeList query_selector_all (string selectors) throws GLib.Error  {
-    return null; // FIXME
+    DomNodeList nulllist = null;
+    return nulllist; // FIXME
   }
   // DomNonElementParentNode
   public DomElement? get_element_by_id (string element_id) throws GLib.Error {
@@ -364,8 +365,9 @@ public class GXml.GDocument : GXml.GNode,
                                     Gee.List<GXml.Namespace>? resolver = null)
                                     throws GXml.XPathError
   {
+    XPathObject nullobj = null;
     if (document_element == null)
-      return null;
+      return nullobj;
     return (document_element as XPathContext).evaluate (expression, resolver);
   }
 }
diff --git a/gxml/GXmlDomCollections.vala b/gxml/GXmlDomCollections.vala
index 6b9119e..56fb556 100644
--- a/gxml/GXmlDomCollections.vala
+++ b/gxml/GXmlDomCollections.vala
@@ -96,7 +96,8 @@ public class GXml.GDomTokenList : Gee.ArrayList<string>, GXml.DomTokenList {
   public void update () {
     if (_element == null) return;
     if (_attr == null) return;
-    _element.set_attribute (_attr, this.to_string ());;
+    try  { _element.set_attribute (_attr, this.to_string ()); }
+    catch (GLib.Error e) { warning (_("Update Error: ")+e.message); }
   }
   public string to_string () {
     string s = "";
diff --git a/gxml/GXmlElement.vala b/gxml/GXmlElement.vala
index a06c13e..19a5e74 100644
--- a/gxml/GXmlElement.vala
+++ b/gxml/GXmlElement.vala
@@ -328,22 +328,21 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
                                     Gee.List<GXml.Namespace>? resolver = null)
                                     throws GXml.XPathError
   {
+    GXml.XPathObject nullobj = null;
     if (!(this is GXml.Node))
-      return null;
+      return nullobj;
     string data = (this as GXml.Node).to_string();
     var ndoc = Xml.Parser.read_memory (data, data.length);
     var gdoc = new GXml.GDocument.from_doc (ndoc);
     var context = new Xml.XPath.Context (ndoc);
     if (resolver != null)
-         resolver.foreach (ns => {
-               int res = context.register_ns (ns.prefix, ns.uri);
-               if (res != 0) {
-                 var err = new GXml.XPathError.EXPRESSION_OK ("invalid namespace.");
-                 err.code = res;
-                 throw err;
-        }
-        return true; 
-      });
+    resolver.foreach (ns => {
+      int res = context.register_ns (ns.prefix, ns.uri);
+      if (res != 0) {
+        GLib.warning (_("invalid namespace. Code: ")+res.to_string ());
+      }
+      return true;
+    });
     return new GXml.GXPathObject (gdoc, context.eval (expression));
   }
 }
diff --git a/gxml/GXmlHashMapAttr.vala b/gxml/GXmlHashMapAttr.vala
index bb28910..2b5fde2 100644
--- a/gxml/GXmlHashMapAttr.vala
+++ b/gxml/GXmlHashMapAttr.vala
@@ -61,10 +61,11 @@ public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>,
     }
   }
   public override GXml.Node @get (string key) {
-    if (_node == null) return null;
+    GXml.Node nullnode = null;
+    if (_node == null) return nullnode;
     if (":" in key) {
       string[] pp = key.split (":");
-      if (pp.length != 2) return null;
+      if (pp.length != 2) return nullnode;
       var ps = _node->properties;
       var prefix = pp[0];
       var n = pp[1];
@@ -78,7 +79,7 @@ public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>,
       }
     }
     var p = _node->has_prop (key);
-    if (p == null) return null;
+    if (p == null) return nullnode;
     // Check property found has Ns, then try to find one without it to return instead
     if (p->ns != null) {
       var npns = _node->has_ns_prop (key, null);
@@ -170,8 +171,9 @@ public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>,
     }
 
     public string get_key () {
+      string nullstr = null;
       if (_current != null) _current->name.dup ();
-      return null;
+      return nullstr;
     }
     public GXml.Node get_value () {
       return new GAttribute (_doc, _current);
diff --git a/gxml/GXmlListChildren.vala b/gxml/GXmlListChildren.vala
index 5c55409..bf7016c 100644
--- a/gxml/GXmlListChildren.vala
+++ b/gxml/GXmlListChildren.vala
@@ -39,7 +39,8 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
   }
   // List
   public override GXml.Node @get (int index) {
-    if (_node == null) return null;
+    GXml.Node nullnode = null;
+    if (_node == null) return nullnode;
     var n = _node->children;
     int i = 0;
     while (n != null) {
@@ -49,7 +50,7 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
       i++;
       n = n->next;
     }
-    return null;
+    return nullnode;
   }
   public override int index_of (GXml.Node item) {
     if (_node == null) return -1;
@@ -76,13 +77,14 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
    * Removes a node at @index. This method never returns a valid pointer.
    */
   public override GXml.Node remove_at (int index) {
-    if (index > size || index < 0) return null;
+    GXml.Node nullnode = null;
+    if (index > size || index < 0) return nullnode;
     var n = @get (index);
-    if (n == null) return null;
+    if (n == null) return nullnode;
     var np = (n as GXml.GNode).get_internal_node ();
     np->unlink ();
     delete np;
-    return null;
+    return nullnode;
   }
   /**
    * This method is ignored by default.
diff --git a/gxml/GXmlListNamespaces.vala b/gxml/GXmlListNamespaces.vala
index f3a95be..40b75a0 100644
--- a/gxml/GXmlListNamespaces.vala
+++ b/gxml/GXmlListNamespaces.vala
@@ -35,7 +35,8 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Namespace>
   }
   // List
   public override new GXml.Namespace @get (int index) {
-    if (_node == null) return null;
+    GXml.Namespace nullns = null;
+    if (_node == null) return nullns;
     var ns = _node->ns_def;
     int i = 0;
     while (ns != null) {
@@ -45,7 +46,7 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Namespace>
       ns = ns->next;
       i++;
     }
-    return null;
+    return nullns;
   }
   public override int index_of (GXml.Namespace item) {
     if (_node == null) return -1;
@@ -61,7 +62,10 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Namespace>
   }
   public override void insert (int index, GXml.Namespace item) {}
   public override Gee.ListIterator<GXml.Namespace> list_iterator () { return new Iterator (_node); }
-  public override GXml.Namespace remove_at (int index) { return null; }
+  public override GXml.Namespace remove_at (int index) {
+    GXml.Namespace nullns = null;
+    return nullns;
+  }
   public override new void @set (int index, GXml.Namespace item) {}
   public override Gee.List<GXml.Namespace>? slice (int start, int stop) {
     var l = new ArrayList<GXml.Namespace> ();
diff --git a/gxml/GXmlNamespace.vala b/gxml/GXmlNamespace.vala
index 461ea16..0ec86cb 100644
--- a/gxml/GXmlNamespace.vala
+++ b/gxml/GXmlNamespace.vala
@@ -30,13 +30,13 @@ public class GXml.GNamespace : Object, GXml.Namespace
   public GNamespace (Xml.Ns* ns) { _ns = ns; }
   public Xml.Ns* get_internal_ns () { return _ns; }
   // GXml.Namespace
-  public string uri {
+  public string? uri {
     owned get {
       if (_ns == null) return null;
       return _ns->href.dup ();
     }
   }
-  public string @prefix {
+  public string? @prefix {
     owned get {
       if (_ns == null) return null;
       return _ns->prefix.dup ();
diff --git a/gxml/GXmlNode.vala b/gxml/GXmlNode.vala
index 6007939..b5068c9 100644
--- a/gxml/GXmlNode.vala
+++ b/gxml/GXmlNode.vala
@@ -168,8 +168,9 @@ public abstract class GXml.GNode : Object,
   public DomNode? parent_node { owned get { return parent as DomNode?; } }
   public DomElement? parent_element {
     owned get {
+      DomElement nullnode = null;
       if (parent is DomElement) return parent as DomElement?;
-      return null;
+      return nullnode;
     }
   }
   public DomNodeList child_nodes { owned get { return children_nodes as DomNodeList; } }
@@ -219,23 +220,22 @@ public abstract class GXml.GNode : Object,
 
   public bool has_child_nodes () { return (children_nodes.size > 0); }
   public void normalize () {
-    try {
     for (int i = 0; i < children_nodes.size; i++) {
       var n = children_nodes.get (i);
       if (n is DomText) {
         child_nodes.remove_at (i);
       }
     }
-    } catch {}
   }
 
   public DomNode clone_node (bool deep = false) {
+    DomNode nullnode = null;
     Xml.Node *n = null;
     if (deep)
       n = _node->copy (1);
     else
       n = _node->copy (2);
-    if (n == null) return null;
+    if (n == null) return nullnode;
     return (DomNode) GNode.to_gnode (_doc, n);
   }
   public bool is_equal_node (DomNode? node) {
diff --git a/gxml/GomDocument.vala b/gxml/GomDocument.vala
index 3f58634..bbf9651 100644
--- a/gxml/GomDocument.vala
+++ b/gxml/GomDocument.vala
@@ -284,7 +284,8 @@ public class GXml.GomDocument : GomNode,
     return null; // FIXME
   }
   public DomNodeList query_selector_all (string selectors) throws GLib.Error  {
-    return null; // FIXME
+    DomNodeList nulllist = null;
+    return nulllist; // FIXME
   }
   // DomNonElementParentNode
   public DomElement? get_element_by_id (string element_id) throws GLib.Error {
diff --git a/gxml/GomElement.vala b/gxml/GomElement.vala
index 4437d1d..35420c1 100644
--- a/gxml/GomElement.vala
+++ b/gxml/GomElement.vala
@@ -499,10 +499,14 @@ public class GXml.GomElement : GomNode,
   }
   public void remove_attribute (string name) {
     if ((this as GomObject).remove_attribute (name)) return;
-    attributes.remove_named_item (name);
+    try { attributes.remove_named_item (name); }
+    catch (GLib.Error e)
+      { warning (_("Removing attribute Error: ")+e.message); }
   }
   public void remove_attribute_ns (string? namespace_uri, string local_name) {
-    attributes.remove_named_item_ns (namespace_uri, local_name);
+    try { attributes.remove_named_item_ns (namespace_uri, local_name); }
+    catch (GLib.Error e)
+      { warning (_("Removing namespaced attribute Error: ")+e.message); }
   }
   public bool has_attribute (string name) {
     return _attributes.has_key (name);
diff --git a/gxml/GomNode.vala b/gxml/GomNode.vala
index 018af80..8810bf8 100644
--- a/gxml/GomNode.vala
+++ b/gxml/GomNode.vala
@@ -74,8 +74,10 @@ public class GXml.GomNode : Object,
       if (this is DomDocument) return (DomDocument) this;
       if (_document == null) {
         _document = new GomDocument ();
-        if (this is DomElement)
-          _document.append_child (this);
+        if (this is DomElement) {
+          try { _document.append_child (this); }
+          catch (GLib.Error e) { warning (e.message); }
+        }
       }
       return _document;
     }
@@ -162,14 +164,12 @@ public class GXml.GomNode : Object,
 
   public bool has_child_nodes () { return (_child_nodes.size > 0); }
   public void normalize () {
-    try {
     for (int i = 0; i < child_nodes.size; i++) {
       var n = child_nodes.get (i);
       if (n is DomText) {
         child_nodes.remove_at (i);
       }
     }
-    } catch {}
   }
 
   public bool is_equal_node (DomNode? node) { // FIXME: This is not going to work
diff --git a/gxml/Namespace.vala b/gxml/Namespace.vala
index 0a18191..4bacbfc 100644
--- a/gxml/Namespace.vala
+++ b/gxml/Namespace.vala
@@ -36,13 +36,13 @@ public interface GXml.Namespace : Object
   /**
    * Read-only property to get namespace's URI.
    */
-  public abstract string uri { owned get; }
+  public abstract string? uri { owned get; }
   /**
    * Read-only property to get namespace's prefix.
    *
    * Prefix should be added to {@link GXml.Element} or {@link GXml.Attribute}
    * name in order to apply a given namespace, unless it is the default.
    */
-  public abstract string prefix { owned get; }
+  public abstract string? prefix { owned get; }
 }
 
diff --git a/gxml/TNamespace.vala b/gxml/TNamespace.vala
index 433fc2d..31680c2 100644
--- a/gxml/TNamespace.vala
+++ b/gxml/TNamespace.vala
@@ -37,6 +37,6 @@ public class GXml.TNamespace : GXml.TNode, GXml.Namespace
     _prefix = prefix;
   }
   // GXml.Namespace
-  public string uri { owned get { return _uri.dup (); } }
-  public string @prefix { owned get { return _prefix.dup (); } }
+  public string? uri { owned get { return _uri.dup (); } }
+  public string? @prefix { owned get { return _prefix.dup (); } }
 }
diff --git a/gxml/TNode.vala b/gxml/TNode.vala
index f480915..4f45178 100644
--- a/gxml/TNode.vala
+++ b/gxml/TNode.vala
@@ -62,7 +62,8 @@ public abstract class GXml.TNode : Object, GXml.Node
   public virtual string value { owned get { return _value.dup (); } set  { _value = value; } }
   public virtual GXml.Node parent {
     owned get {
-      if (_parent == null) return null;
+      GXml.Node nullnode = null;
+      if (_parent == null) return nullnode;
       return (GXml.Node) _parent.ref ();
     }
   }
diff --git a/gxml/XParser.vala b/gxml/XParser.vala
index 348e6e9..91c4436 100644
--- a/gxml/XParser.vala
+++ b/gxml/XParser.vala
@@ -87,7 +87,6 @@ public class GXml.XParser : Object, GXml.Parser {
   public void read_string (string str, GLib.Cancellable? cancellable) throws GLib.Error {
     if (str == "")
       throw new ParserError.INVALID_DATA_ERROR (_("Invalid document string, it is empty or is not allowed"));
-    StringBuilder s = new StringBuilder (str);
     var stream = new GLib.MemoryInputStream.from_data (str.data);
     read_stream (stream, cancellable);
   }
@@ -181,7 +180,7 @@ public class GXml.XParser : Object, GXml.Parser {
   /**
    * Creates a new {@link DomElement} and append it as a child of parent.
    */
-  public DomElement? create_element (DomNode parent) {
+  public DomElement? create_element (DomNode parent) throws GLib.Error {
     DomElement n = null;
 #if DEBUG
     GLib.message ("Creating a standard element: "
diff --git a/test/SerializableObjectModel-TDocument-Test.vala 
b/test/SerializableObjectModel-TDocument-Test.vala
index b122307..24f5b51 100644
--- a/test/SerializableObjectModel-TDocument-Test.vala
+++ b/test/SerializableObjectModel-TDocument-Test.vala
@@ -61,7 +61,7 @@ class SerializableObjectModelTDocumentTest : GXmlTest
        assert (manual.get_contents () == "TEXT INTO THE MANUAL DOCUMENT");
        try {
          manual.serialize (doc);
-         Element element = (Element) doc.root;
+         //Element element = (Element) doc.root;
        } catch (GLib.Error e) {
          stdout.printf (@"$(e.message)");
          assert_not_reached ();
@@ -577,7 +577,7 @@ Test.add_func ("/gxml/tw/serializable/object_model/override_deserialize",
        }
      });*/
   }
-  static void serialize_manual_check (Element element, Manual manual)
+  /*static void serialize_manual_check (Element element, Manual manual)
   {
     var document = element.attrs.get ("document");
     assert (document != null);
@@ -586,5 +586,5 @@ Test.add_func ("/gxml/tw/serializable/object_model/override_deserialize",
     assert (pages != null);
     assert (int.parse (pages.value) == manual.pages);
     assert (element.content == manual.get_contents ());
-  }
+  }*/
 }
diff --git a/test/SerializableObjectModelTest.vala b/test/SerializableObjectModelTest.vala
index e97f33e..7b09139 100644
--- a/test/SerializableObjectModelTest.vala
+++ b/test/SerializableObjectModelTest.vala
@@ -857,7 +857,6 @@ class SerializableObjectModelTest : GXmlTest
        assert (unknown_property.unknown_serializable_nodes.size == 2);
        bool foundn = false;
        bool foundt = false;
-       GXml.Node unkn;
        foreach (GXml.Node n in unknown_property.unknown_serializable_nodes) {
          if (n.name == "UnknownNode") {
            foundn = true;
diff --git a/test/SerializablePropertyEnumTest.vala b/test/SerializablePropertyEnumTest.vala
index b945bf2..48ff421 100644
--- a/test/SerializablePropertyEnumTest.vala
+++ b/test/SerializablePropertyEnumTest.vala
@@ -32,7 +32,7 @@ class SerializablePropertyEnumTest : GXmlTest {
     }
     public Enum.Values get_value () throws GLib.Error { return (Enum.Values) to_integer (); }
     public void set_value (Enum.Values val) throws GLib.Error { parse_integer ((int) val); }
-    public string get_string () throws GLib.Error { return get_serializable_property_value (); }
+    //public string get_string () throws GLib.Error { return get_serializable_property_value (); }
     public void set_string (string? str) throws GLib.Error { set_serializable_property_value (str); }
     public enum Values {
       SER_ONE,


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