exporting dbus-marshal-recursive.h
Colin Walters
walters at verbum.org
Sat Feb 19 09:58:55 PST 2005
On Fri, 2005-02-18 at 16:58 -0500, Havoc Pennington wrote:
>On Fri, 2005-02-18 at 15:55 -0500, Colin Walters wrote:
>>
>> Ok, I took a crack at this; patch attached. Includes tests.
>>
>
>Thanks!
>
>The iterator struct is huuuuuuuuuuge.
Yeah, the problem is that I need to store two large-ish structures both
of which could potentially grow substantially. I made an initial guess
about how large DBusStructureRealIter should be (including future
padding), and it wasn't even large enough to hold the existing
DBusString and DBusTypeReader.
>I suggest store only the sig
>length, not the DBusString. Then you can use
>_dbus_string_init_from_const_len (basically free) from each function. Or
>something, not sure.
Hmmm. The problem I see there is that I'd be declaring a new DBusString
object in the stack frame of each function (such as
dbus_signature_iter_get_current_type), but
_dbus_type_reader_init_types_only just stores a pointer to the
DBusString inside the DBusTypeReader structure from the initial call to
it. Thus, when calling a later function such as
dbus_signature_iter_get_current_type, the DBusTypeReader structure would
have a pointer to a value in the stack frame of the previously called
dbus_signature_iter_init, leading to undefined behavior.
I haven't actually tried, but I'm pretty sure it wouldn't work. Or am I
missing something?
Perhaps I could add a new internal function like
_dbus_type_reader_set_string_internal (...) which would just replace the
DBusString value while retaining everything else about the
DBusTypeReader such as the position? Seems a bit ugly too...
>static void run_test (TestFunc func, const char *test_name)
>{
> /* insert cut-and-pasted stuff */
>}
Ok, I fixed this.
In addition, this patch:
o Implements the human-readable format
- Added to documentation
- New methods dbus_signature_to_human_readable,
dbus_signature_from_human_readable
o Added method dbus_signature_typecode_is_basic, to know when to recurse
o Added dbus_signature_iter_init_validate which validates signature
o Added documentation for new signature bits
o Tests all the above
I think this API will work, but I need to actually use it in the glib
bindings to be sure.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbus-signature-2.patch
Type: text/x-patch
Size: 49713 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20050219/381baa5c/dbus-signature-2-0001.bin
More information about the dbus
mailing list