From 65a653d3a9ef01065352e411bb447db53c625e20 Mon Sep 17 00:00:00 2001 From: Tommi Komulainen Date: Wed, 15 Oct 2008 22:08:26 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20556174=20=E2=80=93=20parse=20types=20for?= =?UTF-8?q?=20lists=20etc.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2008-10-15 Tommi Komulainen Bug 556174 – parse types for lists etc. * girepository/girparser.c (end_type_recurse): * tests/boxed.gir: * tools/generate.c (write_type_info, write_field_info, write_callable_info, write_callable_info, write_constant_info, write_property_info): use nested s for lists and hashes svn path=/trunk/; revision=717 --- girepository/tools/generate.c | 105 +++++++++++++--------------------- 1 file changed, 41 insertions(+), 64 deletions(-) diff --git a/girepository/tools/generate.c b/girepository/tools/generate.c index d4eb4e8eb..fb80138db 100644 --- a/girepository/tools/generate.c +++ b/girepository/tools/generate.c @@ -192,97 +192,112 @@ write_type_info (const gchar *namespace, if (tag == GI_TYPE_TAG_VOID) { - if (is_pointer) - xml_printf (file, "%s", "any"); - else - xml_printf (file, "%s", "none"); + xml_start_element (file, "type"); + + xml_printf (file, " name=\"%s\"", is_pointer ? "any" : "none"); + + xml_end_element (file, "type"); } else if (G_TYPE_TAG_IS_BASIC (tag)) - xml_printf (file, "%s", g_type_tag_to_string (tag)); + { + xml_start_element (file, "type"); + xml_printf (file, " name=\"%s\"", g_type_tag_to_string (tag)); + xml_end_element (file, "type"); + } else if (tag == GI_TYPE_TAG_ARRAY) { gint length; + xml_start_element (file, "array"); + type = g_type_info_get_param_type (info, 0); - write_type_info (namespace, type, file); - xml_printf (file, "["); length = g_type_info_get_array_length (info); if (length >= 0) - xml_printf (file, "length=%d", length); + xml_printf (file, " length=\"%d\"", length); if (g_type_info_is_zero_terminated (info)) - xml_printf (file, "%szero-terminated=1", length >= 0 ? "," : ""); - - xml_printf (file, "]"); + xml_printf (file, " zero-terminated=\"1\""); + + write_type_info (namespace, type, file); + g_base_info_unref ((GIBaseInfo *)type); + + xml_end_element (file, "array"); } else if (tag == GI_TYPE_TAG_INTERFACE) { GIBaseInfo *iface = g_type_info_get_interface (info); + xml_start_element (file, "type"); + xml_printf (file, " name=\""); write_type_name (namespace, iface, file); + xml_printf (file, "\""); + xml_end_element (file, "type"); g_base_info_unref (iface); } else if (tag == GI_TYPE_TAG_GLIST) { + xml_start_element (file, "type"); + xml_printf (file, " name=\"GLib.List\""); type = g_type_info_get_param_type (info, 0); - xml_printf (file, "GLib.List"); if (type) { - xml_printf (file, "<"); write_type_info (namespace, type, file); - xml_printf (file, ">"); g_base_info_unref ((GIBaseInfo *)type); } + xml_end_element (file, "type"); } else if (tag == GI_TYPE_TAG_GSLIST) { + xml_start_element (file, "type"); + xml_printf (file, " name=\"GLib.SList\""); type = g_type_info_get_param_type (info, 0); - xml_printf (file, "GLib.SList"); if (type) { - xml_printf (file, "<"); write_type_info (namespace, type, file); - xml_printf (file, ">"); g_base_info_unref ((GIBaseInfo *)type); } + xml_end_element (file, "type"); } else if (tag == GI_TYPE_TAG_GHASH) { + xml_start_element (file, "type"); + xml_printf (file, " name=\"GLib.HashTable\""); type = g_type_info_get_param_type (info, 0); - xml_printf (file, "GLib.HashTable"); if (type) { - xml_printf (file, "<"); write_type_info (namespace, type, file); g_base_info_unref ((GIBaseInfo *)type); type = g_type_info_get_param_type (info, 1); - xml_printf (file, ","); write_type_info (namespace, type, file); - xml_printf (file, ">"); g_base_info_unref ((GIBaseInfo *)type); } + xml_end_element (file, "type"); } else if (tag == GI_TYPE_TAG_ERROR) { gint n; - xml_printf (file, "GLib.Error"); + xml_start_element (file, "type"); + xml_printf (file, " name=\"GLib.Error\""); + n = g_type_info_get_n_error_domains (info); if (n > 0) { - xml_printf (file, "<"); for (i = 0; i < n; i++) { GIErrorDomainInfo *ed = g_type_info_get_error_domain (info, i); - if (i > 0) - xml_printf (file, ","); + xml_start_element (file, "type"); + xml_printf (file, " name=\""); write_type_name (namespace, (GIBaseInfo *)ed, file); + xml_printf (file, "\""); + xml_end_element (file, "type"); g_base_info_unref ((GIBaseInfo *)ed); } - xml_printf (file, ">"); } + + xml_end_element (file, "type"); } else { @@ -336,17 +351,9 @@ write_field_info (const gchar *namespace, xml_printf (file, "\""); } - xml_start_element (file, "type"); - - xml_printf (file, " name=\""); - write_type_info (namespace, type, file); g_base_info_unref ((GIBaseInfo *)type); - xml_printf (file, "\""); - - xml_end_element (file, "type"); - xml_end_element (file, "field"); } @@ -382,16 +389,8 @@ write_callable_info (const gchar *namespace, if (g_callable_info_may_return_null (info)) xml_printf (file, " null-ok=\"1\""); - xml_start_element (file, "type"); - - xml_printf (file, " name=\""); - write_type_info (namespace, type, file); - xml_printf (file, "\""); - - xml_end_element (file, "type"); - xml_end_element (file, "return-value"); if (g_callable_info_get_n_args (info) <= 0) @@ -447,17 +446,9 @@ write_callable_info (const gchar *namespace, if (g_arg_info_is_optional (arg)) xml_printf (file, " optional=\"1\""); - xml_start_element (file, "type"); - - xml_printf (file, " name=\""); - type = g_arg_info_get_type (arg); write_type_info (namespace, type, file); - xml_printf (file, "\""); - - xml_end_element (file, "type"); - xml_end_element (file, "parameter"); g_base_info_unref ((GIBaseInfo *)arg); @@ -697,13 +688,7 @@ write_constant_info (const gchar *namespace, write_constant_value (namespace, type, &value, file); xml_printf (file, "\""); - xml_start_element (file, "type"); - xml_printf (file, " name=\""); - write_type_info (namespace, type, file); - xml_printf (file, "\""); - - xml_end_element (file, "type"); xml_end_element (file, "constant"); @@ -868,16 +853,8 @@ write_property_info (const gchar *namespace, type = g_property_info_get_type (info); - xml_start_element (file, "type"); - - xml_printf (file, " name=\""); - write_type_info (namespace, type, file); - xml_printf (file, "\""); - - xml_end_element (file, "type"); - xml_end_element (file, "property"); }