diff options
author | Colin Walters <walters@verbum.org> | 2009-02-19 21:48:51 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2009-03-03 17:26:37 -0500 |
commit | d5215b23315e7c9c22c6a32218bb6f8027a9dd4c (patch) | |
tree | e8d9e360099c756677ad23a1039f4d05533008b9 /tools | |
parent | 2bdd2bf9303ae0e718c00ec84078336e722138f1 (diff) | |
download | gobject-introspection-d5215b23315e7c9c22c6a32218bb6f8027a9dd4c.tar.gz |
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.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/generate.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/tools/generate.c b/tools/generate.c index b95e0522..c4d72912 100644 --- a/tools/generate.c +++ b/tools/generate.c @@ -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 @@ -318,6 +319,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, GArgument *argument, @@ -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"); @@ -604,6 +624,8 @@ write_struct_info (const gchar *namespace, is_gtype_struct = g_struct_info_is_gtype_struct (info); 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) @@ -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); @@ -780,7 +806,8 @@ 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++) { @@ -902,7 +929,9 @@ 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); @@ -954,7 +983,8 @@ 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++) @@ -1141,11 +1173,13 @@ write_union_info (const gchar *namespace, if (deprecated) xml_printf (file, " deprecated=\"1\""); - + size = g_union_info_get_size (info); 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; |