dbus/dbus dbus-marshal-basic.c, 1.18, 1.19 dbus-marshal-basic.h, 1.15, 1.16 dbus-marshal-recursive-util.c, 1.1, 1.2 dbus-marshal-validate.c, 1.3, 1.4 dbus-message-builder.c, 1.27, 1.28 dbus-message-util.c, 1.1, 1.2 dbus-types.h, 1.10, 1.11

Havoc Pennington hp@freedesktop.org
Mon Jan 17 11:49:54 PST 2005


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

Modified Files:
	dbus-marshal-basic.c dbus-marshal-basic.h 
	dbus-marshal-recursive-util.c dbus-marshal-validate.c 
	dbus-message-builder.c dbus-message-util.c dbus-types.h 
Log Message:
2005-01-17  Havoc Pennington  <hp@redhat.com>

	* dbus/dbus-types.h: hardcode dbus_bool_t to 32 bits

	* Throughout: modify DBUS_TYPE_BOOLEAN to be a 32-bit type instead
	of an 8-bit type. Now dbus_bool_t is the type to use whenever you 
	are marshaling/unmarshaling a boolean.



Index: dbus-marshal-basic.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-basic.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- dbus-marshal-basic.c	17 Jan 2005 03:53:40 -0000	1.18
+++ dbus-marshal-basic.c	17 Jan 2005 19:49:52 -0000	1.19
@@ -343,7 +343,6 @@
   switch (type)
     {
     case DBUS_TYPE_BYTE:
-    case DBUS_TYPE_BOOLEAN:
       _dbus_string_set_byte (str, pos, vp->byt);
       if (old_end_pos)
         *old_end_pos = pos + 1;
@@ -351,6 +350,7 @@
         *new_end_pos = pos + 1;
       return TRUE;
       break;
+    case DBUS_TYPE_BOOLEAN:
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
       pos = _DBUS_ALIGN_VALUE (pos, 4);
@@ -457,12 +457,12 @@
   switch (type)
     {
     case DBUS_TYPE_BYTE:
-    case DBUS_TYPE_BOOLEAN:
       vp->byt = _dbus_string_get_byte (str, pos);
       (pos)++;
       break;
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
+    case DBUS_TYPE_BOOLEAN:
       pos = _DBUS_ALIGN_VALUE (pos, 4);
       vp->u32 = *(dbus_uint32_t *)(str_data + pos);
       if (byte_order != DBUS_COMPILER_BYTE_ORDER)
@@ -756,13 +756,16 @@
   switch (type)
     {
     case DBUS_TYPE_BYTE:
-    case DBUS_TYPE_BOOLEAN:
       if (!_dbus_string_insert_byte (str, insert_at, vp->byt))
         return FALSE;
       if (pos_after)
         *pos_after = insert_at + 1;
       return TRUE;
       break;
+    case DBUS_TYPE_BOOLEAN:
+      return marshal_4_octets (str, insert_at, vp->u32 != FALSE,
+                               byte_order, pos_after);
+      break;
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
       return marshal_4_octets (str, insert_at, vp->u32,
@@ -952,12 +955,12 @@
   
   switch (element_type)
     {
-    case DBUS_TYPE_BOOLEAN:
-      /* FIXME: we canonicalize to 0 or 1 for the single boolean case
-       * should we here too ? */
     case DBUS_TYPE_BYTE:
       return marshal_1_octets_array (str, insert_at, vp, n_elements, byte_order, pos_after);
       break;
+      /* FIXME: we canonicalize to 0 or 1 for the single boolean case
+       * should we here too ? */
+    case DBUS_TYPE_BOOLEAN:
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
       return marshal_fixed_multi (str, insert_at, vp, n_elements, byte_order, 4, pos_after);
@@ -998,9 +1001,9 @@
   switch (type)
     {
     case DBUS_TYPE_BYTE:
-    case DBUS_TYPE_BOOLEAN:
       (*pos)++;
       break;
+    case DBUS_TYPE_BOOLEAN:
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
       *pos = _DBUS_ALIGN_VALUE (*pos, 4);
@@ -1082,10 +1085,10 @@
   switch (typecode)
     {
     case DBUS_TYPE_BYTE:
-    case DBUS_TYPE_BOOLEAN:
     case DBUS_TYPE_VARIANT:
     case DBUS_TYPE_SIGNATURE:
       return 1;
+    case DBUS_TYPE_BOOLEAN:
     case DBUS_TYPE_INT32:
     case DBUS_TYPE_UINT32:
       /* this stuff is 4 since it starts with a length */
@@ -1528,7 +1531,7 @@
   dbus_int64_t v_INT64;
   dbus_uint64_t v_UINT64;
   unsigned char v_BYTE;
-  unsigned char v_BOOLEAN;
+  dbus_bool_t v_BOOLEAN;
   const char *v_STRING;
   const char *v_SIGNATURE;
   const char *v_OBJECT_PATH;

Index: dbus-marshal-basic.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-basic.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- dbus-marshal-basic.h	17 Jan 2005 03:53:40 -0000	1.15
+++ dbus-marshal-basic.h	17 Jan 2005 19:49:52 -0000	1.16
@@ -141,7 +141,6 @@
 #endif
   double dbl;          /**< as double */
   unsigned char byt;   /**< as byte */
-  unsigned char boo;   /**< as boolean */
   char *str;           /**< as char* */
 } DBusBasicValue;
 

Index: dbus-marshal-recursive-util.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-recursive-util.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbus-marshal-recursive-util.c	17 Jan 2005 03:53:40 -0000	1.1
+++ dbus-marshal-recursive-util.c	17 Jan 2005 19:49:52 -0000	1.2
@@ -2141,7 +2141,7 @@
                                       realign_root);
 }
 
-#define BOOL_FROM_SEED(seed) (seed % 2)
+#define BOOL_FROM_SEED(seed) ((dbus_bool_t)((seed) % 2))
 
 static dbus_bool_t
 bool_write_value (TestTypeNode   *node,
@@ -2149,7 +2149,7 @@
                   DBusTypeWriter *writer,
                   int             seed)
 {
-  unsigned char v;
+  dbus_bool_t v;
 
   v = BOOL_FROM_SEED (seed);
 
@@ -2163,7 +2163,7 @@
                  DBusTypeReader *reader,
                  int             seed)
 {
-  unsigned char v;
+  dbus_bool_t v;
 
   check_expected_type (reader, node->klass->typecode);
 
@@ -2181,7 +2181,7 @@
                 DBusTypeReader *realign_root,
                 int             seed)
 {
-  unsigned char v;
+  dbus_bool_t v;
 
   v = BOOL_FROM_SEED (seed);
 

Index: dbus-marshal-validate.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-validate.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dbus-marshal-validate.c	16 Jan 2005 15:51:55 -0000	1.3
+++ dbus-marshal-validate.c	17 Jan 2005 19:49:52 -0000	1.4
@@ -159,11 +159,6 @@
           break;
 
         case DBUS_TYPE_BOOLEAN:
-          if (!(*p == 0 || *p == 1))
-            return DBUS_INVALID_BOOLEAN_NOT_ZERO_OR_ONE;
-          ++p;
-          break;
-
         case DBUS_TYPE_INT32:
         case DBUS_TYPE_UINT32:
         case DBUS_TYPE_INT64:
@@ -179,6 +174,15 @@
                 return DBUS_INVALID_ALIGNMENT_PADDING_NOT_NUL;
               ++p;
             }
+          
+          if (current_type == DBUS_TYPE_BOOLEAN)
+            {
+              dbus_uint32_t v = _dbus_unpack_uint32 (byte_order,
+                                                     p);
+              if (!(v == 0 || v == 1))
+                return DBUS_INVALID_BOOLEAN_NOT_ZERO_OR_ONE;
+            }
+          
           p += alignment;
           break;
 

Index: dbus-message-builder.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-message-builder.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- dbus-message-builder.c	17 Jan 2005 03:53:40 -0000	1.27
+++ dbus-message-builder.c	17 Jan 2005 19:49:52 -0000	1.28
@@ -456,9 +456,9 @@
   switch (type)
     {
     case DBUS_TYPE_BYTE:
-    case DBUS_TYPE_BOOLEAN:
       align = 1;
       break;
+    case DBUS_TYPE_BOOLEAN:
     case DBUS_TYPE_UINT32:
     case DBUS_TYPE_INT32:
       align = 4;
@@ -514,9 +514,9 @@
   switch (type)
     {
     case DBUS_TYPE_BYTE:
-    case DBUS_TYPE_BOOLEAN:
       elem_size = 1;
       break;
+    case DBUS_TYPE_BOOLEAN:
     case DBUS_TYPE_UINT32:
     case DBUS_TYPE_INT32:
       elem_size = 4;

Index: dbus-message-util.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-message-util.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbus-message-util.c	17 Jan 2005 03:53:40 -0000	1.1
+++ dbus-message-util.c	17 Jan 2005 19:49:52 -0000	1.2
@@ -599,7 +599,7 @@
   dbus_uint64_t v_UINT64;
 #endif
   unsigned char v_BYTE;
-  unsigned char v_BOOLEAN;
+  dbus_bool_t v_BOOLEAN;
 
   const dbus_int32_t *our_int_array;
   int len;
@@ -659,7 +659,7 @@
   dbus_int32_t our_int;
   const char *our_str;
   double our_double;
-  unsigned char our_bool;
+  dbus_bool_t our_bool;
   unsigned char our_byte_1, our_byte_2;
   dbus_uint32_t our_uint32;
   const dbus_int32_t *our_uint32_array = (void*)0xdeadbeef;
@@ -678,7 +678,7 @@
   int our_double_array_len;
   const unsigned char *our_byte_array = (void*)0xdeadbeef;
   int our_byte_array_len;
-  const unsigned char *our_boolean_array = (void*)0xdeadbeef;
+  const dbus_bool_t *our_boolean_array = (void*)0xdeadbeef;
   int our_boolean_array_len;
 
   dbus_message_iter_init (message, &iter);
@@ -844,8 +844,8 @@
   const double *v_ARRAY_DOUBLE = our_double_array;
   const unsigned char our_byte_array[] = { 'a', 'b', 'c', 234 };
   const unsigned char *v_ARRAY_BYTE = our_byte_array;
-  const unsigned char our_boolean_array[] = { TRUE, FALSE, TRUE, TRUE, FALSE };
-  const unsigned char *v_ARRAY_BOOLEAN = our_boolean_array;
+  const dbus_bool_t our_boolean_array[] = { TRUE, FALSE, TRUE, TRUE, FALSE };
+  const dbus_bool_t *v_ARRAY_BOOLEAN = our_boolean_array;
   char sig[64];
   const char *s;
   char *t;
@@ -860,7 +860,7 @@
 #endif
   unsigned char v_BYTE;
   unsigned char v2_BYTE;
-  unsigned char v_BOOLEAN;
+  dbus_bool_t v_BOOLEAN;
 
   message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService",
                                           "/org/freedesktop/TestPath",

Index: dbus-types.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-types.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dbus-types.h	10 Aug 2004 03:07:00 -0000	1.10
+++ dbus-types.h	17 Jan 2005 19:49:52 -0000	1.11
@@ -29,12 +29,13 @@
 
 #include <stddef.h>
 
-typedef unsigned int   dbus_bool_t;
 typedef unsigned short dbus_uint16_t;
 typedef short          dbus_int16_t;
 typedef unsigned int   dbus_uint32_t;
 typedef int            dbus_int32_t;
 typedef dbus_uint32_t  dbus_unichar_t;
+/* boolean size must be fixed at 4 bytes due to wire protocol! */
+typedef dbus_uint32_t  dbus_bool_t;
 
 /* Normally docs are in .c files, but there isn't a .c file for this. */
 /**



More information about the dbus-commit mailing list