[vala] Hide internal methods in ABI



commit 970f58989a2863faca11e30fdbcf4da1273a6acd
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date:   Sun May 12 11:18:27 2013 +0100

    Hide internal methods in ABI
    
    Fixes bug 700157

 ccode/valaccodedeclaration.vala       |    7 +++-
 ccode/valaccodefunction.vala          |    3 ++
 ccode/valaccodemodifiers.vala         |    3 +-
 codegen/valaccodebasemodule.vala      |   20 ++++++++++-
 codegen/valaccodemethodmodule.vala    |    8 +++++
 codegen/valaccodestructmodule.vala    |   20 ++++++++++--
 codegen/valagasyncmodule.vala         |   12 +++++++
 codegen/valagdbusservermodule.vala    |    4 ++
 codegen/valagtypemodule.vala          |   57 +++++++++++++++++++++++++-------
 codegen/valatyperegisterfunction.vala |    4 ++
 compiler/valacompiler.vala            |    3 ++
 vala/valacodecontext.vala             |    5 +++
 12 files changed, 125 insertions(+), 21 deletions(-)
---
diff --git a/ccode/valaccodedeclaration.vala b/ccode/valaccodedeclaration.vala
index 95216f8..24bda72 100644
--- a/ccode/valaccodedeclaration.vala
+++ b/ccode/valaccodedeclaration.vala
@@ -52,7 +52,7 @@ public class Vala.CCodeDeclaration : CCodeStatement {
        }
        
        public override void write (CCodeWriter writer) {
-               if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.EXTERN)) == 0) {
+               if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.INTERNAL | CCodeModifiers.EXTERN)) 
== 0) {
                        foreach (CCodeDeclarator decl in declarators) {
                                decl.write_initialization (writer);
                        }
@@ -70,9 +70,12 @@ public class Vala.CCodeDeclaration : CCodeStatement {
        }
 
        public override void write_declaration (CCodeWriter writer) {
-               if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.EXTERN)) != 0) {
+               if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.INTERNAL | CCodeModifiers.EXTERN)) 
!= 0) {
                        // combined declaration and initialization for static and extern variables
                        writer.write_indent (line);
+                       if ((modifiers & CCodeModifiers.INTERNAL) != 0) {
+                               writer.write_string ("G_GNUC_INTERNAL ");
+                       }
                        if ((modifiers & CCodeModifiers.STATIC) != 0) {
                                writer.write_string ("static ");
                        }
diff --git a/ccode/valaccodefunction.vala b/ccode/valaccodefunction.vala
index d54215b..7f3b3bb 100644
--- a/ccode/valaccodefunction.vala
+++ b/ccode/valaccodefunction.vala
@@ -112,6 +112,9 @@ public class Vala.CCodeFunction : CCodeNode {
        
        public override void write (CCodeWriter writer) {
                writer.write_indent (line);
+               if (CCodeModifiers.INTERNAL in modifiers) {
+                       writer.write_string ("G_GNUC_INTERNAL ");
+               }
                if (CCodeModifiers.STATIC in modifiers) {
                        writer.write_string ("static ");
                }
diff --git a/ccode/valaccodemodifiers.vala b/ccode/valaccodemodifiers.vala
index 4dd7455..600751d 100644
--- a/ccode/valaccodemodifiers.vala
+++ b/ccode/valaccodemodifiers.vala
@@ -33,5 +33,6 @@ public enum Vala.CCodeModifiers {
        INLINE = 1 << 3,
        VOLATILE = 1 << 4,
        DEPRECATED = 1 << 5,
-       THREAD_LOCAL = 1 << 6
+       THREAD_LOCAL = 1 << 6,
+       INTERNAL = 1 << 7
 }
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index a359e39..e708545 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -820,10 +820,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                var regfun = new CCodeFunction (fun_name, "GType");
                regfun.attributes = "G_GNUC_CONST";
 
-               if (en.access == SymbolAccessibility.PRIVATE) {
+               if (en.is_private_symbol ()) {
                        regfun.modifiers = CCodeModifiers.STATIC;
                        // avoid C warning as this function is not always used
-                       regfun.attributes = "G_GNUC_UNUSED";
+                       regfun.attributes += " G_GNUC_UNUSED";
+               } else if (context.hide_internal && en.is_internal_symbol ()) {
+                       regfun.modifiers = CCodeModifiers.INTERNAL;
                }
 
                decl_space.add_function_declaration (regfun);
@@ -1011,6 +1013,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                        if (f.is_private_symbol ()) {
                                flock.modifiers = CCodeModifiers.STATIC;
+                       } else if (context.hide_internal && f.is_internal_symbol ()) {
+                               flock.modifiers = CCodeModifiers.INTERNAL;
                        } else {
                                flock.modifiers = CCodeModifiers.EXTERN;
                        }
@@ -1028,6 +1032,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                        cdecl.add_declarator (new CCodeVariableDeclarator 
(get_array_length_cname (get_ccode_name (f), dim)));
                                        if (f.is_private_symbol ()) {
                                                cdecl.modifiers = CCodeModifiers.STATIC;
+                                       } else if (context.hide_internal && f.is_internal_symbol ()) {
+                                               cdecl.modifiers = CCodeModifiers.INTERNAL;
                                        } else {
                                                cdecl.modifiers = CCodeModifiers.EXTERN;
                                        }
@@ -1043,6 +1049,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                cdecl.add_declarator (new CCodeVariableDeclarator 
(get_ccode_delegate_target_name (f)));
                                if (f.is_private_symbol ()) {
                                        cdecl.modifiers = CCodeModifiers.STATIC;
+                               } else if (context.hide_internal && f.is_internal_symbol ()) {
+                                       cdecl.modifiers = CCodeModifiers.INTERNAL;
                                } else {
                                        cdecl.modifiers = CCodeModifiers.EXTERN;
                                }
@@ -1053,6 +1061,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                        cdecl.add_declarator (new CCodeVariableDeclarator 
(get_delegate_target_destroy_notify_cname  (get_ccode_name (f))));
                                        if (f.is_private_symbol ()) {
                                                cdecl.modifiers = CCodeModifiers.STATIC;
+                                       } else if (context.hide_internal && f.is_internal_symbol ()) {
+                                               cdecl.modifiers = CCodeModifiers.INTERNAL;
                                        } else {
                                                cdecl.modifiers = CCodeModifiers.EXTERN;
                                        }
@@ -1503,6 +1513,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                if (prop.is_private_symbol () || (!acc.readable && !acc.writable) || acc.access == 
SymbolAccessibility.PRIVATE) {
                        function.modifiers |= CCodeModifiers.STATIC;
+               } else if (context.hide_internal && (prop.is_internal_symbol () || acc.access == 
SymbolAccessibility.INTERNAL)) {
+                       function.modifiers |= CCodeModifiers.INTERNAL;
                }
                decl_space.add_function_declaration (function);
        }
@@ -1605,6 +1617,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        if (prop.is_private_symbol () || !(acc.readable || acc.writable) || acc.access == 
SymbolAccessibility.PRIVATE) {
                                // accessor function should be private if the property is an internal symbol 
or it's a construct-only setter
                                function.modifiers |= CCodeModifiers.STATIC;
+                       } else if (context.hide_internal && (prop.is_internal_symbol () || acc.access == 
SymbolAccessibility.INTERNAL)) {
+                               function.modifiers |= CCodeModifiers.INTERNAL;
                        }
 
                        push_function (function);
@@ -1728,6 +1742,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                if (prop.is_private_symbol () || !(acc.readable || acc.writable) || 
acc.access == SymbolAccessibility.PRIVATE) {
                                        // accessor function should be private if the property is an internal 
symbol or it's a construct-only setter
                                        function.modifiers |= CCodeModifiers.STATIC;
+                               } else if (context.hide_internal && (prop.is_internal_symbol () || acc.access 
== SymbolAccessibility.INTERNAL)) {
+                                       function.modifiers |= CCodeModifiers.INTERNAL;
                                }
                        }
 
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index d48c03e..0a933ac 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -165,6 +165,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                        if (m.is_inline) {
                                function.modifiers |= CCodeModifiers.INLINE;
                        }
+               } else if (context.hide_internal && m.is_internal_symbol () && !m.external) {
+                       function.modifiers |= CCodeModifiers.INTERNAL;
                }
 
                if (m.deprecated) {
@@ -192,6 +194,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
 
                        if (m.is_private_symbol ()) {
                                function.modifiers |= CCodeModifiers.STATIC;
+                       } else if (context.hide_internal && m.is_internal_symbol ()) {
+                               function.modifiers |= CCodeModifiers.INTERNAL;
                        }
 
                        cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
@@ -426,6 +430,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                                        cfile.add_function_declaration (function);
                                } else if (m.is_private_symbol ()) {
                                        function.modifiers |= CCodeModifiers.STATIC;
+                               } else if (context.hide_internal && m.is_internal_symbol ()) {
+                                       function.modifiers |= CCodeModifiers.INTERNAL;
                                }
                        } else {
                                if (m.body != null) {
@@ -1178,6 +1184,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                var vfunc = new CCodeFunction (func_name);
                if (m.is_private_symbol ()) {
                        vfunc.modifiers |= CCodeModifiers.STATIC;
+               } else if (context.hide_internal && m.is_internal_symbol ()) {
+                       vfunc.modifiers |= CCodeModifiers.INTERNAL;
                }
 
                var cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 51cef5d..86b1b9b 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -121,6 +121,8 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                var function = new CCodeFunction (get_ccode_dup_function (st), get_ccode_name (st) + "*");
                if (st.is_private_symbol ()) {
                        function.modifiers = CCodeModifiers.STATIC;
+               } else if (context.hide_internal && st.is_internal_symbol ()) {
+                       function.modifiers = CCodeModifiers.INTERNAL;
                }
                function.add_parameter (new CCodeParameter ("self", "const " + get_ccode_name (st) + "*"));
                decl_space.add_function_declaration (function);
@@ -128,6 +130,8 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                function = new CCodeFunction (get_ccode_free_function (st), "void");
                if (st.is_private_symbol ()) {
                        function.modifiers = CCodeModifiers.STATIC;
+               } else if (context.hide_internal && st.is_internal_symbol ()) {
+                       function.modifiers = CCodeModifiers.INTERNAL;
                }
                function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
                decl_space.add_function_declaration (function);
@@ -136,6 +140,8 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                        function = new CCodeFunction (get_ccode_copy_function (st), "void");
                        if (st.is_private_symbol ()) {
                                function.modifiers = CCodeModifiers.STATIC;
+                       } else if (context.hide_internal && st.is_internal_symbol ()) {
+                               function.modifiers = CCodeModifiers.INTERNAL;
                        }
                        function.add_parameter (new CCodeParameter ("self", "const " + get_ccode_name (st) + 
"*"));
                        function.add_parameter (new CCodeParameter ("dest", get_ccode_name (st) + "*"));
@@ -144,6 +150,8 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                        function = new CCodeFunction (get_ccode_destroy_function (st), "void");
                        if (st.is_private_symbol ()) {
                                function.modifiers = CCodeModifiers.STATIC;
+                       } else if (context.hide_internal && st.is_internal_symbol ()) {
+                               function.modifiers = CCodeModifiers.INTERNAL;
                        }
                        function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
                        decl_space.add_function_declaration (function);
@@ -234,8 +242,10 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
 
        void add_struct_free_function (Struct st) {
                var function = new CCodeFunction (get_ccode_free_function (st), "void");
-               if (st.access == SymbolAccessibility.PRIVATE) {
+               if (st.is_private_symbol ()) {
                        function.modifiers = CCodeModifiers.STATIC;
+               } else if (context.hide_internal && st.is_internal_symbol ()) {
+                       function.modifiers = CCodeModifiers.INTERNAL;
                }
 
                function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
@@ -259,8 +269,10 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
 
        void add_struct_copy_function (Struct st) {
                var function = new CCodeFunction (get_ccode_copy_function (st), "void");
-               if (st.access == SymbolAccessibility.PRIVATE) {
+               if (st.is_private_symbol ()) {
                        function.modifiers = CCodeModifiers.STATIC;
+               } else if (context.hide_internal && st.is_internal_symbol ()) {
+                       function.modifiers = CCodeModifiers.INTERNAL;
                }
 
                function.add_parameter (new CCodeParameter ("self", "const " + get_ccode_name (st) + "*"));
@@ -292,8 +304,10 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                push_context (instance_finalize_context);
 
                var function = new CCodeFunction (get_ccode_destroy_function (st), "void");
-               if (st.access == SymbolAccessibility.PRIVATE) {
+               if (st.is_private_symbol ()) {
                        function.modifiers = CCodeModifiers.STATIC;
+               } else if (context.hide_internal && st.is_internal_symbol ()) {
+                       function.modifiers = CCodeModifiers.INTERNAL;
                }
 
                function.add_parameter (new CCodeParameter ("self", get_ccode_name (st) + "*"));
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 1d18369..96b7c2a 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -186,6 +186,8 @@ public class Vala.GAsyncModule : GtkModule {
                        cfile.add_function_declaration (asyncfunc);
                } else if (m.is_private_symbol ()) {
                        asyncfunc.modifiers |= CCodeModifiers.STATIC;
+               } else if (context.hide_internal && m.is_internal_symbol ()) {
+                       asyncfunc.modifiers |= CCodeModifiers.INTERNAL;
                }
 
                push_function (asyncfunc);
@@ -337,6 +339,8 @@ public class Vala.GAsyncModule : GtkModule {
 
                        if (m.is_private_symbol ()) {
                                asyncfunc.modifiers |= CCodeModifiers.STATIC;
+                       } else if (context.hide_internal && m.is_internal_symbol ()) {
+                               asyncfunc.modifiers |= CCodeModifiers.INTERNAL;
                        }
 
                        // do not generate _new functions for creation methods of abstract classes
@@ -352,6 +356,8 @@ public class Vala.GAsyncModule : GtkModule {
 
                        if (m.is_private_symbol ()) {
                                finishfunc.modifiers |= CCodeModifiers.STATIC;
+                       } else if (context.hide_internal && m.is_internal_symbol ()) {
+                               finishfunc.modifiers |= CCodeModifiers.INTERNAL;
                        }
 
                        // do not generate _new functions for creation methods of abstract classes
@@ -367,6 +373,8 @@ public class Vala.GAsyncModule : GtkModule {
 
                                if (m.is_private_symbol ()) {
                                        function.modifiers |= CCodeModifiers.STATIC;
+                               } else if (context.hide_internal && m.is_internal_symbol ()) {
+                                       function.modifiers |= CCodeModifiers.INTERNAL;
                                }
 
                                cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
@@ -378,6 +386,8 @@ public class Vala.GAsyncModule : GtkModule {
 
                                if (m.is_private_symbol ()) {
                                        function.modifiers |= CCodeModifiers.STATIC;
+                               } else if (context.hide_internal && m.is_internal_symbol ()) {
+                                       function.modifiers |= CCodeModifiers.INTERNAL;
                                }
 
                                cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
@@ -517,6 +527,8 @@ public class Vala.GAsyncModule : GtkModule {
 
                if (m.is_private_symbol () || m.base_method != null || m.base_interface_method != null) {
                        finishfunc.modifiers |= CCodeModifiers.STATIC;
+               } else if (context.hide_internal && m.is_internal_symbol ()) {
+                       finishfunc.modifiers |= CCodeModifiers.INTERNAL;
                }
 
                push_function (finishfunc);
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index fc4ca65..6e8ff5a 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -1198,6 +1198,8 @@ public class Vala.GDBusServerModule : GDBusClientModule {
                cfunc.add_parameter (new CCodeParameter ("error", "GError**"));
                if (sym.is_private_symbol ()) {
                        cfunc.modifiers |= CCodeModifiers.STATIC;
+               } else if (context.hide_internal && sym.is_internal_symbol ()) {
+                       cfunc.modifiers |= CCodeModifiers.INTERNAL;
                }
                decl_space.add_function_declaration (cfunc);
        }
@@ -1219,6 +1221,8 @@ public class Vala.GDBusServerModule : GDBusClientModule {
                cfunc.add_parameter (new CCodeParameter ("error", "GError**"));
                if (sym.is_private_symbol ()) {
                        cfunc.modifiers |= CCodeModifiers.STATIC;
+               } else if (context.hide_internal && sym.is_internal_symbol ()) {
+                       cfunc.modifiers |= CCodeModifiers.INTERNAL;
                }
 
                push_function (cfunc);
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 26778eb..3dc3729 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -93,9 +93,12 @@ public class Vala.GTypeModule : GErrorModule {
                if (is_fundamental) {
                        var ref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "ref", 
"gpointer");
                        var unref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "unref", 
"void");
-                       if (cl.access == SymbolAccessibility.PRIVATE) {
+                       if (cl.is_private_symbol ()) {
                                ref_fun.modifiers = CCodeModifiers.STATIC;
                                unref_fun.modifiers = CCodeModifiers.STATIC;
+                       } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                               ref_fun.modifiers = CCodeModifiers.INTERNAL;
+                               unref_fun.modifiers = CCodeModifiers.INTERNAL;
                        }
 
                        ref_fun.add_parameter (new CCodeParameter ("instance", "gpointer"));
@@ -114,10 +117,12 @@ public class Vala.GTypeModule : GErrorModule {
                        function.add_parameter (new CCodeParameter ("object_type", "GType"));
                        function.add_parameter (new CCodeParameter ("flags", "GParamFlags"));
 
-                       if (cl.access == SymbolAccessibility.PRIVATE) {
+                       if (cl.is_private_symbol ()) {
                                function.modifiers = CCodeModifiers.STATIC;
                                // avoid C warning as this function is not always used
                                function.attributes = "G_GNUC_UNUSED";
+                       } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                               function.modifiers = CCodeModifiers.INTERNAL;
                        }
 
                        decl_space.add_function_declaration (function);
@@ -126,10 +131,14 @@ public class Vala.GTypeModule : GErrorModule {
                        function.add_parameter (new CCodeParameter ("value", "GValue*"));
                        function.add_parameter (new CCodeParameter ("v_object", "gpointer"));
 
-                       if (cl.access == SymbolAccessibility.PRIVATE) {
+                       if (cl.is_private_symbol ()) {
                                function.modifiers = CCodeModifiers.STATIC;
                                // avoid C warning as this function is not always used
                                function.attributes = "G_GNUC_UNUSED";
+                       } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                               function.modifiers = CCodeModifiers.INTERNAL;
+                               // avoid C warning as this function is not always used
+                               function.attributes = "G_GNUC_UNUSED";
                        }
 
                        decl_space.add_function_declaration (function);
@@ -138,10 +147,12 @@ public class Vala.GTypeModule : GErrorModule {
                        function.add_parameter (new CCodeParameter ("value", "GValue*"));
                        function.add_parameter (new CCodeParameter ("v_object", "gpointer"));
 
-                       if (cl.access == SymbolAccessibility.PRIVATE) {
+                       if (cl.is_private_symbol ()) {
                                function.modifiers = CCodeModifiers.STATIC;
                                // avoid C warning as this function is not always used
                                function.attributes = "G_GNUC_UNUSED";
+                       } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                               function.modifiers = CCodeModifiers.INTERNAL;
                        }
 
                        decl_space.add_function_declaration (function);
@@ -149,18 +160,24 @@ public class Vala.GTypeModule : GErrorModule {
                        function = new CCodeFunction (get_ccode_get_value_function (cl), "gpointer");
                        function.add_parameter (new CCodeParameter ("value", "const GValue*"));
 
-                       if (cl.access == SymbolAccessibility.PRIVATE) {
+                       if (cl.is_private_symbol ()) {
                                function.modifiers = CCodeModifiers.STATIC;
                                // avoid C warning as this function is not always used
                                function.attributes = "G_GNUC_UNUSED";
+                       } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                               function.modifiers = CCodeModifiers.INTERNAL;
+                               // avoid C warning as this function is not always used
+                               function.attributes = "G_GNUC_UNUSED";
                        }
 
                        decl_space.add_function_declaration (function);
                } else if (!is_gtypeinstance && !is_gsource) {
                        if (cl.base_class == null) {
                                var function = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "free", 
"void");
-                               if (cl.access == SymbolAccessibility.PRIVATE) {
+                               if (cl.is_private_symbol ()) {
                                        function.modifiers = CCodeModifiers.STATIC;
+                               } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                                       function.modifiers = CCodeModifiers.INTERNAL;
                                }
 
                                function.add_parameter (new CCodeParameter ("self", get_ccode_name (cl) + 
"*"));
@@ -653,8 +670,10 @@ public class Vala.GTypeModule : GErrorModule {
                                // ref function
                                var ref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "ref", 
"gpointer");
                                ref_fun.add_parameter (new CCodeParameter ("instance", "gpointer"));
-                               if (cl.access == SymbolAccessibility.PRIVATE) {
+                               if (cl.is_private_symbol ()) {
                                        ref_fun.modifiers = CCodeModifiers.STATIC;
+                               } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                                       ref_fun.modifiers = CCodeModifiers.INTERNAL;
                                }
                                push_function (ref_fun);
 
@@ -670,8 +689,10 @@ public class Vala.GTypeModule : GErrorModule {
                                // unref function
                                var unref_fun = new CCodeFunction (get_ccode_lower_case_prefix (cl) + 
"unref", "void");
                                unref_fun.add_parameter (new CCodeParameter ("instance", "gpointer"));
-                               if (cl.access == SymbolAccessibility.PRIVATE) {
+                               if (cl.is_private_symbol ()) {
                                        unref_fun.modifiers = CCodeModifiers.STATIC;
+                               } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                                       unref_fun.modifiers = CCodeModifiers.INTERNAL;
                                }
                                push_function (unref_fun);
 
@@ -909,8 +930,10 @@ public class Vala.GTypeModule : GErrorModule {
                function.add_parameter (new CCodeParameter ("object_type", "GType"));
                function.add_parameter (new CCodeParameter ("flags", "GParamFlags"));
 
-               if (cl.access == SymbolAccessibility.PRIVATE) {
+               if (cl.is_private_symbol ()) {
                        function.modifiers = CCodeModifiers.STATIC;
+               } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                       function.modifiers = CCodeModifiers.INTERNAL;
                }
 
                push_function (function);
@@ -950,8 +973,10 @@ public class Vala.GTypeModule : GErrorModule {
                function.add_parameter (new CCodeParameter ("value", "GValue*"));
                function.add_parameter (new CCodeParameter ("v_object", "gpointer"));
 
-               if (cl.access == SymbolAccessibility.PRIVATE) {
+               if (cl.is_private_symbol ()) {
                        function.modifiers = CCodeModifiers.STATIC;
+               } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                       function.modifiers = CCodeModifiers.INTERNAL;
                }
 
                var vpointer = new CCodeMemberAccess (new CCodeMemberAccess.pointer (new CCodeIdentifier 
("value"), "data[0]"), "v_pointer");
@@ -1018,8 +1043,10 @@ public class Vala.GTypeModule : GErrorModule {
                function.add_parameter (new CCodeParameter ("value", "GValue*"));
                function.add_parameter (new CCodeParameter ("v_object", "gpointer"));
 
-               if (cl.access == SymbolAccessibility.PRIVATE) {
+               if (cl.is_private_symbol ()) {
                        function.modifiers = CCodeModifiers.STATIC;
+               } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                       function.modifiers = CCodeModifiers.INTERNAL;
                }
 
                var vpointer = new CCodeMemberAccess(new CCodeMemberAccess.pointer (new CCodeIdentifier 
("value"), "data[0]"),"v_pointer");
@@ -1082,8 +1109,10 @@ public class Vala.GTypeModule : GErrorModule {
                var function = new CCodeFunction (get_ccode_get_value_function (cl), "gpointer");
                function.add_parameter (new CCodeParameter ("value", "const GValue*"));
 
-               if (cl.access == SymbolAccessibility.PRIVATE) {
+               if (cl.is_private_symbol ()) {
                        function.modifiers = CCodeModifiers.STATIC;
+               } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                       function.modifiers = CCodeModifiers.INTERNAL;
                }
 
                var vpointer = new CCodeMemberAccess(new CCodeMemberAccess.pointer (new CCodeIdentifier 
("value"), "data[0]"),"v_pointer");
@@ -1683,8 +1712,10 @@ public class Vala.GTypeModule : GErrorModule {
                        ccode.add_assignment (new CCodeIdentifier ("self"), ccast);
                } else {
                        var function = new CCodeFunction (get_ccode_lower_case_prefix (cl) + "free", "void");
-                       if (cl.access == SymbolAccessibility.PRIVATE) {
+                       if (cl.is_private_symbol ()) {
                                function.modifiers = CCodeModifiers.STATIC;
+                       } else if (context.hide_internal && cl.is_internal_symbol ()) {
+                               function.modifiers = CCodeModifiers.INTERNAL;
                        }
 
                        function.add_parameter (new CCodeParameter ("self", get_ccode_name (cl) + "*"));
diff --git a/codegen/valatyperegisterfunction.vala b/codegen/valatyperegisterfunction.vala
index 61e77a8..33a372f 100644
--- a/codegen/valatyperegisterfunction.vala
+++ b/codegen/valatyperegisterfunction.vala
@@ -75,6 +75,10 @@ public abstract class Vala.TypeRegisterFunction {
                                fun.modifiers = CCodeModifiers.STATIC;
                                // avoid C warning as this function is not always used
                                fun.attributes += " G_GNUC_UNUSED";
+                       } else if (context.hide_internal && get_accessibility () == 
SymbolAccessibility.INTERNAL) {
+                               fun.modifiers = CCodeModifiers.INTERNAL;
+                               // avoid C warning as this function is not always used
+                               fun.attributes += " G_GNUC_UNUSED";
                        }
                } else {
                        fun = new CCodeFunction ("%s_register_type".printf 
(CCodeBaseModule.get_ccode_lower_case_name (get_type_declaration ())), "GType");
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 16b55f2..a90d668 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -63,6 +63,7 @@ class Vala.Compiler {
        static bool disable_assert;
        static bool enable_checking;
        static bool deprecated;
+       static bool hide_internal;
        static bool experimental;
        static bool experimental_non_null;
        static bool gobject_tracing;
@@ -122,6 +123,7 @@ class Vala.Compiler {
                { "disable-assert", 0, 0, OptionArg.NONE, ref disable_assert, "Disable assertions", null },
                { "enable-checking", 0, 0, OptionArg.NONE, ref enable_checking, "Enable additional run-time 
checks", null },
                { "enable-deprecated", 0, 0, OptionArg.NONE, ref deprecated, "Enable deprecated features", 
null },
+               { "hide-internal", 0, 0, OptionArg.NONE, ref hide_internal, "Hide symbols marked as 
internal", null },
                { "enable-experimental", 0, 0, OptionArg.NONE, ref experimental, "Enable experimental 
features", null },
                { "disable-warnings", 0, 0, OptionArg.NONE, ref disable_warnings, "Disable warnings", null },
                { "fatal-warnings", 0, 0, OptionArg.NONE, ref fatal_warnings, "Treat warnings as fatal", null 
},
@@ -176,6 +178,7 @@ class Vala.Compiler {
                context.assert = !disable_assert;
                context.checking = enable_checking;
                context.deprecated = deprecated;
+               context.hide_internal = hide_internal;
                context.experimental = experimental;
                context.experimental_non_null = experimental_non_null;
                context.gobject_tracing = gobject_tracing;
diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala
index afad107..965e812 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -42,6 +42,11 @@ public class Vala.CodeContext {
        public bool deprecated { get; set; }
 
        /**
+        * Hide the symbols marked as internal
+        */
+       public bool hide_internal { get; set; }
+
+       /**
         * Do not warn when using experimental features.
         */
        public bool experimental { get; set; }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]