gobject-introspection r717 - in trunk: . girepository tests tools



Author: tko
Date: Wed Oct 15 22:08:26 2008
New Revision: 717
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=717&view=rev

Log:
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

Modified:
   trunk/ChangeLog
   trunk/girepository/girparser.c
   trunk/tests/boxed.gir
   trunk/tools/generate.c

Modified: trunk/girepository/girparser.c
==============================================================================
--- trunk/girepository/girparser.c	(original)
+++ trunk/girepository/girparser.c	Wed Oct 15 22:08:26 2008
@@ -1607,30 +1607,33 @@
 {
   GList *types;
   GIrNodeType *parent;
+  GIrNodeType *param = NULL;
 
   parent = (GIrNodeType *) ((GList*)ctx->type_stack->data)->data;
+  if (ctx->type_parameters)
+    param = (GIrNodeType *) ctx->type_parameters->data;
 
   if (parent->tag == GI_TYPE_TAG_ARRAY ||
       parent->tag == GI_TYPE_TAG_GLIST ||
       parent->tag == GI_TYPE_TAG_GSLIST)
     {
-      if (ctx->type_parameters == NULL)
-	parent->parameter_type1 = parse_type (ctx, "pointer");
+      g_assert (param != NULL);
+
+      if (parent->parameter_type1 == NULL)
+        parent->parameter_type1 = param;
       else
-	parent->parameter_type1 = (GIrNodeType*)ctx->type_parameters->data;
+        g_assert_not_reached ();
     }
   else if (parent->tag == GI_TYPE_TAG_GHASH)
     {
-      if (ctx->type_parameters == NULL)
-	{
-	  parent->parameter_type1 = parse_type (ctx, "pointer");
-	  parent->parameter_type2 = parse_type (ctx, "pointer");
-	}
+      g_assert (param != NULL);
+
+      if (parent->parameter_type1 == NULL)
+        parent->parameter_type1 = param;
+      else if (parent->parameter_type2 == NULL)
+        parent->parameter_type2 = param;
       else
-	{
-	  parent->parameter_type1 = (GIrNodeType*) ctx->type_parameters->data;
-	  parent->parameter_type2 = (GIrNodeType*) ctx->type_parameters->next->data;
-	}
+        g_assert_not_reached ();
     }
   g_list_free (ctx->type_parameters);
   ctx->type_parameters = (GList *)ctx->type_stack->data;

Modified: trunk/tests/boxed.gir
==============================================================================
--- trunk/tests/boxed.gir	(original)
+++ trunk/tests/boxed.gir	Wed Oct 15 22:08:26 2008
@@ -23,10 +23,15 @@
             <type name="BoxedType1"/>
           </parameter>
           <parameter name="w" direction="in">
-            <type name="GLib.List<boxed2>"/>
+            <type name="GLib.List">
+              <type name="boxed2"/>
+            </type>
           </parameter>
           <parameter name="t" transfer="full" direction="in">
-            <type name="GLib.HashTable<utf8,int64>"/>
+            <type name="GLib.HashTable">
+              <type name="utf8"/>
+              <type name="int64"/>
+            </type>
           </parameter>
           <parameter name="e" transfer="full" direction="out">
             <type name="GLib.Error"/>

Modified: trunk/tools/generate.c
==============================================================================
--- trunk/tools/generate.c	(original)
+++ trunk/tools/generate.c	Wed Oct 15 22:08:26 2008
@@ -192,97 +192,112 @@
 
   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 @@
       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 @@
   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 @@
       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_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 @@
     
   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");
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]