[vala/wip/abi: 8/9] ccode: Allow adding of comments to a CCodeStruct
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/abi: 8/9] ccode: Allow adding of comments to a CCodeStruct
- Date: Fri, 19 Jan 2018 07:18:16 +0000 (UTC)
commit 432c53455fb5e642b21713a6418fce6dff366b87
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Jan 17 12:55:59 2018 +0100
ccode: Allow adding of comments to a CCodeStruct
https://bugzilla.gnome.org/show_bug.cgi?id=789069
ccode/valaccodestruct.vala | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/ccode/valaccodestruct.vala b/ccode/valaccodestruct.vala
index fce7fcb..44473aa 100644
--- a/ccode/valaccodestruct.vala
+++ b/ccode/valaccodestruct.vala
@@ -31,21 +31,31 @@ public class Vala.CCodeStruct : CCodeNode {
*/
public string name { get; set; }
- public bool is_empty { get { return declarations.size == 0; } }
+ public bool is_empty { get { return nodes.size == 0; } }
- private List<CCodeDeclaration> declarations = new ArrayList<CCodeDeclaration> ();
+ private List<CCodeNode> nodes = new ArrayList<CCodeNode> ();
public CCodeStruct (string name) {
this.name = name;
}
/**
+ * Adds the specified comment inside this struct.
+ *
+ * @param comment a string comment
+ */
+ public void add_comment (string comment) {
+ var c = new CCodeComment (comment);
+ nodes.add (c);
+ }
+
+ /**
* Adds the specified declaration as member to this struct.
*
* @param decl a variable declaration
*/
public void add_declaration (CCodeDeclaration decl) {
- declarations.add (decl);
+ nodes.add (decl);
}
/**
@@ -65,8 +75,12 @@ public class Vala.CCodeStruct : CCodeNode {
writer.write_string ("struct ");
writer.write_string (name);
writer.write_begin_block ();
- foreach (CCodeDeclaration decl in declarations) {
- decl.write_declaration (writer);
+ foreach (CCodeNode node in nodes) {
+ if (node is CCodeDeclaration) {
+ ((CCodeDeclaration) node).write_declaration (writer);
+ } else {
+ node.write (writer);
+ }
}
writer.write_end_block ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]