}
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);
}
}
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 ");
}
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 ");
}
INLINE = 1 << 3,
VOLATILE = 1 << 4,
DEPRECATED = 1 << 5,
- THREAD_LOCAL = 1 << 6
+ THREAD_LOCAL = 1 << 6,
+ INTERNAL = 1 << 7
}
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);
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;
}
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;
}
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;
}
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;
}
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);
}
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);
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;
}
}
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) {
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);
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) {
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);
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);
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);
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) + "*"));
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);
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) + "*"));
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) + "*"));
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) + "*"));
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);
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
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
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);
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);
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);
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);
}
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);
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"));
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);
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);
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);
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) + "*"));
// 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);
// 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);
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);
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");
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");
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");
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) + "*"));
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");
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;
{ "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 },
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;
*/
public bool deprecated { get; set; }
+ /**
+ * Hide the symbols marked as internal
+ */
+ public bool hide_internal { get; set; }
+
/**
* Do not warn when using experimental features.
*/