summaryrefslogtreecommitdiff
path: root/ccode
diff options
context:
space:
mode:
authorEvan Nemerson <evan@coeus-group.com>2010-05-15 15:16:36 -0700
committerJürg Billeter <j@bitron.ch>2010-06-15 20:40:27 +0200
commit2fb2383e5b878da9f3d800e492252115a76c387c (patch)
tree4f5466fde1e132a74007ed18fcf26a351e12b062 /ccode
parenta2c979388250683f8dc91c18db45d3a0a5b3b3e3 (diff)
downloadvala-2fb2383e5b878da9f3d800e492252115a76c387c.tar.gz
codegen: write G_GNUC_DEPRECATED in generated C where appropriate
Diffstat (limited to 'ccode')
-rw-r--r--ccode/valaccodedeclaration.vala6
-rw-r--r--ccode/valaccodeenum.vala8
-rw-r--r--ccode/valaccodeenumvalue.vala5
-rw-r--r--ccode/valaccodefunction.vala4
-rw-r--r--ccode/valaccodemodifiers.vala3
-rw-r--r--ccode/valaccodestruct.vala9
-rw-r--r--ccode/valaccodetypedefinition.vala11
7 files changed, 43 insertions, 3 deletions
diff --git a/ccode/valaccodedeclaration.vala b/ccode/valaccodedeclaration.vala
index 79966f495..556174e65 100644
--- a/ccode/valaccodedeclaration.vala
+++ b/ccode/valaccodedeclaration.vala
@@ -30,7 +30,7 @@ public class Vala.CCodeDeclaration : CCodeStatement {
* The type of the local variable.
*/
public string type_name { get; set; }
-
+
/**
* The declaration modifier.
*/
@@ -95,6 +95,10 @@ public class Vala.CCodeDeclaration : CCodeStatement {
decl.write (writer);
}
+ if (CCodeModifiers.DEPRECATED in modifiers) {
+ writer.write_string (" G_GNUC_DEPRECATED");
+ }
+
writer.write_string (";");
writer.write_newline ();
return;
diff --git a/ccode/valaccodeenum.vala b/ccode/valaccodeenum.vala
index c32664712..26ebe543d 100644
--- a/ccode/valaccodeenum.vala
+++ b/ccode/valaccodeenum.vala
@@ -30,6 +30,11 @@ public class Vala.CCodeEnum : CCodeNode {
* The name of this enum.
*/
public string name { get; set; }
+
+ /**
+ * Whether the enum is deprecated.
+ */
+ public bool deprecated { get; set; default = false; }
private List<CCodeEnumValue> values = new ArrayList<CCodeEnumValue> ();
@@ -71,6 +76,9 @@ public class Vala.CCodeEnum : CCodeNode {
writer.write_string (" ");
writer.write_string (name);
}
+ if (deprecated) {
+ writer.write_string (" G_GNUC_DEPRECATED");
+ }
writer.write_string (";");
writer.write_newline ();
}
diff --git a/ccode/valaccodeenumvalue.vala b/ccode/valaccodeenumvalue.vala
index 6dc784fd9..e1c02513b 100644
--- a/ccode/valaccodeenumvalue.vala
+++ b/ccode/valaccodeenumvalue.vala
@@ -32,6 +32,11 @@ public class Vala.CCodeEnumValue : CCodeNode {
public string name { get; set; }
/**
+ * Whether this enum value is deprecated.
+ */
+ public bool deprecated { get; set; default = false; }
+
+ /**
* The numerical representation of this enum value.
*/
public CCodeExpression? value { get; set; }
diff --git a/ccode/valaccodefunction.vala b/ccode/valaccodefunction.vala
index faac0ec94..d414fb28b 100644
--- a/ccode/valaccodefunction.vala
+++ b/ccode/valaccodefunction.vala
@@ -117,6 +117,10 @@ public class Vala.CCodeFunction : CCodeNode {
writer.write_string (")");
+ if (CCodeModifiers.DEPRECATED in modifiers) {
+ writer.write_string (" G_GNUC_DEPRECATED");
+ }
+
if (block == null) {
if (attributes != null) {
writer.write_string (" ");
diff --git a/ccode/valaccodemodifiers.vala b/ccode/valaccodemodifiers.vala
index 90f6809c8..d2a96f212 100644
--- a/ccode/valaccodemodifiers.vala
+++ b/ccode/valaccodemodifiers.vala
@@ -30,5 +30,6 @@ public enum Vala.CCodeModifiers {
REGISTER = 1 << 1,
EXTERN = 1 << 2,
INLINE = 1 << 3,
- VOLATILE = 1 << 4
+ VOLATILE = 1 << 4,
+ DEPRECATED = 1 << 5
}
diff --git a/ccode/valaccodestruct.vala b/ccode/valaccodestruct.vala
index 7aa5c407c..20cae7996 100644
--- a/ccode/valaccodestruct.vala
+++ b/ccode/valaccodestruct.vala
@@ -30,6 +30,11 @@ public class Vala.CCodeStruct : CCodeNode {
* The struct name.
*/
public string name { get; set; }
+
+ /**
+ * Whether the struct is deprecated.
+ */
+ public bool deprecated { get; set; default = false; }
private List<CCodeDeclaration> declarations = new ArrayList<CCodeDeclaration> ();
@@ -65,7 +70,11 @@ public class Vala.CCodeStruct : CCodeNode {
foreach (CCodeDeclaration decl in declarations) {
decl.write_declaration (writer);
}
+
writer.write_end_block ();
+ if (deprecated) {
+ writer.write_string (" G_GNUC_DEPRECATED");
+ }
writer.write_string (";");
writer.write_newline ();
writer.write_newline ();
diff --git a/ccode/valaccodetypedefinition.vala b/ccode/valaccodetypedefinition.vala
index f0723fc3e..84d6ce293 100644
--- a/ccode/valaccodetypedefinition.vala
+++ b/ccode/valaccodetypedefinition.vala
@@ -35,6 +35,11 @@ public class Vala.CCodeTypeDefinition : CCodeNode {
* The type declarator.
*/
public CCodeDeclarator declarator { get; set; }
+
+ /**
+ * Whether the type is deprecated.
+ */
+ public bool deprecated { get; set; default = false; }
public CCodeTypeDefinition (string type, CCodeDeclarator decl) {
type_name = type;
@@ -53,7 +58,11 @@ public class Vala.CCodeTypeDefinition : CCodeNode {
writer.write_string (" ");
declarator.write_declaration (writer);
-
+
+ if (deprecated) {
+ writer.write_string (" G_GNUC_DEPRECATED");
+ }
+
writer.write_string (";");
writer.write_newline ();
}