dbus/dbus dbus-marshal-recursive.c, 1.26, 1.27 dbus-marshal-recursive.h, 1.15, 1.16

Havoc Pennington hp at freedesktop.org
Sat Jan 1 18:38:25 PST 2005


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

Modified Files:
	dbus-marshal-recursive.c dbus-marshal-recursive.h 
Log Message:
make reader const-correct


Index: dbus-marshal-recursive.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-recursive.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- dbus-marshal-recursive.c	2 Jan 2005 02:17:05 -0000	1.26
+++ dbus-marshal-recursive.c	2 Jan 2005 02:38:23 -0000	1.27
@@ -36,13 +36,13 @@
   const char *name;
   int         id;         /* index in all_reader_classes */
   dbus_bool_t types_only; /* only iterates over types, not values */
-  void        (* recurse)          (DBusTypeReader     *sub,
-                                    DBusTypeReader     *parent);
-  int         (* get_current_type) (DBusTypeReader     *reader);
-  void        (* next)             (DBusTypeReader     *reader,
-                                    int                 current_type);
-  void        (* init_from_mark)   (DBusTypeReader     *reader,
-                                    const DBusTypeMark *mark);
+  void        (* recurse)          (DBusTypeReader        *sub,
+                                    DBusTypeReader        *parent);
+  int         (* get_current_type) (const DBusTypeReader  *reader);
+  void        (* next)             (DBusTypeReader        *reader,
+                                    int                    current_type);
+  void        (* init_from_mark)   (DBusTypeReader        *reader,
+                                    const DBusTypeMark    *mark);
 };
 
 static int
@@ -132,7 +132,7 @@
 }
 
 static int
-array_reader_get_array_len (DBusTypeReader *reader)
+array_reader_get_array_len (const DBusTypeReader *reader)
 {
   dbus_uint32_t array_len;
   int len_pos;
@@ -221,7 +221,7 @@
 }
 
 static int
-base_reader_get_current_type (DBusTypeReader *reader)
+base_reader_get_current_type (const DBusTypeReader *reader)
 {
   int t;
 
@@ -232,7 +232,7 @@
 }
 
 static int
-struct_reader_get_current_type (DBusTypeReader *reader)
+struct_reader_get_current_type (const DBusTypeReader *reader)
 {
   int t;
 
@@ -246,7 +246,7 @@
 }
 
 static int
-array_types_only_reader_get_current_type (DBusTypeReader *reader)
+array_types_only_reader_get_current_type (const DBusTypeReader *reader)
 {
   int t;
 
@@ -260,7 +260,7 @@
 }
 
 static int
-array_reader_get_current_type (DBusTypeReader *reader)
+array_reader_get_current_type (const DBusTypeReader *reader)
 {
   int t;
   int end_pos;
@@ -639,8 +639,8 @@
 }
 
 void
-_dbus_type_reader_save_mark (DBusTypeReader *reader,
-                             DBusTypeMark   *mark)
+_dbus_type_reader_save_mark (const DBusTypeReader *reader,
+                             DBusTypeMark         *mark)
 {
   mark->type_pos_in_value_str = (reader->type_str == reader->value_str);
   mark->container_type = reader->klass->id;
@@ -655,7 +655,7 @@
 }
 
 int
-_dbus_type_reader_get_current_type (DBusTypeReader *reader)
+_dbus_type_reader_get_current_type (const DBusTypeReader *reader)
 {
   int t;
 
@@ -674,7 +674,7 @@
 }
 
 dbus_bool_t
-_dbus_type_reader_array_is_empty (DBusTypeReader *reader)
+_dbus_type_reader_array_is_empty (const DBusTypeReader *reader)
 {
   dbus_uint32_t array_len;
 
@@ -700,8 +700,8 @@
 }
 
 void
-_dbus_type_reader_read_basic (DBusTypeReader    *reader,
-                              void              *value)
+_dbus_type_reader_read_basic (const DBusTypeReader    *reader,
+                              void                    *value)
 {
   int t;
 
@@ -723,10 +723,10 @@
 }
 
 dbus_bool_t
-_dbus_type_reader_read_array_of_basic (DBusTypeReader    *reader,
-                                       int                type,
-                                       void             **array,
-                                       int               *array_len)
+_dbus_type_reader_read_array_of_basic (const DBusTypeReader    *reader,
+                                       int                      type,
+                                       void                   **array,
+                                       int                     *array_len)
 {
   _dbus_assert (!reader->klass->types_only);
 
@@ -795,8 +795,8 @@
 
 /**
  * Skip to the next value on this "level". e.g. the next field in a
- * struct, the next value in an array, the next key or value in a
- * dict. Returns FALSE at the end of the current container.
+ * struct, the next value in an array. Returns FALSE at the end of the
+ * current container.
  *
  * @param reader the reader
  * @returns FALSE if nothing more to read at or below this level
@@ -830,6 +830,23 @@
   return _dbus_type_reader_get_current_type (reader) != DBUS_TYPE_INVALID;
 }
 
+/**
+ * Check whether there's another value on this "level". e.g. the next
+ * field in a struct, the next value in an array. Returns FALSE at the
+ * end of the current container.
+ *
+ * @param reader the reader
+ * @returns FALSE if nothing more to read at or below this level
+ */
+dbus_bool_t
+_dbus_type_reader_has_next (const DBusTypeReader *reader)
+{
+  /* Not efficient but works for now. */
+  DBusTypeReader copy;
+
+  copy = *reader;
+  return _dbus_type_reader_next (&copy);
+}
 
 /*
  *
@@ -1385,6 +1402,23 @@
 
 }
 
+/**
+ * Iterate through all values in the given reader,
+ * writing a copy of each value to the writer.
+ * The reader will be moved forward to its end position.
+ *
+ * @param writer the writer to copy to
+ * @param reader the reader to copy from
+ */
+dbus_bool_t
+_dbus_type_writer_write_reader (DBusTypeWriter *writer,
+                                DBusTypeReader *reader)
+{
+  /* FIXME */
+
+  return TRUE;
+}
+
 /** @} */ /* end of DBusMarshal group */
 
 #ifdef DBUS_BUILD_TESTS

Index: dbus-marshal-recursive.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-recursive.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- dbus-marshal-recursive.h	2 Jan 2005 00:37:24 -0000	1.15
+++ dbus-marshal-recursive.h	2 Jan 2005 02:38:23 -0000	1.16
@@ -110,36 +110,37 @@
   } u;
 };
 
-void        _dbus_type_reader_init                      (DBusTypeReader      *reader,
-                                                         int                  byte_order,
-                                                         const DBusString    *type_str,
-                                                         int                  type_pos,
-                                                         const DBusString    *value_str,
-                                                         int                  value_pos);
-void        _dbus_type_reader_init_from_mark            (DBusTypeReader      *reader,
-                                                         int                  byte_order,
-                                                         const DBusString    *type_str,
-                                                         const DBusString    *value_str,
-                                                         const DBusTypeMark  *mark);
-void        _dbus_type_reader_init_types_only           (DBusTypeReader      *reader,
-                                                         const DBusString    *type_str,
-                                                         int                  type_pos);
-void        _dbus_type_reader_init_types_only_from_mark (DBusTypeReader      *reader,
-                                                         const DBusString    *type_str,
-                                                         const DBusTypeMark  *mark);
-void        _dbus_type_reader_save_mark                 (DBusTypeReader      *reader,
-                                                         DBusTypeMark        *mark);
-int         _dbus_type_reader_get_current_type          (DBusTypeReader      *reader);
-dbus_bool_t _dbus_type_reader_array_is_empty            (DBusTypeReader      *reader);
-void        _dbus_type_reader_read_basic                (DBusTypeReader      *reader,
-                                                         void                *value);
-dbus_bool_t _dbus_type_reader_read_array_of_basic       (DBusTypeReader      *reader,
-                                                         int                  type,
-                                                         void               **array,
-                                                         int                 *array_len);
-void        _dbus_type_reader_recurse                   (DBusTypeReader      *reader,
-                                                         DBusTypeReader      *subreader);
-dbus_bool_t _dbus_type_reader_next                      (DBusTypeReader      *reader);
+void        _dbus_type_reader_init                      (DBusTypeReader        *reader,
+                                                         int                    byte_order,
+                                                         const DBusString      *type_str,
+                                                         int                    type_pos,
+                                                         const DBusString      *value_str,
+                                                         int                    value_pos);
+void        _dbus_type_reader_init_from_mark            (DBusTypeReader        *reader,
+                                                         int                    byte_order,
+                                                         const DBusString      *type_str,
+                                                         const DBusString      *value_str,
+                                                         const DBusTypeMark    *mark);
+void        _dbus_type_reader_init_types_only           (DBusTypeReader        *reader,
+                                                         const DBusString      *type_str,
+                                                         int                    type_pos);
+void        _dbus_type_reader_init_types_only_from_mark (DBusTypeReader        *reader,
+                                                         const DBusString      *type_str,
+                                                         const DBusTypeMark    *mark);
+void        _dbus_type_reader_save_mark                 (const DBusTypeReader  *reader,
+                                                         DBusTypeMark          *mark);
+int         _dbus_type_reader_get_current_type          (const DBusTypeReader  *reader);
+dbus_bool_t _dbus_type_reader_array_is_empty            (const DBusTypeReader  *reader);
+void        _dbus_type_reader_read_basic                (const DBusTypeReader  *reader,
+                                                         void                  *value);
+dbus_bool_t _dbus_type_reader_read_array_of_basic       (const DBusTypeReader  *reader,
+                                                         int                    type,
+                                                         void                 **array,
+                                                         int                   *array_len);
+void        _dbus_type_reader_recurse                   (DBusTypeReader        *reader,
+                                                         DBusTypeReader        *subreader);
+dbus_bool_t _dbus_type_reader_next                      (DBusTypeReader        *reader);
+dbus_bool_t _dbus_type_reader_has_next                  (const DBusTypeReader  *reader);
 
 
 void        _dbus_type_writer_init            (DBusTypeWriter *writer,
@@ -165,7 +166,8 @@
                                                DBusTypeWriter *sub);
 dbus_bool_t _dbus_type_writer_unrecurse       (DBusTypeWriter *writer,
                                                DBusTypeWriter *sub);
-
+dbus_bool_t _dbus_type_writer_write_reader    (DBusTypeWriter *writer,
+                                               DBusTypeReader *reader);
 
 
 #endif /* DBUS_MARSHAL_RECURSIVE_H */



More information about the dbus-commit mailing list