[gxml] Replace secure cast to avoid null results
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Replace secure cast to avoid null results
- Date: Thu, 10 Oct 2019 17:46:12 +0000 (UTC)
commit a72870986bb816435bfa9ef8cc592eec188e96b1
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Oct 10 12:45:36 2019 -0500
Replace secure cast to avoid null results
examples/vala/example.vala | 2 +-
gxml/Document.vala | 4 ++--
gxml/Element.vala | 2 +-
gxml/Object.vala | 2 +-
gxml/XDocument.vala | 4 ++--
gxml/XListChildren.vala | 2 +-
gxml/XNode.vala | 2 +-
gxml/XParser.vala | 4 ++--
test/ElementTest.vala | 2 +-
9 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/examples/vala/example.vala b/examples/vala/example.vala
index 57a2232..cc62782 100755
--- a/examples/vala/example.vala
+++ b/examples/vala/example.vala
@@ -56,7 +56,7 @@ void create_a_document_from_a_path (string uri) throws GLib.Error {
GLib.File f = GLib.File.new_for_uri (uri+"/bookshelf2.xml");
doc = new GXml.Document.from_path (f.get_path ());
- stdout.printf ("create_a_document_from_a_path:\n%s\n", (doc as GXml.Document).write_string ());
+ stdout.printf ("create_a_document_from_a_path:\n%s\n", ((GXml.Document) doc).write_string ());
}
void saving_a_document_to_a_path (string uri) throws GLib.Error {
diff --git a/gxml/Document.vala b/gxml/Document.vala
index fc6b055..8bf1186 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -249,11 +249,11 @@ public class GXml.Document : GXml.Node,
}
}
if (node is DomText)
- dst = this.create_text_node ((node as DomText).data);
+ dst = this.create_text_node (((DomText) node).data);
if (node is DomComment)
dst = ((DomDocument) this).create_comment (((DomComment) node).data);
if (node is DomProcessingInstruction)
- dst = this.create_processing_instruction (((DomProcessingInstruction) node).target, (node as
DomProcessingInstruction).data);
+ dst = this.create_processing_instruction (((DomProcessingInstruction) node).target,
(((DomProcessingInstruction) node).data));
if (dst != null) {
document_element.append_child (dst as DomNode);
return dst;
diff --git a/gxml/Element.vala b/gxml/Element.vala
index ae74165..4ca3655 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -735,7 +735,7 @@ public class GXml.Element : GXml.Node,
cs += class_names;
foreach (GXml.DomNode n in child_nodes) {
if (!(n is DomElement)) continue;
- string cls = (n as DomElement).get_attribute ("class");
+ string cls = ((DomElement) n).get_attribute ("class");
if (cls != null) {
string[] ncls = {};
if (" " in cls)
diff --git a/gxml/Object.vala b/gxml/Object.vala
index f130bf9..046f578 100644
--- a/gxml/Object.vala
+++ b/gxml/Object.vala
@@ -344,7 +344,7 @@ public interface GXml.Object : GLib.Object,
if (prop != null) {
if (prop.value_type.is_a (typeof (Object))) {
Value v = Value (typeof (Object));
- (this as Object).set_property (name, v);
+ ((Object) this).set_property (name, v);
return true;
}
if (prop.value_type.is_a (typeof (string))) {
diff --git a/gxml/XDocument.vala b/gxml/XDocument.vala
index 6c61baf..a7d193a 100644
--- a/gxml/XDocument.vala
+++ b/gxml/XDocument.vala
@@ -262,11 +262,11 @@ public class GXml.XDocument : GXml.XNode,
}
}
if (node is DomText)
- dst = this.create_text_node ((node as DomText).data);
+ dst = this.create_text_node (((DomText) node).data);
if (node is DomComment)
dst = ((DomDocument) this).create_comment (((DomComment) node).data);
if (node is DomProcessingInstruction)
- dst = this.create_processing_instruction (((DomProcessingInstruction) node).target, (node as
DomProcessingInstruction).data);
+ dst = this.create_processing_instruction (((DomProcessingInstruction) node).target,
((DomProcessingInstruction) node).data);
if (dst != null) {
document_element.append_child (dst as DomNode);
return dst;
diff --git a/gxml/XListChildren.vala b/gxml/XListChildren.vala
index 01c248a..849664f 100644
--- a/gxml/XListChildren.vala
+++ b/gxml/XListChildren.vala
@@ -81,7 +81,7 @@ public class GXml.XListChildren : AbstractBidirList<GXml.DomNode>,
if (index > size || index < 0) return nullnode;
var n = @get (index);
if (n == null) return nullnode;
- var np = (n as GXml.XNode).get_internal_node ();
+ var np = ((GXml.XNode) n).get_internal_node ();
np->unlink ();
delete np;
return nullnode;
diff --git a/gxml/XNode.vala b/gxml/XNode.vala
index 3b8546f..4f1cae1 100644
--- a/gxml/XNode.vala
+++ b/gxml/XNode.vala
@@ -247,7 +247,7 @@ public abstract class GXml.XNode : GLib.Object,
if (this.children_nodes.size != node.child_nodes.size) return false;
foreach (GXml.DomNode a in attrs.values) {
if (!((GXml.XNode?) node).attrs.has_key (a.node_name)) return false;
- if ((a as XNode).value != ((XNode) ((GXml.XNode) node).attrs.get (a.node_name)).value) return false;
+ if (((XNode) a).value != ((XNode) ((GXml.XNode) node).attrs.get (a.node_name)).value) return false;
}
for (int i=0; i < children_nodes.size; i++) {
if (!((GXml.DomNode) children_nodes[i]).is_equal_node (((GXml.DomNode?) node).child_nodes[i])) return
false;
diff --git a/gxml/XParser.vala b/gxml/XParser.vala
index 09d480b..a52ceaf 100644
--- a/gxml/XParser.vala
+++ b/gxml/XParser.vala
@@ -500,7 +500,7 @@ public class GXml.XParser : GLib.Object, GXml.Parser {
tw.start_element (element_node.local_name);
// GXml.Object serialization
- var lp = (node as GXml.Object).get_properties_list ();
+ var lp = ((GXml.Object) node).get_properties_list ();
foreach (ParamSpec pspec in lp) {
string attname = pspec.get_nick ().replace ("::","");
string val = null;
@@ -511,7 +511,7 @@ public class GXml.XParser : GLib.Object, GXml.Parser {
if (gp == null) continue;
val = gp.value;
} else {
- val = (node as GXml.Object).get_property_string (pspec);
+ val = ((GXml.Object) node).get_property_string (pspec);
}
if (val == null) continue;
size += tw.write_attribute (attname, val);
diff --git a/test/ElementTest.vala b/test/ElementTest.vala
index 81feba8..de2699a 100644
--- a/test/ElementTest.vala
+++ b/test/ElementTest.vala
@@ -267,7 +267,7 @@ class GXml.ElementTest : GXmlTest {
GLib.message ("Attribute: "+k+"="+v);
}
#endif
- message ((node as GXml.Element).write_string ());
+ message (((GXml.Element) node).write_string ());
assert (((DomElement) node).attributes.length == 2);
assert (((DomElement) node).get_attribute ("xmlns:magic") ==
"http://hogwarts.co.uk/magic");
assert (((DomElement) node).get_attribute_ns
("http://www.w3.org/2000/xmlns/", "magic") == "http://hogwarts.co.uk/magic");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]