mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 08:22:16 +01:00 
			
		
		
		
	Bug 556174 – parse types for lists etc.
2008-10-15 Tommi Komulainen <tommi.komulainen@iki.fi> 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 <type>s for lists and hashes svn path=/trunk/; revision=717
This commit is contained in:
		
				
					committed by
					
						 Philip Withnall
						Philip Withnall
					
				
			
			
				
	
			
			
			
						parent
						
							b870ad079d
						
					
				
				
					commit
					65a653d3a9
				
			| @@ -192,97 +192,112 @@ write_type_info (const gchar *namespace, | |||||||
|  |  | ||||||
|   if (tag == GI_TYPE_TAG_VOID)  |   if (tag == GI_TYPE_TAG_VOID)  | ||||||
|     { |     { | ||||||
|       if (is_pointer) |       xml_start_element (file, "type"); | ||||||
| 	xml_printf (file, "%s", "any"); |  | ||||||
|       else |       xml_printf (file, " name=\"%s\"", is_pointer ? "any" : "none"); | ||||||
| 	xml_printf (file, "%s", "none"); |  | ||||||
|  |       xml_end_element (file, "type"); | ||||||
|     }  |     }  | ||||||
|   else if (G_TYPE_TAG_IS_BASIC (tag)) |   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) |   else if (tag == GI_TYPE_TAG_ARRAY) | ||||||
|     { |     { | ||||||
|       gint length; |       gint length; | ||||||
|  |  | ||||||
|  |       xml_start_element (file, "array"); | ||||||
|  |  | ||||||
|       type = g_type_info_get_param_type (info, 0); |       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); |       length = g_type_info_get_array_length (info); | ||||||
|        |        | ||||||
|       if (length >= 0) |       if (length >= 0) | ||||||
| 	xml_printf (file, "length=%d", length); | 	xml_printf (file, " length=\"%d\"", length); | ||||||
|        |        | ||||||
|       if (g_type_info_is_zero_terminated (info)) |       if (g_type_info_is_zero_terminated (info)) | ||||||
| 	xml_printf (file, "%szero-terminated=1", length >= 0 ? "," : ""); | 	xml_printf (file, " zero-terminated=\"1\""); | ||||||
|        |  | ||||||
|      xml_printf (file, "]"); |       write_type_info (namespace, type, file); | ||||||
|  |  | ||||||
|       g_base_info_unref ((GIBaseInfo *)type); |       g_base_info_unref ((GIBaseInfo *)type); | ||||||
|  |  | ||||||
|  |       xml_end_element (file, "array"); | ||||||
|     } |     } | ||||||
|   else if (tag == GI_TYPE_TAG_INTERFACE) |   else if (tag == GI_TYPE_TAG_INTERFACE) | ||||||
|     { |     { | ||||||
|       GIBaseInfo *iface = g_type_info_get_interface (info); |       GIBaseInfo *iface = g_type_info_get_interface (info); | ||||||
|  |       xml_start_element (file, "type"); | ||||||
|  |       xml_printf (file, " name=\""); | ||||||
|       write_type_name (namespace, iface, file); |       write_type_name (namespace, iface, file); | ||||||
|  |       xml_printf (file, "\""); | ||||||
|  |       xml_end_element (file, "type"); | ||||||
|       g_base_info_unref (iface); |       g_base_info_unref (iface); | ||||||
|     } |     } | ||||||
|   else if (tag == GI_TYPE_TAG_GLIST) |   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); |       type = g_type_info_get_param_type (info, 0); | ||||||
|       xml_printf (file, "GLib.List"); |  | ||||||
|       if (type) |       if (type) | ||||||
| 	{ | 	{ | ||||||
| 	  xml_printf (file, "<"); |  | ||||||
| 	  write_type_info (namespace, type, file); | 	  write_type_info (namespace, type, file); | ||||||
| 	  xml_printf (file, ">"); |  | ||||||
| 	  g_base_info_unref ((GIBaseInfo *)type); | 	  g_base_info_unref ((GIBaseInfo *)type); | ||||||
| 	} | 	} | ||||||
|  |       xml_end_element (file, "type"); | ||||||
|     } |     } | ||||||
|   else if (tag == GI_TYPE_TAG_GSLIST) |   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); |       type = g_type_info_get_param_type (info, 0); | ||||||
|       xml_printf (file, "GLib.SList"); |  | ||||||
|       if (type) |       if (type) | ||||||
| 	{ | 	{ | ||||||
| 	  xml_printf (file, "<"); |  | ||||||
| 	  write_type_info (namespace, type, file); | 	  write_type_info (namespace, type, file); | ||||||
| 	  xml_printf (file, ">"); |  | ||||||
| 	  g_base_info_unref ((GIBaseInfo *)type); | 	  g_base_info_unref ((GIBaseInfo *)type); | ||||||
| 	} | 	} | ||||||
|  |       xml_end_element (file, "type"); | ||||||
|     } |     } | ||||||
|   else if (tag == GI_TYPE_TAG_GHASH) |   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); |       type = g_type_info_get_param_type (info, 0); | ||||||
|       xml_printf (file, "GLib.HashTable"); |  | ||||||
|       if (type) |       if (type) | ||||||
| 	{ | 	{ | ||||||
| 	  xml_printf (file, "<"); |  | ||||||
| 	  write_type_info (namespace, type, file); | 	  write_type_info (namespace, type, file); | ||||||
| 	  g_base_info_unref ((GIBaseInfo *)type); | 	  g_base_info_unref ((GIBaseInfo *)type); | ||||||
| 	  type = g_type_info_get_param_type (info, 1); | 	  type = g_type_info_get_param_type (info, 1); | ||||||
| 	  xml_printf (file, ","); |  | ||||||
| 	  write_type_info (namespace, type, file); | 	  write_type_info (namespace, type, file); | ||||||
| 	  xml_printf (file, ">"); |  | ||||||
| 	  g_base_info_unref ((GIBaseInfo *)type); | 	  g_base_info_unref ((GIBaseInfo *)type); | ||||||
| 	} | 	} | ||||||
|  |       xml_end_element (file, "type"); | ||||||
|     } |     } | ||||||
|   else if (tag == GI_TYPE_TAG_ERROR)  |   else if (tag == GI_TYPE_TAG_ERROR)  | ||||||
|     { |     { | ||||||
|       gint n; |       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); |       n = g_type_info_get_n_error_domains (info); | ||||||
|       if (n > 0) |       if (n > 0) | ||||||
| 	{ | 	{ | ||||||
| 	  xml_printf (file, "<"); |  | ||||||
| 	  for (i = 0; i < n; i++) | 	  for (i = 0; i < n; i++) | ||||||
| 	    { | 	    { | ||||||
| 	      GIErrorDomainInfo *ed = g_type_info_get_error_domain (info, i); | 	      GIErrorDomainInfo *ed = g_type_info_get_error_domain (info, i); | ||||||
| 	      if (i > 0) | 	      xml_start_element (file, "type"); | ||||||
| 		xml_printf (file, ","); | 	      xml_printf (file, " name=\""); | ||||||
| 	      write_type_name (namespace, (GIBaseInfo *)ed, file); | 	      write_type_name (namespace, (GIBaseInfo *)ed, file); | ||||||
|  | 	      xml_printf (file, "\""); | ||||||
|  | 	      xml_end_element (file, "type"); | ||||||
| 	      g_base_info_unref ((GIBaseInfo *)ed); | 	      g_base_info_unref ((GIBaseInfo *)ed); | ||||||
| 	    } | 	    } | ||||||
| 	  xml_printf (file, ">"); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  |       xml_end_element (file, "type"); | ||||||
|     } |     } | ||||||
|   else |   else | ||||||
|     { |     { | ||||||
| @@ -336,17 +351,9 @@ write_field_info (const gchar *namespace, | |||||||
|       xml_printf (file, "\""); |       xml_printf (file, "\""); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   xml_start_element (file, "type"); |  | ||||||
|  |  | ||||||
|   xml_printf (file, " name=\""); |  | ||||||
|  |  | ||||||
|   write_type_info (namespace, type, file); |   write_type_info (namespace, type, file); | ||||||
|   g_base_info_unref ((GIBaseInfo *)type); |   g_base_info_unref ((GIBaseInfo *)type); | ||||||
|  |  | ||||||
|   xml_printf (file, "\""); |  | ||||||
|  |  | ||||||
|   xml_end_element (file, "type"); |  | ||||||
|  |  | ||||||
|   xml_end_element (file, "field"); |   xml_end_element (file, "field"); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -382,16 +389,8 @@ write_callable_info (const gchar    *namespace, | |||||||
|   if (g_callable_info_may_return_null (info)) |   if (g_callable_info_may_return_null (info)) | ||||||
|     xml_printf (file, " null-ok=\"1\""); |     xml_printf (file, " null-ok=\"1\""); | ||||||
|  |  | ||||||
|   xml_start_element (file, "type"); |  | ||||||
|  |  | ||||||
|   xml_printf (file, " name=\""); |  | ||||||
|  |  | ||||||
|   write_type_info (namespace, type, file); |   write_type_info (namespace, type, file); | ||||||
|  |  | ||||||
|   xml_printf (file, "\""); |  | ||||||
|  |  | ||||||
|   xml_end_element (file, "type"); |  | ||||||
|  |  | ||||||
|   xml_end_element (file, "return-value"); |   xml_end_element (file, "return-value"); | ||||||
| 	 | 	 | ||||||
|   if (g_callable_info_get_n_args (info) <= 0) |   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)) |       if (g_arg_info_is_optional (arg)) | ||||||
| 	xml_printf (file, " optional=\"1\""); | 	xml_printf (file, " optional=\"1\""); | ||||||
|        |        | ||||||
|       xml_start_element (file, "type"); |  | ||||||
|        |  | ||||||
|       xml_printf (file, " name=\""); |  | ||||||
|  |  | ||||||
|       type = g_arg_info_get_type (arg); |       type = g_arg_info_get_type (arg); | ||||||
|       write_type_info (namespace, type, file); |       write_type_info (namespace, type, file); | ||||||
|  |  | ||||||
|       xml_printf (file, "\""); |  | ||||||
|  |  | ||||||
|       xml_end_element (file, "type"); |  | ||||||
|  |  | ||||||
|       xml_end_element (file, "parameter"); |       xml_end_element (file, "parameter"); | ||||||
|  |  | ||||||
|       g_base_info_unref ((GIBaseInfo *)arg); |       g_base_info_unref ((GIBaseInfo *)arg); | ||||||
| @@ -697,13 +688,7 @@ write_constant_info (const gchar    *namespace, | |||||||
|   write_constant_value (namespace, type, &value, file); |   write_constant_value (namespace, type, &value, file); | ||||||
|   xml_printf (file, "\""); |   xml_printf (file, "\""); | ||||||
|  |  | ||||||
|   xml_start_element (file, "type"); |  | ||||||
|   xml_printf (file, " name=\""); |  | ||||||
|  |  | ||||||
|   write_type_info (namespace, type, file); |   write_type_info (namespace, type, file); | ||||||
|   xml_printf (file, "\""); |  | ||||||
|  |  | ||||||
|   xml_end_element (file, "type"); |  | ||||||
|  |  | ||||||
|   xml_end_element (file, "constant"); |   xml_end_element (file, "constant"); | ||||||
|    |    | ||||||
| @@ -868,16 +853,8 @@ write_property_info (const gchar    *namespace, | |||||||
|      |      | ||||||
|   type = g_property_info_get_type (info); |   type = g_property_info_get_type (info); | ||||||
|  |  | ||||||
|   xml_start_element (file, "type"); |  | ||||||
|  |  | ||||||
|   xml_printf (file, " name=\""); |  | ||||||
|  |  | ||||||
|   write_type_info (namespace, type, file); |   write_type_info (namespace, type, file); | ||||||
|  |  | ||||||
|   xml_printf (file, "\""); |  | ||||||
|    |  | ||||||
|   xml_end_element (file, "type"); |  | ||||||
|  |  | ||||||
|   xml_end_element (file, "property"); |   xml_end_element (file, "property"); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user