[gxml] Removed xNode/xDocument related classes



commit 268200bccb4ae74264ab51363d86c0cad01492ba
Author: Daniel Espinosa <esodan gmail com>
Date:   Fri Oct 21 18:22:01 2016 -0500

    Removed xNode/xDocument related classes

 gxml/Document.vala         |    4 +-
 gxml/GXmlDocument.vala     |    2 +-
 gxml/GXmlNode.vala         |   16 ++++++++-
 gxml/Makefile.am           |   29 ----------------
 gxml/libxml-Error.vala     |   13 +-------
 test/EnumerationTest.vala  |   18 +++++-----
 test/GXmlTest.vala         |   78 --------------------------------------------
 test/Makefile.am           |    7 ----
 test/SerializableTest.vala |    4 +-
 9 files changed, 29 insertions(+), 142 deletions(-)
---
diff --git a/gxml/Document.vala b/gxml/Document.vala
index 7fd87ea..96f5bc8 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -123,7 +123,7 @@ public interface GXml.Document : Object, GXml.Node
    */
   public static GXml.Document new_default ()
   {
-   return new xDocument ();
+   return new GDocument ();
   }
   /**
    * Creates a new {@link GXml.Document} from a file path using default implementation class.
@@ -146,7 +146,7 @@ public interface GXml.Document : Object, GXml.Node
   public static GXml.Document new_default_for_file (GLib.File f)
    throws GLib.Error
   {
-    var d = new xDocument.from_path (f.get_path ());
+    var d = new GDocument.from_path (f.get_path ());
     if (!f.query_exists ())
       throw new DocumentError.INVALID_FILE (_("Invalid file"));
     d.file = f;
diff --git a/gxml/GXmlDocument.vala b/gxml/GXmlDocument.vala
index 85814a3..64d8d83 100644
--- a/gxml/GXmlDocument.vala
+++ b/gxml/GXmlDocument.vala
@@ -188,7 +188,7 @@ public class GXml.GDocument : GXml.GNode,
     return TDocument.tw_save_as (this, f, cancellable);
   }
   // DomDocument implementation
-  protected Implementation _implementation = new Implementation ();
+  protected GImplementation _implementation = new GImplementation ();
   protected string _url = "about:blank";
   protected string _origin = "";
   protected string _compat_mode = "";
diff --git a/gxml/GXmlNode.vala b/gxml/GXmlNode.vala
index 2772f8f..07f7aeb 100644
--- a/gxml/GXmlNode.vala
+++ b/gxml/GXmlNode.vala
@@ -22,6 +22,11 @@
 
 using Gee;
 
+public errordomain GXml.Error {
+               NOT_SUPPORTED, /* TODO: GET RID OF THIS */
+               PARSER, WRITER;
+       }
+
 /**
  * Base interface providing basic functionalities to all GXml interfaces.
  */
@@ -33,6 +38,13 @@ public abstract class GXml.GNode : Object,
   protected GXml.GDocument _doc;
   protected Xml.Node *_node;
 
+  internal static string libxml2_error_to_string (Xml.Error *e) {
+    return _("%s:%s:%d: %s:%d: %s").printf (
+            e->level.to_string ().replace ("XML_ERR_",""),
+            e->domain.to_string ().replace ("XML_FROM_",""),
+            e->code, e->file == null ? "<io>" : e->file, e->line, e->message);
+  }
+
   construct {
     Init.init ();
   }
@@ -267,13 +279,13 @@ public abstract class GXml.GNode : Object,
   public string? lookup_prefix (string? nspace) {
     if (_node == null) return null;
     if (parent == null) return null;
-    if (this is GXml.DocumentType || this is GXml.DocumentFragment) return null;
+    if (this is GXml.DocumentType || this is GXml.DomDocumentFragment) return null;
     var ns = _node->doc->search_ns_by_href (_node, nspace);
     if (ns == null) return null;
     return ns->prefix;
   }
   public string? lookup_namespace_uri (string? prefix) {
-    if (this is GXml.DocumentType || this is GXml.DocumentFragment) return null;
+    if (this is GXml.DocumentType || this is GXml.DomDocumentFragment) return null;
     var ns = _node->doc->search_ns (_node, prefix);
     if (ns == null) return null;
     return ns->href;
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index 6b65206..de9c9cf 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -27,35 +27,6 @@ sources = \
        ProcessingInstruction.vala \
        Text.vala \
        NodeType.vala \
-       libxml-Attr.vala \
-       libxml-AttrChildNodeList.vala \
-       libxml-BackedNode.vala \
-       libxml-ChildNodeList.vala \
-       libxml-CDATASection.vala \
-       libxml-CharacterData.vala \
-       libxml-Comment.vala \
-       libxml-DocumentFragment.vala \
-       libxml-DocumentType.vala \
-       libxml-Document.vala \
-       libxml-DomException.vala \
-       libxml-Element.vala \
-       libxml-Entity.vala \
-       libxml-EntityChildNodeList.vala\
-       libxml-EntityReference.vala \
-       libxml-Error.vala \
-       libxml-Implementation.vala \
-       libxml-LinkedList.vala \
-       libxml-NamedNodeMap.vala \
-       libxml-NamedAttrMap.vala \
-       libxml-NamespaceAttr.vala \
-       libxml-NodeChildNodeList.vala \
-       libxml-NodeList.vala \
-       libxml-Node.vala \
-       libxml-Notation.vala \
-       libxml-ProcessingInstruction.vala \
-       libxml-TagNameNodeList.vala \
-       libxml-NamespaceAttrNodeList.vala \
-       libxml-Text.vala \
        Serializable.vala \
        SerializableProperty.vala \
        SerializableBool.vala \
diff --git a/gxml/libxml-Error.vala b/gxml/libxml-Error.vala
index 783fda1..fcbf08d 100644
--- a/gxml/libxml-Error.vala
+++ b/gxml/libxml-Error.vala
@@ -3,16 +3,5 @@ namespace GXml {
         * libmxl2 bindings for Errors on parse and write.
         */
        [Version (deprecated=true, deprecated_since="0.12", replacement="use GLib.Error exceptions")]
-       public errordomain Error {
-               NOT_SUPPORTED, /* TODO: GET RID OF THIS */
-               PARSER, WRITER;
-       }
 
-       // TODO: replace usage of this with GXml.get_last_error_msg
-       internal static string libxml2_error_to_string (Xml.Error *e) {
-               return _("%s:%s:%d: %s:%d: %s").printf (
-                       e->level.to_string ().replace ("XML_ERR_",""),
-                       e->domain.to_string ().replace ("XML_FROM_",""),
-                       e->code, e->file == null ? "<io>" : e->file, e->line, e->message);
-       }
-}
+
diff --git a/test/EnumerationTest.vala b/test/EnumerationTest.vala
index 93b6bc5..1658e33 100644
--- a/test/EnumerationTest.vala
+++ b/test/EnumerationTest.vala
@@ -113,7 +113,7 @@ class SerializableEnumerationTest : GXmlTest
                    });
     Test.add_func ("/gxml/serializable/enumeration-serialize",
                    () => {
-                     var doc = new xDocument ();
+                     var doc = new GDocument ();
                      var options = new Options ();
                      options.options = OptionsEnum.NORMAL_OPERATION;
                      try {
@@ -142,46 +142,46 @@ class SerializableEnumerationTest : GXmlTest
                    () => {
                      var options = new Options ();
                      try {
-                       var doc = new xDocument.from_string ("""<?xml version="1.0"?>
+                       var doc = new GDocument.from_string ("""<?xml version="1.0"?>
                        <options options="NormalOperation"/>""");
                        options.deserialize (doc);
                        if (options.options != OptionsEnum.NORMAL_OPERATION)  {
                          stdout.printf (@"ERROR: Bad value to options property: $(options.options)\n$(doc)");
                          assert_not_reached ();
                        }
-                       var doc2 = new xDocument.from_string ("""<?xml version="1.0"?>
+                       var doc2 = new GDocument.from_string ("""<?xml version="1.0"?>
                        <options options="normal-operation"/>""");
                        options.deserialize (doc2);
                        if (options.options != OptionsEnum.NORMAL_OPERATION)  {
                          stdout.printf (@"ERROR: Bad value to options property: 
$(options.options)\n$(doc2)");
                          assert_not_reached ();
                        }
-                       var doc3 = new xDocument.from_string ("""<?xml version="1.0"?>
+                       var doc3 = new GDocument.from_string ("""<?xml version="1.0"?>
                        <options options="selectbefore"/>""");
                        options.deserialize (doc3);
                        if (options.options != OptionsEnum.SelectBefore)  {
                          stdout.printf (@"ERROR: Bad value to options property: 
$(options.options)\n$(doc3)");
                          assert_not_reached ();
                        }
-                       var doc4 = new xDocument.from_string ("""<?xml version="1.0"?>
+                       var doc4 = new GDocument.from_string ("""<?xml version="1.0"?>
                        <options options="OPTIONS_ENUM_SelectBefore"/>""");
                        options.deserialize (doc4);
                        if (options.options != OptionsEnum.SelectBefore)  {
                          stdout.printf (@"ERROR: Bad value to options property: 
$(options.options)\n$(doc4)");
                          assert_not_reached ();
                        }
-                       var doc5 = new xDocument.from_string ("""<?xml version="1.0"?>
+                       var doc5 = new GDocument.from_string ("""<?xml version="1.0"?>
                        <options options="SelectBefore"/>""");
                        options.deserialize (doc5);
                        if (options.options != OptionsEnum.SelectBefore)  {
                          stdout.printf (@"ERROR: Bad value to options property: 
$(options.options)\n$(doc5)");
                          assert_not_reached ();
                        }
-                       var doc6 = new xDocument.from_string ("""<?xml version="1.0"?>
+                       var doc6 = new GDocument.from_string ("""<?xml version="1.0"?>
                        <options options="SELECTBEFORE"/>""");
                        options.deserialize (doc6);
                        assert (options.options == OptionsEnum.SelectBefore);
-                       var doc7 = new xDocument.from_string ("""<?xml version="1.0"?>
+                       var doc7 = new GDocument.from_string ("""<?xml version="1.0"?>
                        <options options="NORMAL_OPERATION"/>""");
                        options.deserialize (doc7);
                        if (options.options != OptionsEnum.SelectBefore)  {
@@ -189,7 +189,7 @@ class SerializableEnumerationTest : GXmlTest
                          assert_not_reached ();
                        }
                        var op2 = new Options ();
-                       var doc8 = new xDocument.from_string ("""<?xml version="1.0"?>
+                       var doc8 = new GDocument.from_string ("""<?xml version="1.0"?>
                        <options options="INVALID"/>""");
                        op2.deserialize (doc8);
                        if (op2.options != OptionsEnum.SelectBefore)  {
diff --git a/test/GXmlTest.vala b/test/GXmlTest.vala
index e58bc24..6f29a10 100644
--- a/test/GXmlTest.vala
+++ b/test/GXmlTest.vala
@@ -24,39 +24,13 @@
 using GXml;
 
 class GXmlTest {
-       internal static void GXmlLogFunc (string? log_domain, LogLevelFlags log_levels, string message) {
-               // Hush, we don't want to actually show errors; we'll be testing for those
-       }
-
-       internal static void test_error (GXml.DomException expected) {
-               if (expected != GXml.last_error) {
-                       stderr.printf ("Expected last error [%s] but found [%s]", expected.to_string (), 
GXml.last_error.to_string ());
-                       Test.message ("Expected last error [%s] but found [%s]", expected.to_string (), 
GXml.last_error.to_string ());
-                       Test.fail ();
-               }
-
-               // clear it
-               GXml.last_error = DomException.NONE;
-       }
-
        public static int main (string[] args) {
 
 
                // Sets 29 as fatal flags, 16 + 8 + 4 + 1; bits 0,2,3,4, recursion,error,critical,warning; 
we'll want to undo that warning one so we can catch it
                Test.init (ref args);
 
-               // silence warnings we'll be testing for
-               GLib.Log.set_handler ("gxml", GLib.LogLevelFlags.LEVEL_WARNING, GXmlTest.GXmlLogFunc);
-               GLib.Log.set_always_fatal (GLib.LogLevelFlags.FLAG_RECURSION | GLib.LogLevelFlags.LEVEL_ERROR 
| GLib.LogLevelFlags.LEVEL_CRITICAL);
-
-               DocumentTest.add_tests ();
-               NodeTest.add_tests ();
-               ElementTest.add_tests ();
-               AttrTest.add_tests ();
-               NamespaceTest.add_tests ();
                NodeListTest.add_tests ();
-               TextTest.add_tests ();
-               CharacterDataTest.add_tests ();
                ValaLibxml2Test.add_tests ();
                SerializableTest.add_tests ();
                SerializableObjectModelTest.add_tests ();
@@ -92,56 +66,4 @@ class GXmlTest {
 
                return 0;
        }
-
-       internal static xDocument get_doc (string? path = null) {
-               xDocument doc = null;
-               try {
-                       doc = new xDocument.from_path (path != null ? path :
-                                                     GXmlTest.get_test_dir () + "/test.xml");
-               } catch (GXml.Error e) {
-                       GLib.warning (e.message);
-                       assert_not_reached ();
-               }
-               return doc;
-       }
-
-       internal static xDocument get_doc_with_ns () {
-               return get_doc (get_test_dir () + "/test_with_ns.xml");
-       }
-
-       internal static string get_test_dir () {
-               if (TEST_DIR == null || TEST_DIR == "") {
-                       return ".";
-               } else {
-                       return TEST_DIR;
-               }
-       }
-
-       // internal static Attr get_attr_new_doc (string name, string value) {
-       //      return get_attr (name, value, get_doc ());
-       // }
-
-       internal static xAttr get_attr (string name, string value, xDocument doc) {
-               xAttr attr = doc.create_attribute (name);
-               attr.value = value;
-               return attr;
-       }
-
-       internal static xElement get_elem_new_doc (string name, out xDocument doc) {
-               return get_elem (name, doc = get_doc ());
-       }
-
-       internal static xElement get_elem (string name, xDocument doc) {
-               xElement elem = (xElement) doc.create_element (name);
-               return elem;
-       }
-
-       internal static xText get_text_new_doc (string data, out xDocument doc) {
-               return get_text (data, doc = get_doc ());
-       }
-
-       internal static xText get_text (string data, xDocument doc) {
-               xText txt = doc.create_text_node (data);
-               return txt;
-       }
 }
diff --git a/test/Makefile.am b/test/Makefile.am
index 8187efa..3f0df1e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -26,15 +26,8 @@ TEST_PROGS += gxml_test
 
 sources = \
        tests-config.vala \
-       AttrTest.vala \
-       CharacterDataTest.vala \
-       DocumentTest.vala \
-       NodeTest.vala \
-       ElementTest.vala \
        GXmlTest.vala \
-       NamespaceTest.vala \
        NodeListTest.vala \
-       TextTest.vala \
        ValaLibxml2Test.vala \
        EnumerationTest.vala \
        SerializableTest.vala \
diff --git a/test/SerializableTest.vala b/test/SerializableTest.vala
index 5881e92..9a9ea55 100644
--- a/test/SerializableTest.vala
+++ b/test/SerializableTest.vala
@@ -84,12 +84,12 @@ public class SerializableCapsicum : GXml.SerializableObjectModel {
           Can't have static methods in an interface :(, right? */
        public void deserialize_unknown_property_type (GXml.Node elem, ParamSpec prop)
        {
-               xNode element = (xNode) elem;
+               GXml.Node element = (GXml.Node) elem;
                GLib.Value outvalue = GLib.Value (typeof (int));
                switch (prop.name) {
                case "ratings":
                        this.ratings = new GLib.List<int> ();
-                       foreach (GXml.xNode rating in element.child_nodes) {
+                       foreach (GXml.Node rating in element.children_nodes) {
                                int64.try_parse (((GXml.GElement)rating).content, out outvalue);
                                this.ratings.append ((int)outvalue.get_int64 ());
                        }


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