mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Bug 571548 - Generic attributes
We now support an extensible mechanism where arbitrary key-value pairs may be associated with almost all items, including objects, methods, and properties. These attributes appear in both the .gir and the .typelib.
This commit is contained in:
parent
ae73e2e4e6
commit
43c682703c
@ -2,6 +2,7 @@
|
||||
/* GObject introspection: IDL generator
|
||||
*
|
||||
* Copyright (C) 2005 Matthias Clasen
|
||||
* Copyright (C) 2008,2009 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -317,6 +318,21 @@ write_type_info (const gchar *namespace,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
write_attributes (Xml *file,
|
||||
GIBaseInfo *info)
|
||||
{
|
||||
GIAttributeIter iter = { 0, };
|
||||
char *name, *value;
|
||||
|
||||
while (g_base_info_iterate_attributes (info, &iter, &name, &value))
|
||||
{
|
||||
xml_start_element (file, "attribute");
|
||||
xml_printf (file, " name=\"%s\" value=\"%s\"", name, value);
|
||||
xml_end_element (file, "attribute");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
write_constant_value (const gchar *namespace,
|
||||
GITypeInfo *info,
|
||||
@ -355,6 +371,8 @@ write_field_info (const gchar *namespace,
|
||||
if (size)
|
||||
xml_printf (file, " bits=\"%d\"", size);
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
type = g_field_info_get_type (info);
|
||||
|
||||
if (branch)
|
||||
@ -386,6 +404,8 @@ write_callable_info (const gchar *namespace,
|
||||
GITypeInfo *type;
|
||||
gint i;
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
type = g_callable_info_get_return_type (info);
|
||||
|
||||
xml_start_element (file, "return-value");
|
||||
@ -605,6 +625,8 @@ write_struct_info (const gchar *namespace,
|
||||
if (is_gtype_struct)
|
||||
xml_printf (file, " glib:is-gtype-struct=\"1\"");
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
size = g_struct_info_get_size (info);
|
||||
if (show_all && size >= 0)
|
||||
xml_printf (file, " size=\"%d\"", size);
|
||||
@ -650,6 +672,8 @@ write_value_info (const gchar *namespace,
|
||||
if (deprecated)
|
||||
xml_printf (file, " deprecated=\"1\"");
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
xml_end_element (file, "member");
|
||||
}
|
||||
|
||||
@ -746,6 +770,8 @@ write_constant_info (const gchar *namespace,
|
||||
|
||||
write_type_info (namespace, type, file);
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
xml_end_element (file, "constant");
|
||||
|
||||
g_base_info_unref ((GIBaseInfo *)type);
|
||||
@ -781,6 +807,7 @@ write_enum_info (const gchar *namespace,
|
||||
if (deprecated)
|
||||
xml_printf (file, " deprecated=\"1\"");
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
for (i = 0; i < g_enum_info_get_n_values (info); i++)
|
||||
{
|
||||
@ -903,6 +930,8 @@ write_property_info (const gchar *namespace,
|
||||
if (flags & G_PARAM_CONSTRUCT_ONLY)
|
||||
xml_printf (file, " construct-only=\"1\"");
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
type = g_property_info_get_type (info);
|
||||
|
||||
write_type_info (namespace, type, file);
|
||||
@ -955,6 +984,7 @@ write_object_info (const gchar *namespace,
|
||||
if (deprecated)
|
||||
xml_printf (file, " deprecated=\"1\"");
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
if (g_object_info_get_n_interfaces (info) > 0)
|
||||
{
|
||||
@ -1044,6 +1074,8 @@ write_interface_info (const gchar *namespace,
|
||||
if (deprecated)
|
||||
xml_printf (file, " deprecated=\"1\"");
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
if (g_interface_info_get_n_prerequisites (info) > 0)
|
||||
{
|
||||
for (i = 0; i < g_interface_info_get_n_prerequisites (info); i++)
|
||||
@ -1146,6 +1178,8 @@ write_union_info (const gchar *namespace,
|
||||
if (show_all && size >= 0)
|
||||
xml_printf (file, " size=\"%d\"", size);
|
||||
|
||||
write_attributes (file, (GIBaseInfo*) info);
|
||||
|
||||
if (g_union_info_is_discriminated (info))
|
||||
{
|
||||
gint offset;
|
||||
|
Loading…
Reference in New Issue
Block a user