mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Add --all option to g-ir-generate
Add --all option, which is intended to show some information not usually included in the GIR. Currently, it shows the size of structs and unions. Signed-off-by: Andreas Rottmann <a.rottmann@gmx.at>
This commit is contained in:
parent
cd2dcdf1f4
commit
ae73e2e4e6
@ -32,6 +32,7 @@
|
|||||||
/* FIXME: Avoid global */
|
/* FIXME: Avoid global */
|
||||||
static gchar *output = NULL;
|
static gchar *output = NULL;
|
||||||
gchar **includedirs = NULL;
|
gchar **includedirs = NULL;
|
||||||
|
static gboolean show_all = FALSE;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FILE *file;
|
FILE *file;
|
||||||
@ -365,6 +366,12 @@ write_field_info (const gchar *namespace,
|
|||||||
xml_printf (file, "\"");
|
xml_printf (file, "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (show_all)
|
||||||
|
{
|
||||||
|
if (offset >= 0)
|
||||||
|
xml_printf (file, "offset=\"%d\"", offset);
|
||||||
|
}
|
||||||
|
|
||||||
write_type_info (namespace, type, file);
|
write_type_info (namespace, type, file);
|
||||||
g_base_info_unref ((GIBaseInfo *)type);
|
g_base_info_unref ((GIBaseInfo *)type);
|
||||||
|
|
||||||
@ -568,6 +575,7 @@ write_struct_info (const gchar *namespace,
|
|||||||
gboolean deprecated;
|
gboolean deprecated;
|
||||||
gboolean is_gtype_struct;
|
gboolean is_gtype_struct;
|
||||||
gint i;
|
gint i;
|
||||||
|
gint size;
|
||||||
int n_elts;
|
int n_elts;
|
||||||
|
|
||||||
name = g_base_info_get_name ((GIBaseInfo *)info);
|
name = g_base_info_get_name ((GIBaseInfo *)info);
|
||||||
@ -597,6 +605,10 @@ write_struct_info (const gchar *namespace,
|
|||||||
if (is_gtype_struct)
|
if (is_gtype_struct)
|
||||||
xml_printf (file, " glib:is-gtype-struct=\"1\"");
|
xml_printf (file, " glib:is-gtype-struct=\"1\"");
|
||||||
|
|
||||||
|
size = g_struct_info_get_size (info);
|
||||||
|
if (show_all && size >= 0)
|
||||||
|
xml_printf (file, " size=\"%d\"", size);
|
||||||
|
|
||||||
n_elts = g_struct_info_get_n_fields (info) + g_struct_info_get_n_methods (info);
|
n_elts = g_struct_info_get_n_fields (info) + g_struct_info_get_n_methods (info);
|
||||||
if (n_elts > 0)
|
if (n_elts > 0)
|
||||||
{
|
{
|
||||||
@ -1113,6 +1125,7 @@ write_union_info (const gchar *namespace,
|
|||||||
const gchar *type_init;
|
const gchar *type_init;
|
||||||
gboolean deprecated;
|
gboolean deprecated;
|
||||||
gint i;
|
gint i;
|
||||||
|
gint size;
|
||||||
|
|
||||||
name = g_base_info_get_name ((GIBaseInfo *)info);
|
name = g_base_info_get_name ((GIBaseInfo *)info);
|
||||||
deprecated = g_base_info_is_deprecated ((GIBaseInfo *)info);
|
deprecated = g_base_info_is_deprecated ((GIBaseInfo *)info);
|
||||||
@ -1129,6 +1142,9 @@ write_union_info (const gchar *namespace,
|
|||||||
if (deprecated)
|
if (deprecated)
|
||||||
xml_printf (file, " deprecated=\"1\"");
|
xml_printf (file, " deprecated=\"1\"");
|
||||||
|
|
||||||
|
size = g_union_info_get_size (info);
|
||||||
|
if (show_all && size >= 0)
|
||||||
|
xml_printf (file, " size=\"%d\"", size);
|
||||||
|
|
||||||
if (g_union_info_is_discriminated (info))
|
if (g_union_info_is_discriminated (info))
|
||||||
{
|
{
|
||||||
@ -1349,7 +1365,8 @@ main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
{ "shlib", 0, 0, G_OPTION_ARG_NONE, &shlib, "handle typelib embedded in shlib", NULL },
|
{ "shlib", 0, 0, G_OPTION_ARG_NONE, &shlib, "handle typelib embedded in shlib", NULL },
|
||||||
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" },
|
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" },
|
||||||
{ "includedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &includedirs, "include directories in GIR search path", NULL },
|
{ "includedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &includedirs, "include directories in GIR search path", NULL },
|
||||||
|
{ "all", 0, 0, G_OPTION_ARG_NONE, &show_all, "show all available information", NULL, },
|
||||||
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
|
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
|
||||||
{ NULL, }
|
{ NULL, }
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user