From 9b0fc4e482d6d7d9d6105d876fbbd2182e7b6dd3 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Wed, 29 Dec 2004 22:22:41 +0000 Subject: switch to a vtable approach for the reader --- dbus/dbus-marshal-recursive.h | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'dbus/dbus-marshal-recursive.h') diff --git a/dbus/dbus-marshal-recursive.h b/dbus/dbus-marshal-recursive.h index 8e5427bd..6d0a40b4 100644 --- a/dbus/dbus-marshal-recursive.h +++ b/dbus/dbus-marshal-recursive.h @@ -31,23 +31,10 @@ #error "config.h not included here" #endif -/* Notes on my plan to implement this: - * - also have DBusTypeWriter (heh) - * - TypeReader has accessors for: - * . basic type - * . array of basic type (efficiency hack) - * . another type reader - * - a dict will appear to be a list of string, whatever, string, whatever - * - a variant will contain another TypeReader - * - a struct will be a list of whatever, whatever, whatever - * - * So the basic API usage is to go next, next, next; if the - * item is a basic type or basic array then read the item; - * if it's another type reader then process it; if it's - * a container type (struct, array, variant, dict) then - * recurse. - * - */ +typedef struct DBusTypeReader DBusTypeReader; +typedef struct DBusTypeWriter DBusTypeWriter; +typedef struct DBusTypeReaderClass DBusTypeReaderClass; +typedef struct DBusTypeWriterClass DBusTypeWriterClass; struct DBusTypeReader { @@ -57,8 +44,7 @@ struct DBusTypeReader const DBusString *value_str; int value_pos; - /* Hmm - it might be cleaner to do TypeReaderClass *vtable for container type */ - int container_type; + const DBusTypeReaderClass *klass; union { struct { @@ -78,8 +64,6 @@ struct DBusTypeReader } u; }; -typedef struct DBusTypeReader DBusTypeReader; - struct DBusTypeWriter { int byte_order; @@ -90,6 +74,7 @@ struct DBusTypeWriter dbus_uint32_t inside_array : 1; + /* const DBusTypeWriterClass *klass; */ int container_type; union { @@ -107,8 +92,6 @@ struct DBusTypeWriter } u; }; -typedef struct DBusTypeWriter DBusTypeWriter; - void _dbus_type_reader_init (DBusTypeReader *reader, int byte_order, const DBusString *type_str, -- cgit