summaryrefslogtreecommitdiffstats
path: root/glib/dbus-binding-tool-glib.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2005-03-09 17:09:11 +0000
committerColin Walters <walters@verbum.org>2005-03-09 17:09:11 +0000
commit74b1b35402f6b9bbc09999a6224dfc04bc48b2a9 (patch)
treec9cae2dde5d4b11d4cf7e17e5c3009280e1f8ee5 /glib/dbus-binding-tool-glib.c
parent2958e723fc996e2dd7edfdc6ac53dcdf48323549 (diff)
2005-03-09 Colin Walters <walters@verbum.org>
* glib/dbus-gproxy.c (dbus_g_proxy_invoke): New method; calls to this are generated for client-side wrappers. Invokes a D-BUS method and returns reply values. * glib/dbus-binding-tool-glib.c (write_args_sig_for_direction): New function; writes signature string for argument direction. (write_args_for_direction): Change to pass input values directly instead of via address, and fix indentation. (generate_client_glue): Change to invoke dbus_g_proxy_invoke. Also make generated wrappers inlineable. * dbus/dbus-message.c (dbus_message_iter_get_fixed_array): Add note about using dbus_type_is_fixed. * dbus/dbus-marshal-basic.c (_dbus_type_is_fixed): Moved to dbus/dbus-signature.c as dbus_type_is_fixed. All callers updated. * dbus/dbus-signature.c (dbus_type_is_fixed): Moved here from dbus/dbus-marshal-basic.c:_dbus_type_is_fixed. * dbus/dbus-signature.h: Prototype. * glib/dbus-binding-tool-glib.c (compute_marshaller_name): Fix error printf code. * test/glib/test-dbus-glib.c (main): Be sure to clear error as appropriate instead of just freeing it. (main): Free returned strings using g_free. * test/glib/Makefile.am (test-service-glib-glue.h) (test-service-glib-bindings.h): Add dependency on dbus-binding-tool. * glib/dbus-gvalue.c (MAP_BASIC): Refactored from MAP_BASIC_INIT; simply maps a simple D-BUS type to GType. (dbus_dbus_type_to_gtype): Function which maps D-BUS type to GType. (dbus_gvalue_init): Just invoke dbus_dbus_type_to_gtype and initialize the value with it. (dbus_gvalue_binding_type_from_type): Unused, delete. (dbus_gvalue_demarshal): Switch to hardcoding demarshalling for various types instead of unmarshalling to value data directly. Remove can_convert boolean. (dbus_gvalue_marshal): Remove duplicate initialization; switch to returning directly instead of using can_convert boolean. (dbus_gvalue_store): New function; not related to D-BUS per-se. Stores a GValue in a pointer to a value of its corresponding C type. * glib/dbus-gvalue.h: Remove dbus_gvalue_binding_type_from_type, add dbus_gvalue_store.
Diffstat (limited to 'glib/dbus-binding-tool-glib.c')
-rw-r--r--glib/dbus-binding-tool-glib.c73
1 files changed, 41 insertions, 32 deletions
diff --git a/glib/dbus-binding-tool-glib.c b/glib/dbus-binding-tool-glib.c
index 641f07da..5bd413e1 100644
--- a/glib/dbus-binding-tool-glib.c
+++ b/glib/dbus-binding-tool-glib.c
@@ -140,7 +140,7 @@ compute_marshaller_name (MethodInfo *method, GError **error)
g_set_error (error,
DBUS_BINDING_TOOL_ERROR,
DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
- _("Unsupported conversion from D-BUS type %d to glib-genmarshal type"),
+ _("Unsupported conversion from D-BUS type %s to glib-genmarshal type"),
type);
g_string_free (ret, TRUE);
return NULL;
@@ -647,42 +647,54 @@ write_formal_parameters (InterfaceInfo *iface, MethodInfo *method, GIOChannel *c
}
static gboolean
-write_args_for_direction (InterfaceInfo *iface, MethodInfo *method, GIOChannel *channel, int direction, GError **error)
+write_args_sig_for_direction (InterfaceInfo *iface, MethodInfo *method, GIOChannel *channel, int direction, GError **error)
{
GSList *args;
+ WRITE_OR_LOSE ("\"");
+
for (args = method_info_get_args (method); args; args = args->next)
{
ArgInfo *arg;
- const char *type_str;
arg = args->data;
if (direction != arg_info_get_direction (arg))
continue;
- type_str = dbus_gvalue_binding_type_from_type (arg_info_get_type (arg));
- if (!type_str)
- {
- g_set_error (error,
- DBUS_BINDING_TOOL_ERROR,
- DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
- _("Unsupported conversion from D-BUS type %s"),
- arg_info_get_type (arg));
- return FALSE;
- }
+ if (!write_printf_to_iochannel ("%s", channel, error, arg_info_get_type (arg)))
+ goto io_lose;
+ }
+
+ WRITE_OR_LOSE ("\", ");
+
+ return TRUE;
+ io_lose:
+ return FALSE;
+}
+
+static gboolean
+write_args_for_direction (InterfaceInfo *iface, MethodInfo *method, GIOChannel *channel, int direction, GError **error)
+{
+ GSList *args;
+
+ for (args = method_info_get_args (method); args; args = args->next)
+ {
+ ArgInfo *arg;
+
+ arg = args->data;
+
+ if (direction != arg_info_get_direction (arg))
+ continue;
-
switch (direction)
{
case ARG_IN:
- if (!write_printf_to_iochannel (" %s, &IN_%s,\n", channel, error,
- type_str, arg_info_get_name (arg)))
+ if (!write_printf_to_iochannel ("IN_%s, ", channel, error, arg_info_get_name (arg)))
goto io_lose;
break;
case ARG_OUT:
- if (!write_printf_to_iochannel (" %s, OUT_%s,\n", channel, error,
- type_str, arg_info_get_name (arg)))
+ if (!write_printf_to_iochannel ("OUT_%s, ", channel, error, arg_info_get_name (arg)))
goto io_lose;
break;
case ARG_INVALID:
@@ -746,7 +758,7 @@ generate_client_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error
method_name = compute_client_method_name (interface, method);
- WRITE_OR_LOSE ("static gboolean\n");
+ WRITE_OR_LOSE ("static\n#ifdef G_HAVE_INLINE\ninline\n#endif\ngboolean\n");
if (!write_printf_to_iochannel ("%s (DBusGProxy *proxy", channel, error,
method_name))
goto io_lose;
@@ -758,29 +770,26 @@ generate_client_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error
WRITE_OR_LOSE (", GError **error)\n\n");
WRITE_OR_LOSE ("{\n");
- WRITE_OR_LOSE (" gboolean ret;\n\n");
- WRITE_OR_LOSE (" DBusGPendingCall *call;\n\n");
- if (!write_printf_to_iochannel (" call = dbus_g_proxy_begin_call (proxy, \"%s\",\n",
- channel, error,
+ if (!write_printf_to_iochannel (" return dbus_g_proxy_invoke (proxy, \"%s\", ", channel, error,
method_info_get_name (method)))
goto io_lose;
- if (!write_args_for_direction (interface, method, channel, ARG_IN, error))
+ if (!write_args_sig_for_direction (interface, method, channel, ARG_IN, error))
goto io_lose;
- WRITE_OR_LOSE (" DBUS_TYPE_INVALID);\n");
- WRITE_OR_LOSE (" ret = dbus_g_proxy_end_call (proxy, call, error,\n");
-
- if (!write_args_for_direction (interface, method, channel, ARG_OUT, error))
+ if (!write_args_sig_for_direction (interface, method, channel, ARG_OUT, error))
goto io_lose;
- WRITE_OR_LOSE (" DBUS_TYPE_INVALID);\n");
+ WRITE_OR_LOSE ("error, ");
- WRITE_OR_LOSE (" dbus_g_pending_call_unref (call);\n");
- WRITE_OR_LOSE (" return ret;\n");
+ if (!write_args_for_direction (interface, method, channel, ARG_IN, error))
+ goto io_lose;
+
+ if (!write_args_for_direction (interface, method, channel, ARG_OUT, error))
+ goto io_lose;
- WRITE_OR_LOSE ("}\n\n");
+ WRITE_OR_LOSE ("NULL);\n}\n\n");
}
}
return TRUE;