mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-06-19 10:48:31 +02:00
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.
This commit is contained in:
parent
ee27481d7b
commit
2b97fb81a5
13 changed files with 200 additions and 241 deletions
57
ChangeLog
57
ChangeLog
|
|
@ -1,3 +1,60 @@
|
|||
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.
|
||||
|
||||
2005-02-26 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* doc/TODO: remove the "guid" item
|
||||
|
|
|
|||
|
|
@ -68,13 +68,15 @@ compute_marshaller (MethodInfo *method, GError **error)
|
|||
|
||||
if (arg_info_get_direction (arg) == ARG_IN)
|
||||
{
|
||||
const char *marshal_name = dbus_gvalue_genmarshal_name_from_type (arg_info_get_type (arg));
|
||||
const char *marshal_name;
|
||||
|
||||
marshal_name = dbus_gvalue_genmarshal_name_from_type (arg_info_get_type (arg));
|
||||
if (!marshal_name)
|
||||
{
|
||||
g_set_error (error,
|
||||
DBUS_BINDING_TOOL_ERROR,
|
||||
DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
|
||||
_("Unsupported conversion from D-BUS type %d to glib-genmarshal type"),
|
||||
_("Unsupported conversion from D-BUS type %s to glib-genmarshal type"),
|
||||
arg_info_get_type (arg));
|
||||
g_string_free (ret, TRUE);
|
||||
return NULL;
|
||||
|
|
@ -129,7 +131,7 @@ compute_marshaller_name (MethodInfo *method, GError **error)
|
|||
if (arg_info_get_direction (arg) == ARG_IN)
|
||||
{
|
||||
const char *marshal_name;
|
||||
int type;
|
||||
const char *type;
|
||||
|
||||
type = arg_info_get_type (arg);
|
||||
marshal_name = dbus_gvalue_genmarshal_name_from_type (type);
|
||||
|
|
@ -145,7 +147,7 @@ compute_marshaller_name (MethodInfo *method, GError **error)
|
|||
}
|
||||
|
||||
g_string_append (ret, "_");
|
||||
g_string_append (ret, dbus_gvalue_genmarshal_name_from_type (arg_info_get_type (arg)));
|
||||
g_string_append (ret, dbus_gvalue_genmarshal_name_from_type (type));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -385,7 +387,7 @@ generate_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error)
|
|||
g_string_append_c (object_introspection_data_blob, direction);
|
||||
g_string_append_c (object_introspection_data_blob, '\0');
|
||||
|
||||
g_string_append_c (object_introspection_data_blob, arg_info_get_type (arg));
|
||||
g_string_append (object_introspection_data_blob, arg_info_get_type (arg));
|
||||
g_string_append_c (object_introspection_data_blob, '\0');
|
||||
}
|
||||
|
||||
|
|
@ -608,7 +610,6 @@ write_formal_parameters (InterfaceInfo *iface, MethodInfo *method, GIOChannel *c
|
|||
|
||||
direction = arg_info_get_direction (arg);
|
||||
|
||||
/* FIXME - broken for containers */
|
||||
type_str = dbus_gvalue_ctype_from_type (arg_info_get_type (arg), direction == ARG_IN);
|
||||
|
||||
if (!type_str)
|
||||
|
|
@ -616,7 +617,7 @@ write_formal_parameters (InterfaceInfo *iface, MethodInfo *method, GIOChannel *c
|
|||
g_set_error (error,
|
||||
DBUS_BINDING_TOOL_ERROR,
|
||||
DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
|
||||
_("Unsupported conversion from D-BUS type %d to glib C type"),
|
||||
_("Unsupported conversion from D-BUS type %s to glib C type"),
|
||||
arg_info_get_type (arg));
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -660,15 +661,14 @@ write_args_for_direction (InterfaceInfo *iface, MethodInfo *method, GIOChannel *
|
|||
if (direction != arg_info_get_direction (arg))
|
||||
continue;
|
||||
|
||||
/* FIXME - broken for containers */
|
||||
type_str = dbus_gvalue_binding_type_from_type (arg_info_get_type (arg));
|
||||
if (!type_str)
|
||||
{
|
||||
g_set_error (error,
|
||||
DBUS_BINDING_TOOL_ERROR,
|
||||
DBUS_BINDING_TOOL_ERROR_UNSUPPORTED_CONVERSION,
|
||||
_("Unsupported conversion from D-BUS type %c"),
|
||||
(char) arg_info_get_type (arg));
|
||||
_("Unsupported conversion from D-BUS type %s"),
|
||||
arg_info_get_type (arg));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,14 +66,14 @@ struct SignalInfo
|
|||
struct PropertyInfo
|
||||
{
|
||||
BaseInfo base;
|
||||
int type;
|
||||
char *type;
|
||||
PropertyAccessFlags access;
|
||||
};
|
||||
|
||||
struct ArgInfo
|
||||
{
|
||||
BaseInfo base;
|
||||
int type;
|
||||
char *type;
|
||||
ArgDirection direction;
|
||||
};
|
||||
|
||||
|
|
@ -631,7 +631,7 @@ signal_info_add_arg (SignalInfo *info,
|
|||
|
||||
PropertyInfo*
|
||||
property_info_new (const char *name,
|
||||
int type,
|
||||
const char *type,
|
||||
PropertyAccessFlags access)
|
||||
{
|
||||
PropertyInfo *info;
|
||||
|
|
@ -641,7 +641,7 @@ property_info_new (const char *name,
|
|||
info->base.name = g_strdup (name);
|
||||
info->base.type = INFO_TYPE_PROPERTY;
|
||||
|
||||
info->type = type;
|
||||
info->type = g_strdup (type);
|
||||
info->access = access;
|
||||
|
||||
return info;
|
||||
|
|
@ -662,6 +662,7 @@ property_info_unref (PropertyInfo *info)
|
|||
if (info->base.refcount == 0)
|
||||
{
|
||||
base_info_free (info);
|
||||
g_free (info->type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -671,7 +672,7 @@ property_info_get_name (PropertyInfo *info)
|
|||
return info->base.name;
|
||||
}
|
||||
|
||||
int
|
||||
const char *
|
||||
property_info_get_type (PropertyInfo *info)
|
||||
{
|
||||
return info->type;
|
||||
|
|
@ -686,7 +687,7 @@ property_info_get_access (PropertyInfo *info)
|
|||
ArgInfo*
|
||||
arg_info_new (const char *name,
|
||||
ArgDirection direction,
|
||||
int type)
|
||||
const char *type)
|
||||
{
|
||||
ArgInfo *info;
|
||||
|
||||
|
|
@ -697,7 +698,7 @@ arg_info_new (const char *name,
|
|||
/* name can be NULL */
|
||||
info->base.name = g_strdup (name);
|
||||
info->direction = direction;
|
||||
info->type = type;
|
||||
info->type = g_strdup (type);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
|
@ -717,6 +718,7 @@ arg_info_unref (ArgInfo *info)
|
|||
if (info->base.refcount == 0)
|
||||
{
|
||||
base_info_free (info);
|
||||
g_free (info->type);
|
||||
}
|
||||
}
|
||||
const char*
|
||||
|
|
@ -725,7 +727,7 @@ arg_info_get_name (ArgInfo *info)
|
|||
return info->base.name;
|
||||
}
|
||||
|
||||
int
|
||||
const char *
|
||||
arg_info_get_type (ArgInfo *info)
|
||||
{
|
||||
return info->type;
|
||||
|
|
|
|||
|
|
@ -128,20 +128,20 @@ void signal_info_add_arg (SignalInfo *info,
|
|||
ArgInfo *arg);
|
||||
int signal_info_get_n_args (SignalInfo *info);
|
||||
PropertyInfo* property_info_new (const char *name,
|
||||
int type,
|
||||
const char *type,
|
||||
PropertyAccessFlags access);
|
||||
PropertyInfo* property_info_ref (PropertyInfo *info);
|
||||
void property_info_unref (PropertyInfo *info);
|
||||
const char* property_info_get_name (PropertyInfo *info);
|
||||
int property_info_get_type (PropertyInfo *info);
|
||||
const char* property_info_get_type (PropertyInfo *info);
|
||||
PropertyAccessFlags property_info_get_access (PropertyInfo *info);
|
||||
ArgInfo* arg_info_new (const char *name,
|
||||
ArgDirection direction,
|
||||
int type);
|
||||
const char *type);
|
||||
ArgInfo* arg_info_ref (ArgInfo *info);
|
||||
void arg_info_unref (ArgInfo *info);
|
||||
const char* arg_info_get_name (ArgInfo *info);
|
||||
int arg_info_get_type (ArgInfo *info);
|
||||
const char* arg_info_get_type (ArgInfo *info);
|
||||
ArgDirection arg_info_get_direction (ArgInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
|||
|
|
@ -177,13 +177,13 @@ pretty_print (BaseInfo *base,
|
|||
case INFO_TYPE_PROPERTY:
|
||||
{
|
||||
PropertyInfo *a = (PropertyInfo*) base;
|
||||
int pt = property_info_get_type (a);
|
||||
const char *pt = property_info_get_type (a);
|
||||
PropertyAccessFlags acc = property_info_get_access (a);
|
||||
|
||||
printf ("%s%s %s",
|
||||
acc & PROPERTY_READ ? "read" : "",
|
||||
acc & PROPERTY_WRITE ? "write" : "",
|
||||
_dbus_gutils_type_to_string (pt));
|
||||
pt);
|
||||
if (name)
|
||||
printf (" %s\n", name);
|
||||
else
|
||||
|
|
@ -193,12 +193,12 @@ pretty_print (BaseInfo *base,
|
|||
case INFO_TYPE_ARG:
|
||||
{
|
||||
ArgInfo *a = (ArgInfo*) base;
|
||||
int at = arg_info_get_type (a);
|
||||
const char *at = arg_info_get_type (a);
|
||||
ArgDirection d = arg_info_get_direction (a);
|
||||
|
||||
printf ("%s %s",
|
||||
d == ARG_IN ? "in" : "out",
|
||||
_dbus_gutils_type_to_string (at));
|
||||
at);
|
||||
if (name)
|
||||
printf (" %s\n", name);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -247,47 +247,6 @@ gobject_unregister_function (DBusConnection *connection,
|
|||
|
||||
}
|
||||
|
||||
static int
|
||||
gtype_to_dbus_type (GType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case G_TYPE_CHAR:
|
||||
case G_TYPE_UCHAR:
|
||||
return DBUS_TYPE_BYTE;
|
||||
|
||||
case G_TYPE_BOOLEAN:
|
||||
return DBUS_TYPE_BOOLEAN;
|
||||
|
||||
/* 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;
|
||||
case G_TYPE_ULONG:
|
||||
case G_TYPE_UINT:
|
||||
return DBUS_TYPE_UINT32;
|
||||
|
||||
case G_TYPE_INT64:
|
||||
return DBUS_TYPE_INT64;
|
||||
|
||||
case G_TYPE_UINT64:
|
||||
return DBUS_TYPE_UINT64;
|
||||
|
||||
case G_TYPE_FLOAT:
|
||||
case G_TYPE_DOUBLE:
|
||||
return DBUS_TYPE_DOUBLE;
|
||||
|
||||
case G_TYPE_STRING:
|
||||
return DBUS_TYPE_STRING;
|
||||
|
||||
default:
|
||||
return DBUS_TYPE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
introspect_properties (GObject *object, GString *xml)
|
||||
{
|
||||
|
|
@ -303,13 +262,13 @@ introspect_properties (GObject *object, GString *xml)
|
|||
for (i = 0; i < n_specs; i++ )
|
||||
{
|
||||
char *s;
|
||||
int dbus_type;
|
||||
const char *dbus_type;
|
||||
gboolean can_set;
|
||||
gboolean can_get;
|
||||
GParamSpec *spec = specs[i];
|
||||
|
||||
dbus_type = gtype_to_dbus_type (G_PARAM_SPEC_VALUE_TYPE (spec));
|
||||
if (dbus_type == DBUS_TYPE_INVALID)
|
||||
dbus_type = dbus_gtype_to_dbus_type (G_PARAM_SPEC_VALUE_TYPE (spec));
|
||||
if (dbus_type == NULL)
|
||||
continue;
|
||||
|
||||
if (spec->owner_type != last_type)
|
||||
|
|
@ -341,7 +300,7 @@ introspect_properties (GObject *object, GString *xml)
|
|||
g_string_append (xml, " <property name=\"");
|
||||
g_string_append (xml, s);
|
||||
g_string_append (xml, "\" type=\"");
|
||||
g_string_append (xml, _dbus_gutils_type_to_string (dbus_type));
|
||||
g_string_append (xml, dbus_type);
|
||||
g_string_append (xml, "\" access=\"");
|
||||
|
||||
if (can_set && can_get)
|
||||
|
|
@ -397,10 +356,10 @@ introspect_signals (GType type, GString *xml)
|
|||
|
||||
for (arg = 0; arg < query.n_params; arg++)
|
||||
{
|
||||
int dbus_type = gtype_to_dbus_type (query.param_types[arg]);
|
||||
const char *dbus_type = dbus_gtype_to_dbus_type (query.param_types[arg]);
|
||||
|
||||
g_string_append (xml, " <arg type=\"");
|
||||
g_string_append (xml, _dbus_gutils_type_to_string (dbus_type));
|
||||
g_string_append (xml, dbus_type);
|
||||
g_string_append (xml, "\"/>\n");
|
||||
}
|
||||
|
||||
|
|
@ -455,7 +414,7 @@ write_interface (gpointer key, gpointer val, gpointer user_data)
|
|||
|
||||
/* FIXME - handle container types */
|
||||
g_string_append_printf (xml, " <arg name=\"%s\" type=\"%s\" direction=\"%s\"/>\n",
|
||||
name, _dbus_gutils_type_to_string (type[0]), arg_in ? "in" : "out");
|
||||
name, type, arg_in ? "in" : "out");
|
||||
|
||||
}
|
||||
g_string_append (xml, " </method>\n");
|
||||
|
|
@ -543,21 +502,21 @@ handle_introspect (DBusConnection *connection,
|
|||
/* We are introspectable, though I guess that was pretty obvious */
|
||||
g_string_append_printf (xml, " <interface name=\"%s\">\n", DBUS_INTERFACE_INTROSPECTABLE);
|
||||
g_string_append (xml, " <method name=\"Introspect\">\n");
|
||||
g_string_append (xml, " <arg name=\"data\" direction=\"out\" type=\"string\"/>\n");
|
||||
g_string_append_printf (xml, " <arg name=\"data\" direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
|
||||
g_string_append (xml, " </method>\n");
|
||||
g_string_append (xml, " </interface>\n");
|
||||
|
||||
/* We support get/set properties */
|
||||
g_string_append_printf (xml, " <interface name=\"%s\">\n", DBUS_INTERFACE_PROPERTIES);
|
||||
g_string_append (xml, " <method name=\"Get\">\n");
|
||||
g_string_append (xml, " <arg name=\"interface\" direction=\"in\" type=\"string\"/>\n");
|
||||
g_string_append (xml, " <arg name=\"propname\" direction=\"in\" type=\"string\"/>\n");
|
||||
g_string_append (xml, " <arg name=\"value\" direction=\"out\" type=\"variant\"/>\n");
|
||||
g_string_append_printf (xml, " <arg name=\"interface\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
|
||||
g_string_append_printf (xml, " <arg name=\"propname\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
|
||||
g_string_append_printf (xml, " <arg name=\"value\" direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_VARIANT_AS_STRING);
|
||||
g_string_append (xml, " </method>\n");
|
||||
g_string_append (xml, " <method name=\"Set\">\n");
|
||||
g_string_append (xml, " <arg name=\"interface\" direction=\"in\" type=\"string\"/>\n");
|
||||
g_string_append (xml, " <arg name=\"propname\" direction=\"in\" type=\"string\"/>\n");
|
||||
g_string_append (xml, " <arg name=\"value\" direction=\"in\" type=\"variant\"/>\n");
|
||||
g_string_append_printf (xml, " <arg name=\"interface\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
|
||||
g_string_append_printf (xml, " <arg name=\"propname\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING);
|
||||
g_string_append_printf (xml, " <arg name=\"value\" direction=\"in\" type=\"%s\"/>\n", DBUS_TYPE_VARIANT_AS_STRING);
|
||||
g_string_append (xml, " </method>\n");
|
||||
g_string_append (xml, " </interface>\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@
|
|||
*
|
||||
*/
|
||||
#include "dbus-gparser.h"
|
||||
#include "dbus/dbus-glib-lowlevel.h"
|
||||
#include "dbus-gidl.h"
|
||||
#include "dbus/dbus-signature.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <libintl.h>
|
||||
|
|
@ -461,59 +463,21 @@ parse_signal (Parser *parser,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
basic_type_from_string (const char *str)
|
||||
static gboolean
|
||||
validate_signature (const char *str,
|
||||
const char *element_name,
|
||||
GError **error)
|
||||
{
|
||||
if (strcmp (str, "string") == 0)
|
||||
return DBUS_TYPE_STRING;
|
||||
else if (strcmp (str, "int16") == 0)
|
||||
return DBUS_TYPE_INT16;
|
||||
else if (strcmp (str, "uint16") == 0)
|
||||
return DBUS_TYPE_UINT16;
|
||||
else if (strcmp (str, "int32") == 0)
|
||||
return DBUS_TYPE_INT32;
|
||||
else if (strcmp (str, "uint32") == 0)
|
||||
return DBUS_TYPE_UINT32;
|
||||
else if (strcmp (str, "int64") == 0)
|
||||
return DBUS_TYPE_INT64;
|
||||
else if (strcmp (str, "uint64") == 0)
|
||||
return DBUS_TYPE_UINT64;
|
||||
else if (strcmp (str, "double") == 0)
|
||||
return DBUS_TYPE_DOUBLE;
|
||||
else if (strcmp (str, "byte") == 0)
|
||||
return DBUS_TYPE_BYTE;
|
||||
else if (strcmp (str, "boolean") == 0)
|
||||
return DBUS_TYPE_BOOLEAN;
|
||||
else if (strcmp (str, "byte") == 0)
|
||||
return DBUS_TYPE_BYTE;
|
||||
else if (strcmp (str, "object") == 0)
|
||||
return DBUS_TYPE_OBJECT_PATH;
|
||||
else if (strcmp (str, "variant") == 0)
|
||||
return DBUS_TYPE_VARIANT;
|
||||
else
|
||||
return DBUS_TYPE_INVALID;
|
||||
}
|
||||
DBusError derror;
|
||||
|
||||
/* FIXME we have to allow type signatures, not just basic types
|
||||
*/
|
||||
static int
|
||||
type_from_string (const char *str,
|
||||
const char *element_name,
|
||||
GError **error)
|
||||
{
|
||||
int t;
|
||||
dbus_error_init (&derror);
|
||||
|
||||
t = basic_type_from_string (str);
|
||||
|
||||
if (t == DBUS_TYPE_INVALID)
|
||||
if (!dbus_signature_validate (str, &derror))
|
||||
{
|
||||
g_set_error (error, G_MARKUP_ERROR,
|
||||
G_MARKUP_ERROR_PARSE,
|
||||
_("Type \"%s\" not understood on <%s> element "),
|
||||
str, element_name);
|
||||
dbus_set_g_error (error, &derror);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return t;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -529,7 +493,6 @@ parse_property (Parser *parser,
|
|||
PropertyInfo *property;
|
||||
NodeInfo *top;
|
||||
PropertyAccessFlags access_flags;
|
||||
int t;
|
||||
|
||||
if (parser->interface == NULL ||
|
||||
parser->node_stack == NULL ||
|
||||
|
|
@ -582,8 +545,7 @@ parse_property (Parser *parser,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
t = type_from_string (type, element_name, error);
|
||||
if (t == DBUS_TYPE_INVALID)
|
||||
if (!validate_signature (type, element_name, error))
|
||||
return FALSE;
|
||||
|
||||
access_flags = 0;
|
||||
|
|
@ -604,7 +566,7 @@ parse_property (Parser *parser,
|
|||
|
||||
top = parser->node_stack->data;
|
||||
|
||||
property = property_info_new (name, t, access_flags);
|
||||
property = property_info_new (name, type, access_flags);
|
||||
interface_info_add_property (parser->interface, property);
|
||||
property_info_unref (property);
|
||||
|
||||
|
|
@ -624,7 +586,6 @@ parse_arg (Parser *parser,
|
|||
const char *type;
|
||||
const char *direction;
|
||||
ArgDirection dir;
|
||||
int t;
|
||||
ArgInfo *arg;
|
||||
char *generated_name;
|
||||
|
||||
|
|
@ -694,8 +655,7 @@ parse_arg (Parser *parser,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
t = type_from_string (type, element_name, error);
|
||||
if (t == DBUS_TYPE_INVALID)
|
||||
if (!validate_signature (type, element_name, error))
|
||||
return FALSE;
|
||||
|
||||
generated_name = NULL;
|
||||
|
|
@ -706,7 +666,7 @@ parse_arg (Parser *parser,
|
|||
signal_info_get_n_args (parser->signal));
|
||||
|
||||
|
||||
arg = arg_info_new (name ? name : generated_name, dir, t);
|
||||
arg = arg_info_new (name ? name : generated_name, dir, type);
|
||||
if (parser->method)
|
||||
method_info_add_arg (parser->method, arg);
|
||||
else if (parser->signal)
|
||||
|
|
|
|||
|
|
@ -83,48 +83,6 @@ _dbus_gutils_split_path (const char *path)
|
|||
return split;
|
||||
}
|
||||
|
||||
const char *
|
||||
_dbus_gutils_type_to_string (int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DBUS_TYPE_INVALID:
|
||||
return "invalid";
|
||||
case DBUS_TYPE_BOOLEAN:
|
||||
return "boolean";
|
||||
case DBUS_TYPE_BYTE:
|
||||
return "byte";
|
||||
case DBUS_TYPE_INT16:
|
||||
return "int16";
|
||||
case DBUS_TYPE_UINT16:
|
||||
return "uint16";
|
||||
case DBUS_TYPE_INT32:
|
||||
return "int32";
|
||||
case DBUS_TYPE_UINT32:
|
||||
return "uint32";
|
||||
case DBUS_TYPE_DOUBLE:
|
||||
return "double";
|
||||
case DBUS_TYPE_STRING:
|
||||
return "string";
|
||||
case DBUS_TYPE_OBJECT_PATH:
|
||||
return "object_path";
|
||||
case DBUS_TYPE_SIGNATURE:
|
||||
return "signature";
|
||||
case DBUS_TYPE_STRUCT:
|
||||
return "struct";
|
||||
case DBUS_TYPE_ARRAY:
|
||||
return "array";
|
||||
case DBUS_TYPE_VARIANT:
|
||||
return "variant";
|
||||
case DBUS_STRUCT_BEGIN_CHAR:
|
||||
return "begin_struct";
|
||||
case DBUS_STRUCT_END_CHAR:
|
||||
return "end_struct";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
char*
|
||||
_dbus_gutils_wincaps_to_uscore (const char *caps)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
char **_dbus_gutils_split_path (const char *path);
|
||||
const char *_dbus_gutils_type_to_string (int type);
|
||||
|
||||
char *_dbus_gutils_wincaps_to_uscore (const char *uscore);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
const char *
|
||||
dbus_gvalue_genmarshal_name_from_type (int type)
|
||||
/* 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 (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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,11 +20,13 @@ typedef union
|
|||
char * chararray_val;
|
||||
} DBusBasicGValue;
|
||||
|
||||
const char * dbus_gvalue_genmarshal_name_from_type (int type);
|
||||
const char * dbus_gvalue_genmarshal_name_from_type (const char *type);
|
||||
|
||||
const char * dbus_gvalue_ctype_from_type (int type, gboolean in);
|
||||
const char * dbus_gvalue_ctype_from_type (const char *type, gboolean in);
|
||||
|
||||
const char * dbus_gvalue_binding_type_from_type (int type);
|
||||
const char * dbus_gvalue_binding_type_from_type (const char *type);
|
||||
|
||||
const char * dbus_gtype_to_dbus_type (GType type);
|
||||
|
||||
gboolean dbus_gvalue_init (int type,
|
||||
GValue *value);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
<method name="Increment">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="my_object_increment"/>
|
||||
<arg type="uint32" name="x" />
|
||||
<arg type="uint32" direction="out" />
|
||||
<arg type="u" name="x" />
|
||||
<arg type="u" direction="out" />
|
||||
</method>
|
||||
|
||||
<method name="ThrowError">
|
||||
|
|
@ -21,17 +21,17 @@
|
|||
|
||||
<method name="Uppercase">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="my_object_uppercase"/>
|
||||
<arg type="string" direction="in" />
|
||||
<arg type="string" direction="out" />
|
||||
<arg type="s" direction="in" />
|
||||
<arg type="s" direction="out" />
|
||||
</method>
|
||||
|
||||
<method name="ManyArgs">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="my_object_many_args"/>
|
||||
<arg type="uint32" name="x" direction="in" />
|
||||
<arg type="string" name="str" direction="in" />
|
||||
<arg type="double" name="trouble" direction="in" />
|
||||
<arg type="double" name="d_ret" direction="out" />
|
||||
<arg type="string" name="str_ret" direction="out" />
|
||||
<arg type="u" name="x" direction="in" />
|
||||
<arg type="s" name="str" direction="in" />
|
||||
<arg type="d" name="trouble" direction="in" />
|
||||
<arg type="d" name="d_ret" direction="out" />
|
||||
<arg type="s" name="str_ret" direction="out" />
|
||||
</method>
|
||||
|
||||
</interface>
|
||||
|
|
|
|||
|
|
@ -25,49 +25,6 @@
|
|||
#include "dbus-tree-view.h"
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
/* FIXME this function should just be in the library */
|
||||
static const char *
|
||||
type_to_string (int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DBUS_TYPE_INVALID:
|
||||
return "invalid";
|
||||
case DBUS_TYPE_BOOLEAN:
|
||||
return "boolean";
|
||||
case DBUS_TYPE_BYTE:
|
||||
return "byte";
|
||||
case DBUS_TYPE_INT16:
|
||||
return "int16";
|
||||
case DBUS_TYPE_UINT16:
|
||||
return "uint16";
|
||||
case DBUS_TYPE_INT32:
|
||||
return "int32";
|
||||
case DBUS_TYPE_UINT32:
|
||||
return "uint32";
|
||||
case DBUS_TYPE_DOUBLE:
|
||||
return "double";
|
||||
case DBUS_TYPE_STRING:
|
||||
return "string";
|
||||
case DBUS_TYPE_OBJECT_PATH:
|
||||
return "object_path";
|
||||
case DBUS_TYPE_SIGNATURE:
|
||||
return "signature";
|
||||
case DBUS_TYPE_STRUCT:
|
||||
return "struct";
|
||||
case DBUS_TYPE_ARRAY:
|
||||
return "array";
|
||||
case DBUS_TYPE_VARIANT:
|
||||
return "variant";
|
||||
case DBUS_STRUCT_BEGIN_CHAR:
|
||||
return "begin_struct";
|
||||
case DBUS_STRUCT_END_CHAR:
|
||||
return "end_struct";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
MODEL_COLUMN_INFO,
|
||||
|
|
@ -334,14 +291,14 @@ info_set_func_text (GtkTreeViewColumn *tree_column,
|
|||
case INFO_TYPE_PROPERTY:
|
||||
g_string_append (str, "<i>property</i>");
|
||||
g_string_append_printf (str, " <b>%s</b>",
|
||||
type_to_string (property_info_get_type ((PropertyInfo*)info)));
|
||||
property_info_get_type ((PropertyInfo*)info));
|
||||
break;
|
||||
case INFO_TYPE_ARG:
|
||||
g_string_append_printf (str, "<i>arg</i> %s",
|
||||
arg_info_get_direction ((ArgInfo*)info) == ARG_IN ?
|
||||
"in" : "out");
|
||||
g_string_append_printf (str, " <b>%s</b>",
|
||||
type_to_string (arg_info_get_type ((ArgInfo*)info)));
|
||||
arg_info_get_type ((ArgInfo*)info));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue