[gxml] Fixed GCharacter's implementation of DomCharacter.substring_data()
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Fixed GCharacter's implementation of DomCharacter.substring_data()
- Date: Thu, 21 Jul 2016 23:44:50 +0000 (UTC)
commit 8ec208f0b7a54ec3920eca500de87bd483f1f373
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Jul 21 18:43:50 2016 -0500
Fixed GCharacter's implementation of DomCharacter.substring_data()
gxml/DomCharacter.vala | 6 ++--
gxml/DomCollections.vala | 15 +++++++++++
gxml/DomDocument.vala | 22 ++++++++++++++++
test/DomGDocumentTest.vala | 58 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 98 insertions(+), 3 deletions(-)
---
diff --git a/gxml/DomCharacter.vala b/gxml/DomCharacter.vala
index b530199..284d56a 100644
--- a/gxml/DomCharacter.vala
+++ b/gxml/DomCharacter.vala
@@ -39,9 +39,9 @@ public interface GXml.DomCharacterData : GLib.Object,
public virtual string substring_data (ulong offset, ulong count) throws GLib.Error {
if (((int)offset) > this.data.length)
throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for substring"));
- int c = (int) count;
- if (c > this.data.length) c = this.data.length;
- return this.data[(int)offset:(int)c];
+ int end = (int) (offset + count);
+ if (!(end < data.length)) end = data.length;
+ return data.slice ((int) offset, end);
}
public virtual void append_data (string data) {
this.data += data;
diff --git a/gxml/DomCollections.vala b/gxml/DomCollections.vala
index 5448589..770c203 100644
--- a/gxml/DomCollections.vala
+++ b/gxml/DomCollections.vala
@@ -65,6 +65,10 @@ public interface GXml.DomHTMLCollection : GLib.Object, Gee.BidirList<GXml.DomEle
}
}
+
+/**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public interface GXml.DomNodeIterator {
public abstract DomNode root { get; }
public abstract DomNode reference_node { get; }
@@ -78,6 +82,9 @@ public interface GXml.DomNodeIterator {
public abstract void detach();
}
+/**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public class GXml.DomNodeFilter : Object {
// Constants for acceptNode()
public const ushort FILTER_ACCEPT = 1;
@@ -102,6 +109,10 @@ public class GXml.DomNodeFilter : Object {
public delegate ushort AcceptNode(Node node); // FIXME: Should be a User defined method
}
+
+/**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public interface GXml.DomTreeWalker : Object {
public abstract DomNode root { get; }
public abstract ulong what_to_show { get; }
@@ -146,6 +157,10 @@ public interface GXml.DomTokenList : GLib.Object, Gee.BidirList<string> {
public abstract string to_string ();
}
+
+/**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public interface GXml.DomSettableTokenList : GXml.DomTokenList {
public abstract string @value { owned get; set; }
}
diff --git a/gxml/DomDocument.vala b/gxml/DomDocument.vala
index ed79fff..fe3ff24 100644
--- a/gxml/DomDocument.vala
+++ b/gxml/DomDocument.vala
@@ -50,17 +50,33 @@ public interface GXml.DomDocument : GLib.Object,
public abstract DomNode import_node (DomNode node, bool deep = false) throws GLib.Error;
public abstract DomNode adopt_node (DomNode node) throws GLib.Error;
+ /**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public abstract DomEvent create_event (string interface) throws GLib.Error;
+ /**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public abstract DomRange create_range();
// NodeFilter.SHOW_ALL = 0xFFFFFFFF
+ /**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public abstract DomNodeIterator create_node_iterator (DomNode root, ulong whatToShow = (ulong) 0xFFFFFFFF,
DomNodeFilter? filter = null);
+
+ /**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public abstract DomTreeWalker create_tree_walker (DomNode root, ulong what_to_show = (ulong) 0xFFFFFFFF,
DomNodeFilter? filter = null);
}
public interface GXml.DomXMLDocument : GLib.Object, GXml.DomDocument {}
+/**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public interface GXml.DomImplementation : GLib.Object {
public abstract DomDocumentType create_document_type (string qualified_name, string public_id, string
system_id) throws GLib.Error;
public abstract DomXMLDocument create_document (string? nspace, string? qualified_name, DocumentType?
doctype = null) throws GLib.Error;
@@ -69,12 +85,18 @@ public interface GXml.DomImplementation : GLib.Object {
public virtual bool has_feature() { return true; } // useless; always returns true
}
+/**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public interface GXml.DomDocumentFragment : GLib.Object,
GXml.DomNode,
GXml.DomParentNode,
GXml.DomNonElementParentNode
{}
+/**
+ * No implemented jet. This can lead to API changes in future versions.
+ */
public interface GXml.DomDocumentType : GLib.Object, GXml.DomNode, GXml.DomChildNode {
public abstract string name { get; }
public abstract string public_id { get; }
diff --git a/test/DomGDocumentTest.vala b/test/DomGDocumentTest.vala
index 4deb2f1..da129cc 100644
--- a/test/DomGDocumentTest.vala
+++ b/test/DomGDocumentTest.vala
@@ -445,5 +445,63 @@ static const string XMLDOC ="<?xml version=\"1.0\"?>
assert_not_reached ();
}
});
+ Test.add_func ("/gxml/dom/document/event", () => {
+ try {
+ GLib.message ("No implemented...Skiping");
+ //TODO: implement
+ } catch (GLib.Error e) {
+ GLib.message ("Error: "+ e.message);
+ assert_not_reached ();
+ }
+ });
+ Test.add_func ("/gxml/dom/document/range", () => {
+ try {
+ GLib.message ("No implemented...Skiping");
+ //TODO: implement
+ } catch (GLib.Error e) {
+ GLib.message ("Error: "+ e.message);
+ assert_not_reached ();
+ }
+ });
+ Test.add_func ("/gxml/dom/document/iterator", () => {
+ try {
+ GLib.message ("No implemented...Skiping");
+ //TODO: implement
+ } catch (GLib.Error e) {
+ GLib.message ("Error: "+ e.message);
+ assert_not_reached ();
+ }
+ });
+ Test.add_func ("/gxml/dom/document/walker", () => {
+ try {
+ GLib.message ("No implemented...Skiping");
+ //TODO: implement
+ } catch (GLib.Error e) {
+ GLib.message ("Error: "+ e.message);
+ assert_not_reached ();
+ }
+ });
+ Test.add_func ("/gxml/dom/character", () => {
+ try {
+ var d = new GDocument () as DomDocument;
+ var t = d.create_text_node ("TEXT") as DomCharacterData;
+ assert (t.data == "TEXT");
+ assert (t.length == "TEXT".length);
+ assert (t.substring_data (0,2) == "TE");
+ assert (t.substring_data (0,3) == "TEX");
+ assert (t.substring_data (1,3) == "EXT");
+ assert (t.substring_data (1,4) == "EXT");
+ assert (t.substring_data (1,5) == "EXT");
+ assert (t.substring_data (2,0) == "");
+ try {
+ t.substring_data (5,1);
+ assert_not_reached ();
+ }
+ catch {}
+ } catch (GLib.Error e) {
+ GLib.message ("Error: "+ e.message);
+ assert_not_reached ();
+ }
+ });
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]