[gxml] Adding documentation examples
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Adding documentation examples
- Date: Thu, 2 Feb 2017 23:42:57 +0000 (UTC)
commit 52da13cefcddcc11a4ef867d2d13429742a7a1f5
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Feb 2 17:42:24 2017 -0600
Adding documentation examples
gxml/GomNode.vala | 4 ++-
gxml/GomObject.vala | 58 +++++++++++++++++++++++++++++++-------------------
2 files changed, 39 insertions(+), 23 deletions(-)
---
diff --git a/gxml/GomNode.vala b/gxml/GomNode.vala
index 6808491..0570c57 100644
--- a/gxml/GomNode.vala
+++ b/gxml/GomNode.vala
@@ -237,7 +237,9 @@ public class GXml.GomNode : Object,
if (ns == nspace) return true;
return false;
}
-
+ /**
+ * Sets node's parent and checks for namespace conflics.
+ */
internal void set_parent (DomNode node) throws GLib.Error {
if (this is DomElement) {
var e = (this as DomElement);
diff --git a/gxml/GomObject.vala b/gxml/GomObject.vala
index 657fc50..aeea6ba 100644
--- a/gxml/GomObject.vala
+++ b/gxml/GomObject.vala
@@ -332,29 +332,43 @@ public interface GXml.GomObject : GLib.Object,
*
* If Object's property has been set, this method overwrite it.
*
+ * {{{
+ * class NodeA : GomObject {
+ * construct { try { initialize ("NodeA"); } catch { warning ("Can't initialize); }
+ * }
+ * class NodeB : GomObject {
+ * public NodeA node { get; set; }
+ * }
+ *
+ * var nb = new NodeB ();
+ * nb.create_instance_property ("node");
+ * assert (nb.node != null);
+ * }}}
+ *
* Returns: true if property has been set and initialized, false otherwise.
*/
- public bool create_instance_property (string name) {
- var prop = find_object_property_name (name);
- if (prop == null) return false;
- Value v = Value (prop.value_type);
- Object obj;
- if (prop.value_type.is_a (typeof (GomCollection))) {
- obj = Object.new (prop.value_type, "element", this);
- v.set_object (obj);
- set_property (prop.name, v);
- return true;
- }
- if (prop.value_type.is_a (typeof (GomElement))) {
- obj = Object.new (prop.value_type,"owner_document", this.owner_document);
- try { this.append_child (obj as GomElement); }
- catch (GLib.Error e) {
- warning (_("Error while atemting to instantiate property object: %s").printf (e.message));
- }
- v.set_object (obj);
- set_property (prop.name, v);
- return true;
+ public bool create_instance_property (string name) {
+ var prop = find_object_property_name (name);
+ if (prop == null) return false;
+ Value v = Value (prop.value_type);
+ Object obj;
+ if (prop.value_type.is_a (typeof (GomCollection))) {
+ obj = Object.new (prop.value_type, "element", this);
+ v.set_object (obj);
+ set_property (prop.name, v);
+ return true;
+ }
+ if (prop.value_type.is_a (typeof (GomElement))) {
+ obj = Object.new (prop.value_type,"owner_document", this.owner_document);
+ try { this.append_child (obj as GomElement); }
+ catch (GLib.Error e) {
+ warning (_("Error while atemting to instantiate property object: %s").printf (e.message));
+ return false;
}
- return false;
- }
+ v.set_object (obj);
+ set_property (prop.name, v);
+ return true;
+ }
+ return false;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]