[gxml] Removing some warnings. API change. Valac to 0.32



commit a010d68b2d00aa0b2cf5b07e24d7ea5097fd8125
Author: Daniel Espinosa <esodan gmail com>
Date:   Fri Sep 9 10:30:43 2016 -0500

    Removing some warnings. API change. Valac to 0.32
    
    * TNode based classes API changes:
        * TDocument.read_doc_stream() now throws GLib.Error
    * Reducing number of warnings at valac compilation time
    * Bump version of required VALAC to 0.32, due to use of [Version] annotation
    * Updated some error message text to avoid warnings

 NEWS                                |    5 ++++-
 configure.ac                        |    2 +-
 gxml/GXmlDocument.vala              |    4 ++--
 gxml/GXmlDomRange.vala              |    4 ----
 gxml/GXmlElement.vala               |    3 +--
 gxml/GXmlHashMapAttr.vala           |    4 ----
 gxml/GXmlListChildren.vala          |    9 ++-------
 gxml/GXmlListNamespaces.vala        |    1 -
 gxml/GXmlNode.vala                  |    3 ++-
 gxml/GXmlProcessingInstruction.vala |    2 +-
 gxml/Serializable.vala              |    9 ++-------
 gxml/SerializableObjectModel.vala   |    1 -
 gxml/TDocument.vala                 |   15 ++++++++++-----
 gxml/libxml-DomException.vala       |    2 +-
 vapi/xlibxml-1.0.vapi               |    2 +-
 15 files changed, 27 insertions(+), 39 deletions(-)
---
diff --git a/NEWS b/NEWS
index 14f0f19..3ef54d0 100644
--- a/NEWS
+++ b/NEWS
@@ -24,7 +24,10 @@ Version 0.11.0
     Updated Hungarian   by Balázs Meskó <meskobalazs gmail com>
     Updated Spanish     by Daniel Mustieles <daniel mustieles gmail com>
     Added Indonesian    by Andika Triwidada <atriwidada gnome org>
-
+* TNode based classes API changes:
+    * TDocument.read_doc_stream() now throws GLib.Error
+* Reducing number of warnings at valac compilation time
+* Bump version of required VALAC to 0.32, due to use of [Version] annotation
 
 ===============
 Version 0.10.0
diff --git a/configure.ac b/configure.ac
index cff92f8..050883f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,7 +128,7 @@ PKG_CHECK_MODULES([GLIB],
                    gobject-2.0 >= $GLIB_REQUIRED])
 
 # Check for vala
-VALAC_CHECK
+VALAC_CHECK(0.32)
 
 # Check for libgee
 PKG_CHECK_MODULES(GEE, gee-0.8 >= $GEE_REQUIRED)
diff --git a/gxml/GXmlDocument.vala b/gxml/GXmlDocument.vala
index 1630721..53301ea 100644
--- a/gxml/GXmlDocument.vala
+++ b/gxml/GXmlDocument.vala
@@ -386,7 +386,7 @@ public class GXml.GDocumentType : GXml.GChildNode,
   protected string _public_id = "";
   protected string _system_id = "";
 
-  public string name { get { return _name; } }
+  public  new string name { get { return _name; } }
   public string public_id { get { return _public_id; } }
   public string system_id { get { return _system_id; } }
 
@@ -401,7 +401,7 @@ public class GXml.GDocumentType : GXml.GChildNode,
     _system_id = system_id;
   }
   // DomChildNode implementation
-  public void remove () {
+  public new void remove () {
     get_internal_node ()->unlink ();
   }
 }
diff --git a/gxml/GXmlDomRange.vala b/gxml/GXmlDomRange.vala
index 51a4a04..0cb6895 100644
--- a/gxml/GXmlDomRange.vala
+++ b/gxml/GXmlDomRange.vala
@@ -169,22 +169,18 @@ public class GXml.GDomRange : Object, GXml.DomRange {
                                set_start (_start_container, 0);
                                set_end (source_range.start_container, 0);
                                return 0;
-                               break;
                        case BoundaryPoints.START_TO_END:
                                set_start (_start_container, _start_container.child_nodes.size);
                                set_end (source_range.end_container, 0);
                                return -1;
-                               break;
                        case BoundaryPoints.END_TO_END:
                                set_start (_end_container, 0);
                                set_end (source_range.end_container, 0);
                                return 0;
-                               break;
                        case BoundaryPoints.END_TO_START:
                                set_start (_start_container, 0);
                                set_end (source_range.end_container, 0);
                                return 1;
-                               break;
                }
                return 0;
        }
diff --git a/gxml/GXmlElement.vala b/gxml/GXmlElement.vala
index d347862..509a266 100644
--- a/gxml/GXmlElement.vala
+++ b/gxml/GXmlElement.vala
@@ -92,12 +92,11 @@ public class GXml.GElement : GXml.GNonDocumentChildNode,
   }
   public GXml.Node? get_ns_attr (string name, string uri) {
     if (_node == null) return null;
-    var ns = _node->doc->search_ns_by_href (_node, uri);
     var a = _node->has_ns_prop (name, uri);
     if (a == null) return null;
     return new GAttribute (_doc, a);
   }
-  public void normalize () {}
+  public new void normalize () {}
   public string content {
     owned get {
       return _node->get_content ().dup ();
diff --git a/gxml/GXmlHashMapAttr.vala b/gxml/GXmlHashMapAttr.vala
index cf3b00d..1883237 100644
--- a/gxml/GXmlHashMapAttr.vala
+++ b/gxml/GXmlHashMapAttr.vala
@@ -234,7 +234,6 @@ public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>,
     return null;
   }
   public DomNode? set_named_item (DomNode node) throws GLib.Error {
-    var i = values.iterator ();
     iterator ().next ();
     var _parent = iterator ().get ().value.parent_node as DomElement;
     if (size > 0 && node.owner_document != _parent.owner_document)
@@ -252,7 +251,6 @@ public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>,
     return null;
   }
   public DomNode? remove_named_item (string name) throws GLib.Error {
-    var i = values.iterator ();
     iterator ().next ();
     var _parent = iterator ().get ().value.parent_node as DomElement;
     var n = base.get (name);
@@ -288,7 +286,6 @@ public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>,
   }
   // Introduced in DOM Level 2:
   public DomNode? set_named_item_ns (DomNode node) throws GLib.Error {
-    var i = values.iterator ();
     iterator ().next ();
     var _parent = iterator ().get ().value.parent_node as DomElement;
     if (size > 0 && node.owner_document != _parent.owner_document)
@@ -309,7 +306,6 @@ public class GXml.GHashMapAttr : Gee.AbstractMap<string,GXml.Node>,
   }
   // Introduced in DOM Level 2:
   public DomNode? remove_named_item_ns (string namespace_uri, string local_name) throws GLib.Error {
-    var i = values.iterator ();
     iterator ().next ();
     var _parent = iterator ().get ().value.parent_node as DomElement;
     if (!(_parent is DomElement)) return null;
diff --git a/gxml/GXmlListChildren.vala b/gxml/GXmlListChildren.vala
index 4f6e03a..60859b3 100644
--- a/gxml/GXmlListChildren.vala
+++ b/gxml/GXmlListChildren.vala
@@ -30,7 +30,6 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
 {
   private GXml.GDocument _doc;
   private Xml.Node *_node;
-  private bool _read_only = false;
   public GListChildren (GDocument doc, Xml.Node* node) {
     _node = node;
     _doc = doc;
@@ -44,7 +43,6 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
     var n = _node->children;
     int i = 0;
     while (n != null) {
-      var t = (GXml.NodeType) n->type;
       if (i == index) {
         return GNode.to_gnode (_doc, n);
       }
@@ -108,11 +106,8 @@ public class GXml.GListChildren : AbstractBidirList<GXml.Node>,
     if (_node == null) return false;
     if (!(item is GNamespace))
       return (_node->add_child (((GNode) item).get_internal_node ())) != null;
-    else {
-      var ns = (GXml.Namespace) item;
-      return (_node->new_ns (ns.uri, ns.prefix)) != null;
-    }
-    return false;
+    var ns = (GXml.Namespace) item;
+    return (_node->new_ns (ns.uri, ns.prefix)) != null;
   }
   public override void clear () {
     if (_node == null) return;
diff --git a/gxml/GXmlListNamespaces.vala b/gxml/GXmlListNamespaces.vala
index 83c5f89..f3a95be 100644
--- a/gxml/GXmlListNamespaces.vala
+++ b/gxml/GXmlListNamespaces.vala
@@ -29,7 +29,6 @@ public class GXml.GListNamespaces : Gee.AbstractList<GXml.Namespace>
 {
   private GDocument _doc;
   private Xml.Node *_node;
-  private bool _read_only = false;
   public GListNamespaces (GDocument doc, Xml.Node *node) {
     _node = node;
     _doc = doc;
diff --git a/gxml/GXmlNode.vala b/gxml/GXmlNode.vala
index cb11953..7fd9877 100644
--- a/gxml/GXmlNode.vala
+++ b/gxml/GXmlNode.vala
@@ -202,13 +202,14 @@ public abstract class GXml.GNode : Object,
 
   public bool has_child_nodes () { return (children_nodes.size > 0); }
   public void normalize () {
-    GXml.DomText t = owner_document.create_text_node (text_content);
+    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) {
diff --git a/gxml/GXmlProcessingInstruction.vala b/gxml/GXmlProcessingInstruction.vala
index 7356532..7cc2b40 100644
--- a/gxml/GXmlProcessingInstruction.vala
+++ b/gxml/GXmlProcessingInstruction.vala
@@ -35,5 +35,5 @@ public class GXml.GProcessingInstruction : GXml.GCharacterData,
   }
   // GXml.ProcessingInstruction
   public string target { owned get { return name; } }
-  public string data { owned get { return base.value; } set { base.value = value; } }
+  public new string data { owned get { return base.value; } set { base.value = value; } }
 }
diff --git a/gxml/Serializable.vala b/gxml/Serializable.vala
index 8147a3e..0282cce 100644
--- a/gxml/Serializable.vala
+++ b/gxml/Serializable.vala
@@ -410,11 +410,6 @@ namespace GXml {
       } else if (t == typeof (string)) {
         dest2.set_string (str);
         ret = true;
-      } else if (t == typeof (char)) {
-        char val;
-        val = (char) double.parse (str);
-        dest2.set_char (val);
-        ret = true;
       } else if (t == typeof (uchar)) {
         uchar val;
         val = (uchar) double.parse (str);
@@ -436,7 +431,7 @@ namespace GXml {
         dest = dest2;
         return true;
       } else {
-        throw new SerializableError.UNSUPPORTED_TYPE_ERROR (_("Transformation Error on '%s' or Unsupported 
type: '%s'"),
+        throw new SerializableError.UNSUPPORTED_TYPE_ERROR (_("Transformation Error on \'%s\' or Unsupported 
type: \'%s\'"),
                                                       str, t.name ());
       }
     }
@@ -457,7 +452,7 @@ namespace GXml {
       }
       else
       {
-        throw new SerializableError.UNSUPPORTED_TYPE_ERROR (_("Can't transform '%s' to string"), val.type 
().name ());
+        throw new SerializableError.UNSUPPORTED_TYPE_ERROR (_("Can't transform \'%s\' to string"), val.type 
().name ());
       }
     }
   }
diff --git a/gxml/SerializableObjectModel.vala b/gxml/SerializableObjectModel.vala
index f1f94a0..369dbf5 100644
--- a/gxml/SerializableObjectModel.vala
+++ b/gxml/SerializableObjectModel.vala
@@ -38,7 +38,6 @@ using Gee;
 public abstract class GXml.SerializableObjectModel : Object, Serializable
 {
        construct { Init.init (); }
-       GXml.Text text_node = null;
   // To find unknown nodes
   protected GXml.Node _node = null;
   /* Serializable interface properties */
diff --git a/gxml/TDocument.vala b/gxml/TDocument.vala
index 1c2a59d..f950f71 100644
--- a/gxml/TDocument.vala
+++ b/gxml/TDocument.vala
@@ -33,7 +33,6 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
   protected Gee.ArrayList<GXml.Node> _namespaces;
   protected Gee.ArrayList<GXml.Node> _children;
   private GXml.Element _root = null;
-  private ReadTypeFunc _readtype_func = null;
 
   construct {
     _name = "#document";
@@ -187,7 +186,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
   {
     return save_as (file, cancellable);
   }
-  [Deprecated (since="0.8.1", replacement="save_as")]
+  [Version (deprecated=true, deprecated_since="0.8.1", replacement="save_as")]
   public bool save_to (GLib.File f, GLib.Cancellable? cancellable = null)
     throws GLib.Error
   {
@@ -438,6 +437,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
   }
   public override string to_string ()
   {
+    try {
 #if DEBUG
     GLib.message ("TDocument: to_string ()");
 #endif
@@ -448,6 +448,7 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
     int size;
     doc.dump_memory (out str, out size);
     return str;
+    } catch (GLib.Error e) { return "ERROR: "+e.message; }
   }
   /**
    * Enum for {@link Xml.TextReader} flag on parsing.
@@ -478,14 +479,16 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
   /**
    * Reads document from {@link GLib.InputStream} objects.
    */
-  public static void read_doc_stream (GXml.Document doc, GLib.InputStream istream, ReadTypeFunc? rtfunc = 
null) {
+  public static void read_doc_stream (GXml.Document doc,
+                                      GLib.InputStream istream,
+                                      ReadTypeFunc? rtfunc = null) throws GLib.Error
+  {
     var b = new MemoryOutputStream.resizable ();
     b.splice (istream, 0);
 #if DEBUG
     GLib.message ("FILE:"+(string)b.data);
 #endif
     var tr = new TextReader.for_memory ((char[]) b.data, (int) b.get_data_size (), "/gxml_memory");
-    GXml.Node current = null;
     while (read_node (doc, tr, rtfunc) == ReadType.CONTINUE);
   }
   /**
@@ -567,8 +570,10 @@ public class GXml.TDocument : GXml.TNode, GXml.Document
         var c = tr.move_to_attribute_no (i);
 #if DEBUG
         GLib.message ("Current Attribute: "+i.to_string ());
-        if (c != 1) GLib.message ("Fail to move to attribute number: "+i.to_string ());
 #endif
+        if (c != 1) {
+          throw new DocumentError.INVALID_DOCUMENT_ERROR (_("Parsing ERROR: Fail to move to attribute 
number: %i").printf (i));
+        }
         if (tr.is_namespace_decl () == 1) {
 #if DEBUG
           GLib.message ("Is Namespace Declaration...");
diff --git a/gxml/libxml-DomException.vala b/gxml/libxml-DomException.vala
index 3ac99bc..1b70a2a 100644
--- a/gxml/libxml-DomException.vala
+++ b/gxml/libxml-DomException.vala
@@ -34,7 +34,7 @@ namespace GXml {
         * @param exception rised
         * @param message message to log
         */
-       [Deprecated (since="0.8.1", replacement="exeption")]
+       [Version (deprecated=true, deprecated_since="0.8.1", replacement="exeption")]
        public static void warning (GXml.DomException ex, string message) {
                GXml.exception (ex, message);
        }
diff --git a/vapi/xlibxml-1.0.vapi b/vapi/xlibxml-1.0.vapi
index 66c44e9..60700c1 100644
--- a/vapi/xlibxml-1.0.vapi
+++ b/vapi/xlibxml-1.0.vapi
@@ -31,7 +31,7 @@ namespace Xmlx {
   [CCode (cname = "gxml_validate_name", cheader_filename = "gxml//xlibxml.h")]
   public static int validate_name (string name, int space);
   [CCode (cname = "gxml_parser_context_get_last_error", cheader_filename = "gxml/xlibxml.h")]
-  [Deprecated (replacement = "context_get_last_error", since = "0.8.1")]
+  [Version (deprecated=true, replacement = "context_get_last_error", deprecated_since = "0.8.1")]
   public static Xml.Error* parser_context_get_last_error (Xml.ParserCtxt ctx);
   [CCode (cname = "gxml_context_get_last_error", cheader_filename = "gxml/xlibxml.h")]
   public static Xml.Error* context_get_last_error (Xml.ParserCtxt ctx);


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