dbus/glib dbus-gobject.c, 1.10, 1.11 dbus-gproxy.c, 1.12,
1.13 dbus-gutils.c, 1.6, 1.7 dbus-gvalue.c, 1.2, 1.3
Havoc Pennington
hp@freedesktop.org
Fri Jan 14 23:15:40 PST 2005
Update of /cvs/dbus/dbus/glib
In directory gabe:/tmp/cvs-serv28195/glib
Modified Files:
dbus-gobject.c dbus-gproxy.c dbus-gutils.c dbus-gvalue.c
Log Message:
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
Index: dbus-gobject.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gobject.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dbus-gobject.c 10 Aug 2004 03:07:00 -0000 1.10
+++ dbus-gobject.c 15 Jan 2005 07:15:38 -0000 1.11
@@ -308,7 +308,7 @@
g_error ("Out of memory");
dbus_message_append_args (message,
- DBUS_TYPE_STRING, xml->str,
+ DBUS_TYPE_STRING, &xml->str,
DBUS_TYPE_INVALID);
dbus_connection_send (connection, message, NULL);
Index: dbus-gproxy.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gproxy.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dbus-gproxy.c 10 Aug 2004 03:07:01 -0000 1.12
+++ dbus-gproxy.c 15 Jan 2005 07:15:38 -0000 1.13
@@ -941,8 +941,8 @@
DBusGProxy *proxy;
DBusMessage *request, *reply;
DBusError derror;
- char *base_service_name;
-
+ const char *base_service_name;
+
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (service_name != NULL, NULL);
g_return_val_if_fail (path_name != NULL, NULL);
@@ -962,7 +962,7 @@
g_error ("Out of memory");
if (! dbus_message_append_args (request,
- DBUS_TYPE_STRING, service_name,
+ DBUS_TYPE_STRING, &service_name,
DBUS_TYPE_INVALID))
g_error ("Out of memory");
@@ -997,7 +997,6 @@
dbus_message_unref (request);
if (reply)
dbus_message_unref (reply);
- dbus_free (base_service_name);
return proxy;
}
Index: dbus-gutils.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gutils.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dbus-gutils.c 10 Aug 2004 03:07:01 -0000 1.6
+++ dbus-gutils.c 15 Jan 2005 07:15:38 -0000 1.7
@@ -84,10 +84,10 @@
{
case DBUS_TYPE_INVALID:
return "invalid";
- case DBUS_TYPE_NIL:
- return "nil";
case DBUS_TYPE_BOOLEAN:
return "boolean";
+ case DBUS_TYPE_BYTE:
+ return "byte";
case DBUS_TYPE_INT32:
return "int32";
case DBUS_TYPE_UINT32:
@@ -96,16 +96,20 @@
return "double";
case DBUS_TYPE_STRING:
return "string";
- case DBUS_TYPE_CUSTOM:
- return "custom";
+ case DBUS_TYPE_OBJECT_PATH:
+ return "object_path";
+ case DBUS_TYPE_SIGNATURE:
+ return "signature";
+ case DBUS_TYPE_STRUCT:
+ return "struct";
case DBUS_TYPE_ARRAY:
return "array";
- case DBUS_TYPE_DICT:
- return "dict";
- case DBUS_TYPE_INT64:
- return "int64";
- case DBUS_TYPE_UINT64:
- return "uint64";
+ case DBUS_TYPE_VARIANT:
+ return "variant";
+ case DBUS_STRUCT_BEGIN_CHAR:
+ return "begin_struct";
+ case DBUS_STRUCT_END_CHAR:
+ return "end_struct";
default:
return "unknown";
}
Index: dbus-gvalue.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gvalue.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dbus-gvalue.c 28 May 2004 13:10:36 -0000 1.2
+++ dbus-gvalue.c 15 Jan 2005 07:15:38 -0000 1.3
@@ -1,3 +1,26 @@
+/* -*- mode: C; c-file-style: "gnu" -*- */
+/* dbus-gvalue.c GValue to-from DBusMessageIter
+ *
+ * Copyright (C) 2004 Ximian, Inc.
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * 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-gvalue.h>
gboolean
@@ -5,41 +28,43 @@
{
gboolean can_convert = TRUE;
+ /* This is slightly evil, we don't use g_value_set_foo() functions */
+#define MAP_BASIC(d_t, g_t) \
+ case DBUS_TYPE_##d_t: \
+ g_value_init (value, G_TYPE_##g_t); \
+ dbus_message_iter_get_basic (iter, &value->data[0]); \
+ break
+
switch (dbus_message_iter_get_arg_type (iter))
{
-#define MAP(d_t, d_get, g_t, g_set) \
- case DBUS_##d_t: \
- g_value_init (value, G_##g_t); \
- g_value_##g_set (value, dbus_message_iter_##d_get (iter)); \
- break
-
- MAP(TYPE_BYTE, get_byte, TYPE_UCHAR, set_uchar);
- MAP(TYPE_BOOLEAN, get_boolean, TYPE_BOOLEAN , set_boolean);
- MAP(TYPE_INT32, get_int32, TYPE_INT , set_int);
- MAP(TYPE_UINT32, get_uint32, TYPE_UINT , set_uint);
-#ifdef DBUS_HAVE_INT64
- MAP(TYPE_INT64, get_int64, TYPE_INT64 , set_int64);
- MAP(TYPE_UINT64, get_uint64, TYPE_UINT64 , set_uint64);
-#endif
- MAP(TYPE_DOUBLE, get_double, TYPE_DOUBLE , set_double);
+ MAP_BASIC (BOOLEAN, BOOLEAN);
+ MAP_BASIC (BYTE, UCHAR);
+ MAP_BASIC (INT32, INT);
+ MAP_BASIC (UINT32, UINT);
+ MAP_BASIC (INT64, INT64);
+ MAP_BASIC (UINT64, UINT64);
+ MAP_BASIC (DOUBLE, DOUBLE);
+
case DBUS_TYPE_STRING:
+ case DBUS_TYPE_OBJECT_PATH:
+ case DBUS_TYPE_SIGNATURE:
{
- char *s; /* FIXME use a const string accessor */
+ const char *s;
g_value_init (value, G_TYPE_STRING);
- s = dbus_message_iter_get_string (iter);
+ dbus_message_iter_get_basic (iter, &s);
g_value_set_string (value, s);
- g_free (s);
}
break;
+
+ case DBUS_TYPE_STRUCT:
+ case DBUS_TYPE_ARRAY:
+ case DBUS_TYPE_VARIANT:
default:
- /* FIXME: we need to define custom boxed types for arrays
- etc. so we can map them transparently / pleasantly */
can_convert = FALSE;
- break;
}
-#undef MAP
+#undef MAP_BASIC
return can_convert;
}
@@ -54,59 +79,120 @@
switch (value_type)
{
case G_TYPE_CHAR:
- dbus_message_iter_append_byte (iter,
- g_value_get_char (value));
+ {
+ char b = g_value_get_char (value);
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_BYTE,
+ &b))
+ goto nomem;
+ }
break;
case G_TYPE_UCHAR:
- dbus_message_iter_append_byte (iter,
- g_value_get_uchar (value));
+ {
+ unsigned char b = g_value_get_uchar (value);
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_BYTE,
+ &b))
+ goto nomem;
+ }
break;
case G_TYPE_BOOLEAN:
- dbus_message_iter_append_boolean (iter,
- g_value_get_boolean (value));
+ {
+ unsigned char b = g_value_get_boolean (value);
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_BOOLEAN,
+ &b))
+ goto nomem;
+ }
break;
case G_TYPE_INT:
- dbus_message_iter_append_int32 (iter,
- g_value_get_int (value));
+ {
+ dbus_int32_t v = g_value_get_int (value);
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_INT32,
+ &v))
+ goto nomem;
+ }
break;
case G_TYPE_UINT:
- dbus_message_iter_append_uint32 (iter,
- g_value_get_uint (value));
+ {
+ dbus_uint32_t v = g_value_get_uint (value);
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_UINT32,
+ &v))
+ goto nomem;
+ }
break;
/* long gets cut to 32 bits so the remote API is consistent
* on all architectures
*/
case G_TYPE_LONG:
- dbus_message_iter_append_int32 (iter,
- g_value_get_long (value));
+ {
+ dbus_int32_t v = g_value_get_long (value);
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_INT32,
+ &v))
+ goto nomem;
+ }
break;
case G_TYPE_ULONG:
- dbus_message_iter_append_uint32 (iter,
- g_value_get_ulong (value));
+ {
+ dbus_uint32_t v = g_value_get_ulong (value);
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_UINT32,
+ &v))
+ goto nomem;
+ }
break;
-#ifdef DBUS_HAVE_INT64
case G_TYPE_INT64:
- dbus_message_iter_append_int64 (iter,
- g_value_get_int64 (value));
+ {
+ gint64 v = g_value_get_int64 (value);
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_INT64,
+ &v))
+ goto nomem;
+ }
break;
case G_TYPE_UINT64:
- dbus_message_iter_append_uint64 (iter,
- g_value_get_uint64 (value));
+ {
+ guint64 v = g_value_get_uint64 (value);
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_UINT64,
+ &v))
+ goto nomem;
+ }
break;
-#endif
case G_TYPE_FLOAT:
- dbus_message_iter_append_double (iter,
- g_value_get_float (value));
+ {
+ double v = g_value_get_float (value);
+
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_DOUBLE,
+ &v))
+ goto nomem;
+ }
break;
case G_TYPE_DOUBLE:
- dbus_message_iter_append_double (iter,
- g_value_get_double (value));
+ {
+ double v = g_value_get_double (value);
+
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_DOUBLE,
+ &v))
+ goto nomem;
+ }
break;
case G_TYPE_STRING:
/* FIXME, the GValue string may not be valid UTF-8 */
- dbus_message_iter_append_string (iter,
- g_value_get_string (value));
+ {
+ const char *v = g_value_get_string (value);
+ if (!dbus_message_iter_append_basic (iter,
+ DBUS_TYPE_STRING,
+ &v))
+ goto nomem;
+ }
break;
+
default:
/* FIXME: we need to define custom boxed types for arrays
etc. so we can map them transparently / pleasantly */
@@ -115,5 +201,9 @@
}
return can_convert;
+
+ nomem:
+ g_error ("no memory");
+ return FALSE;
}
More information about the dbus-commit
mailing list