summaryrefslogtreecommitdiffstats
path: root/glib/dbus-binding-tool-glib.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2005-06-17 14:29:48 +0000
committerColin Walters <walters@verbum.org>2005-06-17 14:29:48 +0000
commit949436ffac9e46649398e1bc9f0ddf567c88dd1c (patch)
treed8bad3f3ffa5813a7e99726b66bba3de8aafc319 /glib/dbus-binding-tool-glib.c
parent679018f00c7277ecd6272cb1be5dfdedf134c422 (diff)
2005-06-17 Colin Walters <walters@verbum.org>
* glib/dbus-gproxy.c (dbus_g_proxy_emit_remote_signal): Don't spew warnings if we get malformed remote signals. * glib/dbus-gobject.c (propsig_iterate): New function. (lookup_object_info): New function, extracted from lookup_object_and_method. (introspect_properties, introspect_signals): Delete; these are merged into write_interface. (write_interface): Write out signals and properties here; dump the org.gtk.object stuff and use the interface given in the introspection data blob. Also fix up property XML. (lookup_values): New function. (introspect_interfaces): Gather a mapping from interface to a list of its methods, signals, and properties, then write out each interface. (lookup_object_and_method): Use lookup_object_info. (struct DBusGSignalClosure): Add interface. (dbus_g_signal_closure_new): Add interface. Don't dup signame; we can just use the constant data. (dbus_g_signal_closure_finalize): Don't free signal name. (signal_emitter_marshaller): Use interface from signal closure. (export_signals): Only export signals mentioned in introspection blob. (dbus_g_connection_register_g_object): Warn if we have no introspection data for an object. (funcsig_equal): Remove unused variable. (dbus_g_object_register_marshaller): Take varargs instead of list. (dbus_g_object_register_marshaller_array): New function, extracted from old dbus_g_object_register_marshaller. * glib/dbus-binding-tool-glib.c (struct DBusBindingToolCData): Add signals and property data. (write_quoted_string): New function, extracted from generate_glue. (generate_glue): Write signals and properties to introspection blob. * dbus/dbus-glib.h (struct DBusGObjectInfo): Include exported_signals and exported_properties. (dbus_g_object_register_marshaller): Update prototype. (dbus_g_object_register_marshaller_array): Prototype. * test/glib/test-dbus-glib.c: Extend testing to cover new signals. * test/glib/test-service-glib.c: Add new test signals and method to emit them. * test/glib/test-service-glib.xml: Add some test signals. * test/glib/Makefile.am (BUILT_SOURCES): Add my-object-marshal.c and my-object-marshal.h (test_service_glib_SOURCES, test_dbus_glib_SOURCES): Add my-object-marshal.c. (my-object-marshal.c, my-object-marshal.h): Implement. * test/glib/.cvsignore: Update. * doc/TODO: Remove two GLib TODO items fixed by this patch.
Diffstat (limited to 'glib/dbus-binding-tool-glib.c')
-rw-r--r--glib/dbus-binding-tool-glib.c88
1 files changed, 72 insertions, 16 deletions
diff --git a/glib/dbus-binding-tool-glib.c b/glib/dbus-binding-tool-glib.c
index b04386bc..fd849a86 100644
--- a/glib/dbus-binding-tool-glib.c
+++ b/glib/dbus-binding-tool-glib.c
@@ -48,6 +48,8 @@ typedef struct
GHashTable *generated;
GString *blob;
+ GString *signal_blob;
+ GString *property_blob;
guint count;
} DBusBindingToolCData;
@@ -365,13 +367,37 @@ write_printf_to_iochannel (const char *fmt, GIOChannel *channel, GError **error,
}
static gboolean
+write_quoted_string (GIOChannel *channel, GString *string, GError **error)
+{
+ guint i;
+
+ WRITE_OR_LOSE ("\"");
+ for (i = 0; i < string->len; i++)
+ {
+ if (string->str[i] != '\0')
+ {
+ if (!g_io_channel_write_chars (channel, string->str + i, 1, NULL, error))
+ return FALSE;
+ }
+ else
+ {
+ if (!g_io_channel_write_chars (channel, "\\0", -1, NULL, error))
+ return FALSE;
+ }
+ }
+ WRITE_OR_LOSE ("\\0\"");
+ return TRUE;
+ io_lose:
+ return FALSE;
+}
+
+static gboolean
generate_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error)
{
if (base_info_get_type (base) == INFO_TYPE_NODE)
{
GString *object_introspection_data_blob;
GIOChannel *channel;
- guint i;
channel = data->channel;
@@ -380,6 +406,9 @@ generate_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error)
data->blob = object_introspection_data_blob;
data->count = 0;
+ data->signal_blob = g_string_new_len ("", 0);
+ data->property_blob = g_string_new_len ("", 0);
+
if (!write_printf_to_iochannel ("static const DBusGMethodInfo dbus_glib_%s_methods[] = {\n", channel, error, data->prefix))
goto io_lose;
@@ -402,29 +431,28 @@ generate_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error)
goto io_lose;
if (!write_printf_to_iochannel (" %d,\n", channel, error, data->count))
goto io_lose;
- WRITE_OR_LOSE(" \"");
- for (i = 0; i < object_introspection_data_blob->len; i++)
- {
- if (object_introspection_data_blob->str[i] != '\0')
- {
- if (!g_io_channel_write_chars (channel, object_introspection_data_blob->str + i, 1, NULL, error))
- return FALSE;
- }
- else
- {
- if (!g_io_channel_write_chars (channel, "\\0", -1, NULL, error))
- return FALSE;
- }
- }
- WRITE_OR_LOSE ("\"\n};\n\n");
+
+ if (!write_quoted_string (channel, object_introspection_data_blob, error))
+ goto io_lose;
+ WRITE_OR_LOSE (",\n");
+ if (!write_quoted_string (channel, data->signal_blob, error))
+ goto io_lose;
+ WRITE_OR_LOSE (",\n");
+ if (!write_quoted_string (channel, data->property_blob, error))
+ goto io_lose;
+ WRITE_OR_LOSE ("\n};\n\n");
g_string_free (object_introspection_data_blob, TRUE);
+ g_string_free (data->signal_blob, TRUE);
+ g_string_free (data->property_blob, TRUE);
}
else
{
GIOChannel *channel;
InterfaceInfo *interface;
GSList *methods;
+ GSList *signals;
+ GSList *properties;
GSList *tmp;
const char *interface_c_name;
GString *object_introspection_data_blob;
@@ -532,6 +560,34 @@ generate_glue (BaseInfo *base, DBusBindingToolCData *data, GError **error)
data->count++;
}
+
+ signals = interface_info_get_signals (interface);
+
+ for (tmp = signals; tmp != NULL; tmp = g_slist_next (tmp))
+ {
+ SignalInfo *sig;
+
+ sig = tmp->data;
+
+ g_string_append (data->signal_blob, interface_info_get_name (interface));
+ g_string_append_c (data->signal_blob, '\0');
+ g_string_append (data->signal_blob, signal_info_get_name (sig));
+ g_string_append_c (data->signal_blob, '\0');
+ }
+
+ properties = interface_info_get_properties (interface);
+
+ for (tmp = properties; tmp != NULL; tmp = g_slist_next (tmp))
+ {
+ PropertyInfo *prop;
+
+ prop = tmp->data;
+
+ g_string_append (data->property_blob, interface_info_get_name (interface));
+ g_string_append_c (data->property_blob, '\0');
+ g_string_append (data->property_blob, property_info_get_name (prop));
+ g_string_append_c (data->property_blob, '\0');
+ }
}
return TRUE;
io_lose: