summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2005-03-09 17:09:11 +0000
committerColin Walters <walters@verbum.org>2005-03-09 17:09:11 +0000
commit74b1b35402f6b9bbc09999a6224dfc04bc48b2a9 (patch)
treec9cae2dde5d4b11d4cf7e17e5c3009280e1f8ee5 /dbus
parent2958e723fc996e2dd7edfdc6ac53dcdf48323549 (diff)
2005-03-09 Colin Walters <walters@verbum.org>
* glib/dbus-gproxy.c (dbus_g_proxy_invoke): New method; calls to this are generated for client-side wrappers. Invokes a D-BUS method and returns reply values. * glib/dbus-binding-tool-glib.c (write_args_sig_for_direction): New function; writes signature string for argument direction. (write_args_for_direction): Change to pass input values directly instead of via address, and fix indentation. (generate_client_glue): Change to invoke dbus_g_proxy_invoke. Also make generated wrappers inlineable. * dbus/dbus-message.c (dbus_message_iter_get_fixed_array): Add note about using dbus_type_is_fixed. * dbus/dbus-marshal-basic.c (_dbus_type_is_fixed): Moved to dbus/dbus-signature.c as dbus_type_is_fixed. All callers updated. * dbus/dbus-signature.c (dbus_type_is_fixed): Moved here from dbus/dbus-marshal-basic.c:_dbus_type_is_fixed. * dbus/dbus-signature.h: Prototype. * glib/dbus-binding-tool-glib.c (compute_marshaller_name): Fix error printf code. * test/glib/test-dbus-glib.c (main): Be sure to clear error as appropriate instead of just freeing it. (main): Free returned strings using g_free. * test/glib/Makefile.am (test-service-glib-glue.h) (test-service-glib-bindings.h): Add dependency on dbus-binding-tool. * glib/dbus-gvalue.c (MAP_BASIC): Refactored from MAP_BASIC_INIT; simply maps a simple D-BUS type to GType. (dbus_dbus_type_to_gtype): Function which maps D-BUS type to GType. (dbus_gvalue_init): Just invoke dbus_dbus_type_to_gtype and initialize the value with it. (dbus_gvalue_binding_type_from_type): Unused, delete. (dbus_gvalue_demarshal): Switch to hardcoding demarshalling for various types instead of unmarshalling to value data directly. Remove can_convert boolean. (dbus_gvalue_marshal): Remove duplicate initialization; switch to returning directly instead of using can_convert boolean. (dbus_gvalue_store): New function; not related to D-BUS per-se. Stores a GValue in a pointer to a value of its corresponding C type. * glib/dbus-gvalue.h: Remove dbus_gvalue_binding_type_from_type, add dbus_gvalue_store.
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-glib.h7
-rw-r--r--dbus/dbus-marshal-basic.c34
-rw-r--r--dbus/dbus-marshal-byteswap.c3
-rw-r--r--dbus/dbus-marshal-recursive-util.c4
-rw-r--r--dbus/dbus-marshal-recursive.c8
-rw-r--r--dbus/dbus-message.c11
-rw-r--r--dbus/dbus-signature.c30
-rw-r--r--dbus/dbus-signature.h1
8 files changed, 56 insertions, 42 deletions
diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h
index a9aad540..e1b4a704 100644
--- a/dbus/dbus-glib.h
+++ b/dbus/dbus-glib.h
@@ -174,6 +174,13 @@ void dbus_g_proxy_call_no_reply (DBusGProxy *proxy,
const char* dbus_g_proxy_get_bus_name (DBusGProxy *proxy);
+gboolean dbus_g_proxy_invoke (DBusGProxy *proxy,
+ const char *method,
+ const char *insig,
+ const char *outsig,
+ GError **error,
+ ...);
+
#undef DBUS_INSIDE_DBUS_GLIB_H
G_END_DECLS
diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c
index fde58d51..ea0648ae 100644
--- a/dbus/dbus-marshal-basic.c
+++ b/dbus/dbus-marshal-basic.c
@@ -620,7 +620,7 @@ _dbus_marshal_read_fixed_multi (const DBusString *str,
int array_len;
int alignment;
- _dbus_assert (_dbus_type_is_fixed (element_type));
+ _dbus_assert (dbus_type_is_fixed (element_type));
_dbus_assert (dbus_type_is_basic (element_type));
#if 0
@@ -1054,7 +1054,7 @@ marshal_fixed_multi (DBusString *str,
/**
* Marshals a block of values of fixed-length type all at once, as an
- * optimization. _dbus_type_is_fixed() returns #TRUE for fixed-length
+ * optimization. dbus_type_is_fixed() returns #TRUE for fixed-length
* types, which are the basic types minus the string-like types.
*
* The value argument should be the adddress of an
@@ -1080,7 +1080,7 @@ _dbus_marshal_write_fixed_multi (DBusString *str,
{
const void* vp = *(const DBusBasicValue**)value;
- _dbus_assert (_dbus_type_is_fixed (element_type));
+ _dbus_assert (dbus_type_is_fixed (element_type));
_dbus_assert (n_elements >= 0);
#if 0
@@ -1299,34 +1299,6 @@ _dbus_type_is_valid (int typecode)
}
/**
- * 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.
- *
- * @returns #FALSE if the type can occupy different lengths
- */
-dbus_bool_t
-_dbus_type_is_fixed (int typecode)
-{
- 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;
- }
-}
-
-/**
* Returns a string describing the given type.
*
* @param typecode the type to describe
diff --git a/dbus/dbus-marshal-byteswap.c b/dbus/dbus-marshal-byteswap.c
index c8ec8942..7571e2fc 100644
--- a/dbus/dbus-marshal-byteswap.c
+++ b/dbus/dbus-marshal-byteswap.c
@@ -23,6 +23,7 @@
#include "dbus-marshal-byteswap.h"
#include "dbus-marshal-basic.h"
+#include "dbus-signature.h"
/**
* @addtogroup DBusMarshal
@@ -103,7 +104,7 @@ byteswap_body_helper (DBusTypeReader *reader,
p = _DBUS_ALIGN_ADDRESS (p, alignment);
- if (_dbus_type_is_fixed (elem_type))
+ if (dbus_type_is_fixed (elem_type))
{
if (alignment > 1)
_dbus_swap_array (p, array_len / alignment, alignment);
diff --git a/dbus/dbus-marshal-recursive-util.c b/dbus/dbus-marshal-recursive-util.c
index e1b00e58..0d06bc2f 100644
--- a/dbus/dbus-marshal-recursive-util.c
+++ b/dbus/dbus-marshal-recursive-util.c
@@ -3074,7 +3074,7 @@ array_write_value (TestTypeNode *node,
goto oom;
if (arrays_write_fixed_in_blocks &&
- _dbus_type_is_fixed (element_type) &&
+ dbus_type_is_fixed (element_type) &&
child->klass->write_multi)
{
if (!node_write_multi (child, block, &sub, seed, n_copies))
@@ -3138,7 +3138,7 @@ array_read_or_set_value (TestTypeNode *node,
_dbus_type_reader_recurse (reader, &sub);
if (realign_root == NULL && arrays_write_fixed_in_blocks &&
- _dbus_type_is_fixed (_dbus_type_reader_get_element_type (reader)) &&
+ dbus_type_is_fixed (_dbus_type_reader_get_element_type (reader)) &&
child->klass->read_multi)
{
if (!node_read_multi (child, &sub, seed, n_copies))
diff --git a/dbus/dbus-marshal-recursive.c b/dbus/dbus-marshal-recursive.c
index 432e6f0b..6fcbd623 100644
--- a/dbus/dbus-marshal-recursive.c
+++ b/dbus/dbus-marshal-recursive.c
@@ -1018,7 +1018,7 @@ _dbus_type_reader_read_fixed_multi (const DBusTypeReader *reader,
reader->type_pos);
_dbus_assert (element_type != DBUS_TYPE_INVALID); /* why we don't use get_current_type() */
- _dbus_assert (_dbus_type_is_fixed (element_type));
+ _dbus_assert (dbus_type_is_fixed (element_type));
alignment = _dbus_type_get_alignment (element_type);
@@ -1464,7 +1464,7 @@ _dbus_type_reader_set_basic (DBusTypeReader *reader,
_dbus_assert (dbus_type_is_basic (current_type));
- if (_dbus_type_is_fixed (current_type))
+ if (dbus_type_is_fixed (current_type))
{
reader_set_basic_fixed_length (reader, current_type, value);
return TRUE;
@@ -2404,7 +2404,7 @@ _dbus_type_writer_write_basic (DBusTypeWriter *writer,
/**
* Writes a block of fixed-length basic values, i.e. those that are
- * both _dbus_type_is_fixed() and _dbus_type_is_basic(). The block
+ * both dbus_type_is_fixed() and _dbus_type_is_basic(). The block
* must be written inside an array.
*
* The value parameter should be the address of said array of values,
@@ -2423,7 +2423,7 @@ _dbus_type_writer_write_fixed_multi (DBusTypeWriter *writer,
int n_elements)
{
_dbus_assert (writer->container_type == DBUS_TYPE_ARRAY);
- _dbus_assert (_dbus_type_is_fixed (element_type));
+ _dbus_assert (dbus_type_is_fixed (element_type));
_dbus_assert (writer->type_pos_is_expectation);
_dbus_assert (n_elements >= 0);
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index 672a72b4..b090fab0 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -1270,7 +1270,7 @@ dbus_message_append_args_valist (DBusMessage *message,
&array))
goto failed;
- if (_dbus_type_is_fixed (element_type))
+ if (dbus_type_is_fixed (element_type))
{
const DBusBasicValue **value;
int n_elements;
@@ -1676,6 +1676,9 @@ dbus_message_iter_get_basic (DBusMessageIter *iter,
* such as integers, bool, double. The block read will be from the
* current position in the array until the end of the array.
*
+ * This function should only be used if #dbus_type_is_fixed returns
+ * #TRUE for the element type.
+ *
* The value argument should be the address of a location to store the
* returned array. So for int32 it should be a "const dbus_int32_t**"
* The returned value is by reference and should not be freed.
@@ -1693,7 +1696,7 @@ dbus_message_iter_get_fixed_array (DBusMessageIter *iter,
_dbus_return_if_fail (_dbus_message_iter_check (real));
_dbus_return_if_fail (value != NULL);
- _dbus_return_if_fail (_dbus_type_is_fixed (_dbus_type_reader_get_element_type (&real->u.reader)));
+ _dbus_return_if_fail (dbus_type_is_fixed (_dbus_type_reader_get_element_type (&real->u.reader)));
_dbus_type_reader_read_fixed_multi (&real->u.reader,
value, n_elements);
@@ -1778,7 +1781,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter,
goto out;
}
- if (_dbus_type_is_fixed (spec_element_type))
+ if (dbus_type_is_fixed (spec_element_type))
{
ptr = va_arg (var_args, const DBusBasicValue**);
n_elements_p = va_arg (var_args, int*);
@@ -2138,7 +2141,7 @@ dbus_message_iter_append_fixed_array (DBusMessageIter *iter,
_dbus_return_val_if_fail (_dbus_message_iter_append_check (real), FALSE);
_dbus_return_val_if_fail (real->iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER, FALSE);
- _dbus_return_val_if_fail (_dbus_type_is_fixed (element_type), FALSE);
+ _dbus_return_val_if_fail (dbus_type_is_fixed (element_type), FALSE);
_dbus_return_val_if_fail (real->u.writer.container_type == DBUS_TYPE_ARRAY, FALSE);
_dbus_return_val_if_fail (value != NULL, FALSE);
_dbus_return_val_if_fail (n_elements >= 0, FALSE);
diff --git a/dbus/dbus-signature.c b/dbus/dbus-signature.c
index 698c21ed..7cbae7c2 100644
--- a/dbus/dbus-signature.c
+++ b/dbus/dbus-signature.c
@@ -262,6 +262,36 @@ dbus_type_is_basic (int typecode)
return !(typecode == DBUS_TYPE_INVALID || TYPE_IS_CONTAINER (typecode));
}
+/**
+ * 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.
+ *
+ * @returns #FALSE if the type can occupy different lengths
+ */
+dbus_bool_t
+dbus_type_is_fixed (int typecode)
+{
+ 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;
+ }
+}
#ifdef DBUS_BUILD_TESTS
diff --git a/dbus/dbus-signature.h b/dbus/dbus-signature.h
index 3c50795e..fd64ed11 100644
--- a/dbus/dbus-signature.h
+++ b/dbus/dbus-signature.h
@@ -65,6 +65,7 @@ dbus_bool_t dbus_signature_validate_single (const char *signatur
dbus_bool_t dbus_type_is_basic (int typecode);
dbus_bool_t dbus_type_is_container (int typecode);
+dbus_bool_t dbus_type_is_fixed (int typecode);
DBUS_END_DECLS