diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-01-03 18:55:18 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-01-04 14:38:11 +0100 |
commit | 4e3103bfd1928b080df77b68e6015fae609ad351 (patch) | |
tree | a30c7ae1f00a24a9b76e4770735dd7e1a4be6d6d | |
parent | 76efeb6f154d2826950b191c978ddd82a5d569dd (diff) | |
download | vala-4e3103bfd1928b080df77b68e6015fae609ad351.tar.gz |
Move writing of G_GNUC_DEPRECATED down to CCodeDeclarator implementations
Doing so in CCodeDeclaration is error-prone. CCodeVariableDeclarator still
requires special handling which isn't done here.
-rw-r--r-- | ccode/valaccodedeclaration.vala | 4 | ||||
-rw-r--r-- | ccode/valaccodefunctiondeclarator.vala | 4 | ||||
-rw-r--r-- | codegen/valaccodemethodmodule.vala | 8 | ||||
-rw-r--r-- | codegen/valagtypemodule.vala | 4 | ||||
-rw-r--r-- | tests/annotations/deprecated.vala | 37 |
5 files changed, 53 insertions, 4 deletions
diff --git a/ccode/valaccodedeclaration.vala b/ccode/valaccodedeclaration.vala index 4d0fa7425..4cbd86204 100644 --- a/ccode/valaccodedeclaration.vala +++ b/ccode/valaccodedeclaration.vala @@ -96,10 +96,6 @@ 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/valaccodefunctiondeclarator.vala b/ccode/valaccodefunctiondeclarator.vala index b195f5ae3..30f0c63b1 100644 --- a/ccode/valaccodefunctiondeclarator.vala +++ b/ccode/valaccodefunctiondeclarator.vala @@ -77,6 +77,10 @@ public class Vala.CCodeFunctionDeclarator : CCodeDeclarator { writer.write_string (")"); + if (CCodeModifiers.DEPRECATED in modifiers) { + writer.write_string (" G_GNUC_DEPRECATED"); + } + if (CCodeModifiers.PRINTF in modifiers) { format_arg_index = (format_arg_index >= 0 ? format_arg_index + 1 : args_index); writer.write_string (" G_GNUC_PRINTF(%d,%d)".printf (format_arg_index, args_index + 1)); diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index 35de6deda..1f47af9c8 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -1072,6 +1072,10 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { } else if (m.scanf_format) { func.modifiers |= CCodeModifiers.SCANF; } + + if (m.version.deprecated) { + func.modifiers |= CCodeModifiers.DEPRECATED; + } } public void generate_vfunc (Method m, DataType return_type, Map<int,CCodeParameter> cparam_map, Map<int,CCodeExpression> carg_map, string suffix = "", int direction = 3) { @@ -1147,6 +1151,10 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { vfunc.modifiers |= CCodeModifiers.SCANF; } + if (m.version.deprecated) { + vfunc.modifiers |= CCodeModifiers.DEPRECATED; + } + cfile.add_function (vfunc); pop_context (); diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index 654383fae..7e5639f60 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -393,6 +393,10 @@ public class Vala.GTypeModule : GErrorModule { vdeclarator.modifiers |= CCodeModifiers.SCANF; } + if (m.version.deprecated) { + vdeclarator.modifiers |= CCodeModifiers.DEPRECATED; + } + generate_cparameters (m, decl_space, cparam_map, new CCodeFunction ("fake"), vdeclarator); var vdecl = new CCodeDeclaration (get_ccode_name (creturn_type)); diff --git a/tests/annotations/deprecated.vala b/tests/annotations/deprecated.vala index 0968b1538..f633dac6d 100644 --- a/tests/annotations/deprecated.vala +++ b/tests/annotations/deprecated.vala @@ -1,4 +1,11 @@ [Version (deprecated = true)] +int bar = 42; + +[Version (deprecated = true)] +void baz () { +} + +[Version (deprecated = true)] delegate void FooDelegate (); [Version (deprecated = true)] @@ -17,9 +24,39 @@ void test_struct_field () { [Version (deprecated = true)] class FooClass : Object { [Version (deprecated = true)] + public static int manam = 42; + [Version (deprecated = true)] public int bar { get; set; default = 42; } [Version (deprecated = true)] public int baz; + [Version (deprecated = true)] + public int foo () { + return 42; + } + [Version (deprecated = true)] + public virtual int foov () { + return 42; + } +} + +[Version (deprecated = true)] +abstract class AFoo : Object { + [Version (deprecated = true)] + public int foo () { + return 42; + } + [Version (deprecated = true)] + public abstract int fooa (); +} + +[Version (deprecated = true)] +interface IFoo : Object { + [Version (deprecated = true)] + public int foo () { + return 42; + } + [Version (deprecated = true)] + public abstract void fooa (); } void test_class_property () { |