From a6c8a71b1bcba04b63812a61f668e87af0922e5e Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 14 Aug 2003 22:49:13 +0000 Subject: 2003-08-14 Havoc Pennington * dbus/dbus-pending-call.c: start on new object that will replace DBusMessageHandler and ReplyHandlerData for tracking outstanding replies * dbus/dbus-gproxy.c: start on proxy object used to communicate with remote interfaces * dbus/dbus-gidl.c: do the boring boilerplate in here --- glib/dbus-gidl.c | 331 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 331 insertions(+) create mode 100644 glib/dbus-gidl.c (limited to 'glib/dbus-gidl.c') diff --git a/glib/dbus-gidl.c b/glib/dbus-gidl.c new file mode 100644 index 00000000..b6e0fb8c --- /dev/null +++ b/glib/dbus-gidl.c @@ -0,0 +1,331 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-gidl.c data structure describing an interface, to be generated from IDL + * or something + * + * Copyright (C) 2003 Red Hat, Inc. + * + * Licensed under the Academic Free License version 1.2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "dbus-gidl.h" + +struct InterfaceInfo +{ + int refcount; + char *name; + GSList *methods; + GSList *signals; +}; + +struct MethodInfo +{ + int refcount; + GSList *args; + char *name; + MethodStyle style; +}; + +struct SignalInfo +{ + int refcount; + GSList *args; + char *name; +}; + +struct ArgInfo +{ + int refcount; + char *name; + int type; + ArgDirection direction; +}; + +static void +free_method_list (GSList **methods_p) +{ + GSList *tmp; + tmp = *methods_p; + while (tmp != NULL) + { + method_info_unref (tmp->data); + tmp = tmp->next; + } + g_slist_free (*methods_p); + *methods_p = NULL; +} + +static void +free_signal_list (GSList **signals_p) +{ + GSList *tmp; + tmp = *signals_p; + while (tmp != NULL) + { + signal_info_unref (tmp->data); + tmp = tmp->next; + } + g_slist_free (*signals_p); + *signals_p = NULL; +} + +InterfaceInfo* +interface_info_new (const char *name) +{ + InterfaceInfo *info; + + info = g_new0 (InterfaceInfo, 1); + info->refcount = 1; + info->name = g_strdup (name); + + return info; +} + +void +interface_info_ref (InterfaceInfo *info) +{ + info->refcount += 1; +} + +void +interface_info_unref (InterfaceInfo *info) +{ + info->refcount -= 1; + if (info->refcount == 0) + { + free_method_list (&info->methods); + free_signal_list (&info->signals); + g_free (info->name); + g_free (info); + } +} + +GSList* +interface_info_get_methods (InterfaceInfo *info) +{ + return info->methods; +} + +GSList* +interface_info_get_signals (InterfaceInfo *info) +{ + return info->signals; +} + +void +interface_info_add_method (InterfaceInfo *info, + MethodInfo *method) +{ + method_info_ref (method); + info->methods = g_slist_append (info->methods, method); +} + +void +interface_info_add_signal (InterfaceInfo *info, + SignalInfo *signal) +{ + signal_info_ref (signal); + info->signals = g_slist_append (info->signals, signal); +} + +static void +free_arg_list (GSList **args_p) +{ + GSList *tmp; + tmp = *args_p; + while (tmp != NULL) + { + arg_info_unref (tmp->data); + tmp = tmp->next; + } + g_slist_free (*args_p); + *args_p = NULL; +} + +MethodInfo* +method_info_new (const char *name, + MethodStyle style) +{ + MethodInfo *info; + + info = g_new0 (MethodInfo, 1); + info->refcount = 1; + info->name = g_strdup (name); + info->style = style; + + return info; +} + +void +method_info_ref (MethodInfo *info) +{ + info->refcount += 1; +} + +void +method_info_unref (MethodInfo *info) +{ + info->refcount -= 1; + if (info->refcount == 0) + { + free_arg_list (&info->args); + g_free (info->name); + g_free (info); + } +} + +const char* +method_info_get_name (MethodInfo *info) +{ + return info->name; +} + +GSList* +method_info_get_args (MethodInfo *info) +{ + return info->args; +} + +MethodStyle +method_info_get_style (MethodInfo *info) +{ + return info->style; +} + +void +method_info_add_arg (MethodInfo *info, + ArgInfo *arg) +{ + arg_info_ref (arg); + info->args = g_slist_append (info->args, arg); +} + +SignalInfo* +signal_info_new (const char *name) +{ + SignalInfo *info; + + info = g_new0 (SignalInfo, 1); + info->refcount = 1; + info->name = g_strdup (name); + + return info; +} + +void +signal_info_ref (SignalInfo *info) +{ + info->refcount += 1; +} + +void +signal_info_unref (SignalInfo *info) +{ + info->refcount -= 1; + if (info->refcount == 0) + { + free_arg_list (&info->args); + g_free (info->name); + g_free (info); + } +} + +const char* +signal_info_get_name (SignalInfo *info) +{ + return info->name; +} + +GSList* +signal_info_get_args (SignalInfo *info) +{ + return info->args; +} + +void +signal_info_add_arg (SignalInfo *info, + ArgInfo *arg) +{ + arg_info_ref (arg); + info->args = g_slist_append (info->args, arg); +} + +ArgInfo* +arg_info_new (const char *name, + ArgDirection direction, + int type) +{ + ArgInfo *info; + + info = g_new0 (ArgInfo, 1); + info->refcount = 1; + info->name = g_strdup (name); + info->direction = direction; + info->type = type; + + return info; +} + +void +arg_info_ref (ArgInfo *info) +{ + info->refcount += 1; +} + +void +arg_info_unref (ArgInfo *info) +{ + info->refcount -= 1; + if (info->refcount == 0) + { + g_free (info->name); + g_free (info); + } +} +const char* +arg_info_get_name (ArgInfo *info) +{ + return info->name; +} + +int +arg_info_get_type (ArgInfo *info) +{ + return info->type; +} + +ArgDirection +arg_info_get_direction (ArgInfo *info) +{ + return info->direction; +} + +#ifdef DBUS_BUILD_TESTS + +/** + * @ingroup DBusGIDL + * Unit test for GLib IDL internals + * @returns #TRUE on success. + */ +dbus_bool_t +_dbus_gidl_test (void) +{ + + return TRUE; +} + +#endif /* DBUS_BUILD_TESTS */ -- cgit From ce969c6347b69180088c592e9184f05d0d3525c4 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 30 Aug 2003 02:56:12 +0000 Subject: 2003-08-29 Havoc Pennington * dbus/dbus-object-tree.c: modify to allow overlapping paths to be registered (struct DBusObjectSubtree): shrink this a lot, since we may have a lot of them (_dbus_object_tree_free_all_unlocked): implement (_dbus_object_tree_dispatch_and_unlock): implement --- glib/dbus-gidl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'glib/dbus-gidl.c') diff --git a/glib/dbus-gidl.c b/glib/dbus-gidl.c index b6e0fb8c..c1a1f6dc 100644 --- a/glib/dbus-gidl.c +++ b/glib/dbus-gidl.c @@ -37,7 +37,6 @@ struct MethodInfo int refcount; GSList *args; char *name; - MethodStyle style; }; struct SignalInfo @@ -157,15 +156,13 @@ free_arg_list (GSList **args_p) } MethodInfo* -method_info_new (const char *name, - MethodStyle style) +method_info_new (const char *name) { MethodInfo *info; info = g_new0 (MethodInfo, 1); info->refcount = 1; info->name = g_strdup (name); - info->style = style; return info; } -- cgit From 5fd1e389e1c1c12ad4a55c2af6abdc8e7a2f6d41 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 31 Aug 2003 01:51:44 +0000 Subject: 2003-08-30 Havoc Pennington * test/data/valid-config-files/system.d/test.conf: change to root for the user so warnings don't get printed * dbus/dbus-message.c: add dbus_message_get_path, dbus_message_set_path * dbus/dbus-object-tree.c (do_test_dispatch): add test of dispatching to a path * dbus/dbus-string.c (_dbus_string_validate_path): add * dbus/dbus-marshal.c (_dbus_demarshal_object_path): implement (_dbus_marshal_object_path): implement * dbus/dbus-protocol.h (DBUS_HEADER_FIELD_PATH): new header field to contain the path to the target object (DBUS_HEADER_FIELD_SENDER_SERVICE): rename DBUS_HEADER_FIELD_SENDER to explicitly say it's the sender service --- glib/dbus-gidl.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'glib/dbus-gidl.c') diff --git a/glib/dbus-gidl.c b/glib/dbus-gidl.c index c1a1f6dc..d64e95a7 100644 --- a/glib/dbus-gidl.c +++ b/glib/dbus-gidl.c @@ -197,12 +197,6 @@ method_info_get_args (MethodInfo *info) return info->args; } -MethodStyle -method_info_get_style (MethodInfo *info) -{ - return info->style; -} - void method_info_add_arg (MethodInfo *info, ArgInfo *arg) -- cgit From d021cfae6695f0f44102edf758abfc42e2f3c093 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Wed, 3 Sep 2003 02:08:25 +0000 Subject: 2003-09-01 Havoc Pennington * glib/dbus-gparser.c: implement * glib/dbus-gobject.c: start implementing skeletons support * configure.in: when disabling checks/assert, also define G_DISABLE_ASSERT and G_DISABLE_CHECKS --- glib/dbus-gidl.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 4 deletions(-) (limited to 'glib/dbus-gidl.c') diff --git a/glib/dbus-gidl.c b/glib/dbus-gidl.c index d64e95a7..12468abb 100644 --- a/glib/dbus-gidl.c +++ b/glib/dbus-gidl.c @@ -24,6 +24,13 @@ #include "dbus-gidl.h" +struct NodeInfo +{ + int refcount; + char *name; + GSList *interfaces; +}; + struct InterfaceInfo { int refcount; @@ -54,6 +61,20 @@ struct ArgInfo ArgDirection direction; }; +static void +free_interface_list (GSList **interfaces_p) +{ + GSList *tmp; + tmp = *interfaces_p; + while (tmp != NULL) + { + interface_info_unref (tmp->data); + tmp = tmp->next; + } + g_slist_free (*interfaces_p); + *interfaces_p = NULL; +} + static void free_method_list (GSList **methods_p) { @@ -82,6 +103,59 @@ free_signal_list (GSList **signals_p) *signals_p = NULL; } +NodeInfo* +node_info_new (const char *name) +{ + NodeInfo *info; + + /* name can be NULL */ + + info = g_new0 (NodeInfo, 1); + info->refcount = 1; + info->name = g_strdup (name); + + return info; +} + +void +node_info_ref (NodeInfo *info) +{ + info->refcount += 1; +} + +void +node_info_unref (NodeInfo *info) +{ + info->refcount -= 1; + if (info->refcount == 0) + { + free_interface_list (&info->interfaces); + g_free (info->name); + g_free (info); + } +} + +const char* +node_info_get_name (NodeInfo *info) +{ + return info->name; +} + +GSList* +node_info_get_interfaces (NodeInfo *info) +{ + return info->interfaces; +} + +void +node_info_add_interface (NodeInfo *info, + InterfaceInfo *interface) +{ + interface_info_ref (interface); + info->interfaces = g_slist_append (info->interfaces, interface); +} + + InterfaceInfo* interface_info_new (const char *name) { @@ -90,7 +164,7 @@ interface_info_new (const char *name) info = g_new0 (InterfaceInfo, 1); info->refcount = 1; info->name = g_strdup (name); - + return info; } @@ -113,6 +187,12 @@ interface_info_unref (InterfaceInfo *info) } } +const char* +interface_info_get_name (InterfaceInfo *info) +{ + return info->name; +} + GSList* interface_info_get_methods (InterfaceInfo *info) { @@ -163,7 +243,7 @@ method_info_new (const char *name) info = g_new0 (MethodInfo, 1); info->refcount = 1; info->name = g_strdup (name); - + return info; } @@ -213,7 +293,7 @@ signal_info_new (const char *name) info = g_new0 (SignalInfo, 1); info->refcount = 1; info->name = g_strdup (name); - + return info; } @@ -264,10 +344,12 @@ arg_info_new (const char *name, info = g_new0 (ArgInfo, 1); info->refcount = 1; + + /* name can be NULL */ info->name = g_strdup (name); info->direction = direction; info->type = type; - + return info; } -- cgit From 85ab0327d82e4945ad16630e583d8cc68df25a90 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 7 Sep 2003 23:04:54 +0000 Subject: 2003-09-07 Havoc Pennington * Make Doxygen contented. --- glib/dbus-gidl.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'glib/dbus-gidl.c') diff --git a/glib/dbus-gidl.c b/glib/dbus-gidl.c index 12468abb..b867d178 100644 --- a/glib/dbus-gidl.c +++ b/glib/dbus-gidl.c @@ -24,6 +24,8 @@ #include "dbus-gidl.h" +#ifndef DOXYGEN_SHOULD_SKIP_THIS + struct NodeInfo { int refcount; @@ -402,3 +404,5 @@ _dbus_gidl_test (void) } #endif /* DBUS_BUILD_TESTS */ + +#endif /* DOXYGEN_SHOULD_SKIP_THIS */ -- cgit From 583994cb3b7f5562fb7b8c37b4cb0d5af78e4ce2 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Wed, 17 Sep 2003 03:52:07 +0000 Subject: 2003-09-15 Havoc Pennington * dbus/dbus-pending-call.c: add the get/set object data boilerplate as for DBusConnection, etc. Use generic object data for the notify callback. * glib/dbus-gparser.c (parse_node): parse child nodes * tools/dbus-viewer.c: more hacking on the dbus-viewer * glib/dbus-gutils.c (_dbus_gutils_split_path): add a file to contain functions shared between the convenience lib and the installed lib * glib/Makefile.am (libdbus_glib_1_la_LDFLAGS): add -export-symbols-regex to the GLib library * dbus/dbus-object-tree.c (_dbus_object_tree_dispatch_and_unlock): fix the locking in here, and add a default handler for Introspect() that just returns sub-nodes. 2003-09-14 Havoc Pennington * glib/dbus-gthread.c (dbus_g_thread_init): rename to make g_foo rather than gfoo consistent * glib/dbus-gproxy.h: delete for now, move contents to dbus-glib.h, because the include files don't work right since we aren't in the dbus/ subdir. * glib/dbus-gproxy.c (dbus_gproxy_send): finish implementing (dbus_gproxy_end_call): finish (dbus_gproxy_begin_call): finish * glib/dbus-gmain.c (dbus_set_g_error): new * glib/dbus-gobject.c (handle_introspect): include information about child nodes in the introspection * dbus/dbus-connection.c (dbus_connection_list_registered): new function to help in implementation of introspection * dbus/dbus-object-tree.c (_dbus_object_tree_list_registered_and_unlock): new function 2003-09-12 Havoc Pennington * glib/dbus-gidl.h: add common base class for all the foo_info types * tools/dbus-viewer.c: add GTK-based introspection UI thingy similar to kdcop * test/Makefile.am: try test srcdir -ef . in addition to test srcdir = ., one of them should work (yeah lame) * glib/Makefile.am: build the "idl" parser stuff as a convenience library * glib/dbus-gparser.h: make description_load routines return NodeInfo* not Parser* * Makefile.am (SUBDIRS): build test dir after all library dirs * configure.in: add GTK+ detection --- glib/dbus-gidl.c | 226 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 171 insertions(+), 55 deletions(-) (limited to 'glib/dbus-gidl.c') diff --git a/glib/dbus-gidl.c b/glib/dbus-gidl.c index b867d178..596b43ca 100644 --- a/glib/dbus-gidl.c +++ b/glib/dbus-gidl.c @@ -26,43 +26,131 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS -struct NodeInfo +struct BaseInfo { - int refcount; + unsigned int refcount : 28; + unsigned int type : 4; char *name; +}; + +struct NodeInfo +{ + BaseInfo base; GSList *interfaces; + GSList *nodes; }; struct InterfaceInfo { - int refcount; - char *name; + BaseInfo base; + /* Since we have BaseInfo now these could be one list */ GSList *methods; GSList *signals; }; struct MethodInfo { - int refcount; + BaseInfo base; GSList *args; - char *name; }; struct SignalInfo { - int refcount; + BaseInfo base; GSList *args; - char *name; }; struct ArgInfo { - int refcount; - char *name; + BaseInfo base; int type; ArgDirection direction; }; +void +base_info_ref (BaseInfo *info) +{ + g_return_if_fail (info != NULL); + g_return_if_fail (info->refcount > 0); + + info->refcount += 1; +} + +static void +base_info_free (void *ptr) +{ + BaseInfo *info; + + info = ptr; + + g_free (info->name); + g_free (info); +} + +void +base_info_unref (BaseInfo *info) +{ + g_return_if_fail (info != NULL); + g_return_if_fail (info->refcount > 0); + + /* This is sort of bizarre, BaseInfo was tacked on later */ + + switch (info->type) + { + case INFO_TYPE_NODE: + node_info_unref ((NodeInfo*) info); + break; + case INFO_TYPE_INTERFACE: + interface_info_unref ((InterfaceInfo*) info); + break; + case INFO_TYPE_SIGNAL: + signal_info_unref ((SignalInfo*) info); + break; + case INFO_TYPE_METHOD: + method_info_unref ((MethodInfo*) info); + break; + case INFO_TYPE_ARG: + arg_info_unref ((ArgInfo*) info); + break; + } +} + +InfoType +base_info_get_type (BaseInfo *info) +{ + return info->type; +} + +const char* +base_info_get_name (BaseInfo *info) +{ + return info->name; +} + +void +base_info_set_name (BaseInfo *info, + const char *name) +{ + char *old; + + old = info->name; + info->name = g_strdup (name); + g_free (old); +} + +GType +base_info_get_gtype (void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("BaseInfo", + (GBoxedCopyFunc) base_info_ref, + (GBoxedFreeFunc) base_info_unref); + + return our_type; +} + static void free_interface_list (GSList **interfaces_p) { @@ -77,6 +165,20 @@ free_interface_list (GSList **interfaces_p) *interfaces_p = NULL; } +static void +free_node_list (GSList **nodes_p) +{ + GSList *tmp; + tmp = *nodes_p; + while (tmp != NULL) + { + node_info_unref (tmp->data); + tmp = tmp->next; + } + g_slist_free (*nodes_p); + *nodes_p = NULL; +} + static void free_method_list (GSList **methods_p) { @@ -113,34 +215,35 @@ node_info_new (const char *name) /* name can be NULL */ info = g_new0 (NodeInfo, 1); - info->refcount = 1; - info->name = g_strdup (name); - + info->base.refcount = 1; + info->base.name = g_strdup (name); + info->base.type = INFO_TYPE_NODE; + return info; } void node_info_ref (NodeInfo *info) { - info->refcount += 1; + info->base.refcount += 1; } void node_info_unref (NodeInfo *info) { - info->refcount -= 1; - if (info->refcount == 0) + info->base.refcount -= 1; + if (info->base.refcount == 0) { free_interface_list (&info->interfaces); - g_free (info->name); - g_free (info); + free_node_list (&info->nodes); + base_info_free (info); } } const char* node_info_get_name (NodeInfo *info) { - return info->name; + return info->base.name; } GSList* @@ -157,6 +260,19 @@ node_info_add_interface (NodeInfo *info, info->interfaces = g_slist_append (info->interfaces, interface); } +GSList* +node_info_get_nodes (NodeInfo *info) +{ + return info->nodes; +} + +void +node_info_add_node (NodeInfo *info, + NodeInfo *node) +{ + node_info_ref (node); + info->nodes = g_slist_append (info->nodes, node); +} InterfaceInfo* interface_info_new (const char *name) @@ -164,35 +280,35 @@ interface_info_new (const char *name) InterfaceInfo *info; info = g_new0 (InterfaceInfo, 1); - info->refcount = 1; - info->name = g_strdup (name); - + info->base.refcount = 1; + info->base.name = g_strdup (name); + info->base.type = INFO_TYPE_INTERFACE; + return info; } void interface_info_ref (InterfaceInfo *info) { - info->refcount += 1; + info->base.refcount += 1; } void interface_info_unref (InterfaceInfo *info) { - info->refcount -= 1; - if (info->refcount == 0) + info->base.refcount -= 1; + if (info->base.refcount == 0) { free_method_list (&info->methods); free_signal_list (&info->signals); - g_free (info->name); - g_free (info); + base_info_free (info); } } const char* interface_info_get_name (InterfaceInfo *info) { - return info->name; + return info->base.name; } GSList* @@ -243,34 +359,34 @@ method_info_new (const char *name) MethodInfo *info; info = g_new0 (MethodInfo, 1); - info->refcount = 1; - info->name = g_strdup (name); - + info->base.refcount = 1; + info->base.name = g_strdup (name); + info->base.type = INFO_TYPE_METHOD; + return info; } void method_info_ref (MethodInfo *info) { - info->refcount += 1; + info->base.refcount += 1; } void method_info_unref (MethodInfo *info) { - info->refcount -= 1; - if (info->refcount == 0) + info->base.refcount -= 1; + if (info->base.refcount == 0) { free_arg_list (&info->args); - g_free (info->name); - g_free (info); + base_info_free (info); } } const char* method_info_get_name (MethodInfo *info) { - return info->name; + return info->base.name; } GSList* @@ -293,34 +409,34 @@ signal_info_new (const char *name) SignalInfo *info; info = g_new0 (SignalInfo, 1); - info->refcount = 1; - info->name = g_strdup (name); - + info->base.refcount = 1; + info->base.name = g_strdup (name); + info->base.type = INFO_TYPE_SIGNAL; + return info; } void signal_info_ref (SignalInfo *info) { - info->refcount += 1; + info->base.refcount += 1; } void signal_info_unref (SignalInfo *info) { - info->refcount -= 1; - if (info->refcount == 0) + info->base.refcount -= 1; + if (info->base.refcount == 0) { free_arg_list (&info->args); - g_free (info->name); - g_free (info); + base_info_free (info); } } const char* signal_info_get_name (SignalInfo *info) { - return info->name; + return info->base.name; } GSList* @@ -345,10 +461,11 @@ arg_info_new (const char *name, ArgInfo *info; info = g_new0 (ArgInfo, 1); - info->refcount = 1; - + info->base.refcount = 1; + info->base.type = INFO_TYPE_ARG; + /* name can be NULL */ - info->name = g_strdup (name); + info->base.name = g_strdup (name); info->direction = direction; info->type = type; @@ -358,23 +475,22 @@ arg_info_new (const char *name, void arg_info_ref (ArgInfo *info) { - info->refcount += 1; + info->base.refcount += 1; } void arg_info_unref (ArgInfo *info) { - info->refcount -= 1; - if (info->refcount == 0) + info->base.refcount -= 1; + if (info->base.refcount == 0) { - g_free (info->name); - g_free (info); + base_info_free (info); } } const char* arg_info_get_name (ArgInfo *info) { - return info->name; + return info->base.name; } int -- cgit