]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Move writing of G_GNUC_DEPRECATED down to CCodeDeclarator implementations
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 3 Jan 2017 17:55:18 +0000 (18:55 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 4 Jan 2017 13:38:11 +0000 (14:38 +0100)
Doing so in CCodeDeclaration is error-prone. CCodeVariableDeclarator still
requires special handling which isn't done here.

ccode/valaccodedeclaration.vala
ccode/valaccodefunctiondeclarator.vala
codegen/valaccodemethodmodule.vala
codegen/valagtypemodule.vala
tests/annotations/deprecated.vala

index 4d0fa742568fea84228e0a00038f6b4b8e1eb823..4cbd86204423ade1ec88ee4097eb5130b2a2fe51 100644 (file)
@@ -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;
index b195f5ae38d33cb2ed61f81c0cdddef225e23adc..30f0c63b1dcdd8895fc91edeaab0e3e8022b7b28 100644 (file)
@@ -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));
index 35de6deda868014940c188335d289a6cc9669d0b..1f47af9c8045b884b60e9b6c5c98145db326f033 100644 (file)
@@ -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 ();
index 654383faea54ec6d0a106156c5bc372e22d1a74f..7e5639f60d34559f10b31c9c2dc3d42082b04a22 100644 (file)
@@ -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));
index 0968b15389e6eaddf0624e7755f63287372d6f63..f633dac6de5d3cadf295f1a16a7dd88096dea6f2 100644 (file)
@@ -1,3 +1,10 @@
+[Version (deprecated = true)]
+int bar = 42;
+
+[Version (deprecated = true)]
+void baz () {
+}
+
 [Version (deprecated = true)]
 delegate void FooDelegate ();
 
@@ -16,10 +23,40 @@ 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 () {