diff options
author | Colin Walters <walters@verbum.org> | 2005-02-24 16:03:56 +0000 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2005-02-24 16:03:56 +0000 |
commit | 54a2e9f7961b4b8afff94bb0c5b756f986965be6 (patch) | |
tree | 475800623e70c6bf14e7b4b2af2be8cc14d217ba /dbus/dbus-marshal-recursive.c | |
parent | d3f1b8bc89631cd9ef1cf2a806ce80f056b940fb (diff) |
2005-02-24 Colin Walters <walters@verbum.org>
* dbus/dbus-signature.c: New file; implements various functions
related to type signatures. Includes an interator for parsing,
validation functions.
(dbus_type_is_basic): Moved here from
dbus-marshal-basic.c:_dbus_type_is_basic.
(dbus_type_is_container): Moved here from
dbus-marshal-basic.c:_dbus_type_is_container.
All callers of _dbus_type_is_container and _dbus_type_is_basic
updated, and include dbus-signature.h.
* dbus/dbus-signature.h: New file; prototypes for the above.
* dbus/Makefile.am (DBUS_LIB_SOURCES): Add dbus-signature.c,
dbus-signature.h.
* dbus/dbus-marshal-basic.c (map_type_char_to_type): New utility
function factored out of _dbus_first_type_in_signature.
(_dbus_first_type_in_signature_c_str): New function; returns first
type code for a type signature character.
* dbus/dbus-marshal-basic.h: Prototype _dbus_first_type_in_signature_c_str,
handle function moves.
* dbus/dbus-marshal-recursive.h: Export _dbus_type_signature_next.
* dbus/dbus-marshal-recursive.c (_dbus_type_signature_next): New
function; skips to next complete type in type signature.
Implemented using previous skip_one_complete_type. Now
skip_one_complete_type just delegates to
_dbus_type_signature_next.
* dbus/dbus-marshal-basic.c (_dbus_type_is_basic): Moved
to dbus-signature.c
(_dbus_type_is_container): Ditto.
* doc/dbus-specification.xml: Update introspection sample to
use real type signatures.
* dbus/dbus-test.h: Prototype signature test.
* dbus/dbus-test.c (dbus_internal_do_not_use_run_tests): Run
signature tests.
* dbus/dbus-protocol.h (DBUS_ERROR_INVALID_SIGNATURE): New error.
Diffstat (limited to 'dbus/dbus-marshal-recursive.c')
-rw-r--r-- | dbus/dbus-marshal-recursive.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/dbus/dbus-marshal-recursive.c b/dbus/dbus-marshal-recursive.c index 738edd91..432e6f0b 100644 --- a/dbus/dbus-marshal-recursive.c +++ b/dbus/dbus-marshal-recursive.c @@ -23,6 +23,7 @@ #include "dbus-marshal-recursive.h" #include "dbus-marshal-basic.h" +#include "dbus-signature.h" #include "dbus-internals.h" /** @@ -308,18 +309,33 @@ array_reader_check_finished (const DBusTypeReader *reader) return reader->value_pos == end_pos; } -/* this is written a little oddly to try and overoptimize */ static void skip_one_complete_type (const DBusString *type_str, int *type_pos) { + _dbus_type_signature_next (_dbus_string_get_const_data (type_str), + type_pos); +} + +/** + * Skips to the next "complete" type inside a type signature. + * The signature is read starting at type_pos, and the next + * type position is stored in the same variable. + * + * @param type_str a type signature (must be valid) + * @param type_pos an integer position in the type signtaure (in and out) + */ +void +_dbus_type_signature_next (const char *type_str, + int *type_pos) +{ const unsigned char *p; const unsigned char *start; _dbus_assert (type_str != NULL); _dbus_assert (type_pos != NULL); - start = _dbus_string_get_const_data (type_str); + start = type_str; p = start + *type_pos; _dbus_assert (*p != DBUS_STRUCT_END_CHAR); @@ -1446,7 +1462,7 @@ _dbus_type_reader_set_basic (DBusTypeReader *reader, realign_root->value_pos); #endif - _dbus_assert (_dbus_type_is_basic (current_type)); + _dbus_assert (dbus_type_is_basic (current_type)); if (_dbus_type_is_fixed (current_type)) { @@ -2500,7 +2516,7 @@ writer_write_reader_helper (DBusTypeWriter *writer, while ((current_type = _dbus_type_reader_get_current_type (reader)) != DBUS_TYPE_INVALID) { - if (_dbus_type_is_container (current_type)) + if (dbus_type_is_container (current_type)) { DBusTypeReader subreader; DBusTypeWriter subwriter; @@ -2646,7 +2662,7 @@ writer_write_reader_helper (DBusTypeWriter *writer, { DBusBasicValue val; - _dbus_assert (_dbus_type_is_basic (current_type)); + _dbus_assert (dbus_type_is_basic (current_type)); #if RECURSIVE_MARSHAL_WRITE_TRACE _dbus_verbose ("Reading basic value %s at %d\n", |