os/ossrv/ofdbus/dbus-glib/dbus/dbus-gidl.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ofdbus/dbus-glib/dbus/dbus-gidl.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,795 @@
     1.4 +/* -*- mode: C; c-file-style: "gnu" -*- */
     1.5 +/* dbus-gidl.c data structure describing an interface, to be generated from IDL
     1.6 + *             or something
     1.7 + *
     1.8 + * Copyright (C) 2003, 2005  Red Hat, Inc.
     1.9 + * Portion Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
    1.10 + * Licensed under the Academic Free License version 2.1
    1.11 + *
    1.12 + * This program is free software; you can redistribute it and/or modify
    1.13 + * it under the terms of the GNU General Public License as published by
    1.14 + * the Free Software Foundation; either version 2 of the License, or
    1.15 + * (at your option) any later version.
    1.16 + *
    1.17 + * This program is distributed in the hope that it will be useful,
    1.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.20 + * GNU General Public License for more details.
    1.21 + *
    1.22 + * You should have received a copy of the GNU General Public License
    1.23 + * along with this program; if not, write to the Free Software
    1.24 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "dbus-gidl.h"
    1.29 +
    1.30 +#ifndef DOXYGEN_SHOULD_SKIP_THIS
    1.31 +
    1.32 +struct BaseInfo
    1.33 +{
    1.34 +  unsigned int refcount : 28;
    1.35 +  unsigned int type     : 4;
    1.36 +  char *name;
    1.37 +};
    1.38 +
    1.39 +struct NodeInfo
    1.40 +{
    1.41 +  BaseInfo base;
    1.42 +  GSList *interfaces;
    1.43 +  GSList *nodes;
    1.44 +};
    1.45 +
    1.46 +struct InterfaceInfo
    1.47 +{
    1.48 +  BaseInfo base;
    1.49 +  GHashTable *annotations;
    1.50 +  /* Since we have BaseInfo now these could be one list */
    1.51 +  GSList *methods;
    1.52 +  GSList *signals;
    1.53 +  GSList *properties;
    1.54 +};
    1.55 +
    1.56 +struct MethodInfo
    1.57 +{
    1.58 +  BaseInfo base;
    1.59 +  GHashTable *annotations;
    1.60 +  GSList *args;
    1.61 +};
    1.62 +
    1.63 +struct SignalInfo
    1.64 +{
    1.65 +  BaseInfo base;
    1.66 +  GSList *args;
    1.67 +};
    1.68 +
    1.69 +struct PropertyInfo
    1.70 +{
    1.71 +  BaseInfo base;
    1.72 +  char *type;
    1.73 +  PropertyAccessFlags access;
    1.74 +};
    1.75 +
    1.76 +struct ArgInfo
    1.77 +{
    1.78 +  BaseInfo base;
    1.79 +  char *type;
    1.80 +  ArgDirection direction;
    1.81 +  GHashTable *annotations;
    1.82 +};
    1.83 +
    1.84 +static void
    1.85 +get_hash_key (gpointer key, gpointer value, gpointer data)
    1.86 +{
    1.87 +  GSList **list = data;
    1.88 +  *list = g_slist_prepend (*list, key);
    1.89 +}
    1.90 +
    1.91 +static GSList *
    1.92 +get_hash_keys (GHashTable *table)
    1.93 +{
    1.94 +  GSList *ret = NULL;
    1.95 +
    1.96 +  g_hash_table_foreach (table, get_hash_key, &ret);
    1.97 +
    1.98 +  return ret;
    1.99 +}
   1.100 +
   1.101 +BaseInfo *
   1.102 +base_info_ref (BaseInfo *info)
   1.103 +{
   1.104 +  g_return_val_if_fail (info != NULL, NULL);
   1.105 +  g_return_val_if_fail (info->refcount > 0, NULL);
   1.106 +  
   1.107 +  info->refcount += 1;
   1.108 +
   1.109 +  return info;
   1.110 +}
   1.111 +
   1.112 +static void
   1.113 +base_info_free (void *ptr)
   1.114 +{
   1.115 +  BaseInfo *info;
   1.116 +
   1.117 +  info = ptr;
   1.118 +  
   1.119 +  g_free (info->name);
   1.120 +  g_free (info);
   1.121 +}
   1.122 +
   1.123 +void
   1.124 +base_info_unref (BaseInfo *info)
   1.125 +{
   1.126 +  g_return_if_fail (info != NULL);
   1.127 +  g_return_if_fail (info->refcount > 0);
   1.128 +  
   1.129 +  /* This is sort of bizarre, BaseInfo was tacked on later */
   1.130 +
   1.131 +  switch (info->type)
   1.132 +    {
   1.133 +    case INFO_TYPE_NODE:
   1.134 +      node_info_unref ((NodeInfo*) info);
   1.135 +      break;
   1.136 +    case INFO_TYPE_INTERFACE:
   1.137 +      interface_info_unref ((InterfaceInfo*) info);
   1.138 +      break;
   1.139 +    case INFO_TYPE_SIGNAL:
   1.140 +      signal_info_unref ((SignalInfo*) info);
   1.141 +      break;
   1.142 +    case INFO_TYPE_METHOD:
   1.143 +      method_info_unref ((MethodInfo*) info);
   1.144 +      break;
   1.145 +    case INFO_TYPE_PROPERTY:
   1.146 +      property_info_unref ((PropertyInfo*) info);
   1.147 +      break;
   1.148 +    case INFO_TYPE_ARG:
   1.149 +      arg_info_unref ((ArgInfo*) info);
   1.150 +      break;
   1.151 +    }
   1.152 +}
   1.153 +
   1.154 +InfoType
   1.155 +base_info_get_type (BaseInfo      *info)
   1.156 +{
   1.157 +  return info->type;
   1.158 +}
   1.159 +
   1.160 +const char*
   1.161 +base_info_get_name (BaseInfo *info)
   1.162 +{
   1.163 +  return info->name;
   1.164 +}
   1.165 +
   1.166 +void
   1.167 +base_info_set_name (BaseInfo      *info,
   1.168 +                    const char    *name)
   1.169 +{
   1.170 +  char *old;
   1.171 +
   1.172 +  old = info->name;
   1.173 +  info->name = g_strdup (name);
   1.174 +  g_free (old);
   1.175 +}
   1.176 +
   1.177 +GType
   1.178 +base_info_get_gtype (void)
   1.179 +{
   1.180 + 
   1.181 +  #if EMULATOR
   1.182 +GET_STATIC_VAR_FROM_TLS(out_type,dbus_gidl,GType )
   1.183 +#define our_type (*GET_DBUS_WSD_VAR_NAME(our_type,dbus_gidl,s)())
   1.184 +#else
   1.185 +  static GType our_type = 0;
   1.186 +#endif
   1.187 +
   1.188 +  
   1.189 +  if (our_type == 0)
   1.190 +    our_type = g_boxed_type_register_static ("BaseInfo",
   1.191 +                                             (GBoxedCopyFunc) base_info_ref,
   1.192 +                                             (GBoxedFreeFunc) base_info_unref);
   1.193 +
   1.194 +  return our_type;
   1.195 +}
   1.196 +
   1.197 +static void
   1.198 +free_interface_list (GSList **interfaces_p)
   1.199 +{
   1.200 +  GSList *tmp;
   1.201 +  tmp = *interfaces_p;
   1.202 +  while (tmp != NULL)
   1.203 +    {
   1.204 +      interface_info_unref (tmp->data);
   1.205 +      tmp = tmp->next;
   1.206 +    }
   1.207 +  g_slist_free (*interfaces_p);
   1.208 +  *interfaces_p = NULL;
   1.209 +}
   1.210 +
   1.211 +static void
   1.212 +free_node_list (GSList **nodes_p)
   1.213 +{
   1.214 +  GSList *tmp;
   1.215 +  tmp = *nodes_p;
   1.216 +  while (tmp != NULL)
   1.217 +    {
   1.218 +      node_info_unref (tmp->data);
   1.219 +      tmp = tmp->next;
   1.220 +    }
   1.221 +  g_slist_free (*nodes_p);
   1.222 +  *nodes_p = NULL;
   1.223 +}
   1.224 +
   1.225 +static void
   1.226 +free_method_list (GSList **methods_p)
   1.227 +{
   1.228 +  GSList *tmp;
   1.229 +  tmp = *methods_p;
   1.230 +  while (tmp != NULL)
   1.231 +    {
   1.232 +      method_info_unref (tmp->data);
   1.233 +      tmp = tmp->next;
   1.234 +    }
   1.235 +  g_slist_free (*methods_p);
   1.236 +  *methods_p = NULL;
   1.237 +}
   1.238 +
   1.239 +static void
   1.240 +free_signal_list (GSList **signals_p)
   1.241 +{
   1.242 +  GSList *tmp;
   1.243 +  tmp = *signals_p;
   1.244 +  while (tmp != NULL)
   1.245 +    {
   1.246 +      signal_info_unref (tmp->data);
   1.247 +      tmp = tmp->next;
   1.248 +    }
   1.249 +  g_slist_free (*signals_p);
   1.250 +  *signals_p = NULL;
   1.251 +}
   1.252 +
   1.253 +static void
   1.254 +free_property_list (GSList **props_p)
   1.255 +{
   1.256 +  GSList *tmp;
   1.257 +  tmp = *props_p;
   1.258 +  while (tmp != NULL)
   1.259 +    {
   1.260 +      property_info_unref (tmp->data);
   1.261 +      tmp = tmp->next;
   1.262 +    }
   1.263 +  g_slist_free (*props_p);
   1.264 +  *props_p = NULL;
   1.265 +}
   1.266 +
   1.267 +NodeInfo*
   1.268 +node_info_new (const char *name)
   1.269 +{
   1.270 +  NodeInfo *info;
   1.271 +
   1.272 +  /* name can be NULL */
   1.273 +  
   1.274 +  info = g_new0 (NodeInfo, 1);
   1.275 +  info->base.refcount = 1;
   1.276 +  info->base.name = g_strdup (name);
   1.277 +  info->base.type = INFO_TYPE_NODE;
   1.278 +  
   1.279 +  return info;
   1.280 +}
   1.281 +
   1.282 +NodeInfo *
   1.283 +node_info_ref (NodeInfo *info)
   1.284 +{
   1.285 +  info->base.refcount += 1;
   1.286 +
   1.287 +  return info;
   1.288 +}
   1.289 +
   1.290 +void
   1.291 +node_info_unref (NodeInfo *info)
   1.292 +{
   1.293 +  info->base.refcount -= 1;
   1.294 +  if (info->base.refcount == 0)
   1.295 +    {
   1.296 +      free_interface_list (&info->interfaces);
   1.297 +      free_node_list (&info->nodes);
   1.298 +      base_info_free (info);
   1.299 +    }
   1.300 +}
   1.301 +
   1.302 +const char*
   1.303 +node_info_get_name (NodeInfo *info)
   1.304 +{
   1.305 +  return info->base.name;
   1.306 +}
   1.307 +
   1.308 +GSList*
   1.309 +node_info_get_interfaces (NodeInfo *info)
   1.310 +{
   1.311 +  return info->interfaces;
   1.312 +}
   1.313 +
   1.314 +void
   1.315 +node_info_add_interface (NodeInfo *info,
   1.316 +                         InterfaceInfo    *interface)
   1.317 +{
   1.318 +  interface_info_ref (interface);
   1.319 +  info->interfaces = g_slist_append (info->interfaces, interface);
   1.320 +}
   1.321 +
   1.322 +GSList*
   1.323 +node_info_get_nodes (NodeInfo *info)
   1.324 +{
   1.325 +  return info->nodes;
   1.326 +}
   1.327 +
   1.328 +void
   1.329 +node_info_add_node (NodeInfo *info,
   1.330 +                    NodeInfo *node)
   1.331 +{
   1.332 +  node_info_ref (node);
   1.333 +  info->nodes = g_slist_append (info->nodes, node);
   1.334 +}
   1.335 +
   1.336 +void
   1.337 +node_info_replace_node (NodeInfo            *info,
   1.338 +                        NodeInfo            *old_child,
   1.339 +                        NodeInfo            *new_child)
   1.340 +{
   1.341 +  GSList *link;
   1.342 +
   1.343 +  node_info_ref (new_child); /* before unref old_child in case they are the same */
   1.344 +  link = g_slist_find (info->nodes, old_child);
   1.345 +  g_assert (link != NULL);
   1.346 +  node_info_unref (old_child);
   1.347 +  link->data = new_child;
   1.348 +}
   1.349 +
   1.350 +InterfaceInfo*
   1.351 +interface_info_new (const char *name)
   1.352 +{
   1.353 +  InterfaceInfo *info;
   1.354 +
   1.355 +  info = g_new0 (InterfaceInfo, 1);
   1.356 +  info->base.refcount = 1;
   1.357 +  info->base.name = g_strdup (name);
   1.358 +  info->base.type = INFO_TYPE_INTERFACE;
   1.359 +  info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
   1.360 +					     (GDestroyNotify) g_free,
   1.361 +					     (GDestroyNotify) g_free);
   1.362 +  
   1.363 +  return info;
   1.364 +}
   1.365 +
   1.366 +InterfaceInfo *
   1.367 +interface_info_ref (InterfaceInfo *info)
   1.368 +{
   1.369 +  info->base.refcount += 1;
   1.370 +
   1.371 +  return info;
   1.372 +}
   1.373 +
   1.374 +void
   1.375 +interface_info_unref (InterfaceInfo *info)
   1.376 +{
   1.377 +  info->base.refcount -= 1;
   1.378 +  if (info->base.refcount == 0)
   1.379 +    {
   1.380 +      g_hash_table_destroy (info->annotations);
   1.381 +      free_method_list (&info->methods);
   1.382 +      free_signal_list (&info->signals);
   1.383 +      free_property_list (&info->properties);
   1.384 +      base_info_free (info);
   1.385 +    }
   1.386 +}
   1.387 +
   1.388 +const char*
   1.389 +interface_info_get_name (InterfaceInfo *info)
   1.390 +{
   1.391 +  return info->base.name;
   1.392 +}
   1.393 +
   1.394 +GSList *
   1.395 +interface_info_get_annotations (InterfaceInfo *info)
   1.396 +{
   1.397 +  return get_hash_keys (info->annotations);
   1.398 +}
   1.399 +
   1.400 +const char*
   1.401 +interface_info_get_annotation (InterfaceInfo *info,
   1.402 +			       const char    *name)
   1.403 +{
   1.404 +  return g_hash_table_lookup (info->annotations, name);
   1.405 +}
   1.406 +
   1.407 +GSList*
   1.408 +interface_info_get_methods (InterfaceInfo *info)
   1.409 +{
   1.410 +  return info->methods;
   1.411 +}
   1.412 +
   1.413 +GSList*
   1.414 +interface_info_get_signals (InterfaceInfo *info)
   1.415 +{
   1.416 +  return info->signals;
   1.417 +}
   1.418 +
   1.419 +GSList*
   1.420 +interface_info_get_properties (InterfaceInfo *info)
   1.421 +{
   1.422 +  return info->properties;
   1.423 +}
   1.424 +
   1.425 +void
   1.426 +interface_info_add_annotation (InterfaceInfo *info,
   1.427 +			       const char    *name,
   1.428 +			       const char    *value)
   1.429 +{
   1.430 +  g_hash_table_insert (info->annotations,
   1.431 +		       g_strdup (name),
   1.432 +		       g_strdup (value));
   1.433 +}
   1.434 +
   1.435 +void
   1.436 +interface_info_add_method (InterfaceInfo *info,
   1.437 +                           MethodInfo    *method)
   1.438 +{
   1.439 +  method_info_ref (method);
   1.440 +  info->methods = g_slist_append (info->methods, method);
   1.441 +}
   1.442 +
   1.443 +void
   1.444 +interface_info_add_signal (InterfaceInfo *info,
   1.445 +                           SignalInfo    *signal)
   1.446 +{
   1.447 +  signal_info_ref (signal);
   1.448 +  info->signals = g_slist_append (info->signals, signal);
   1.449 +}
   1.450 +
   1.451 +void
   1.452 +interface_info_add_property (InterfaceInfo *info,
   1.453 +                             PropertyInfo  *property)
   1.454 +{
   1.455 +  property_info_ref (property);
   1.456 +  info->properties = g_slist_append (info->properties, property);
   1.457 +}
   1.458 +
   1.459 +static void
   1.460 +free_arg_list (GSList **args_p)
   1.461 +{
   1.462 +  GSList *tmp;
   1.463 +  tmp = *args_p;
   1.464 +  while (tmp != NULL)
   1.465 +    {
   1.466 +      ArgInfo *ai = tmp->data;
   1.467 +      g_assert (ai->base.type == INFO_TYPE_ARG);
   1.468 +      arg_info_unref (tmp->data);
   1.469 +      tmp = tmp->next;
   1.470 +    }
   1.471 +  g_slist_free (*args_p);
   1.472 +  *args_p = NULL;
   1.473 +}
   1.474 +
   1.475 +MethodInfo*
   1.476 +method_info_new (const char *name)
   1.477 +{
   1.478 +  MethodInfo *info;
   1.479 +
   1.480 +  info = g_new0 (MethodInfo, 1);
   1.481 +  info->base.refcount = 1;
   1.482 +  info->base.name = g_strdup (name);
   1.483 +  info->base.type = INFO_TYPE_METHOD;
   1.484 +  info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
   1.485 +					  (GDestroyNotify) g_free,
   1.486 +					  (GDestroyNotify) g_free);
   1.487 +  
   1.488 +  return info;
   1.489 +}
   1.490 +
   1.491 +MethodInfo *
   1.492 +method_info_ref (MethodInfo *info)
   1.493 +{
   1.494 +  info->base.refcount += 1;
   1.495 +
   1.496 +  return info;
   1.497 +}
   1.498 +
   1.499 +void
   1.500 +method_info_unref (MethodInfo *info)
   1.501 +{
   1.502 +  info->base.refcount -= 1;
   1.503 +  if (info->base.refcount == 0)
   1.504 +    {
   1.505 +      g_hash_table_destroy (info->annotations);
   1.506 +      free_arg_list (&info->args);
   1.507 +      base_info_free (info);
   1.508 +    }
   1.509 +}
   1.510 +
   1.511 +const char*
   1.512 +method_info_get_name (MethodInfo *info)
   1.513 +{
   1.514 +  return info->base.name;
   1.515 +}
   1.516 +
   1.517 +GSList *
   1.518 +method_info_get_annotations (MethodInfo *info)
   1.519 +{
   1.520 +  return get_hash_keys (info->annotations);
   1.521 +}
   1.522 +
   1.523 +const char*
   1.524 +method_info_get_annotation (MethodInfo *info,
   1.525 +			    const char *name)
   1.526 +{
   1.527 +  return g_hash_table_lookup (info->annotations, name);
   1.528 +}
   1.529 +
   1.530 +GSList*
   1.531 +method_info_get_args (MethodInfo *info)
   1.532 +{
   1.533 +  return info->args;
   1.534 +}
   1.535 +
   1.536 +int
   1.537 +method_info_get_n_args (MethodInfo *info)
   1.538 +{
   1.539 +  return g_slist_length (info->args);
   1.540 +}
   1.541 +
   1.542 +static int
   1.543 +args_sort_by_direction (const void *a,
   1.544 +                        const void *b)
   1.545 +{
   1.546 +  const ArgInfo *arg_a = a;
   1.547 +  const ArgInfo *arg_b = b;
   1.548 +
   1.549 +  if (arg_a->direction == arg_b->direction)
   1.550 +    return 0;
   1.551 +  else if (arg_a->direction == ARG_IN)
   1.552 +    return -1; /* in is less than out */
   1.553 +  else
   1.554 +    return 1;
   1.555 +}                  
   1.556 +
   1.557 +void
   1.558 +method_info_add_annotation (MethodInfo  *info,
   1.559 +			    const char  *name,
   1.560 +			    const char  *value)
   1.561 +{
   1.562 +  g_hash_table_insert (info->annotations,
   1.563 +		       g_strdup (name),
   1.564 +		       g_strdup (value));
   1.565 +}
   1.566 +
   1.567 +void
   1.568 +method_info_add_arg (MethodInfo    *info,
   1.569 +                     ArgInfo       *arg)
   1.570 +{
   1.571 +  arg_info_ref (arg);
   1.572 +  info->args = g_slist_append (info->args, arg);
   1.573 +
   1.574 +  /* Keep "in" args sorted before "out" and otherwise maintain
   1.575 +   * stable order (g_slist_sort is stable, at least in sufficiently
   1.576 +   * new glib)
   1.577 +   */
   1.578 +  info->args = g_slist_sort (info->args, args_sort_by_direction);
   1.579 +}
   1.580 +
   1.581 +SignalInfo*
   1.582 +signal_info_new (const char *name)
   1.583 +{
   1.584 +  SignalInfo *info;
   1.585 +
   1.586 +  info = g_new0 (SignalInfo, 1);
   1.587 +  info->base.refcount = 1;
   1.588 +  info->base.name = g_strdup (name);
   1.589 +  info->base.type = INFO_TYPE_SIGNAL;
   1.590 +  
   1.591 +  return info;
   1.592 +}
   1.593 +
   1.594 +SignalInfo *
   1.595 +signal_info_ref (SignalInfo *info)
   1.596 +{
   1.597 +  info->base.refcount += 1;
   1.598 +
   1.599 +  return info;
   1.600 +}
   1.601 +
   1.602 +void
   1.603 +signal_info_unref (SignalInfo *info)
   1.604 +{
   1.605 +  info->base.refcount -= 1;
   1.606 +  if (info->base.refcount == 0)
   1.607 +    {
   1.608 +      free_arg_list (&info->args);
   1.609 +      base_info_free (info);
   1.610 +    }
   1.611 +}
   1.612 +
   1.613 +const char*
   1.614 +signal_info_get_name (SignalInfo *info)
   1.615 +{
   1.616 +  return info->base.name;
   1.617 +}
   1.618 +
   1.619 +GSList*
   1.620 +signal_info_get_args (SignalInfo *info)
   1.621 +{
   1.622 +  return info->args;
   1.623 +}
   1.624 +
   1.625 +int
   1.626 +signal_info_get_n_args (SignalInfo *info)
   1.627 +{
   1.628 +  return g_slist_length (info->args);
   1.629 +}
   1.630 +
   1.631 +void
   1.632 +signal_info_add_arg (SignalInfo    *info,
   1.633 +                     ArgInfo       *arg)
   1.634 +{
   1.635 +  g_assert (arg->direction == ARG_OUT);
   1.636 +  
   1.637 +  arg_info_ref (arg);
   1.638 +  info->args = g_slist_append (info->args, arg);
   1.639 +  
   1.640 +  /* signal args don't need sorting since only "out" is allowed */
   1.641 +}
   1.642 +
   1.643 +PropertyInfo*
   1.644 +property_info_new (const char          *name,
   1.645 +                   const char          *type,
   1.646 +                   PropertyAccessFlags  access)
   1.647 +{
   1.648 +  PropertyInfo *info;
   1.649 +
   1.650 +  info = g_new0 (PropertyInfo, 1);
   1.651 +  info->base.refcount = 1;
   1.652 +  info->base.name = g_strdup (name);
   1.653 +  info->base.type = INFO_TYPE_PROPERTY;
   1.654 +
   1.655 +  info->type = g_strdup (type);
   1.656 +  info->access = access;
   1.657 +  
   1.658 +  return info;
   1.659 +}
   1.660 +
   1.661 +PropertyInfo*
   1.662 +property_info_ref (PropertyInfo *info)
   1.663 +{
   1.664 +  info->base.refcount += 1;
   1.665 +  
   1.666 +  return info;
   1.667 +}
   1.668 +
   1.669 +void
   1.670 +property_info_unref (PropertyInfo *info)
   1.671 +{
   1.672 +  info->base.refcount -= 1;
   1.673 +  if (info->base.refcount == 0)
   1.674 +    {
   1.675 +      g_free (info->type);
   1.676 +      base_info_free (info);
   1.677 +    }
   1.678 +}
   1.679 +
   1.680 +const char*
   1.681 +property_info_get_name (PropertyInfo *info)
   1.682 +{
   1.683 +  return info->base.name;
   1.684 +}
   1.685 +
   1.686 +const char *
   1.687 +property_info_get_type (PropertyInfo *info)
   1.688 +{
   1.689 +  return info->type;
   1.690 +}
   1.691 +
   1.692 +PropertyAccessFlags
   1.693 +property_info_get_access (PropertyInfo *info)
   1.694 +{
   1.695 +  return info->access;
   1.696 +}
   1.697 +
   1.698 +ArgInfo*
   1.699 +arg_info_new (const char  *name,
   1.700 +              ArgDirection direction,
   1.701 +              const char  *type)
   1.702 +{
   1.703 +  ArgInfo *info;
   1.704 +
   1.705 +  info = g_new0 (ArgInfo, 1);
   1.706 +  info->base.refcount = 1;
   1.707 +  info->base.type = INFO_TYPE_ARG;
   1.708 +  
   1.709 +  /* name can be NULL */
   1.710 +  info->base.name = g_strdup (name);
   1.711 +  info->direction = direction;
   1.712 +  info->type = g_strdup (type);
   1.713 +  info->annotations = g_hash_table_new_full (g_str_hash, g_str_equal,
   1.714 +					     (GDestroyNotify) g_free,
   1.715 +					     (GDestroyNotify) g_free);
   1.716 +
   1.717 +  return info;
   1.718 +}
   1.719 +
   1.720 +ArgInfo *
   1.721 +arg_info_ref (ArgInfo *info)
   1.722 +{
   1.723 +  info->base.refcount += 1;
   1.724 +
   1.725 +  return info;
   1.726 +}
   1.727 +
   1.728 +void
   1.729 +arg_info_unref (ArgInfo *info)
   1.730 +{
   1.731 +  info->base.refcount -= 1;
   1.732 +  if (info->base.refcount == 0)
   1.733 +    {
   1.734 +      g_hash_table_destroy (info->annotations);
   1.735 +      g_free (info->type);
   1.736 +      base_info_free (info);
   1.737 +    }
   1.738 +}
   1.739 +
   1.740 +const char*
   1.741 +arg_info_get_name (ArgInfo *info)
   1.742 +{
   1.743 +  return info->base.name;
   1.744 +}
   1.745 +
   1.746 +const char *
   1.747 +arg_info_get_type (ArgInfo *info)
   1.748 +{
   1.749 +  return info->type;
   1.750 +}
   1.751 +
   1.752 +ArgDirection
   1.753 +arg_info_get_direction (ArgInfo *info)
   1.754 +{
   1.755 +  return info->direction;
   1.756 +}
   1.757 +
   1.758 +GSList*
   1.759 +arg_info_get_annotations (ArgInfo *info)
   1.760 +{
   1.761 +  return get_hash_keys (info->annotations);
   1.762 +}
   1.763 +
   1.764 +const char*
   1.765 +arg_info_get_annotation (ArgInfo    *info,
   1.766 +			 const char *annotation)
   1.767 +{
   1.768 +  return g_hash_table_lookup (info->annotations, annotation);
   1.769 +}
   1.770 +
   1.771 +void
   1.772 +arg_info_add_annotation (ArgInfo             *info,
   1.773 +			 const char          *name,
   1.774 +			 const char          *value)
   1.775 +{
   1.776 +  g_hash_table_insert (info->annotations,
   1.777 +		       g_strdup (name),
   1.778 +		       g_strdup (value));
   1.779 +}
   1.780 +
   1.781 +
   1.782 +#ifdef DBUS_BUILD_TESTS
   1.783 +
   1.784 +/**
   1.785 + * @ingroup DBusGIDL
   1.786 + * Unit test for GLib IDL internals
   1.787 + * Returns: #TRUE on success.
   1.788 + */
   1.789 +gboolean
   1.790 +_dbus_gidl_test (void)
   1.791 +{
   1.792 +
   1.793 +  return TRUE;
   1.794 +}
   1.795 +
   1.796 +#endif /* DBUS_BUILD_TESTS */
   1.797 +
   1.798 +#endif /* DOXYGEN_SHOULD_SKIP_THIS */