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



Author: walters
Date: Mon Aug 25 15:22:39 2008
New Revision: 492
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=492&view=rev

Log:
2008-08-25  Colin Walters  <walters verbum org>

	* girepository/girparser.c: Parse new implements
	syntax, drop gapi one.
	* tests/object.gir: Update.
	* tools/generate.c: Generate new syntax.


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

Modified: trunk/girepository/girparser.c
==============================================================================
--- trunk/girepository/girparser.c	(original)
+++ trunk/girepository/girparser.c	Mon Aug 25 15:22:39 2008
@@ -1532,6 +1532,36 @@
 }
 
 static gboolean
+start_implements (GMarkupParseContext *context,
+		  const gchar         *element_name,
+		  const gchar        **attribute_names,
+		  const gchar        **attribute_values,
+		  ParseContext       *ctx,
+		  GError             **error)
+{
+  GIrNodeInterface *iface;
+  const char *name;
+
+  if (strcmp (element_name, "implements") != 0 ||
+      !(ctx->state == STATE_CLASS))
+    return FALSE;
+
+  state_switch (ctx, STATE_IMPLEMENTS);
+  
+  name = find_attribute ("name", attribute_names, attribute_values);
+  if (name == NULL)
+    {
+      MISSING_ATTRIBUTE (context, error, element_name, "name");
+      return FALSE;
+    }
+      
+  iface = (GIrNodeInterface *)ctx->current_node;
+  iface->interfaces = g_list_append (iface->interfaces, g_strdup (name));
+
+  return TRUE;
+}
+
+static gboolean
 start_glib_signal (GMarkupParseContext *context,
 		   const gchar         *element_name,
 		   const gchar        **attribute_names,
@@ -1947,51 +1977,10 @@
 			   attribute_names, attribute_values,
 			   ctx, error))
 	goto out;
-      if (strcmp (element_name, "implements") == 0 &&
-	  ctx->state == STATE_CLASS)
-	{
-	  state_switch (ctx, STATE_IMPLEMENTS);
-
-	  goto out;
-	}
-      else if (strcmp (element_name, "interface") == 0 &&
-	       ctx->state == STATE_IMPLEMENTS)
-	{
-	  const gchar *name;
-
-	  name = find_attribute ("name", attribute_names, attribute_values);
-
-	  if (name == NULL)
-	    MISSING_ATTRIBUTE (context, error, element_name, "name");
-	  else
-	    {  
-	      GIrNodeInterface *iface;
-
-	      iface = (GIrNodeInterface *)ctx->current_node;
-	      iface ->interfaces = g_list_append (iface->interfaces, g_strdup (name));
-	    }
-
-	  goto out;
-	}
-      else if (strcmp (element_name, "interface") == 0 &&
-	       ctx->state == STATE_REQUIRES)
-	{
-	  const gchar *name;
-
-	  name = find_attribute ("name", attribute_names, attribute_values);
-
-	  if (name == NULL)
-	    MISSING_ATTRIBUTE (context, error, element_name, "name");
-	  else
-	    {  
-	      GIrNodeInterface *iface;
-
-	      iface = (GIrNodeInterface *)ctx->current_node;
-	      iface ->prerequisites = g_list_append (iface->prerequisites, g_strdup (name));
-	    }
-
-	  goto out;
-	}
+      else if (start_implements (context, element_name,
+				 attribute_names, attribute_values,
+				 ctx, error))
+	goto out;
       break;
 
     case 'm':

Modified: trunk/tests/object.gir
==============================================================================
--- trunk/tests/object.gir	(original)
+++ trunk/tests/object.gir	Mon Aug 25 15:22:39 2008
@@ -4,10 +4,10 @@
             xmlns:c="http://www.gtk.org/introspection/c/1.0";
             xmlns:glib="http://www.gtk.org/introspection/glib/1.0";>
   <namespace name="Foo">
+    <interface name="IFace1" glib:type-name="IFace1" glib:get-type="iface1_get_type">
+    </interface>
     <class name="Object1" parent="Object2" glib:type-name="Object1" glib:get-type="object1_get_type">
-      <implements>
-        <interface name="Iface1" />
-      </implements>
+      <implements name="IFace1" />
       <property name="prop1" readable="0" writable="0">
         <type name="int"/>
       </property>

Modified: trunk/tools/generate.c
==============================================================================
--- trunk/tools/generate.c	(original)
+++ trunk/tools/generate.c	Mon Aug 25 15:22:39 2008
@@ -787,16 +787,14 @@
 
   if (g_object_info_get_n_interfaces (info) > 0)
     {
-      g_fprintf (file, "      <implements>\n");
       for (i = 0; i < g_object_info_get_n_interfaces (info); i++)
 	{
 	  GIInterfaceInfo *imp = g_object_info_get_interface (info, i);
-	  g_fprintf (file, "        <interface name=\"");
+	  g_fprintf (file, "      <implements name=\"");
 	  write_type_name (namespace, (GIBaseInfo*)imp, file);
 	  g_fprintf (file,"\" />\n");
 	  g_base_info_unref ((GIBaseInfo*)imp);
 	}
-      g_fprintf (file, "      </implements>\n");
     }
 
   for (i = 0; i < g_object_info_get_n_fields (info); i++)



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