dbus/glib dbus-gparser.c, 1.11, 1.12 dbus-glib-tool.c, 1.8, 1.9 dbus-gidl.h, 1.9, 1.10 dbus-gidl.c, 1.12, 1.13 dbus-binding-tool-glib.h, 1.1, 1.2 dbus-binding-tool-glib.c, 1.1, 1.2

Colin Walters walters at freedesktop.org
Thu Feb 17 13:11:20 PST 2005


Update of /cvs/dbus/dbus/glib
In directory gabe:/tmp/cvs-serv11714/glib

Modified Files:
	dbus-gparser.c dbus-glib-tool.c dbus-gidl.h dbus-gidl.c 
	dbus-binding-tool-glib.h dbus-binding-tool-glib.c 
Log Message:
2005-02-17  Colin Walters  <walters at verbum.org>

	* glib/dbus-gparser.c (struct Parser): Add in_annotation boolean.
	(parse_node, parse_interface, parse_method, parse_signal)
	(parse_property, parse_annotation): Lose if we're currently in an
	annotation.
	(parse_annotation): New function.
	(parser_start_element, parser_end_element): Handle annotation.
	(parse_method, parse_interface): Remove support for c_name attribute,
	switch to annotations.

	* glib/dbus-gidl.h (interface_info_get_binding_names)
	(method_info_get_binding_names)
	(interface_info_get_binding_name, method_info_get_binding_name)
	(interface_info_set_binding_name, method_info_set_binding_name):
	Remove.
	(interface_info_get_annotations, method_info_get_annotations)
	(interface_info_get_annotation, method_info_get_annotation)
	(interface_info_add_annotation, method_info_add_annotation):
	Prototype.

	* glib/dbus-gidl.c (struct InterfaceInfo): Substitute "annotations"
	for "bindings".
	(struct MethodInfo): Ditto.
	Straightfoward conversion of binding methods into annotation methods
	as prototyped.

	* glib/dbus-glib-tool.c (pretty_print): Print annotations.

	* glib/dbus-binding-tool-glib.h (DBUS_GLIB_ANNOTATION_C_SYMBOL): Define.

	* glib/dbus-binding-tool-glib.c (gather_marshallers, generate_glue):
	Use new annotation API.

	* doc/introspect.dtd: Fix a number of DTD syntax errors.  Add
	annotation element.
	
	* doc/dbus-specification.xml: Discuss introspection annotations,
	include list of well-known annotations.

	* test/glib/test-service-glib.xml: Make validate against new DTD.


Index: dbus-gparser.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gparser.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- dbus-gparser.c	17 Feb 2005 17:41:26 -0000	1.11
+++ dbus-gparser.c	17 Feb 2005 21:11:18 -0000	1.12
@@ -171,6 +171,7 @@
   SignalInfo *signal;
   PropertyInfo *property;
   ArgInfo *arg;
+  gboolean in_annotation;
 };
 
 Parser*
@@ -240,7 +241,8 @@
       parser->method ||
       parser->signal ||
       parser->property ||
-      parser->arg)
+      parser->arg ||
+      parser->in_annotation)
     {
       g_set_error (error, G_MARKUP_ERROR,
                    G_MARKUP_ERROR_PARSE,
@@ -308,7 +310,6 @@
                  GError     **error)
 {
   const char *name;
-  const char *c_name;
   InterfaceInfo *iface;
   NodeInfo *top;
   
@@ -317,6 +318,7 @@
       parser->signal ||
       parser->property ||
       parser->arg ||
+      parser->in_annotation ||
       (parser->node_stack == NULL))
     {
       g_set_error (error, G_MARKUP_ERROR,
@@ -330,7 +332,6 @@
   if (!locate_attributes (element_name, attribute_names,
                           attribute_values, error,
                           "name", &name,
-                          "c_name", &c_name,
                           NULL))
     return FALSE;
 
@@ -346,8 +347,6 @@
   top = parser->node_stack->data;
   
   iface = interface_info_new (name);
-  if (c_name)
-    interface_info_set_binding_name (iface, "C", c_name);
   node_info_add_interface (top, iface);
   interface_info_unref (iface);
 
@@ -364,7 +363,6 @@
               GError     **error)
 {
   const char *name;
-  const char *c_name;
   MethodInfo *method;
   NodeInfo *top;
   
@@ -373,6 +371,7 @@
       parser->method ||
       parser->signal ||
       parser->property ||
+      parser->in_annotation ||
       parser->arg)
     {
       g_set_error (error, G_MARKUP_ERROR,
@@ -386,7 +385,6 @@
   if (!locate_attributes (element_name, attribute_names,
                           attribute_values, error,
                           "name", &name,
-                          "c_name", &c_name,
                           NULL))
     return FALSE;
 
@@ -402,8 +400,6 @@
   top = parser->node_stack->data;
   
   method = method_info_new (name);
-  if (c_name)
-    method_info_set_binding_name (method, "C", c_name);
   interface_info_add_method (parser->interface, method);
   method_info_unref (method);
 
@@ -428,6 +424,7 @@
       parser->signal ||
       parser->method ||
       parser->property ||
+      parser->in_annotation ||
       parser->arg)
     {
       g_set_error (error, G_MARKUP_ERROR,
@@ -539,6 +536,7 @@
       parser->signal ||
       parser->method ||
       parser->property ||
+      parser->in_annotation ||
       parser->arg)
     {
       g_set_error (error, G_MARKUP_ERROR,
@@ -633,6 +631,7 @@
   if (!(parser->method || parser->signal) ||
       parser->node_stack == NULL ||
       parser->property ||
+      parser->in_annotation ||
       parser->arg)
     {
       g_set_error (error, G_MARKUP_ERROR,
@@ -724,6 +723,67 @@
   return TRUE;
 }
 
+static gboolean
+parse_annotation (Parser      *parser,
+		  const char  *element_name,
+		  const char **attribute_names,
+		  const char **attribute_values,
+		  GError     **error)
+{
+  const char *name;
+  const char *value;
+  
+  if (!(parser->method || parser->interface || parser->arg) || 
+      parser->node_stack == NULL ||
+      parser->signal ||
+      parser->in_annotation)
+    {
+      g_set_error (error, G_MARKUP_ERROR,
+                   G_MARKUP_ERROR_PARSE,
+                   _("Can't put <%s> element here"),
+                   element_name);
+      return FALSE;      
+    }
+
+  name = NULL;
+  if (!locate_attributes (element_name, attribute_names,
+                          attribute_values, error,
+                          "name", &name,
+                          "value", &value,
+                          NULL))
+    return FALSE;
+
+  /* name can be null for args */
+  
+  if (name == NULL)
+    {
+      g_set_error (error, G_MARKUP_ERROR,
+                   G_MARKUP_ERROR_PARSE,
+                   _("\"%s\" attribute required on <%s> element "),
+                   "name", element_name);
+      return FALSE;
+    }
+  if (value == NULL)
+    {
+      g_set_error (error, G_MARKUP_ERROR,
+                   G_MARKUP_ERROR_PARSE,
+                   _("\"%s\" attribute required on <%s> element "),
+                   "value", element_name);
+      return FALSE;
+    }
+
+  if (parser->method)
+    method_info_add_annotation (parser->method, name, value);
+  else if (parser->interface)
+    interface_info_add_annotation (parser->interface, name, value);
+  else
+    g_assert_not_reached ();
+
+  parser->in_annotation = TRUE;
+
+  return TRUE;
+}
+
 gboolean
 parser_start_element (Parser      *parser,
                       const char  *element_name,
@@ -769,6 +829,12 @@
                       attribute_values, error))
         return FALSE;
     }
+  else if (ELEMENT_IS ("annotation"))
+    {
+      if (!parse_annotation (parser, element_name, attribute_names,
+			     attribute_values, error))
+        return FALSE;
+    }
   else
     {
       g_set_error (error, G_MARKUP_ERROR,
@@ -807,6 +873,10 @@
     {
       parser->arg = NULL;
     }
+  else if (ELEMENT_IS ("annotation"))
+    {
+      parser->in_annotation = FALSE;
+    }
   else if (ELEMENT_IS ("node"))
     {
       NodeInfo *top;

Index: dbus-glib-tool.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-glib-tool.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- dbus-glib-tool.c	17 Feb 2005 17:41:26 -0000	1.8
+++ dbus-glib-tool.c	17 Feb 2005 21:11:18 -0000	1.9
@@ -107,22 +107,22 @@
     case INFO_TYPE_INTERFACE:
       {
         InterfaceInfo *i = (InterfaceInfo*) base;
-	GSList *binding_types, *elt;
+	GSList *annotations, *elt;
 
         g_assert (name != NULL);
 
         printf (_("interface \"%s\" {\n"), name);
 
-	binding_types = interface_info_get_binding_names (i);
-	for (elt = binding_types; elt; elt = elt->next)
+	annotations = interface_info_get_annotations (i);
+	for (elt = annotations; elt; elt = elt->next)
 	  {
-	    const char *binding_type = elt->data;
-	    const char *binding_name = interface_info_get_binding_name (i, binding_type);
+	    const char *name = elt->data;
+	    const char *value = interface_info_get_annotation (i, name);
 
 	    printf (_(" (binding \"%s\": \"%s\") "),
-		    binding_type, binding_name);
+		    name, value);
 	  }
-	g_slist_free (binding_types);
+	g_slist_free (annotations);
 
         pretty_print_list (interface_info_get_methods (i), depth + 1);
         pretty_print_list (interface_info_get_signals (i), depth + 1);
@@ -135,21 +135,21 @@
     case INFO_TYPE_METHOD:
       {
         MethodInfo *m = (MethodInfo*) base;
-	GSList *binding_types, *elt;
+	GSList *annotations, *elt;
 
         g_assert (name != NULL);
 
-	binding_types = method_info_get_binding_names (m);
+	annotations = method_info_get_annotations (m);
         printf (_("method \"%s\""), name);
-	for (elt = binding_types; elt; elt = elt->next)
+	for (elt = annotations; elt; elt = elt->next)
 	  {
-	    const char *binding_type = elt->data;
-	    const char *binding_name = method_info_get_binding_name (m, binding_type);
+	    const char *name = elt->data;
+	    const char *value = method_info_get_annotation (m, name);
 
-	    printf (_(" (binding \"%s\": \"%s\") "),
-		    binding_type, binding_name);
+	    printf (_(" (annotation \"%s\": \"%s\") "),
+		    name, value);
 	  }
-	g_slist_free (binding_types);
+	g_slist_free (annotations);
 
         pretty_print_list (method_info_get_args (m), depth + 1);
 

Index: dbus-gidl.h
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gidl.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- dbus-gidl.h	17 Feb 2005 17:41:26 -0000	1.9
+++ dbus-gidl.h	17 Feb 2005 21:11:18 -0000	1.10
@@ -90,15 +90,15 @@
 InterfaceInfo*      interface_info_ref            (InterfaceInfo       *info);
 void                interface_info_unref          (InterfaceInfo       *info);
 const char*         interface_info_get_name       (InterfaceInfo       *info);
-GSList*             interface_info_get_binding_names(InterfaceInfo     *info);
-const char*         interface_info_get_binding_name(InterfaceInfo*info,
-						    const char         *binding_type);
+GSList*             interface_info_get_annotations(InterfaceInfo       *info);
+const char*         interface_info_get_annotation (InterfaceInfo*info,
+						   const char         *annotation);
 GSList*             interface_info_get_methods    (InterfaceInfo       *info);
 GSList*             interface_info_get_signals    (InterfaceInfo       *info);
 GSList*             interface_info_get_properties (InterfaceInfo       *info);
-void                interface_info_set_binding_name(InterfaceInfo      *info,
-						    const char         *name,
-						    const char         *value);
+void                interface_info_add_annotation (InterfaceInfo      *info,
+						   const char         *name,
+						   const char         *value);
 void                interface_info_add_method     (InterfaceInfo       *info,
                                                    MethodInfo          *method);
 void                interface_info_add_signal     (InterfaceInfo       *info,
@@ -109,12 +109,12 @@
 MethodInfo*         method_info_ref               (MethodInfo          *info);
 void                method_info_unref             (MethodInfo          *info);
 const char*         method_info_get_name          (MethodInfo          *info);
-GSList*             method_info_get_binding_names (MethodInfo          *info);
-const char*         method_info_get_binding_name  (MethodInfo          *info,
-						   const char          *binding_type);
-void                method_info_set_binding_name  (MethodInfo          *info,
-						   const char          *binding_type,
-						   const char          *bound_name);
+GSList*             method_info_get_annotations   (MethodInfo          *info);
+const char*         method_info_get_annotation    (MethodInfo          *info,
+						   const char          *annotation);
+void                method_info_add_annotation    (MethodInfo          *info,
+						   const char          *name,
+						   const char          *value);
 GSList*             method_info_get_args          (MethodInfo          *info);
 void                method_info_add_arg           (MethodInfo          *info,
                                                    ArgInfo             *arg);

Index: dbus-gidl.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gidl.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dbus-gidl.c	17 Feb 2005 17:41:26 -0000	1.12
+++ dbus-gidl.c	17 Feb 2005 21:11:18 -0000	1.13
@@ -43,7 +43,7 @@
 struct InterfaceInfo
 {
   BaseInfo base;
-  GHashTable *bindings;
+  GHashTable *annotations;
   /* Since we have BaseInfo now these could be one list */
   GSList *methods;
   GSList *signals;
@@ -53,7 +53,7 @@
 struct MethodInfo
 {
   BaseInfo base;
-  GHashTable *bindings;
+  GHashTable *annotations;
   GSList *args;
 };
 
@@ -345,9 +345,9 @@
   info->base.refcount = 1;
   info->base.name = g_strdup (name);
   info->base.type = INFO_TYPE_INTERFACE;
-  info->bindings = g_hash_table_new_full (g_str_hash, g_str_equal,
-					  (GDestroyNotify) g_free,
-					  (GDestroyNotify) g_free);
+  info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
+					     (GDestroyNotify) g_free,
+					     (GDestroyNotify) g_free);
   
   return info;
 }
@@ -366,7 +366,7 @@
   info->base.refcount -= 1;
   if (info->base.refcount == 0)
     {
-      g_hash_table_destroy (info->bindings);
+      g_hash_table_destroy (info->annotations);
       free_method_list (&info->methods);
       free_signal_list (&info->signals);
       free_property_list (&info->properties);
@@ -381,16 +381,16 @@
 }
 
 GSList *
-interface_info_get_binding_names (InterfaceInfo *info)
+interface_info_get_annotations (InterfaceInfo *info)
 {
-  return get_hash_keys (info->bindings);
+  return get_hash_keys (info->annotations);
 }
 
 const char*
-interface_info_get_binding_name (InterfaceInfo *info,
-				 const char    *binding_type)
+interface_info_get_annotation (InterfaceInfo *info,
+			       const char    *name)
 {
-  return g_hash_table_lookup (info->bindings, binding_type);
+  return g_hash_table_lookup (info->annotations, name);
 }
 
 GSList*
@@ -412,13 +412,13 @@
 }
 
 void
-interface_info_set_binding_name (InterfaceInfo *info,
-				 const char    *binding_type,
-				 const char    *bound_name)
+interface_info_add_annotation (InterfaceInfo *info,
+			       const char    *name,
+			       const char    *value)
 {
-  g_hash_table_insert (info->bindings,
-		       g_strdup (binding_type),
-		       g_strdup (bound_name));
+  g_hash_table_insert (info->annotations,
+		       g_strdup (name),
+		       g_strdup (value));
 }
 
 void
@@ -470,7 +470,7 @@
   info->base.refcount = 1;
   info->base.name = g_strdup (name);
   info->base.type = INFO_TYPE_METHOD;
-  info->bindings = g_hash_table_new_full (g_str_hash, g_str_equal,
+  info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
 					  (GDestroyNotify) g_free,
 					  (GDestroyNotify) g_free);
   
@@ -491,7 +491,7 @@
   info->base.refcount -= 1;
   if (info->base.refcount == 0)
     {
-      g_hash_table_destroy (info->bindings);
+      g_hash_table_destroy (info->annotations);
       free_arg_list (&info->args);
       base_info_free (info);
     }
@@ -504,16 +504,16 @@
 }
 
 GSList *
-method_info_get_binding_names (MethodInfo *info)
+method_info_get_annotations (MethodInfo *info)
 {
-  return get_hash_keys (info->bindings);
+  return get_hash_keys (info->annotations);
 }
 
 const char*
-method_info_get_binding_name (MethodInfo *info,
-			      const char *binding_type)
+method_info_get_annotation (MethodInfo *info,
+			    const char *name)
 {
-  return g_hash_table_lookup (info->bindings, binding_type);
+  return g_hash_table_lookup (info->annotations, name);
 }
 
 GSList*
@@ -544,13 +544,13 @@
 }                  
 
 void
-method_info_set_binding_name (MethodInfo  *info,
-			      const char  *binding_type,
-			      const char  *bound_name)
+method_info_add_annotation (MethodInfo  *info,
+			    const char  *name,
+			    const char  *value)
 {
-  g_hash_table_insert (info->bindings,
-		       g_strdup (binding_type),
-		       g_strdup (bound_name));
+  g_hash_table_insert (info->annotations,
+		       g_strdup (name),
+		       g_strdup (value));
 }
 
 void

Index: dbus-binding-tool-glib.h
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-binding-tool-glib.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbus-binding-tool-glib.h	17 Feb 2005 17:41:26 -0000	1.1
+++ dbus-binding-tool-glib.h	17 Feb 2005 21:11:18 -0000	1.2
@@ -25,6 +25,8 @@
 
 G_BEGIN_DECLS
 
+#define DBUS_GLIB_ANNOTATION_C_SYMBOL "org.freedesktop.DBus.GLib.CSymbol"
+
 gboolean dbus_binding_tool_output_glib_client (BaseInfo *info, GIOChannel *channel, GError **error);
 gboolean dbus_binding_tool_output_glib_server (BaseInfo *info, GIOChannel *channel, GError **error);
 

Index: dbus-binding-tool-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-binding-tool-glib.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbus-binding-tool-glib.c	17 Feb 2005 17:41:26 -0000	1.1
+++ dbus-binding-tool-glib.c	17 Feb 2005 21:11:18 -0000	1.2
@@ -201,7 +201,7 @@
       const char *interface_c_name;
 
       interface = (InterfaceInfo *) base;
-      interface_c_name = interface_info_get_binding_name (interface, "C");
+      interface_c_name = interface_info_get_annotation (interface, DBUS_GLIB_ANNOTATION_C_SYMBOL);
       if (interface_c_name == NULL)
         {
           return TRUE;
@@ -217,7 +217,7 @@
           char *marshaller_name;
 
           method = (MethodInfo *) tmp->data;
-          if (method_info_get_binding_name (method, "C") == NULL)
+          if (method_info_get_annotation (method, DBUS_GLIB_ANNOTATION_C_SYMBOL) == NULL)
             {
               continue;
             }
@@ -306,7 +306,7 @@
       channel = data->channel;
 
       interface = (InterfaceInfo *) base;
-      interface_c_name = interface_info_get_binding_name (interface, "C");
+      interface_c_name = interface_info_get_annotation (interface, DBUS_GLIB_ANNOTATION_C_SYMBOL);
       if (interface_c_name == NULL)
         {
           return TRUE;
@@ -319,7 +319,7 @@
 
       /* Table of marshalled methods. */
 
-      if (!write_printf_to_iochannel ("static const DBusGMethodInfo dbus_glib_%s_methods[] = {\n", channel, error, interface_info_get_binding_name (interface, "C")))
+      if (!write_printf_to_iochannel ("static const DBusGMethodInfo dbus_glib_%s_methods[] = {\n", channel, error, interface_info_get_annotation (interface, DBUS_GLIB_ANNOTATION_C_SYMBOL)))
 	goto io_lose;
       for (tmp = methods; tmp != NULL; tmp = g_slist_next (tmp))
         {
@@ -329,7 +329,7 @@
 	  GSList *args;
 
           method = (MethodInfo *) tmp->data;
-	  method_c_name = method_info_get_binding_name (method, "C");
+	  method_c_name = method_info_get_annotation (method, DBUS_GLIB_ANNOTATION_C_SYMBOL);
           if (method_c_name == NULL)
             {
               continue;



More information about the dbus-commit mailing list