[vala] codegen: write G_GNUC_DEPRECATED in generated C where appropriate
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: write G_GNUC_DEPRECATED in generated C where appropriate
- Date: Tue, 15 Jun 2010 18:43:46 +0000 (UTC)
commit 2fb2383e5b878da9f3d800e492252115a76c387c
Author: Evan Nemerson <evan coeus-group com>
Date: Sat May 15 15:16:36 2010 -0700
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 ++++++++++-
codegen/valaccodebasemodule.vala | 14 +++++++++++---
codegen/valaccodedelegatemodule.vala | 2 ++
codegen/valaccodemethodmodule.vala | 4 ++++
codegen/valaccodestructmodule.vala | 3 ++-
11 files changed, 62 insertions(+), 7 deletions(-)
---
diff --git a/ccode/valaccodedeclaration.vala b/ccode/valaccodedeclaration.vala
index 79966f4..556174e 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 c326647..26ebe54 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 6dc784f..e1c0251 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 faac0ec..d414fb2 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 90f6809..d2a96f2 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 7aa5c40..20cae79 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 f0723fc..84d6ce2 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 ();
}
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 2cfc9bb..24b0fb5 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -767,13 +767,18 @@ public class Vala.CCodeBaseModule : CCodeModule {
var cenum = new CCodeEnum (en.get_cname ());
+ cenum.deprecated = en.deprecated;
+
foreach (EnumValue ev in en.get_values ()) {
+ CCodeEnumValue c_ev;
if (ev.value == null) {
- cenum.add_value (new CCodeEnumValue (ev.get_cname ()));
+ c_ev = new CCodeEnumValue (ev.get_cname ());
} else {
ev.value.accept (codegen);
- cenum.add_value (new CCodeEnumValue (ev.get_cname (), (CCodeExpression) ev.value.ccodenode));
+ c_ev = new CCodeEnumValue (ev.get_cname (), (CCodeExpression) ev.value.ccodenode);
}
+ c_ev.deprecated = ev.deprecated;
+ cenum.add_value (c_ev);
}
decl_space.add_type_definition (cenum);
@@ -879,7 +884,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
} else {
cdecl.modifiers = CCodeModifiers.EXTERN;
}
-
+
decl_space.add_constant_declaration (cdecl);
} else {
var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.initializer.ccodenode);
@@ -918,6 +923,9 @@ public class Vala.CCodeBaseModule : CCodeModule {
} else {
cdecl.modifiers = CCodeModifiers.EXTERN;
}
+ if (f.deprecated) {
+ cdecl.modifiers |= CCodeModifiers.DEPRECATED;
+ }
decl_space.add_type_member_declaration (cdecl);
if (f.get_lock_used ()) {
diff --git a/codegen/valaccodedelegatemodule.vala b/codegen/valaccodedelegatemodule.vala
index e503e6c..3b21bba 100644
--- a/codegen/valaccodedelegatemodule.vala
+++ b/codegen/valaccodedelegatemodule.vala
@@ -110,6 +110,8 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
}
var ctypedef = new CCodeTypeDefinition (return_type_cname, cfundecl);
+ ctypedef.deprecated = d.deprecated;
+
decl_space.add_type_definition (ctypedef);
}
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 553c25c..2e30afe 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -179,6 +179,10 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
}
}
+ if (m.deprecated) {
+ function.modifiers |= CCodeModifiers.DEPRECATED;
+ }
+
var cparam_map = new HashMap<int,CCodeFormalParameter> (direct_hash, direct_equal);
var carg_map = new HashMap<int,CCodeExpression> (direct_hash, direct_equal);
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 7aceec0..d84cbb7 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -63,6 +63,7 @@ public class Vala.CCodeStructModule : CCodeBaseModule {
}
var instance_struct = new CCodeStruct ("_%s".printf (st.get_cname ()));
+ instance_struct.deprecated = st.deprecated;
foreach (Field f in st.get_fields ()) {
string field_ctype = f.field_type.get_cname ();
@@ -73,7 +74,7 @@ public class Vala.CCodeStructModule : CCodeBaseModule {
if (f.binding == MemberBinding.INSTANCE) {
generate_type_declaration (f.field_type, decl_space);
- instance_struct.add_field (field_ctype, f.get_cname () + f.field_type.get_cdeclarator_suffix ());
+ instance_struct.add_field (field_ctype, f.get_cname () + f.field_type.get_cdeclarator_suffix (), f.deprecated ? " G_GNUC_DEPRECATED" : null);
if (f.field_type is ArrayType && !f.no_array_length) {
// create fields to store array dimensions
var array_type = (ArrayType) f.field_type;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]