dbus/dbus dbus-marshal-basic.c, 1.10, 1.11 dbus-marshal-basic.h, 1.8, 1.9 dbus-marshal-recursive.c, 1.31, 1.32

Havoc Pennington hp at freedesktop.org
Sun Jan 2 11:10:19 PST 2005


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

Modified Files:
	dbus-marshal-basic.c dbus-marshal-basic.h 
	dbus-marshal-recursive.c 
Log Message:
clean up the naming of dbus_marshal functions


Index: dbus-marshal-basic.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-basic.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dbus-marshal-basic.c	2 Jan 2005 08:46:42 -0000	1.10
+++ dbus-marshal-basic.c	2 Jan 2005 19:10:16 -0000	1.11
@@ -283,7 +283,7 @@
 
   _dbus_string_init_const (&dstr, value);
 
-  old_len = _dbus_demarshal_uint32 (str, pos, byte_order, NULL);
+  old_len = _dbus_marshal_read_uint32 (str, pos, byte_order, NULL);
 
   new_len = _dbus_string_get_length (&dstr);
 
@@ -358,13 +358,13 @@
  * @returns #FALSE if no memory
  */
 dbus_bool_t
-_dbus_marshal_set_basic_type (DBusString       *str,
-                              int               pos,
-                              int               type,
-                              const void       *value,
-                              int               byte_order,
-                              int              *old_end_pos,
-                              int              *new_end_pos)
+_dbus_marshal_set_basic (DBusString       *str,
+                         int               pos,
+                         int               type,
+                         const void       *value,
+                         int               byte_order,
+                         int              *old_end_pos,
+                         int              *new_end_pos)
 {
   const DBusBasicValue *vp;
 
@@ -419,10 +419,10 @@
 }
 
 static dbus_uint32_t
-demarshal_4_octets (const DBusString *str,
-                    int               pos,
-                    int               byte_order,
-                    int              *new_pos)
+read_4_octets (const DBusString *str,
+               int               pos,
+               int               byte_order,
+               int              *new_pos)
 {
   pos = _DBUS_ALIGN_VALUE (pos, 4);
 
@@ -443,16 +443,16 @@
  * @returns the demarshaled integer.
  */
 dbus_uint32_t
-_dbus_demarshal_uint32  (const DBusString *str,
-			 int               pos,
-                         int               byte_order,
-			 int              *new_pos)
+_dbus_marshal_read_uint32  (const DBusString *str,
+                            int               pos,
+                            int               byte_order,
+                            int              *new_pos)
 {
-  return demarshal_4_octets (str, pos, byte_order, new_pos);
+  return read_4_octets (str, pos, byte_order, new_pos);
 }
 
 /**
- * Demarshals a basic type. The "value" pointer is always
+ * Demarshals a basic-typed value. The "value" pointer is always
  * the address of a variable of the basic type. So e.g.
  * if the basic type is "double" then the pointer is
  * a double*, and if it's "char*" then the pointer is
@@ -473,12 +473,12 @@
  * @param new_pos pointer to update with new position, or #NULL
  **/
 void
-_dbus_demarshal_basic_type (const DBusString      *str,
-                            int                    pos,
-			    int                    type,
-			    void                  *value,
-			    int                    byte_order,
-                            int                   *new_pos)
+_dbus_marshal_read_basic (const DBusString      *str,
+                          int                    pos,
+                          int                    type,
+                          void                  *value,
+                          int                    byte_order,
+                          int                   *new_pos)
 {
   const char *str_data;
   DBusBasicValue *vp;
@@ -523,7 +523,7 @@
       {
         int len;
 
-        len = _dbus_demarshal_uint32 (str, pos, byte_order, &pos);
+        len = _dbus_marshal_read_uint32 (str, pos, byte_order, &pos);
 
         vp->str = (char*) str_data + pos;
 
@@ -711,11 +711,11 @@
 }
 
 /**
- * Marshals a basic type. The "value" pointer is always the
+ * Marshals a basic-typed value. 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
+ * with _dbus_marshal_read_basic() and to have a simple
  * consistent rule.
  *
  * @param str string to marshal to
@@ -727,12 +727,12 @@
  * @returns #TRUE on success
  **/
 dbus_bool_t
-_dbus_marshal_basic_type (DBusString *str,
-                          int         insert_at,
-			  int         type,
-			  const void *value,
-			  int         byte_order,
-                          int        *pos_after)
+_dbus_marshal_write_basic (DBusString *str,
+                           int         insert_at,
+                           int         type,
+                           const void *value,
+                           int         byte_order,
+                           int        *pos_after)
 {
   const DBusBasicValue *vp;
 
@@ -909,13 +909,13 @@
  * @returns #TRUE on success
  **/
 dbus_bool_t
-_dbus_marshal_basic_type_array (DBusString *str,
-                                int         insert_at,
-				int         element_type,
-				const void *value,
-				int         len,
-				int         byte_order,
-                                int        *pos_after)
+_dbus_marshal_write_basic_array (DBusString *str,
+                                 int         insert_at,
+                                 int         element_type,
+                                 const void *value,
+                                 int         len,
+                                 int         byte_order,
+                                 int        *pos_after)
 {
   /* FIXME use the insert_at arg and fill in pos_after */
 
@@ -956,19 +956,19 @@
 
 
 /**
- * Skips over a basic type, reporting the following position.
+ * Skips over a basic-typed value, reporting the following position.
  *
  * @param str the string containing the data
- * @param type type of value to demarshal
+ * @param type type of value to read
  * @param byte_order the byte order
  * @param pos pointer to position in the string,
  *            updated on return to new position
  **/
 void
-_dbus_marshal_skip_basic_type (const DBusString      *str,
-                               int                    type,
-                               int                    byte_order,
-                               int                   *pos)
+_dbus_marshal_skip_basic (const DBusString      *str,
+                          int                    type,
+                          int                    byte_order,
+                          int                   *pos)
 {
   switch (type)
     {
@@ -992,7 +992,7 @@
       {
         int len;
 
-        len = _dbus_demarshal_uint32 (str, *pos, byte_order, pos);
+        len = _dbus_marshal_read_uint32 (str, *pos, byte_order, pos);
 
         *pos += len + 1; /* length plus nul */
       }
@@ -1035,12 +1035,7 @@
 
   i = _DBUS_ALIGN_VALUE (*pos, 4);
 
-  _dbus_demarshal_basic_type (str,
-                              i,
-                              DBUS_TYPE_UINT32,
-                              &array_len,
-                              byte_order,
-                              &i);
+  array_len = _dbus_marshal_read_uint32 (str, i, byte_order, &i);
 
   alignment = _dbus_type_get_alignment (element_type);
 
@@ -1155,7 +1150,7 @@
  *
  * This function is defined to return #TRUE for exactly those
  * types that can be written with _dbus_marshal_basic_type()
- * and read with _dbus_demarshal_basic_type().
+ * and read with _dbus_marshal_read_basic().
  *
  * This function will crash if passed a typecode that isn't
  * in dbus-protocol.h
@@ -1320,7 +1315,7 @@
 #define MARSHAL_BASIC(typename, byte_order, literal)                    \
   do {                                                                  \
      v_##typename = literal;                                            \
-     if (!_dbus_marshal_basic_type (&str, pos, DBUS_TYPE_##typename,    \
+     if (!_dbus_marshal_write_basic (&str, pos, DBUS_TYPE_##typename,   \
                                     &v_##typename,                      \
                                     byte_order, NULL))                  \
        _dbus_assert_not_reached ("no memory");                          \
@@ -1328,7 +1323,7 @@
 
 #define DEMARSHAL_BASIC(typename, byte_order)                                   \
   do {                                                                          \
-    _dbus_demarshal_basic_type (&str, pos, DBUS_TYPE_##typename, &v_##typename, \
+    _dbus_marshal_read_basic (&str, pos, DBUS_TYPE_##typename, &v_##typename,   \
                                 byte_order, &pos);                              \
   } while (0)
 
@@ -1621,23 +1616,23 @@
       _dbus_string_init_const (&t, "Hello world foo");
 
       v_STRING = _dbus_string_get_const_data (&t);
-      _dbus_marshal_set_basic_type (&str, 0, DBUS_TYPE_STRING,
-                                    &v_STRING, byte_order, NULL, NULL);
+      _dbus_marshal_set_basic (&str, 0, DBUS_TYPE_STRING,
+                               &v_STRING, byte_order, NULL, NULL);
 
-      _dbus_demarshal_basic_type (&str, 0, DBUS_TYPE_STRING,
-                                  &v_STRING, byte_order,
-                                  NULL);
+      _dbus_marshal_read_basic (&str, 0, DBUS_TYPE_STRING,
+                                &v_STRING, byte_order,
+                                NULL);
       _dbus_assert (strcmp (v_STRING, "Hello world foo") == 0);
 
       /* Set it to something shorter */
       _dbus_string_init_const (&t, "Hello");
 
       v_STRING = _dbus_string_get_const_data (&t);
-      _dbus_marshal_set_basic_type (&str, 0, DBUS_TYPE_STRING,
-                                    &v_STRING, byte_order, NULL, NULL);
-      _dbus_demarshal_basic_type (&str, 0, DBUS_TYPE_STRING,
-                                  &v_STRING, byte_order,
-                                  NULL);
+      _dbus_marshal_set_basic (&str, 0, DBUS_TYPE_STRING,
+                               &v_STRING, byte_order, NULL, NULL);
+      _dbus_marshal_read_basic (&str, 0, DBUS_TYPE_STRING,
+                                &v_STRING, byte_order,
+                                NULL);
       _dbus_assert (strcmp (v_STRING, "Hello") == 0);
 
       /* Do the other byte order */

Index: dbus-marshal-basic.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-basic.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- dbus-marshal-basic.h	2 Jan 2005 08:46:42 -0000	1.8
+++ dbus-marshal-basic.h	2 Jan 2005 19:10:16 -0000	1.9
@@ -2,7 +2,7 @@
 /* dbus-marshal-basic.h  Marshalling routines for basic (primitive) types
  *
  * Copyright (C) 2002  CodeFactory AB
- * Copyright (C) 2004  Red Hat, Inc.
+ * Copyright (C) 2004, 2005  Red Hat, Inc.
  *
  * Licensed under the Academic Free License version 2.1
  *
@@ -262,53 +262,54 @@
                                    const unsigned char *data);
 
 
-dbus_bool_t   _dbus_marshal_set_basic_type   (DBusString       *str,
-                                              int               pos,
-                                              int               type,
-                                              const void       *value,
-                                              int               byte_order,
-                                              int              *old_end_pos,
-                                              int              *new_end_pos);
-dbus_bool_t   _dbus_marshal_basic_type       (DBusString       *str,
-                                              int               insert_at,
-                                              int               type,
-                                              const void       *value,
-                                              int               byte_order,
-                                              int              *pos_after);
-dbus_bool_t   _dbus_marshal_basic_type_array (DBusString       *str,
-                                              int               insert_at,
-                                              int               element_type,
-                                              const void       *value,
-                                              int               len,
-                                              int               byte_order,
-                                              int              *pos_after);
-void          _dbus_demarshal_basic_type     (const DBusString *str,
-                                              int               pos,
-                                              int               type,
-                                              void             *value,
-                                              int               byte_order,
-                                              int              *new_pos);
-void          _dbus_marshal_skip_basic_type  (const DBusString *str,
-                                              int               type,
-                                              int               byte_order,
-                                              int              *pos);
-void          _dbus_marshal_skip_array       (const DBusString *str,
-                                              int               element_type,
-                                              int               byte_order,
-                                              int              *pos);
-void          _dbus_marshal_set_uint32       (DBusString       *str,
-                                              int               pos,
-                                              dbus_uint32_t     value,
-                                              int               byte_order);
-dbus_uint32_t _dbus_demarshal_uint32         (const DBusString *str,
-                                              int               pos,
-                                              int               byte_order,
-                                              int              *new_pos);
-dbus_bool_t   _dbus_type_is_valid            (int               typecode);
-int           _dbus_type_get_alignment       (int               typecode);
-dbus_bool_t   _dbus_type_is_basic            (int               typecode);
-dbus_bool_t   _dbus_type_is_container        (int               typecode);
-dbus_bool_t   _dbus_type_length_varies       (int               typecode);
+dbus_bool_t   _dbus_marshal_set_basic         (DBusString       *str,
+                                               int               pos,
+                                               int               type,
+                                               const void       *value,
+                                               int               byte_order,
+                                               int              *old_end_pos,
+                                               int              *new_end_pos);
+dbus_bool_t   _dbus_marshal_write_basic       (DBusString       *str,
+                                               int               insert_at,
+                                               int               type,
+                                               const void       *value,
+                                               int               byte_order,
+                                               int              *pos_after);
+dbus_bool_t   _dbus_marshal_write_basic_array (DBusString       *str,
+                                               int               insert_at,
+                                               int               element_type,
+                                               const void       *value,
+                                               int               len,
+                                               int               byte_order,
+                                               int              *pos_after);
+void          _dbus_marshal_read_basic        (const DBusString *str,
+                                               int               pos,
+                                               int               type,
+                                               void             *value,
+                                               int               byte_order,
+                                               int              *new_pos);
+void          _dbus_marshal_skip_basic        (const DBusString *str,
+                                               int               type,
+                                               int               byte_order,
+                                               int              *pos);
+void          _dbus_marshal_skip_array        (const DBusString *str,
+                                               int               element_type,
+                                               int               byte_order,
+                                               int              *pos);
+void          _dbus_marshal_set_uint32        (DBusString       *str,
+                                               int               pos,
+                                               dbus_uint32_t     value,
+                                               int               byte_order);
+dbus_uint32_t _dbus_marshal_read_uint32       (const DBusString *str,
+                                               int               pos,
+                                               int               byte_order,
+                                               int              *new_pos);
+dbus_bool_t   _dbus_type_is_valid             (int               typecode);
+int           _dbus_type_get_alignment        (int               typecode);
+dbus_bool_t   _dbus_type_is_basic             (int               typecode);
+dbus_bool_t   _dbus_type_is_container         (int               typecode);
+dbus_bool_t   _dbus_type_length_varies        (int               typecode);
+
 
 
 

Index: dbus-marshal-recursive.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-recursive.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- dbus-marshal-recursive.c	2 Jan 2005 08:46:42 -0000	1.31
+++ dbus-marshal-recursive.c	2 Jan 2005 19:10:16 -0000	1.32
@@ -140,12 +140,12 @@
   /* array_len_offset is the offset back from start_pos to end of the len */
   len_pos = reader->u.array.start_pos - ((int)reader->array_len_offset) - 4;
 
-  _dbus_demarshal_basic_type (reader->value_str,
-                              len_pos,
-                              DBUS_TYPE_UINT32,
-                              &array_len,
-                              reader->byte_order,
-                              NULL);
+  _dbus_marshal_read_basic (reader->value_str,
+                            len_pos,
+                            DBUS_TYPE_UINT32,
+                            &array_len,
+                            reader->byte_order,
+                            NULL);
 
   _dbus_verbose ("   reader %p len_pos %d array len %u len_offset %d\n",
                  reader, len_pos, array_len, reader->array_len_offset);
@@ -333,9 +333,9 @@
 
     default:
       if (!reader->klass->types_only)
-        _dbus_marshal_skip_basic_type (reader->value_str,
-                                       current_type, reader->byte_order,
-                                       &reader->value_pos);
+        _dbus_marshal_skip_basic (reader->value_str,
+                                  current_type, reader->byte_order,
+                                  &reader->value_pos);
 
       reader->type_pos += 1;
       break;
@@ -421,9 +421,9 @@
 
     default:
       {
-        _dbus_marshal_skip_basic_type (reader->value_str,
-                                       current_type, reader->byte_order,
-                                       &reader->value_pos);
+        _dbus_marshal_skip_basic (reader->value_str,
+                                  current_type, reader->byte_order,
+                                  &reader->value_pos);
       }
       break;
     }
@@ -660,12 +660,12 @@
    _dbus_verbose ("checking array len at %d\n", reader->value_pos);
 #endif
 
-  _dbus_demarshal_basic_type (reader->value_str,
-                              reader->value_pos,
-                              DBUS_TYPE_UINT32,
-                              &array_len,
-                              reader->byte_order,
-                              NULL);
+   _dbus_marshal_read_basic (reader->value_str,
+                             reader->value_pos,
+                             DBUS_TYPE_UINT32,
+                             &array_len,
+                             reader->byte_order,
+                             NULL);
 #if RECURSIVE_MARSHAL_TRACE
   _dbus_verbose (" ... array len = %d\n", array_len);
 #endif
@@ -683,11 +683,11 @@
 
   t = _dbus_type_reader_get_current_type (reader);
 
-  _dbus_demarshal_basic_type (reader->value_str,
-                              reader->value_pos,
-                              t, value,
-                              reader->byte_order,
-                              NULL);
+  _dbus_marshal_read_basic (reader->value_str,
+                            reader->value_pos,
+                            t, value,
+                            reader->byte_order,
+                            NULL);
 
 
 #if RECURSIVE_MARSHAL_TRACE
@@ -859,16 +859,16 @@
 }
 
 static void
-reader_fixed_length_set_basic (DBusTypeReader *reader,
+reader_set_basic_fixed_length (DBusTypeReader *reader,
                                int             current_type,
                                const void     *value)
 {
-  _dbus_marshal_set_basic_type ((DBusString*) reader->value_str,
-                                reader->value_pos,
-                                current_type,
-                                value,
-                                reader->byte_order,
-                                NULL, NULL);
+  _dbus_marshal_set_basic ((DBusString*) reader->value_str,
+                           reader->value_pos,
+                           current_type,
+                           value,
+                           reader->byte_order,
+                           NULL, NULL);
 }
 
 /**
@@ -905,11 +905,12 @@
 
   if (!_dbus_type_length_varies (current_type))
     {
-      reader_fixed_length_set_basic (reader, current_type, value);
+      reader_set_basic_fixed_length (reader, current_type, value);
       return TRUE;
     }
 
-  /* FIXME */
+  /* In the harder case, we have to fix alignment after we insert. */
+
 
   retval = TRUE;
 
@@ -975,12 +976,12 @@
                                            int             type,
                                            const void     *value)
 {
-  return _dbus_marshal_basic_type (writer->value_str,
-                                   writer->value_pos,
-                                   type,
-                                   value,
-                                   writer->byte_order,
-                                   &writer->value_pos);
+  return _dbus_marshal_write_basic (writer->value_str,
+                                    writer->value_pos,
+                                    type,
+                                    value,
+                                    writer->byte_order,
+                                    &writer->value_pos);
 }
 
 /* If our parent is an array, things are a little bit complicated.



More information about the dbus-commit mailing list