]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Avoic C warnings for some possibly unused functions
authorJürg Billeter <j@bitron.ch>
Sun, 21 Mar 2010 08:51:24 +0000 (09:51 +0100)
committerJürg Billeter <j@bitron.ch>
Sun, 21 Mar 2010 08:51:24 +0000 (09:51 +0100)
ccode/valaccodefunction.vala
codegen/valaccodebasemodule.vala
codegen/valagtypemodule.vala
codegen/valatyperegisterfunction.vala

index 1dfef1b298a2d9ebca9392dd90b27c17a03bcd9e..2b3775ddf037e6dd0b365070d142fc97509f3bab 100644 (file)
@@ -1,6 +1,6 @@
 /* valaccodefunction.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -41,6 +41,8 @@ public class Vala.CCodeFunction : CCodeNode {
         */
        public string return_type { get; set; }
 
+       public string attributes { get; set; }
+
        /**
         * The function body.
         */
@@ -70,6 +72,7 @@ public class Vala.CCodeFunction : CCodeNode {
        public CCodeFunction copy () {
                var func = new CCodeFunction (name, return_type);
                func.modifiers = modifiers;
+               func.attributes = attributes;
 
                /* no deep copy for lists available yet
                 * func.parameters = parameters.copy ();
@@ -109,7 +112,13 @@ public class Vala.CCodeFunction : CCodeNode {
                }
                
                writer.write_string (")");
+
                if (block == null) {
+                       if (attributes != null) {
+                               writer.write_string (" ");
+                               writer.write_string (attributes);
+                       }
+
                        writer.write_string (";");
                } else {
                        block.write (writer);
index dd2a158beadcefdda316a80d9296830722392c07..edb496bc6df9c981a5293d24ce2ce58e11f68479 100644 (file)
@@ -772,6 +772,8 @@ internal class Vala.CCodeBaseModule : CCodeModule {
 
                if (en.access == SymbolAccessibility.PRIVATE) {
                        regfun.modifiers = CCodeModifiers.STATIC;
+                       // avoid C warning as this function is not always used
+                       regfun.attributes = "G_GNUC_UNUSED";
                }
 
                decl_space.add_type_member_declaration (regfun);
index c99a38199ed6a98d555066347a2df575af78c0be..62c1b1d29cc360dec97db57a549b6321ed4bd3eb 100644 (file)
@@ -118,6 +118,8 @@ internal class Vala.GTypeModule : GErrorModule {
 
                        if (cl.access == SymbolAccessibility.PRIVATE) {
                                function.modifiers = CCodeModifiers.STATIC;
+                               // avoid C warning as this function is not always used
+                               function.attributes = "G_GNUC_UNUSED";
                        }
 
                        decl_space.add_type_member_declaration (function);
@@ -128,6 +130,8 @@ internal class Vala.GTypeModule : GErrorModule {
 
                        if (cl.access == SymbolAccessibility.PRIVATE) {
                                function.modifiers = CCodeModifiers.STATIC;
+                               // avoid C warning as this function is not always used
+                               function.attributes = "G_GNUC_UNUSED";
                        }
 
                        decl_space.add_type_member_declaration (function);
@@ -137,6 +141,8 @@ internal class Vala.GTypeModule : GErrorModule {
 
                        if (cl.access == SymbolAccessibility.PRIVATE) {
                                function.modifiers = CCodeModifiers.STATIC;
+                               // avoid C warning as this function is not always used
+                               function.attributes = "G_GNUC_UNUSED";
                        }
 
                        decl_space.add_type_member_declaration (function);
index 4b4ffcb1d018b4ea3c6d9359f926334207dcf336..571bca64a66be20d18fe950548bb65b443d0ed10 100644 (file)
@@ -1,6 +1,6 @@
 /* valatyperegisterfunction.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -71,6 +71,8 @@ public abstract class Vala.TypeRegisterFunction {
                        /* Function will not be prototyped anyway */
                        if (get_accessibility () == SymbolAccessibility.PRIVATE) {
                                fun.modifiers = CCodeModifiers.STATIC;
+                               // avoid C warning as this function is not always used
+                               fun.attributes = "G_GNUC_UNUSED";
                        }
                } else {
                        fun = new CCodeFunction ("%s_register_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
@@ -79,6 +81,8 @@ public abstract class Vala.TypeRegisterFunction {
                        var get_fun = new CCodeFunction ("%s_get_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
                        if (get_accessibility () == SymbolAccessibility.PRIVATE) {
                                fun.modifiers = CCodeModifiers.STATIC;
+                               // avoid C warning as this function is not always used
+                               fun.attributes = "G_GNUC_UNUSED";
                        }
 
                        declaration_fragment.append (get_fun.copy ());