예제 #1
0
/**
 * A "container type" can contain basic types, or nested
 * container types. #DBUS_TYPE_INVALID is not a container type.
 *
 * This function will crash if passed a typecode that isn't
 * in dbus-protocol.h
 *
 * @returns #TRUE if type is a container
 */
dbus_bool_t
dbus_type_is_container (int typecode)
{
  /* only reasonable (non-line-noise) typecodes are allowed */
  _dbus_return_val_if_fail (_dbus_type_is_valid (typecode) || typecode == DBUS_TYPE_INVALID,
			    FALSE);
  return TYPE_IS_CONTAINER (typecode);
}
static dbus_bool_t
find_next_typecode (DBusMessageDataIter *iter,
                    DBusString          *data,
                    DBusValidity        *expected_validity)
{
  int body_seq;
  int byte_seq;
  int base_depth;

  base_depth = iter->depth;

 restart:
  _dbus_assert (iter->depth == (base_depth + 0));
  _dbus_string_set_length (data, 0);

  body_seq = iter_get_sequence (iter);
  
  if (!generate_many_bodies (iter, data, expected_validity))
    return FALSE;
  /* Undo the "next" in generate_many_bodies */
  iter_set_sequence (iter, body_seq);
  
  iter_recurse (iter);
  while (TRUE)
    {
      _dbus_assert (iter->depth == (base_depth + 1));
      
      byte_seq = iter_get_sequence (iter);

      _dbus_assert (byte_seq <= _dbus_string_get_length (data));
      
      if (byte_seq == _dbus_string_get_length (data))
        {
          /* reset byte count */
          iter_set_sequence (iter, 0);
          iter_unrecurse (iter);
          _dbus_assert (iter->depth == (base_depth + 0));
          iter_next (iter); /* go to the next body */
          goto restart;
        }

      _dbus_assert (byte_seq < _dbus_string_get_length (data));

      if (_dbus_type_is_valid (_dbus_string_get_byte (data, byte_seq)))
        break;
      else
        iter_next (iter);
    }

  _dbus_assert (byte_seq == iter_get_sequence (iter));
  _dbus_assert (byte_seq < _dbus_string_get_length (data));

  iter_unrecurse (iter);

  _dbus_assert (iter->depth == (base_depth + 0));
  
  return TRUE;
}
예제 #3
0
/**
 * A "basic type" is a somewhat arbitrary concept, but the intent is
 * to include those types that are fully-specified by a single
 * typecode, with no additional type information or nested values. So
 * all numbers and strings are basic types and structs, arrays, and
 * variants are not basic types.  #DBUS_TYPE_INVALID is not a basic
 * type.
 *
 * This function will crash if passed a typecode that isn't
 * in dbus-protocol.h 
 *
 * @returns #TRUE if type is basic
 */
dbus_bool_t
dbus_type_is_basic (int typecode)
{
  /* only reasonable (non-line-noise) typecodes are allowed */
  _dbus_return_val_if_fail (_dbus_type_is_valid (typecode) || typecode == DBUS_TYPE_INVALID,
			    FALSE);

  /* everything that isn't invalid or a container */
  return !(typecode == DBUS_TYPE_INVALID || TYPE_IS_CONTAINER (typecode));
}
예제 #4
0
/**
 * Tells you whether values of this type can change length if you set
 * them to some other value. For this purpose, you assume that the
 * first byte of the old and new value would be in the same location,
 * so alignment padding is not a factor.
 *
 * This function is useful to determine whether
 * dbus_message_iter_get_fixed_array() may be used.
 *
 * Some structs are fixed-size (if they contain only fixed-size types)
 * but struct is not considered a fixed type for purposes of this
 * function.
 *
 * This function will crash if passed a typecode that isn't
 * in dbus-protocol.h
 * 
 * @returns #FALSE if the type can occupy different lengths
 */
dbus_bool_t
dbus_type_is_fixed (int typecode)
{
  /* only reasonable (non-line-noise) typecodes are allowed */
  _dbus_return_val_if_fail (_dbus_type_is_valid (typecode) || typecode == DBUS_TYPE_INVALID,
			    FALSE);
  
  switch (typecode)
    {
    case DBUS_TYPE_BYTE:
    case DBUS_TYPE_BOOLEAN:
    case DBUS_TYPE_INT16:
    case DBUS_TYPE_UINT16:
    case DBUS_TYPE_INT32:
    case DBUS_TYPE_UINT32:
    case DBUS_TYPE_INT64:
    case DBUS_TYPE_UINT64:
    case DBUS_TYPE_DOUBLE:
      return TRUE;
    default:
      return FALSE;
    }
}