dbus/dbus dbus-marshal-basic.c, 1.7, 1.8 dbus-marshal-recursive.c, 1.27, 1.28

Havoc Pennington hp at freedesktop.org
Sat Jan 1 18:47:53 PST 2005


Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv17933

Modified Files:
	dbus-marshal-basic.c dbus-marshal-recursive.c 
Log Message:
change strings to be marshaled consistently with the other basic types (address of the value passed in, so char**)


Index: dbus-marshal-basic.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-basic.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dbus-marshal-basic.c	1 Jan 2005 21:05:48 -0000	1.7
+++ dbus-marshal-basic.c	2 Jan 2005 02:47:51 -0000	1.8
@@ -999,12 +999,17 @@
 }
 
 /**
- * Marshals a basic type
+ * Marshals a basic type. The "value" pointer is always the
+ * address of a variable containing the basic type value.
+ * So for example for int32 it will be dbus_int32_t*, and
+ * for string it will be const char**. This is for symmetry
+ * with _dbus_demarshal_basic_type() and to have a simple
+ * consistent rule.
  *
  * @param str string to marshal to
  * @param insert_at where to insert the value
  * @param type type of value
- * @param value pointer to value
+ * @param value pointer to a variable containing the value
  * @param byte_order byte order
  * @param pos_after #NULL or the position after the type
  * @returns #TRUE on success
@@ -1051,10 +1056,10 @@
       break;
     case DBUS_TYPE_STRING:
     case DBUS_TYPE_OBJECT_PATH:
-      return marshal_string (str, insert_at, (const char*) value, byte_order, pos_after);
+      return marshal_string (str, insert_at, *(const char**) value, byte_order, pos_after);
       break;
     case DBUS_TYPE_SIGNATURE:
-      return marshal_signature (str, insert_at, (const char*) value, pos_after);
+      return marshal_signature (str, insert_at, *(const char**) value, pos_after);
       break;
     default:
       _dbus_assert_not_reached ("not a basic type");
@@ -1285,10 +1290,7 @@
 
 #define MARSHAL_TEST_STRCMP(typename, byte_order, literal)                              \
   do {                                                                                  \
-    if (!_dbus_marshal_basic_type (&str, pos, DBUS_TYPE_##typename,                     \
-                                   literal,                                             \
-                                   byte_order, NULL))                                   \
-       _dbus_assert_not_reached ("no memory");                                          \
+    MARSHAL_BASIC (typename, byte_order, literal);                                      \
     dump_pos = pos;                                                                     \
     DEMARSHAL_BASIC (typename, byte_order);                                             \
     if (strcmp (literal, v_##typename) != 0)                                            \

Index: dbus-marshal-recursive.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-recursive.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- dbus-marshal-recursive.c	2 Jan 2005 02:38:23 -0000	1.27
+++ dbus-marshal-recursive.c	2 Jan 2005 02:47:51 -0000	1.28
@@ -2871,13 +2871,14 @@
                     int             seed)
 {
   char buf[MAX_SAMPLE_STRING_LEN];
+  const char *v_string = buf;
 
   string_from_seed (buf, node->klass->subclass_detail,
                     seed);
-
+  
   return _dbus_type_writer_write_basic (writer,
                                         node->klass->typecode,
-                                        buf);
+                                        &v_string);
 }
 
 static dbus_bool_t
@@ -3063,12 +3064,13 @@
                          int             seed)
 {
   char buf[MAX_SAMPLE_OBJECT_PATH_LEN];
-
+  const char *v_string = buf;
+  
   object_path_from_seed (buf, seed);
 
   return _dbus_type_writer_write_basic (writer,
                                         node->klass->typecode,
-                                        buf);
+                                        &v_string);
 }
 
 static dbus_bool_t
@@ -3129,12 +3131,13 @@
                        int             seed)
 {
   char buf[MAX_SAMPLE_SIGNATURE_LEN];
-
+  const char *v_string = buf;
+  
   signature_from_seed (buf, seed);
 
   return _dbus_type_writer_write_basic (writer,
                                         node->klass->typecode,
-                                        buf);
+                                        &v_string);
 }
 
 static dbus_bool_t



More information about the dbus-commit mailing list