[gxml] Remove secure casts and some doc warnings
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Remove secure casts and some doc warnings
- Date: Thu, 10 Oct 2019 18:26:54 +0000 (UTC)
commit f950e09db8437caa5ef282ed866c7abd9aa8f8b7
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Oct 10 13:22:46 2019 -0500
Remove secure casts and some doc warnings
gxml/CssSelectorParser.vala | 10 ++++------
gxml/Element.vala | 2 +-
gxml/Property.vala | 14 +++++++++-----
test/ElementTest.vala | 2 +-
test/SerializationTest.vala | 2 +-
5 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/gxml/CssSelectorParser.vala b/gxml/CssSelectorParser.vala
index 9bd7d27..8b75afb 100644
--- a/gxml/CssSelectorParser.vala
+++ b/gxml/CssSelectorParser.vala
@@ -192,9 +192,8 @@ public class GXml.CssNotSelector : GXml.CssSelector {
}
/**
- * a list of {@link GXml.CssSelector} that shouldn't match
- *
- * @return a {@link Gee.List} of {@link GXml.CssSelector}
+ * a list of {@link GXml.CssSelector} that shouldn't match as a
+ * {@link Gee.List} of {@link GXml.CssSelector}
*/
public Gee.List<GXml.CssSelector> selectors {
get {
@@ -446,9 +445,8 @@ public class GXml.CssSelectorParser : GLib.Object {
this.list = new Gee.ArrayList<GXml.CssSelector>();
}
/**
- * a list of parsed {@link GXml.CssSelector}
- *
- * @return a {@link Gee.List} of {@link GXml.CssSelector}
+ * a list of parsed {@link GXml.CssSelector} as a
+ * {@link Gee.List} of {@link GXml.CssSelector}
*/
public Gee.List<GXml.CssSelector> selectors {
get {
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 4ca3655..71d2d75 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -567,7 +567,7 @@ public class GXml.Element : GXml.Node,
if (nspn != ((GXml.Attr) node).prefix
&& nsn != ((GXml.Attr) node).namespace_uri) {
throw new DomError.NAMESPACE_ERROR
- (_("Trying to add an attribute with an undefined namespace's prefix: %s").printf ((node as
GXml.Attr).prefix));
+ (_("Trying to add an attribute with an undefined namespace's prefix: %s").printf
(((GXml.Attr) node).prefix));
}
nspn = _element.lookup_prefix (((GXml.Attr) node).namespace_uri);
nsn = _element.lookup_namespace_uri (nspn);
diff --git a/gxml/Property.vala b/gxml/Property.vala
index 7bffe36..dcb22a0 100644
--- a/gxml/Property.vala
+++ b/gxml/Property.vala
@@ -483,11 +483,13 @@ public class GXml.Date : GXml.BaseProperty {
* Convenient class to handle {@link Element}'s attributes
* using a {@link GLib.DateTime} as sources of values.
*
- * Timestamp is considered in local time.
+ * Timestamp is considered in UTC time.
*
* Property is represented as a string using a {@link DateTime.format}
* and {@link GLib.DateTime.format} method. If {@link DateTime.format}
* is not set '%FT%T' format is used by default.
+ *
+ * For limitations on text parsing, see at {@link GLib.DateTime.DateTime.from_iso8601}
*/
public class GXml.DateTime : GXml.BaseProperty {
protected GLib.DateTime _value = null;
@@ -501,11 +503,13 @@ public class GXml.DateTime : GXml.BaseProperty {
return _value.format (s);
}
set {
- var tv = TimeVal ();
- if (tv.from_iso8601 (value)) {
- _value = new GLib.DateTime.from_timeval_local (tv);
- } else
+ var tz = new TimeZone.utc ();
+ var dt = new GLib.DateTime.from_iso8601 (value, tz);
+ if (dt != null) {
+ _value = dt.add_days (0) ;
+ } else {
warning (_("Invalid timestamp for property: "+value));
+ }
}
}
/**
diff --git a/test/ElementTest.vala b/test/ElementTest.vala
index de2699a..8a51f3d 100644
--- a/test/ElementTest.vala
+++ b/test/ElementTest.vala
@@ -369,7 +369,7 @@ class GXml.ElementTest : GXmlTest {
assert (elem.lookup_namespace_uri ("xtest") == "http://www.w3c.org/test");
assert (n.lookup_namespace_uri ("xtest") == "http://www.w3c.org/test");
assert (child.lookup_namespace_uri ("xtest") == "http://www.w3c.org/test");
- message ((elem as GXml.Element).write_string ());
+ message (((GXml.Element) elem).write_string ());
child.set_attribute_ns ("http://www.w3c.org/test","xtest:val","Value");
assert (elem.get_attribute_ns ("http://www.w3.org/2000/xmlns/","xtest") ==
"http://www.w3c.org/test");
assert (elem.get_attribute_ns ("http://www.w3.org/2000/xmlns","xtest") ==
"http://www.w3c.org/test");
diff --git a/test/SerializationTest.vala b/test/SerializationTest.vala
index ad11df4..b7c0452 100644
--- a/test/SerializationTest.vala
+++ b/test/SerializationTest.vala
@@ -689,7 +689,7 @@ class SerializationTest : GXmlTest {
assert (t.timestamp != null);
assert (t.timestamp.value != null);
assert (t.timestamp.value == "2017-02-10T14:14:20");
- t.timestamp.value = "2023-3-10T15:23:10.356";
+ t.timestamp.value = "2023-03-10T15:23:10.356";
assert (t.timestamp.value != null);
assert (t.timestamp.value == "2023-03-10T15:23:10");
string s2 = t.to_string ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]