sl@0: /* -*- mode: C; c-file-style: "gnu" -*- */
sl@0: /* dbus-gidl.c data structure describing an interface, to be generated from IDL
sl@0:  *             or something
sl@0:  *
sl@0:  * Copyright (C) 2003, 2005  Red Hat, Inc.
sl@0:  * Portion Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
sl@0:  * Licensed under the Academic Free License version 2.1
sl@0:  *
sl@0:  * This program is free software; you can redistribute it and/or modify
sl@0:  * it under the terms of the GNU General Public License as published by
sl@0:  * the Free Software Foundation; either version 2 of the License, or
sl@0:  * (at your option) any later version.
sl@0:  *
sl@0:  * This program is distributed in the hope that it will be useful,
sl@0:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
sl@0:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
sl@0:  * GNU General Public License for more details.
sl@0:  *
sl@0:  * You should have received a copy of the GNU General Public License
sl@0:  * along with this program; if not, write to the Free Software
sl@0:  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
sl@0:  *
sl@0:  */
sl@0: 
sl@0: #include "dbus-gidl.h"
sl@0: 
sl@0: #ifndef DOXYGEN_SHOULD_SKIP_THIS
sl@0: 
sl@0: struct BaseInfo
sl@0: {
sl@0:   unsigned int refcount : 28;
sl@0:   unsigned int type     : 4;
sl@0:   char *name;
sl@0: };
sl@0: 
sl@0: struct NodeInfo
sl@0: {
sl@0:   BaseInfo base;
sl@0:   GSList *interfaces;
sl@0:   GSList *nodes;
sl@0: };
sl@0: 
sl@0: struct InterfaceInfo
sl@0: {
sl@0:   BaseInfo base;
sl@0:   GHashTable *annotations;
sl@0:   /* Since we have BaseInfo now these could be one list */
sl@0:   GSList *methods;
sl@0:   GSList *signals;
sl@0:   GSList *properties;
sl@0: };
sl@0: 
sl@0: struct MethodInfo
sl@0: {
sl@0:   BaseInfo base;
sl@0:   GHashTable *annotations;
sl@0:   GSList *args;
sl@0: };
sl@0: 
sl@0: struct SignalInfo
sl@0: {
sl@0:   BaseInfo base;
sl@0:   GSList *args;
sl@0: };
sl@0: 
sl@0: struct PropertyInfo
sl@0: {
sl@0:   BaseInfo base;
sl@0:   char *type;
sl@0:   PropertyAccessFlags access;
sl@0: };
sl@0: 
sl@0: struct ArgInfo
sl@0: {
sl@0:   BaseInfo base;
sl@0:   char *type;
sl@0:   ArgDirection direction;
sl@0:   GHashTable *annotations;
sl@0: };
sl@0: 
sl@0: static void
sl@0: get_hash_key (gpointer key, gpointer value, gpointer data)
sl@0: {
sl@0:   GSList **list = data;
sl@0:   *list = g_slist_prepend (*list, key);
sl@0: }
sl@0: 
sl@0: static GSList *
sl@0: get_hash_keys (GHashTable *table)
sl@0: {
sl@0:   GSList *ret = NULL;
sl@0: 
sl@0:   g_hash_table_foreach (table, get_hash_key, &ret);
sl@0: 
sl@0:   return ret;
sl@0: }
sl@0: 
sl@0: BaseInfo *
sl@0: base_info_ref (BaseInfo *info)
sl@0: {
sl@0:   g_return_val_if_fail (info != NULL, NULL);
sl@0:   g_return_val_if_fail (info->refcount > 0, NULL);
sl@0:   
sl@0:   info->refcount += 1;
sl@0: 
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: static void
sl@0: base_info_free (void *ptr)
sl@0: {
sl@0:   BaseInfo *info;
sl@0: 
sl@0:   info = ptr;
sl@0:   
sl@0:   g_free (info->name);
sl@0:   g_free (info);
sl@0: }
sl@0: 
sl@0: void
sl@0: base_info_unref (BaseInfo *info)
sl@0: {
sl@0:   g_return_if_fail (info != NULL);
sl@0:   g_return_if_fail (info->refcount > 0);
sl@0:   
sl@0:   /* This is sort of bizarre, BaseInfo was tacked on later */
sl@0: 
sl@0:   switch (info->type)
sl@0:     {
sl@0:     case INFO_TYPE_NODE:
sl@0:       node_info_unref ((NodeInfo*) info);
sl@0:       break;
sl@0:     case INFO_TYPE_INTERFACE:
sl@0:       interface_info_unref ((InterfaceInfo*) info);
sl@0:       break;
sl@0:     case INFO_TYPE_SIGNAL:
sl@0:       signal_info_unref ((SignalInfo*) info);
sl@0:       break;
sl@0:     case INFO_TYPE_METHOD:
sl@0:       method_info_unref ((MethodInfo*) info);
sl@0:       break;
sl@0:     case INFO_TYPE_PROPERTY:
sl@0:       property_info_unref ((PropertyInfo*) info);
sl@0:       break;
sl@0:     case INFO_TYPE_ARG:
sl@0:       arg_info_unref ((ArgInfo*) info);
sl@0:       break;
sl@0:     }
sl@0: }
sl@0: 
sl@0: InfoType
sl@0: base_info_get_type (BaseInfo      *info)
sl@0: {
sl@0:   return info->type;
sl@0: }
sl@0: 
sl@0: const char*
sl@0: base_info_get_name (BaseInfo *info)
sl@0: {
sl@0:   return info->name;
sl@0: }
sl@0: 
sl@0: void
sl@0: base_info_set_name (BaseInfo      *info,
sl@0:                     const char    *name)
sl@0: {
sl@0:   char *old;
sl@0: 
sl@0:   old = info->name;
sl@0:   info->name = g_strdup (name);
sl@0:   g_free (old);
sl@0: }
sl@0: 
sl@0: GType
sl@0: base_info_get_gtype (void)
sl@0: {
sl@0:  
sl@0:   #if EMULATOR
sl@0: GET_STATIC_VAR_FROM_TLS(out_type,dbus_gidl,GType )
sl@0: #define our_type (*GET_DBUS_WSD_VAR_NAME(our_type,dbus_gidl,s)())
sl@0: #else
sl@0:   static GType our_type = 0;
sl@0: #endif
sl@0: 
sl@0:   
sl@0:   if (our_type == 0)
sl@0:     our_type = g_boxed_type_register_static ("BaseInfo",
sl@0:                                              (GBoxedCopyFunc) base_info_ref,
sl@0:                                              (GBoxedFreeFunc) base_info_unref);
sl@0: 
sl@0:   return our_type;
sl@0: }
sl@0: 
sl@0: static void
sl@0: free_interface_list (GSList **interfaces_p)
sl@0: {
sl@0:   GSList *tmp;
sl@0:   tmp = *interfaces_p;
sl@0:   while (tmp != NULL)
sl@0:     {
sl@0:       interface_info_unref (tmp->data);
sl@0:       tmp = tmp->next;
sl@0:     }
sl@0:   g_slist_free (*interfaces_p);
sl@0:   *interfaces_p = NULL;
sl@0: }
sl@0: 
sl@0: static void
sl@0: free_node_list (GSList **nodes_p)
sl@0: {
sl@0:   GSList *tmp;
sl@0:   tmp = *nodes_p;
sl@0:   while (tmp != NULL)
sl@0:     {
sl@0:       node_info_unref (tmp->data);
sl@0:       tmp = tmp->next;
sl@0:     }
sl@0:   g_slist_free (*nodes_p);
sl@0:   *nodes_p = NULL;
sl@0: }
sl@0: 
sl@0: static void
sl@0: free_method_list (GSList **methods_p)
sl@0: {
sl@0:   GSList *tmp;
sl@0:   tmp = *methods_p;
sl@0:   while (tmp != NULL)
sl@0:     {
sl@0:       method_info_unref (tmp->data);
sl@0:       tmp = tmp->next;
sl@0:     }
sl@0:   g_slist_free (*methods_p);
sl@0:   *methods_p = NULL;
sl@0: }
sl@0: 
sl@0: static void
sl@0: free_signal_list (GSList **signals_p)
sl@0: {
sl@0:   GSList *tmp;
sl@0:   tmp = *signals_p;
sl@0:   while (tmp != NULL)
sl@0:     {
sl@0:       signal_info_unref (tmp->data);
sl@0:       tmp = tmp->next;
sl@0:     }
sl@0:   g_slist_free (*signals_p);
sl@0:   *signals_p = NULL;
sl@0: }
sl@0: 
sl@0: static void
sl@0: free_property_list (GSList **props_p)
sl@0: {
sl@0:   GSList *tmp;
sl@0:   tmp = *props_p;
sl@0:   while (tmp != NULL)
sl@0:     {
sl@0:       property_info_unref (tmp->data);
sl@0:       tmp = tmp->next;
sl@0:     }
sl@0:   g_slist_free (*props_p);
sl@0:   *props_p = NULL;
sl@0: }
sl@0: 
sl@0: NodeInfo*
sl@0: node_info_new (const char *name)
sl@0: {
sl@0:   NodeInfo *info;
sl@0: 
sl@0:   /* name can be NULL */
sl@0:   
sl@0:   info = g_new0 (NodeInfo, 1);
sl@0:   info->base.refcount = 1;
sl@0:   info->base.name = g_strdup (name);
sl@0:   info->base.type = INFO_TYPE_NODE;
sl@0:   
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: NodeInfo *
sl@0: node_info_ref (NodeInfo *info)
sl@0: {
sl@0:   info->base.refcount += 1;
sl@0: 
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: void
sl@0: node_info_unref (NodeInfo *info)
sl@0: {
sl@0:   info->base.refcount -= 1;
sl@0:   if (info->base.refcount == 0)
sl@0:     {
sl@0:       free_interface_list (&info->interfaces);
sl@0:       free_node_list (&info->nodes);
sl@0:       base_info_free (info);
sl@0:     }
sl@0: }
sl@0: 
sl@0: const char*
sl@0: node_info_get_name (NodeInfo *info)
sl@0: {
sl@0:   return info->base.name;
sl@0: }
sl@0: 
sl@0: GSList*
sl@0: node_info_get_interfaces (NodeInfo *info)
sl@0: {
sl@0:   return info->interfaces;
sl@0: }
sl@0: 
sl@0: void
sl@0: node_info_add_interface (NodeInfo *info,
sl@0:                          InterfaceInfo    *interface)
sl@0: {
sl@0:   interface_info_ref (interface);
sl@0:   info->interfaces = g_slist_append (info->interfaces, interface);
sl@0: }
sl@0: 
sl@0: GSList*
sl@0: node_info_get_nodes (NodeInfo *info)
sl@0: {
sl@0:   return info->nodes;
sl@0: }
sl@0: 
sl@0: void
sl@0: node_info_add_node (NodeInfo *info,
sl@0:                     NodeInfo *node)
sl@0: {
sl@0:   node_info_ref (node);
sl@0:   info->nodes = g_slist_append (info->nodes, node);
sl@0: }
sl@0: 
sl@0: void
sl@0: node_info_replace_node (NodeInfo            *info,
sl@0:                         NodeInfo            *old_child,
sl@0:                         NodeInfo            *new_child)
sl@0: {
sl@0:   GSList *link;
sl@0: 
sl@0:   node_info_ref (new_child); /* before unref old_child in case they are the same */
sl@0:   link = g_slist_find (info->nodes, old_child);
sl@0:   g_assert (link != NULL);
sl@0:   node_info_unref (old_child);
sl@0:   link->data = new_child;
sl@0: }
sl@0: 
sl@0: InterfaceInfo*
sl@0: interface_info_new (const char *name)
sl@0: {
sl@0:   InterfaceInfo *info;
sl@0: 
sl@0:   info = g_new0 (InterfaceInfo, 1);
sl@0:   info->base.refcount = 1;
sl@0:   info->base.name = g_strdup (name);
sl@0:   info->base.type = INFO_TYPE_INTERFACE;
sl@0:   info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
sl@0: 					     (GDestroyNotify) g_free,
sl@0: 					     (GDestroyNotify) g_free);
sl@0:   
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: InterfaceInfo *
sl@0: interface_info_ref (InterfaceInfo *info)
sl@0: {
sl@0:   info->base.refcount += 1;
sl@0: 
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: void
sl@0: interface_info_unref (InterfaceInfo *info)
sl@0: {
sl@0:   info->base.refcount -= 1;
sl@0:   if (info->base.refcount == 0)
sl@0:     {
sl@0:       g_hash_table_destroy (info->annotations);
sl@0:       free_method_list (&info->methods);
sl@0:       free_signal_list (&info->signals);
sl@0:       free_property_list (&info->properties);
sl@0:       base_info_free (info);
sl@0:     }
sl@0: }
sl@0: 
sl@0: const char*
sl@0: interface_info_get_name (InterfaceInfo *info)
sl@0: {
sl@0:   return info->base.name;
sl@0: }
sl@0: 
sl@0: GSList *
sl@0: interface_info_get_annotations (InterfaceInfo *info)
sl@0: {
sl@0:   return get_hash_keys (info->annotations);
sl@0: }
sl@0: 
sl@0: const char*
sl@0: interface_info_get_annotation (InterfaceInfo *info,
sl@0: 			       const char    *name)
sl@0: {
sl@0:   return g_hash_table_lookup (info->annotations, name);
sl@0: }
sl@0: 
sl@0: GSList*
sl@0: interface_info_get_methods (InterfaceInfo *info)
sl@0: {
sl@0:   return info->methods;
sl@0: }
sl@0: 
sl@0: GSList*
sl@0: interface_info_get_signals (InterfaceInfo *info)
sl@0: {
sl@0:   return info->signals;
sl@0: }
sl@0: 
sl@0: GSList*
sl@0: interface_info_get_properties (InterfaceInfo *info)
sl@0: {
sl@0:   return info->properties;
sl@0: }
sl@0: 
sl@0: void
sl@0: interface_info_add_annotation (InterfaceInfo *info,
sl@0: 			       const char    *name,
sl@0: 			       const char    *value)
sl@0: {
sl@0:   g_hash_table_insert (info->annotations,
sl@0: 		       g_strdup (name),
sl@0: 		       g_strdup (value));
sl@0: }
sl@0: 
sl@0: void
sl@0: interface_info_add_method (InterfaceInfo *info,
sl@0:                            MethodInfo    *method)
sl@0: {
sl@0:   method_info_ref (method);
sl@0:   info->methods = g_slist_append (info->methods, method);
sl@0: }
sl@0: 
sl@0: void
sl@0: interface_info_add_signal (InterfaceInfo *info,
sl@0:                            SignalInfo    *signal)
sl@0: {
sl@0:   signal_info_ref (signal);
sl@0:   info->signals = g_slist_append (info->signals, signal);
sl@0: }
sl@0: 
sl@0: void
sl@0: interface_info_add_property (InterfaceInfo *info,
sl@0:                              PropertyInfo  *property)
sl@0: {
sl@0:   property_info_ref (property);
sl@0:   info->properties = g_slist_append (info->properties, property);
sl@0: }
sl@0: 
sl@0: static void
sl@0: free_arg_list (GSList **args_p)
sl@0: {
sl@0:   GSList *tmp;
sl@0:   tmp = *args_p;
sl@0:   while (tmp != NULL)
sl@0:     {
sl@0:       ArgInfo *ai = tmp->data;
sl@0:       g_assert (ai->base.type == INFO_TYPE_ARG);
sl@0:       arg_info_unref (tmp->data);
sl@0:       tmp = tmp->next;
sl@0:     }
sl@0:   g_slist_free (*args_p);
sl@0:   *args_p = NULL;
sl@0: }
sl@0: 
sl@0: MethodInfo*
sl@0: method_info_new (const char *name)
sl@0: {
sl@0:   MethodInfo *info;
sl@0: 
sl@0:   info = g_new0 (MethodInfo, 1);
sl@0:   info->base.refcount = 1;
sl@0:   info->base.name = g_strdup (name);
sl@0:   info->base.type = INFO_TYPE_METHOD;
sl@0:   info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
sl@0: 					  (GDestroyNotify) g_free,
sl@0: 					  (GDestroyNotify) g_free);
sl@0:   
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: MethodInfo *
sl@0: method_info_ref (MethodInfo *info)
sl@0: {
sl@0:   info->base.refcount += 1;
sl@0: 
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: void
sl@0: method_info_unref (MethodInfo *info)
sl@0: {
sl@0:   info->base.refcount -= 1;
sl@0:   if (info->base.refcount == 0)
sl@0:     {
sl@0:       g_hash_table_destroy (info->annotations);
sl@0:       free_arg_list (&info->args);
sl@0:       base_info_free (info);
sl@0:     }
sl@0: }
sl@0: 
sl@0: const char*
sl@0: method_info_get_name (MethodInfo *info)
sl@0: {
sl@0:   return info->base.name;
sl@0: }
sl@0: 
sl@0: GSList *
sl@0: method_info_get_annotations (MethodInfo *info)
sl@0: {
sl@0:   return get_hash_keys (info->annotations);
sl@0: }
sl@0: 
sl@0: const char*
sl@0: method_info_get_annotation (MethodInfo *info,
sl@0: 			    const char *name)
sl@0: {
sl@0:   return g_hash_table_lookup (info->annotations, name);
sl@0: }
sl@0: 
sl@0: GSList*
sl@0: method_info_get_args (MethodInfo *info)
sl@0: {
sl@0:   return info->args;
sl@0: }
sl@0: 
sl@0: int
sl@0: method_info_get_n_args (MethodInfo *info)
sl@0: {
sl@0:   return g_slist_length (info->args);
sl@0: }
sl@0: 
sl@0: static int
sl@0: args_sort_by_direction (const void *a,
sl@0:                         const void *b)
sl@0: {
sl@0:   const ArgInfo *arg_a = a;
sl@0:   const ArgInfo *arg_b = b;
sl@0: 
sl@0:   if (arg_a->direction == arg_b->direction)
sl@0:     return 0;
sl@0:   else if (arg_a->direction == ARG_IN)
sl@0:     return -1; /* in is less than out */
sl@0:   else
sl@0:     return 1;
sl@0: }                  
sl@0: 
sl@0: void
sl@0: method_info_add_annotation (MethodInfo  *info,
sl@0: 			    const char  *name,
sl@0: 			    const char  *value)
sl@0: {
sl@0:   g_hash_table_insert (info->annotations,
sl@0: 		       g_strdup (name),
sl@0: 		       g_strdup (value));
sl@0: }
sl@0: 
sl@0: void
sl@0: method_info_add_arg (MethodInfo    *info,
sl@0:                      ArgInfo       *arg)
sl@0: {
sl@0:   arg_info_ref (arg);
sl@0:   info->args = g_slist_append (info->args, arg);
sl@0: 
sl@0:   /* Keep "in" args sorted before "out" and otherwise maintain
sl@0:    * stable order (g_slist_sort is stable, at least in sufficiently
sl@0:    * new glib)
sl@0:    */
sl@0:   info->args = g_slist_sort (info->args, args_sort_by_direction);
sl@0: }
sl@0: 
sl@0: SignalInfo*
sl@0: signal_info_new (const char *name)
sl@0: {
sl@0:   SignalInfo *info;
sl@0: 
sl@0:   info = g_new0 (SignalInfo, 1);
sl@0:   info->base.refcount = 1;
sl@0:   info->base.name = g_strdup (name);
sl@0:   info->base.type = INFO_TYPE_SIGNAL;
sl@0:   
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: SignalInfo *
sl@0: signal_info_ref (SignalInfo *info)
sl@0: {
sl@0:   info->base.refcount += 1;
sl@0: 
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: void
sl@0: signal_info_unref (SignalInfo *info)
sl@0: {
sl@0:   info->base.refcount -= 1;
sl@0:   if (info->base.refcount == 0)
sl@0:     {
sl@0:       free_arg_list (&info->args);
sl@0:       base_info_free (info);
sl@0:     }
sl@0: }
sl@0: 
sl@0: const char*
sl@0: signal_info_get_name (SignalInfo *info)
sl@0: {
sl@0:   return info->base.name;
sl@0: }
sl@0: 
sl@0: GSList*
sl@0: signal_info_get_args (SignalInfo *info)
sl@0: {
sl@0:   return info->args;
sl@0: }
sl@0: 
sl@0: int
sl@0: signal_info_get_n_args (SignalInfo *info)
sl@0: {
sl@0:   return g_slist_length (info->args);
sl@0: }
sl@0: 
sl@0: void
sl@0: signal_info_add_arg (SignalInfo    *info,
sl@0:                      ArgInfo       *arg)
sl@0: {
sl@0:   g_assert (arg->direction == ARG_OUT);
sl@0:   
sl@0:   arg_info_ref (arg);
sl@0:   info->args = g_slist_append (info->args, arg);
sl@0:   
sl@0:   /* signal args don't need sorting since only "out" is allowed */
sl@0: }
sl@0: 
sl@0: PropertyInfo*
sl@0: property_info_new (const char          *name,
sl@0:                    const char          *type,
sl@0:                    PropertyAccessFlags  access)
sl@0: {
sl@0:   PropertyInfo *info;
sl@0: 
sl@0:   info = g_new0 (PropertyInfo, 1);
sl@0:   info->base.refcount = 1;
sl@0:   info->base.name = g_strdup (name);
sl@0:   info->base.type = INFO_TYPE_PROPERTY;
sl@0: 
sl@0:   info->type = g_strdup (type);
sl@0:   info->access = access;
sl@0:   
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: PropertyInfo*
sl@0: property_info_ref (PropertyInfo *info)
sl@0: {
sl@0:   info->base.refcount += 1;
sl@0:   
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: void
sl@0: property_info_unref (PropertyInfo *info)
sl@0: {
sl@0:   info->base.refcount -= 1;
sl@0:   if (info->base.refcount == 0)
sl@0:     {
sl@0:       g_free (info->type);
sl@0:       base_info_free (info);
sl@0:     }
sl@0: }
sl@0: 
sl@0: const char*
sl@0: property_info_get_name (PropertyInfo *info)
sl@0: {
sl@0:   return info->base.name;
sl@0: }
sl@0: 
sl@0: const char *
sl@0: property_info_get_type (PropertyInfo *info)
sl@0: {
sl@0:   return info->type;
sl@0: }
sl@0: 
sl@0: PropertyAccessFlags
sl@0: property_info_get_access (PropertyInfo *info)
sl@0: {
sl@0:   return info->access;
sl@0: }
sl@0: 
sl@0: ArgInfo*
sl@0: arg_info_new (const char  *name,
sl@0:               ArgDirection direction,
sl@0:               const char  *type)
sl@0: {
sl@0:   ArgInfo *info;
sl@0: 
sl@0:   info = g_new0 (ArgInfo, 1);
sl@0:   info->base.refcount = 1;
sl@0:   info->base.type = INFO_TYPE_ARG;
sl@0:   
sl@0:   /* name can be NULL */
sl@0:   info->base.name = g_strdup (name);
sl@0:   info->direction = direction;
sl@0:   info->type = g_strdup (type);
sl@0:   info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
sl@0: 					     (GDestroyNotify) g_free,
sl@0: 					     (GDestroyNotify) g_free);
sl@0: 
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: ArgInfo *
sl@0: arg_info_ref (ArgInfo *info)
sl@0: {
sl@0:   info->base.refcount += 1;
sl@0: 
sl@0:   return info;
sl@0: }
sl@0: 
sl@0: void
sl@0: arg_info_unref (ArgInfo *info)
sl@0: {
sl@0:   info->base.refcount -= 1;
sl@0:   if (info->base.refcount == 0)
sl@0:     {
sl@0:       g_hash_table_destroy (info->annotations);
sl@0:       g_free (info->type);
sl@0:       base_info_free (info);
sl@0:     }
sl@0: }
sl@0: 
sl@0: const char*
sl@0: arg_info_get_name (ArgInfo *info)
sl@0: {
sl@0:   return info->base.name;
sl@0: }
sl@0: 
sl@0: const char *
sl@0: arg_info_get_type (ArgInfo *info)
sl@0: {
sl@0:   return info->type;
sl@0: }
sl@0: 
sl@0: ArgDirection
sl@0: arg_info_get_direction (ArgInfo *info)
sl@0: {
sl@0:   return info->direction;
sl@0: }
sl@0: 
sl@0: GSList*
sl@0: arg_info_get_annotations (ArgInfo *info)
sl@0: {
sl@0:   return get_hash_keys (info->annotations);
sl@0: }
sl@0: 
sl@0: const char*
sl@0: arg_info_get_annotation (ArgInfo    *info,
sl@0: 			 const char *annotation)
sl@0: {
sl@0:   return g_hash_table_lookup (info->annotations, annotation);
sl@0: }
sl@0: 
sl@0: void
sl@0: arg_info_add_annotation (ArgInfo             *info,
sl@0: 			 const char          *name,
sl@0: 			 const char          *value)
sl@0: {
sl@0:   g_hash_table_insert (info->annotations,
sl@0: 		       g_strdup (name),
sl@0: 		       g_strdup (value));
sl@0: }
sl@0: 
sl@0: 
sl@0: #ifdef DBUS_BUILD_TESTS
sl@0: 
sl@0: /**
sl@0:  * @ingroup DBusGIDL
sl@0:  * Unit test for GLib IDL internals
sl@0:  * Returns: #TRUE on success.
sl@0:  */
sl@0: gboolean
sl@0: _dbus_gidl_test (void)
sl@0: {
sl@0: 
sl@0:   return TRUE;
sl@0: }
sl@0: 
sl@0: #endif /* DBUS_BUILD_TESTS */
sl@0: 
sl@0: #endif /* DOXYGEN_SHOULD_SKIP_THIS */