dbus/dbus dbus-marshal-recursive.c, 1.11, 1.12 dbus-marshal-recursive.h, 1.10, 1.11

Havoc Pennington hp at freedesktop.org
Thu Dec 30 15:34:26 PST 2004


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

Modified Files:
	dbus-marshal-recursive.c dbus-marshal-recursive.h 
Log Message:
- add variant reader
- further squish the iterator structs



Index: dbus-marshal-recursive.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-recursive.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- dbus-marshal-recursive.c	30 Dec 2004 22:44:44 -0000	1.11
+++ dbus-marshal-recursive.c	30 Dec 2004 23:34:23 -0000	1.12
@@ -145,8 +145,37 @@
                  _dbus_type_to_string (sub->u.array.element_type));
 }
 
+static void
+variant_reader_recurse (DBusTypeReader *sub,
+                        DBusTypeReader *parent)
+{
+  int sig_len;
+
+  _dbus_assert (!_dbus_type_reader_array_is_empty (parent));
+  
+  base_reader_recurse (sub, parent);
+
+  /* Variant is 1 byte sig length (without nul), signature with nul,
+   * padding to 8-boundary, then values
+   */
+
+  sig_len = _dbus_string_get_byte (sub->value_str, sub->value_pos);
+
+  sub->type_str = sub->value_str;
+  sub->type_pos = sub->value_pos + 1;
+  
+  sub->value_pos = sub->type_pos + sig_len + 1;
+  
+  sub->value_pos = _DBUS_ALIGN_VALUE (sub->value_pos, 8);
+
+  _dbus_verbose ("    type reader %p variant containing '%s'\n",
+                 sub,
+                 _dbus_string_get_const_data_len (sub->type_str,
+                                                  sub->type_pos, 0));
+}
+
 static int
-body_reader_get_current_type (DBusTypeReader *reader)
+base_reader_get_current_type (DBusTypeReader *reader)
 {
   int t;
 
@@ -369,7 +398,7 @@
 static const DBusTypeReaderClass body_reader_class = {
   "body",
   NULL, /* body is always toplevel, so doesn't get recursed into */
-  body_reader_get_current_type,
+  base_reader_get_current_type,
   base_reader_next
 };
 
@@ -387,6 +416,13 @@
   array_reader_next
 };
 
+static const DBusTypeReaderClass variant_reader_class = {
+  "variant",
+  variant_reader_recurse,
+  base_reader_get_current_type,
+  base_reader_next
+};
+
 void
 _dbus_type_reader_init (DBusTypeReader    *reader,
                         int                byte_order,
@@ -503,6 +539,9 @@
     case DBUS_TYPE_ARRAY:
       sub->klass = &array_reader_class;
       break;
+    case DBUS_TYPE_VARIANT:
+      sub->klass = &variant_reader_class;
+      break;
     default:
       _dbus_verbose ("recursing into type %s\n", _dbus_type_to_string (t));
 #ifndef DBUS_DISABLE_CHECKS

Index: dbus-marshal-recursive.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-recursive.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dbus-marshal-recursive.h	30 Dec 2004 22:46:13 -0000	1.10
+++ dbus-marshal-recursive.h	30 Dec 2004 23:34:23 -0000	1.11
@@ -37,7 +37,8 @@
 
 struct DBusTypeReader
 {
-  int byte_order;
+  dbus_uint32_t byte_order : 8;
+  
   const DBusString *type_str;
   int type_pos;
   const DBusString *value_str;
@@ -60,15 +61,16 @@
 
 struct DBusTypeWriter
 {
-  int byte_order;
+  dbus_uint32_t byte_order : 8;
+
+  dbus_uint32_t container_type : 8;
+
+  dbus_uint32_t type_pos_is_expectation : 1; /* type_pos is an insertion point or an expected next type */
   DBusString *type_str;
   int type_pos;
   DBusString *value_str;
   int value_pos;
 
-  dbus_uint32_t type_pos_is_expectation : 1; /* type_pos is an insertion point or an expected next type */
-
-  dbus_uint32_t container_type : 8;
   union
   {
     struct {



More information about the dbus-commit mailing list