diff options
author | Colin Walters <walters@verbum.org> | 2005-02-27 17:38:12 +0000 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2005-02-27 17:38:12 +0000 |
commit | 2b97fb81a508a047b14f4c4426c28abfd18bb2e0 (patch) | |
tree | d44ef7f2fe5d373ac44e3a41add8bd3f08e2a8fc /glib/dbus-gvalue.c | |
parent | ee27481d7b7d6d9a4f41b7d641a2618dedf676dd (diff) |
2005-02-27 Colin Walters <walters@verbum.org>
* glib/dbus-gidl.c (property_info_get_type, arg_info_get_type):
Change return value to const char * instead of int so we can do
full signatures.
(struct PropertyInfo, struct ArgInfo): Store char *.
(property_info_new, arg_info_new): Update parameters, strdup.
(property_info_unref, arg_info_unref): Free.
* glib/dbus-gidl.h: Update prototypes.
* glib/dbus-gparser.c (basic_type_from_string): Delete.
(validate_signature): New function, just validates signature and
sets GError.
(parse_property, parse_arg): Invoke validate_signature. Store
signature instead of just type code.
* glib/dbus-gvalue.c (base_type_from_signature): New utility
function to return a primary type for a signature, dropping
information about types in container types.
(dbus_gvalue_genmarshal_name_from_type)
(dbus_gvalue_binding_type_from_type)
(dbus_gvalue_ctype_from_type): Update to take full signature
instead of type code.
(dbus_gtype_to_dbus_type): Moved here from glib/dbus-gobject.c.
* glib/dbus-gvalue.h: Update prototypes for above.
* glib/dbus-gobject.c (gtype_to_dbus_type): Moved to
glib/dbus-gvalue.c as dbus_gtype_to_dbus_type.
(introspect_properties, introspect_signals, write_interface):
Update to handle signatures, and remove usage of
_dbus_gutils_type_to_string.
(handle_introspect): Print out type codes instead of e.g. "string"
in hardcoded introspection XML; also use x_AS_STRING constants
instead of hardcoding in string.
* glib/dbus-glib-tool.c (pretty_print): Handle signature change
to string. Remove usage of _dbus_gutils_type_to_string.
* glib/dbus-gutils.c (_dbus_gutils_type_to_string): Delete.
* glib/dbus-gutils.h (_dbus_gutils_type_to_string): Update for
deletion.
* glib/dbus-binding-tool-glib.c (compute_marshaller)
(compute_marshaller_name, generate_glue): Handle signature change
to string.
(write_formal_parameters, write_args_for_direction): Ditto, and
remove FIXME.
* tools/dbus-tree-view.c (type_to_string): Delete.
(info_set_func_text): Update to print full signatures.
* test/glib/test-service-glib.xml: Change types to new
introspection format.
Diffstat (limited to 'glib/dbus-gvalue.c')
-rw-r--r-- | glib/dbus-gvalue.c | 71 |
1 files changed, 68 insertions, 3 deletions
diff --git a/glib/dbus-gvalue.c b/glib/dbus-gvalue.c index 8306be9b..bcda9259 100644 --- a/glib/dbus-gvalue.c +++ b/glib/dbus-gvalue.c @@ -23,6 +23,7 @@ */ #include <dbus-gvalue.h> +#include "dbus/dbus-signature.h" /* This is slightly evil, we don't use g_value_set_foo() functions */ #define MAP_BASIC_INIT(d_t, g_t) \ @@ -71,9 +72,24 @@ dbus_gvalue_init (int type, return can_convert; } +/* FIXME - broken for containers + */ +static int +base_type_from_signature (const char *signature) +{ + DBusSignatureIter iter; + + dbus_signature_iter_init (&iter, signature); + + return dbus_signature_iter_get_current_type (&iter); +} + const char * -dbus_gvalue_genmarshal_name_from_type (int type) +dbus_gvalue_genmarshal_name_from_type (const char *signature) { + int type; + + type = base_type_from_signature (signature); switch (type) { case DBUS_TYPE_BOOLEAN: @@ -109,8 +125,12 @@ dbus_gvalue_genmarshal_name_from_type (int type) } const char * -dbus_gvalue_binding_type_from_type (int type) +dbus_gvalue_binding_type_from_type (const char *signature) { + int type; + + type = base_type_from_signature (signature); + #define STRINGIFY(x) \ case x: \ return (#x) @@ -142,8 +162,12 @@ dbus_gvalue_binding_type_from_type (int type) } const char * -dbus_gvalue_ctype_from_type (int type, gboolean in) +dbus_gvalue_ctype_from_type (const char *signature, gboolean in) { + int type; + + type = base_type_from_signature (signature); + switch (type) { case DBUS_TYPE_BOOLEAN: @@ -181,6 +205,47 @@ dbus_gvalue_ctype_from_type (int type, gboolean in) return NULL; } +const char * +dbus_gtype_to_dbus_type (GType type) +{ + switch (type) + { + case G_TYPE_CHAR: + case G_TYPE_UCHAR: + return DBUS_TYPE_BYTE_AS_STRING; + + case G_TYPE_BOOLEAN: + return DBUS_TYPE_BOOLEAN_AS_STRING; + + /* long gets cut to 32 bits so the remote API is consistent + * on all architectures + */ + + case G_TYPE_LONG: + case G_TYPE_INT: + return DBUS_TYPE_INT32_AS_STRING; + case G_TYPE_ULONG: + case G_TYPE_UINT: + return DBUS_TYPE_UINT32_AS_STRING; + + case G_TYPE_INT64: + return DBUS_TYPE_INT64_AS_STRING; + + case G_TYPE_UINT64: + return DBUS_TYPE_UINT64_AS_STRING; + + case G_TYPE_FLOAT: + case G_TYPE_DOUBLE: + return DBUS_TYPE_DOUBLE_AS_STRING; + + case G_TYPE_STRING: + return DBUS_TYPE_STRING_AS_STRING; + + default: + return NULL; + } +} + gboolean dbus_gvalue_demarshal (DBusMessageIter *iter, GValue *value) { |