mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Add an option to make glib-compile-resources use G_GNUC_INTERNAL
https://bugzilla.gnome.org/show_bug.cgi?id=687742
This commit is contained in:
parent
138f4c1e2f
commit
8caf39b59b
@ -147,6 +147,19 @@ can manually call at initialization and uninitialization time.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--internal</option></term>
|
||||
<listitem><para>
|
||||
By default code generated by <option>--generate-source</option> declares all
|
||||
initialization functions as <type>extern</type>. So they are exported
|
||||
unless this is prevented by a link script or other means. Since libraries
|
||||
usually want to use the functions only internally it can be more useful to
|
||||
declare them as
|
||||
<link linkend="G-GNUC-INTERNAL:CAPS"><literal>G_GNUC_INTERNAL</literal></link>
|
||||
which is what <option>--internal</option> does.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@ -605,9 +605,11 @@ main (int argc, char **argv)
|
||||
gboolean generate_source = FALSE;
|
||||
gboolean generate_header = FALSE;
|
||||
gboolean manual_register = FALSE;
|
||||
gboolean internal = FALSE;
|
||||
gboolean generate_dependencies = FALSE;
|
||||
char *c_name = NULL;
|
||||
char *c_name_no_underscores;
|
||||
const char *linkage = "extern";
|
||||
GOptionContext *context;
|
||||
GOptionEntry entries[] = {
|
||||
{ "target", 0, 0, G_OPTION_ARG_FILENAME, &target, N_("name of the output file"), N_("FILE") },
|
||||
@ -617,6 +619,7 @@ main (int argc, char **argv)
|
||||
{ "generate-source", 0, 0, G_OPTION_ARG_NONE, &generate_source, N_("Generate sourcecode used to link in the resource file into your code"), NULL },
|
||||
{ "generate-dependencies", 0, 0, G_OPTION_ARG_NONE, &generate_dependencies, N_("Generate dependency list"), NULL },
|
||||
{ "manual-register", 0, 0, G_OPTION_ARG_NONE, &manual_register, N_("Don't automatically create and register resource"), NULL },
|
||||
{ "internal", 0, 0, G_OPTION_ARG_NONE, &internal, N_("Don't export functions; declare them G_GNUC_INTERNAL"), NULL },
|
||||
{ "c-name", 0, 0, G_OPTION_ARG_STRING, &c_name, N_("C identifier name used for the generated source code"), NULL },
|
||||
{ NULL }
|
||||
};
|
||||
@ -664,6 +667,9 @@ main (int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (internal)
|
||||
linkage = "G_GNUC_INTERNAL";
|
||||
|
||||
srcfile = argv[1];
|
||||
|
||||
xmllint = g_strdup (g_getenv ("XMLLINT"));
|
||||
@ -805,16 +811,16 @@ main (int argc, char **argv)
|
||||
"\n"
|
||||
"#include <gio/gio.h>\n"
|
||||
"\n"
|
||||
"extern GResource *%s_get_resource (void);\n",
|
||||
c_name, c_name, c_name);
|
||||
"%s GResource *%s_get_resource (void);\n",
|
||||
c_name, c_name, linkage, c_name);
|
||||
|
||||
if (manual_register)
|
||||
fprintf (file,
|
||||
"\n"
|
||||
"extern void %s_register_resource (void);\n"
|
||||
"extern void %s_unregister_resource (void);\n"
|
||||
"%s void %s_register_resource (void);\n"
|
||||
"%s void %s_unregister_resource (void);\n"
|
||||
"\n",
|
||||
c_name, c_name);
|
||||
linkage, c_name, linkage, c_name);
|
||||
|
||||
fprintf (file,
|
||||
"#endif\n");
|
||||
@ -870,30 +876,30 @@ main (int argc, char **argv)
|
||||
fprintf (file,
|
||||
"\n"
|
||||
"static GStaticResource static_resource = { %s_resource_data.data, sizeof (%s_resource_data.data) };\n"
|
||||
"extern GResource *%s_get_resource (void);\n"
|
||||
"%s GResource *%s_get_resource (void);\n"
|
||||
"GResource *%s_get_resource (void)\n"
|
||||
"{\n"
|
||||
" return g_static_resource_get_resource (&static_resource);\n"
|
||||
"}\n",
|
||||
c_name, c_name, c_name, c_name);
|
||||
c_name, c_name, linkage, c_name, c_name);
|
||||
|
||||
|
||||
if (manual_register)
|
||||
{
|
||||
fprintf (file,
|
||||
"\n"
|
||||
"extern void %s_unregister_resource (void);\n"
|
||||
"%s void %s_unregister_resource (void);\n"
|
||||
"void %s_unregister_resource (void)\n"
|
||||
"{\n"
|
||||
" g_static_resource_fini (&static_resource);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"extern void %s_register_resource (void);\n"
|
||||
"%s void %s_register_resource (void);\n"
|
||||
"void %s_register_resource (void)\n"
|
||||
"{\n"
|
||||
" g_static_resource_init (&static_resource);\n"
|
||||
"}\n",
|
||||
c_name, c_name, c_name, c_name);
|
||||
linkage, c_name, c_name, linkage, c_name, c_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user