From 2fb2383e5b878da9f3d800e492252115a76c387c Mon Sep 17 00:00:00 2001 From: Evan Nemerson Date: Sat, 15 May 2010 15:16:36 -0700 Subject: codegen: write G_GNUC_DEPRECATED in generated C where appropriate --- ccode/valaccodedeclaration.vala | 6 +++++- ccode/valaccodeenum.vala | 8 ++++++++ ccode/valaccodeenumvalue.vala | 5 +++++ ccode/valaccodefunction.vala | 4 ++++ ccode/valaccodemodifiers.vala | 3 ++- ccode/valaccodestruct.vala | 9 +++++++++ ccode/valaccodetypedefinition.vala | 11 ++++++++++- 7 files changed, 43 insertions(+), 3 deletions(-) (limited to 'ccode') 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 values = new ArrayList (); @@ -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 @@ -31,6 +31,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. */ 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 declarations = new ArrayList (); @@ -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 (); } -- cgit v1.2.1