]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Mark GObject *_get_type() functions as constant
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Tue, 22 Jun 2010 13:42:54 +0000 (14:42 +0100)
committerJürg Billeter <j@bitron.ch>
Mon, 12 Jul 2010 18:37:46 +0000 (20:37 +0200)
Add the G_GNUC_CONST attribute to the declarations of all *_get_type()
functions, since they are constant functions.

Fixes bug 622399.

codegen/valaccodebasemodule.vala
codegen/valadbusclientmodule.vala
codegen/valagdbusclientmodule.vala
codegen/valatyperegisterfunction.vala

index ed0dab88198a6457eb216a15d6b185760e7193fe..b54ff418bdd0ea49fe0db0ef565b90b2d004df78 100644 (file)
@@ -707,6 +707,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
                var fun_name = "%s_get_type".printf (en.get_lower_case_cname (null));
                var regfun = new CCodeFunction (fun_name, "GType");
+               regfun.attributes = "G_GNUC_CONST";
 
                if (en.access == SymbolAccessibility.PRIVATE) {
                        regfun.modifiers = CCodeModifiers.STATIC;
index e0477852a1831a2c14d4923c766aafdeac52b8d5..9e02444df2e22523739e909f33022972a9a60131 100644 (file)
@@ -1082,7 +1082,9 @@ public class Vala.DBusClientModule : DBusModule {
 
                source_declarations.add_type_definition (instance_struct);
 
-               source_declarations.add_type_member_declaration (new CCodeFunction(lower_cname + "_get_type", "GType"));
+               var type_fun = new CCodeFunction(lower_cname + "_get_type", "GType");
+               type_fun.attributes = "G_GNUC_CONST";
+               source_declarations.add_type_member_declaration (type_fun);
 
                var define_type = new CCodeFunctionCall (new CCodeIdentifier ("G_DEFINE_TYPE_EXTENDED"));
                define_type.add_argument (new CCodeIdentifier (cname));
index e83d3c6c80f493660346858c355d57cf61c77e93..1113df6d5635614627cb88a05dff6b414901bdf6 100644 (file)
@@ -186,6 +186,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 
                // declare proxy_get_type function
                var proxy_get_type = new CCodeFunction (get_type_name, "GType");
+               proxy_get_type.attributes = "G_GNUC_CONST";
                decl_space.add_type_member_declaration (proxy_get_type);
        }
 
index 7ce72052b4823084ac9f09a0e70e4b0fe1609a2b..5d541e0afb784412ef38e926a2d0123834a1a867 100644 (file)
@@ -68,17 +68,20 @@ public abstract class Vala.TypeRegisterFunction {
                CCodeFunction fun;
                if (!plugin) {
                        fun = new CCodeFunction ("%s_get_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
+                       fun.attributes = "G_GNUC_CONST";
+
                        /* 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";
+                               fun.attributes += " G_GNUC_UNUSED";
                        }
                } else {
                        fun = new CCodeFunction ("%s_register_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
                        fun.add_parameter (new CCodeFormalParameter ("module", "GTypeModule *"));
 
                        var get_fun = new CCodeFunction ("%s_get_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
+                       get_fun.attributes = "G_GNUC_CONST";
 
                        declaration_fragment.append (get_fun.copy ());