[gxml] Moving delayed parsing to GomElement



commit 2e40f00bce11bf4f0c954bd5c1c821f58e4bc245
Author: Daniel Espinosa <esodan gmail com>
Date:   Thu May 11 11:12:28 2017 -0500

    Moving delayed parsing to GomElement
    
    In order to avoid API breaks, methods and properties
    for delayed parsing has been moved to GomElement from
    GomObject

 gxml/GomObject.vala      |   18 ------------------
 gxml/XParser.vala        |   14 ++++++++------
 test/GomElementTest.vala |    2 +-
 3 files changed, 9 insertions(+), 25 deletions(-)
---
diff --git a/gxml/GomObject.vala b/gxml/GomObject.vala
index f5f3088..7a0736e 100644
--- a/gxml/GomObject.vala
+++ b/gxml/GomObject.vala
@@ -35,24 +35,6 @@ public interface GXml.GomObject : GLib.Object,
                                   DomNode,
                                   DomElement {
   /**
-   * Controls if children should be parsed or delayed
-   */
-  public abstract bool parse_children { get; set; default = true; }
-  /**
-   * Holds unparsed text for this {@link GomElement}.
-   *
-   * If {@link parse_children} is true this will hold a string with all childrens
-   * for this {@link GomElement}. It is set to null if {@link parse_children} is false
-   * and {@link parse_children} is called.
-   */
-  public abstract string unparsed { get; set; }
-  /**
-   * Reads all children stored in {@link unparsed} string.
-   *
-   * After this method is called, {@link unparsed} is freed and set to null.
-   */
-  public abstract void read_unparsed () throws GLib.Error;
-  /**
    * Returns a list with all properties' nick with "::" prefix. Nick name,
    * with "::" prefix will be used on serialization to an attribute's name.
    */
diff --git a/gxml/XParser.vala b/gxml/XParser.vala
index 6b3dd60..29bc6ab 100644
--- a/gxml/XParser.vala
+++ b/gxml/XParser.vala
@@ -170,12 +170,14 @@ public class GXml.XParser : Object, GXml.Parser {
     if (current_is_element () && (node is DomDocument))
       read_child_element (node);
     else {
-      if ((node as GomObject).parse_children)
-        read_child_nodes (node);
-      else {
-        (node as GomObject).unparsed = read_unparsed ();
-        //warning ("Unparsed text: "+(node as GomObject).unparsed);
-        move_next_node ();
+      if (node is GomElement) {
+        if ((node as GomElement).parse_children)
+          read_child_nodes (node);
+        else {
+          (node as GomElement).unparsed = read_unparsed ();
+          //warning ("Unparsed text: "+(node as GomObject).unparsed);
+          move_next_node ();
+        }
       }
     }
   }
diff --git a/test/GomElementTest.vala b/test/GomElementTest.vala
index 8a40607..23e1f27 100644
--- a/test/GomElementTest.vala
+++ b/test/GomElementTest.vala
@@ -212,7 +212,7 @@ class GomElementTest : GXmlTest  {
                                assert (n.unparsed == "<child p1=\"Value1\" p2=\"Value2\"><child2/></child>");
                                assert (!n.has_child_nodes ());
                                assert (n.child_nodes.length == 0);
-                               (n as GomObject).read_unparsed ();
+                               n.read_unparsed ();
                                assert (n.has_child_nodes ());
                                assert (n.child_nodes.length == 1);
                                assert (n.unparsed == null);


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