summaryrefslogtreecommitdiff
path: root/ccode
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2010-08-14 13:04:55 +0200
committerJürg Billeter <j@bitron.ch>2010-09-09 16:23:28 +0200
commiteebec1fdd5d5e27f6dcb68c6e76615736e4bffb1 (patch)
tree4f0bb80b0e2aa2eb46de4c3f54bd7ca4dc593839 /ccode
parent548b6d6ef3f5fa84acdcfaf15877008c3fb76040 (diff)
downloadvala-eebec1fdd5d5e27f6dcb68c6e76615736e4bffb1.tar.gz
Add CCodeFile.add_function_declaration and CCodeFunction.is_declaration
Diffstat (limited to 'ccode')
-rw-r--r--ccode/valaccodefile.vala6
-rw-r--r--ccode/valaccodefunction.vala8
2 files changed, 12 insertions, 2 deletions
diff --git a/ccode/valaccodefile.vala b/ccode/valaccodefile.vala
index 2276cc37d..88bba4a0d 100644
--- a/ccode/valaccodefile.vala
+++ b/ccode/valaccodefile.vala
@@ -73,6 +73,12 @@ public class Vala.CCodeFile {
type_member_definition.append (node);
}
+ public void add_function_declaration (CCodeFunction func) {
+ var decl = func.copy ();
+ decl.is_declaration = true;
+ type_member_declaration.append (decl);
+ }
+
public void add_function (CCodeFunction func) {
type_member_definition.append (func);
}
diff --git a/ccode/valaccodefunction.vala b/ccode/valaccodefunction.vala
index d414fb28b..bf7071f8d 100644
--- a/ccode/valaccodefunction.vala
+++ b/ccode/valaccodefunction.vala
@@ -43,16 +43,19 @@ public class Vala.CCodeFunction : CCodeNode {
public string attributes { get; set; }
+ public bool is_declaration { get; set; }
+
/**
* The function body.
*/
public CCodeBlock block { get; set; }
private List<CCodeFormalParameter> parameters = new ArrayList<CCodeFormalParameter> ();
-
+
public CCodeFunction (string name, string return_type = "void") {
this.name = name;
this.return_type = return_type;
+ this.block = new CCodeBlock ();
}
/**
@@ -85,6 +88,7 @@ public class Vala.CCodeFunction : CCodeNode {
func.parameters.add (param);
}
+ func.is_declaration = is_declaration;
func.block = block;
return func;
}
@@ -121,7 +125,7 @@ public class Vala.CCodeFunction : CCodeNode {
writer.write_string (" G_GNUC_DEPRECATED");
}
- if (block == null) {
+ if (is_declaration) {
if (attributes != null) {
writer.write_string (" ");
writer.write_string (attributes);